@neuralnomads/codenomad 0.7.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-CU67Zn6k.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/angular-ts-BwZT4LLn.js","assets/scss-OYdSNvt2.js","assets/apl-dKokRX4l.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-CbQHKStN.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-DVc8C-J4.js","assets/html-derivative-BFtXZ54Q.js","assets/sql-BLtJtn59.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nwyudZeR.js","assets/coffee-Ch7k5sss.js","assets/cpp-CofmeUqb.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-tKQVLTB8.js","assets/shellscript-Yzrsuije.js","assets/edge-BkV0erSs.js","assets/elixir-CDX3lj18.js","assets/elm-DbKCFpqz.js","assets/erb-BOJIQeun.js","assets/ruby-BvKwtOVI.js","assets/haml-B8DHNrY2.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BbnMAYS6.js","assets/yaml-Buea-lGh.js","assets/erlang-DsQrWhSR.js","assets/markdown-Cvjx9yec.js","assets/fortran-fixed-form-BZjJHVRy.js","assets/fortran-free-form-D22FLkUw.js","assets/fsharp-CXgrBDvD.js","assets/gdresource-B7Tvp0Sc.js","assets/gdshader-DkwncUOv.js","assets/gdscript-DTMYz4Jt.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-Rg0-pVw9.js","assets/glimmer-ts-U6CK756n.js","assets/hack-CaT9iCJl.js","assets/handlebars-BL8al0AC.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-4LBKfQ-Z.js","assets/jison-wvAkD_A8.js","assets/julia-C8NyazO9.js","assets/r-DiinP2Uv.js","assets/latex-BUKiar2Z.js","assets/tex-Cppo0RY3.js","assets/liquid-DYVedYrR.js","assets/marko-CPi9NSCl.js","assets/less-B1dDrJ26.js","assets/mdc-DUICxH0z.js","assets/nginx-DknmC5AR.js","assets/nim-CVrawwO9.js","assets/perl-C0TMdlhV.js","assets/php-CDn_0X-4.js","assets/pug-CGlum2m_.js","assets/qml-3beO22l8.js","assets/razor-WgofotgN.js","assets/csharp-CX12Zw3r.js","assets/rst-B0xPkSld.js","assets/cmake-D1j8_8rp.js","assets/sas-cz2c8ADy.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-Brmx7dQM.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-BH5u7GGu.js","assets/svelte-3Dk4HxPD.js","assets/templ-W15q3VgB.js","assets/go-Dn2_MT6a.js","assets/ts-tags-zn1MmPIZ.js","assets/twig-CO9l9SDP.js","assets/vue-CCoi5OLL.js","assets/vue-html-DAAvJJDi.js","assets/vue-vine-_Ih-lPRR.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js"])))=>i.map(i=>d[i]);
2
- var pw=Object.defineProperty;var EE=e=>{throw TypeError(e)};var hw=(e,t,n)=>t in e?pw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var X=(e,t,n)=>hw(e,typeof t!="symbol"?t+"":t,n),Ew=(e,t,n)=>t.has(e)||EE("Cannot "+n);var SE=(e,t,n)=>t.has(e)?EE("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var md=(e,t,n)=>(Ew(e,t,"access private method"),n);import{o as Ne,c as J,a as ne,b as F,$ as vc,u as Wr,d as vg,e as U,m as oe,s as lt,f as S,D as fu,g as Tn,h as qr,i as Jt,j as en,k as we,l as ci,P as l_,S as W,n as Ir,p as ur,q as yc,t as x,r as C,F as _t,v as ri,w as rt,M as sr,x as Wc,y as Ii,z as wt,A as Fe,B as Ht,C as Ci,E as vt,G as Fn,H as $a,I as by,J as $o,K as Sw,L as bw,N as vw,O as Mi,Q as yw,R as Tw,T as Cw,U as Rw}from"./index-D4j6wgeo.js";function Iw(e){return(...t)=>{for(const n of e)n&&n(...t)}}const pe=e=>typeof e=="function"&&!e.length?e():e,bE=e=>Array.isArray(e)?e:e?[e]:[];function Ow(e,...t){return typeof e=="function"?e(...t):e}const Nw=Ne;function Aw(e,t,n,r){return e.addEventListener(t,n,r),Nw(e.removeEventListener.bind(e,t,n,r))}function ww(e,t,n,r){const i=()=>{bE(pe(e)).forEach(s=>{s&&bE(pe(t)).forEach(o=>Aw(s,o,n,r))})};typeof e=="function"?J(i):ne(i)}const om=Symbol("fallback");function vE(e){for(const t of e)t.dispose()}function xw(e,t,n,r={}){const i=new Map;return Ne(()=>vE(i.values())),()=>{const o=e()||[];return o[vc],Wr(()=>{var d,u;if(!o.length)return vE(i.values()),i.clear(),r.fallback?[vg(m=>(i.set(om,{dispose:m}),r.fallback()))]:[];const a=new Array(o.length),l=i.get(om);if(!i.size||l){l==null||l.dispose(),i.delete(om);for(let _=0;_<o.length;_++){const m=o[_],g=t(m,_);s(a,m,_,g)}return a}const c=new Set(i.keys());for(let _=0;_<o.length;_++){const m=o[_],g=t(m,_);c.delete(g);const p=i.get(g);p?(a[_]=p.mapped,(d=p.setIndex)==null||d.call(p,_),p.setItem(()=>m)):s(a,m,_,g)}for(const _ of c)(u=i.get(_))==null||u.dispose(),i.delete(_);return a})};function s(o,a,l,c){vg(d=>{const[u,_]=U(a),m={setItem:_,dispose:d};if(n.length>1){const[g,p]=U(l);m.setIndex=p,m.mapped=n(u,g)}else m.mapped=n(u);i.set(c,m),o[l]=m.mapped})}}function Dw(e){const{by:t}=e;return F(xw(()=>e.each,typeof t=="function"?t:n=>n[t],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}const Lw=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function yE(e){const t={};let n;for(;n=Lw.exec(e);)t[n[1]]=n[2];return t}function Js(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=yE(e)}else typeof t=="string"&&(t=yE(t));return{...e,...t}}function mn(...e){return Iw(e)}function kw(e,t,n=-1){return n in e?[...e.slice(0,n),t,...e.slice(n)]:[...e,t]}function TE(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Mw(e){return typeof e=="number"}function ea(e){return Object.prototype.toString.call(e)==="[object String]"}function os(e){return typeof e=="function"}function Wi(e){return t=>`${e()}-${t}`}function Ti(e,t){return e?e===t||e.contains(t):!1}function Ul(e,t=!1){const{activeElement:n}=Vi(e);if(!(n!=null&&n.nodeName))return null;if(vy(n)&&n.contentDocument)return Ul(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=Vi(n).getElementById(r);if(i)return i}}return n}function Pw(e){return Vi(e).defaultView||window}function Vi(e){return e?e.ownerDocument||e:document}function vy(e){return e.tagName==="IFRAME"}var Qf=(e=>(e.Escape="Escape",e.Enter="Enter",e.Tab="Tab",e.Space=" ",e.ArrowDown="ArrowDown",e.ArrowLeft="ArrowLeft",e.ArrowRight="ArrowRight",e.ArrowUp="ArrowUp",e.End="End",e.Home="Home",e.PageDown="PageDown",e.PageUp="PageUp",e))(Qf||{});function yy(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)==null?void 0:t.brands.some(n=>e.test(n.brand)))||e.test(window.navigator.userAgent)}function jf(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)==null?void 0:t.platform)||window.navigator.platform):!1}function qc(){return jf(/^Mac/i)}function $w(){return jf(/^iPhone/i)}function Fw(){return jf(/^iPad/i)||qc()&&navigator.maxTouchPoints>1}function Bw(){return $w()||Fw()}function jd(){return qc()||Bw()}function Uw(){return yy(/AppleWebKit/i)&&!Gw()}function Gw(){return yy(/Chrome/i)}function Dt(e,t){return t&&(os(t)?t(e):t[0](t[1],e)),e==null?void 0:e.defaultPrevented}function Nn(e){return t=>{for(const n of e)Dt(t,n)}}function Vw(e){return qc()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Qn(e){if(e)if(Hw())e.focus({preventScroll:!0});else{const t=Yw(e);e.focus(),zw(t)}}var gd=null;function Hw(){if(gd==null){gd=!1;try{document.createElement("div").focus({get preventScroll(){return gd=!0,!0}})}catch{}}return gd}function Yw(e){let t=e.parentNode;const n=[],r=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==r;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return r instanceof HTMLElement&&n.push({element:r,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft}),n}function zw(e){for(const{element:t,scrollTop:n,scrollLeft:r}of e)t.scrollTop=n,t.scrollLeft=r}var Ty=["input:not([type='hidden']):not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","[tabindex]","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]:not([contenteditable='false'])"],Ww=[...Ty,'[tabindex]:not([tabindex="-1"]):not([disabled])'],Xf=`${Ty.join(":not([hidden]),")},[tabindex]:not([disabled]):not([hidden])`,qw=Ww.join(':not([hidden]):not([tabindex="-1"]),');function Cy(e,t){const r=Array.from(e.querySelectorAll(Xf)).filter(CE);return t&&CE(e)&&r.unshift(e),r.forEach((i,s)=>{if(vy(i)&&i.contentDocument){const o=i.contentDocument.body,a=Cy(o,!1);r.splice(s,1,...a)}}),r}function CE(e){return Ry(e)&&!Kw(e)}function Ry(e){return e.matches(Xf)&&Zf(e)}function Kw(e){return Number.parseInt(e.getAttribute("tabindex")||"0",10)<0}function Zf(e,t){return e.nodeName!=="#comment"&&Qw(e)&&jw(e,t)&&(!e.parentElement||Zf(e.parentElement,e))}function Qw(e){if(!(e instanceof HTMLElement)&&!(e instanceof SVGElement))return!1;const{display:t,visibility:n}=e.style;let r=t!=="none"&&n!=="hidden"&&n!=="collapse";if(r){if(!e.ownerDocument.defaultView)return r;const{getComputedStyle:i}=e.ownerDocument.defaultView,{display:s,visibility:o}=i(e);r=s!=="none"&&o!=="hidden"&&o!=="collapse"}return r}function jw(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function Xw(e,t,n){const r=t!=null&&t.tabbable?qw:Xf,i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(s){var o;return(o=t==null?void 0:t.from)!=null&&o.contains(s)?NodeFilter.FILTER_REJECT:s.matches(r)&&Zf(s)&&(!(t!=null&&t.accept)||t.accept(s))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(i.currentNode=t.from),i}function Zw(){}function Tt(e,t){return oe(e,t)}var Rl=new Map,RE=new Set;function IE(){if(typeof window>"u")return;const e=n=>{if(!n.target)return;let r=Rl.get(n.target);r||(r=new Set,Rl.set(n.target,r),n.target.addEventListener("transitioncancel",t)),r.add(n.propertyName)},t=n=>{if(!n.target)return;const r=Rl.get(n.target);if(r&&(r.delete(n.propertyName),r.size===0&&(n.target.removeEventListener("transitioncancel",t),Rl.delete(n.target)),Rl.size===0)){for(const i of RE)i();RE.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?IE():document.addEventListener("DOMContentLoaded",IE));function OE(e,t){const n=NE(e,t,"left"),r=NE(e,t,"top"),i=t.offsetWidth,s=t.offsetHeight;let o=e.scrollLeft,a=e.scrollTop;const l=o+e.offsetWidth,c=a+e.offsetHeight;n<=o?o=n:n+i>l&&(o+=n+i-l),r<=a?a=r:r+s>c&&(a+=r+s-c),e.scrollLeft=o,e.scrollTop=a}function NE(e,t,n){const r=n==="left"?"offsetLeft":"offsetTop";let i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);){if(t.offsetParent.contains(e)){i-=e[r];break}t=t.offsetParent}return i}var c_={border:"0",clip:"rect(0 0 0 0)","clip-path":"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:"0",position:"absolute",width:"1px","white-space":"nowrap"},pu="data-kb-top-layer",Iy,yg=!1,ms=[];function Tc(e){return ms.findIndex(t=>t.node===e)}function Jw(e){return ms[Tc(e)]}function ex(e){return ms[ms.length-1].node===e}function Oy(){return ms.filter(e=>e.isPointerBlocking)}function tx(){return[...Oy()].slice(-1)[0]}function Jf(){return Oy().length>0}function Ny(e){var n;const t=Tc((n=tx())==null?void 0:n.node);return Tc(e)<t}function nx(e){ms.push(e)}function rx(e){const t=Tc(e);t<0||ms.splice(t,1)}function ix(){for(const{node:e}of ms)e.style.pointerEvents=Ny(e)?"none":"auto"}function sx(e){if(Jf()&&!yg){const t=Vi(e);Iy=document.body.style.pointerEvents,t.body.style.pointerEvents="none",yg=!0}}function ox(e){if(Jf())return;const t=Vi(e);t.body.style.pointerEvents=Iy,t.body.style.length===0&&t.body.removeAttribute("style"),yg=!1}var Pr={layers:ms,isTopMostLayer:ex,hasPointerBlockingLayer:Jf,isBelowPointerBlockingLayer:Ny,addLayer:nx,removeLayer:rx,indexOf:Tc,find:Jw,assignPointerEventToLayers:ix,disableBodyPointerEvents:sx,restoreBodyPointerEvents:ox},am="focusScope.autoFocusOnMount",lm="focusScope.autoFocusOnUnmount",AE={bubbles:!1,cancelable:!0},wE={stack:[],active(){return this.stack[0]},add(e){var t;e!==this.active()&&((t=this.active())==null||t.pause()),this.stack=TE(this.stack,e),this.stack.unshift(e)},remove(e){var t;this.stack=TE(this.stack,e),(t=this.active())==null||t.resume()}};function ep(e,t){const[n,r]=U(!1),i={pause(){r(!0)},resume(){r(!1)}};let s=null;const o=g=>{var p;return(p=e.onMountAutoFocus)==null?void 0:p.call(e,g)},a=g=>{var p;return(p=e.onUnmountAutoFocus)==null?void 0:p.call(e,g)},l=()=>Vi(t()),c=()=>{const g=l().createElement("span");return g.setAttribute("data-focus-trap",""),g.tabIndex=0,Object.assign(g.style,c_),g},d=()=>{const g=t();return g?Cy(g,!0).filter(p=>!p.hasAttribute("data-focus-trap")):[]},u=()=>{const g=d();return g.length>0?g[0]:null},_=()=>{const g=d();return g.length>0?g[g.length-1]:null},m=()=>{const g=t();if(!g)return!1;const p=Ul(g);return!p||Ti(g,p)?!1:Ry(p)};J(()=>{const g=t();if(!g)return;wE.add(i);const p=Ul(g);if(!Ti(g,p)){const h=new CustomEvent(am,AE);g.addEventListener(am,o),g.dispatchEvent(h),h.defaultPrevented||setTimeout(()=>{Qn(u()),Ul(g)===p&&Qn(g)},0)}Ne(()=>{g.removeEventListener(am,o),setTimeout(()=>{const h=new CustomEvent(lm,AE);m()&&h.preventDefault(),g.addEventListener(lm,a),g.dispatchEvent(h),h.defaultPrevented||Qn(p??l().body),g.removeEventListener(lm,a),wE.remove(i)},0)})}),J(()=>{const g=t();if(!g||!pe(e.trapFocus)||n())return;const p=h=>{const f=h.target;f!=null&&f.closest(`[${pu}]`)||(Ti(g,f)?s=f:Qn(s))},E=h=>{const b=h.relatedTarget??Ul(g);b!=null&&b.closest(`[${pu}]`)||Ti(g,b)||Qn(s)};l().addEventListener("focusin",p),l().addEventListener("focusout",E),Ne(()=>{l().removeEventListener("focusin",p),l().removeEventListener("focusout",E)})}),J(()=>{const g=t();if(!g||!pe(e.trapFocus)||n())return;const p=c();g.insertAdjacentElement("afterbegin",p);const E=c();g.insertAdjacentElement("beforeend",E);function h(b){const y=u(),v=_();b.relatedTarget===y?Qn(v):Qn(y)}p.addEventListener("focusin",h),E.addEventListener("focusin",h);const f=new MutationObserver(b=>{for(const y of b)y.previousSibling===E&&(E.remove(),g.insertAdjacentElement("beforeend",E)),y.nextSibling===p&&(p.remove(),g.insertAdjacentElement("afterbegin",p))});f.observe(g,{childList:!0,subtree:!1}),Ne(()=>{p.removeEventListener("focusin",h),E.removeEventListener("focusin",h),p.remove(),E.remove(),f.disconnect()})})}var Ay=7e3,cm=null,ax="data-live-announcer";function dm(e,t="assertive",n=Ay){cm||(cm=new lx),cm.announce(e,t,n)}var lx=class{constructor(){X(this,"node");X(this,"assertiveLog");X(this,"politeLog");this.node=document.createElement("div"),this.node.dataset.liveAnnouncer="true",Object.assign(this.node.style,c_),this.assertiveLog=this.createLog("assertive"),this.node.appendChild(this.assertiveLog),this.politeLog=this.createLog("polite"),this.node.appendChild(this.politeLog),document.body.prepend(this.node)}createLog(e){const t=document.createElement("div");return t.setAttribute("role","log"),t.setAttribute("aria-live",e),t.setAttribute("aria-relevant","additions"),t}destroy(){this.node&&(document.body.removeChild(this.node),this.node=null)}announce(e,t="assertive",n=Ay){if(!this.node)return;const r=document.createElement("div");r.textContent=e,t==="assertive"?this.assertiveLog.appendChild(r):this.politeLog.appendChild(r),e!==""&&setTimeout(()=>{r.remove()},n)}clear(e){this.node&&((!e||e==="assertive")&&(this.assertiveLog.innerHTML=""),(!e||e==="polite")&&(this.politeLog.innerHTML=""))}};function tp(e){J(()=>{pe(e.isDisabled)||Ne(cx(pe(e.targets),pe(e.root)))})}var Il=new WeakMap,Zr=[];function cx(e,t=document.body){const n=new Set(e),r=new Set,i=l=>{for(const _ of l.querySelectorAll(`[${ax}], [${pu}]`))n.add(_);const c=_=>{if(n.has(_)||_.parentElement&&r.has(_.parentElement)&&_.parentElement.getAttribute("role")!=="row")return NodeFilter.FILTER_REJECT;for(const m of n)if(_.contains(m))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},d=document.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,{acceptNode:c}),u=c(l);if(u===NodeFilter.FILTER_ACCEPT&&s(l),u!==NodeFilter.FILTER_REJECT){let _=d.nextNode();for(;_!=null;)s(_),_=d.nextNode()}},s=l=>{const c=Il.get(l)??0;l.getAttribute("aria-hidden")==="true"&&c===0||(c===0&&l.setAttribute("aria-hidden","true"),r.add(l),Il.set(l,c+1))};Zr.length&&Zr[Zr.length-1].disconnect(),i(t);const o=new MutationObserver(l=>{for(const c of l)if(!(c.type!=="childList"||c.addedNodes.length===0)&&![...n,...r].some(d=>d.contains(c.target))){for(const d of c.removedNodes)d instanceof Element&&(n.delete(d),r.delete(d));for(const d of c.addedNodes)(d instanceof HTMLElement||d instanceof SVGElement)&&(d.dataset.liveAnnouncer==="true"||d.dataset.reactAriaTopLayer==="true")?n.add(d):d instanceof Element&&i(d)}});o.observe(t,{childList:!0,subtree:!0});const a={observe(){o.observe(t,{childList:!0,subtree:!0})},disconnect(){o.disconnect()}};return Zr.push(a),()=>{o.disconnect();for(const l of r){const c=Il.get(l);if(c==null)return;c===1?(l.removeAttribute("aria-hidden"),Il.delete(l)):Il.set(l,c-1)}a===Zr[Zr.length-1]?(Zr.pop(),Zr.length&&Zr[Zr.length-1].observe()):Zr.splice(Zr.indexOf(a),1)}}var xE="interactOutside.pointerDownOutside",DE="interactOutside.focusOutside";function dx(e,t){let n,r=Zw;const i=()=>Vi(t()),s=u=>{var _;return(_=e.onPointerDownOutside)==null?void 0:_.call(e,u)},o=u=>{var _;return(_=e.onFocusOutside)==null?void 0:_.call(e,u)},a=u=>{var _;return(_=e.onInteractOutside)==null?void 0:_.call(e,u)},l=u=>{var m;const _=u.target;return!(_ instanceof Element)||_.closest(`[${pu}]`)||!Ti(i(),_)||Ti(t(),_)?!1:!((m=e.shouldExcludeElement)!=null&&m.call(e,_))},c=u=>{function _(){const m=t(),g=u.target;if(!m||!g||!l(u))return;const p=Nn([s,a]);g.addEventListener(xE,p,{once:!0});const E=new CustomEvent(xE,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:u.button===2||Vw(u)&&u.button===0}});g.dispatchEvent(E)}u.pointerType==="touch"?(i().removeEventListener("click",_),r=_,i().addEventListener("click",_,{once:!0})):_()},d=u=>{const _=t(),m=u.target;if(!_||!m||!l(u))return;const g=Nn([o,a]);m.addEventListener(DE,g,{once:!0});const p=new CustomEvent(DE,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:!1}});m.dispatchEvent(p)};J(()=>{pe(e.isDisabled)||(n=window.setTimeout(()=>{i().addEventListener("pointerdown",c,!0)},0),i().addEventListener("focusin",d,!0),Ne(()=>{window.clearTimeout(n),i().removeEventListener("click",r),i().removeEventListener("pointerdown",c,!0),i().removeEventListener("focusin",d,!0)}))})}function ux(e){const t=n=>{var r;n.key===Qf.Escape&&((r=e.onEscapeKeyDown)==null||r.call(e,n))};J(()=>{var r;if(pe(e.isDisabled))return;const n=((r=e.ownerDocument)==null?void 0:r.call(e))??Vi();n.addEventListener("keydown",t),Ne(()=>{n.removeEventListener("keydown",t)})})}function Gt(e){const[t,n]=lt(e,["as"]);if(!t.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return S(fu,oe(n,{get component(){return t.as}}))}var wy=Jt();function _x(){return en(wy)}function np(e){let t;const n=_x(),[r,i]=lt(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),s=new Set([]),o=u=>{s.add(u);const _=n==null?void 0:n.registerNestedLayer(u);return()=>{s.delete(u),_==null||_()}};dx({shouldExcludeElement:u=>{var _;return t?((_=r.excludedElements)==null?void 0:_.some(m=>Ti(m(),u)))||[...s].some(m=>Ti(m,u)):!1},onPointerDownOutside:u=>{var _,m,g;!t||Pr.isBelowPointerBlockingLayer(t)||!r.bypassTopMostLayerCheck&&!Pr.isTopMostLayer(t)||((_=r.onPointerDownOutside)==null||_.call(r,u),(m=r.onInteractOutside)==null||m.call(r,u),u.defaultPrevented||(g=r.onDismiss)==null||g.call(r))},onFocusOutside:u=>{var _,m,g;(_=r.onFocusOutside)==null||_.call(r,u),(m=r.onInteractOutside)==null||m.call(r,u),u.defaultPrevented||(g=r.onDismiss)==null||g.call(r)}},()=>t),ux({ownerDocument:()=>Vi(t),onEscapeKeyDown:u=>{var _;!t||!Pr.isTopMostLayer(t)||((_=r.onEscapeKeyDown)==null||_.call(r,u),!u.defaultPrevented&&r.onDismiss&&(u.preventDefault(),r.onDismiss()))}}),Tn(()=>{if(!t)return;Pr.addLayer({node:t,isPointerBlocking:r.disableOutsidePointerEvents,dismiss:r.onDismiss});const u=n==null?void 0:n.registerNestedLayer(t);Pr.assignPointerEventToLayers(),Pr.disableBodyPointerEvents(t),Ne(()=>{t&&(Pr.removeLayer(t),u==null||u(),Pr.assignPointerEventToLayers(),Pr.restoreBodyPointerEvents(t))})}),J(qr([()=>t,()=>r.disableOutsidePointerEvents],([u,_])=>{if(!u)return;const m=Pr.find(u);m&&m.isPointerBlocking!==_&&(m.isPointerBlocking=_,Pr.assignPointerEventToLayers()),_&&Pr.disableBodyPointerEvents(u),Ne(()=>{Pr.restoreBodyPointerEvents(u)})},{defer:!0}));const d={registerNestedLayer:o};return S(wy.Provider,{value:d,get children(){return S(Gt,oe({as:"div",ref(u){var _=mn(m=>t=m,r.ref);typeof _=="function"&&_(u)}},i))}})}function d_(e){var o;const[t,n]=U((o=e.defaultValue)==null?void 0:o.call(e)),r=F(()=>{var a;return((a=e.value)==null?void 0:a.call(e))!==void 0}),i=F(()=>{var a;return r()?(a=e.value)==null?void 0:a.call(e):t()});return[i,a=>{Wr(()=>{var c;const l=Ow(a,i());return Object.is(l,i())||(r()||n(l),(c=e.onChange)==null||c.call(e,l)),l})}]}function xy(e){const[t,n]=d_(e);return[()=>t()??!1,n]}function mx(e){const[t,n]=d_(e);return[()=>t()??[],n]}function u_(e={}){const[t,n]=xy({value:()=>pe(e.open),defaultValue:()=>!!pe(e.defaultOpen),onChange:o=>{var a;return(a=e.onOpenChange)==null?void 0:a.call(e,o)}}),r=()=>{n(!0)},i=()=>{n(!1)};return{isOpen:t,setIsOpen:n,open:r,close:i,toggle:()=>{t()?i():r()}}}function Dy(e,t){const[n,r]=U(LE(t==null?void 0:t()));return J(()=>{var i;r(((i=e())==null?void 0:i.tagName.toLowerCase())||LE(t==null?void 0:t()))}),n}function LE(e){return ea(e)?e:void 0}var gx=Object.defineProperty,eo=(e,t)=>{for(var n in t)gx(e,n,{get:t[n],enumerable:!0})},fx={};eo(fx,{Button:()=>Ex,Root:()=>Fo});var px=["button","color","file","image","reset","submit"];function hx(e){const t=e.tagName.toLowerCase();return t==="button"?!0:t==="input"&&e.type?px.indexOf(e.type)!==-1:!1}function Fo(e){let t;const n=Tt({type:"button"},e),[r,i]=lt(n,["ref","type","disabled"]),s=Dy(()=>t,()=>"button"),o=F(()=>{const c=s();return c==null?!1:hx({tagName:c,type:r.type})}),a=F(()=>s()==="input"),l=F(()=>s()==="a"&&(t==null?void 0:t.getAttribute("href"))!=null);return S(Gt,oe({as:"button",ref(c){var d=mn(u=>t=u,r.ref);typeof d=="function"&&d(c)},get type(){return we(()=>!!(o()||a()))()?r.type:void 0},get role(){return!o()&&!l()?"button":void 0},get tabIndex(){return!o()&&!l()&&!r.disabled?0:void 0},get disabled(){return we(()=>!!(o()||a()))()?r.disabled:void 0},get"aria-disabled"(){return!o()&&!a()&&r.disabled?!0:void 0},get"data-disabled"(){return r.disabled?"":void 0}},i))}var Ex=Fo;function mr(e){return t=>(e(t),()=>e(void 0))}var cr=e=>typeof e=="function"?e():e,Tg=(e,t)=>{if(e.contains(t))return!0;let n=t;for(;n;){if(n===e)return!0;n=n._$host??n.parentElement}return!1},fd=new Map,Sx=e=>{J(()=>{const t=cr(e.style)??{},n=cr(e.properties)??[],r={};for(const s in t)r[s]=e.element.style[s];const i=fd.get(e.key);i?i.activeCount++:fd.set(e.key,{activeCount:1,originalStyles:r,properties:n.map(s=>s.key)}),Object.assign(e.element.style,e.style);for(const s of n)e.element.style.setProperty(s.key,s.value);Ne(()=>{var o;const s=fd.get(e.key);if(s){if(s.activeCount!==1){s.activeCount--;return}fd.delete(e.key);for(const[a,l]of Object.entries(s.originalStyles))e.element.style[a]=l;for(const a of s.properties)e.element.style.removeProperty(a);e.element.style.length===0&&e.element.removeAttribute("style"),(o=e.cleanup)==null||o.call(e)}})})},kE=Sx,bx=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},vx=(e,t)=>{const n=getComputedStyle(e),r=t==="x"?n.overflowX:n.overflowY;return r==="auto"||r==="scroll"||e.tagName==="HTML"&&r==="visible"},yx=(e,t,n)=>{const r=t==="x"&&window.getComputedStyle(e).direction==="rtl"?-1:1;let i=e,s=0,o=0,a=!1;do{const[l,c,d]=bx(i,t),u=d-l-r*c;(c!==0||u!==0)&&vx(i,t)&&(s+=u,o+=c),i===(n??document.documentElement)?a=!0:i=i._$host??i.parentElement}while(i&&!a);return[s,o]},[ME,PE]=U([]),Tx=e=>ME().indexOf(e)===ME().length-1,Cx=e=>{const t=oe({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=ci();let r=[0,0],i=null,s=null;J(()=>{cr(t.enabled)&&(PE(c=>[...c,n]),Ne(()=>{PE(c=>c.filter(d=>d!==n))}))}),J(()=>{if(!cr(t.enabled)||!cr(t.hideScrollbar))return;const{body:c}=document,d=window.innerWidth-c.offsetWidth;if(cr(t.preventScrollbarShift)){const u={overflow:"hidden"},_=[];d>0&&(cr(t.preventScrollbarShiftMode)==="padding"?u.paddingRight=`calc(${window.getComputedStyle(c).paddingRight} + ${d}px)`:u.marginRight=`calc(${window.getComputedStyle(c).marginRight} + ${d}px)`,_.push({key:"--scrollbar-width",value:`${d}px`}));const m=window.scrollY,g=window.scrollX;kE({key:"prevent-scroll",element:c,style:u,properties:_,cleanup:()=>{cr(t.restoreScrollPosition)&&d>0&&window.scrollTo(g,m)}})}else kE({key:"prevent-scroll",element:c,style:{overflow:"hidden"}})}),J(()=>{!Tx(n)||!cr(t.enabled)||(document.addEventListener("wheel",a,{passive:!1}),document.addEventListener("touchstart",o,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),Ne(()=>{document.removeEventListener("wheel",a),document.removeEventListener("touchstart",o),document.removeEventListener("touchmove",l)}))});const o=c=>{r=$E(c),i=null,s=null},a=c=>{const d=c.target,u=cr(t.element),_=Rx(c),m=Math.abs(_[0])>Math.abs(_[1])?"x":"y",g=m==="x"?_[0]:_[1],p=FE(d,m,g,u);let E;u&&Tg(u,d)?E=!p:E=!0,E&&c.cancelable&&c.preventDefault()},l=c=>{const d=cr(t.element),u=c.target;let _;if(c.touches.length===2)_=!cr(t.allowPinchZoom);else{if(i==null||s===null){const m=$E(c).map((p,E)=>r[E]-p),g=Math.abs(m[0])>Math.abs(m[1])?"x":"y";i=g,s=g==="x"?m[0]:m[1]}if(u.type==="range")_=!1;else{const m=FE(u,i,s,d);d&&Tg(d,u)?_=!m:_=!0}}_&&c.cancelable&&c.preventDefault()}},Rx=e=>[e.deltaX,e.deltaY],$E=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],FE=(e,t,n,r)=>{const i=r!==null&&Tg(r,e),[s,o]=yx(e,t,i?r:void 0);return!(n>0&&Math.abs(s)<=1||n<0&&Math.abs(o)<1)},Ix=Cx,rp=Ix,Ox=e=>{const t=F(()=>{const o=cr(e.element);if(o)return getComputedStyle(o)}),n=()=>{var o;return((o=t())==null?void 0:o.animationName)??"none"},[r,i]=U(cr(e.show)?"present":"hidden");let s="none";return J(o=>{const a=cr(e.show);return Wr(()=>{var d;if(o===a)return a;const l=s,c=n();a?i("present"):c==="none"||((d=t())==null?void 0:d.display)==="none"?i("hidden"):i(o===!0&&l!==c?"hiding":"hidden")}),a}),J(()=>{const o=cr(e.element);if(!o)return;const a=c=>{c.target===o&&(s=n())},l=c=>{const u=n().includes(c.animationName);c.target===o&&u&&r()==="hiding"&&i("hidden")};o.addEventListener("animationstart",a),o.addEventListener("animationcancel",l),o.addEventListener("animationend",l),Ne(()=>{o.removeEventListener("animationstart",a),o.removeEventListener("animationcancel",l),o.removeEventListener("animationend",l)})}),{present:()=>r()==="present"||r()==="hiding",state:r,setState:i}},Nx=Ox,Cc=Nx,Ax={};eo(Ax,{CloseButton:()=>ky,Content:()=>My,Description:()=>Py,Dialog:()=>ft,Overlay:()=>$y,Portal:()=>Fy,Root:()=>By,Title:()=>Uy,Trigger:()=>Gy,useDialogContext:()=>to});var Ly=Jt();function to(){const e=en(Ly);if(e===void 0)throw new Error("[kobalte]: `useDialogContext` must be used within a `Dialog` component");return e}function ky(e){const t=to(),[n,r]=lt(e,["aria-label","onClick"]);return S(Fo,oe({get"aria-label"(){return n["aria-label"]||t.translations().dismiss},onClick:s=>{Dt(s,n.onClick),t.close()}},r))}function My(e){let t;const n=to(),r=Tt({id:n.generateId("content")},e),[i,s]=lt(r,["ref","onOpenAutoFocus","onCloseAutoFocus","onPointerDownOutside","onFocusOutside","onInteractOutside"]);let o=!1,a=!1;const l=_=>{var m;(m=i.onPointerDownOutside)==null||m.call(i,_),n.modal()&&_.detail.isContextMenu&&_.preventDefault()},c=_=>{var m;(m=i.onFocusOutside)==null||m.call(i,_),n.modal()&&_.preventDefault()},d=_=>{var m;(m=i.onInteractOutside)==null||m.call(i,_),!n.modal()&&(_.defaultPrevented||(o=!0,_.detail.originalEvent.type==="pointerdown"&&(a=!0)),Ti(n.triggerRef(),_.target)&&_.preventDefault(),_.detail.originalEvent.type==="focusin"&&a&&_.preventDefault())},u=_=>{var m;(m=i.onCloseAutoFocus)==null||m.call(i,_),n.modal()?(_.preventDefault(),Qn(n.triggerRef())):(_.defaultPrevented||(o||Qn(n.triggerRef()),_.preventDefault()),o=!1,a=!1)};return tp({isDisabled:()=>!(n.isOpen()&&n.modal()),targets:()=>t?[t]:[]}),rp({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),ep({trapFocus:()=>n.isOpen()&&n.modal(),onMountAutoFocus:i.onOpenAutoFocus,onUnmountAutoFocus:u},()=>t),J(()=>Ne(n.registerContentId(s.id))),S(W,{get when(){return n.contentPresent()},get children(){return S(np,oe({ref(_){var m=mn(g=>{n.setContentRef(g),t=g},i.ref);typeof m=="function"&&m(_)},role:"dialog",tabIndex:-1,get disableOutsidePointerEvents(){return we(()=>!!n.modal())()&&n.isOpen()},get excludedElements(){return[n.triggerRef]},get"aria-labelledby"(){return n.titleId()},get"aria-describedby"(){return n.descriptionId()},get"data-expanded"(){return n.isOpen()?"":void 0},get"data-closed"(){return n.isOpen()?void 0:""},onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:d,get onDismiss(){return n.close}},s))}})}function Py(e){const t=to(),n=Tt({id:t.generateId("description")},e),[r,i]=lt(n,["id"]);return J(()=>Ne(t.registerDescriptionId(r.id))),S(Gt,oe({as:"p",get id(){return r.id}},i))}function $y(e){const t=to(),[n,r]=lt(e,["ref","style","onPointerDown"]),i=s=>{Dt(s,n.onPointerDown),s.target===s.currentTarget&&s.preventDefault()};return S(W,{get when(){return t.overlayPresent()},get children(){return S(Gt,oe({as:"div",ref(s){var o=mn(t.setOverlayRef,n.ref);typeof o=="function"&&o(s)},get style(){return Js({"pointer-events":"auto"},n.style)},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onPointerDown:i},r))}})}function Fy(e){const t=to();return S(W,{get when(){return t.contentPresent()||t.overlayPresent()},get children(){return S(l_,e)}})}var BE={dismiss:"Dismiss"};function By(e){const t=`dialog-${ci()}`,n=Tt({id:t,modal:!0,translations:BE},e),[r,i]=U(),[s,o]=U(),[a,l]=U(),[c,d]=U(),[u,_]=U(),[m,g]=U(),p=u_({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:y=>{var v;return(v=n.onOpenChange)==null?void 0:v.call(n,y)}}),E=()=>n.forceMount||p.isOpen(),{present:h}=Cc({show:E,element:()=>c()??null}),{present:f}=Cc({show:E,element:()=>u()??null}),b={translations:()=>n.translations??BE,isOpen:p.isOpen,modal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??b.modal(),contentId:r,titleId:s,descriptionId:a,triggerRef:m,overlayRef:c,setOverlayRef:d,contentRef:u,setContentRef:_,overlayPresent:h,contentPresent:f,close:p.close,toggle:p.toggle,setTriggerRef:g,generateId:Wi(()=>n.id),registerContentId:mr(i),registerTitleId:mr(o),registerDescriptionId:mr(l)};return S(Ly.Provider,{value:b,get children(){return n.children}})}function Uy(e){const t=to(),n=Tt({id:t.generateId("title")},e),[r,i]=lt(n,["id"]);return J(()=>Ne(t.registerTitleId(r.id))),S(Gt,oe({as:"h2",get id(){return r.id}},i))}function Gy(e){const t=to(),[n,r]=lt(e,["ref","onClick"]);return S(Fo,oe({ref(s){var o=mn(t.setTriggerRef,n.ref);typeof o=="function"&&o(s)},"aria-haspopup":"dialog",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return we(()=>!!t.isOpen())()?t.contentId():void 0},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onClick:s=>{Dt(s,n.onClick),t.toggle()}},r))}var ft=Object.assign(By,{CloseButton:ky,Content:My,Description:Py,Overlay:$y,Portal:Fy,Title:Uy,Trigger:Gy});const wx=e=>typeof e=="function",hu=(e,t)=>wx(e)?e(t):e;var Pn;(function(e){e[e.ADD_TOAST=0]="ADD_TOAST",e[e.UPDATE_TOAST=1]="UPDATE_TOAST",e[e.UPSERT_TOAST=2]="UPSERT_TOAST",e[e.DISMISS_TOAST=3]="DISMISS_TOAST",e[e.REMOVE_TOAST=4]="REMOVE_TOAST",e[e.START_PAUSE=5]="START_PAUSE",e[e.END_PAUSE=6]="END_PAUSE"})(Pn||(Pn={}));const Fa=Symbol("store-raw"),Bi=Symbol("store-node"),ii=Symbol("store-has"),Vy=Symbol("store-self");function Hy(e){let t=e[Ir];if(!t&&(Object.defineProperty(e,Ir,{value:t=new Proxy(e,Dx)}),!Array.isArray(e))){const n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e);for(let i=0,s=n.length;i<s;i++){const o=n[i];r[o].get&&Object.defineProperty(e,o,{enumerable:r[o].enumerable,get:r[o].get.bind(t)})}}return t}function Oi(e){let t;return e!=null&&typeof e=="object"&&(e[Ir]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function gs(e,t=new Set){let n,r,i,s;if(n=e!=null&&e[Fa])return n;if(!Oi(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let o=0,a=e.length;o<a;o++)i=e[o],(r=gs(i,t))!==i&&(e[o]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);const o=Object.keys(e),a=Object.getOwnPropertyDescriptors(e);for(let l=0,c=o.length;l<c;l++)s=o[l],!a[s].get&&(i=e[s],(r=gs(i,t))!==i&&(e[s]=r))}return e}function Ba(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Co(e,t,n){if(e[t])return e[t];const[r,i]=U(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function xx(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===Ir||t===Bi||(delete n.value,delete n.writable,n.get=()=>e[Ir][t]),n}function ip(e){yc()&&Co(Ba(e,Bi),Vy)()}function Yy(e){return ip(e),Reflect.ownKeys(e)}const Dx={get(e,t,n){if(t===Fa)return e;if(t===Ir)return n;if(t===vc)return ip(e),n;const r=Ba(e,Bi),i=r[t];let s=i?i():e[t];if(t===Bi||t===ii||t==="__proto__")return s;if(!i){const o=Object.getOwnPropertyDescriptor(e,t);yc()&&(typeof s!="function"||e.hasOwnProperty(t))&&!(o&&o.get)&&(s=Co(r,t,s)())}return Oi(s)?Hy(s):s},has(e,t){return t===Fa||t===Ir||t===vc||t===Bi||t===ii||t==="__proto__"?!0:(yc()&&Co(Ba(e,ii),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:Yy,getOwnPropertyDescriptor:xx};function dr(e,t,n,r=!1){if(!r&&e[t]===n)return;const i=e[t],s=e.length;n===void 0?(delete e[t],e[ii]&&e[ii][t]&&i!==void 0&&e[ii][t].$()):(e[t]=n,e[ii]&&e[ii][t]&&i===void 0&&e[ii][t].$());let o=Ba(e,Bi),a;if((a=Co(o,t,i))&&a.$(()=>n),Array.isArray(e)&&e.length!==s){for(let l=e.length;l<s;l++)(a=o[l])&&a.$();(a=Co(o,"length",s))&&a.$(e.length)}(a=o[Vy])&&a.$()}function zy(e,t){const n=Object.keys(t);for(let r=0;r<n.length;r+=1){const i=n[r];dr(e,i,t[i])}}function Lx(e,t){if(typeof t=="function"&&(t=t(e)),t=gs(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){const i=t[n];e[n]!==i&&dr(e,n,i)}dr(e,"length",r)}else zy(e,t)}function Gl(e,t,n=[]){let r,i=e;if(t.length>1){r=t.shift();const o=typeof r,a=Array.isArray(e);if(Array.isArray(r)){for(let l=0;l<r.length;l++)Gl(e,[r[l]].concat(t),n);return}else if(a&&o==="function"){for(let l=0;l<e.length;l++)r(e[l],l)&&Gl(e,[l].concat(t),n);return}else if(a&&o==="object"){const{from:l=0,to:c=e.length-1,by:d=1}=r;for(let u=l;u<=c;u+=d)Gl(e,[u].concat(t),n);return}else if(t.length>1){Gl(e[r],t,[r].concat(n));return}i=e[r],n=[r].concat(n)}let s=t[0];typeof s=="function"&&(s=s(i,n),s===i)||r===void 0&&s==null||(s=gs(s),r===void 0||Oi(i)&&Oi(s)&&!Array.isArray(s)?zy(i,s):dr(e,r,s))}function Wy(...[e,t]){const n=gs(e||{}),r=Array.isArray(n),i=Hy(n);function s(...o){ur(()=>{r&&o.length===1?Lx(n,o[0]):Gl(n,o)})}return[i,s]}function kx(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||n.set||!n.configurable||t===Ir||t===Bi||(delete n.value,delete n.writable,n.get=()=>e[Ir][t],n.set=r=>e[Ir][t]=r),n}const Mx={get(e,t,n){if(t===Fa)return e;if(t===Ir)return n;if(t===vc)return ip(e),n;const r=Ba(e,Bi),i=r[t];let s=i?i():e[t];if(t===Bi||t===ii||t==="__proto__")return s;if(!i){const o=Object.getOwnPropertyDescriptor(e,t),a=typeof s=="function";if(yc()&&(!a||e.hasOwnProperty(t))&&!(o&&o.get))s=Co(r,t,s)();else if(s!=null&&a&&s===Array.prototype[t])return(...l)=>ur(()=>Array.prototype[t].apply(n,l))}return Oi(s)?qy(s):s},has(e,t){return t===Fa||t===Ir||t===vc||t===Bi||t===ii||t==="__proto__"?!0:(yc()&&Co(Ba(e,ii),t)(),t in e)},set(e,t,n){return ur(()=>dr(e,t,gs(n))),!0},deleteProperty(e,t){return ur(()=>dr(e,t,void 0,!0)),!0},ownKeys:Yy,getOwnPropertyDescriptor:kx};function qy(e){let t=e[Ir];if(!t){Object.defineProperty(e,Ir,{value:t=new Proxy(e,Mx)});const n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),s=i!==null&&e!==null&&typeof e=="object"&&!Array.isArray(e)&&i!==Object.prototype;if(s){let o=i;for(;o!=null;){const a=Object.getOwnPropertyDescriptors(o);n.push(...Object.keys(a)),Object.assign(r,a),o=Object.getPrototypeOf(o)}}for(let o=0,a=n.length;o<a;o++){const l=n[o];if(!(s&&l==="constructor")){if(r[l].get){const c=r[l].get.bind(t);Object.defineProperty(e,l,{get:c,configurable:!0})}if(r[l].set){const c=r[l].set;Object.defineProperty(e,l,{set:u=>ur(()=>c.call(t,u)),configurable:!0})}}}}return t}function Ky(e,t){const n=gs(e||{});return qy(n)}const Cg=Symbol("store-root");function ta(e,t,n,r,i){const s=t[n];if(e===s)return;const o=Array.isArray(e);if(n!==Cg&&(!Oi(e)||!Oi(s)||o!==Array.isArray(s)||i&&e[i]!==s[i])){dr(t,n,e);return}if(o){if(e.length&&s.length&&(!r||i&&e[0]&&e[0][i]!=null)){let c,d,u,_,m,g,p,E;for(u=0,_=Math.min(s.length,e.length);u<_&&(s[u]===e[u]||i&&s[u]&&e[u]&&s[u][i]&&s[u][i]===e[u][i]);u++)ta(e[u],s,u,r,i);const h=new Array(e.length),f=new Map;for(_=s.length-1,m=e.length-1;_>=u&&m>=u&&(s[_]===e[m]||i&&s[_]&&e[m]&&s[_][i]&&s[_][i]===e[m][i]);_--,m--)h[m]=s[_];if(u>m||u>_){for(d=u;d<=m;d++)dr(s,d,e[d]);for(;d<e.length;d++)dr(s,d,h[d]),ta(e[d],s,d,r,i);s.length>e.length&&dr(s,"length",e.length);return}for(p=new Array(m+1),d=m;d>=u;d--)g=e[d],E=i&&g?g[i]:g,c=f.get(E),p[d]=c===void 0?-1:c,f.set(E,d);for(c=u;c<=_;c++)g=s[c],E=i&&g?g[i]:g,d=f.get(E),d!==void 0&&d!==-1&&(h[d]=s[c],d=p[d],f.set(E,d));for(d=u;d<e.length;d++)d in h?(dr(s,d,h[d]),ta(e[d],s,d,r,i)):dr(s,d,e[d])}else for(let c=0,d=e.length;c<d;c++)ta(e[c],s,c,r,i);s.length>e.length&&dr(s,"length",e.length);return}const a=Object.keys(e);for(let c=0,d=a.length;c<d;c++)ta(e[a[c]],s,a[c],r,i);const l=Object.keys(s);for(let c=0,d=l.length;c<d;c++)e[l[c]]===void 0&&dr(s,l[c],void 0)}function Px(e,t={}){const{merge:n,key:r="id"}=t,i=gs(e);return s=>{if(!Oi(s)||!Oi(i))return i;const o=ta(i,{[Cg]:s},Cg,n,r);return o===void 0?s:o}}const Eu=new WeakMap,Qy={get(e,t){if(t===Fa)return e;const n=e[t];let r;return Oi(n)?Eu.get(n)||(Eu.set(n,r=new Proxy(n,Qy)),r):n},set(e,t,n){return dr(e,t,gs(n)),!0},deleteProperty(e,t){return dr(e,t,void 0,!0),!0}};function bi(e){return t=>{if(Oi(t)){let n;(n=Eu.get(t))||Eu.set(t,n=new Proxy(t,Qy)),e(n)}return t}}const[bo,Ns]=Wy({toasts:[],pausedAt:void 0}),$x=()=>{const{pausedAt:e,toasts:t}=bo;if(e)return;const n=Date.now();return t.map(i=>{if(i.duration===1/0)return;const s=(i.duration||0)+i.pauseDuration-(n-i.createdAt);if(s<=0){i.visible&&Ni({type:Pn.DISMISS_TOAST,toastId:i.id});return}return setTimeout(()=>{Ni({type:Pn.DISMISS_TOAST,toastId:i.id})},s)})},ec=new Map,UE=(e,t)=>{if(ec.has(e))return;const n=setTimeout(()=>{ec.delete(e),Ni({type:Pn.REMOVE_TOAST,toastId:e})},t);ec.set(e,n)},Fx=e=>{const t=ec.get(e);ec.delete(e),t&&clearTimeout(t)},Ni=e=>{switch(e.type){case Pn.ADD_TOAST:Ns("toasts",i=>{const s=i;return[e.toast,...s]});break;case Pn.DISMISS_TOAST:const{toastId:t}=e,n=bo.toasts;if(t){const i=n.find(s=>s.id===t);i&&UE(t,i.unmountDelay),Ns("toasts",s=>s.id===t,bi(s=>s.visible=!1))}else n.forEach(i=>{UE(i.id,i.unmountDelay)}),Ns("toasts",i=>i.id!==void 0,bi(i=>i.visible=!1));break;case Pn.REMOVE_TOAST:if(!e.toastId){Ns("toasts",[]);break}Ns("toasts",i=>i.filter(o=>o.id!==e.toastId));break;case Pn.UPDATE_TOAST:e.toast.id&&Fx(e.toast.id),Ns("toasts",i=>i.id===e.toast.id,i=>({...i,...e.toast}));break;case Pn.UPSERT_TOAST:bo.toasts.find(i=>i.id===e.toast.id)?Ni({type:Pn.UPDATE_TOAST,toast:e.toast}):Ni({type:Pn.ADD_TOAST,toast:e.toast});break;case Pn.START_PAUSE:Ns(bi(i=>{i.pausedAt=Date.now(),i.toasts.forEach(s=>{s.paused=!0})}));break;case Pn.END_PAUSE:const r=e.time-(bo.pausedAt||0);Ns(bi(i=>{i.pausedAt=void 0,i.toasts.forEach(s=>{s.pauseDuration+=r,s.paused=!1})}));break}},Bx={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Ta={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},jy={position:"top-right",toastOptions:Ta,gutter:8,containerStyle:{},containerClassName:""},pd="16px",Ux={position:"fixed","z-index":9999,top:pd,bottom:pd,left:pd,right:pd,"pointer-events":"none"},Gx=(()=>{let e=0;return()=>String(++e)})(),Vx=e=>{Qx(t=>({containerClassName:e.containerClassName??t.containerClassName,containerStyle:e.containerStyle??t.containerStyle,gutter:e.gutter??t.gutter,position:e.position??t.position,toastOptions:{...e.toastOptions}}))},Hx=(e,t)=>{const r=e.includes("top")?{top:0,"margin-top":`${t}px`}:{bottom:0,"margin-bottom":`${t}px`},i=e.includes("center")?{"justify-content":"center"}:e.includes("right")?{"justify-content":"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:"all 230ms cubic-bezier(.21,1.02,.73,1)",...r,...i}},Yx=(e,t)=>{const n=e.getBoundingClientRect();n.height!==t.height&&Ni({type:Pn.UPDATE_TOAST,toast:{id:t.id,height:n.height}})},zx=(e,t)=>{const{toasts:n}=bo,r=na().gutter||jy.gutter||8,i=n.filter(l=>(l.position||t)===t&&l.height),s=i.findIndex(l=>l.id===e.id),o=i.filter((l,c)=>c<s&&l.visible).length;return i.slice(0,o).reduce((l,c)=>l+r+(c.height||0),0)},Wx=(e,t)=>(e.position||t).includes("top")?1:-1,qx={display:"flex","align-items":"center",color:"#363636",background:"white","box-shadow":"0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05)","max-width":"350px","pointer-events":"auto",padding:"8px 10px","border-radius":"4px","line-height":"1.3","will-change":"transform"},Kx={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},hd={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},Su=e=>({calcMode:"spline",keyTimes:"0; 1",keySplines:e}),[na,Qx]=U(jy),jx=(e,t="blank",n)=>{var r,i,s;return{...Ta,...na().toastOptions,...n,type:t,message:e,pauseDuration:0,createdAt:Date.now(),visible:!0,id:n.id||Gx(),paused:!1,style:{...Ta.style,...(r=na().toastOptions)==null?void 0:r.style,...n.style},duration:n.duration||((i=na().toastOptions)==null?void 0:i.duration)||Bx[t],position:n.position||((s=na().toastOptions)==null?void 0:s.position)||na().position||Ta.position}},Kc=e=>(t,n={})=>vg(()=>{const r=bo.toasts.find(s=>s.id===n.id),i=jx(t,e,{...r,duration:void 0,...n});return Ni({type:Pn.UPSERT_TOAST,toast:i}),i.id}),Yr=(e,t)=>Kc("blank")(e,t);Wr(()=>Yr);Yr.error=Kc("error");Yr.success=Kc("success");Yr.loading=Kc("loading");Yr.custom=Kc("custom");Yr.dismiss=e=>{Ni({type:Pn.DISMISS_TOAST,toastId:e})};Yr.promise=(e,t,n)=>{const r=Yr.loading(t.loading,{...n});return e.then(i=>(Yr.success(hu(t.success,i),{id:r,...n}),i)).catch(i=>{Yr.error(hu(t.error,i),{id:r,...n})}),e};Yr.remove=e=>{Ni({type:Pn.REMOVE_TOAST,toastId:e})};var Xx=x("<div><style>.sldt-active{z-index:9999;}.sldt-active>*{pointer-events:auto;}");const Zx=e=>(J(()=>{Vx(e)}),J(()=>{const t=$x();Ne(()=>{t&&t.forEach(n=>n&&clearTimeout(n))})}),(()=>{var t=Xx();return t.firstChild,C(t,S(_t,{get each(){return bo.toasts},children:n=>S(nD,{toast:n})}),null),ne(n=>{var r={...Ux,...e.containerStyle},i=e.containerClassName;return n.e=ri(t,r,n.e),i!==n.t&&rt(t,n.t=i),n},{e:void 0,t:void 0}),t})());var Ed=x("<div>"),Jx=x("<div><div>");const eD=e=>{let t;return J(()=>{if(!t)return;const n=Wx(e.toast,e.position);e.toast.visible?t.animate([{transform:`translate3d(0,${n*-200}%,0) scale(.6)`,opacity:.5},{transform:"translate3d(0,0,0) scale(1)",opacity:1}],{duration:350,fill:"forwards",easing:"cubic-bezier(.21,1.02,.73,1)"}):t.animate([{transform:"translate3d(0,0,-1px) scale(1)",opacity:1},{transform:`translate3d(0,${n*-150}%,-1px) scale(.4)`,opacity:0}],{duration:400,fill:"forwards",easing:"cubic-bezier(.06,.71,.55,1)"})}),(()=>{var n=Jx(),r=n.firstChild,i=t;return typeof i=="function"?wt(i,n):t=n,C(n,S(Wc,{get children(){return[S(sr,{get when(){return e.toast.icon},get children(){var s=Ed();return C(s,()=>e.toast.icon),ne(o=>ri(s,hd,o)),s}}),S(sr,{get when(){return e.toast.type==="loading"},get children(){var s=Ed();return C(s,S(dD,oe(()=>e.toast.iconTheme))),ne(o=>ri(s,hd,o)),s}}),S(sr,{get when(){return e.toast.type==="success"},get children(){var s=Ed();return C(s,S(oD,oe(()=>e.toast.iconTheme))),ne(o=>ri(s,hd,o)),s}}),S(sr,{get when(){return e.toast.type==="error"},get children(){var s=Ed();return C(s,S(lD,oe(()=>e.toast.iconTheme))),ne(o=>ri(s,hd,o)),s}})]}}),r),Ii(r,oe(()=>e.toast.ariaProps),!1,!0),C(r,()=>hu(e.toast.message,e.toast)),ne(s=>{var o=e.toast.className,a={...qx,...e.toast.style},l=Kx;return o!==s.e&&rt(n,s.e=o),s.t=ri(n,a,s.t),s.a=ri(r,l,s.a),s},{e:void 0,t:void 0,a:void 0}),n})()};var tD=x("<div>");const nD=e=>{const t=()=>{const i=e.toast.position||Ta.position,s=zx(e.toast,i);return Hx(i,s)},n=F(()=>t());let r;return Tn(()=>{r&&Yx(r,e.toast)}),(()=>{var i=tD();i.addEventListener("mouseleave",()=>Ni({type:Pn.END_PAUSE,time:Date.now()})),i.addEventListener("mouseenter",()=>Ni({type:Pn.START_PAUSE,time:Date.now()}));var s=r;return typeof s=="function"?wt(s,i):r=i,C(i,(()=>{var o=we(()=>e.toast.type==="custom");return()=>o()?hu(e.toast.message,e.toast):S(eD,{get toast(){return e.toast},get position(){return e.toast.position||Ta.position}})})()),ne(o=>{var a=n(),l=e.toast.visible?"sldt-active":"";return o.e=ri(i,a,o.e),l!==o.t&&rt(i,o.t=l),o},{e:void 0,t:void 0}),i})()};var rD=x('<svg><circle cx=16 cy=16 r=0><animate attributeName=opacity values="0; 1; 1"></animate><animate attributeName=r values="0; 17.5; 16"></svg>',!1,!0,!1),iD=x('<svg><circle cx=16 cy=16 r=12 opacity=0><animate attributeName=opacity values="1; 0"></animate><animate attributeName=r values="12; 26"></svg>',!1,!0,!1);const Xy=e=>{const t={dur:"0.35s",begin:"100ms",fill:"freeze",calcMode:"spline",keyTimes:"0; 0.6; 1",keySplines:"0.25 0.71 0.4 0.88; .59 .22 .87 .63"};return(()=>{var n=rD(),r=n.firstChild,i=r.nextSibling;return Ii(r,t,!0,!1),Ii(i,t,!0,!1),ne(()=>Fe(n,"fill",e.fill)),n})()},Zy=e=>{const t={dur:"1s",begin:e.begin||"320ms",fill:"freeze",...Su("0.0 0.0 0.2 1")};return(()=>{var n=iD(),r=n.firstChild,i=r.nextSibling;return Ii(r,t,!0,!1),Ii(i,t,!0,!1),ne(()=>Fe(n,"fill",e.fill)),n})()};var sD=x('<svg viewBox="0 0 32 32"width=1.25rem height=1.25rem style=overflow:visible><path fill=none stroke-width=4 stroke-dasharray=22 stroke-dashoffset=22 stroke-linecap=round stroke-miterlimit=10 d=M9.8,17.2l3.8,3.6c0.1,0.1,0.3,0.1,0.4,0l9.6-9.7><animate attributeName=stroke-dashoffset values=22;0 dur=0.25s begin=250ms fill=freeze>');const oD=e=>{const t=e.primary||"#34C759";return(()=>{var n=sD(),r=n.firstChild,i=r.firstChild;return C(n,S(Xy,{fill:t}),r),C(n,S(Zy,{fill:t,begin:"350ms"}),r),Ii(i,oe(()=>Su("0.0, 0.0, 0.58, 1.0")),!0,!1),ne(()=>Fe(r,"stroke",e.secondary||"#FCFCFC")),n})()};var aD=x('<svg viewBox="0 0 32 32"width=1.25rem height=1.25rem style=overflow:visible><path fill=none stroke-width=4 stroke-dasharray=9 stroke-dashoffset=9 stroke-linecap=round d=M16,7l0,9><animate attributeName=stroke-dashoffset values=9;0 dur=0.2s begin=250ms fill=freeze></animate></path><circle cx=16 cy=23 r=2.5 opacity=0><animate attributeName=opacity values=0;1 dur=0.25s begin=350ms fill=freeze>');const lD=e=>{const t=e.primary||"#FF3B30";return(()=>{var n=aD(),r=n.firstChild,i=r.firstChild,s=r.nextSibling,o=s.firstChild;return C(n,S(Xy,{fill:t}),r),C(n,S(Zy,{fill:t}),r),Ii(i,oe(()=>Su("0.0, 0.0, 0.58, 1.0")),!0,!1),Ii(o,oe(()=>Su("0.0, 0.0, 0.58, 1.0")),!0,!1),ne(a=>{var l=e.secondary||"#FFFFFF",c=e.secondary||"#FFFFFF";return l!==a.e&&Fe(r,"stroke",a.e=l),c!==a.t&&Fe(s,"fill",a.t=c),a},{e:void 0,t:void 0}),n})()};var cD=x('<svg viewBox="0 0 32 32"width=1.25rem height=1.25rem style=overflow:visible><path fill=none stroke-width=4 stroke-miterlimit=10 d=M16,6c3,0,5.7,1.3,7.5,3.4c1.5,1.8,2.5,4,2.5,6.6c0,5.5-4.5,10-10,10S6,21.6,6,16S10.5,6,16,6z></path><path fill=none stroke-width=4 stroke-linecap=round stroke-miterlimit=10 d=M16,6c3,0,5.7,1.3,7.5,3.4c0.6,0.7,1.1,1.4,1.5,2.2><animateTransform attributeName=transform type=rotate from="0 16 16"to="360 16 16"dur=0.75s repeatCount=indefinite>');const dD=e=>(()=>{var t=cD(),n=t.firstChild,r=n.nextSibling;return ne(i=>{var s=e.primary||"#E5E7EB",o=e.secondary||"#4b5563";return s!==i.e&&Fe(n,"stroke",i.e=s),o!==i.t&&Fe(r,"stroke",i.t=o),i},{e:void 0,t:void 0}),t})(),[Rg,sp]=U(null);function Gs(e,t){sp({type:"alert",message:e,...t})}function op(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(r=>{sp({type:"confirm",message:e,...t,resolve:r})})}function um(){sp(null)}var uD=x('<div class="flex items-start gap-3"><div class="flex h-12 w-12 shrink-0 items-center justify-center rounded-xl border text-base font-semibold"aria-hidden></div><div class="flex-1 min-w-0">'),_D=x('<div class=mt-4><label class="text-xs font-medium text-muted uppercase tracking-wide"></label><input class="modal-search-input mt-2">'),mD=x('<div class="mt-6 flex justify-end gap-3"><button type=button class=button-primary>'),gD=x('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),fD=x('<p class="mt-2 text-secondary">'),pD=x("<button type=button class=button-secondary>");const hD={info:{badgeBg:"var(--badge-neutral-bg)",badgeBorder:"var(--border-base)",badgeText:"var(--accent-primary)",symbol:"i",fallbackTitle:"Heads up"},warning:{badgeBg:"rgba(255, 152, 0, 0.14)",badgeBorder:"var(--status-warning)",badgeText:"var(--status-warning)",symbol:"!",fallbackTitle:"Please review"},error:{badgeBg:"var(--danger-soft-bg)",badgeBorder:"var(--status-error)",badgeText:"var(--status-error)",symbol:"!",fallbackTitle:"Something went wrong"}};function Sd(e,t,n){var i,s,o,a,l,c,d,u;const r=t??Rg();if((r==null?void 0:r.type)==="confirm"){e?(i=r.onConfirm)==null||i.call(r):(s=r.onCancel)==null||s.call(r),(o=r.resolve)==null||o.call(r,e),um();return}if((r==null?void 0:r.type)==="prompt"){e?((a=r.onConfirm)==null||a.call(r),(l=r.resolvePrompt)==null||l.call(r,n??"")):((c=r.onCancel)==null||c.call(r),(d=r.resolvePrompt)==null||d.call(r,null)),um();return}e&&((u=r==null?void 0:r.onConfirm)==null||u.call(r)),um()}const ED=()=>{let e;return J(()=>{Rg()&&queueMicrotask(()=>{e==null||e.focus()})}),S(W,{get when(){return Rg()},keyed:!0,children:t=>{const n=t.variant??"info",r=hD[n],i=t.title||r.fallbackTitle,s=t.type==="confirm",o=t.type==="prompt",a=t.confirmLabel||(s?"Confirm":o?"Run":"OK"),l=t.cancelLabel||"Cancel",[c,d]=U(t.inputDefaultValue??"");return S(ft,{open:!0,modal:!0,onOpenChange:u=>{u||Sd(!1,t)},get children(){return S(ft.Portal,{get children(){return[S(ft.Overlay,{class:"modal-overlay"}),(()=>{var u=gD();return C(u,S(ft.Content,{class:"modal-surface w-full max-w-sm p-6 border border-base shadow-2xl",tabIndex:-1,get children(){return[(()=>{var _=uD(),m=_.firstChild,g=m.nextSibling;return C(m,()=>r.symbol),C(g,S(ft.Title,{class:"text-lg font-semibold text-primary",children:i}),null),C(g,S(ft.Description,{class:"text-sm text-secondary mt-1 whitespace-pre-line break-words",get children(){return[we(()=>t.message),we(()=>we(()=>!!t.detail)()&&(()=>{var p=fD();return C(p,()=>t.detail),p})())]}}),null),ne(p=>{var E=r.badgeBg,h=r.badgeBorder,f=r.badgeText;return E!==p.e&&Ci(m,"background-color",p.e=E),h!==p.t&&Ci(m,"border-color",p.t=h),f!==p.a&&Ci(m,"color",p.a=f),p},{e:void 0,t:void 0,a:void 0}),_})(),S(W,{when:o,get children(){var _=_D(),m=_.firstChild,g=m.nextSibling;return C(m,()=>t.inputLabel||"Arguments"),g.$$keydown=p=>{p.key==="Enter"&&(p.preventDefault(),Sd(!0,t,c()))},g.$$input=p=>d(p.currentTarget.value),ne(()=>Fe(g,"placeholder",t.inputPlaceholder||"")),ne(()=>g.value=c()),_}}),(()=>{var _=mD(),m=_.firstChild;return C(_,(s||o)&&(()=>{var g=pD();return g.$$click=()=>Sd(!1,t),C(g,l),g})(),m),m.$$click=()=>Sd(!0,t,c()),wt(g=>{e=g},m),C(m,a),_})()]}})),u})()]}})}})}})};Ht(["input","keydown","click"]);const Ko={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};var SD=x("<svg>");const bD=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),It=e=>{const[t,n]=lt(e,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var r=SD();return Ii(r,oe(Ko,{get width(){return t.size??Ko.width},get height(){return t.size??Ko.height},get stroke(){return t.color??Ko.stroke},get"stroke-width"(){return we(()=>!!t.absoluteStrokeWidth)()?Number(t.strokeWidth??Ko["stroke-width"])*24/Number(t.size):Number(t.strokeWidth??Ko["stroke-width"])},get class(){return`lucide lucide-${bD((t==null?void 0:t.name)??"icon")} ${t.class!=null?t.class:""}`}},n),!0,!0),C(r,S(_t,{get each(){return t.iconNode},children:([i,s])=>S(fu,oe({component:i},s))})),r})()},vD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],yD=e=>S(It,oe(e,{name:"AlertCircle",iconNode:vD})),TD=[["path",{d:"M15 6v6h4l-7 7-7-7h4V6h6z",key:"1thax2"}]],CD=e=>S(It,oe(e,{name:"ArrowBigDown",iconNode:TD})),RD=[["path",{d:"M9 18v-6H5l7-7 7 7h-4v6H9z",key:"1x06kx"}]],ID=e=>S(It,oe(e,{name:"ArrowBigUp",iconNode:RD})),OD=[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]],Jy=e=>S(It,oe(e,{name:"ArrowUpLeft",iconNode:OD})),ND=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],eT=e=>S(It,oe(e,{name:"Bot",iconNode:ND})),AD=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],wD=e=>S(It,oe(e,{name:"Check",iconNode:AD})),xD=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Qc=e=>S(It,oe(e,{name:"ChevronDown",iconNode:xD})),DD=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],LD=e=>S(It,oe(e,{name:"ChevronRight",iconNode:DD})),kD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],MD=e=>S(It,oe(e,{name:"Clock",iconNode:kD})),PD=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],$D=e=>S(It,oe(e,{name:"Copy",iconNode:PD})),FD=[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]],BD=e=>S(It,oe(e,{name:"Expand",iconNode:FD})),UD=[["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}],["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["line",{x1:"10",x2:"21",y1:"14",y2:"3",key:"18c3s4"}]],GD=e=>S(It,oe(e,{name:"ExternalLink",iconNode:UD})),VD=[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}]],HD=e=>S(It,oe(e,{name:"File",iconNode:VD})),YD=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]],tT=e=>S(It,oe(e,{name:"FoldVertical",iconNode:YD})),zD=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],nT=e=>S(It,oe(e,{name:"FolderOpen",iconNode:zD})),WD=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],qD=e=>S(It,oe(e,{name:"FolderPlus",iconNode:WD})),KD=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ap=e=>S(It,oe(e,{name:"Folder",iconNode:KD})),QD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],jD=e=>S(It,oe(e,{name:"Globe",iconNode:QD})),XD=[["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["path",{d:"m15.5 7.5 3 3L22 7l-3-3",key:"1rn1fs"}]],GE=e=>S(It,oe(e,{name:"Key",iconNode:XD})),ZD=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],JD=e=>S(It,oe(e,{name:"Link2",iconNode:ZD})),e0=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ro=e=>S(It,oe(e,{name:"Loader2",iconNode:e0})),t0=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],n0=e=>S(It,oe(e,{name:"Maximize2",iconNode:t0})),r0=[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],i0=e=>S(It,oe(e,{name:"Minimize2",iconNode:r0})),s0=[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],rT=e=>S(It,oe(e,{name:"MonitorUp",iconNode:s0})),o0=[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],iT=e=>S(It,oe(e,{name:"Pencil",iconNode:o0})),a0=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],lp=e=>S(It,oe(e,{name:"Plus",iconNode:a0})),l0=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],c0=e=>S(It,oe(e,{name:"RefreshCw",iconNode:l0})),d0=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],u0=e=>S(It,oe(e,{name:"Search",iconNode:d0})),_0=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],m0=e=>S(It,oe(e,{name:"Settings",iconNode:_0})),g0=[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],__=e=>S(It,oe(e,{name:"ShieldAlert",iconNode:g0})),f0=[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}]],VE=e=>S(It,oe(e,{name:"Shield",iconNode:f0})),p0=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],h0=e=>S(It,oe(e,{name:"TerminalSquare",iconNode:p0})),E0=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],al=e=>S(It,oe(e,{name:"Trash2",iconNode:E0})),S0=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],sT=e=>S(It,oe(e,{name:"User",iconNode:S0})),b0=[["path",{d:"M5 13a10 10 0 0 1 14 0",key:"6v8j51"}],["path",{d:"M8.5 16.5a5 5 0 0 1 7 0",key:"sej527"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["line",{x1:"12",x2:"12.01",y1:"20",y2:"20",key:"of4bc4"}]],v0=e=>S(It,oe(e,{name:"Wifi",iconNode:b0})),y0=[["polygon",{points:"7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2",key:"h1p8hx"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],T0=e=>S(It,oe(e,{name:"XOctagon",iconNode:y0})),C0=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],cp=e=>S(It,oe(e,{name:"X",iconNode:C0})),HE="http://127.0.0.1:9898";var Sy;const R0=typeof window<"u"?(Sy=window.location)==null?void 0:Sy.origin:void 0,I0=typeof window<"u"?window.__CODENOMAD_API_BASE__??R0??HE:HE,O0=typeof window<"u"?window.__CODENOMAD_EVENTS_URL__??"/api/events":"/api/events",Ua=I0,YE=w0(Ua,O0),N0=Ua;function A0(e,t){const n=encodeURIComponent(e),r=encodeURIComponent(t);return x0(`/workspaces/${n}/plugin/background-processes/${r}/stream`)}function w0(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(e){const n=t.startsWith("/")?t:`/${t}`;return`${e}${n}`}return t}function x0(e){if(e.startsWith("http://")||e.startsWith("https://")||!Ua)return e;const t=e.startsWith("/")?e:`/${e}`;return`${Ua}${t}`}const zE=vt("api"),_m=vt("sse");function D0(e){const t={};if(!e)return t;if(e instanceof Headers)return e.forEach((n,r)=>{t[r]=n}),t;if(Array.isArray(e)){for(const[n,r]of e)t[n]=r;return t}return{...e}}function bd(e,t){if(t){zE.info(e,t);return}zE.info(e)}async function cn(e,t){const n=Ua?new URL(e,Ua).toString():e,r=D0(t==null?void 0:t.headers);(t==null?void 0:t.body)!==void 0&&(r["Content-Type"]="application/json");const i=((t==null?void 0:t.method)??"GET").toUpperCase(),s=Date.now();bd(`${i} ${e}`);try{const o=await fetch(n,{...t,headers:r,credentials:(t==null?void 0:t.credentials)??"include"});if(!o.ok){const l=await o.text();throw bd(`${i} ${e} -> ${o.status}`,{durationMs:Date.now()-s,error:l}),new Error(l||`Request failed with ${o.status}`)}const a=Date.now()-s;return bd(`${i} ${e} -> ${o.status}`,{durationMs:a}),o.status===204?void 0:await o.json()}catch(o){throw bd(`${i} ${e} failed`,{durationMs:Date.now()-s,error:o}),o}}const vn={fetchWorkspaces(){return cn("/api/workspaces")},createWorkspace(e){return cn("/api/workspaces",{method:"POST",body:JSON.stringify(e)})},fetchServerMeta(){return cn("/api/meta")},fetchAuthStatus(){return cn("/api/auth/status")},setServerPassword(e){return cn("/api/auth/password",{method:"POST",body:JSON.stringify({password:e})})},deleteWorkspace(e){return cn(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})},listWorkspaceFiles(e,t="."){const n=new URLSearchParams({path:t});return cn(`/api/workspaces/${encodeURIComponent(e)}/files?${n.toString()}`)},searchWorkspaceFiles(e,t,n){const r=t.trim();if(!r)return Promise.resolve([]);const i=new URLSearchParams({q:r});return n!=null&&n.limit&&i.set("limit",String(n.limit)),n!=null&&n.type&&i.set("type",n.type),cn(`/api/workspaces/${encodeURIComponent(e)}/files/search?${i.toString()}`)},readWorkspaceFile(e,t){const n=new URLSearchParams({path:t});return cn(`/api/workspaces/${encodeURIComponent(e)}/files/content?${n.toString()}`)},fetchConfig(){return cn("/api/config/app")},updateConfig(e){return cn("/api/config/app",{method:"PUT",body:JSON.stringify(e)})},listBinaries(){return cn("/api/config/binaries")},createBinary(e){return cn("/api/config/binaries",{method:"POST",body:JSON.stringify(e)})},updateBinary(e,t){return cn(`/api/config/binaries/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})},deleteBinary(e){return cn(`/api/config/binaries/${encodeURIComponent(e)}`,{method:"DELETE"})},validateBinary(e){return cn("/api/config/binaries/validate",{method:"POST",body:JSON.stringify({path:e})})},listFileSystem(e,t){const n=new URLSearchParams;e&&e!=="."&&n.set("path",e),(t==null?void 0:t.includeFiles)!==void 0&&n.set("includeFiles",String(t.includeFiles));const r=n.toString();return cn(r?`/api/filesystem?${r}`:"/api/filesystem")},readInstanceData(e){return cn(`/api/storage/instances/${encodeURIComponent(e)}`)},writeInstanceData(e,t){return cn(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})},deleteInstanceData(e){return cn(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"DELETE"})},listBackgroundProcesses(e){return cn(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes`)},stopBackgroundProcess(e,t){return cn(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes/${encodeURIComponent(t)}/stop`,{method:"POST"})},terminateBackgroundProcess(e,t){return cn(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes/${encodeURIComponent(t)}/terminate`,{method:"POST"})},fetchBackgroundProcessOutput(e,t,n){const r=new URLSearchParams;n!=null&&n.method&&r.set("method",n.method),n!=null&&n.pattern&&r.set("pattern",n.pattern),n!=null&&n.lines&&r.set("lines",String(n.lines)),(n==null?void 0:n.maxBytes)!==void 0&&r.set("maxBytes",String(n.maxBytes));const i=r.toString(),s=i?`?${i}`:"";return cn(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes/${encodeURIComponent(t)}/output${s}`)},connectEvents(e,t){_m.info(`Connecting to ${YE}`);const n=new EventSource(YE,{withCredentials:!0});return n.onmessage=r=>{try{const i=JSON.parse(r.data);e(i)}catch(i){_m.error("Failed to parse event",i)}},n.onerror=()=>{_m.warn("EventSource error, closing stream"),t==null||t()},n}},WE=1e3,L0=1e4,qE=vt("sse");function vd(e,t){if(t){qE.info(e,t);return}qE.info(e)}class k0{constructor(){this.handlers=new Map,this.source=null,this.retryDelay=WE,this.connect()}connect(){this.source&&this.source.close(),vd("Connecting to backend events stream"),this.source=vn.connectEvents(t=>this.dispatch(t),()=>this.scheduleReconnect()),this.source.onopen=()=>{vd("Events stream connected"),this.retryDelay=WE}}scheduleReconnect(){this.source&&(this.source.close(),this.source=null),vd("Events stream disconnected, scheduling reconnect",{delayMs:this.retryDelay}),setTimeout(()=>{this.retryDelay=Math.min(this.retryDelay*2,L0),this.connect()},this.retryDelay)}dispatch(t){var n,r;vd(`event ${t.type}`),(n=this.handlers.get("*"))==null||n.forEach(i=>i(t)),(r=this.handlers.get(t.type))==null||r.forEach(i=>i(t))}on(t,n){this.handlers.has(t)||this.handlers.set(t,new Set);const r=this.handlers.get(t);return r.add(n),()=>r.delete(n)}}const Ga=new k0,M0=vt("actions"),KE={messageHistory:[],agentModelSelections:{}};function QE(e,t){if(e===t)return!0;if(typeof e=="object"&&e!==null&&typeof t=="object"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){M0.warn("Failed to compare config objects",n)}return!1}class P0{constructor(){this.configChangeListeners=new Set,this.configCache=null,this.loadPromise=null,this.instanceDataCache=new Map,this.instanceDataListeners=new Map,this.instanceLoadPromises=new Map,Ga.on("config.appChanged",t=>{t.type==="config.appChanged"&&this.setConfigCache(t.config)}),Ga.on("instance.dataChanged",t=>{t.type==="instance.dataChanged"&&this.setInstanceDataCache(t.instanceId,t.data)})}async loadConfig(){return this.configCache?this.configCache:(this.loadPromise||(this.loadPromise=vn.fetchConfig().then(t=>(this.setConfigCache(t),t)).finally(()=>{this.loadPromise=null})),this.loadPromise)}async updateConfig(t){const n=await vn.updateConfig(t);return this.setConfigCache(n),n}async loadInstanceData(t){const n=this.instanceDataCache.get(t);if(n)return n;if(!this.instanceLoadPromises.has(t)){const r=vn.readInstanceData(t).then(i=>{const s=this.normalizeInstanceData(i);return this.setInstanceDataCache(t,s),s}).finally(()=>{this.instanceLoadPromises.delete(t)});this.instanceLoadPromises.set(t,r)}return this.instanceLoadPromises.get(t)}async saveInstanceData(t,n){const r=this.normalizeInstanceData(n);await vn.writeInstanceData(t,r),this.setInstanceDataCache(t,r)}async deleteInstanceData(t){await vn.deleteInstanceData(t),this.setInstanceDataCache(t,KE)}onConfigChanged(t){return this.configChangeListeners.add(t),this.configCache&&t(this.configCache),()=>this.configChangeListeners.delete(t)}onInstanceDataChanged(t,n){this.instanceDataListeners.has(t)||this.instanceDataListeners.set(t,new Set);const r=this.instanceDataListeners.get(t);r.add(n);const i=this.instanceDataCache.get(t);return i&&n(i),()=>{r.delete(n),r.size===0&&this.instanceDataListeners.delete(t)}}setConfigCache(t){if(this.configCache&&QE(this.configCache,t)){this.configCache=t;return}this.configCache=t,this.notifyConfigChanged(t)}notifyConfigChanged(t){for(const n of this.configChangeListeners)n(t)}normalizeInstanceData(t){const n=t??KE,r=Array.isArray(n.messageHistory)?[...n.messageHistory]:[],i={...n.agentModelSelections??{}};return{...n,messageHistory:r,agentModelSelections:i}}setInstanceDataCache(t,n){const r=this.normalizeInstanceData(n),i=this.instanceDataCache.get(t);if(i&&QE(i,r)){this.instanceDataCache.set(t,r);return}this.instanceDataCache.set(t,r),this.notifyInstanceDataChanged(t,r)}notifyInstanceDataChanged(t,n){const r=this.instanceDataListeners.get(t);if(r)for(const i of r)i(n)}}const Io=new P0,oT=vt("api"),m_={messageHistory:[],agentModelSelections:{}},[dp,aT]=U(new Map),yd=new Map,Va=new Map;function lT(e){const t=e??m_;return{...t,messageHistory:Array.isArray(t.messageHistory)?[...t.messageHistory]:[],agentModelSelections:{...t.agentModelSelections??{}}}}function jE(e){if(Va.has(e))return;const t=Io.onInstanceDataChanged(e,n=>{bu(e,n)});Va.set(e,t)}function $0(e){const t=Va.get(e);t&&(t(),Va.delete(e))}function bu(e,t){aT(n=>{const r=new Map(n);return r.set(e,lT(t)),r})}async function Bo(e){if(!e||dp().has(e))return;if(yd.has(e)){await yd.get(e);return}const t=Io.loadInstanceData(e).then(n=>{bu(e,n),jE(e)}).catch(n=>{oT.warn("Failed to load instance data",n),bu(e,m_),jE(e)}).finally(()=>{yd.delete(e)});yd.set(e,t),await t}async function up(e,t){if(!e)return;await Bo(e);const n=dp().get(e)??m_,r=lT(n);t(r);try{await Io.saveInstanceData(e,r)}catch(i){oT.warn("Failed to persist instance data",i)}bu(e,r)}function _p(e){return dp().get(e)??m_}function F0(e){aT(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),$0(e)}const B0=Jt(),U0={getInstanceConfig:_p,ensureInstanceConfig:Bo,updateInstanceConfig:up,clearInstanceConfig:F0},G0=e=>(Ne(()=>{for(const t of Va.values())t();Va.clear()}),S(B0.Provider,{value:U0,get children(){return e.children}})),Hi=vt("actions"),V0=20,H0=5,Jr={showThinkingBlocks:!1,thinkingBlocksExpansion:"expanded",showTimelineTools:!0,environmentVariables:{},modelRecents:[],diffViewMode:"split",toolOutputExpansion:"expanded",diagnosticsExpansion:"expanded",showUsageMetrics:!0,autoCleanupBlankSessions:!0,listeningMode:"local"};function cT(e,t){if(e===t)return!0;if(typeof e=="object"&&e!==null&&typeof t=="object"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){Hi.warn("Failed to compare preference values",n)}return!1}function g_(e){const t=e??{},n={...Jr.environmentVariables,...t.environmentVariables??{}},i=(t.modelRecents??Jr.modelRecents).map(s=>({...s}));return{showThinkingBlocks:t.showThinkingBlocks??Jr.showThinkingBlocks,thinkingBlocksExpansion:t.thinkingBlocksExpansion??Jr.thinkingBlocksExpansion,showTimelineTools:t.showTimelineTools??Jr.showTimelineTools,lastUsedBinary:t.lastUsedBinary??Jr.lastUsedBinary,environmentVariables:n,modelRecents:i,diffViewMode:t.diffViewMode??Jr.diffViewMode,toolOutputExpansion:t.toolOutputExpansion??Jr.toolOutputExpansion,diagnosticsExpansion:t.diagnosticsExpansion??Jr.diagnosticsExpansion,showUsageMetrics:t.showUsageMetrics??Jr.showUsageMetrics,autoCleanupBlankSessions:t.autoCleanupBlankSessions??Jr.autoCleanupBlankSessions,listeningMode:t.listeningMode??Jr.listeningMode}}const[no,Y0]=U(_T()),z0=F(()=>no()),[dT,W0]=U(!1),Jn=F(()=>no().preferences),q0=F(()=>no().recentFolders??[]),K0=F(()=>no().opencodeBinaries??[]),uT=F(()=>no().theme??"dark");let Td=null;function f_(e){return{preferences:g_(e==null?void 0:e.preferences),recentFolders:((e==null?void 0:e.recentFolders)??[]).map(t=>({...t})),opencodeBinaries:((e==null?void 0:e.opencodeBinaries)??[]).map(t=>({...t})),theme:(e==null?void 0:e.theme)??"dark"}}function _T(){return f_()}function Q0(e){var r;const t=!!((r=e==null?void 0:e.preferences)!=null&&r.agentModelSelections);return{cleaned:f_(e),migrated:t}}async function mp(e){try{const t=e??await Io.loadConfig(),{cleaned:n,migrated:r}=Q0(t);Ig(n),r&&Io.updateConfig(n).catch(i=>{Hi.error("Failed to persist legacy config cleanup",i)})}catch(t){Hi.error("Failed to load config",t),Ig(_T())}}function Ig(e){Y0(f_(e)),W0(!0)}function j0(){return f_(no())}function X0(e,t){if(cT(e,t))return;const n=mT(e,t);n.length>0&&Hi.info("[Config] Changes",n)}function mT(e,t,n=[]){if(e===t)return[];if(typeof e!="object"||e===null||typeof t!="object"||t===null)return[n.join(".")];const r=Object.keys(e),i=Object.keys(t),s=new Set([...r,...i]),o=[];for(const a of s){const l=[...n,a],c=e[a],d=t[a];o.push(...mT(c,d,l))}return o}function vs(e){const t=no(),n=j0();e(n),X0(t,n),Ig(n),Z0(n)}async function Z0(e){try{await gp(),await Io.updateConfig(e)}catch(t){Hi.error("Failed to save config",t),mp().catch(n=>{Hi.error("Failed to refresh config",n)})}}function J0(e){uT()!==e&&vs(t=>{t.theme=e})}async function gp(){dT()||(Td||(Td=mp().finally(()=>{Td=null})),await Td)}function gT(e,t){const n=t.filter(r=>r.path!==e);return n.unshift({path:e,lastAccessed:Date.now()}),n.slice(0,V0)}function fp(e,t,n){const r=Date.now(),i=n.find(o=>o.path===e);if(i){const o={...i,lastUsed:r},a=n.filter(l=>l.path!==e);return[o,...a]}return[t?{path:e,version:t,lastUsed:r}:{path:e,lastUsed:r},...n].slice(0,10)}function di(e){const t=no().preferences,n=g_({...t,...e});cT(t,n)||vs(r=>{r.preferences=n})}function fT(e){Jn().listeningMode!==e&&di({listeningMode:e})}function eL(e){Jn().diffViewMode!==e&&di({diffViewMode:e})}function tL(e){Jn().toolOutputExpansion!==e&&di({toolOutputExpansion:e})}function nL(e){Jn().diagnosticsExpansion!==e&&di({diagnosticsExpansion:e})}function rL(e){Jn().thinkingBlocksExpansion!==e&&di({thinkingBlocksExpansion:e})}function iL(){di({showThinkingBlocks:!Jn().showThinkingBlocks})}function sL(){di({showTimelineTools:!Jn().showTimelineTools})}function oL(){di({showUsageMetrics:!Jn().showUsageMetrics})}function aL(){const e=!Jn().autoCleanupBlankSessions;Hi.info("toggle auto cleanup",{value:e}),di({autoCleanupBlankSessions:e})}function lL(e){vs(t=>{t.recentFolders=gT(e,t.recentFolders)})}function cL(e){vs(t=>{t.recentFolders=t.recentFolders.filter(n=>n.path!==e)})}function dL(e,t){vs(n=>{n.opencodeBinaries=fp(e,t,n.opencodeBinaries)})}function uL(e){vs(t=>{t.opencodeBinaries=t.opencodeBinaries.filter(n=>n.path!==e)})}function _L(e){const t=e||Jn().lastUsedBinary||"opencode";vs(n=>{n.preferences=g_({...n.preferences,lastUsedBinary:t}),n.opencodeBinaries=fp(t,void 0,n.opencodeBinaries)})}function mL(e,t){vs(n=>{const r=t&&t.trim().length>0?t:n.preferences.lastUsedBinary||"opencode";n.recentFolders=gT(e,n.recentFolders),n.preferences=g_({...n.preferences,lastUsedBinary:r}),n.opencodeBinaries=fp(r,void 0,n.opencodeBinaries)})}function pp(e){di({environmentVariables:e})}function gL(e,t){const r={...Jn().environmentVariables||{},[e]:t};pp(r)}function fL(e){const t=Jn().environmentVariables||{},{[e]:n,...r}=t;pp(r)}function pT(e){if(!e.providerId||!e.modelId)return;const n=(Jn().modelRecents??[]).filter(i=>i.providerId!==e.providerId||i.modelId!==e.modelId),r=[e,...n].slice(0,H0);di({modelRecents:r})}async function p_(e,t,n){!e||!t||!n.providerId||!n.modelId||(await Bo(e),await up(e,r=>{const i={...r.agentModelSelections??{}},s=i[t];s&&s.providerId===n.providerId&&s.modelId===n.modelId||(i[t]=n,r.agentModelSelections=i)}))}async function hT(e,t){return!e||!t?void 0:(await Bo(e),(_p(e).agentModelSelections??{})[t])}gp().catch(e=>{Hi.error("Failed to initialize config",e)});const ET=Jt(),pL={isLoaded:dT,config:z0,preferences:Jn,recentFolders:q0,opencodeBinaries:K0,themePreference:uT,setThemePreference:J0,updateConfig:vs,toggleShowThinkingBlocks:iL,toggleShowTimelineTools:sL,toggleUsageMetrics:oL,toggleAutoCleanupBlankSessions:aL,setDiffViewMode:eL,setToolOutputExpansion:tL,setDiagnosticsExpansion:nL,setThinkingBlocksExpansion:rL,setListeningMode:fT,addRecentFolder:lL,removeRecentFolder:cL,addOpenCodeBinary:dL,removeOpenCodeBinary:uL,updateLastUsedBinary:_L,recordWorkspaceLaunch:mL,updatePreferences:di,updateEnvironmentVariables:pp,addEnvironmentVariable:gL,removeEnvironmentVariable:fL,addRecentModelPreference:pT,setAgentModelPreference:p_,getAgentModelPreference:hT},hL=e=>(Tn(()=>{gp().catch(n=>{Hi.error("Failed to initialize config",n)});const t=Io.onConfigChanged(n=>{mp(n).catch(r=>{Hi.error("Failed to refresh config",r)})});return()=>{t()}}),S(ET.Provider,{value:pL,get children(){return e.children}}));function ro(){const e=en(ET);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e}var EL=x('<p class="text-xs text-muted mt-1 font-mono break-all">Root: '),SL=x('<div class="px-4 pb-2"><div class="flex items-center justify-between gap-3 rounded-md border border-border-subtle px-4 py-3"><div><p class="text-xs text-secondary uppercase tracking-wide">Current folder</p><p class="text-sm font-mono text-primary break-all"></p></div><button type=button class="selector-button selector-button-secondary whitespace-nowrap">Select Current'),bL=x('<div class="flex items-center gap-2 px-4 py-2 text-xs text-secondary"><span>Loading <!>…'),vL=x('<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-6"><div class="modal-surface max-h-full w-full max-w-3xl overflow-hidden rounded-xl bg-surface p-0"role=dialog aria-modal=true><div class="panel flex flex-col"><div class="panel-header flex items-start justify-between gap-4"><div><h3 class=panel-title></h3><p class=panel-subtitle></p></div><button type=button class="selector-button selector-button-secondary">Close</button></div><div class=panel-body><label class="w-full text-sm text-secondary mb-2 block">Filter</label><div class=selector-input-group><div class="flex items-center gap-2 px-3 text-muted"></div><input type=text class=selector-input></div></div><div class="panel-list panel-list--fill max-h-96 overflow-auto"></div><div class=panel-footer><div class=panel-footer-hints><div class="flex items-center gap-1.5"><kbd class=kbd>↑</kbd><kbd class=kbd>↓</kbd><span>Navigate</span></div><div class="flex items-center gap-1.5"><kbd class=kbd>Enter</kbd><span>Select</span></div><div class="flex items-center gap-1.5"><kbd class=kbd>Esc</kbd><span>Close'),yL=x('<div class="flex items-center gap-2"><span>Loading <!>…'),TL=x('<div class="flex items-center justify-center py-6 text-sm text-secondary">'),CL=x("<span class=text-red-500>"),RL=x('<div class="flex flex-col items-center justify-center gap-2 py-10 text-sm text-secondary"><p>No entries found.</p><button type=button class="selector-button selector-button-secondary">Retry'),IL=x('<div class=panel-list-item role=button><div class="panel-list-item-content directory-browser-row"><button type=button class=directory-browser-row-main><div class=directory-browser-row-icon></div><div class=directory-browser-row-text><span class=directory-browser-row-name>Up one level'),OL=x('<div class=panel-list-item role=listitem><div class="panel-list-item-content directory-browser-row"><button type=button class=directory-browser-row-main><div class=directory-browser-row-icon></div><div class=directory-browser-row-text><span class=directory-browser-row-name></span><span class=directory-browser-row-sub></span></div></button><button type=button class="selector-button selector-button-secondary directory-browser-select">Select');const NL=vt("actions"),AL=200;function mm(e){if(!e||e==="."||e==="./")return".";let t=e.replace(/\\/g,"/");return t.startsWith("./")&&(t=t.replace(/^\.\/+/,"")),t.startsWith("/")&&(t=t.replace(/^\/+/,"")),t=t.replace(/\/+/g,"/"),t===""?".":t}function Ol(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;const n=e.includes("\\")?"\\":"/",r=e.endsWith(n)?e:`${e}${n}`,i=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${r}${i}`}const wL=e=>{const[t,n]=U(""),[r,i]=U([]),[s,o]=U(null),[a,l]=U(null),[c,d]=U(null),[u,_]=U(""),[m,g]=U(0);let p;const E=new Map,h=new Map,f=new Map;function b(){E.clear(),h.clear(),f.clear(),i([]),o(null),l(null)}async function y(L,R=!1){const D=mm(L);if(E.has(D)&&h.has(D))return R&&(o(h.get(D)??null),i(E.get(D)??[])),h.get(D);if(f.has(D)){const P=await f.get(D);return R&&(o(P),i(E.get(D)??[])),P}const w=(async()=>{l(D);const P=await vn.listFileSystem(D==="."?".":D,{includeFiles:e.mode==="files"});return E.set(D,P.entries),h.set(D,P.metadata),t()||n(P.metadata.rootPath),a()===D&&l(null),P.metadata})().catch(P=>{throw a()===D&&l(null),P});f.set(D,w);try{const P=await w;if(R){const j=mm(P.currentPath);o(P),i(E.get(j)??E.get(D)??[])}return P}finally{f.delete(D)}}async function v(){d(null),b();try{const L=await y(".",!0);n(L.rootPath),i(E.get(mm(L.currentPath))??[])}catch(L){const R=L instanceof Error?L.message:"Unable to load filesystem";d(R)}}function O(){const L=a();return L?L==="."?t()||"workspace root":Ol(t(),L):"filesystem"}function T(){const L=s();return L?L.pathKind==="relative"?Ol(t(),L.currentPath):L.displayPath:t()}function I(L){L.target===L.currentTarget&&e.onClose()}function k(L){const R=Ol(t(),L.path);e.onSelect(R)}function A(L){y(L,!0).catch(R=>{NL.error("Failed to open directory",R),d(R instanceof Error?R.message:"Unable to open directory")})}function V(){var R;const L=(R=s())==null?void 0:R.parentPath;L&&A(L)}const B=F(()=>{const L=u().trim().toLowerCase(),R=r().filter(D=>e.mode==="directories"?D.type==="directory":!0);return L?R.filter(D=>Ol(t(),D.path).toLowerCase().includes(L)||D.name.toLowerCase().includes(L)):R}),$=F(()=>B().slice(0,AL)),M=F(()=>{const L=[],R=s();R!=null&&R.parentPath&&L.push({type:"up",path:R.parentPath});for(const D of $())L.push({type:"entry",entry:D});return L});return J(()=>{const L=$();if(L.length===0){g(0);return}m()>=L.length&&g(L.length-1)}),J(()=>{if(!e.open)return;_(""),g(0),v(),setTimeout(()=>p==null?void 0:p.focus(),50);const L=R=>{if(!e.open)return;const D=$();if(R.key==="Escape"){R.preventDefault(),e.onClose();return}if(D.length!==0){if(R.key==="ArrowDown")R.preventDefault(),g(w=>Math.min(w+1,D.length-1));else if(R.key==="ArrowUp")R.preventDefault(),g(w=>Math.max(w-1,0));else if(R.key==="Enter"){R.preventDefault();const w=D[m()];w&&k(w)}}};window.addEventListener("keydown",L),Ne(()=>{window.removeEventListener("keydown",L),b(),n(""),d(null)})}),S(W,{get when(){return e.open},get children(){var L=vL(),R=L.firstChild,D=R.firstChild,w=D.firstChild,P=w.firstChild,j=P.firstChild,le=j.nextSibling,me=P.nextSibling,Ae=me.firstChild,ie=w.nextSibling,re=ie.firstChild,Ee=re.nextSibling,Se=Ee.firstChild,q=Se.nextSibling,ae=ie.nextSibling;return L.$$click=I,C(j,()=>e.title),C(le,()=>e.description||"Search for a path under the configured workspace root."),C(P,S(W,{get when(){return t()},get children(){var N=EL();return N.firstChild,C(N,t,null),N}}),null),Fn(me,"click",e.onClose,!0),C(me,S(cp,{class:"w-4 h-4"}),Ae),C(Se,S(u0,{class:"w-4 h-4"})),q.$$input=N=>_(N.currentTarget.value),wt(N=>{p=N},q),C(D,S(W,{get when(){return e.mode==="directories"},get children(){var N=SL(),H=N.firstChild,te=H.firstChild,Q=te.firstChild,z=Q.nextSibling,he=te.nextSibling;return C(z,T),he.$$click=()=>e.onSelect(T()),N}}),ae),C(ae,S(W,{get when(){return r().length>0},get fallback(){return(()=>{var N=TL();return C(N,S(W,{get when(){return a()!==null},get fallback(){return(()=>{var H=CL();return C(H,c),H})()},get children(){var H=yL(),te=H.firstChild,Q=te.firstChild,z=Q.nextSibling;return z.nextSibling,C(H,S(Ro,{class:"w-4 h-4 animate-spin"}),te),C(te,O,z),H}})),N})()},get children(){return[S(W,{get when(){return a()},get children(){var N=bL(),H=N.firstChild,te=H.firstChild,Q=te.nextSibling;return Q.nextSibling,C(N,S(Ro,{class:"w-3.5 h-3.5 animate-spin"}),H),C(H,O,Q),N}}),S(W,{get when(){return M().length>0},get fallback(){return(()=>{var N=RL(),H=N.firstChild,te=H.nextSibling;return te.$$click=v,N})()},get children(){return S(_t,{get each(){return M()},children:N=>{if(N.type==="up")return(()=>{var z=IL(),he=z.firstChild,ue=he.firstChild,ce=ue.firstChild;return ue.$$click=V,C(ce,S(Jy,{class:"w-4 h-4"})),z})();const H=N.entry,te=()=>k(H),Q=()=>{H.type==="directory"?A(H.path):te()};return(()=>{var z=OL(),he=z.firstChild,ue=he.firstChild,ce=ue.firstChild,se=ce.nextSibling,ke=se.firstChild,We=ke.nextSibling,Oe=ue.nextSibling;return ue.$$click=Q,C(ce,S(W,{get when(){return H.type==="directory"},get fallback(){return S(HD,{class:"w-4 h-4"})},get children(){return S(ap,{class:"w-4 h-4"})}})),C(ke,()=>H.name||H.path),C(We,()=>Ol(t(),H.path)),Oe.$$click=je=>{je.stopPropagation(),te()},z})()}})}})]}})),ne(()=>Fe(q,"placeholder",e.mode==="directories"?"Search for folders":"Search for files")),ne(()=>q.value=u()),L}})};Ht(["click","input"]);const xL=vt("actions");function DL(e){if(!e||e.canceled)return null;const t=Array.isArray(e.paths)?e.paths:e.path?[e.path]:[];return t.length===0?null:t[0]??null}async function LL(e){if(typeof window>"u")return null;const t=window.electronAPI;if(!(t!=null&&t.openDialog))return null;try{const n=await t.openDialog(e);return DL(n)}catch(n){return xL.error("[native] electron dialog failed",n),null}}const kL=vt("actions");async function ML(e){var r;if(typeof window>"u")return null;const t=window.__TAURI__,n=t==null?void 0:t.dialog;if(!(n!=null&&n.open))return null;try{const i=await n.open({title:e.title,defaultPath:e.defaultPath,directory:e.mode==="directory",multiple:!1,filters:(r=e.filters)==null?void 0:r.map(s=>({name:s.name,extensions:s.extensions}))});return i?Array.isArray(i)?i[0]??null:i:null}catch(i){return kL.error("[native] tauri dialog failed",i),null}}function ST(){switch($a.host){case"electron":return LL;case"tauri":return ML;default:return null}}function bT(){return ST()!==null}async function vT(e){const t=ST();return t?t(e):null}async function PL(e){return vT({mode:"directory",...e??{}})}async function $L(e){return vT({mode:"file",...e??{}})}var FL=x('<div class="selector-loading text-xs"><span>Checking versions…'),BL=x("<div class=selector-validation-error><div class=selector-validation-error-content><span class=selector-validation-error-text>"),UL=x('<div class=panel><div class="panel-header flex items-center justify-between gap-3"><div><h3 class=panel-title>OpenCode Binary</h3><p class=panel-subtitle>Choose which executable OpenCode should run</p></div></div><div class="panel-body space-y-3"><div class=selector-input-group><input type=text placeholder="Enter path to opencode binary…"class=selector-input><button type=button class="selector-button selector-button-primary">Add</button></div><button type=button class="selector-button selector-button-secondary w-full flex items-center justify-center gap-2">Browse for Binary…</button></div><div class="panel-list panel-list--fill max-h-80 overflow-y-auto">'),GL=x('<div class="text-xs font-mono truncate pl-6 text-muted">'),VL=x("<span class=selector-badge-version>v"),HL=x("<span class=selector-badge-time>Checking…"),YL=x("<span class=selector-badge-time>"),zL=x("<span class=selector-badge-time>Use binary from system PATH"),WL=x('<button type=button class="p-2 text-muted hover:text-primary"title="Remove binary">'),qL=x('<div class="panel-list-item flex items-center"><button type=button class="panel-list-item-content flex-1"><div class="flex flex-col flex-1 min-w-0 gap-1.5"><div class="flex items-center gap-2"><span class="text-sm font-medium truncate text-primary"></span></div><div class="flex items-center gap-2 text-xs text-muted pl-6 flex-wrap">');const KL=vt("actions"),QL=e=>{const{opencodeBinaries:t,addOpenCodeBinary:n,removeOpenCodeBinary:r,preferences:i,updatePreferences:s}=ro(),[o,a]=U(""),[l,c]=U(!1),[d,u]=U(null),[_,m]=U(new Map),[g,p]=U(new Set),[E,h]=U(!1),f=bT(),b=()=>t(),y=()=>i().lastUsedBinary,v=F(()=>b().filter(w=>w.path!=="opencode")),O=F(()=>[{path:"opencode",isDefault:!0},...v()]),T=()=>e.selectedBinary||"opencode";J(()=>{if(!e.selectedBinary&&y())e.onBinaryChange(y());else if(!e.selectedBinary){const w=b()[0];w&&e.onBinaryChange(w.path)}}),J(()=>{const w=new Map(_());let P=!1;b().forEach(j=>{j.version&&!w.has(j.path)&&(w.set(j.path,j.version),P=!0)}),P&&m(w)}),J(()=>{if(!e.isVisible)return;const w=_(),P=["opencode",...v().map(j=>j.path)].filter(j=>!w.has(j));P.length!==0&&setTimeout(()=>{P.forEach(j=>{I(j).catch(le=>KL.error("Failed to validate binary",{path:j,error:le}))})},0)}),Ne(()=>{p(new Set),c(!1)});async function I(w){if(_().has(w)){const P=_().get(w);return P?{valid:!0,version:P}:{valid:!0}}if(g().has(w))return{valid:!1,error:"Already validating"};try{p(j=>new Set(j).add(w)),c(!0),u(null);const P=await vn.validateBinary(w);if(P.valid&&P.version){const j=new Map(_());j.set(w,P.version),m(j)}return P}catch(P){return{valid:!1,error:P instanceof Error?P.message:String(P)}}finally{p(P=>{const j=new Set(P);return j.delete(w),j.size===0&&c(!1),j})}}async function k(){if(!e.disabled){if(u(null),f){const w=await $L({title:"Select OpenCode Binary"});w&&(a(w),A(w));return}h(!0)}}async function A(w){const P=await I(w);P.valid?(n(w,P.version),e.onBinaryChange(w),s({lastUsedBinary:w}),a(""),u(null)):u(P.error||"Invalid OpenCode binary")}function V(w){h(!1),a(w),A(w)}async function B(){const w=o().trim();w&&await A(w)}function $(w){e.disabled||w!==e.selectedBinary&&(e.onBinaryChange(w),s({lastUsedBinary:w}))}function M(w,P){P.stopPropagation(),!e.disabled&&(r(w),e.selectedBinary===w&&(e.onBinaryChange("opencode"),s({lastUsedBinary:"opencode"})))}function L(w){if(!w)return"";const P=Math.floor((Date.now()-w)/1e3),j=Math.floor(P/60),le=Math.floor(j/60),me=Math.floor(le/24);return me>0?`${me}d ago`:le>0?`${le}h ago`:j>0?`${j}m ago`:"just now"}function R(w){if(w==="opencode")return"opencode (system PATH)";const P=w.split(/[/\\]/);return P[P.length-1]??w}const D=w=>g().has(w);return[(()=>{var w=UL(),P=w.firstChild;P.firstChild;var j=P.nextSibling,le=j.firstChild,me=le.firstChild,Ae=me.nextSibling,ie=Ae.firstChild,re=le.nextSibling,Ee=re.firstChild,Se=j.nextSibling;return C(P,S(W,{get when(){return l()},get children(){var q=FL(),ae=q.firstChild;return C(q,S(Ro,{class:"selector-loading-spinner"}),ae),q}}),null),me.$$keydown=q=>{q.key==="Enter"&&(q.preventDefault(),B())},me.$$input=q=>a(q.currentTarget.value),Ae.$$click=B,C(Ae,S(lp,{class:"w-4 h-4"}),ie),re.$$click=()=>void k(),C(re,S(nT,{class:"w-4 h-4"}),Ee),C(j,S(W,{get when(){return d()},get children(){var q=BL(),ae=q.firstChild,N=ae.firstChild;return C(ae,S(yD,{class:"selector-validation-error-icon"}),N),C(N,d),q}}),null),C(Se,S(_t,{get each(){return O()},children:q=>{const ae=q.isDefault,N=()=>_().get(q.path)??q.version;return(()=>{var H=qL(),te=H.firstChild,Q=te.firstChild,z=Q.firstChild,he=z.firstChild,ue=z.nextSibling;return te.$$click=()=>$(q.path),C(z,S(wD,{get class(){return`w-4 h-4 transition-opacity ${T()===q.path?"opacity-100":"opacity-0"}`}}),he),C(he,()=>R(q.path)),C(Q,S(W,{when:!ae,get children(){var ce=GL();return C(ce,()=>q.path),ce}}),ue),C(ue,S(W,{get when(){return N()},get children(){var ce=VL();return ce.firstChild,C(ce,N,null),ce}}),null),C(ue,S(W,{get when(){return D(q.path)},get children(){return HL()}}),null),C(ue,S(W,{get when(){return!ae&&q.lastUsed},get children(){var ce=YL();return C(ce,()=>L(q.lastUsed)),ce}}),null),C(ue,S(W,{when:ae,get children(){return zL()}}),null),C(H,S(W,{when:!ae,get children(){var ce=WL();return ce.$$click=se=>M(q.path,se),C(ce,S(al,{class:"w-3.5 h-3.5"})),ne(()=>ce.disabled=e.disabled),ce}}),null),ne(ce=>{var se=T()===q.path,ke=e.disabled;return se!==ce.e&&H.classList.toggle("panel-list-item-highlight",ce.e=se),ke!==ce.t&&(te.disabled=ce.t=ke),ce},{e:void 0,t:void 0}),H})()}})),ne(q=>{var ae=e.disabled,N=e.disabled||!o().trim(),H=e.disabled;return ae!==q.e&&(me.disabled=q.e=ae),N!==q.t&&(Ae.disabled=q.t=N),H!==q.a&&(re.disabled=q.a=H),q},{e:void 0,t:void 0,a:void 0}),ne(()=>me.value=o()),w})(),S(wL,{get open(){return E()},mode:"files",title:"Select OpenCode Binary",description:"Browse files exposed by the CLI server.",onClose:()=>h(!1),onSelect:V})]};Ht(["input","keydown","click"]);var jL=x("<div class=space-y-2>"),XL=x('<div class="text-xs text-muted text-center py-2">No environment variables configured. Add variables above to customize the OpenCode environment.'),ZL=x('<div class=space-y-3><div class="flex items-center gap-2 mb-3"><span class="text-sm font-medium text-secondary">Environment Variables</span><span class="text-xs text-muted">(<!> variable<!>)</span></div><div class="flex items-center gap-2 pt-2 border-t border-base"><div class="flex-1 flex items-center gap-2"><input type=text class="flex-1 px-2.5 py-1.5 text-sm bg-surface-base border border-base rounded text-primary focus-ring-accent disabled:opacity-50 disabled:cursor-not-allowed"placeholder="Variable name"><input type=text class="flex-1 px-2.5 py-1.5 text-sm bg-surface-base border border-base rounded text-primary focus-ring-accent disabled:opacity-50 disabled:cursor-not-allowed"placeholder="Variable value"></div><button class="p-1.5 icon-muted icon-accent-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors"title="Add variable"></button></div><div class="text-xs text-muted mt-2">These variables will be available in the OpenCode environment when starting instances.'),JL=x('<div class="flex items-center gap-2"><div class="flex-1 flex items-center gap-2"><input type=text class="flex-1 px-2.5 py-1.5 text-sm bg-surface-secondary border border-base rounded text-muted cursor-not-allowed"placeholder="Variable name"title="Variable name (read-only)"><input type=text class="flex-1 px-2.5 py-1.5 text-sm bg-surface-base border border-base rounded text-primary focus-ring-accent disabled:opacity-50 disabled:cursor-not-allowed"placeholder="Variable value"></div><button class="p-1.5 icon-muted icon-danger-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors"title="Remove variable">');const ek=e=>{const{preferences:t,addEnvironmentVariable:n,removeEnvironmentVariable:r,updateEnvironmentVariables:i}=ro(),[s,o]=U(t().environmentVariables||{}),[a,l]=U(""),[c,d]=U(""),u=()=>Object.entries(s());function _(){const E=a().trim(),h=c().trim();E&&(n(E,h),o({...s(),[E]:h}),l(""),d(""))}function m(E){r(E);const{[E]:h,...f}=s();o(f)}function g(E,h){const f={...s(),[E]:h};o(f),i(f)}function p(E){E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),_())}return(()=>{var E=ZL(),h=E.firstChild,f=h.firstChild,b=f.nextSibling,y=b.firstChild,v=y.nextSibling,O=v.nextSibling,T=O.nextSibling;T.nextSibling;var I=h.nextSibling,k=I.firstChild,A=k.firstChild,V=A.nextSibling,B=k.nextSibling,$=I.nextSibling;return C(h,S(jD,{class:"w-4 h-4 icon-muted"}),f),C(b,()=>u().length,v),C(b,()=>u().length!==1?"s":"",T),C(E,S(W,{get when(){return u().length>0},get children(){var M=jL();return C(M,S(_t,{get each(){return u()},children:([L,R])=>(()=>{var D=JL(),w=D.firstChild,P=w.firstChild,j=P.nextSibling,le=w.nextSibling;return C(w,S(GE,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),P),P.value=L,j.$$input=me=>g(L,me.currentTarget.value),j.value=R,le.$$click=()=>m(L),C(le,S(al,{class:"w-3.5 h-3.5"})),ne(me=>{var Ae=e.disabled,ie=e.disabled,re=e.disabled;return Ae!==me.e&&(P.disabled=me.e=Ae),ie!==me.t&&(j.disabled=me.t=ie),re!==me.a&&(le.disabled=me.a=re),me},{e:void 0,t:void 0,a:void 0}),D})()})),M}}),I),C(k,S(GE,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),A),A.addEventListener("keypress",p),A.$$input=M=>l(M.currentTarget.value),V.addEventListener("keypress",p),V.$$input=M=>d(M.currentTarget.value),B.$$click=_,C(B,S(lp,{class:"w-3.5 h-3.5"})),C(E,S(W,{get when(){return u().length===0},get children(){return XL()}}),$),ne(M=>{var L=e.disabled,R=e.disabled,D=e.disabled||!a().trim();return L!==M.e&&(A.disabled=M.e=L),R!==M.t&&(V.disabled=M.t=R),D!==M.a&&(B.disabled=M.a=D),M},{e:void 0,t:void 0,a:void 0}),ne(()=>A.value=a()),ne(()=>V.value=c()),E})()};Ht(["input","click"]);var tk=x('<header class="px-6 py-4 border-b"style=border-color:var(--border-base)>'),nk=x('<div class="flex-1 overflow-y-auto p-6 space-y-6"><div class=panel><div class=panel-header><h3 class=panel-title>Environment Variables</h3><p class=panel-subtitle>Applied whenever a new OpenCode instance starts</p></div><div class=panel-body>'),rk=x('<div class="px-6 py-4 border-t flex justify-end"style=border-color:var(--border-base)><button type=button class="selector-button selector-button-secondary">Close'),ik=x('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">');const sk=e=>S(ft,{get open(){return e.open},onOpenChange:t=>!t&&e.onClose(),get children(){return S(ft.Portal,{get children(){return[S(ft.Overlay,{class:"modal-overlay"}),(()=>{var t=ik();return C(t,S(ft.Content,{class:"modal-surface w-full max-w-5xl max-h-[90vh] flex flex-col overflow-hidden",get children(){return[(()=>{var n=tk();return C(n,S(ft.Title,{class:"text-xl font-semibold text-primary",children:"Advanced Settings"})),n})(),(()=>{var n=nk(),r=n.firstChild,i=r.firstChild,s=i.nextSibling;return C(n,S(QL,{get selectedBinary(){return e.selectedBinary},get onBinaryChange(){return e.onBinaryChange},get disabled(){return!!e.isLoading},get isVisible(){return e.open}}),r),C(s,S(ek,{get disabled(){return!!e.isLoading}})),n})(),(()=>{var n=rk(),r=n.firstChild;return Fn(r,"click",e.onClose,!0),n})()]}})),t})()]}})}});Ht(["click"]);const XE="__drives__";var ok=x('<div class=directory-browser-current><div class=directory-browser-current-meta><span class=directory-browser-current-label>Current folder</span><span class=directory-browser-current-path></span></div><button type=button class="selector-button selector-button-secondary directory-browser-select directory-browser-current-select">Select Current'),ak=x('<div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto directory-browser-list"role=listbox>'),lk=x('<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-6"><div class="modal-surface directory-browser-modal"role=dialog aria-modal=true><div class="panel directory-browser-panel"><div class=directory-browser-header><div class=directory-browser-heading><h3 class=directory-browser-title></h3><p class=directory-browser-description></p></div><button type=button class=directory-browser-close aria-label=Close></button></div><div class="panel-body directory-browser-body">'),ck=x("<div class=directory-browser-loading><span>Loading folders…"),dk=x('<div class="panel-empty-state flex-1">'),uk=x("<span class=text-red-500>"),_k=x('<div class="panel-empty-state flex-1">No folders available.'),mk=x('<div class=panel-list-item role=option><div class="panel-list-item-content directory-browser-row"><button type=button class=directory-browser-row-main><div class=directory-browser-row-icon></div><div class=directory-browser-row-text><span class=directory-browser-row-name>'),gk=x('<button type=button class="selector-button selector-button-secondary directory-browser-select">Select');function Cd(e){if(!e||e==="."||e==="./")return".";if(e===XE)return XE;let t=e.replace(/\\/g,"/");if(/^[a-zA-Z]:/.test(t)){const[n,r=""]=t.split(":"),i=r.startsWith("/")?r:r?`/${r}`:"/";return`${n.toUpperCase()}:${i.replace(/\/+/g,"/")}`}return t.startsWith("//")?`//${t.slice(2).replace(/\/+/g,"/")}`:t.startsWith("/")?`/${t.slice(1).replace(/\/+/g,"/")}`:(t=t.replace(/^\.\/+/,"").replace(/\/+/g,"/"),t===""?".":t)}function yT(e){return e.startsWith("/")||/^[a-zA-Z]:/.test(e)||e.startsWith("\\\\")}function ZE(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;if(yT(t))return t;const n=e.includes("\\")?"\\":"/",r=e.endsWith(n)?e:`${e}${n}`,i=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${r}${i}`}const fk=e=>{const[t,n]=U(""),[r,i]=U(!1),[s,o]=U(null),[a,l]=U(new Map),[c,d]=U(new Set),[u,_]=U(null),[m,g]=U(null),p=new Map,E=new Map;function h(){l(new Map),d(new Set),_(null),g(null),p.clear(),E.clear(),o(null)}J(()=>{if(!e.open)return;h(),f();const M=L=>{L.key==="Escape"&&(L.preventDefault(),e.onClose())};window.addEventListener("keydown",M),Ne(()=>{window.removeEventListener("keydown",M)})});async function f(){i(!0);try{const M=await y();b(M)}catch(M){const L=M instanceof Error?M.message:"Unable to load filesystem";o(L)}finally{i(!1)}}function b(M){const L=Cd(M.currentPath);_(L),g(M),n(M.rootPath)}async function y(M){const L=M?Cd(M):void 0;if(L){const D=p.get(L);if(D)return D;const w=E.get(L);if(w)return w}const R=(async()=>{L&&d(j=>{const le=new Set(j);return le.add(L),le});const D=await vn.listFileSystem(M,{includeFiles:!1}),w=Cd(D.metadata.currentPath),P=D.entries.filter(j=>j.type==="directory").sort((j,le)=>j.name.localeCompare(le.name));return l(j=>{const le=new Map(j);return le.set(w,P),le}),p.set(w,D.metadata),d(j=>{const le=new Set(j);return L&&le.delete(L),le.delete(w),le}),D.metadata})().catch(D=>{throw L&&d(w=>{const P=new Set(w);return P.delete(L),P}),D}).finally(()=>{L&&E.delete(L)});return L&&E.set(L,R),R}async function v(M){o(null);try{const L=await y(M);b(L)}catch(L){const R=L instanceof Error?L.message:"Unable to load filesystem";o(R)}}const O=F(()=>{const M=[],L=m();L!=null&&L.parentPath&&M.push({type:"up",path:L.parentPath});const R=u();if(!R)return M;const D=a().get(R)??[];for(const w of D)M.push({type:"folder",entry:w});return M});function T(M){v(M)}function I(){var L;const M=(L=m())==null?void 0:L.parentPath;M&&v(M)}const k=F(()=>{const M=m();return!M||M.pathKind==="drives"?"":M.pathKind==="relative"?ZE(M.rootPath,M.currentPath):M.displayPath}),A=F(()=>!!k());function V(M){const L=M.absolutePath?M.absolutePath:yT(M.path)?M.path:ZE(t(),M.path);e.onSelect(L)}function B(M){return c().has(Cd(M))}function $(M){M.target===M.currentTarget&&e.onClose()}return S(W,{get when(){return e.open},get children(){var M=lk(),L=M.firstChild,R=L.firstChild,D=R.firstChild,w=D.firstChild,P=w.firstChild,j=P.nextSibling,le=w.nextSibling,me=D.nextSibling;return M.$$click=$,C(P,()=>e.title),C(j,()=>e.description||"Browse folders under the configured workspace root."),Fn(le,"click",e.onClose,!0),C(le,S(cp,{class:"w-5 h-5"})),C(me,S(W,{get when(){return t()},get children(){var Ae=ok(),ie=Ae.firstChild,re=ie.firstChild,Ee=re.nextSibling,Se=ie.nextSibling;return C(Ee,k),Se.$$click=()=>{const q=k();q&&e.onSelect(q)},ne(()=>Se.disabled=!A()),Ae}}),null),C(me,S(W,{get when(){return we(()=>!r())()&&!s()},get fallback(){return(()=>{var Ae=dk();return C(Ae,S(W,{get when(){return r()},get fallback(){return(()=>{var ie=uk();return C(ie,s),ie})()},get children(){var ie=ck(),re=ie.firstChild;return C(ie,S(Ro,{class:"w-5 h-5 animate-spin"}),re),ie}})),Ae})()},get children(){return S(W,{get when(){return O().length>0},get fallback(){return _k()},get children(){var Ae=ak();return C(Ae,S(_t,{get each(){return O()},children:ie=>{const re=ie.type==="folder",Ee=re?ie.entry.name||ie.entry.path:"Up one level",Se=()=>re?T(ie.entry.path):I();return(()=>{var q=mk(),ae=q.firstChild,N=ae.firstChild,H=N.firstChild,te=H.nextSibling,Q=te.firstChild;return N.$$click=Se,C(H,S(W,{when:!re,get fallback(){return S(ap,{class:"w-4 h-4"})},get children(){return S(Jy,{class:"w-4 h-4"})}})),C(Q,Ee),C(N,S(W,{get when(){return re&&B(ie.entry.path)},get children(){return S(Ro,{class:"directory-browser-row-spinner animate-spin"})}}),null),C(ae,re?(()=>{var z=gk();return z.$$click=he=>{he.stopPropagation(),V(ie.entry)},z})():null,null),q})()}})),Ae}})}}),null),M}})};Ht(["click"]);const vo=()=>navigator.platform.toLowerCase().includes("mac");var pk=x("<kbd>"),hk=x("<span>"),Ek=x("<span class=kbd-separator>+");const Sk={enter:"Enter",return:"Enter",esc:"Esc",escape:"Esc",tab:"Tab",space:"Space",backspace:"Backspace",delete:"Delete",pageup:"Page Up",pagedown:"Page Down",home:"Home",end:"End",arrowup:"↑",arrowdown:"↓",arrowleft:"←",arrowright:"→"},ir=e=>{const t=()=>{if(e.children)return[{text:e.children,isModifier:!1}];if(!e.shortcut)return[];const n=[];return e.shortcut.toLowerCase().split("+").forEach(s=>{const o=s.trim(),a=o.toLowerCase();if(a==="cmd"||a==="command")n.push({text:vo()?"Cmd":"Ctrl",isModifier:!1});else if(a==="shift")n.push({text:"Shift",isModifier:!1});else if(a==="alt"||a==="option")n.push({text:vo()?"Option":"Alt",isModifier:!1});else if(a==="ctrl"||a==="control")n.push({text:"Ctrl",isModifier:!1});else{const l=Sk[a];l?n.push({text:l,isModifier:!1}):o.length===1?n.push({text:o.toUpperCase(),isModifier:!1}):n.push({text:o.charAt(0).toUpperCase()+o.slice(1),isModifier:!1})}}),n};return(()=>{var n=pk();return C(n,S(_t,{get each(){return t()},children:(r,i)=>[we(()=>we(()=>i()>0)()&&Ek()),(()=>{var s=hk();return C(s,()=>r.text),s})()]})),ne(()=>rt(n,`kbd ${e.class||""}`)),n})()};var bk=x('<div class="absolute top-4 right-6"><button type=button class="selector-button selector-button-secondary inline-flex items-center justify-center">'),vk=x('<div class="panel flex flex-col flex-1 min-h-0"><div class=panel-header><h2 class=panel-title>Recent Folders</h2><p class=panel-subtitle> <!> available</p></div><div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto">'),yk=x('<div class="flex items-center gap-1.5"><kbd class=kbd>↑</kbd><kbd class=kbd>↓</kbd><span>Navigate'),Tk=x('<div class="flex items-center gap-1.5"><kbd class=kbd>Enter</kbd><span>Select'),Ck=x('<div class="flex items-center gap-1.5"><kbd class=kbd>Del</kbd><span>Remove'),Rk=x("<div class=folder-loading-overlay><div class=folder-loading-indicator><div class=spinner></div><p class=folder-loading-text>Starting instance…</p><p class=folder-loading-subtext>Hang tight while we prepare your workspace."),Ik=x('<div class="flex h-screen w-full items-start justify-center overflow-hidden py-6 px-4 sm:px-6 relative"style=background-color:var(--surface-secondary)><div class="w-full max-w-3xl h-full px-4 sm:px-8 pb-2 flex flex-col overflow-hidden"><div class="mb-6 text-center shrink-0"><div class="mb-3 flex justify-center"><img alt="CodeNomad logo"class="h-32 w-auto sm:h-48"loading=lazy></div><h1 class="mb-2 text-3xl font-semibold text-primary">CodeNomad</h1><p class="text-base text-secondary">Select a folder to start coding with AI</p></div><div class="space-y-4 flex-1 min-h-0 overflow-hidden flex flex-col"><div class="panel shrink-0"><div class="panel-header hidden sm:block"><h2 class=panel-title>Browse for Folder</h2><p class=panel-subtitle>Select any folder on your computer</p></div><div class=panel-body><button class="button-primary w-full flex items-center justify-center text-sm disabled:cursor-not-allowed"><div class="flex items-center gap-2"><span></span></div></button></div><div class="panel-section w-full"><button class="panel-section-header w-full justify-between"><div class="flex items-center gap-2"><span class="text-sm font-medium text-secondary">Advanced Settings</span></div></button></div></div></div><div class="mt-1 panel panel-footer shrink-0 hidden sm:block"><div class=panel-footer-hints><div class="flex items-center gap-1.5"><span>Browse',!0,!1,!1),Ok=x('<div class="panel panel-empty-state flex-1"><div class=panel-empty-state-icon></div><p class=panel-empty-state-title>No Recent Folders</p><p class=panel-empty-state-description>Browse for a folder to get started'),Nk=x("<kbd class=kbd>↵"),Ak=x('<div class=panel-list-item><div class="flex items-center gap-2 w-full px-1"><button class="panel-list-item-content flex-1"><div class="flex items-center justify-between gap-3 w-full"><div class="flex-1 min-w-0"><div class="flex items-center gap-2 mb-1"><span class="text-sm font-medium truncate text-primary"></span></div><div class="text-xs font-mono truncate pl-6 text-muted"></div><div class="text-xs mt-1 pl-6 text-muted"></div></div></div></button><button class="p-2 transition-all hover:bg-red-100 dark:hover:bg-red-900/30 opacity-70 hover:opacity-100 rounded"title="Remove from recent">');const wk=new URL("/assets/CodeNomad-Icon-bmTWNPXy.png",import.meta.url).href,JE=e=>{const{recentFolders:t,removeRecentFolder:n,preferences:r}=ro(),[i,s]=U(0),[o,a]=U("recent"),[l,c]=U(r().lastUsedBinary||"opencode"),[d,u]=U(!1),_=bT();let m;const g=()=>t(),p=()=>!!e.isLoading;J(()=>{const A=r().lastUsedBinary;A&&c(V=>V===A?V:A)});function E(A){const V=m;if(!V)return;const B=V.querySelector(`[data-folder-index="${A}"]`);if(!B)return;const $=V.getBoundingClientRect(),M=B.getBoundingClientRect();M.top<$.top?V.scrollTop-=$.top-M.top:M.bottom>$.bottom&&(V.scrollTop+=M.bottom-$.bottom)}function h(A){const V=A.key.toLowerCase(),B=(A.metaKey||A.ctrlKey)&&!A.shiftKey&&V==="n",$=["ArrowDown","ArrowUp","PageDown","PageUp","Home","End","Enter","Backspace","Delete"];if(p()){(B||$.includes(A.key))&&A.preventDefault();return}const M=g();if(B){A.preventDefault(),v();return}if(M.length!==0){if(A.key==="ArrowDown"){A.preventDefault();const L=Math.min(i()+1,M.length-1);s(L),a("recent"),E(L)}else if(A.key==="ArrowUp"){A.preventDefault();const L=Math.max(i()-1,0);s(L),a("recent"),E(L)}else if(A.key==="PageDown"){A.preventDefault();const R=Math.min(i()+5,M.length-1);s(R),a("recent"),E(R)}else if(A.key==="PageUp"){A.preventDefault();const R=Math.max(i()-5,0);s(R),a("recent"),E(R)}else if(A.key==="Home")A.preventDefault(),s(0),a("recent"),E(0);else if(A.key==="End"){A.preventDefault();const L=M.length-1;s(L),a("recent"),E(L)}else if(A.key==="Enter")A.preventDefault(),f();else if((A.key==="Backspace"||A.key==="Delete")&&(A.preventDefault(),M.length>0&&o()==="recent")){const L=M[i()];L&&I(L.path)}}}function f(){if(p())return;const A=g(),V=i(),B=A[V];B&&y(B.path)}Tn(()=>{window.addEventListener("keydown",h),Ne(()=>{window.removeEventListener("keydown",h)})});function b(A){const V=Math.floor((Date.now()-A)/1e3),B=Math.floor(V/60),$=Math.floor(B/60),M=Math.floor($/24);return M>0?`${M}d ago`:$>0?`${$}h ago`:B>0?`${B}m ago`:"just now"}function y(A){p()||e.onSelectFolder(A,l())}async function v(){var A;if(!p()){if(a("new"),_){const V=(A=g()[0])==null?void 0:A.path,B=await PL({title:"Select Workspace",defaultPath:V});B&&y(B);return}u(!0)}}function O(A){u(!1),y(A)}function T(A){c(A)}function I(A,V){if(p())return;V==null||V.stopPropagation(),n(A);const B=g();i()>=B.length&&B.length>0&&s(B.length-1)}function k(A){return A.startsWith("/Users/")?A.replace(/^\/Users\/[^/]+/,"~"):A}return[(()=>{var A=Ik(),V=A.firstChild,B=V.firstChild,$=B.firstChild,M=$.firstChild,L=B.nextSibling,R=L.firstChild,D=R.firstChild,w=D.nextSibling,P=w.firstChild,j=P.firstChild,le=j.firstChild,me=w.nextSibling,Ae=me.firstChild,ie=Ae.firstChild,re=ie.firstChild,Ee=L.nextSibling,Se=Ee.firstChild,q=Se.firstChild,ae=q.firstChild;return C(V,S(W,{get when(){return e.onOpenRemoteAccess},get children(){var N=bk(),H=N.firstChild;return H.$$click=()=>{var te;return(te=e.onOpenRemoteAccess)==null?void 0:te.call(e)},C(H,S(rT,{class:"w-4 h-4"})),N}}),B),Fe(M,"src",wk),C(L,S(W,{get when(){return g().length>0},get fallback(){return(()=>{var N=Ok(),H=N.firstChild;return C(H,S(MD,{class:"w-12 h-12 mx-auto"})),N})()},get children(){var N=vk(),H=N.firstChild,te=H.firstChild,Q=te.nextSibling,z=Q.firstChild,he=z.nextSibling;he.nextSibling;var ue=H.nextSibling;return C(Q,()=>g().length,z),C(Q,()=>g().length===1?"folder":"folders",he),wt(ce=>m=ce,ue),C(ue,S(_t,{get each(){return g()},children:(ce,se)=>(()=>{var ke=Ak(),We=ke.firstChild,Oe=We.firstChild,je=Oe.firstChild,dt=je.firstChild,Lt=dt.firstChild,be=Lt.firstChild,ee=Lt.nextSibling,Re=ee.nextSibling,He=Oe.nextSibling;return Oe.addEventListener("mouseenter",()=>{p()||(a("recent"),s(se()))}),Oe.$$click=()=>y(ce.path),C(Lt,S(ap,{class:"w-4 h-4 flex-shrink-0 icon-muted"}),be),C(be,()=>ce.path.split("/").pop()),C(ee,()=>k(ce.path)),C(Re,()=>b(ce.lastAccessed)),C(je,S(W,{get when(){return we(()=>o()==="recent")()&&i()===se()},get children(){return Nk()}}),null),He.$$click=qe=>I(ce.path,qe),C(He,S(al,{class:"w-3.5 h-3.5 transition-colors icon-muted hover:text-red-600 dark:hover:text-red-400"})),ne(qe=>{var de=o()==="recent"&&i()===se(),ge=!!p(),Ce=se(),Ke=p(),$e=p();return de!==qe.e&&ke.classList.toggle("panel-list-item-highlight",qe.e=de),ge!==qe.t&&ke.classList.toggle("panel-list-item-disabled",qe.t=ge),Ce!==qe.a&&Fe(Oe,"data-folder-index",qe.a=Ce),Ke!==qe.o&&(Oe.disabled=qe.o=Ke),$e!==qe.i&&(He.disabled=qe.i=$e),qe},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),ke})()})),N}}),R),P.addEventListener("mouseenter",()=>a("new")),P.$$click=()=>void v(),C(j,S(qD,{class:"w-4 h-4"}),le),C(le,()=>e.isLoading?"Opening...":"Browse Folders"),C(P,S(ir,{shortcut:"cmd+n",class:"ml-2"}),null),Ae.$$click=()=>{var N;return(N=e.onAdvancedSettingsOpen)==null?void 0:N.call(e)},C(ie,S(m0,{class:"w-4 h-4 icon-muted"}),re),C(Ae,S(LD,{class:"w-4 h-4 icon-muted"}),null),C(Se,S(W,{get when(){return g().length>0},get children(){return[yk(),Tk(),Ck()]}}),q),C(q,S(ir,{shortcut:"cmd+n"}),ae),C(A,S(W,{get when(){return p()},get children(){return Rk()}}),null),ne(N=>{var H=p()?"true":"false",te=e.isLoading;return H!==N.e&&Fe(V,"aria-busy",N.e=H),te!==N.t&&(P.disabled=N.t=te),N},{e:void 0,t:void 0}),A})(),S(sk,{get open(){return!!e.advancedSettingsOpen},onClose:()=>{var A;return(A=e.onAdvancedSettingsClose)==null?void 0:A.call(e)},get selectedBinary(){return l()},onBinaryChange:T,get isLoading(){return e.isLoading}}),S(fk,{get open(){return d()},title:"Select Workspace",description:"Select workspace to start coding.",onClose:()=>u(!1),onSelect:O})]};Ht(["click"]);function hp(e){return!e||e.type==="idle"?"idle":"working"}function xk(e,t,n="",r={providerId:"",modelId:""},i="idle"){return{...e,instanceId:t,parentId:e.parentID||null,agent:n,model:r,status:i}}function Dk(e){return(e==null?void 0:e.id)??""}function jc(e){return(e==null?void 0:e.sessionID)??(e==null?void 0:e.sessionId)??void 0}function TT(e){const t=e==null?void 0:e.tool;return(t==null?void 0:t.messageID)??(t==null?void 0:t.messageId)??(e==null?void 0:e.messageID)??(e==null?void 0:e.messageId)??void 0}function CT(e){const t=e==null?void 0:e.tool,n=(e==null?void 0:e.metadata)||{};return(t==null?void 0:t.callID)??(t==null?void 0:t.callId)??(e==null?void 0:e.callID)??(e==null?void 0:e.callId)??(e==null?void 0:e.toolCallID)??(e==null?void 0:e.toolCallId)??n.callID??n.callId??void 0}function Og(e){var n;const t=(n=e==null?void 0:e.time)==null?void 0:n.created;return typeof t=="number"?t:Date.now()}function h_(e){return(e==null?void 0:e.permission)??(e==null?void 0:e.type)??"permission"}function Lk(e){const t=e==null?void 0:e.patterns;if(Array.isArray(t))return t.filter(r=>typeof r=="string");const n=e==null?void 0:e.pattern;return typeof n=="string"&&n.length>0?[n]:[]}function RT(e){const t=e==null?void 0:e.title;if(typeof t=="string"&&t.trim().length>0)return t;const n=h_(e),r=Lk(e);return r.length>0?`${n}: ${r.join(", ")}`:n}function kk(e){return(e==null?void 0:e.requestID)??(e==null?void 0:e.requestId)??(e==null?void 0:e.permissionID)??(e==null?void 0:e.permissionId)??void 0}function Mk(e){return(e==null?void 0:e.id)??""}function E_(e){return e==null?void 0:e.sessionID}function IT(e){var t;return(t=e==null?void 0:e.tool)==null?void 0:t.messageID}function OT(e){var t;return(t=e==null?void 0:e.tool)==null?void 0:t.callID}function Pk(e){return e==null?void 0:e.requestID}class eS extends Error{constructor(t,n){super(t),this.name="OpencodeApiError",n&&"cause"in n&&(this.cause=n.cause)}}async function An(e,t){const n=await e;if(!n)throw new eS(`${t} returned no result`);if(n.error)throw new eS(`${t} failed`,{cause:n.error});return n.data}const $k=({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:r,responseValidator:i,sseDefaultRetryDelay:s,sseMaxRetryAttempts:o,sseMaxRetryDelay:a,sseSleepFn:l,url:c,...d})=>{let u;const _=l??(p=>new Promise(E=>setTimeout(E,p)));return{stream:async function*(){let p=s??3e3,E=0;const h=d.signal??new AbortController().signal;for(;!h.aborted;){E++;const f=d.headers instanceof Headers?d.headers:new Headers(d.headers);u!==void 0&&f.set("Last-Event-ID",u);try{const b={redirect:"follow",...d,body:d.serializedBody,headers:f,signal:h};let y=new Request(c,b);e&&(y=await e(c,b));const O=await(d.fetch??globalThis.fetch)(y);if(!O.ok)throw new Error(`SSE failed: ${O.status} ${O.statusText}`);if(!O.body)throw new Error("No body in SSE response");const T=O.body.pipeThrough(new TextDecoderStream).getReader();let I="";const k=()=>{try{T.cancel()}catch{}};h.addEventListener("abort",k);try{for(;;){const{done:A,value:V}=await T.read();if(A)break;I+=V;const B=I.split(`
2
+ var pw=Object.defineProperty;var EE=e=>{throw TypeError(e)};var hw=(e,t,n)=>t in e?pw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var X=(e,t,n)=>hw(e,typeof t!="symbol"?t+"":t,n),Ew=(e,t,n)=>t.has(e)||EE("Cannot "+n);var SE=(e,t,n)=>t.has(e)?EE("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var md=(e,t,n)=>(Ew(e,t,"access private method"),n);import{o as Ne,c as J,a as ne,b as F,$ as vc,u as Wr,d as vg,e as U,m as oe,s as lt,f as S,D as fu,g as Tn,h as qr,i as Jt,j as en,k as we,l as ci,P as l_,S as W,n as Ir,p as ur,q as yc,t as x,r as C,F as _t,v as ri,w as rt,M as sr,x as Wc,y as Ii,z as wt,A as Fe,B as Ht,C as Ci,E as vt,G as Fn,H as $a,I as by,J as $o,K as Sw,L as bw,N as vw,O as Mi,Q as yw,R as Tw,T as Cw,U as Rw}from"./index-D4j6wgeo.js";function Iw(e){return(...t)=>{for(const n of e)n&&n(...t)}}const pe=e=>typeof e=="function"&&!e.length?e():e,bE=e=>Array.isArray(e)?e:e?[e]:[];function Ow(e,...t){return typeof e=="function"?e(...t):e}const Nw=Ne;function Aw(e,t,n,r){return e.addEventListener(t,n,r),Nw(e.removeEventListener.bind(e,t,n,r))}function ww(e,t,n,r){const i=()=>{bE(pe(e)).forEach(s=>{s&&bE(pe(t)).forEach(o=>Aw(s,o,n,r))})};typeof e=="function"?J(i):ne(i)}const om=Symbol("fallback");function vE(e){for(const t of e)t.dispose()}function xw(e,t,n,r={}){const i=new Map;return Ne(()=>vE(i.values())),()=>{const o=e()||[];return o[vc],Wr(()=>{var d,u;if(!o.length)return vE(i.values()),i.clear(),r.fallback?[vg(m=>(i.set(om,{dispose:m}),r.fallback()))]:[];const a=new Array(o.length),l=i.get(om);if(!i.size||l){l==null||l.dispose(),i.delete(om);for(let _=0;_<o.length;_++){const m=o[_],g=t(m,_);s(a,m,_,g)}return a}const c=new Set(i.keys());for(let _=0;_<o.length;_++){const m=o[_],g=t(m,_);c.delete(g);const p=i.get(g);p?(a[_]=p.mapped,(d=p.setIndex)==null||d.call(p,_),p.setItem(()=>m)):s(a,m,_,g)}for(const _ of c)(u=i.get(_))==null||u.dispose(),i.delete(_);return a})};function s(o,a,l,c){vg(d=>{const[u,_]=U(a),m={setItem:_,dispose:d};if(n.length>1){const[g,p]=U(l);m.setIndex=p,m.mapped=n(u,g)}else m.mapped=n(u);i.set(c,m),o[l]=m.mapped})}}function Dw(e){const{by:t}=e;return F(xw(()=>e.each,typeof t=="function"?t:n=>n[t],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}const Lw=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function yE(e){const t={};let n;for(;n=Lw.exec(e);)t[n[1]]=n[2];return t}function Js(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=yE(e)}else typeof t=="string"&&(t=yE(t));return{...e,...t}}function mn(...e){return Iw(e)}function kw(e,t,n=-1){return n in e?[...e.slice(0,n),t,...e.slice(n)]:[...e,t]}function TE(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Mw(e){return typeof e=="number"}function ea(e){return Object.prototype.toString.call(e)==="[object String]"}function os(e){return typeof e=="function"}function Wi(e){return t=>`${e()}-${t}`}function Ti(e,t){return e?e===t||e.contains(t):!1}function Ul(e,t=!1){const{activeElement:n}=Vi(e);if(!(n!=null&&n.nodeName))return null;if(vy(n)&&n.contentDocument)return Ul(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=Vi(n).getElementById(r);if(i)return i}}return n}function Pw(e){return Vi(e).defaultView||window}function Vi(e){return e?e.ownerDocument||e:document}function vy(e){return e.tagName==="IFRAME"}var Qf=(e=>(e.Escape="Escape",e.Enter="Enter",e.Tab="Tab",e.Space=" ",e.ArrowDown="ArrowDown",e.ArrowLeft="ArrowLeft",e.ArrowRight="ArrowRight",e.ArrowUp="ArrowUp",e.End="End",e.Home="Home",e.PageDown="PageDown",e.PageUp="PageUp",e))(Qf||{});function yy(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)==null?void 0:t.brands.some(n=>e.test(n.brand)))||e.test(window.navigator.userAgent)}function jf(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)==null?void 0:t.platform)||window.navigator.platform):!1}function qc(){return jf(/^Mac/i)}function $w(){return jf(/^iPhone/i)}function Fw(){return jf(/^iPad/i)||qc()&&navigator.maxTouchPoints>1}function Bw(){return $w()||Fw()}function jd(){return qc()||Bw()}function Uw(){return yy(/AppleWebKit/i)&&!Gw()}function Gw(){return yy(/Chrome/i)}function Dt(e,t){return t&&(os(t)?t(e):t[0](t[1],e)),e==null?void 0:e.defaultPrevented}function Nn(e){return t=>{for(const n of e)Dt(t,n)}}function Vw(e){return qc()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Qn(e){if(e)if(Hw())e.focus({preventScroll:!0});else{const t=Yw(e);e.focus(),zw(t)}}var gd=null;function Hw(){if(gd==null){gd=!1;try{document.createElement("div").focus({get preventScroll(){return gd=!0,!0}})}catch{}}return gd}function Yw(e){let t=e.parentNode;const n=[],r=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==r;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return r instanceof HTMLElement&&n.push({element:r,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft}),n}function zw(e){for(const{element:t,scrollTop:n,scrollLeft:r}of e)t.scrollTop=n,t.scrollLeft=r}var Ty=["input:not([type='hidden']):not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","[tabindex]","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]:not([contenteditable='false'])"],Ww=[...Ty,'[tabindex]:not([tabindex="-1"]):not([disabled])'],Xf=`${Ty.join(":not([hidden]),")},[tabindex]:not([disabled]):not([hidden])`,qw=Ww.join(':not([hidden]):not([tabindex="-1"]),');function Cy(e,t){const r=Array.from(e.querySelectorAll(Xf)).filter(CE);return t&&CE(e)&&r.unshift(e),r.forEach((i,s)=>{if(vy(i)&&i.contentDocument){const o=i.contentDocument.body,a=Cy(o,!1);r.splice(s,1,...a)}}),r}function CE(e){return Ry(e)&&!Kw(e)}function Ry(e){return e.matches(Xf)&&Zf(e)}function Kw(e){return Number.parseInt(e.getAttribute("tabindex")||"0",10)<0}function Zf(e,t){return e.nodeName!=="#comment"&&Qw(e)&&jw(e,t)&&(!e.parentElement||Zf(e.parentElement,e))}function Qw(e){if(!(e instanceof HTMLElement)&&!(e instanceof SVGElement))return!1;const{display:t,visibility:n}=e.style;let r=t!=="none"&&n!=="hidden"&&n!=="collapse";if(r){if(!e.ownerDocument.defaultView)return r;const{getComputedStyle:i}=e.ownerDocument.defaultView,{display:s,visibility:o}=i(e);r=s!=="none"&&o!=="hidden"&&o!=="collapse"}return r}function jw(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function Xw(e,t,n){const r=t!=null&&t.tabbable?qw:Xf,i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(s){var o;return(o=t==null?void 0:t.from)!=null&&o.contains(s)?NodeFilter.FILTER_REJECT:s.matches(r)&&Zf(s)&&(!(t!=null&&t.accept)||t.accept(s))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(i.currentNode=t.from),i}function Zw(){}function Tt(e,t){return oe(e,t)}var Rl=new Map,RE=new Set;function IE(){if(typeof window>"u")return;const e=n=>{if(!n.target)return;let r=Rl.get(n.target);r||(r=new Set,Rl.set(n.target,r),n.target.addEventListener("transitioncancel",t)),r.add(n.propertyName)},t=n=>{if(!n.target)return;const r=Rl.get(n.target);if(r&&(r.delete(n.propertyName),r.size===0&&(n.target.removeEventListener("transitioncancel",t),Rl.delete(n.target)),Rl.size===0)){for(const i of RE)i();RE.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?IE():document.addEventListener("DOMContentLoaded",IE));function OE(e,t){const n=NE(e,t,"left"),r=NE(e,t,"top"),i=t.offsetWidth,s=t.offsetHeight;let o=e.scrollLeft,a=e.scrollTop;const l=o+e.offsetWidth,c=a+e.offsetHeight;n<=o?o=n:n+i>l&&(o+=n+i-l),r<=a?a=r:r+s>c&&(a+=r+s-c),e.scrollLeft=o,e.scrollTop=a}function NE(e,t,n){const r=n==="left"?"offsetLeft":"offsetTop";let i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);){if(t.offsetParent.contains(e)){i-=e[r];break}t=t.offsetParent}return i}var c_={border:"0",clip:"rect(0 0 0 0)","clip-path":"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:"0",position:"absolute",width:"1px","white-space":"nowrap"},pu="data-kb-top-layer",Iy,yg=!1,ms=[];function Tc(e){return ms.findIndex(t=>t.node===e)}function Jw(e){return ms[Tc(e)]}function ex(e){return ms[ms.length-1].node===e}function Oy(){return ms.filter(e=>e.isPointerBlocking)}function tx(){return[...Oy()].slice(-1)[0]}function Jf(){return Oy().length>0}function Ny(e){var n;const t=Tc((n=tx())==null?void 0:n.node);return Tc(e)<t}function nx(e){ms.push(e)}function rx(e){const t=Tc(e);t<0||ms.splice(t,1)}function ix(){for(const{node:e}of ms)e.style.pointerEvents=Ny(e)?"none":"auto"}function sx(e){if(Jf()&&!yg){const t=Vi(e);Iy=document.body.style.pointerEvents,t.body.style.pointerEvents="none",yg=!0}}function ox(e){if(Jf())return;const t=Vi(e);t.body.style.pointerEvents=Iy,t.body.style.length===0&&t.body.removeAttribute("style"),yg=!1}var Pr={layers:ms,isTopMostLayer:ex,hasPointerBlockingLayer:Jf,isBelowPointerBlockingLayer:Ny,addLayer:nx,removeLayer:rx,indexOf:Tc,find:Jw,assignPointerEventToLayers:ix,disableBodyPointerEvents:sx,restoreBodyPointerEvents:ox},am="focusScope.autoFocusOnMount",lm="focusScope.autoFocusOnUnmount",AE={bubbles:!1,cancelable:!0},wE={stack:[],active(){return this.stack[0]},add(e){var t;e!==this.active()&&((t=this.active())==null||t.pause()),this.stack=TE(this.stack,e),this.stack.unshift(e)},remove(e){var t;this.stack=TE(this.stack,e),(t=this.active())==null||t.resume()}};function ep(e,t){const[n,r]=U(!1),i={pause(){r(!0)},resume(){r(!1)}};let s=null;const o=g=>{var p;return(p=e.onMountAutoFocus)==null?void 0:p.call(e,g)},a=g=>{var p;return(p=e.onUnmountAutoFocus)==null?void 0:p.call(e,g)},l=()=>Vi(t()),c=()=>{const g=l().createElement("span");return g.setAttribute("data-focus-trap",""),g.tabIndex=0,Object.assign(g.style,c_),g},d=()=>{const g=t();return g?Cy(g,!0).filter(p=>!p.hasAttribute("data-focus-trap")):[]},u=()=>{const g=d();return g.length>0?g[0]:null},_=()=>{const g=d();return g.length>0?g[g.length-1]:null},m=()=>{const g=t();if(!g)return!1;const p=Ul(g);return!p||Ti(g,p)?!1:Ry(p)};J(()=>{const g=t();if(!g)return;wE.add(i);const p=Ul(g);if(!Ti(g,p)){const h=new CustomEvent(am,AE);g.addEventListener(am,o),g.dispatchEvent(h),h.defaultPrevented||setTimeout(()=>{Qn(u()),Ul(g)===p&&Qn(g)},0)}Ne(()=>{g.removeEventListener(am,o),setTimeout(()=>{const h=new CustomEvent(lm,AE);m()&&h.preventDefault(),g.addEventListener(lm,a),g.dispatchEvent(h),h.defaultPrevented||Qn(p??l().body),g.removeEventListener(lm,a),wE.remove(i)},0)})}),J(()=>{const g=t();if(!g||!pe(e.trapFocus)||n())return;const p=h=>{const f=h.target;f!=null&&f.closest(`[${pu}]`)||(Ti(g,f)?s=f:Qn(s))},E=h=>{const b=h.relatedTarget??Ul(g);b!=null&&b.closest(`[${pu}]`)||Ti(g,b)||Qn(s)};l().addEventListener("focusin",p),l().addEventListener("focusout",E),Ne(()=>{l().removeEventListener("focusin",p),l().removeEventListener("focusout",E)})}),J(()=>{const g=t();if(!g||!pe(e.trapFocus)||n())return;const p=c();g.insertAdjacentElement("afterbegin",p);const E=c();g.insertAdjacentElement("beforeend",E);function h(b){const y=u(),v=_();b.relatedTarget===y?Qn(v):Qn(y)}p.addEventListener("focusin",h),E.addEventListener("focusin",h);const f=new MutationObserver(b=>{for(const y of b)y.previousSibling===E&&(E.remove(),g.insertAdjacentElement("beforeend",E)),y.nextSibling===p&&(p.remove(),g.insertAdjacentElement("afterbegin",p))});f.observe(g,{childList:!0,subtree:!1}),Ne(()=>{p.removeEventListener("focusin",h),E.removeEventListener("focusin",h),p.remove(),E.remove(),f.disconnect()})})}var Ay=7e3,cm=null,ax="data-live-announcer";function dm(e,t="assertive",n=Ay){cm||(cm=new lx),cm.announce(e,t,n)}var lx=class{constructor(){X(this,"node");X(this,"assertiveLog");X(this,"politeLog");this.node=document.createElement("div"),this.node.dataset.liveAnnouncer="true",Object.assign(this.node.style,c_),this.assertiveLog=this.createLog("assertive"),this.node.appendChild(this.assertiveLog),this.politeLog=this.createLog("polite"),this.node.appendChild(this.politeLog),document.body.prepend(this.node)}createLog(e){const t=document.createElement("div");return t.setAttribute("role","log"),t.setAttribute("aria-live",e),t.setAttribute("aria-relevant","additions"),t}destroy(){this.node&&(document.body.removeChild(this.node),this.node=null)}announce(e,t="assertive",n=Ay){if(!this.node)return;const r=document.createElement("div");r.textContent=e,t==="assertive"?this.assertiveLog.appendChild(r):this.politeLog.appendChild(r),e!==""&&setTimeout(()=>{r.remove()},n)}clear(e){this.node&&((!e||e==="assertive")&&(this.assertiveLog.innerHTML=""),(!e||e==="polite")&&(this.politeLog.innerHTML=""))}};function tp(e){J(()=>{pe(e.isDisabled)||Ne(cx(pe(e.targets),pe(e.root)))})}var Il=new WeakMap,Zr=[];function cx(e,t=document.body){const n=new Set(e),r=new Set,i=l=>{for(const _ of l.querySelectorAll(`[${ax}], [${pu}]`))n.add(_);const c=_=>{if(n.has(_)||_.parentElement&&r.has(_.parentElement)&&_.parentElement.getAttribute("role")!=="row")return NodeFilter.FILTER_REJECT;for(const m of n)if(_.contains(m))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},d=document.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,{acceptNode:c}),u=c(l);if(u===NodeFilter.FILTER_ACCEPT&&s(l),u!==NodeFilter.FILTER_REJECT){let _=d.nextNode();for(;_!=null;)s(_),_=d.nextNode()}},s=l=>{const c=Il.get(l)??0;l.getAttribute("aria-hidden")==="true"&&c===0||(c===0&&l.setAttribute("aria-hidden","true"),r.add(l),Il.set(l,c+1))};Zr.length&&Zr[Zr.length-1].disconnect(),i(t);const o=new MutationObserver(l=>{for(const c of l)if(!(c.type!=="childList"||c.addedNodes.length===0)&&![...n,...r].some(d=>d.contains(c.target))){for(const d of c.removedNodes)d instanceof Element&&(n.delete(d),r.delete(d));for(const d of c.addedNodes)(d instanceof HTMLElement||d instanceof SVGElement)&&(d.dataset.liveAnnouncer==="true"||d.dataset.reactAriaTopLayer==="true")?n.add(d):d instanceof Element&&i(d)}});o.observe(t,{childList:!0,subtree:!0});const a={observe(){o.observe(t,{childList:!0,subtree:!0})},disconnect(){o.disconnect()}};return Zr.push(a),()=>{o.disconnect();for(const l of r){const c=Il.get(l);if(c==null)return;c===1?(l.removeAttribute("aria-hidden"),Il.delete(l)):Il.set(l,c-1)}a===Zr[Zr.length-1]?(Zr.pop(),Zr.length&&Zr[Zr.length-1].observe()):Zr.splice(Zr.indexOf(a),1)}}var xE="interactOutside.pointerDownOutside",DE="interactOutside.focusOutside";function dx(e,t){let n,r=Zw;const i=()=>Vi(t()),s=u=>{var _;return(_=e.onPointerDownOutside)==null?void 0:_.call(e,u)},o=u=>{var _;return(_=e.onFocusOutside)==null?void 0:_.call(e,u)},a=u=>{var _;return(_=e.onInteractOutside)==null?void 0:_.call(e,u)},l=u=>{var m;const _=u.target;return!(_ instanceof Element)||_.closest(`[${pu}]`)||!Ti(i(),_)||Ti(t(),_)?!1:!((m=e.shouldExcludeElement)!=null&&m.call(e,_))},c=u=>{function _(){const m=t(),g=u.target;if(!m||!g||!l(u))return;const p=Nn([s,a]);g.addEventListener(xE,p,{once:!0});const E=new CustomEvent(xE,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:u.button===2||Vw(u)&&u.button===0}});g.dispatchEvent(E)}u.pointerType==="touch"?(i().removeEventListener("click",_),r=_,i().addEventListener("click",_,{once:!0})):_()},d=u=>{const _=t(),m=u.target;if(!_||!m||!l(u))return;const g=Nn([o,a]);m.addEventListener(DE,g,{once:!0});const p=new CustomEvent(DE,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:!1}});m.dispatchEvent(p)};J(()=>{pe(e.isDisabled)||(n=window.setTimeout(()=>{i().addEventListener("pointerdown",c,!0)},0),i().addEventListener("focusin",d,!0),Ne(()=>{window.clearTimeout(n),i().removeEventListener("click",r),i().removeEventListener("pointerdown",c,!0),i().removeEventListener("focusin",d,!0)}))})}function ux(e){const t=n=>{var r;n.key===Qf.Escape&&((r=e.onEscapeKeyDown)==null||r.call(e,n))};J(()=>{var r;if(pe(e.isDisabled))return;const n=((r=e.ownerDocument)==null?void 0:r.call(e))??Vi();n.addEventListener("keydown",t),Ne(()=>{n.removeEventListener("keydown",t)})})}function Gt(e){const[t,n]=lt(e,["as"]);if(!t.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return S(fu,oe(n,{get component(){return t.as}}))}var wy=Jt();function _x(){return en(wy)}function np(e){let t;const n=_x(),[r,i]=lt(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),s=new Set([]),o=u=>{s.add(u);const _=n==null?void 0:n.registerNestedLayer(u);return()=>{s.delete(u),_==null||_()}};dx({shouldExcludeElement:u=>{var _;return t?((_=r.excludedElements)==null?void 0:_.some(m=>Ti(m(),u)))||[...s].some(m=>Ti(m,u)):!1},onPointerDownOutside:u=>{var _,m,g;!t||Pr.isBelowPointerBlockingLayer(t)||!r.bypassTopMostLayerCheck&&!Pr.isTopMostLayer(t)||((_=r.onPointerDownOutside)==null||_.call(r,u),(m=r.onInteractOutside)==null||m.call(r,u),u.defaultPrevented||(g=r.onDismiss)==null||g.call(r))},onFocusOutside:u=>{var _,m,g;(_=r.onFocusOutside)==null||_.call(r,u),(m=r.onInteractOutside)==null||m.call(r,u),u.defaultPrevented||(g=r.onDismiss)==null||g.call(r)}},()=>t),ux({ownerDocument:()=>Vi(t),onEscapeKeyDown:u=>{var _;!t||!Pr.isTopMostLayer(t)||((_=r.onEscapeKeyDown)==null||_.call(r,u),!u.defaultPrevented&&r.onDismiss&&(u.preventDefault(),r.onDismiss()))}}),Tn(()=>{if(!t)return;Pr.addLayer({node:t,isPointerBlocking:r.disableOutsidePointerEvents,dismiss:r.onDismiss});const u=n==null?void 0:n.registerNestedLayer(t);Pr.assignPointerEventToLayers(),Pr.disableBodyPointerEvents(t),Ne(()=>{t&&(Pr.removeLayer(t),u==null||u(),Pr.assignPointerEventToLayers(),Pr.restoreBodyPointerEvents(t))})}),J(qr([()=>t,()=>r.disableOutsidePointerEvents],([u,_])=>{if(!u)return;const m=Pr.find(u);m&&m.isPointerBlocking!==_&&(m.isPointerBlocking=_,Pr.assignPointerEventToLayers()),_&&Pr.disableBodyPointerEvents(u),Ne(()=>{Pr.restoreBodyPointerEvents(u)})},{defer:!0}));const d={registerNestedLayer:o};return S(wy.Provider,{value:d,get children(){return S(Gt,oe({as:"div",ref(u){var _=mn(m=>t=m,r.ref);typeof _=="function"&&_(u)}},i))}})}function d_(e){var o;const[t,n]=U((o=e.defaultValue)==null?void 0:o.call(e)),r=F(()=>{var a;return((a=e.value)==null?void 0:a.call(e))!==void 0}),i=F(()=>{var a;return r()?(a=e.value)==null?void 0:a.call(e):t()});return[i,a=>{Wr(()=>{var c;const l=Ow(a,i());return Object.is(l,i())||(r()||n(l),(c=e.onChange)==null||c.call(e,l)),l})}]}function xy(e){const[t,n]=d_(e);return[()=>t()??!1,n]}function mx(e){const[t,n]=d_(e);return[()=>t()??[],n]}function u_(e={}){const[t,n]=xy({value:()=>pe(e.open),defaultValue:()=>!!pe(e.defaultOpen),onChange:o=>{var a;return(a=e.onOpenChange)==null?void 0:a.call(e,o)}}),r=()=>{n(!0)},i=()=>{n(!1)};return{isOpen:t,setIsOpen:n,open:r,close:i,toggle:()=>{t()?i():r()}}}function Dy(e,t){const[n,r]=U(LE(t==null?void 0:t()));return J(()=>{var i;r(((i=e())==null?void 0:i.tagName.toLowerCase())||LE(t==null?void 0:t()))}),n}function LE(e){return ea(e)?e:void 0}var gx=Object.defineProperty,eo=(e,t)=>{for(var n in t)gx(e,n,{get:t[n],enumerable:!0})},fx={};eo(fx,{Button:()=>Ex,Root:()=>Fo});var px=["button","color","file","image","reset","submit"];function hx(e){const t=e.tagName.toLowerCase();return t==="button"?!0:t==="input"&&e.type?px.indexOf(e.type)!==-1:!1}function Fo(e){let t;const n=Tt({type:"button"},e),[r,i]=lt(n,["ref","type","disabled"]),s=Dy(()=>t,()=>"button"),o=F(()=>{const c=s();return c==null?!1:hx({tagName:c,type:r.type})}),a=F(()=>s()==="input"),l=F(()=>s()==="a"&&(t==null?void 0:t.getAttribute("href"))!=null);return S(Gt,oe({as:"button",ref(c){var d=mn(u=>t=u,r.ref);typeof d=="function"&&d(c)},get type(){return we(()=>!!(o()||a()))()?r.type:void 0},get role(){return!o()&&!l()?"button":void 0},get tabIndex(){return!o()&&!l()&&!r.disabled?0:void 0},get disabled(){return we(()=>!!(o()||a()))()?r.disabled:void 0},get"aria-disabled"(){return!o()&&!a()&&r.disabled?!0:void 0},get"data-disabled"(){return r.disabled?"":void 0}},i))}var Ex=Fo;function mr(e){return t=>(e(t),()=>e(void 0))}var cr=e=>typeof e=="function"?e():e,Tg=(e,t)=>{if(e.contains(t))return!0;let n=t;for(;n;){if(n===e)return!0;n=n._$host??n.parentElement}return!1},fd=new Map,Sx=e=>{J(()=>{const t=cr(e.style)??{},n=cr(e.properties)??[],r={};for(const s in t)r[s]=e.element.style[s];const i=fd.get(e.key);i?i.activeCount++:fd.set(e.key,{activeCount:1,originalStyles:r,properties:n.map(s=>s.key)}),Object.assign(e.element.style,e.style);for(const s of n)e.element.style.setProperty(s.key,s.value);Ne(()=>{var o;const s=fd.get(e.key);if(s){if(s.activeCount!==1){s.activeCount--;return}fd.delete(e.key);for(const[a,l]of Object.entries(s.originalStyles))e.element.style[a]=l;for(const a of s.properties)e.element.style.removeProperty(a);e.element.style.length===0&&e.element.removeAttribute("style"),(o=e.cleanup)==null||o.call(e)}})})},kE=Sx,bx=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},vx=(e,t)=>{const n=getComputedStyle(e),r=t==="x"?n.overflowX:n.overflowY;return r==="auto"||r==="scroll"||e.tagName==="HTML"&&r==="visible"},yx=(e,t,n)=>{const r=t==="x"&&window.getComputedStyle(e).direction==="rtl"?-1:1;let i=e,s=0,o=0,a=!1;do{const[l,c,d]=bx(i,t),u=d-l-r*c;(c!==0||u!==0)&&vx(i,t)&&(s+=u,o+=c),i===(n??document.documentElement)?a=!0:i=i._$host??i.parentElement}while(i&&!a);return[s,o]},[ME,PE]=U([]),Tx=e=>ME().indexOf(e)===ME().length-1,Cx=e=>{const t=oe({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=ci();let r=[0,0],i=null,s=null;J(()=>{cr(t.enabled)&&(PE(c=>[...c,n]),Ne(()=>{PE(c=>c.filter(d=>d!==n))}))}),J(()=>{if(!cr(t.enabled)||!cr(t.hideScrollbar))return;const{body:c}=document,d=window.innerWidth-c.offsetWidth;if(cr(t.preventScrollbarShift)){const u={overflow:"hidden"},_=[];d>0&&(cr(t.preventScrollbarShiftMode)==="padding"?u.paddingRight=`calc(${window.getComputedStyle(c).paddingRight} + ${d}px)`:u.marginRight=`calc(${window.getComputedStyle(c).marginRight} + ${d}px)`,_.push({key:"--scrollbar-width",value:`${d}px`}));const m=window.scrollY,g=window.scrollX;kE({key:"prevent-scroll",element:c,style:u,properties:_,cleanup:()=>{cr(t.restoreScrollPosition)&&d>0&&window.scrollTo(g,m)}})}else kE({key:"prevent-scroll",element:c,style:{overflow:"hidden"}})}),J(()=>{!Tx(n)||!cr(t.enabled)||(document.addEventListener("wheel",a,{passive:!1}),document.addEventListener("touchstart",o,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),Ne(()=>{document.removeEventListener("wheel",a),document.removeEventListener("touchstart",o),document.removeEventListener("touchmove",l)}))});const o=c=>{r=$E(c),i=null,s=null},a=c=>{const d=c.target,u=cr(t.element),_=Rx(c),m=Math.abs(_[0])>Math.abs(_[1])?"x":"y",g=m==="x"?_[0]:_[1],p=FE(d,m,g,u);let E;u&&Tg(u,d)?E=!p:E=!0,E&&c.cancelable&&c.preventDefault()},l=c=>{const d=cr(t.element),u=c.target;let _;if(c.touches.length===2)_=!cr(t.allowPinchZoom);else{if(i==null||s===null){const m=$E(c).map((p,E)=>r[E]-p),g=Math.abs(m[0])>Math.abs(m[1])?"x":"y";i=g,s=g==="x"?m[0]:m[1]}if(u.type==="range")_=!1;else{const m=FE(u,i,s,d);d&&Tg(d,u)?_=!m:_=!0}}_&&c.cancelable&&c.preventDefault()}},Rx=e=>[e.deltaX,e.deltaY],$E=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],FE=(e,t,n,r)=>{const i=r!==null&&Tg(r,e),[s,o]=yx(e,t,i?r:void 0);return!(n>0&&Math.abs(s)<=1||n<0&&Math.abs(o)<1)},Ix=Cx,rp=Ix,Ox=e=>{const t=F(()=>{const o=cr(e.element);if(o)return getComputedStyle(o)}),n=()=>{var o;return((o=t())==null?void 0:o.animationName)??"none"},[r,i]=U(cr(e.show)?"present":"hidden");let s="none";return J(o=>{const a=cr(e.show);return Wr(()=>{var d;if(o===a)return a;const l=s,c=n();a?i("present"):c==="none"||((d=t())==null?void 0:d.display)==="none"?i("hidden"):i(o===!0&&l!==c?"hiding":"hidden")}),a}),J(()=>{const o=cr(e.element);if(!o)return;const a=c=>{c.target===o&&(s=n())},l=c=>{const u=n().includes(c.animationName);c.target===o&&u&&r()==="hiding"&&i("hidden")};o.addEventListener("animationstart",a),o.addEventListener("animationcancel",l),o.addEventListener("animationend",l),Ne(()=>{o.removeEventListener("animationstart",a),o.removeEventListener("animationcancel",l),o.removeEventListener("animationend",l)})}),{present:()=>r()==="present"||r()==="hiding",state:r,setState:i}},Nx=Ox,Cc=Nx,Ax={};eo(Ax,{CloseButton:()=>ky,Content:()=>My,Description:()=>Py,Dialog:()=>ft,Overlay:()=>$y,Portal:()=>Fy,Root:()=>By,Title:()=>Uy,Trigger:()=>Gy,useDialogContext:()=>to});var Ly=Jt();function to(){const e=en(Ly);if(e===void 0)throw new Error("[kobalte]: `useDialogContext` must be used within a `Dialog` component");return e}function ky(e){const t=to(),[n,r]=lt(e,["aria-label","onClick"]);return S(Fo,oe({get"aria-label"(){return n["aria-label"]||t.translations().dismiss},onClick:s=>{Dt(s,n.onClick),t.close()}},r))}function My(e){let t;const n=to(),r=Tt({id:n.generateId("content")},e),[i,s]=lt(r,["ref","onOpenAutoFocus","onCloseAutoFocus","onPointerDownOutside","onFocusOutside","onInteractOutside"]);let o=!1,a=!1;const l=_=>{var m;(m=i.onPointerDownOutside)==null||m.call(i,_),n.modal()&&_.detail.isContextMenu&&_.preventDefault()},c=_=>{var m;(m=i.onFocusOutside)==null||m.call(i,_),n.modal()&&_.preventDefault()},d=_=>{var m;(m=i.onInteractOutside)==null||m.call(i,_),!n.modal()&&(_.defaultPrevented||(o=!0,_.detail.originalEvent.type==="pointerdown"&&(a=!0)),Ti(n.triggerRef(),_.target)&&_.preventDefault(),_.detail.originalEvent.type==="focusin"&&a&&_.preventDefault())},u=_=>{var m;(m=i.onCloseAutoFocus)==null||m.call(i,_),n.modal()?(_.preventDefault(),Qn(n.triggerRef())):(_.defaultPrevented||(o||Qn(n.triggerRef()),_.preventDefault()),o=!1,a=!1)};return tp({isDisabled:()=>!(n.isOpen()&&n.modal()),targets:()=>t?[t]:[]}),rp({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),ep({trapFocus:()=>n.isOpen()&&n.modal(),onMountAutoFocus:i.onOpenAutoFocus,onUnmountAutoFocus:u},()=>t),J(()=>Ne(n.registerContentId(s.id))),S(W,{get when(){return n.contentPresent()},get children(){return S(np,oe({ref(_){var m=mn(g=>{n.setContentRef(g),t=g},i.ref);typeof m=="function"&&m(_)},role:"dialog",tabIndex:-1,get disableOutsidePointerEvents(){return we(()=>!!n.modal())()&&n.isOpen()},get excludedElements(){return[n.triggerRef]},get"aria-labelledby"(){return n.titleId()},get"aria-describedby"(){return n.descriptionId()},get"data-expanded"(){return n.isOpen()?"":void 0},get"data-closed"(){return n.isOpen()?void 0:""},onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:d,get onDismiss(){return n.close}},s))}})}function Py(e){const t=to(),n=Tt({id:t.generateId("description")},e),[r,i]=lt(n,["id"]);return J(()=>Ne(t.registerDescriptionId(r.id))),S(Gt,oe({as:"p",get id(){return r.id}},i))}function $y(e){const t=to(),[n,r]=lt(e,["ref","style","onPointerDown"]),i=s=>{Dt(s,n.onPointerDown),s.target===s.currentTarget&&s.preventDefault()};return S(W,{get when(){return t.overlayPresent()},get children(){return S(Gt,oe({as:"div",ref(s){var o=mn(t.setOverlayRef,n.ref);typeof o=="function"&&o(s)},get style(){return Js({"pointer-events":"auto"},n.style)},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onPointerDown:i},r))}})}function Fy(e){const t=to();return S(W,{get when(){return t.contentPresent()||t.overlayPresent()},get children(){return S(l_,e)}})}var BE={dismiss:"Dismiss"};function By(e){const t=`dialog-${ci()}`,n=Tt({id:t,modal:!0,translations:BE},e),[r,i]=U(),[s,o]=U(),[a,l]=U(),[c,d]=U(),[u,_]=U(),[m,g]=U(),p=u_({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:y=>{var v;return(v=n.onOpenChange)==null?void 0:v.call(n,y)}}),E=()=>n.forceMount||p.isOpen(),{present:h}=Cc({show:E,element:()=>c()??null}),{present:f}=Cc({show:E,element:()=>u()??null}),b={translations:()=>n.translations??BE,isOpen:p.isOpen,modal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??b.modal(),contentId:r,titleId:s,descriptionId:a,triggerRef:m,overlayRef:c,setOverlayRef:d,contentRef:u,setContentRef:_,overlayPresent:h,contentPresent:f,close:p.close,toggle:p.toggle,setTriggerRef:g,generateId:Wi(()=>n.id),registerContentId:mr(i),registerTitleId:mr(o),registerDescriptionId:mr(l)};return S(Ly.Provider,{value:b,get children(){return n.children}})}function Uy(e){const t=to(),n=Tt({id:t.generateId("title")},e),[r,i]=lt(n,["id"]);return J(()=>Ne(t.registerTitleId(r.id))),S(Gt,oe({as:"h2",get id(){return r.id}},i))}function Gy(e){const t=to(),[n,r]=lt(e,["ref","onClick"]);return S(Fo,oe({ref(s){var o=mn(t.setTriggerRef,n.ref);typeof o=="function"&&o(s)},"aria-haspopup":"dialog",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return we(()=>!!t.isOpen())()?t.contentId():void 0},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onClick:s=>{Dt(s,n.onClick),t.toggle()}},r))}var ft=Object.assign(By,{CloseButton:ky,Content:My,Description:Py,Overlay:$y,Portal:Fy,Title:Uy,Trigger:Gy});const wx=e=>typeof e=="function",hu=(e,t)=>wx(e)?e(t):e;var Pn;(function(e){e[e.ADD_TOAST=0]="ADD_TOAST",e[e.UPDATE_TOAST=1]="UPDATE_TOAST",e[e.UPSERT_TOAST=2]="UPSERT_TOAST",e[e.DISMISS_TOAST=3]="DISMISS_TOAST",e[e.REMOVE_TOAST=4]="REMOVE_TOAST",e[e.START_PAUSE=5]="START_PAUSE",e[e.END_PAUSE=6]="END_PAUSE"})(Pn||(Pn={}));const Fa=Symbol("store-raw"),Bi=Symbol("store-node"),ii=Symbol("store-has"),Vy=Symbol("store-self");function Hy(e){let t=e[Ir];if(!t&&(Object.defineProperty(e,Ir,{value:t=new Proxy(e,Dx)}),!Array.isArray(e))){const n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e);for(let i=0,s=n.length;i<s;i++){const o=n[i];r[o].get&&Object.defineProperty(e,o,{enumerable:r[o].enumerable,get:r[o].get.bind(t)})}}return t}function Oi(e){let t;return e!=null&&typeof e=="object"&&(e[Ir]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function gs(e,t=new Set){let n,r,i,s;if(n=e!=null&&e[Fa])return n;if(!Oi(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let o=0,a=e.length;o<a;o++)i=e[o],(r=gs(i,t))!==i&&(e[o]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);const o=Object.keys(e),a=Object.getOwnPropertyDescriptors(e);for(let l=0,c=o.length;l<c;l++)s=o[l],!a[s].get&&(i=e[s],(r=gs(i,t))!==i&&(e[s]=r))}return e}function Ba(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Co(e,t,n){if(e[t])return e[t];const[r,i]=U(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function xx(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===Ir||t===Bi||(delete n.value,delete n.writable,n.get=()=>e[Ir][t]),n}function ip(e){yc()&&Co(Ba(e,Bi),Vy)()}function Yy(e){return ip(e),Reflect.ownKeys(e)}const Dx={get(e,t,n){if(t===Fa)return e;if(t===Ir)return n;if(t===vc)return ip(e),n;const r=Ba(e,Bi),i=r[t];let s=i?i():e[t];if(t===Bi||t===ii||t==="__proto__")return s;if(!i){const o=Object.getOwnPropertyDescriptor(e,t);yc()&&(typeof s!="function"||e.hasOwnProperty(t))&&!(o&&o.get)&&(s=Co(r,t,s)())}return Oi(s)?Hy(s):s},has(e,t){return t===Fa||t===Ir||t===vc||t===Bi||t===ii||t==="__proto__"?!0:(yc()&&Co(Ba(e,ii),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:Yy,getOwnPropertyDescriptor:xx};function dr(e,t,n,r=!1){if(!r&&e[t]===n)return;const i=e[t],s=e.length;n===void 0?(delete e[t],e[ii]&&e[ii][t]&&i!==void 0&&e[ii][t].$()):(e[t]=n,e[ii]&&e[ii][t]&&i===void 0&&e[ii][t].$());let o=Ba(e,Bi),a;if((a=Co(o,t,i))&&a.$(()=>n),Array.isArray(e)&&e.length!==s){for(let l=e.length;l<s;l++)(a=o[l])&&a.$();(a=Co(o,"length",s))&&a.$(e.length)}(a=o[Vy])&&a.$()}function zy(e,t){const n=Object.keys(t);for(let r=0;r<n.length;r+=1){const i=n[r];dr(e,i,t[i])}}function Lx(e,t){if(typeof t=="function"&&(t=t(e)),t=gs(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){const i=t[n];e[n]!==i&&dr(e,n,i)}dr(e,"length",r)}else zy(e,t)}function Gl(e,t,n=[]){let r,i=e;if(t.length>1){r=t.shift();const o=typeof r,a=Array.isArray(e);if(Array.isArray(r)){for(let l=0;l<r.length;l++)Gl(e,[r[l]].concat(t),n);return}else if(a&&o==="function"){for(let l=0;l<e.length;l++)r(e[l],l)&&Gl(e,[l].concat(t),n);return}else if(a&&o==="object"){const{from:l=0,to:c=e.length-1,by:d=1}=r;for(let u=l;u<=c;u+=d)Gl(e,[u].concat(t),n);return}else if(t.length>1){Gl(e[r],t,[r].concat(n));return}i=e[r],n=[r].concat(n)}let s=t[0];typeof s=="function"&&(s=s(i,n),s===i)||r===void 0&&s==null||(s=gs(s),r===void 0||Oi(i)&&Oi(s)&&!Array.isArray(s)?zy(i,s):dr(e,r,s))}function Wy(...[e,t]){const n=gs(e||{}),r=Array.isArray(n),i=Hy(n);function s(...o){ur(()=>{r&&o.length===1?Lx(n,o[0]):Gl(n,o)})}return[i,s]}function kx(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||n.set||!n.configurable||t===Ir||t===Bi||(delete n.value,delete n.writable,n.get=()=>e[Ir][t],n.set=r=>e[Ir][t]=r),n}const Mx={get(e,t,n){if(t===Fa)return e;if(t===Ir)return n;if(t===vc)return ip(e),n;const r=Ba(e,Bi),i=r[t];let s=i?i():e[t];if(t===Bi||t===ii||t==="__proto__")return s;if(!i){const o=Object.getOwnPropertyDescriptor(e,t),a=typeof s=="function";if(yc()&&(!a||e.hasOwnProperty(t))&&!(o&&o.get))s=Co(r,t,s)();else if(s!=null&&a&&s===Array.prototype[t])return(...l)=>ur(()=>Array.prototype[t].apply(n,l))}return Oi(s)?qy(s):s},has(e,t){return t===Fa||t===Ir||t===vc||t===Bi||t===ii||t==="__proto__"?!0:(yc()&&Co(Ba(e,ii),t)(),t in e)},set(e,t,n){return ur(()=>dr(e,t,gs(n))),!0},deleteProperty(e,t){return ur(()=>dr(e,t,void 0,!0)),!0},ownKeys:Yy,getOwnPropertyDescriptor:kx};function qy(e){let t=e[Ir];if(!t){Object.defineProperty(e,Ir,{value:t=new Proxy(e,Mx)});const n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),s=i!==null&&e!==null&&typeof e=="object"&&!Array.isArray(e)&&i!==Object.prototype;if(s){let o=i;for(;o!=null;){const a=Object.getOwnPropertyDescriptors(o);n.push(...Object.keys(a)),Object.assign(r,a),o=Object.getPrototypeOf(o)}}for(let o=0,a=n.length;o<a;o++){const l=n[o];if(!(s&&l==="constructor")){if(r[l].get){const c=r[l].get.bind(t);Object.defineProperty(e,l,{get:c,configurable:!0})}if(r[l].set){const c=r[l].set;Object.defineProperty(e,l,{set:u=>ur(()=>c.call(t,u)),configurable:!0})}}}}return t}function Ky(e,t){const n=gs(e||{});return qy(n)}const Cg=Symbol("store-root");function ta(e,t,n,r,i){const s=t[n];if(e===s)return;const o=Array.isArray(e);if(n!==Cg&&(!Oi(e)||!Oi(s)||o!==Array.isArray(s)||i&&e[i]!==s[i])){dr(t,n,e);return}if(o){if(e.length&&s.length&&(!r||i&&e[0]&&e[0][i]!=null)){let c,d,u,_,m,g,p,E;for(u=0,_=Math.min(s.length,e.length);u<_&&(s[u]===e[u]||i&&s[u]&&e[u]&&s[u][i]&&s[u][i]===e[u][i]);u++)ta(e[u],s,u,r,i);const h=new Array(e.length),f=new Map;for(_=s.length-1,m=e.length-1;_>=u&&m>=u&&(s[_]===e[m]||i&&s[_]&&e[m]&&s[_][i]&&s[_][i]===e[m][i]);_--,m--)h[m]=s[_];if(u>m||u>_){for(d=u;d<=m;d++)dr(s,d,e[d]);for(;d<e.length;d++)dr(s,d,h[d]),ta(e[d],s,d,r,i);s.length>e.length&&dr(s,"length",e.length);return}for(p=new Array(m+1),d=m;d>=u;d--)g=e[d],E=i&&g?g[i]:g,c=f.get(E),p[d]=c===void 0?-1:c,f.set(E,d);for(c=u;c<=_;c++)g=s[c],E=i&&g?g[i]:g,d=f.get(E),d!==void 0&&d!==-1&&(h[d]=s[c],d=p[d],f.set(E,d));for(d=u;d<e.length;d++)d in h?(dr(s,d,h[d]),ta(e[d],s,d,r,i)):dr(s,d,e[d])}else for(let c=0,d=e.length;c<d;c++)ta(e[c],s,c,r,i);s.length>e.length&&dr(s,"length",e.length);return}const a=Object.keys(e);for(let c=0,d=a.length;c<d;c++)ta(e[a[c]],s,a[c],r,i);const l=Object.keys(s);for(let c=0,d=l.length;c<d;c++)e[l[c]]===void 0&&dr(s,l[c],void 0)}function Px(e,t={}){const{merge:n,key:r="id"}=t,i=gs(e);return s=>{if(!Oi(s)||!Oi(i))return i;const o=ta(i,{[Cg]:s},Cg,n,r);return o===void 0?s:o}}const Eu=new WeakMap,Qy={get(e,t){if(t===Fa)return e;const n=e[t];let r;return Oi(n)?Eu.get(n)||(Eu.set(n,r=new Proxy(n,Qy)),r):n},set(e,t,n){return dr(e,t,gs(n)),!0},deleteProperty(e,t){return dr(e,t,void 0,!0),!0}};function bi(e){return t=>{if(Oi(t)){let n;(n=Eu.get(t))||Eu.set(t,n=new Proxy(t,Qy)),e(n)}return t}}const[bo,Ns]=Wy({toasts:[],pausedAt:void 0}),$x=()=>{const{pausedAt:e,toasts:t}=bo;if(e)return;const n=Date.now();return t.map(i=>{if(i.duration===1/0)return;const s=(i.duration||0)+i.pauseDuration-(n-i.createdAt);if(s<=0){i.visible&&Ni({type:Pn.DISMISS_TOAST,toastId:i.id});return}return setTimeout(()=>{Ni({type:Pn.DISMISS_TOAST,toastId:i.id})},s)})},ec=new Map,UE=(e,t)=>{if(ec.has(e))return;const n=setTimeout(()=>{ec.delete(e),Ni({type:Pn.REMOVE_TOAST,toastId:e})},t);ec.set(e,n)},Fx=e=>{const t=ec.get(e);ec.delete(e),t&&clearTimeout(t)},Ni=e=>{switch(e.type){case Pn.ADD_TOAST:Ns("toasts",i=>{const s=i;return[e.toast,...s]});break;case Pn.DISMISS_TOAST:const{toastId:t}=e,n=bo.toasts;if(t){const i=n.find(s=>s.id===t);i&&UE(t,i.unmountDelay),Ns("toasts",s=>s.id===t,bi(s=>s.visible=!1))}else n.forEach(i=>{UE(i.id,i.unmountDelay)}),Ns("toasts",i=>i.id!==void 0,bi(i=>i.visible=!1));break;case Pn.REMOVE_TOAST:if(!e.toastId){Ns("toasts",[]);break}Ns("toasts",i=>i.filter(o=>o.id!==e.toastId));break;case Pn.UPDATE_TOAST:e.toast.id&&Fx(e.toast.id),Ns("toasts",i=>i.id===e.toast.id,i=>({...i,...e.toast}));break;case Pn.UPSERT_TOAST:bo.toasts.find(i=>i.id===e.toast.id)?Ni({type:Pn.UPDATE_TOAST,toast:e.toast}):Ni({type:Pn.ADD_TOAST,toast:e.toast});break;case Pn.START_PAUSE:Ns(bi(i=>{i.pausedAt=Date.now(),i.toasts.forEach(s=>{s.paused=!0})}));break;case Pn.END_PAUSE:const r=e.time-(bo.pausedAt||0);Ns(bi(i=>{i.pausedAt=void 0,i.toasts.forEach(s=>{s.pauseDuration+=r,s.paused=!1})}));break}},Bx={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Ta={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},jy={position:"top-right",toastOptions:Ta,gutter:8,containerStyle:{},containerClassName:""},pd="16px",Ux={position:"fixed","z-index":9999,top:pd,bottom:pd,left:pd,right:pd,"pointer-events":"none"},Gx=(()=>{let e=0;return()=>String(++e)})(),Vx=e=>{Qx(t=>({containerClassName:e.containerClassName??t.containerClassName,containerStyle:e.containerStyle??t.containerStyle,gutter:e.gutter??t.gutter,position:e.position??t.position,toastOptions:{...e.toastOptions}}))},Hx=(e,t)=>{const r=e.includes("top")?{top:0,"margin-top":`${t}px`}:{bottom:0,"margin-bottom":`${t}px`},i=e.includes("center")?{"justify-content":"center"}:e.includes("right")?{"justify-content":"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:"all 230ms cubic-bezier(.21,1.02,.73,1)",...r,...i}},Yx=(e,t)=>{const n=e.getBoundingClientRect();n.height!==t.height&&Ni({type:Pn.UPDATE_TOAST,toast:{id:t.id,height:n.height}})},zx=(e,t)=>{const{toasts:n}=bo,r=na().gutter||jy.gutter||8,i=n.filter(l=>(l.position||t)===t&&l.height),s=i.findIndex(l=>l.id===e.id),o=i.filter((l,c)=>c<s&&l.visible).length;return i.slice(0,o).reduce((l,c)=>l+r+(c.height||0),0)},Wx=(e,t)=>(e.position||t).includes("top")?1:-1,qx={display:"flex","align-items":"center",color:"#363636",background:"white","box-shadow":"0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05)","max-width":"350px","pointer-events":"auto",padding:"8px 10px","border-radius":"4px","line-height":"1.3","will-change":"transform"},Kx={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},hd={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},Su=e=>({calcMode:"spline",keyTimes:"0; 1",keySplines:e}),[na,Qx]=U(jy),jx=(e,t="blank",n)=>{var r,i,s;return{...Ta,...na().toastOptions,...n,type:t,message:e,pauseDuration:0,createdAt:Date.now(),visible:!0,id:n.id||Gx(),paused:!1,style:{...Ta.style,...(r=na().toastOptions)==null?void 0:r.style,...n.style},duration:n.duration||((i=na().toastOptions)==null?void 0:i.duration)||Bx[t],position:n.position||((s=na().toastOptions)==null?void 0:s.position)||na().position||Ta.position}},Kc=e=>(t,n={})=>vg(()=>{const r=bo.toasts.find(s=>s.id===n.id),i=jx(t,e,{...r,duration:void 0,...n});return Ni({type:Pn.UPSERT_TOAST,toast:i}),i.id}),Yr=(e,t)=>Kc("blank")(e,t);Wr(()=>Yr);Yr.error=Kc("error");Yr.success=Kc("success");Yr.loading=Kc("loading");Yr.custom=Kc("custom");Yr.dismiss=e=>{Ni({type:Pn.DISMISS_TOAST,toastId:e})};Yr.promise=(e,t,n)=>{const r=Yr.loading(t.loading,{...n});return e.then(i=>(Yr.success(hu(t.success,i),{id:r,...n}),i)).catch(i=>{Yr.error(hu(t.error,i),{id:r,...n})}),e};Yr.remove=e=>{Ni({type:Pn.REMOVE_TOAST,toastId:e})};var Xx=x("<div><style>.sldt-active{z-index:9999;}.sldt-active>*{pointer-events:auto;}");const Zx=e=>(J(()=>{Vx(e)}),J(()=>{const t=$x();Ne(()=>{t&&t.forEach(n=>n&&clearTimeout(n))})}),(()=>{var t=Xx();return t.firstChild,C(t,S(_t,{get each(){return bo.toasts},children:n=>S(nD,{toast:n})}),null),ne(n=>{var r={...Ux,...e.containerStyle},i=e.containerClassName;return n.e=ri(t,r,n.e),i!==n.t&&rt(t,n.t=i),n},{e:void 0,t:void 0}),t})());var Ed=x("<div>"),Jx=x("<div><div>");const eD=e=>{let t;return J(()=>{if(!t)return;const n=Wx(e.toast,e.position);e.toast.visible?t.animate([{transform:`translate3d(0,${n*-200}%,0) scale(.6)`,opacity:.5},{transform:"translate3d(0,0,0) scale(1)",opacity:1}],{duration:350,fill:"forwards",easing:"cubic-bezier(.21,1.02,.73,1)"}):t.animate([{transform:"translate3d(0,0,-1px) scale(1)",opacity:1},{transform:`translate3d(0,${n*-150}%,-1px) scale(.4)`,opacity:0}],{duration:400,fill:"forwards",easing:"cubic-bezier(.06,.71,.55,1)"})}),(()=>{var n=Jx(),r=n.firstChild,i=t;return typeof i=="function"?wt(i,n):t=n,C(n,S(Wc,{get children(){return[S(sr,{get when(){return e.toast.icon},get children(){var s=Ed();return C(s,()=>e.toast.icon),ne(o=>ri(s,hd,o)),s}}),S(sr,{get when(){return e.toast.type==="loading"},get children(){var s=Ed();return C(s,S(dD,oe(()=>e.toast.iconTheme))),ne(o=>ri(s,hd,o)),s}}),S(sr,{get when(){return e.toast.type==="success"},get children(){var s=Ed();return C(s,S(oD,oe(()=>e.toast.iconTheme))),ne(o=>ri(s,hd,o)),s}}),S(sr,{get when(){return e.toast.type==="error"},get children(){var s=Ed();return C(s,S(lD,oe(()=>e.toast.iconTheme))),ne(o=>ri(s,hd,o)),s}})]}}),r),Ii(r,oe(()=>e.toast.ariaProps),!1,!0),C(r,()=>hu(e.toast.message,e.toast)),ne(s=>{var o=e.toast.className,a={...qx,...e.toast.style},l=Kx;return o!==s.e&&rt(n,s.e=o),s.t=ri(n,a,s.t),s.a=ri(r,l,s.a),s},{e:void 0,t:void 0,a:void 0}),n})()};var tD=x("<div>");const nD=e=>{const t=()=>{const i=e.toast.position||Ta.position,s=zx(e.toast,i);return Hx(i,s)},n=F(()=>t());let r;return Tn(()=>{r&&Yx(r,e.toast)}),(()=>{var i=tD();i.addEventListener("mouseleave",()=>Ni({type:Pn.END_PAUSE,time:Date.now()})),i.addEventListener("mouseenter",()=>Ni({type:Pn.START_PAUSE,time:Date.now()}));var s=r;return typeof s=="function"?wt(s,i):r=i,C(i,(()=>{var o=we(()=>e.toast.type==="custom");return()=>o()?hu(e.toast.message,e.toast):S(eD,{get toast(){return e.toast},get position(){return e.toast.position||Ta.position}})})()),ne(o=>{var a=n(),l=e.toast.visible?"sldt-active":"";return o.e=ri(i,a,o.e),l!==o.t&&rt(i,o.t=l),o},{e:void 0,t:void 0}),i})()};var rD=x('<svg><circle cx=16 cy=16 r=0><animate attributeName=opacity values="0; 1; 1"></animate><animate attributeName=r values="0; 17.5; 16"></svg>',!1,!0,!1),iD=x('<svg><circle cx=16 cy=16 r=12 opacity=0><animate attributeName=opacity values="1; 0"></animate><animate attributeName=r values="12; 26"></svg>',!1,!0,!1);const Xy=e=>{const t={dur:"0.35s",begin:"100ms",fill:"freeze",calcMode:"spline",keyTimes:"0; 0.6; 1",keySplines:"0.25 0.71 0.4 0.88; .59 .22 .87 .63"};return(()=>{var n=rD(),r=n.firstChild,i=r.nextSibling;return Ii(r,t,!0,!1),Ii(i,t,!0,!1),ne(()=>Fe(n,"fill",e.fill)),n})()},Zy=e=>{const t={dur:"1s",begin:e.begin||"320ms",fill:"freeze",...Su("0.0 0.0 0.2 1")};return(()=>{var n=iD(),r=n.firstChild,i=r.nextSibling;return Ii(r,t,!0,!1),Ii(i,t,!0,!1),ne(()=>Fe(n,"fill",e.fill)),n})()};var sD=x('<svg viewBox="0 0 32 32"width=1.25rem height=1.25rem style=overflow:visible><path fill=none stroke-width=4 stroke-dasharray=22 stroke-dashoffset=22 stroke-linecap=round stroke-miterlimit=10 d=M9.8,17.2l3.8,3.6c0.1,0.1,0.3,0.1,0.4,0l9.6-9.7><animate attributeName=stroke-dashoffset values=22;0 dur=0.25s begin=250ms fill=freeze>');const oD=e=>{const t=e.primary||"#34C759";return(()=>{var n=sD(),r=n.firstChild,i=r.firstChild;return C(n,S(Xy,{fill:t}),r),C(n,S(Zy,{fill:t,begin:"350ms"}),r),Ii(i,oe(()=>Su("0.0, 0.0, 0.58, 1.0")),!0,!1),ne(()=>Fe(r,"stroke",e.secondary||"#FCFCFC")),n})()};var aD=x('<svg viewBox="0 0 32 32"width=1.25rem height=1.25rem style=overflow:visible><path fill=none stroke-width=4 stroke-dasharray=9 stroke-dashoffset=9 stroke-linecap=round d=M16,7l0,9><animate attributeName=stroke-dashoffset values=9;0 dur=0.2s begin=250ms fill=freeze></animate></path><circle cx=16 cy=23 r=2.5 opacity=0><animate attributeName=opacity values=0;1 dur=0.25s begin=350ms fill=freeze>');const lD=e=>{const t=e.primary||"#FF3B30";return(()=>{var n=aD(),r=n.firstChild,i=r.firstChild,s=r.nextSibling,o=s.firstChild;return C(n,S(Xy,{fill:t}),r),C(n,S(Zy,{fill:t}),r),Ii(i,oe(()=>Su("0.0, 0.0, 0.58, 1.0")),!0,!1),Ii(o,oe(()=>Su("0.0, 0.0, 0.58, 1.0")),!0,!1),ne(a=>{var l=e.secondary||"#FFFFFF",c=e.secondary||"#FFFFFF";return l!==a.e&&Fe(r,"stroke",a.e=l),c!==a.t&&Fe(s,"fill",a.t=c),a},{e:void 0,t:void 0}),n})()};var cD=x('<svg viewBox="0 0 32 32"width=1.25rem height=1.25rem style=overflow:visible><path fill=none stroke-width=4 stroke-miterlimit=10 d=M16,6c3,0,5.7,1.3,7.5,3.4c1.5,1.8,2.5,4,2.5,6.6c0,5.5-4.5,10-10,10S6,21.6,6,16S10.5,6,16,6z></path><path fill=none stroke-width=4 stroke-linecap=round stroke-miterlimit=10 d=M16,6c3,0,5.7,1.3,7.5,3.4c0.6,0.7,1.1,1.4,1.5,2.2><animateTransform attributeName=transform type=rotate from="0 16 16"to="360 16 16"dur=0.75s repeatCount=indefinite>');const dD=e=>(()=>{var t=cD(),n=t.firstChild,r=n.nextSibling;return ne(i=>{var s=e.primary||"#E5E7EB",o=e.secondary||"#4b5563";return s!==i.e&&Fe(n,"stroke",i.e=s),o!==i.t&&Fe(r,"stroke",i.t=o),i},{e:void 0,t:void 0}),t})(),[Rg,sp]=U(null);function Gs(e,t){sp({type:"alert",message:e,...t})}function op(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(r=>{sp({type:"confirm",message:e,...t,resolve:r})})}function um(){sp(null)}var uD=x('<div class="flex items-start gap-3"><div class="flex h-12 w-12 shrink-0 items-center justify-center rounded-xl border text-base font-semibold"aria-hidden></div><div class="flex-1 min-w-0">'),_D=x('<div class=mt-4><label class="text-xs font-medium text-muted uppercase tracking-wide"></label><input class="modal-search-input mt-2">'),mD=x('<div class="mt-6 flex justify-end gap-3"><button type=button class=button-primary>'),gD=x('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),fD=x('<p class="mt-2 text-secondary">'),pD=x("<button type=button class=button-secondary>");const hD={info:{badgeBg:"var(--badge-neutral-bg)",badgeBorder:"var(--border-base)",badgeText:"var(--accent-primary)",symbol:"i",fallbackTitle:"Heads up"},warning:{badgeBg:"rgba(255, 152, 0, 0.14)",badgeBorder:"var(--status-warning)",badgeText:"var(--status-warning)",symbol:"!",fallbackTitle:"Please review"},error:{badgeBg:"var(--danger-soft-bg)",badgeBorder:"var(--status-error)",badgeText:"var(--status-error)",symbol:"!",fallbackTitle:"Something went wrong"}};function Sd(e,t,n){var i,s,o,a,l,c,d,u;const r=t??Rg();if((r==null?void 0:r.type)==="confirm"){e?(i=r.onConfirm)==null||i.call(r):(s=r.onCancel)==null||s.call(r),(o=r.resolve)==null||o.call(r,e),um();return}if((r==null?void 0:r.type)==="prompt"){e?((a=r.onConfirm)==null||a.call(r),(l=r.resolvePrompt)==null||l.call(r,n??"")):((c=r.onCancel)==null||c.call(r),(d=r.resolvePrompt)==null||d.call(r,null)),um();return}e&&((u=r==null?void 0:r.onConfirm)==null||u.call(r)),um()}const ED=()=>{let e;return J(()=>{Rg()&&queueMicrotask(()=>{e==null||e.focus()})}),S(W,{get when(){return Rg()},keyed:!0,children:t=>{const n=t.variant??"info",r=hD[n],i=t.title||r.fallbackTitle,s=t.type==="confirm",o=t.type==="prompt",a=t.confirmLabel||(s?"Confirm":o?"Run":"OK"),l=t.cancelLabel||"Cancel",[c,d]=U(t.inputDefaultValue??"");return S(ft,{open:!0,modal:!0,onOpenChange:u=>{u||Sd(!1,t)},get children(){return S(ft.Portal,{get children(){return[S(ft.Overlay,{class:"modal-overlay"}),(()=>{var u=gD();return C(u,S(ft.Content,{class:"modal-surface w-full max-w-sm p-6 border border-base shadow-2xl",tabIndex:-1,get children(){return[(()=>{var _=uD(),m=_.firstChild,g=m.nextSibling;return C(m,()=>r.symbol),C(g,S(ft.Title,{class:"text-lg font-semibold text-primary",children:i}),null),C(g,S(ft.Description,{class:"text-sm text-secondary mt-1 whitespace-pre-line break-words",get children(){return[we(()=>t.message),we(()=>we(()=>!!t.detail)()&&(()=>{var p=fD();return C(p,()=>t.detail),p})())]}}),null),ne(p=>{var E=r.badgeBg,h=r.badgeBorder,f=r.badgeText;return E!==p.e&&Ci(m,"background-color",p.e=E),h!==p.t&&Ci(m,"border-color",p.t=h),f!==p.a&&Ci(m,"color",p.a=f),p},{e:void 0,t:void 0,a:void 0}),_})(),S(W,{when:o,get children(){var _=_D(),m=_.firstChild,g=m.nextSibling;return C(m,()=>t.inputLabel||"Arguments"),g.$$keydown=p=>{p.key==="Enter"&&(p.preventDefault(),Sd(!0,t,c()))},g.$$input=p=>d(p.currentTarget.value),ne(()=>Fe(g,"placeholder",t.inputPlaceholder||"")),ne(()=>g.value=c()),_}}),(()=>{var _=mD(),m=_.firstChild;return C(_,(s||o)&&(()=>{var g=pD();return g.$$click=()=>Sd(!1,t),C(g,l),g})(),m),m.$$click=()=>Sd(!0,t,c()),wt(g=>{e=g},m),C(m,a),_})()]}})),u})()]}})}})}})};Ht(["input","keydown","click"]);const Ko={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};var SD=x("<svg>");const bD=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),It=e=>{const[t,n]=lt(e,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var r=SD();return Ii(r,oe(Ko,{get width(){return t.size??Ko.width},get height(){return t.size??Ko.height},get stroke(){return t.color??Ko.stroke},get"stroke-width"(){return we(()=>!!t.absoluteStrokeWidth)()?Number(t.strokeWidth??Ko["stroke-width"])*24/Number(t.size):Number(t.strokeWidth??Ko["stroke-width"])},get class(){return`lucide lucide-${bD((t==null?void 0:t.name)??"icon")} ${t.class!=null?t.class:""}`}},n),!0,!0),C(r,S(_t,{get each(){return t.iconNode},children:([i,s])=>S(fu,oe({component:i},s))})),r})()},vD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],yD=e=>S(It,oe(e,{name:"AlertCircle",iconNode:vD})),TD=[["path",{d:"M15 6v6h4l-7 7-7-7h4V6h6z",key:"1thax2"}]],CD=e=>S(It,oe(e,{name:"ArrowBigDown",iconNode:TD})),RD=[["path",{d:"M9 18v-6H5l7-7 7 7h-4v6H9z",key:"1x06kx"}]],ID=e=>S(It,oe(e,{name:"ArrowBigUp",iconNode:RD})),OD=[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]],Jy=e=>S(It,oe(e,{name:"ArrowUpLeft",iconNode:OD})),ND=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],eT=e=>S(It,oe(e,{name:"Bot",iconNode:ND})),AD=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],wD=e=>S(It,oe(e,{name:"Check",iconNode:AD})),xD=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Qc=e=>S(It,oe(e,{name:"ChevronDown",iconNode:xD})),DD=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],LD=e=>S(It,oe(e,{name:"ChevronRight",iconNode:DD})),kD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],MD=e=>S(It,oe(e,{name:"Clock",iconNode:kD})),PD=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],$D=e=>S(It,oe(e,{name:"Copy",iconNode:PD})),FD=[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]],BD=e=>S(It,oe(e,{name:"Expand",iconNode:FD})),UD=[["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}],["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["line",{x1:"10",x2:"21",y1:"14",y2:"3",key:"18c3s4"}]],GD=e=>S(It,oe(e,{name:"ExternalLink",iconNode:UD})),VD=[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}]],HD=e=>S(It,oe(e,{name:"File",iconNode:VD})),YD=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]],tT=e=>S(It,oe(e,{name:"FoldVertical",iconNode:YD})),zD=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],nT=e=>S(It,oe(e,{name:"FolderOpen",iconNode:zD})),WD=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],qD=e=>S(It,oe(e,{name:"FolderPlus",iconNode:WD})),KD=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ap=e=>S(It,oe(e,{name:"Folder",iconNode:KD})),QD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],jD=e=>S(It,oe(e,{name:"Globe",iconNode:QD})),XD=[["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["path",{d:"m15.5 7.5 3 3L22 7l-3-3",key:"1rn1fs"}]],GE=e=>S(It,oe(e,{name:"Key",iconNode:XD})),ZD=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],JD=e=>S(It,oe(e,{name:"Link2",iconNode:ZD})),e0=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ro=e=>S(It,oe(e,{name:"Loader2",iconNode:e0})),t0=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],n0=e=>S(It,oe(e,{name:"Maximize2",iconNode:t0})),r0=[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],i0=e=>S(It,oe(e,{name:"Minimize2",iconNode:r0})),s0=[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],rT=e=>S(It,oe(e,{name:"MonitorUp",iconNode:s0})),o0=[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],iT=e=>S(It,oe(e,{name:"Pencil",iconNode:o0})),a0=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],lp=e=>S(It,oe(e,{name:"Plus",iconNode:a0})),l0=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],c0=e=>S(It,oe(e,{name:"RefreshCw",iconNode:l0})),d0=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],u0=e=>S(It,oe(e,{name:"Search",iconNode:d0})),_0=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],m0=e=>S(It,oe(e,{name:"Settings",iconNode:_0})),g0=[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],__=e=>S(It,oe(e,{name:"ShieldAlert",iconNode:g0})),f0=[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}]],VE=e=>S(It,oe(e,{name:"Shield",iconNode:f0})),p0=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],h0=e=>S(It,oe(e,{name:"TerminalSquare",iconNode:p0})),E0=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],al=e=>S(It,oe(e,{name:"Trash2",iconNode:E0})),S0=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],sT=e=>S(It,oe(e,{name:"User",iconNode:S0})),b0=[["path",{d:"M5 13a10 10 0 0 1 14 0",key:"6v8j51"}],["path",{d:"M8.5 16.5a5 5 0 0 1 7 0",key:"sej527"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["line",{x1:"12",x2:"12.01",y1:"20",y2:"20",key:"of4bc4"}]],v0=e=>S(It,oe(e,{name:"Wifi",iconNode:b0})),y0=[["polygon",{points:"7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2",key:"h1p8hx"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],T0=e=>S(It,oe(e,{name:"XOctagon",iconNode:y0})),C0=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],cp=e=>S(It,oe(e,{name:"X",iconNode:C0})),HE="http://127.0.0.1:9898";var Sy;const R0=typeof window<"u"?(Sy=window.location)==null?void 0:Sy.origin:void 0,I0=typeof window<"u"?window.__CODENOMAD_API_BASE__??R0??HE:HE,O0=typeof window<"u"?window.__CODENOMAD_EVENTS_URL__??"/api/events":"/api/events",Ua=I0,YE=w0(Ua,O0),N0=Ua;function A0(e,t){const n=encodeURIComponent(e),r=encodeURIComponent(t);return x0(`/workspaces/${n}/plugin/background-processes/${r}/stream`)}function w0(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(e){const n=t.startsWith("/")?t:`/${t}`;return`${e}${n}`}return t}function x0(e){if(e.startsWith("http://")||e.startsWith("https://")||!Ua)return e;const t=e.startsWith("/")?e:`/${e}`;return`${Ua}${t}`}const zE=vt("api"),_m=vt("sse");function D0(e){const t={};if(!e)return t;if(e instanceof Headers)return e.forEach((n,r)=>{t[r]=n}),t;if(Array.isArray(e)){for(const[n,r]of e)t[n]=r;return t}return{...e}}function bd(e,t){if(t){zE.info(e,t);return}zE.info(e)}async function cn(e,t){const n=Ua?new URL(e,Ua).toString():e,r=D0(t==null?void 0:t.headers);(t==null?void 0:t.body)!==void 0&&(r["Content-Type"]="application/json");const i=((t==null?void 0:t.method)??"GET").toUpperCase(),s=Date.now();bd(`${i} ${e}`);try{const o=await fetch(n,{...t,headers:r,credentials:(t==null?void 0:t.credentials)??"include"});if(!o.ok){const l=await o.text();throw bd(`${i} ${e} -> ${o.status}`,{durationMs:Date.now()-s,error:l}),new Error(l||`Request failed with ${o.status}`)}const a=Date.now()-s;return bd(`${i} ${e} -> ${o.status}`,{durationMs:a}),o.status===204?void 0:await o.json()}catch(o){throw bd(`${i} ${e} failed`,{durationMs:Date.now()-s,error:o}),o}}const vn={fetchWorkspaces(){return cn("/api/workspaces")},createWorkspace(e){return cn("/api/workspaces",{method:"POST",body:JSON.stringify(e)})},fetchServerMeta(){return cn("/api/meta")},fetchAuthStatus(){return cn("/api/auth/status")},setServerPassword(e){return cn("/api/auth/password",{method:"POST",body:JSON.stringify({password:e})})},deleteWorkspace(e){return cn(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})},listWorkspaceFiles(e,t="."){const n=new URLSearchParams({path:t});return cn(`/api/workspaces/${encodeURIComponent(e)}/files?${n.toString()}`)},searchWorkspaceFiles(e,t,n){const r=t.trim();if(!r)return Promise.resolve([]);const i=new URLSearchParams({q:r});return n!=null&&n.limit&&i.set("limit",String(n.limit)),n!=null&&n.type&&i.set("type",n.type),cn(`/api/workspaces/${encodeURIComponent(e)}/files/search?${i.toString()}`)},readWorkspaceFile(e,t){const n=new URLSearchParams({path:t});return cn(`/api/workspaces/${encodeURIComponent(e)}/files/content?${n.toString()}`)},fetchConfig(){return cn("/api/config/app")},updateConfig(e){return cn("/api/config/app",{method:"PUT",body:JSON.stringify(e)})},listBinaries(){return cn("/api/config/binaries")},createBinary(e){return cn("/api/config/binaries",{method:"POST",body:JSON.stringify(e)})},updateBinary(e,t){return cn(`/api/config/binaries/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})},deleteBinary(e){return cn(`/api/config/binaries/${encodeURIComponent(e)}`,{method:"DELETE"})},validateBinary(e){return cn("/api/config/binaries/validate",{method:"POST",body:JSON.stringify({path:e})})},listFileSystem(e,t){const n=new URLSearchParams;e&&e!=="."&&n.set("path",e),(t==null?void 0:t.includeFiles)!==void 0&&n.set("includeFiles",String(t.includeFiles));const r=n.toString();return cn(r?`/api/filesystem?${r}`:"/api/filesystem")},readInstanceData(e){return cn(`/api/storage/instances/${encodeURIComponent(e)}`)},writeInstanceData(e,t){return cn(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})},deleteInstanceData(e){return cn(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"DELETE"})},listBackgroundProcesses(e){return cn(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes`)},stopBackgroundProcess(e,t){return cn(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes/${encodeURIComponent(t)}/stop`,{method:"POST"})},terminateBackgroundProcess(e,t){return cn(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes/${encodeURIComponent(t)}/terminate`,{method:"POST"})},fetchBackgroundProcessOutput(e,t,n){const r=new URLSearchParams;n!=null&&n.method&&r.set("method",n.method),n!=null&&n.pattern&&r.set("pattern",n.pattern),n!=null&&n.lines&&r.set("lines",String(n.lines)),(n==null?void 0:n.maxBytes)!==void 0&&r.set("maxBytes",String(n.maxBytes));const i=r.toString(),s=i?`?${i}`:"";return cn(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes/${encodeURIComponent(t)}/output${s}`)},connectEvents(e,t){_m.info(`Connecting to ${YE}`);const n=new EventSource(YE,{withCredentials:!0});return n.onmessage=r=>{try{const i=JSON.parse(r.data);e(i)}catch(i){_m.error("Failed to parse event",i)}},n.onerror=()=>{_m.warn("EventSource error, closing stream"),t==null||t()},n}},WE=1e3,L0=1e4,qE=vt("sse");function vd(e,t){if(t){qE.info(e,t);return}qE.info(e)}class k0{constructor(){this.handlers=new Map,this.source=null,this.retryDelay=WE,this.connect()}connect(){this.source&&this.source.close(),vd("Connecting to backend events stream"),this.source=vn.connectEvents(t=>this.dispatch(t),()=>this.scheduleReconnect()),this.source.onopen=()=>{vd("Events stream connected"),this.retryDelay=WE}}scheduleReconnect(){this.source&&(this.source.close(),this.source=null),vd("Events stream disconnected, scheduling reconnect",{delayMs:this.retryDelay}),setTimeout(()=>{this.retryDelay=Math.min(this.retryDelay*2,L0),this.connect()},this.retryDelay)}dispatch(t){var n,r;vd(`event ${t.type}`),(n=this.handlers.get("*"))==null||n.forEach(i=>i(t)),(r=this.handlers.get(t.type))==null||r.forEach(i=>i(t))}on(t,n){this.handlers.has(t)||this.handlers.set(t,new Set);const r=this.handlers.get(t);return r.add(n),()=>r.delete(n)}}const Ga=new k0,M0=vt("actions"),KE={messageHistory:[],agentModelSelections:{}};function QE(e,t){if(e===t)return!0;if(typeof e=="object"&&e!==null&&typeof t=="object"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){M0.warn("Failed to compare config objects",n)}return!1}class P0{constructor(){this.configChangeListeners=new Set,this.configCache=null,this.loadPromise=null,this.instanceDataCache=new Map,this.instanceDataListeners=new Map,this.instanceLoadPromises=new Map,Ga.on("config.appChanged",t=>{t.type==="config.appChanged"&&this.setConfigCache(t.config)}),Ga.on("instance.dataChanged",t=>{t.type==="instance.dataChanged"&&this.setInstanceDataCache(t.instanceId,t.data)})}async loadConfig(){return this.configCache?this.configCache:(this.loadPromise||(this.loadPromise=vn.fetchConfig().then(t=>(this.setConfigCache(t),t)).finally(()=>{this.loadPromise=null})),this.loadPromise)}async updateConfig(t){const n=await vn.updateConfig(t);return this.setConfigCache(n),n}async loadInstanceData(t){const n=this.instanceDataCache.get(t);if(n)return n;if(!this.instanceLoadPromises.has(t)){const r=vn.readInstanceData(t).then(i=>{const s=this.normalizeInstanceData(i);return this.setInstanceDataCache(t,s),s}).finally(()=>{this.instanceLoadPromises.delete(t)});this.instanceLoadPromises.set(t,r)}return this.instanceLoadPromises.get(t)}async saveInstanceData(t,n){const r=this.normalizeInstanceData(n);await vn.writeInstanceData(t,r),this.setInstanceDataCache(t,r)}async deleteInstanceData(t){await vn.deleteInstanceData(t),this.setInstanceDataCache(t,KE)}onConfigChanged(t){return this.configChangeListeners.add(t),this.configCache&&t(this.configCache),()=>this.configChangeListeners.delete(t)}onInstanceDataChanged(t,n){this.instanceDataListeners.has(t)||this.instanceDataListeners.set(t,new Set);const r=this.instanceDataListeners.get(t);r.add(n);const i=this.instanceDataCache.get(t);return i&&n(i),()=>{r.delete(n),r.size===0&&this.instanceDataListeners.delete(t)}}setConfigCache(t){if(this.configCache&&QE(this.configCache,t)){this.configCache=t;return}this.configCache=t,this.notifyConfigChanged(t)}notifyConfigChanged(t){for(const n of this.configChangeListeners)n(t)}normalizeInstanceData(t){const n=t??KE,r=Array.isArray(n.messageHistory)?[...n.messageHistory]:[],i={...n.agentModelSelections??{}};return{...n,messageHistory:r,agentModelSelections:i}}setInstanceDataCache(t,n){const r=this.normalizeInstanceData(n),i=this.instanceDataCache.get(t);if(i&&QE(i,r)){this.instanceDataCache.set(t,r);return}this.instanceDataCache.set(t,r),this.notifyInstanceDataChanged(t,r)}notifyInstanceDataChanged(t,n){const r=this.instanceDataListeners.get(t);if(r)for(const i of r)i(n)}}const Io=new P0,oT=vt("api"),m_={messageHistory:[],agentModelSelections:{}},[dp,aT]=U(new Map),yd=new Map,Va=new Map;function lT(e){const t=e??m_;return{...t,messageHistory:Array.isArray(t.messageHistory)?[...t.messageHistory]:[],agentModelSelections:{...t.agentModelSelections??{}}}}function jE(e){if(Va.has(e))return;const t=Io.onInstanceDataChanged(e,n=>{bu(e,n)});Va.set(e,t)}function $0(e){const t=Va.get(e);t&&(t(),Va.delete(e))}function bu(e,t){aT(n=>{const r=new Map(n);return r.set(e,lT(t)),r})}async function Bo(e){if(!e||dp().has(e))return;if(yd.has(e)){await yd.get(e);return}const t=Io.loadInstanceData(e).then(n=>{bu(e,n),jE(e)}).catch(n=>{oT.warn("Failed to load instance data",n),bu(e,m_),jE(e)}).finally(()=>{yd.delete(e)});yd.set(e,t),await t}async function up(e,t){if(!e)return;await Bo(e);const n=dp().get(e)??m_,r=lT(n);t(r);try{await Io.saveInstanceData(e,r)}catch(i){oT.warn("Failed to persist instance data",i)}bu(e,r)}function _p(e){return dp().get(e)??m_}function F0(e){aT(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),$0(e)}const B0=Jt(),U0={getInstanceConfig:_p,ensureInstanceConfig:Bo,updateInstanceConfig:up,clearInstanceConfig:F0},G0=e=>(Ne(()=>{for(const t of Va.values())t();Va.clear()}),S(B0.Provider,{value:U0,get children(){return e.children}})),Hi=vt("actions"),V0=20,H0=5,Jr={showThinkingBlocks:!1,thinkingBlocksExpansion:"expanded",showTimelineTools:!0,environmentVariables:{},modelRecents:[],diffViewMode:"split",toolOutputExpansion:"expanded",diagnosticsExpansion:"expanded",showUsageMetrics:!0,autoCleanupBlankSessions:!0,listeningMode:"local"};function cT(e,t){if(e===t)return!0;if(typeof e=="object"&&e!==null&&typeof t=="object"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){Hi.warn("Failed to compare preference values",n)}return!1}function g_(e){const t=e??{},n={...Jr.environmentVariables,...t.environmentVariables??{}},i=(t.modelRecents??Jr.modelRecents).map(s=>({...s}));return{showThinkingBlocks:t.showThinkingBlocks??Jr.showThinkingBlocks,thinkingBlocksExpansion:t.thinkingBlocksExpansion??Jr.thinkingBlocksExpansion,showTimelineTools:t.showTimelineTools??Jr.showTimelineTools,lastUsedBinary:t.lastUsedBinary??Jr.lastUsedBinary,environmentVariables:n,modelRecents:i,diffViewMode:t.diffViewMode??Jr.diffViewMode,toolOutputExpansion:t.toolOutputExpansion??Jr.toolOutputExpansion,diagnosticsExpansion:t.diagnosticsExpansion??Jr.diagnosticsExpansion,showUsageMetrics:t.showUsageMetrics??Jr.showUsageMetrics,autoCleanupBlankSessions:t.autoCleanupBlankSessions??Jr.autoCleanupBlankSessions,listeningMode:t.listeningMode??Jr.listeningMode}}const[no,Y0]=U(_T()),z0=F(()=>no()),[dT,W0]=U(!1),Jn=F(()=>no().preferences),q0=F(()=>no().recentFolders??[]),K0=F(()=>no().opencodeBinaries??[]),uT=F(()=>no().theme??"dark");let Td=null;function f_(e){return{preferences:g_(e==null?void 0:e.preferences),recentFolders:((e==null?void 0:e.recentFolders)??[]).map(t=>({...t})),opencodeBinaries:((e==null?void 0:e.opencodeBinaries)??[]).map(t=>({...t})),theme:(e==null?void 0:e.theme)??"dark"}}function _T(){return f_()}function Q0(e){var r;const t=!!((r=e==null?void 0:e.preferences)!=null&&r.agentModelSelections);return{cleaned:f_(e),migrated:t}}async function mp(e){try{const t=e??await Io.loadConfig(),{cleaned:n,migrated:r}=Q0(t);Ig(n),r&&Io.updateConfig(n).catch(i=>{Hi.error("Failed to persist legacy config cleanup",i)})}catch(t){Hi.error("Failed to load config",t),Ig(_T())}}function Ig(e){Y0(f_(e)),W0(!0)}function j0(){return f_(no())}function X0(e,t){if(cT(e,t))return;const n=mT(e,t);n.length>0&&Hi.info("[Config] Changes",n)}function mT(e,t,n=[]){if(e===t)return[];if(typeof e!="object"||e===null||typeof t!="object"||t===null)return[n.join(".")];const r=Object.keys(e),i=Object.keys(t),s=new Set([...r,...i]),o=[];for(const a of s){const l=[...n,a],c=e[a],d=t[a];o.push(...mT(c,d,l))}return o}function vs(e){const t=no(),n=j0();e(n),X0(t,n),Ig(n),Z0(n)}async function Z0(e){try{await gp(),await Io.updateConfig(e)}catch(t){Hi.error("Failed to save config",t),mp().catch(n=>{Hi.error("Failed to refresh config",n)})}}function J0(e){uT()!==e&&vs(t=>{t.theme=e})}async function gp(){dT()||(Td||(Td=mp().finally(()=>{Td=null})),await Td)}function gT(e,t){const n=t.filter(r=>r.path!==e);return n.unshift({path:e,lastAccessed:Date.now()}),n.slice(0,V0)}function fp(e,t,n){const r=Date.now(),i=n.find(o=>o.path===e);if(i){const o={...i,lastUsed:r},a=n.filter(l=>l.path!==e);return[o,...a]}return[t?{path:e,version:t,lastUsed:r}:{path:e,lastUsed:r},...n].slice(0,10)}function di(e){const t=no().preferences,n=g_({...t,...e});cT(t,n)||vs(r=>{r.preferences=n})}function fT(e){Jn().listeningMode!==e&&di({listeningMode:e})}function eL(e){Jn().diffViewMode!==e&&di({diffViewMode:e})}function tL(e){Jn().toolOutputExpansion!==e&&di({toolOutputExpansion:e})}function nL(e){Jn().diagnosticsExpansion!==e&&di({diagnosticsExpansion:e})}function rL(e){Jn().thinkingBlocksExpansion!==e&&di({thinkingBlocksExpansion:e})}function iL(){di({showThinkingBlocks:!Jn().showThinkingBlocks})}function sL(){di({showTimelineTools:!Jn().showTimelineTools})}function oL(){di({showUsageMetrics:!Jn().showUsageMetrics})}function aL(){const e=!Jn().autoCleanupBlankSessions;Hi.info("toggle auto cleanup",{value:e}),di({autoCleanupBlankSessions:e})}function lL(e){vs(t=>{t.recentFolders=gT(e,t.recentFolders)})}function cL(e){vs(t=>{t.recentFolders=t.recentFolders.filter(n=>n.path!==e)})}function dL(e,t){vs(n=>{n.opencodeBinaries=fp(e,t,n.opencodeBinaries)})}function uL(e){vs(t=>{t.opencodeBinaries=t.opencodeBinaries.filter(n=>n.path!==e)})}function _L(e){const t=e||Jn().lastUsedBinary||"opencode";vs(n=>{n.preferences=g_({...n.preferences,lastUsedBinary:t}),n.opencodeBinaries=fp(t,void 0,n.opencodeBinaries)})}function mL(e,t){vs(n=>{const r=t&&t.trim().length>0?t:n.preferences.lastUsedBinary||"opencode";n.recentFolders=gT(e,n.recentFolders),n.preferences=g_({...n.preferences,lastUsedBinary:r}),n.opencodeBinaries=fp(r,void 0,n.opencodeBinaries)})}function pp(e){di({environmentVariables:e})}function gL(e,t){const r={...Jn().environmentVariables||{},[e]:t};pp(r)}function fL(e){const t=Jn().environmentVariables||{},{[e]:n,...r}=t;pp(r)}function pT(e){if(!e.providerId||!e.modelId)return;const n=(Jn().modelRecents??[]).filter(i=>i.providerId!==e.providerId||i.modelId!==e.modelId),r=[e,...n].slice(0,H0);di({modelRecents:r})}async function p_(e,t,n){!e||!t||!n.providerId||!n.modelId||(await Bo(e),await up(e,r=>{const i={...r.agentModelSelections??{}},s=i[t];s&&s.providerId===n.providerId&&s.modelId===n.modelId||(i[t]=n,r.agentModelSelections=i)}))}async function hT(e,t){return!e||!t?void 0:(await Bo(e),(_p(e).agentModelSelections??{})[t])}gp().catch(e=>{Hi.error("Failed to initialize config",e)});const ET=Jt(),pL={isLoaded:dT,config:z0,preferences:Jn,recentFolders:q0,opencodeBinaries:K0,themePreference:uT,setThemePreference:J0,updateConfig:vs,toggleShowThinkingBlocks:iL,toggleShowTimelineTools:sL,toggleUsageMetrics:oL,toggleAutoCleanupBlankSessions:aL,setDiffViewMode:eL,setToolOutputExpansion:tL,setDiagnosticsExpansion:nL,setThinkingBlocksExpansion:rL,setListeningMode:fT,addRecentFolder:lL,removeRecentFolder:cL,addOpenCodeBinary:dL,removeOpenCodeBinary:uL,updateLastUsedBinary:_L,recordWorkspaceLaunch:mL,updatePreferences:di,updateEnvironmentVariables:pp,addEnvironmentVariable:gL,removeEnvironmentVariable:fL,addRecentModelPreference:pT,setAgentModelPreference:p_,getAgentModelPreference:hT},hL=e=>(Tn(()=>{gp().catch(n=>{Hi.error("Failed to initialize config",n)});const t=Io.onConfigChanged(n=>{mp(n).catch(r=>{Hi.error("Failed to refresh config",r)})});return()=>{t()}}),S(ET.Provider,{value:pL,get children(){return e.children}}));function ro(){const e=en(ET);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e}var EL=x('<p class="text-xs text-muted mt-1 font-mono break-all">Root: '),SL=x('<div class="px-4 pb-2"><div class="flex items-center justify-between gap-3 rounded-md border border-border-subtle px-4 py-3"><div><p class="text-xs text-secondary uppercase tracking-wide">Current folder</p><p class="text-sm font-mono text-primary break-all"></p></div><button type=button class="selector-button selector-button-secondary whitespace-nowrap">Select Current'),bL=x('<div class="flex items-center gap-2 px-4 py-2 text-xs text-secondary"><span>Loading <!>…'),vL=x('<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-6"><div class="modal-surface max-h-full w-full max-w-3xl overflow-hidden rounded-xl bg-surface p-0"role=dialog aria-modal=true><div class="panel flex flex-col"><div class="panel-header flex items-start justify-between gap-4"><div><h3 class=panel-title></h3><p class=panel-subtitle></p></div><button type=button class="selector-button selector-button-secondary">Close</button></div><div class=panel-body><label class="w-full text-sm text-secondary mb-2 block">Filter</label><div class=selector-input-group><div class="flex items-center gap-2 px-3 text-muted"></div><input type=text class=selector-input></div></div><div class="panel-list panel-list--fill max-h-96 overflow-auto"></div><div class=panel-footer><div class=panel-footer-hints><div class="flex items-center gap-1.5"><kbd class=kbd>↑</kbd><kbd class=kbd>↓</kbd><span>Navigate</span></div><div class="flex items-center gap-1.5"><kbd class=kbd>Enter</kbd><span>Select</span></div><div class="flex items-center gap-1.5"><kbd class=kbd>Esc</kbd><span>Close'),yL=x('<div class="flex items-center gap-2"><span>Loading <!>…'),TL=x('<div class="flex items-center justify-center py-6 text-sm text-secondary">'),CL=x("<span class=text-red-500>"),RL=x('<div class="flex flex-col items-center justify-center gap-2 py-10 text-sm text-secondary"><p>No entries found.</p><button type=button class="selector-button selector-button-secondary">Retry'),IL=x('<div class=panel-list-item role=button><div class="panel-list-item-content directory-browser-row"><button type=button class=directory-browser-row-main><div class=directory-browser-row-icon></div><div class=directory-browser-row-text><span class=directory-browser-row-name>Up one level'),OL=x('<div class=panel-list-item role=listitem><div class="panel-list-item-content directory-browser-row"><button type=button class=directory-browser-row-main><div class=directory-browser-row-icon></div><div class=directory-browser-row-text><span class=directory-browser-row-name></span><span class=directory-browser-row-sub></span></div></button><button type=button class="selector-button selector-button-secondary directory-browser-select">Select');const NL=vt("actions"),AL=200;function mm(e){if(!e||e==="."||e==="./")return".";let t=e.replace(/\\/g,"/");return t.startsWith("./")&&(t=t.replace(/^\.\/+/,"")),t.startsWith("/")&&(t=t.replace(/^\/+/,"")),t=t.replace(/\/+/g,"/"),t===""?".":t}function Ol(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;const n=e.includes("\\")?"\\":"/",r=e.endsWith(n)?e:`${e}${n}`,i=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${r}${i}`}const wL=e=>{const[t,n]=U(""),[r,i]=U([]),[s,o]=U(null),[a,l]=U(null),[c,d]=U(null),[u,_]=U(""),[m,g]=U(0);let p;const E=new Map,h=new Map,f=new Map;function b(){E.clear(),h.clear(),f.clear(),i([]),o(null),l(null)}async function y(L,R=!1){const D=mm(L);if(E.has(D)&&h.has(D))return R&&(o(h.get(D)??null),i(E.get(D)??[])),h.get(D);if(f.has(D)){const P=await f.get(D);return R&&(o(P),i(E.get(D)??[])),P}const w=(async()=>{l(D);const P=await vn.listFileSystem(D==="."?".":D,{includeFiles:e.mode==="files"});return E.set(D,P.entries),h.set(D,P.metadata),t()||n(P.metadata.rootPath),a()===D&&l(null),P.metadata})().catch(P=>{throw a()===D&&l(null),P});f.set(D,w);try{const P=await w;if(R){const j=mm(P.currentPath);o(P),i(E.get(j)??E.get(D)??[])}return P}finally{f.delete(D)}}async function v(){d(null),b();try{const L=await y(".",!0);n(L.rootPath),i(E.get(mm(L.currentPath))??[])}catch(L){const R=L instanceof Error?L.message:"Unable to load filesystem";d(R)}}function O(){const L=a();return L?L==="."?t()||"workspace root":Ol(t(),L):"filesystem"}function T(){const L=s();return L?L.pathKind==="relative"?Ol(t(),L.currentPath):L.displayPath:t()}function I(L){L.target===L.currentTarget&&e.onClose()}function k(L){const R=Ol(t(),L.path);e.onSelect(R)}function A(L){y(L,!0).catch(R=>{NL.error("Failed to open directory",R),d(R instanceof Error?R.message:"Unable to open directory")})}function V(){var R;const L=(R=s())==null?void 0:R.parentPath;L&&A(L)}const B=F(()=>{const L=u().trim().toLowerCase(),R=r().filter(D=>e.mode==="directories"?D.type==="directory":!0);return L?R.filter(D=>Ol(t(),D.path).toLowerCase().includes(L)||D.name.toLowerCase().includes(L)):R}),$=F(()=>B().slice(0,AL)),M=F(()=>{const L=[],R=s();R!=null&&R.parentPath&&L.push({type:"up",path:R.parentPath});for(const D of $())L.push({type:"entry",entry:D});return L});return J(()=>{const L=$();if(L.length===0){g(0);return}m()>=L.length&&g(L.length-1)}),J(()=>{if(!e.open)return;_(""),g(0),v(),setTimeout(()=>p==null?void 0:p.focus(),50);const L=R=>{if(!e.open)return;const D=$();if(R.key==="Escape"){R.preventDefault(),e.onClose();return}if(D.length!==0){if(R.key==="ArrowDown")R.preventDefault(),g(w=>Math.min(w+1,D.length-1));else if(R.key==="ArrowUp")R.preventDefault(),g(w=>Math.max(w-1,0));else if(R.key==="Enter"){R.preventDefault();const w=D[m()];w&&k(w)}}};window.addEventListener("keydown",L),Ne(()=>{window.removeEventListener("keydown",L),b(),n(""),d(null)})}),S(W,{get when(){return e.open},get children(){var L=vL(),R=L.firstChild,D=R.firstChild,w=D.firstChild,P=w.firstChild,j=P.firstChild,le=j.nextSibling,me=P.nextSibling,Ae=me.firstChild,ie=w.nextSibling,re=ie.firstChild,Ee=re.nextSibling,Se=Ee.firstChild,q=Se.nextSibling,ae=ie.nextSibling;return L.$$click=I,C(j,()=>e.title),C(le,()=>e.description||"Search for a path under the configured workspace root."),C(P,S(W,{get when(){return t()},get children(){var N=EL();return N.firstChild,C(N,t,null),N}}),null),Fn(me,"click",e.onClose,!0),C(me,S(cp,{class:"w-4 h-4"}),Ae),C(Se,S(u0,{class:"w-4 h-4"})),q.$$input=N=>_(N.currentTarget.value),wt(N=>{p=N},q),C(D,S(W,{get when(){return e.mode==="directories"},get children(){var N=SL(),H=N.firstChild,te=H.firstChild,Q=te.firstChild,z=Q.nextSibling,he=te.nextSibling;return C(z,T),he.$$click=()=>e.onSelect(T()),N}}),ae),C(ae,S(W,{get when(){return r().length>0},get fallback(){return(()=>{var N=TL();return C(N,S(W,{get when(){return a()!==null},get fallback(){return(()=>{var H=CL();return C(H,c),H})()},get children(){var H=yL(),te=H.firstChild,Q=te.firstChild,z=Q.nextSibling;return z.nextSibling,C(H,S(Ro,{class:"w-4 h-4 animate-spin"}),te),C(te,O,z),H}})),N})()},get children(){return[S(W,{get when(){return a()},get children(){var N=bL(),H=N.firstChild,te=H.firstChild,Q=te.nextSibling;return Q.nextSibling,C(N,S(Ro,{class:"w-3.5 h-3.5 animate-spin"}),H),C(H,O,Q),N}}),S(W,{get when(){return M().length>0},get fallback(){return(()=>{var N=RL(),H=N.firstChild,te=H.nextSibling;return te.$$click=v,N})()},get children(){return S(_t,{get each(){return M()},children:N=>{if(N.type==="up")return(()=>{var z=IL(),he=z.firstChild,ue=he.firstChild,ce=ue.firstChild;return ue.$$click=V,C(ce,S(Jy,{class:"w-4 h-4"})),z})();const H=N.entry,te=()=>k(H),Q=()=>{H.type==="directory"?A(H.path):te()};return(()=>{var z=OL(),he=z.firstChild,ue=he.firstChild,ce=ue.firstChild,se=ce.nextSibling,ke=se.firstChild,We=ke.nextSibling,Oe=ue.nextSibling;return ue.$$click=Q,C(ce,S(W,{get when(){return H.type==="directory"},get fallback(){return S(HD,{class:"w-4 h-4"})},get children(){return S(ap,{class:"w-4 h-4"})}})),C(ke,()=>H.name||H.path),C(We,()=>Ol(t(),H.path)),Oe.$$click=je=>{je.stopPropagation(),te()},z})()}})}})]}})),ne(()=>Fe(q,"placeholder",e.mode==="directories"?"Search for folders":"Search for files")),ne(()=>q.value=u()),L}})};Ht(["click","input"]);const xL=vt("actions");function DL(e){if(!e||e.canceled)return null;const t=Array.isArray(e.paths)?e.paths:e.path?[e.path]:[];return t.length===0?null:t[0]??null}async function LL(e){if(typeof window>"u")return null;const t=window.electronAPI;if(!(t!=null&&t.openDialog))return null;try{const n=await t.openDialog(e);return DL(n)}catch(n){return xL.error("[native] electron dialog failed",n),null}}const kL=vt("actions");async function ML(e){var r;if(typeof window>"u")return null;const t=window.__TAURI__,n=t==null?void 0:t.dialog;if(!(n!=null&&n.open))return null;try{const i=await n.open({title:e.title,defaultPath:e.defaultPath,directory:e.mode==="directory",multiple:!1,filters:(r=e.filters)==null?void 0:r.map(s=>({name:s.name,extensions:s.extensions}))});return i?Array.isArray(i)?i[0]??null:i:null}catch(i){return kL.error("[native] tauri dialog failed",i),null}}function ST(){switch($a.host){case"electron":return LL;case"tauri":return ML;default:return null}}function bT(){return ST()!==null}async function vT(e){const t=ST();return t?t(e):null}async function PL(e){return vT({mode:"directory",...e??{}})}async function $L(e){return vT({mode:"file",...e??{}})}var FL=x('<div class="selector-loading text-xs"><span>Checking versions…'),BL=x("<div class=selector-validation-error><div class=selector-validation-error-content><span class=selector-validation-error-text>"),UL=x('<div class=panel><div class="panel-header flex items-center justify-between gap-3"><div><h3 class=panel-title>OpenCode Binary</h3><p class=panel-subtitle>Choose which executable OpenCode should run</p></div></div><div class="panel-body space-y-3"><div class=selector-input-group><input type=text placeholder="Enter path to opencode binary…"class=selector-input><button type=button class="selector-button selector-button-primary">Add</button></div><button type=button class="selector-button selector-button-secondary w-full flex items-center justify-center gap-2">Browse for Binary…</button></div><div class="panel-list panel-list--fill max-h-80 overflow-y-auto">'),GL=x('<div class="text-xs font-mono truncate pl-6 text-muted">'),VL=x("<span class=selector-badge-version>v"),HL=x("<span class=selector-badge-time>Checking…"),YL=x("<span class=selector-badge-time>"),zL=x("<span class=selector-badge-time>Use binary from system PATH"),WL=x('<button type=button class="p-2 text-muted hover:text-primary"title="Remove binary">'),qL=x('<div class="panel-list-item flex items-center"><button type=button class="panel-list-item-content flex-1"><div class="flex flex-col flex-1 min-w-0 gap-1.5"><div class="flex items-center gap-2"><span class="text-sm font-medium truncate text-primary"></span></div><div class="flex items-center gap-2 text-xs text-muted pl-6 flex-wrap">');const KL=vt("actions"),QL=e=>{const{opencodeBinaries:t,addOpenCodeBinary:n,removeOpenCodeBinary:r,preferences:i,updatePreferences:s}=ro(),[o,a]=U(""),[l,c]=U(!1),[d,u]=U(null),[_,m]=U(new Map),[g,p]=U(new Set),[E,h]=U(!1),f=bT(),b=()=>t(),y=()=>i().lastUsedBinary,v=F(()=>b().filter(w=>w.path!=="opencode")),O=F(()=>[{path:"opencode",isDefault:!0},...v()]),T=()=>e.selectedBinary||"opencode";J(()=>{if(!e.selectedBinary&&y())e.onBinaryChange(y());else if(!e.selectedBinary){const w=b()[0];w&&e.onBinaryChange(w.path)}}),J(()=>{const w=new Map(_());let P=!1;b().forEach(j=>{j.version&&!w.has(j.path)&&(w.set(j.path,j.version),P=!0)}),P&&m(w)}),J(()=>{if(!e.isVisible)return;const w=_(),P=["opencode",...v().map(j=>j.path)].filter(j=>!w.has(j));P.length!==0&&setTimeout(()=>{P.forEach(j=>{I(j).catch(le=>KL.error("Failed to validate binary",{path:j,error:le}))})},0)}),Ne(()=>{p(new Set),c(!1)});async function I(w){if(_().has(w)){const P=_().get(w);return P?{valid:!0,version:P}:{valid:!0}}if(g().has(w))return{valid:!1,error:"Already validating"};try{p(j=>new Set(j).add(w)),c(!0),u(null);const P=await vn.validateBinary(w);if(P.valid&&P.version){const j=new Map(_());j.set(w,P.version),m(j)}return P}catch(P){return{valid:!1,error:P instanceof Error?P.message:String(P)}}finally{p(P=>{const j=new Set(P);return j.delete(w),j.size===0&&c(!1),j})}}async function k(){if(!e.disabled){if(u(null),f){const w=await $L({title:"Select OpenCode Binary"});w&&(a(w),A(w));return}h(!0)}}async function A(w){const P=await I(w);P.valid?(n(w,P.version),e.onBinaryChange(w),s({lastUsedBinary:w}),a(""),u(null)):u(P.error||"Invalid OpenCode binary")}function V(w){h(!1),a(w),A(w)}async function B(){const w=o().trim();w&&await A(w)}function $(w){e.disabled||w!==e.selectedBinary&&(e.onBinaryChange(w),s({lastUsedBinary:w}))}function M(w,P){P.stopPropagation(),!e.disabled&&(r(w),e.selectedBinary===w&&(e.onBinaryChange("opencode"),s({lastUsedBinary:"opencode"})))}function L(w){if(!w)return"";const P=Math.floor((Date.now()-w)/1e3),j=Math.floor(P/60),le=Math.floor(j/60),me=Math.floor(le/24);return me>0?`${me}d ago`:le>0?`${le}h ago`:j>0?`${j}m ago`:"just now"}function R(w){if(w==="opencode")return"opencode (system PATH)";const P=w.split(/[/\\]/);return P[P.length-1]??w}const D=w=>g().has(w);return[(()=>{var w=UL(),P=w.firstChild;P.firstChild;var j=P.nextSibling,le=j.firstChild,me=le.firstChild,Ae=me.nextSibling,ie=Ae.firstChild,re=le.nextSibling,Ee=re.firstChild,Se=j.nextSibling;return C(P,S(W,{get when(){return l()},get children(){var q=FL(),ae=q.firstChild;return C(q,S(Ro,{class:"selector-loading-spinner"}),ae),q}}),null),me.$$keydown=q=>{q.key==="Enter"&&(q.preventDefault(),B())},me.$$input=q=>a(q.currentTarget.value),Ae.$$click=B,C(Ae,S(lp,{class:"w-4 h-4"}),ie),re.$$click=()=>void k(),C(re,S(nT,{class:"w-4 h-4"}),Ee),C(j,S(W,{get when(){return d()},get children(){var q=BL(),ae=q.firstChild,N=ae.firstChild;return C(ae,S(yD,{class:"selector-validation-error-icon"}),N),C(N,d),q}}),null),C(Se,S(_t,{get each(){return O()},children:q=>{const ae=q.isDefault,N=()=>_().get(q.path)??q.version;return(()=>{var H=qL(),te=H.firstChild,Q=te.firstChild,z=Q.firstChild,he=z.firstChild,ue=z.nextSibling;return te.$$click=()=>$(q.path),C(z,S(wD,{get class(){return`w-4 h-4 transition-opacity ${T()===q.path?"opacity-100":"opacity-0"}`}}),he),C(he,()=>R(q.path)),C(Q,S(W,{when:!ae,get children(){var ce=GL();return C(ce,()=>q.path),ce}}),ue),C(ue,S(W,{get when(){return N()},get children(){var ce=VL();return ce.firstChild,C(ce,N,null),ce}}),null),C(ue,S(W,{get when(){return D(q.path)},get children(){return HL()}}),null),C(ue,S(W,{get when(){return!ae&&q.lastUsed},get children(){var ce=YL();return C(ce,()=>L(q.lastUsed)),ce}}),null),C(ue,S(W,{when:ae,get children(){return zL()}}),null),C(H,S(W,{when:!ae,get children(){var ce=WL();return ce.$$click=se=>M(q.path,se),C(ce,S(al,{class:"w-3.5 h-3.5"})),ne(()=>ce.disabled=e.disabled),ce}}),null),ne(ce=>{var se=T()===q.path,ke=e.disabled;return se!==ce.e&&H.classList.toggle("panel-list-item-highlight",ce.e=se),ke!==ce.t&&(te.disabled=ce.t=ke),ce},{e:void 0,t:void 0}),H})()}})),ne(q=>{var ae=e.disabled,N=e.disabled||!o().trim(),H=e.disabled;return ae!==q.e&&(me.disabled=q.e=ae),N!==q.t&&(Ae.disabled=q.t=N),H!==q.a&&(re.disabled=q.a=H),q},{e:void 0,t:void 0,a:void 0}),ne(()=>me.value=o()),w})(),S(wL,{get open(){return E()},mode:"files",title:"Select OpenCode Binary",description:"Browse files exposed by the CLI server.",onClose:()=>h(!1),onSelect:V})]};Ht(["input","keydown","click"]);var jL=x("<div class=space-y-2>"),XL=x('<div class="text-xs text-muted text-center py-2">No environment variables configured. Add variables above to customize the OpenCode environment.'),ZL=x('<div class=space-y-3><div class="flex items-center gap-2 mb-3"><span class="text-sm font-medium text-secondary">Environment Variables</span><span class="text-xs text-muted">(<!> variable<!>)</span></div><div class="flex items-center gap-2 pt-2 border-t border-base"><div class="flex-1 flex items-center gap-2"><input type=text class="flex-1 px-2.5 py-1.5 text-sm bg-surface-base border border-base rounded text-primary focus-ring-accent disabled:opacity-50 disabled:cursor-not-allowed"placeholder="Variable name"><input type=text class="flex-1 px-2.5 py-1.5 text-sm bg-surface-base border border-base rounded text-primary focus-ring-accent disabled:opacity-50 disabled:cursor-not-allowed"placeholder="Variable value"></div><button class="p-1.5 icon-muted icon-accent-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors"title="Add variable"></button></div><div class="text-xs text-muted mt-2">These variables will be available in the OpenCode environment when starting instances.'),JL=x('<div class="flex items-center gap-2"><div class="flex-1 flex items-center gap-2"><input type=text class="flex-1 px-2.5 py-1.5 text-sm bg-surface-secondary border border-base rounded text-muted cursor-not-allowed"placeholder="Variable name"title="Variable name (read-only)"><input type=text class="flex-1 px-2.5 py-1.5 text-sm bg-surface-base border border-base rounded text-primary focus-ring-accent disabled:opacity-50 disabled:cursor-not-allowed"placeholder="Variable value"></div><button class="p-1.5 icon-muted icon-danger-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors"title="Remove variable">');const ek=e=>{const{preferences:t,addEnvironmentVariable:n,removeEnvironmentVariable:r,updateEnvironmentVariables:i}=ro(),[s,o]=U(t().environmentVariables||{}),[a,l]=U(""),[c,d]=U(""),u=()=>Object.entries(s());function _(){const E=a().trim(),h=c().trim();E&&(n(E,h),o({...s(),[E]:h}),l(""),d(""))}function m(E){r(E);const{[E]:h,...f}=s();o(f)}function g(E,h){const f={...s(),[E]:h};o(f),i(f)}function p(E){E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),_())}return(()=>{var E=ZL(),h=E.firstChild,f=h.firstChild,b=f.nextSibling,y=b.firstChild,v=y.nextSibling,O=v.nextSibling,T=O.nextSibling;T.nextSibling;var I=h.nextSibling,k=I.firstChild,A=k.firstChild,V=A.nextSibling,B=k.nextSibling,$=I.nextSibling;return C(h,S(jD,{class:"w-4 h-4 icon-muted"}),f),C(b,()=>u().length,v),C(b,()=>u().length!==1?"s":"",T),C(E,S(W,{get when(){return u().length>0},get children(){var M=jL();return C(M,S(_t,{get each(){return u()},children:([L,R])=>(()=>{var D=JL(),w=D.firstChild,P=w.firstChild,j=P.nextSibling,le=w.nextSibling;return C(w,S(GE,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),P),P.value=L,j.$$input=me=>g(L,me.currentTarget.value),j.value=R,le.$$click=()=>m(L),C(le,S(al,{class:"w-3.5 h-3.5"})),ne(me=>{var Ae=e.disabled,ie=e.disabled,re=e.disabled;return Ae!==me.e&&(P.disabled=me.e=Ae),ie!==me.t&&(j.disabled=me.t=ie),re!==me.a&&(le.disabled=me.a=re),me},{e:void 0,t:void 0,a:void 0}),D})()})),M}}),I),C(k,S(GE,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),A),A.addEventListener("keypress",p),A.$$input=M=>l(M.currentTarget.value),V.addEventListener("keypress",p),V.$$input=M=>d(M.currentTarget.value),B.$$click=_,C(B,S(lp,{class:"w-3.5 h-3.5"})),C(E,S(W,{get when(){return u().length===0},get children(){return XL()}}),$),ne(M=>{var L=e.disabled,R=e.disabled,D=e.disabled||!a().trim();return L!==M.e&&(A.disabled=M.e=L),R!==M.t&&(V.disabled=M.t=R),D!==M.a&&(B.disabled=M.a=D),M},{e:void 0,t:void 0,a:void 0}),ne(()=>A.value=a()),ne(()=>V.value=c()),E})()};Ht(["input","click"]);var tk=x('<header class="px-6 py-4 border-b"style=border-color:var(--border-base)>'),nk=x('<div class="flex-1 overflow-y-auto p-6 space-y-6"><div class=panel><div class=panel-header><h3 class=panel-title>Environment Variables</h3><p class=panel-subtitle>Applied whenever a new OpenCode instance starts</p></div><div class=panel-body>'),rk=x('<div class="px-6 py-4 border-t flex justify-end"style=border-color:var(--border-base)><button type=button class="selector-button selector-button-secondary">Close'),ik=x('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">');const sk=e=>S(ft,{get open(){return e.open},onOpenChange:t=>!t&&e.onClose(),get children(){return S(ft.Portal,{get children(){return[S(ft.Overlay,{class:"modal-overlay"}),(()=>{var t=ik();return C(t,S(ft.Content,{class:"modal-surface w-full max-w-5xl max-h-[90vh] flex flex-col overflow-hidden",get children(){return[(()=>{var n=tk();return C(n,S(ft.Title,{class:"text-xl font-semibold text-primary",children:"Advanced Settings"})),n})(),(()=>{var n=nk(),r=n.firstChild,i=r.firstChild,s=i.nextSibling;return C(n,S(QL,{get selectedBinary(){return e.selectedBinary},get onBinaryChange(){return e.onBinaryChange},get disabled(){return!!e.isLoading},get isVisible(){return e.open}}),r),C(s,S(ek,{get disabled(){return!!e.isLoading}})),n})(),(()=>{var n=rk(),r=n.firstChild;return Fn(r,"click",e.onClose,!0),n})()]}})),t})()]}})}});Ht(["click"]);const XE="__drives__";var ok=x('<div class=directory-browser-current><div class=directory-browser-current-meta><span class=directory-browser-current-label>Current folder</span><span class=directory-browser-current-path></span></div><button type=button class="selector-button selector-button-secondary directory-browser-select directory-browser-current-select">Select Current'),ak=x('<div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto directory-browser-list"role=listbox>'),lk=x('<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-6"><div class="modal-surface directory-browser-modal"role=dialog aria-modal=true><div class="panel directory-browser-panel"><div class=directory-browser-header><div class=directory-browser-heading><h3 class=directory-browser-title></h3><p class=directory-browser-description></p></div><button type=button class=directory-browser-close aria-label=Close></button></div><div class="panel-body directory-browser-body">'),ck=x("<div class=directory-browser-loading><span>Loading folders…"),dk=x('<div class="panel-empty-state flex-1">'),uk=x("<span class=text-red-500>"),_k=x('<div class="panel-empty-state flex-1">No folders available.'),mk=x('<div class=panel-list-item role=option><div class="panel-list-item-content directory-browser-row"><button type=button class=directory-browser-row-main><div class=directory-browser-row-icon></div><div class=directory-browser-row-text><span class=directory-browser-row-name>'),gk=x('<button type=button class="selector-button selector-button-secondary directory-browser-select">Select');function Cd(e){if(!e||e==="."||e==="./")return".";if(e===XE)return XE;let t=e.replace(/\\/g,"/");if(/^[a-zA-Z]:/.test(t)){const[n,r=""]=t.split(":"),i=r.startsWith("/")?r:r?`/${r}`:"/";return`${n.toUpperCase()}:${i.replace(/\/+/g,"/")}`}return t.startsWith("//")?`//${t.slice(2).replace(/\/+/g,"/")}`:t.startsWith("/")?`/${t.slice(1).replace(/\/+/g,"/")}`:(t=t.replace(/^\.\/+/,"").replace(/\/+/g,"/"),t===""?".":t)}function yT(e){return e.startsWith("/")||/^[a-zA-Z]:/.test(e)||e.startsWith("\\\\")}function ZE(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;if(yT(t))return t;const n=e.includes("\\")?"\\":"/",r=e.endsWith(n)?e:`${e}${n}`,i=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${r}${i}`}const fk=e=>{const[t,n]=U(""),[r,i]=U(!1),[s,o]=U(null),[a,l]=U(new Map),[c,d]=U(new Set),[u,_]=U(null),[m,g]=U(null),p=new Map,E=new Map;function h(){l(new Map),d(new Set),_(null),g(null),p.clear(),E.clear(),o(null)}J(()=>{if(!e.open)return;h(),f();const M=L=>{L.key==="Escape"&&(L.preventDefault(),e.onClose())};window.addEventListener("keydown",M),Ne(()=>{window.removeEventListener("keydown",M)})});async function f(){i(!0);try{const M=await y();b(M)}catch(M){const L=M instanceof Error?M.message:"Unable to load filesystem";o(L)}finally{i(!1)}}function b(M){const L=Cd(M.currentPath);_(L),g(M),n(M.rootPath)}async function y(M){const L=M?Cd(M):void 0;if(L){const D=p.get(L);if(D)return D;const w=E.get(L);if(w)return w}const R=(async()=>{L&&d(j=>{const le=new Set(j);return le.add(L),le});const D=await vn.listFileSystem(M,{includeFiles:!1}),w=Cd(D.metadata.currentPath),P=D.entries.filter(j=>j.type==="directory").sort((j,le)=>j.name.localeCompare(le.name));return l(j=>{const le=new Map(j);return le.set(w,P),le}),p.set(w,D.metadata),d(j=>{const le=new Set(j);return L&&le.delete(L),le.delete(w),le}),D.metadata})().catch(D=>{throw L&&d(w=>{const P=new Set(w);return P.delete(L),P}),D}).finally(()=>{L&&E.delete(L)});return L&&E.set(L,R),R}async function v(M){o(null);try{const L=await y(M);b(L)}catch(L){const R=L instanceof Error?L.message:"Unable to load filesystem";o(R)}}const O=F(()=>{const M=[],L=m();L!=null&&L.parentPath&&M.push({type:"up",path:L.parentPath});const R=u();if(!R)return M;const D=a().get(R)??[];for(const w of D)M.push({type:"folder",entry:w});return M});function T(M){v(M)}function I(){var L;const M=(L=m())==null?void 0:L.parentPath;M&&v(M)}const k=F(()=>{const M=m();return!M||M.pathKind==="drives"?"":M.pathKind==="relative"?ZE(M.rootPath,M.currentPath):M.displayPath}),A=F(()=>!!k());function V(M){const L=M.absolutePath?M.absolutePath:yT(M.path)?M.path:ZE(t(),M.path);e.onSelect(L)}function B(M){return c().has(Cd(M))}function $(M){M.target===M.currentTarget&&e.onClose()}return S(W,{get when(){return e.open},get children(){var M=lk(),L=M.firstChild,R=L.firstChild,D=R.firstChild,w=D.firstChild,P=w.firstChild,j=P.nextSibling,le=w.nextSibling,me=D.nextSibling;return M.$$click=$,C(P,()=>e.title),C(j,()=>e.description||"Browse folders under the configured workspace root."),Fn(le,"click",e.onClose,!0),C(le,S(cp,{class:"w-5 h-5"})),C(me,S(W,{get when(){return t()},get children(){var Ae=ok(),ie=Ae.firstChild,re=ie.firstChild,Ee=re.nextSibling,Se=ie.nextSibling;return C(Ee,k),Se.$$click=()=>{const q=k();q&&e.onSelect(q)},ne(()=>Se.disabled=!A()),Ae}}),null),C(me,S(W,{get when(){return we(()=>!r())()&&!s()},get fallback(){return(()=>{var Ae=dk();return C(Ae,S(W,{get when(){return r()},get fallback(){return(()=>{var ie=uk();return C(ie,s),ie})()},get children(){var ie=ck(),re=ie.firstChild;return C(ie,S(Ro,{class:"w-5 h-5 animate-spin"}),re),ie}})),Ae})()},get children(){return S(W,{get when(){return O().length>0},get fallback(){return _k()},get children(){var Ae=ak();return C(Ae,S(_t,{get each(){return O()},children:ie=>{const re=ie.type==="folder",Ee=re?ie.entry.name||ie.entry.path:"Up one level",Se=()=>re?T(ie.entry.path):I();return(()=>{var q=mk(),ae=q.firstChild,N=ae.firstChild,H=N.firstChild,te=H.nextSibling,Q=te.firstChild;return N.$$click=Se,C(H,S(W,{when:!re,get fallback(){return S(ap,{class:"w-4 h-4"})},get children(){return S(Jy,{class:"w-4 h-4"})}})),C(Q,Ee),C(N,S(W,{get when(){return re&&B(ie.entry.path)},get children(){return S(Ro,{class:"directory-browser-row-spinner animate-spin"})}}),null),C(ae,re?(()=>{var z=gk();return z.$$click=he=>{he.stopPropagation(),V(ie.entry)},z})():null,null),q})()}})),Ae}})}}),null),M}})};Ht(["click"]);const vo=()=>navigator.platform.toLowerCase().includes("mac");var pk=x("<kbd>"),hk=x("<span>"),Ek=x("<span class=kbd-separator>+");const Sk={enter:"Enter",return:"Enter",esc:"Esc",escape:"Esc",tab:"Tab",space:"Space",backspace:"Backspace",delete:"Delete",pageup:"Page Up",pagedown:"Page Down",home:"Home",end:"End",arrowup:"↑",arrowdown:"↓",arrowleft:"←",arrowright:"→"},ir=e=>{const t=()=>{if(e.children)return[{text:e.children,isModifier:!1}];if(!e.shortcut)return[];const n=[];return e.shortcut.toLowerCase().split("+").forEach(s=>{const o=s.trim(),a=o.toLowerCase();if(a==="cmd"||a==="command")n.push({text:vo()?"Cmd":"Ctrl",isModifier:!1});else if(a==="shift")n.push({text:"Shift",isModifier:!1});else if(a==="alt"||a==="option")n.push({text:vo()?"Option":"Alt",isModifier:!1});else if(a==="ctrl"||a==="control")n.push({text:"Ctrl",isModifier:!1});else{const l=Sk[a];l?n.push({text:l,isModifier:!1}):o.length===1?n.push({text:o.toUpperCase(),isModifier:!1}):n.push({text:o.charAt(0).toUpperCase()+o.slice(1),isModifier:!1})}}),n};return(()=>{var n=pk();return C(n,S(_t,{get each(){return t()},children:(r,i)=>[we(()=>we(()=>i()>0)()&&Ek()),(()=>{var s=hk();return C(s,()=>r.text),s})()]})),ne(()=>rt(n,`kbd ${e.class||""}`)),n})()};var bk=x('<div class="absolute top-4 right-6"><button type=button class="selector-button selector-button-secondary inline-flex items-center justify-center">'),vk=x('<div class="panel flex flex-col flex-1 min-h-0"><div class=panel-header><h2 class=panel-title>Recent Folders</h2><p class=panel-subtitle> <!> available</p></div><div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto">'),yk=x('<div class="flex items-center gap-1.5"><kbd class=kbd>↑</kbd><kbd class=kbd>↓</kbd><span>Navigate'),Tk=x('<div class="flex items-center gap-1.5"><kbd class=kbd>Enter</kbd><span>Select'),Ck=x('<div class="flex items-center gap-1.5"><kbd class=kbd>Del</kbd><span>Remove'),Rk=x("<div class=folder-loading-overlay><div class=folder-loading-indicator><div class=spinner></div><p class=folder-loading-text>Starting instance…</p><p class=folder-loading-subtext>Hang tight while we prepare your workspace."),Ik=x('<div class="flex h-screen w-full items-start justify-center overflow-hidden py-6 px-4 sm:px-6 relative"style=background-color:var(--surface-secondary)><div class="w-full max-w-3xl h-full px-4 sm:px-8 pb-2 flex flex-col overflow-hidden"><div class="mb-6 text-center shrink-0"><div class="mb-3 flex justify-center"><img alt="CodeNomad logo"class="h-32 w-auto sm:h-48"loading=lazy></div><h1 class="mb-2 text-3xl font-semibold text-primary">CodeNomad</h1><p class="text-base text-secondary">Select a folder to start coding with AI</p></div><div class="space-y-4 flex-1 min-h-0 overflow-hidden flex flex-col"><div class="panel shrink-0"><div class="panel-header hidden sm:block"><h2 class=panel-title>Browse for Folder</h2><p class=panel-subtitle>Select any folder on your computer</p></div><div class=panel-body><button class="button-primary w-full flex items-center justify-center text-sm disabled:cursor-not-allowed"><div class="flex items-center gap-2"><span></span></div></button></div><div class="panel-section w-full"><button class="panel-section-header w-full justify-between"><div class="flex items-center gap-2"><span class="text-sm font-medium text-secondary">Advanced Settings</span></div></button></div></div></div><div class="mt-1 panel panel-footer shrink-0 hidden sm:block"><div class=panel-footer-hints><div class="flex items-center gap-1.5"><span>Browse',!0,!1,!1),Ok=x('<div class="panel panel-empty-state flex-1"><div class=panel-empty-state-icon></div><p class=panel-empty-state-title>No Recent Folders</p><p class=panel-empty-state-description>Browse for a folder to get started'),Nk=x("<kbd class=kbd>↵"),Ak=x('<div class=panel-list-item><div class="flex items-center gap-2 w-full px-1"><button class="panel-list-item-content flex-1"><div class="flex items-center justify-between gap-3 w-full"><div class="flex-1 min-w-0"><div class="flex items-center gap-2 mb-1"><span class="text-sm font-medium truncate text-primary"></span></div><div class="text-xs font-mono truncate pl-6 text-muted"></div><div class="text-xs mt-1 pl-6 text-muted"></div></div></div></button><button class="p-2 transition-all hover:bg-red-100 dark:hover:bg-red-900/30 opacity-70 hover:opacity-100 rounded"title="Remove from recent">');const wk=new URL("/assets/CodeNomad-Icon-bmTWNPXy.png",import.meta.url).href,JE=e=>{const{recentFolders:t,removeRecentFolder:n,preferences:r}=ro(),[i,s]=U(0),[o,a]=U("recent"),[l,c]=U(r().lastUsedBinary||"opencode"),[d,u]=U(!1),_=bT();let m;const g=()=>t(),p=()=>!!e.isLoading;J(()=>{const A=r().lastUsedBinary;A&&c(V=>V===A?V:A)});function E(A){const V=m;if(!V)return;const B=V.querySelector(`[data-folder-index="${A}"]`);if(!B)return;const $=V.getBoundingClientRect(),M=B.getBoundingClientRect();M.top<$.top?V.scrollTop-=$.top-M.top:M.bottom>$.bottom&&(V.scrollTop+=M.bottom-$.bottom)}function h(A){const V=A.key.toLowerCase(),B=(A.metaKey||A.ctrlKey)&&!A.shiftKey&&V==="n",$=["ArrowDown","ArrowUp","PageDown","PageUp","Home","End","Enter","Backspace","Delete"];if(p()){(B||$.includes(A.key))&&A.preventDefault();return}const M=g();if(B){A.preventDefault(),v();return}if(M.length!==0){if(A.key==="ArrowDown"){A.preventDefault();const L=Math.min(i()+1,M.length-1);s(L),a("recent"),E(L)}else if(A.key==="ArrowUp"){A.preventDefault();const L=Math.max(i()-1,0);s(L),a("recent"),E(L)}else if(A.key==="PageDown"){A.preventDefault();const R=Math.min(i()+5,M.length-1);s(R),a("recent"),E(R)}else if(A.key==="PageUp"){A.preventDefault();const R=Math.max(i()-5,0);s(R),a("recent"),E(R)}else if(A.key==="Home")A.preventDefault(),s(0),a("recent"),E(0);else if(A.key==="End"){A.preventDefault();const L=M.length-1;s(L),a("recent"),E(L)}else if(A.key==="Enter")A.preventDefault(),f();else if((A.key==="Backspace"||A.key==="Delete")&&(A.preventDefault(),M.length>0&&o()==="recent")){const L=M[i()];L&&I(L.path)}}}function f(){if(p())return;const A=g(),V=i(),B=A[V];B&&y(B.path)}Tn(()=>{window.addEventListener("keydown",h),Ne(()=>{window.removeEventListener("keydown",h)})});function b(A){const V=Math.floor((Date.now()-A)/1e3),B=Math.floor(V/60),$=Math.floor(B/60),M=Math.floor($/24);return M>0?`${M}d ago`:$>0?`${$}h ago`:B>0?`${B}m ago`:"just now"}function y(A){p()||e.onSelectFolder(A,l())}async function v(){var A;if(!p()){if(a("new"),_){const V=(A=g()[0])==null?void 0:A.path,B=await PL({title:"Select Workspace",defaultPath:V});B&&y(B);return}u(!0)}}function O(A){u(!1),y(A)}function T(A){c(A)}function I(A,V){if(p())return;V==null||V.stopPropagation(),n(A);const B=g();i()>=B.length&&B.length>0&&s(B.length-1)}function k(A){return A.startsWith("/Users/")?A.replace(/^\/Users\/[^/]+/,"~"):A}return[(()=>{var A=Ik(),V=A.firstChild,B=V.firstChild,$=B.firstChild,M=$.firstChild,L=B.nextSibling,R=L.firstChild,D=R.firstChild,w=D.nextSibling,P=w.firstChild,j=P.firstChild,le=j.firstChild,me=w.nextSibling,Ae=me.firstChild,ie=Ae.firstChild,re=ie.firstChild,Ee=L.nextSibling,Se=Ee.firstChild,q=Se.firstChild,ae=q.firstChild;return C(V,S(W,{get when(){return e.onOpenRemoteAccess},get children(){var N=bk(),H=N.firstChild;return H.$$click=()=>{var te;return(te=e.onOpenRemoteAccess)==null?void 0:te.call(e)},C(H,S(rT,{class:"w-4 h-4"})),N}}),B),Fe(M,"src",wk),C(L,S(W,{get when(){return g().length>0},get fallback(){return(()=>{var N=Ok(),H=N.firstChild;return C(H,S(MD,{class:"w-12 h-12 mx-auto"})),N})()},get children(){var N=vk(),H=N.firstChild,te=H.firstChild,Q=te.nextSibling,z=Q.firstChild,he=z.nextSibling;he.nextSibling;var ue=H.nextSibling;return C(Q,()=>g().length,z),C(Q,()=>g().length===1?"folder":"folders",he),wt(ce=>m=ce,ue),C(ue,S(_t,{get each(){return g()},children:(ce,se)=>(()=>{var ke=Ak(),We=ke.firstChild,Oe=We.firstChild,je=Oe.firstChild,dt=je.firstChild,Lt=dt.firstChild,be=Lt.firstChild,ee=Lt.nextSibling,Re=ee.nextSibling,He=Oe.nextSibling;return Oe.addEventListener("mouseenter",()=>{p()||(a("recent"),s(se()))}),Oe.$$click=()=>y(ce.path),C(Lt,S(ap,{class:"w-4 h-4 flex-shrink-0 icon-muted"}),be),C(be,()=>ce.path.split("/").pop()),C(ee,()=>k(ce.path)),C(Re,()=>b(ce.lastAccessed)),C(je,S(W,{get when(){return we(()=>o()==="recent")()&&i()===se()},get children(){return Nk()}}),null),He.$$click=qe=>I(ce.path,qe),C(He,S(al,{class:"w-3.5 h-3.5 transition-colors icon-muted hover:text-red-600 dark:hover:text-red-400"})),ne(qe=>{var de=o()==="recent"&&i()===se(),ge=!!p(),Ce=se(),Ke=p(),Pe=p();return de!==qe.e&&ke.classList.toggle("panel-list-item-highlight",qe.e=de),ge!==qe.t&&ke.classList.toggle("panel-list-item-disabled",qe.t=ge),Ce!==qe.a&&Fe(Oe,"data-folder-index",qe.a=Ce),Ke!==qe.o&&(Oe.disabled=qe.o=Ke),Pe!==qe.i&&(He.disabled=qe.i=Pe),qe},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),ke})()})),N}}),R),P.addEventListener("mouseenter",()=>a("new")),P.$$click=()=>void v(),C(j,S(qD,{class:"w-4 h-4"}),le),C(le,()=>e.isLoading?"Opening...":"Browse Folders"),C(P,S(ir,{shortcut:"cmd+n",class:"ml-2"}),null),Ae.$$click=()=>{var N;return(N=e.onAdvancedSettingsOpen)==null?void 0:N.call(e)},C(ie,S(m0,{class:"w-4 h-4 icon-muted"}),re),C(Ae,S(LD,{class:"w-4 h-4 icon-muted"}),null),C(Se,S(W,{get when(){return g().length>0},get children(){return[yk(),Tk(),Ck()]}}),q),C(q,S(ir,{shortcut:"cmd+n"}),ae),C(A,S(W,{get when(){return p()},get children(){return Rk()}}),null),ne(N=>{var H=p()?"true":"false",te=e.isLoading;return H!==N.e&&Fe(V,"aria-busy",N.e=H),te!==N.t&&(P.disabled=N.t=te),N},{e:void 0,t:void 0}),A})(),S(sk,{get open(){return!!e.advancedSettingsOpen},onClose:()=>{var A;return(A=e.onAdvancedSettingsClose)==null?void 0:A.call(e)},get selectedBinary(){return l()},onBinaryChange:T,get isLoading(){return e.isLoading}}),S(fk,{get open(){return d()},title:"Select Workspace",description:"Select workspace to start coding.",onClose:()=>u(!1),onSelect:O})]};Ht(["click"]);function hp(e){return!e||e.type==="idle"?"idle":"working"}function xk(e,t,n="",r={providerId:"",modelId:""},i="idle"){return{...e,instanceId:t,parentId:e.parentID||null,agent:n,model:r,status:i}}function Dk(e){return(e==null?void 0:e.id)??""}function jc(e){return(e==null?void 0:e.sessionID)??(e==null?void 0:e.sessionId)??void 0}function TT(e){const t=e==null?void 0:e.tool;return(t==null?void 0:t.messageID)??(t==null?void 0:t.messageId)??(e==null?void 0:e.messageID)??(e==null?void 0:e.messageId)??void 0}function CT(e){const t=e==null?void 0:e.tool,n=(e==null?void 0:e.metadata)||{};return(t==null?void 0:t.callID)??(t==null?void 0:t.callId)??(e==null?void 0:e.callID)??(e==null?void 0:e.callId)??(e==null?void 0:e.toolCallID)??(e==null?void 0:e.toolCallId)??n.callID??n.callId??void 0}function Og(e){var n;const t=(n=e==null?void 0:e.time)==null?void 0:n.created;return typeof t=="number"?t:Date.now()}function h_(e){return(e==null?void 0:e.permission)??(e==null?void 0:e.type)??"permission"}function Lk(e){const t=e==null?void 0:e.patterns;if(Array.isArray(t))return t.filter(r=>typeof r=="string");const n=e==null?void 0:e.pattern;return typeof n=="string"&&n.length>0?[n]:[]}function RT(e){const t=e==null?void 0:e.title;if(typeof t=="string"&&t.trim().length>0)return t;const n=h_(e),r=Lk(e);return r.length>0?`${n}: ${r.join(", ")}`:n}function kk(e){return(e==null?void 0:e.requestID)??(e==null?void 0:e.requestId)??(e==null?void 0:e.permissionID)??(e==null?void 0:e.permissionId)??void 0}function Mk(e){return(e==null?void 0:e.id)??""}function E_(e){return e==null?void 0:e.sessionID}function IT(e){var t;return(t=e==null?void 0:e.tool)==null?void 0:t.messageID}function OT(e){var t;return(t=e==null?void 0:e.tool)==null?void 0:t.callID}function Pk(e){return e==null?void 0:e.requestID}class eS extends Error{constructor(t,n){super(t),this.name="OpencodeApiError",n&&"cause"in n&&(this.cause=n.cause)}}async function An(e,t){const n=await e;if(!n)throw new eS(`${t} returned no result`);if(n.error)throw new eS(`${t} failed`,{cause:n.error});return n.data}const $k=({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:r,responseValidator:i,sseDefaultRetryDelay:s,sseMaxRetryAttempts:o,sseMaxRetryDelay:a,sseSleepFn:l,url:c,...d})=>{let u;const _=l??(p=>new Promise(E=>setTimeout(E,p)));return{stream:async function*(){let p=s??3e3,E=0;const h=d.signal??new AbortController().signal;for(;!h.aborted;){E++;const f=d.headers instanceof Headers?d.headers:new Headers(d.headers);u!==void 0&&f.set("Last-Event-ID",u);try{const b={redirect:"follow",...d,body:d.serializedBody,headers:f,signal:h};let y=new Request(c,b);e&&(y=await e(c,b));const O=await(d.fetch??globalThis.fetch)(y);if(!O.ok)throw new Error(`SSE failed: ${O.status} ${O.statusText}`);if(!O.body)throw new Error("No body in SSE response");const T=O.body.pipeThrough(new TextDecoderStream).getReader();let I="";const k=()=>{try{T.cancel()}catch{}};h.addEventListener("abort",k);try{for(;;){const{done:A,value:V}=await T.read();if(A)break;I+=V;const B=I.split(`
3
3
 
4
4
  `);I=B.pop()??"";for(const $ of B){const M=$.split(`
5
5
  `),L=[];let R;for(const P of M)if(P.startsWith("data:"))L.push(P.replace(/^data:\s*/,""));else if(P.startsWith("event:"))R=P.replace(/^event:\s*/,"");else if(P.startsWith("id:"))u=P.replace(/^id:\s*/,"");else if(P.startsWith("retry:")){const j=Number.parseInt(P.replace(/^retry:\s*/,""),10);Number.isNaN(j)||(p=j)}let D,w=!1;if(L.length){const P=L.join(`
@@ -105,11 +105,11 @@ https://github.com/highlightjs/highlight.js/issues/2277`),j=R,P=D),w===void 0&&(
105
105
  `);a+=`<span data-start="${l.startIndex}" data-end="${l.endIndex}" class="${(g=((m=c==null?void 0:c.properties)===null||m===void 0?void 0:m.className)||[])===null||g===void 0?void 0:g.join(" ")}" style="${((p=c==null?void 0:c.properties)===null||p===void 0?void 0:p.style)||""}">${s(f)}<span data-diff-highlight style="background-color: var(${n==="add"?oN:aN});border-top-left-radius: ${v?"0.2em":"0"};border-bottom-left-radius: ${v?"0.2em":"0"};border-top-right-radius: ${O||T?"0.2em":"0"};border-bottom-right-radius: ${O||T?"0.2em":"0"}">${T?`${s(b)}<span data-newline-symbol>${lN(i.newLineSymbol)}</span>`:s(b)}</span>${s(y)}</span>`}}),a+="</span>",e.syntaxTemplate=a,e.syntaxTemplateMode="relative"},cN=e=>{var t;let n="";const r=K_;return(t=e==null?void 0:e.nodeList)===null||t===void 0||t.forEach(({node:i,wrapper:s})=>{var o,a,l;n+=`<span data-start="${i.startIndex}" data-end="${i.endIndex}" class="${(a=((o=s==null?void 0:s.properties)===null||o===void 0?void 0:o.className)||[])===null||a===void 0?void 0:a.join(" ")}" style="${((l=s==null?void 0:s.properties)===null||l===void 0?void 0:l.style)||""}">${r(i.value)}</span>`}),n},dN=e=>e?K_(e):"",T4=40;function C4(e,t){throw new Error(t)}function R4(e){var t,n;if(e.length===0)return 0;for(let r=e.length-1;r>=0;r--){const i=e[r];for(let s=i.lines.length-1;s>=0;s--){const o=i.lines[s];if(o.type===En.Hunk)continue;const a=(t=o.newLineNumber)!==null&&t!==void 0?t:0,l=(n=o.oldLineNumber)!==null&&n!==void 0?n:0;return a>l?a:l}}return 0}function I4(e,t,n){const r=n===null?1/0:t.oldStartLine-n.header.oldStartLine-n.header.oldLineCount;return e===0?t.oldStartLine>1&&t.newStartLine>1?fa.Up:fa.None:r<=T4?fa.Short:fa.Both}const uN=(e,t)=>{const n=[];for(let r=0;r<e;r++)n.push(t(r));return n},lv=e=>{const t=e.lastIndexOf(".");return e.slice(t+1)},cv=(e,t,{getAdditionRaw:n,getDeletionRaw:r,getAdditionSyntax:i,getDeletionSyntax:s})=>{if(e.length===t.length){const o=e.length;for(let a=0;a<o;a++){const l=e[a],c=t[a];if(!l.changes||!c.changes){const d=Sr.prototype.clone.call(l,n(l.newLineNumber)||l.text||""),u=Sr.prototype.clone.call(c,r(c.oldLineNumber)||c.text||""),{addRange:_,delRange:m}=S4(d,u);l.changes=_,c.changes=m}(!l.plainTemplate||!c.plainTemplate)&&(Ku({diffLine:l,rawLine:n(l.newLineNumber),operator:"add"}),Ku({diffLine:c,rawLine:r(c.oldLineNumber),operator:"del"})),(!l.syntaxTemplate||!c.syntaxTemplate)&&(Qu({diffLine:l,syntaxLine:i(l.newLineNumber),operator:"add"}),Qu({diffLine:c,syntaxLine:s(c.oldLineNumber),operator:"del"}))}}},O4=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,N4=/[\u202A-\u202E]|[\u2066-\u2069]/,_N="+",mN="-",gN=" ",fN="\\",pN=`
106
106
  `,A4=new Set([_N,mN,gN,fN,pN]);class w4{constructor(){Object.defineProperty(this,"__v_skip",{value:!0}),this.reset()}reset(){this.ls=0,this.le=-1,this.text=""}nextLine(){return this.ls=this.le+1,this.ls>=this.text.length?!1:(this.le=this.text.indexOf(`
107
107
  `,this.ls),this.le===-1&&(this.le=this.text.length),this.ls!==this.le)}readLine(t){return t?this.nextLine()?this.text.substring(this.ls,this.le):null:this.nextLine()?this.text.substring(this.ls+1,this.le+1):this.text.length>this.ls?`
108
- `:null}lineStartsWith(t){return this.text.startsWith(t,this.ls)}lineEndsWith(t){return this.text.endsWith(t,this.le)}peek(){const t=this.le+1;return t<this.text.length?this.text[t]:null}parseDiffHeader(){for(;this.nextLine();){if(this.lineStartsWith("Binary files ")&&this.lineEndsWith("differ"))return{isBinary:!0};if(this.lineStartsWith("---"),this.lineStartsWith("+++"))return{isBinary:!1}}return null}numberFromGroup(t,n,r=null){const i=t[n];if(!i){if(!r)throw new Error(`Group ${n} missing from regexp match and no defaultValue was provided`);return r}const s=parseInt(i,10);if(isNaN(s))throw new Error(`Could not parse capture group ${n} into number: ${i}`);return s}parseHunkHeader(t){const n=O4.exec(t);if(!n)throw new Error("Invalid hunk header format");const r=this.numberFromGroup(n,1),i=this.numberFromGroup(n,2,1),s=this.numberFromGroup(n,3),o=this.numberFromGroup(n,4,1);return new p4(r,i,s,o)}parseLinePrefix(t){return t&&t.length&&A4.has(t[0])?t[0]:null}parseHunk(t,n,r){const i=this.readLine(!0);if(!i)throw new Error("Expected hunk header but reached end of diff");const s=this.parseHunkHeader(i),o=new Array;o.push(new Sr(i,En.Hunk,1,null,null));let a,l=s.oldStartLine,c=s.newStartLine,d=t;for(;a=this.parseLinePrefix(this.peek());){const u=this.readLine(!1);if(!u)throw new Error("Expected unified diff line but reached end of diff");if(a===fN){if(u.length<12)throw new Error('Expected "no newline at end of file" marker to be at least 12 bytes long');const m=o.length-1,g=o[m];o[m]=g.withNoTrailingNewLine(!0);continue}d++;let _;if(a===_N)_=new Sr(u,En.Add,d,null,c++);else if(a===mN)_=new Sr(u,En.Delete,d,l++,null);else if(a===gN||a===pN)_=new Sr(u,En.Context,d,l++,c++);else return C4(a,`Unknown DiffLinePrefix: ${a}`);o.push(_)}if(o.length===1)throw new Error("Malformed diff, empty hunk");return new f4(s,o,t,t+o.length-1,I4(n,s,r))}parse(t){this.text=t;try{const n=this.parseDiffHeader(),r=this.le,i=this.text.substring(0,r);if(!n)return{header:i,contents:"",hunks:[],isBinary:!1,maxLineNumber:0,hasHiddenBidiChars:!1};if(n.isBinary)return{header:i,contents:"",hunks:[],isBinary:!0,maxLineNumber:0,hasHiddenBidiChars:!1};const s=new Array;let o=0,a=null;do{const c=this.parseHunk(o,s.length,a);s.push(c),a=c,o+=c.lines.length}while(this.peek());const l=this.text.substring(r+1,this.le).replace(/\n\/g,"");return{header:i,contents:l,hunks:s,isBinary:n.isBinary,maxLineNumber:R4(s),hasHiddenBidiChars:N4.test(t)}}finally{this.reset()}}}const x4=new w4;function Y(e,t,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)}function Pe(e,t,n,r,i){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var lu,dc,pa,_f;class D4 extends Map{constructor(){super(...arguments),lu.add(this),dc.set(this,[]),pa.set(this,30)}get maxLength(){return Y(this,pa,"f")}setMaxLength(t){Pe(this,pa,t),Y(this,lu,"m",_f).call(this)}set(t,n){return Y(this,pa,"f")<=0?this:this.has(t)?this:(Y(this,dc,"f").push(t),Y(this,lu,"m",_f).call(this),super.set(t,n))}}dc=new WeakMap,pa=new WeakMap,lu=new WeakSet,_f=function(){for(;Y(this,dc,"f").length>Y(this,pa,"f");){const t=Y(this,dc,"f").shift();this.delete(t)}};var hN;const is=new D4;is.setMaxLength(50);is.name="@git-diff-view/core";class Bc{static createInstance(t){var n;const r=new Bc(t==null?void 0:t.raw,t==null?void 0:t.lang,t==null?void 0:t.fileName);return r.ast=t==null?void 0:t.ast,r.rawFile=(t==null?void 0:t.rawFile)||{},r.plainFile=(t==null?void 0:t.plainFile)||{},r.hasDoRaw=t==null?void 0:t.hasDoRaw,r.rawLength=t==null?void 0:t.rawLength,r.syntaxFile=(t==null?void 0:t.syntaxFile)||{},r.hasDoSyntax=t==null?void 0:t.hasDoSyntax,r.syntaxLength=t==null?void 0:t.syntaxLength,r.highlighterName=t==null?void 0:t.highlighterName,r.highlighterType=t==null?void 0:t.highlighterType,r.maxLineNumber=t==null?void 0:t.maxLineNumber,r.enableTemplate=(n=t==null?void 0:t.enableTemplate)!==null&&n!==void 0?n:!0,r}constructor(t,n,r){hN.add(this),this.raw=t,this.lang=n,this.fileName=r,this.rawFile={},this.hasDoRaw=!1,this.syntaxFile={},this.plainFile={},this.hasDoSyntax=!1,this.maxLineNumber=0,this.enableTemplate=!0,this.raw=y4(t),Object.defineProperty(this,"__v_skip",{value:!0})}doSyntax({registerHighlighter:t,theme:n}){if(!this.raw||this.hasDoSyntax)return;const r=t||au;if(this.syntaxLength||this.rawLength>r.maxLineToIgnoreSyntax)return;let i=r;try{r.hasRegisteredCurrentLang(this.lang)||(i=au)}catch{i=au}if(this.ast=i.getAST(this.raw,this.fileName,this.lang,n),!this.ast)return;const{syntaxFileObject:s,syntaxFileLineNumber:o}=i.processAST(this.ast);this.enableTemplate&&Object.values(s).forEach(a=>{a.template=cN(a)}),this.syntaxFile=s,this.syntaxLength=o,this.highlighterName=i.name,this.highlighterType=i.type,this.hasDoSyntax=!0}doRaw(){if(!this.raw||this.hasDoRaw)return;const n=this.raw.split(`
108
+ `:null}lineStartsWith(t){return this.text.startsWith(t,this.ls)}lineEndsWith(t){return this.text.endsWith(t,this.le)}peek(){const t=this.le+1;return t<this.text.length?this.text[t]:null}parseDiffHeader(){for(;this.nextLine();){if(this.lineStartsWith("Binary files ")&&this.lineEndsWith("differ"))return{isBinary:!0};if(this.lineStartsWith("---"),this.lineStartsWith("+++"))return{isBinary:!1}}return null}numberFromGroup(t,n,r=null){const i=t[n];if(!i){if(!r)throw new Error(`Group ${n} missing from regexp match and no defaultValue was provided`);return r}const s=parseInt(i,10);if(isNaN(s))throw new Error(`Could not parse capture group ${n} into number: ${i}`);return s}parseHunkHeader(t){const n=O4.exec(t);if(!n)throw new Error("Invalid hunk header format");const r=this.numberFromGroup(n,1),i=this.numberFromGroup(n,2,1),s=this.numberFromGroup(n,3),o=this.numberFromGroup(n,4,1);return new p4(r,i,s,o)}parseLinePrefix(t){return t&&t.length&&A4.has(t[0])?t[0]:null}parseHunk(t,n,r){const i=this.readLine(!0);if(!i)throw new Error("Expected hunk header but reached end of diff");const s=this.parseHunkHeader(i),o=new Array;o.push(new Sr(i,En.Hunk,1,null,null));let a,l=s.oldStartLine,c=s.newStartLine,d=t;for(;a=this.parseLinePrefix(this.peek());){const u=this.readLine(!1);if(!u)throw new Error("Expected unified diff line but reached end of diff");if(a===fN){if(u.length<12)throw new Error('Expected "no newline at end of file" marker to be at least 12 bytes long');const m=o.length-1,g=o[m];o[m]=g.withNoTrailingNewLine(!0);continue}d++;let _;if(a===_N)_=new Sr(u,En.Add,d,null,c++);else if(a===mN)_=new Sr(u,En.Delete,d,l++,null);else if(a===gN||a===pN)_=new Sr(u,En.Context,d,l++,c++);else return C4(a,`Unknown DiffLinePrefix: ${a}`);o.push(_)}if(o.length===1)throw new Error("Malformed diff, empty hunk");return new f4(s,o,t,t+o.length-1,I4(n,s,r))}parse(t){this.text=t;try{const n=this.parseDiffHeader(),r=this.le,i=this.text.substring(0,r);if(!n)return{header:i,contents:"",hunks:[],isBinary:!1,maxLineNumber:0,hasHiddenBidiChars:!1};if(n.isBinary)return{header:i,contents:"",hunks:[],isBinary:!0,maxLineNumber:0,hasHiddenBidiChars:!1};const s=new Array;let o=0,a=null;do{const c=this.parseHunk(o,s.length,a);s.push(c),a=c,o+=c.lines.length}while(this.peek());const l=this.text.substring(r+1,this.le).replace(/\n\/g,"");return{header:i,contents:l,hunks:s,isBinary:n.isBinary,maxLineNumber:R4(s),hasHiddenBidiChars:N4.test(t)}}finally{this.reset()}}}const x4=new w4;function Y(e,t,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)}function $e(e,t,n,r,i){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var lu,dc,pa,_f;class D4 extends Map{constructor(){super(...arguments),lu.add(this),dc.set(this,[]),pa.set(this,30)}get maxLength(){return Y(this,pa,"f")}setMaxLength(t){$e(this,pa,t),Y(this,lu,"m",_f).call(this)}set(t,n){return Y(this,pa,"f")<=0?this:this.has(t)?this:(Y(this,dc,"f").push(t),Y(this,lu,"m",_f).call(this),super.set(t,n))}}dc=new WeakMap,pa=new WeakMap,lu=new WeakSet,_f=function(){for(;Y(this,dc,"f").length>Y(this,pa,"f");){const t=Y(this,dc,"f").shift();this.delete(t)}};var hN;const is=new D4;is.setMaxLength(50);is.name="@git-diff-view/core";class Bc{static createInstance(t){var n;const r=new Bc(t==null?void 0:t.raw,t==null?void 0:t.lang,t==null?void 0:t.fileName);return r.ast=t==null?void 0:t.ast,r.rawFile=(t==null?void 0:t.rawFile)||{},r.plainFile=(t==null?void 0:t.plainFile)||{},r.hasDoRaw=t==null?void 0:t.hasDoRaw,r.rawLength=t==null?void 0:t.rawLength,r.syntaxFile=(t==null?void 0:t.syntaxFile)||{},r.hasDoSyntax=t==null?void 0:t.hasDoSyntax,r.syntaxLength=t==null?void 0:t.syntaxLength,r.highlighterName=t==null?void 0:t.highlighterName,r.highlighterType=t==null?void 0:t.highlighterType,r.maxLineNumber=t==null?void 0:t.maxLineNumber,r.enableTemplate=(n=t==null?void 0:t.enableTemplate)!==null&&n!==void 0?n:!0,r}constructor(t,n,r){hN.add(this),this.raw=t,this.lang=n,this.fileName=r,this.rawFile={},this.hasDoRaw=!1,this.syntaxFile={},this.plainFile={},this.hasDoSyntax=!1,this.maxLineNumber=0,this.enableTemplate=!0,this.raw=y4(t),Object.defineProperty(this,"__v_skip",{value:!0})}doSyntax({registerHighlighter:t,theme:n}){if(!this.raw||this.hasDoSyntax)return;const r=t||au;if(this.syntaxLength||this.rawLength>r.maxLineToIgnoreSyntax)return;let i=r;try{r.hasRegisteredCurrentLang(this.lang)||(i=au)}catch{i=au}if(this.ast=i.getAST(this.raw,this.fileName,this.lang,n),!this.ast)return;const{syntaxFileObject:s,syntaxFileLineNumber:o}=i.processAST(this.ast);this.enableTemplate&&Object.values(s).forEach(a=>{a.template=cN(a)}),this.syntaxFile=s,this.syntaxLength=o,this.highlighterName=i.name,this.highlighterType=i.type,this.hasDoSyntax=!0}doRaw(){if(!this.raw||this.hasDoRaw)return;const n=this.raw.split(`
109
109
  `);this.rawLength=n.length,this.maxLineNumber=n.length,this.rawFile={},this.plainFile={};for(let r=0;r<n.length;r++)this.rawFile[r+1]=r<n.length-1?n[r]+`
110
- `:n[r],this.enableTemplate&&(this.plainFile[r+1]={value:this.rawFile[r+1],template:dN(this.rawFile[r+1])});this.hasDoRaw=!0}}hN=new WeakSet;function Xo(e,t,n,r,i){let s=e+"--0.0.35--"+n+"--"+t;i&&(s=i+"--0.0.35--"+n+"--"+t);let o=e+"--0.0.35--"+(n==="light"?"dark":"light")+"--"+t;if(i&&(o=i+"--0.0.35--"+(n==="light"?"dark":"light")+"--"+t),is.has(s))return is.get(s);if(is.has(o)){const l=is.get(o);if(l.highlighterType==="class")return l}const a=new Bc(e,t,r);return is.set(s,a),a}const L4=is,k4=()=>is.setMaxLength(0);var Bt,un,_n,Ps,$s,Fs,Bs,fo,po,ha,Ea,xs,Ds,ns,rs,pr,kn,Bn,bn,Un,ws,aa,la,ca,da,Ql,Ei,uc,Vr,_c,ho,Eo,Kn,jl,uo,_o,Xl,ts,EN,SN,mf,bN,gf,dv,vN,Sa,ba,mc,gc,uv,_v;let hn=40;const zm=new Set;class ju{static createInstance(t,n){var r,i,s,o,a,l;const c=new ju(((r=t==null?void 0:t.oldFile)===null||r===void 0?void 0:r.fileName)||"",((i=t==null?void 0:t.oldFile)===null||i===void 0?void 0:i.content)||"",((s=t==null?void 0:t.newFile)===null||s===void 0?void 0:s.fileName)||"",((o=t==null?void 0:t.newFile)===null||o===void 0?void 0:o.content)||"",(t==null?void 0:t.hunks)||[],((a=t==null?void 0:t.oldFile)===null||a===void 0?void 0:a.fileLang)||"",((l=t==null?void 0:t.newFile)===null||l===void 0?void 0:l.fileLang)||"");return n&&(n.isFullMerge?c._mergeFullBundle(n):c.mergeBundle(n)),c}constructor(t,n,r,i,s,o,a,l){Bt.add(this),this.uuid=l,un.set(this,void 0),_n.set(this,void 0),Ps.set(this,void 0),$s.set(this,void 0),Fs.set(this,void 0),Bs.set(this,void 0),fo.set(this,void 0),po.set(this,void 0),ha.set(this,void 0),Ea.set(this,void 0),xs.set(this,void 0),Ds.set(this,void 0),ns.set(this,void 0),rs.set(this,void 0),pr.set(this,[]),kn.set(this,[]),Bn.set(this,void 0),bn.set(this,[]),Un.set(this,void 0),ws.set(this,[]),aa.set(this,!1),la.set(this,!1),ca.set(this,!1),da.set(this,!1),Ql.set(this,0),Ei.set(this,!1),uc.set(this,!1),Vr.set(this,!0),_c.set(this,!1),ho.set(this,void 0),Eo.set(this,void 0),Kn.set(this,"light"),jl.set(this,void 0),uo.set(this,{state:!1}),_o.set(this,{state:!1}),this._version_="0.0.35",this._oldFileName="",this._oldFileContent="",this._oldFileLang="",this._newFileName="",this._newFileContent="",this._newFileLang="",this._diffList=[],this.diffLineLength=0,this.splitLineLength=0,this.unifiedLineLength=0,this.fileLineLength=0,this.additionLength=0,this.deletionLength=0,this.hasSomeLineCollapsed=!1,Xl.set(this,""),ts.set(this,new Map),this.getSplitLeftLine=d=>Y(this,pr,"f")[d],this.getSplitLineByLineNumber=(d,u)=>{var _,m;return u===Me.old?(_=Y(this,pr,"f"))===null||_===void 0?void 0:_.find(g=>g.lineNumber===d):(m=Y(this,kn,"f"))===null||m===void 0?void 0:m.find(g=>g.lineNumber===d)},this.getSplitLineIndexByLineNumber=(d,u)=>{var _,m;return u===Me.old?(_=Y(this,pr,"f"))===null||_===void 0?void 0:_.findIndex(g=>g.lineNumber===d):(m=Y(this,kn,"f"))===null||m===void 0?void 0:m.findIndex(g=>g.lineNumber===d)},this.getSplitRightLine=d=>Y(this,kn,"f")[d],this.getSplitHunkLine=d=>{var u;return(u=Y(this,Bn,"f"))===null||u===void 0?void 0:u[d]},this.onSplitHunkExpand=(d,u,_=!0)=>{var m,g;const p=(m=Y(this,Bn,"f"))===null||m===void 0?void 0:m[u];if(!(!p||!p.splitInfo)&&!Y(this,Ei,"f")){if(d==="all"){for(let E=p.splitInfo.startHiddenIndex;E<p.splitInfo.endHiddenIndex;E++){const h=Y(this,pr,"f")[E],f=Y(this,kn,"f")[E];h!=null&&h.isHidden&&(h.isHidden=!1),f!=null&&f.isHidden&&(f.isHidden=!1)}p.splitInfo=Object.assign(Object.assign(Object.assign({},p.splitInfo),p.hunkInfo),{plainText:p.text,startHiddenIndex:p.splitInfo.endHiddenIndex})}else if(d==="down"){for(let E=p.splitInfo.startHiddenIndex;E<p.splitInfo.startHiddenIndex+hn;E++){const h=Y(this,pr,"f")[E],f=Y(this,kn,"f")[E];h!=null&&h.isHidden&&(h.isHidden=!1),f!=null&&f.isHidden&&(f.isHidden=!1)}p.isLast?p.splitInfo=Object.assign(Object.assign({},p.splitInfo),{startHiddenIndex:p.splitInfo.startHiddenIndex+hn}):p.splitInfo=Object.assign(Object.assign({},p.splitInfo),{startHiddenIndex:p.splitInfo.startHiddenIndex+hn,plainText:`@@ -${p.splitInfo.oldStartIndex},${p.splitInfo.oldLength} +${p.splitInfo.newStartIndex},${p.splitInfo.newLength}`})}else{if(p.isLast)return;for(let y=p.splitInfo.endHiddenIndex-hn;y<p.splitInfo.endHiddenIndex;y++){const v=Y(this,pr,"f")[y],O=Y(this,kn,"f")[y];v!=null&&v.isHidden&&(v.isHidden=!1),O!=null&&O.isHidden&&(O.isHidden=!1)}const E=p.splitInfo.oldStartIndex-hn,h=p.splitInfo.oldLength+hn,f=p.splitInfo.newStartIndex-hn,b=p.splitInfo.newLength+hn;p.splitInfo=Object.assign(Object.assign({},p.splitInfo),{endHiddenIndex:p.splitInfo.endHiddenIndex-hn,oldStartIndex:E,oldLength:h,newStartIndex:f,newLength:b,plainText:`@@ -${E},${h} +${f},${b}`}),(g=Y(this,Bn,"f"))===null||g===void 0||delete g[u],Y(this,Bn,"f")[p.splitInfo.endHiddenIndex]=p}_&&this.notifyAll()}},this.getUnifiedLine=d=>Y(this,bn,"f")[d],this.getUnifiedLineByLineNumber=(d,u)=>{var _,m;return u===Me.old?(_=Y(this,bn,"f"))===null||_===void 0?void 0:_.find(g=>g.oldLineNumber===d):(m=Y(this,bn,"f"))===null||m===void 0?void 0:m.find(g=>g.newLineNumber===d)},this.getUnifiedLineIndexByLineNumber=(d,u)=>{var _,m;return u===Me.old?(_=Y(this,bn,"f"))===null||_===void 0?void 0:_.findIndex(g=>g.oldLineNumber===d):(m=Y(this,bn,"f"))===null||m===void 0?void 0:m.findIndex(g=>g.newLineNumber===d)},this.getUnifiedHunkLine=d=>{var u;return(u=Y(this,Un,"f"))===null||u===void 0?void 0:u[d]},this.onUnifiedHunkExpand=(d,u,_=!0)=>{var m,g,p;if(Y(this,Ei,"f"))return;const E=(m=Y(this,Un,"f"))===null||m===void 0?void 0:m[u];if(!(!E||!E.unifiedInfo)){if(d==="all"){for(let h=E.unifiedInfo.startHiddenIndex;h<E.unifiedInfo.endHiddenIndex;h++){const f=(g=Y(this,bn,"f"))===null||g===void 0?void 0:g[h];f!=null&&f.isHidden&&(f.isHidden=!1)}E.unifiedInfo=Object.assign(Object.assign(Object.assign({},E.unifiedInfo),E.hunkInfo),{plainText:E.text,startHiddenIndex:E.unifiedInfo.endHiddenIndex})}else if(d==="down"){for(let h=E.unifiedInfo.startHiddenIndex;h<E.unifiedInfo.startHiddenIndex+hn;h++){const f=Y(this,bn,"f")[h];f!=null&&f.isHidden&&(f.isHidden=!1)}E.isLast?E.unifiedInfo=Object.assign(Object.assign({},E.unifiedInfo),{startHiddenIndex:E.unifiedInfo.startHiddenIndex+hn}):E.unifiedInfo=Object.assign(Object.assign({},E.unifiedInfo),{startHiddenIndex:E.unifiedInfo.startHiddenIndex+hn,plainText:`@@ -${E.unifiedInfo.oldStartIndex},${E.unifiedInfo.oldLength} +${E.unifiedInfo.newStartIndex},${E.unifiedInfo.newLength}`})}else{if(E.isLast)return;for(let v=E.unifiedInfo.endHiddenIndex-hn;v<E.unifiedInfo.endHiddenIndex;v++){const O=Y(this,bn,"f")[v];O!=null&&O.isHidden&&(O.isHidden=!1)}const h=E.unifiedInfo.oldStartIndex-hn,f=E.unifiedInfo.oldLength+hn,b=E.unifiedInfo.newStartIndex-hn,y=E.unifiedInfo.newLength+hn;E.unifiedInfo=Object.assign(Object.assign({},E.unifiedInfo),{endHiddenIndex:E.unifiedInfo.endHiddenIndex-hn,oldStartIndex:h,oldLength:f,newStartIndex:b,newLength:y,plainText:`@@ -${h},${f} +${b},${y}`}),(p=Y(this,Un,"f"))===null||p===void 0||delete p[u],Y(this,Un,"f")[E.unifiedInfo.endHiddenIndex]=E}_&&this.notifyAll()}},this.onAllExpand=d=>{Y(this,Ei,"f")||(d==="split"?(Object.keys(Y(this,Bn,"f")||{}).forEach(u=>{this.onSplitHunkExpand("all",+u,!1)}),Y(this,uo,"f").state=!0):(Object.keys(Y(this,Un,"f")||{}).forEach(u=>{this.onUnifiedHunkExpand("all",+u,!1)}),Y(this,_o,"f").state=!0),this.notifyAll())},this.onAllCollapse=d=>{Y(this,Ei,"f")||(d==="split"?(Object.values(Y(this,pr,"f")||{}).forEach(u=>{!u.isHidden&&u._isHidden&&(u.isHidden=u._isHidden)}),Object.values(Y(this,kn,"f")||{}).forEach(u=>{!u.isHidden&&u._isHidden&&(u.isHidden=u._isHidden)}),Object.values(Y(this,Bn,"f")||{}).forEach(u=>{u.splitInfo&&(u.splitInfo=Object.assign(Object.assign({},u.splitInfo),{oldStartIndex:u.splitInfo._oldStartIndex,oldLength:u.splitInfo._oldLength,newStartIndex:u.splitInfo._newStartIndex,newLength:u.splitInfo._newLength,startHiddenIndex:u.splitInfo._startHiddenIndex,endHiddenIndex:u.splitInfo._endHiddenIndex,plainText:u.splitInfo._plainText}))}),Object.keys(Y(this,Bn,"f")||{}).forEach(u=>{const _=Y(this,Bn,"f")[u];_.splitInfo&&_.splitInfo.endHiddenIndex!==+u&&(delete Y(this,Bn,"f")[u],Y(this,Bn,"f")[_.splitInfo.endHiddenIndex]=_)}),Y(this,uo,"f").state=!1):(Object.values(Y(this,bn,"f")||{}).forEach(u=>{!u.isHidden&&u._isHidden&&(u.isHidden=u._isHidden)}),Object.values(Y(this,Un,"f")||{}).forEach(u=>{u.unifiedInfo&&(u.unifiedInfo=Object.assign(Object.assign({},u.unifiedInfo),{oldStartIndex:u.unifiedInfo._oldStartIndex,oldLength:u.unifiedInfo._oldLength,newStartIndex:u.unifiedInfo._newStartIndex,newLength:u.unifiedInfo._newLength,startHiddenIndex:u.unifiedInfo._startHiddenIndex,endHiddenIndex:u.unifiedInfo._endHiddenIndex,plainText:u.unifiedInfo._plainText}))}),Object.keys(Y(this,Un,"f")||{}).forEach(u=>{const _=Y(this,Un,"f")[u];_.unifiedInfo&&_.unifiedInfo.endHiddenIndex!==+u&&(delete Y(this,Un,"f")[u],Y(this,Un,"f")[_.unifiedInfo.endHiddenIndex]=_)}),Y(this,_o,"f").state=!1),this.notifyAll())},this.getOldFileContent=()=>{var d;return(d=Y(this,un,"f"))===null||d===void 0?void 0:d.raw},this.getNewFileContent=()=>{var d;return(d=Y(this,_n,"f"))===null||d===void 0?void 0:d.raw},this.getOldPlainLine=d=>{var u;return(u=Y(this,ha,"f"))===null||u===void 0?void 0:u[d]},this.getOldSyntaxLine=d=>{var u;return(u=Y(this,xs,"f"))===null||u===void 0?void 0:u[d]},this.getNewPlainLine=d=>{var u;return(u=Y(this,Ea,"f"))===null||u===void 0?void 0:u[d]},this.getNewSyntaxLine=d=>{var u;return(u=Y(this,Ds,"f"))===null||u===void 0?void 0:u[d]},this.subscribe=d=>(Y(this,ws,"f").push(d),()=>{Pe(this,ws,Y(this,ws,"f").filter(u=>u!==d))}),this.notifyAll=d=>{var u;Pe(this,Ql,(u=Y(this,Ql,"f"),u++,u)),Y(this,ws,"f").forEach(_=>{d&&_.isSyncExternal||_()}),Y(this,ts,"f").forEach((_,m)=>{m.notifyAll(!0)})},this.getUpdateCount=()=>Y(this,Ql,"f"),this.getExpandEnabled=()=>!Y(this,Ei,"f"),this.getBundle=()=>{const d=Y(this,aa,"f"),u=Y(this,la,"f"),_=Y(this,ca,"f"),m=Y(this,da,"f"),g=Y(this,fo,"f"),p=Y(this,Fs,"f"),E=Y(this,ha,"f"),h=Y(this,xs,"f"),f=Y(this,ns,"f"),b=Y(this,po,"f"),y=Y(this,Bs,"f"),v=Y(this,Ea,"f"),O=Y(this,Ds,"f"),T=Y(this,rs,"f"),I=this.splitLineLength,k=this.unifiedLineLength,A=this.fileLineLength,V=this.additionLength,B=this.deletionLength,$=Y(this,Ei,"f"),M=Y(this,ho,"f"),L=Y(this,Eo,"f"),R=this.hasSomeLineCollapsed,D=Y(this,uo,"f"),w=Y(this,_o,"f"),P=Y(this,pr,"f"),j=Y(this,kn,"f"),le=Y(this,Bn,"f"),me=Y(this,bn,"f"),Ae=Y(this,Un,"f"),ie=this._version_,re=Y(this,Kn,"f"),Ee=Y(this,Vr,"f");return{hasInitRaw:d,hasInitSyntax:u,hasBuildSplit:_,hasBuildUnified:m,oldFileLines:g,oldFileDiffLines:p,oldFilePlainLines:E,oldFileSyntaxLines:h,oldFilePlaceholderLines:f,newFileLines:b,newFileDiffLines:y,newFilePlainLines:v,newFileSyntaxLines:O,newFilePlaceholderLines:T,splitLineLength:I,unifiedLineLength:k,fileLineLength:A,additionLength:V,deletionLength:B,splitLeftLines:P,splitRightLines:j,splitHunkLines:le,unifiedLines:me,unifiedHunkLines:Ae,highlighterName:M,highlighterType:L,composeByDiff:$,hasSomeLineCollapsed:R,hasExpandSplitAll:D,hasExpandUnifiedAll:w,version:ie,theme:re,enableTemplate:Ee,isFullMerge:!1}},this.mergeBundle=(d,u=!0)=>{Pe(this,aa,d.hasInitRaw),Pe(this,la,d.hasInitSyntax),Pe(this,ca,d.hasBuildSplit),Pe(this,da,d.hasBuildUnified),Pe(this,Ei,d.composeByDiff),Pe(this,ho,d.highlighterName),Pe(this,Eo,d.highlighterType),Pe(this,fo,d.oldFileLines),Pe(this,Fs,d.oldFileDiffLines),Pe(this,ha,d.oldFilePlainLines),Pe(this,xs,d.oldFileSyntaxLines),Pe(this,ns,d.oldFilePlaceholderLines),Pe(this,po,d.newFileLines),Pe(this,Bs,d.newFileDiffLines),Pe(this,Ea,d.newFilePlainLines),Pe(this,Ds,d.newFileSyntaxLines),Pe(this,rs,d.newFilePlaceholderLines),this.splitLineLength=d.splitLineLength,this.unifiedLineLength=d.unifiedLineLength,this.fileLineLength=d.fileLineLength,this.additionLength=d.additionLength,this.deletionLength=d.deletionLength,this.hasSomeLineCollapsed=d.hasSomeLineCollapsed,Pe(this,uo,d.hasExpandSplitAll),Pe(this,_o,d.hasExpandUnifiedAll),Pe(this,pr,d.splitLeftLines),Pe(this,kn,d.splitRightLines),Pe(this,Bn,d.splitHunkLines),Pe(this,bn,d.unifiedLines),Pe(this,Un,d.unifiedHunkLines),Pe(this,Kn,d.theme),Pe(this,Vr,d.enableTemplate),Pe(this,uc,!0),u&&this.notifyAll()},this._getHighlighterName=()=>Y(this,ho,"f")||"",this._getIsPureDiffRender=()=>Y(this,Ei,"f"),this._getTheme=()=>Y(this,Kn,"f"),this._addClonedInstance=d=>{const u=()=>{this._notifyOthers(d),this._mergeFullBundle(d._getFullBundle(),!1)};u.isSyncExternal=!0;const _=d.subscribe(u);Y(this,ts,"f").set(d,_)},this._notifyOthers=d=>{Y(this,ts,"f").forEach((u,_)=>{_!==d&&_.notifyAll(!0)})},this._delClonedInstance=d=>{const u=Y(this,ts,"f").get(d);u==null||u(),Y(this,ts,"f").delete(d)},this._getFullBundle=()=>{const d=this.getBundle(),u=Y(this,un,"f"),_=Y(this,_n,"f"),m=Y(this,$s,"f"),g=Y(this,Ps,"f");return Object.assign(Object.assign({},d),{oldFileResult:u,newFileResult:_,diffLines:m,diffListResults:g,isFullMerge:Y(this,uc,"f")?Y(this,_c,"f"):!0})},this._mergeFullBundle=(d,u=!0)=>{this.mergeBundle(d,u);try{Pe(this,un,d.oldFileResult?Bc.createInstance(d.oldFileResult):null,"f"),Pe(this,_n,d.newFileResult?Bc.createInstance(d.newFileResult):null,"f"),Pe(this,$s,d.diffLines,"f"),Pe(this,Ps,d.diffListResults,"f"),Pe(this,_c,d.isFullMerge,"f")}catch{}},this._destroy=()=>{this.clearId(),Y(this,ws,"f").splice(0,Y(this,ws,"f").length),Y(this,ts,"f").forEach(d=>d()),Y(this,ts,"f").clear()},this.clear=()=>{this._destroy(),Pe(this,un,null),Pe(this,_n,null),Pe(this,$s,null),Pe(this,Ps,null),Pe(this,Bs,null),Pe(this,Fs,null),Pe(this,po,null),Pe(this,fo,null),Pe(this,Ds,null),Pe(this,xs,null),Pe(this,Bn,null),Pe(this,pr,null),Pe(this,kn,null),Pe(this,Un,null),Pe(this,bn,null),Pe(this,Kn,void 0)},Object.defineProperty(this,"__v_skip",{value:!0});const c=Array.from(new Set(s));this._oldFileName=t,this._newFileName=r,this._diffList=c,this._oldFileLang=lv(o||t||a||r)||"txt",this._newFileLang=lv(a||r||o||t)||"txt",this._oldFileContent=n,this._newFileContent=i,this.initId()}initId(){let t="--"+Math.random().toString().slice(2);for(;zm.has(t);)t="--"+Math.random().toString().slice(2);zm.add(t),Pe(this,Xl,t)}getId(){return Y(this,Xl,"f")}clearId(){zm.delete(Y(this,Xl,"f"))}initTheme(t){Pe(this,jl,Y(this,Kn,"f")),Pe(this,Kn,t||Y(this,Kn,"f")||"light")}initRaw(){Y(this,aa,"f")||(Y(this,Bt,"m",SN).call(this),Y(this,Bt,"m",mf).call(this),Y(this,Bt,"m",EN).call(this),Y(this,Bt,"m",gf).call(this),Y(this,Bt,"m",bN).call(this),Pe(this,aa,!0))}initSyntax({registerHighlighter:t}={}){Y(this,la,"f")&&(!Y(this,jl,"f")||Y(this,Kn,"f")===Y(this,jl,"f"))||(Y(this,Bt,"m",vN).call(this,{registerHighlighter:t}),Y(this,Bt,"m",gf).call(this),Pe(this,la,!0))}init(){this.initRaw(),this.initSyntax()}enableTemplate(){Pe(this,Vr,!0)}disableTemplate(){Pe(this,Vr,!1)}getIsEnableTemplate(){return Y(this,Vr,"f")}buildSplitDiffLines(){var t,n,r,i,s,o;if(Y(this,ca,"f"))return;let a=1,l=1,c=!0,d=1/0;const u=((t=Y(this,un,"f"))===null||t===void 0?void 0:t.maxLineNumber)||0,_=((n=Y(this,_n,"f"))===null||n===void 0?void 0:n.maxLineNumber)||0;for(;a<=u||l<=_;){const m=Y(this,Bt,"m",Sa).call(this,a),g=Y(this,Bt,"m",ba).call(this,l),p=Y(this,Bt,"m",mc).call(this,a),E=Y(this,Bt,"m",gc).call(this,l),h=Sr.prototype.isIncludeableLine.call(m||{}),f=Sr.prototype.isIncludeableLine.call(g||{}),b=Y(this,kn,"f").length,y=!m&&!g;if(m&&!g){if(m.newLineNumber&&m.newLineNumber>l){l++;continue}(m.newLineNumber===null||m.newLineNumber===void 0)&&l++}if(g&&!m){if(g.oldLineNumber&&g.oldLineNumber>a){a++;continue}(g.oldLineNumber===null||g.oldLineNumber===void 0)&&a++}if(!m&&!p&&!g&&!E)break;if(!m&&!g){if(!((r=Y(this,ns,"f"))===null||r===void 0)&&r[a]&&(!((i=Y(this,rs,"f"))===null||i===void 0)&&i[l])){a++,l++;continue}if(!p&&(!((s=Y(this,rs,"f"))===null||s===void 0)&&s[l])){l++;continue}if(!E&&(!((o=Y(this,ns,"f"))===null||o===void 0)&&o[a])){a++;continue}}if(h&&f||!h&&!f?(Y(this,pr,"f").push({lineNumber:a++,value:p,diff:m,isHidden:y,_isHidden:y}),Y(this,kn,"f").push({lineNumber:l++,value:E,diff:g,isHidden:y,_isHidden:y})):h?(Y(this,pr,"f").push({lineNumber:a++,value:p,diff:m,isHidden:y,_isHidden:y}),Y(this,kn,"f").push({})):f&&(Y(this,pr,"f").push({}),Y(this,kn,"f").push({lineNumber:l++,value:E,diff:g,isHidden:y,_isHidden:y})),!c&&y&&(d=b),y&&(this.hasSomeLineCollapsed=!0),c=y,m!=null&&m.prevHunkLine||g!=null&&g.prevHunkLine){const v=(m==null?void 0:m.prevHunkLine)||g.prevHunkLine;v.isFirst?(v.splitInfo=Object.assign(Object.assign({},v.hunkInfo),{startHiddenIndex:0,endHiddenIndex:v.hunkInfo.newStartIndex-1,plainText:v.text,_startHiddenIndex:0,_endHiddenIndex:v.hunkInfo.newStartIndex-1,_plainText:v.text}),d=1/0):Number.isFinite(d)&&(v.splitInfo=Object.assign(Object.assign({},v.hunkInfo),{startHiddenIndex:d,endHiddenIndex:b,plainText:v.text,_startHiddenIndex:d,_endHiddenIndex:b,_plainText:v.text}),d=1/0),Pe(this,Bn,Object.assign(Object.assign({},Y(this,Bn,"f")),{[b]:v}))}}if(Number.isFinite(d)){const g=new Sr("",En.Hunk,null,null,null);g.isLast=!0,g.splitInfo={startHiddenIndex:d,endHiddenIndex:Y(this,kn,"f").length,_startHiddenIndex:d,_endHiddenIndex:Y(this,kn,"f").length,plainText:"",oldStartIndex:0,newStartIndex:0,oldLength:0,newLength:0,_plainText:"",_oldStartIndex:0,_newStartIndex:0,_oldLength:0,_newLength:0},Pe(this,Bn,Object.assign(Object.assign({},Y(this,Bn,"f")),{[Y(this,kn,"f").length]:g})),d=1/0}this.splitLineLength=Y(this,kn,"f").length,Pe(this,ca,!0),this.notifyAll()}buildUnifiedDiffLines(){var t,n,r,i,s,o;if(Y(this,da,"f"))return;let a=1,l=1,c=!0,d=1/0;const u=((t=Y(this,un,"f"))===null||t===void 0?void 0:t.maxLineNumber)||0,_=((n=Y(this,_n,"f"))===null||n===void 0?void 0:n.maxLineNumber)||0;for(;a<=u||l<=_;){const m=Y(this,Bt,"m",mc).call(this,a),g=Y(this,Bt,"m",Sa).call(this,a),p=Y(this,Bt,"m",gc).call(this,l),E=Y(this,Bt,"m",ba).call(this,l),h=Sr.prototype.isIncludeableLine.call(g||{}),f=Sr.prototype.isIncludeableLine.call(E||{}),b=Y(this,bn,"f").length,y=!g&&!E;if(g&&!E){if(g.newLineNumber&&g.newLineNumber>l){l++;continue}(g.newLineNumber===null||g.newLineNumber===void 0)&&l++}if(E&&!g){if(E.oldLineNumber&&E.oldLineNumber>a){a++;continue}(E.oldLineNumber===null||E.oldLineNumber===void 0)&&a++}if(!m&&!p&&!E&&!g)break;if(!g&&!E){if(!((r=Y(this,ns,"f"))===null||r===void 0)&&r[a]&&(!((i=Y(this,rs,"f"))===null||i===void 0)&&i[l])){a++,l++;continue}if(!m&&(!((s=Y(this,rs,"f"))===null||s===void 0)&&s[l])){l++;continue}if(!p&&(!((o=Y(this,ns,"f"))===null||o===void 0)&&o[a])){a++;continue}}if(!h&&!f?Y(this,bn,"f").push({oldLineNumber:a++,newLineNumber:l++,value:p,diff:E,isHidden:y,_isHidden:y}):h?Y(this,bn,"f").push({oldLineNumber:a++,value:m,diff:g,isHidden:y,_isHidden:y}):f&&Y(this,bn,"f").push({newLineNumber:l++,value:p,diff:E,isHidden:y,_isHidden:y}),!c&&y&&(d=b),y&&(this.hasSomeLineCollapsed=!0),c=y,g!=null&&g.prevHunkLine||E!=null&&E.prevHunkLine){const v=(g==null?void 0:g.prevHunkLine)||E.prevHunkLine;v.isFirst?(v.unifiedInfo=Object.assign(Object.assign({},v.hunkInfo),{startHiddenIndex:0,endHiddenIndex:v.hunkInfo.newStartIndex-1,plainText:v.text,_startHiddenIndex:0,_endHiddenIndex:v.hunkInfo.newStartIndex-1,_plainText:v.text}),d=1/0):Number.isFinite(d)&&(v.unifiedInfo=Object.assign(Object.assign({},v.hunkInfo),{startHiddenIndex:d,endHiddenIndex:b,plainText:v.text,_startHiddenIndex:d,_endHiddenIndex:b,_plainText:v.text}),d=1/0),Pe(this,Un,Object.assign(Object.assign({},Y(this,Un,"f")),{[b]:v}))}}if(Number.isFinite(d)){const g=new Sr("",En.Hunk,null,null,null);g.isLast=!0,g.unifiedInfo={startHiddenIndex:d,endHiddenIndex:Y(this,bn,"f").length,_startHiddenIndex:d,_endHiddenIndex:Y(this,bn,"f").length,plainText:"",oldStartIndex:0,newStartIndex:0,oldLength:0,newLength:0,_plainText:"",_oldStartIndex:0,_newStartIndex:0,_oldLength:0,_newLength:0},Pe(this,Un,Object.assign(Object.assign({},Y(this,Un,"f")),{[Y(this,bn,"f").length]:g})),d=1/0}this.unifiedLineLength=Y(this,bn,"f").length,Pe(this,da,!0),this.notifyAll()}get hasExpandSplitAll(){return Y(this,uo,"f").state}get hasExpandUnifiedAll(){return Y(this,_o,"f").state}}un=new WeakMap,_n=new WeakMap,Ps=new WeakMap,$s=new WeakMap,Fs=new WeakMap,Bs=new WeakMap,fo=new WeakMap,po=new WeakMap,ha=new WeakMap,Ea=new WeakMap,xs=new WeakMap,Ds=new WeakMap,ns=new WeakMap,rs=new WeakMap,pr=new WeakMap,kn=new WeakMap,Bn=new WeakMap,bn=new WeakMap,Un=new WeakMap,ws=new WeakMap,aa=new WeakMap,la=new WeakMap,ca=new WeakMap,da=new WeakMap,Ql=new WeakMap,Ei=new WeakMap,uc=new WeakMap,Vr=new WeakMap,_c=new WeakMap,ho=new WeakMap,Eo=new WeakMap,Kn=new WeakMap,jl=new WeakMap,uo=new WeakMap,_o=new WeakMap,Xl=new WeakMap,ts=new WeakMap,Bt=new WeakSet,EN=function(){this._diffList&&Pe(this,Ps,this._diffList.map(t=>x4.parse(t)))},SN=function(){!this._oldFileContent&&!this._newFileContent||(this._oldFileContent&&(Pe(this,un,Xo(this._oldFileContent,this._oldFileLang,Y(this,Kn,"f"),this._oldFileName,this.uuid?this.uuid+"-old":void 0)),Y(this,un,"f").enableTemplate=Y(this,Vr,"f")),this._newFileContent&&(Pe(this,_n,Xo(this._newFileContent,this._newFileLang,Y(this,Kn,"f"),this._newFileName,this.uuid?this.uuid+"-new":void 0)),Y(this,_n,"f").enableTemplate=Y(this,Vr,"f")))},mf=function(){var t,n,r,i,s,o,a,l;(t=Y(this,un,"f"))===null||t===void 0||t.doRaw(),Pe(this,fo,(n=Y(this,un,"f"))===null||n===void 0?void 0:n.rawFile),Pe(this,ha,(r=Y(this,un,"f"))===null||r===void 0?void 0:r.plainFile),(i=Y(this,_n,"f"))===null||i===void 0||i.doRaw(),Pe(this,po,(s=Y(this,_n,"f"))===null||s===void 0?void 0:s.rawFile),Pe(this,Ea,(o=Y(this,_n,"f"))===null||o===void 0?void 0:o.plainFile),this.fileLineLength=Math.max(this.fileLineLength,((a=Y(this,un,"f"))===null||a===void 0?void 0:a.maxLineNumber)||0,((l=Y(this,_n,"f"))===null||l===void 0?void 0:l.maxLineNumber)||0)},bN=function(){if(this._oldFileContent&&this._newFileContent)return;const t={},n={};if(!this._oldFileContent&&!this._newFileContent){let r=1,i=1,s="",o="",a=!1;for(;i<=this.diffLineLength||r<=this.diffLineLength;){const l=i++,c=r++,d=Y(this,Bt,"m",Sa).call(this,l),u=Y(this,Bt,"m",ba).call(this,c);d?s+=d.text:(s+=`
110
+ `:n[r],this.enableTemplate&&(this.plainFile[r+1]={value:this.rawFile[r+1],template:dN(this.rawFile[r+1])});this.hasDoRaw=!0}}hN=new WeakSet;function Xo(e,t,n,r,i){let s=e+"--0.0.35--"+n+"--"+t;i&&(s=i+"--0.0.35--"+n+"--"+t);let o=e+"--0.0.35--"+(n==="light"?"dark":"light")+"--"+t;if(i&&(o=i+"--0.0.35--"+(n==="light"?"dark":"light")+"--"+t),is.has(s))return is.get(s);if(is.has(o)){const l=is.get(o);if(l.highlighterType==="class")return l}const a=new Bc(e,t,r);return is.set(s,a),a}const L4=is,k4=()=>is.setMaxLength(0);var Bt,un,_n,Ps,$s,Fs,Bs,fo,po,ha,Ea,xs,Ds,ns,rs,pr,kn,Bn,bn,Un,ws,aa,la,ca,da,Ql,Ei,uc,Vr,_c,ho,Eo,Kn,jl,uo,_o,Xl,ts,EN,SN,mf,bN,gf,dv,vN,Sa,ba,mc,gc,uv,_v;let hn=40;const zm=new Set;class ju{static createInstance(t,n){var r,i,s,o,a,l;const c=new ju(((r=t==null?void 0:t.oldFile)===null||r===void 0?void 0:r.fileName)||"",((i=t==null?void 0:t.oldFile)===null||i===void 0?void 0:i.content)||"",((s=t==null?void 0:t.newFile)===null||s===void 0?void 0:s.fileName)||"",((o=t==null?void 0:t.newFile)===null||o===void 0?void 0:o.content)||"",(t==null?void 0:t.hunks)||[],((a=t==null?void 0:t.oldFile)===null||a===void 0?void 0:a.fileLang)||"",((l=t==null?void 0:t.newFile)===null||l===void 0?void 0:l.fileLang)||"");return n&&(n.isFullMerge?c._mergeFullBundle(n):c.mergeBundle(n)),c}constructor(t,n,r,i,s,o,a,l){Bt.add(this),this.uuid=l,un.set(this,void 0),_n.set(this,void 0),Ps.set(this,void 0),$s.set(this,void 0),Fs.set(this,void 0),Bs.set(this,void 0),fo.set(this,void 0),po.set(this,void 0),ha.set(this,void 0),Ea.set(this,void 0),xs.set(this,void 0),Ds.set(this,void 0),ns.set(this,void 0),rs.set(this,void 0),pr.set(this,[]),kn.set(this,[]),Bn.set(this,void 0),bn.set(this,[]),Un.set(this,void 0),ws.set(this,[]),aa.set(this,!1),la.set(this,!1),ca.set(this,!1),da.set(this,!1),Ql.set(this,0),Ei.set(this,!1),uc.set(this,!1),Vr.set(this,!0),_c.set(this,!1),ho.set(this,void 0),Eo.set(this,void 0),Kn.set(this,"light"),jl.set(this,void 0),uo.set(this,{state:!1}),_o.set(this,{state:!1}),this._version_="0.0.35",this._oldFileName="",this._oldFileContent="",this._oldFileLang="",this._newFileName="",this._newFileContent="",this._newFileLang="",this._diffList=[],this.diffLineLength=0,this.splitLineLength=0,this.unifiedLineLength=0,this.fileLineLength=0,this.additionLength=0,this.deletionLength=0,this.hasSomeLineCollapsed=!1,Xl.set(this,""),ts.set(this,new Map),this.getSplitLeftLine=d=>Y(this,pr,"f")[d],this.getSplitLineByLineNumber=(d,u)=>{var _,m;return u===Me.old?(_=Y(this,pr,"f"))===null||_===void 0?void 0:_.find(g=>g.lineNumber===d):(m=Y(this,kn,"f"))===null||m===void 0?void 0:m.find(g=>g.lineNumber===d)},this.getSplitLineIndexByLineNumber=(d,u)=>{var _,m;return u===Me.old?(_=Y(this,pr,"f"))===null||_===void 0?void 0:_.findIndex(g=>g.lineNumber===d):(m=Y(this,kn,"f"))===null||m===void 0?void 0:m.findIndex(g=>g.lineNumber===d)},this.getSplitRightLine=d=>Y(this,kn,"f")[d],this.getSplitHunkLine=d=>{var u;return(u=Y(this,Bn,"f"))===null||u===void 0?void 0:u[d]},this.onSplitHunkExpand=(d,u,_=!0)=>{var m,g;const p=(m=Y(this,Bn,"f"))===null||m===void 0?void 0:m[u];if(!(!p||!p.splitInfo)&&!Y(this,Ei,"f")){if(d==="all"){for(let E=p.splitInfo.startHiddenIndex;E<p.splitInfo.endHiddenIndex;E++){const h=Y(this,pr,"f")[E],f=Y(this,kn,"f")[E];h!=null&&h.isHidden&&(h.isHidden=!1),f!=null&&f.isHidden&&(f.isHidden=!1)}p.splitInfo=Object.assign(Object.assign(Object.assign({},p.splitInfo),p.hunkInfo),{plainText:p.text,startHiddenIndex:p.splitInfo.endHiddenIndex})}else if(d==="down"){for(let E=p.splitInfo.startHiddenIndex;E<p.splitInfo.startHiddenIndex+hn;E++){const h=Y(this,pr,"f")[E],f=Y(this,kn,"f")[E];h!=null&&h.isHidden&&(h.isHidden=!1),f!=null&&f.isHidden&&(f.isHidden=!1)}p.isLast?p.splitInfo=Object.assign(Object.assign({},p.splitInfo),{startHiddenIndex:p.splitInfo.startHiddenIndex+hn}):p.splitInfo=Object.assign(Object.assign({},p.splitInfo),{startHiddenIndex:p.splitInfo.startHiddenIndex+hn,plainText:`@@ -${p.splitInfo.oldStartIndex},${p.splitInfo.oldLength} +${p.splitInfo.newStartIndex},${p.splitInfo.newLength}`})}else{if(p.isLast)return;for(let y=p.splitInfo.endHiddenIndex-hn;y<p.splitInfo.endHiddenIndex;y++){const v=Y(this,pr,"f")[y],O=Y(this,kn,"f")[y];v!=null&&v.isHidden&&(v.isHidden=!1),O!=null&&O.isHidden&&(O.isHidden=!1)}const E=p.splitInfo.oldStartIndex-hn,h=p.splitInfo.oldLength+hn,f=p.splitInfo.newStartIndex-hn,b=p.splitInfo.newLength+hn;p.splitInfo=Object.assign(Object.assign({},p.splitInfo),{endHiddenIndex:p.splitInfo.endHiddenIndex-hn,oldStartIndex:E,oldLength:h,newStartIndex:f,newLength:b,plainText:`@@ -${E},${h} +${f},${b}`}),(g=Y(this,Bn,"f"))===null||g===void 0||delete g[u],Y(this,Bn,"f")[p.splitInfo.endHiddenIndex]=p}_&&this.notifyAll()}},this.getUnifiedLine=d=>Y(this,bn,"f")[d],this.getUnifiedLineByLineNumber=(d,u)=>{var _,m;return u===Me.old?(_=Y(this,bn,"f"))===null||_===void 0?void 0:_.find(g=>g.oldLineNumber===d):(m=Y(this,bn,"f"))===null||m===void 0?void 0:m.find(g=>g.newLineNumber===d)},this.getUnifiedLineIndexByLineNumber=(d,u)=>{var _,m;return u===Me.old?(_=Y(this,bn,"f"))===null||_===void 0?void 0:_.findIndex(g=>g.oldLineNumber===d):(m=Y(this,bn,"f"))===null||m===void 0?void 0:m.findIndex(g=>g.newLineNumber===d)},this.getUnifiedHunkLine=d=>{var u;return(u=Y(this,Un,"f"))===null||u===void 0?void 0:u[d]},this.onUnifiedHunkExpand=(d,u,_=!0)=>{var m,g,p;if(Y(this,Ei,"f"))return;const E=(m=Y(this,Un,"f"))===null||m===void 0?void 0:m[u];if(!(!E||!E.unifiedInfo)){if(d==="all"){for(let h=E.unifiedInfo.startHiddenIndex;h<E.unifiedInfo.endHiddenIndex;h++){const f=(g=Y(this,bn,"f"))===null||g===void 0?void 0:g[h];f!=null&&f.isHidden&&(f.isHidden=!1)}E.unifiedInfo=Object.assign(Object.assign(Object.assign({},E.unifiedInfo),E.hunkInfo),{plainText:E.text,startHiddenIndex:E.unifiedInfo.endHiddenIndex})}else if(d==="down"){for(let h=E.unifiedInfo.startHiddenIndex;h<E.unifiedInfo.startHiddenIndex+hn;h++){const f=Y(this,bn,"f")[h];f!=null&&f.isHidden&&(f.isHidden=!1)}E.isLast?E.unifiedInfo=Object.assign(Object.assign({},E.unifiedInfo),{startHiddenIndex:E.unifiedInfo.startHiddenIndex+hn}):E.unifiedInfo=Object.assign(Object.assign({},E.unifiedInfo),{startHiddenIndex:E.unifiedInfo.startHiddenIndex+hn,plainText:`@@ -${E.unifiedInfo.oldStartIndex},${E.unifiedInfo.oldLength} +${E.unifiedInfo.newStartIndex},${E.unifiedInfo.newLength}`})}else{if(E.isLast)return;for(let v=E.unifiedInfo.endHiddenIndex-hn;v<E.unifiedInfo.endHiddenIndex;v++){const O=Y(this,bn,"f")[v];O!=null&&O.isHidden&&(O.isHidden=!1)}const h=E.unifiedInfo.oldStartIndex-hn,f=E.unifiedInfo.oldLength+hn,b=E.unifiedInfo.newStartIndex-hn,y=E.unifiedInfo.newLength+hn;E.unifiedInfo=Object.assign(Object.assign({},E.unifiedInfo),{endHiddenIndex:E.unifiedInfo.endHiddenIndex-hn,oldStartIndex:h,oldLength:f,newStartIndex:b,newLength:y,plainText:`@@ -${h},${f} +${b},${y}`}),(p=Y(this,Un,"f"))===null||p===void 0||delete p[u],Y(this,Un,"f")[E.unifiedInfo.endHiddenIndex]=E}_&&this.notifyAll()}},this.onAllExpand=d=>{Y(this,Ei,"f")||(d==="split"?(Object.keys(Y(this,Bn,"f")||{}).forEach(u=>{this.onSplitHunkExpand("all",+u,!1)}),Y(this,uo,"f").state=!0):(Object.keys(Y(this,Un,"f")||{}).forEach(u=>{this.onUnifiedHunkExpand("all",+u,!1)}),Y(this,_o,"f").state=!0),this.notifyAll())},this.onAllCollapse=d=>{Y(this,Ei,"f")||(d==="split"?(Object.values(Y(this,pr,"f")||{}).forEach(u=>{!u.isHidden&&u._isHidden&&(u.isHidden=u._isHidden)}),Object.values(Y(this,kn,"f")||{}).forEach(u=>{!u.isHidden&&u._isHidden&&(u.isHidden=u._isHidden)}),Object.values(Y(this,Bn,"f")||{}).forEach(u=>{u.splitInfo&&(u.splitInfo=Object.assign(Object.assign({},u.splitInfo),{oldStartIndex:u.splitInfo._oldStartIndex,oldLength:u.splitInfo._oldLength,newStartIndex:u.splitInfo._newStartIndex,newLength:u.splitInfo._newLength,startHiddenIndex:u.splitInfo._startHiddenIndex,endHiddenIndex:u.splitInfo._endHiddenIndex,plainText:u.splitInfo._plainText}))}),Object.keys(Y(this,Bn,"f")||{}).forEach(u=>{const _=Y(this,Bn,"f")[u];_.splitInfo&&_.splitInfo.endHiddenIndex!==+u&&(delete Y(this,Bn,"f")[u],Y(this,Bn,"f")[_.splitInfo.endHiddenIndex]=_)}),Y(this,uo,"f").state=!1):(Object.values(Y(this,bn,"f")||{}).forEach(u=>{!u.isHidden&&u._isHidden&&(u.isHidden=u._isHidden)}),Object.values(Y(this,Un,"f")||{}).forEach(u=>{u.unifiedInfo&&(u.unifiedInfo=Object.assign(Object.assign({},u.unifiedInfo),{oldStartIndex:u.unifiedInfo._oldStartIndex,oldLength:u.unifiedInfo._oldLength,newStartIndex:u.unifiedInfo._newStartIndex,newLength:u.unifiedInfo._newLength,startHiddenIndex:u.unifiedInfo._startHiddenIndex,endHiddenIndex:u.unifiedInfo._endHiddenIndex,plainText:u.unifiedInfo._plainText}))}),Object.keys(Y(this,Un,"f")||{}).forEach(u=>{const _=Y(this,Un,"f")[u];_.unifiedInfo&&_.unifiedInfo.endHiddenIndex!==+u&&(delete Y(this,Un,"f")[u],Y(this,Un,"f")[_.unifiedInfo.endHiddenIndex]=_)}),Y(this,_o,"f").state=!1),this.notifyAll())},this.getOldFileContent=()=>{var d;return(d=Y(this,un,"f"))===null||d===void 0?void 0:d.raw},this.getNewFileContent=()=>{var d;return(d=Y(this,_n,"f"))===null||d===void 0?void 0:d.raw},this.getOldPlainLine=d=>{var u;return(u=Y(this,ha,"f"))===null||u===void 0?void 0:u[d]},this.getOldSyntaxLine=d=>{var u;return(u=Y(this,xs,"f"))===null||u===void 0?void 0:u[d]},this.getNewPlainLine=d=>{var u;return(u=Y(this,Ea,"f"))===null||u===void 0?void 0:u[d]},this.getNewSyntaxLine=d=>{var u;return(u=Y(this,Ds,"f"))===null||u===void 0?void 0:u[d]},this.subscribe=d=>(Y(this,ws,"f").push(d),()=>{$e(this,ws,Y(this,ws,"f").filter(u=>u!==d))}),this.notifyAll=d=>{var u;$e(this,Ql,(u=Y(this,Ql,"f"),u++,u)),Y(this,ws,"f").forEach(_=>{d&&_.isSyncExternal||_()}),Y(this,ts,"f").forEach((_,m)=>{m.notifyAll(!0)})},this.getUpdateCount=()=>Y(this,Ql,"f"),this.getExpandEnabled=()=>!Y(this,Ei,"f"),this.getBundle=()=>{const d=Y(this,aa,"f"),u=Y(this,la,"f"),_=Y(this,ca,"f"),m=Y(this,da,"f"),g=Y(this,fo,"f"),p=Y(this,Fs,"f"),E=Y(this,ha,"f"),h=Y(this,xs,"f"),f=Y(this,ns,"f"),b=Y(this,po,"f"),y=Y(this,Bs,"f"),v=Y(this,Ea,"f"),O=Y(this,Ds,"f"),T=Y(this,rs,"f"),I=this.splitLineLength,k=this.unifiedLineLength,A=this.fileLineLength,V=this.additionLength,B=this.deletionLength,$=Y(this,Ei,"f"),M=Y(this,ho,"f"),L=Y(this,Eo,"f"),R=this.hasSomeLineCollapsed,D=Y(this,uo,"f"),w=Y(this,_o,"f"),P=Y(this,pr,"f"),j=Y(this,kn,"f"),le=Y(this,Bn,"f"),me=Y(this,bn,"f"),Ae=Y(this,Un,"f"),ie=this._version_,re=Y(this,Kn,"f"),Ee=Y(this,Vr,"f");return{hasInitRaw:d,hasInitSyntax:u,hasBuildSplit:_,hasBuildUnified:m,oldFileLines:g,oldFileDiffLines:p,oldFilePlainLines:E,oldFileSyntaxLines:h,oldFilePlaceholderLines:f,newFileLines:b,newFileDiffLines:y,newFilePlainLines:v,newFileSyntaxLines:O,newFilePlaceholderLines:T,splitLineLength:I,unifiedLineLength:k,fileLineLength:A,additionLength:V,deletionLength:B,splitLeftLines:P,splitRightLines:j,splitHunkLines:le,unifiedLines:me,unifiedHunkLines:Ae,highlighterName:M,highlighterType:L,composeByDiff:$,hasSomeLineCollapsed:R,hasExpandSplitAll:D,hasExpandUnifiedAll:w,version:ie,theme:re,enableTemplate:Ee,isFullMerge:!1}},this.mergeBundle=(d,u=!0)=>{$e(this,aa,d.hasInitRaw),$e(this,la,d.hasInitSyntax),$e(this,ca,d.hasBuildSplit),$e(this,da,d.hasBuildUnified),$e(this,Ei,d.composeByDiff),$e(this,ho,d.highlighterName),$e(this,Eo,d.highlighterType),$e(this,fo,d.oldFileLines),$e(this,Fs,d.oldFileDiffLines),$e(this,ha,d.oldFilePlainLines),$e(this,xs,d.oldFileSyntaxLines),$e(this,ns,d.oldFilePlaceholderLines),$e(this,po,d.newFileLines),$e(this,Bs,d.newFileDiffLines),$e(this,Ea,d.newFilePlainLines),$e(this,Ds,d.newFileSyntaxLines),$e(this,rs,d.newFilePlaceholderLines),this.splitLineLength=d.splitLineLength,this.unifiedLineLength=d.unifiedLineLength,this.fileLineLength=d.fileLineLength,this.additionLength=d.additionLength,this.deletionLength=d.deletionLength,this.hasSomeLineCollapsed=d.hasSomeLineCollapsed,$e(this,uo,d.hasExpandSplitAll),$e(this,_o,d.hasExpandUnifiedAll),$e(this,pr,d.splitLeftLines),$e(this,kn,d.splitRightLines),$e(this,Bn,d.splitHunkLines),$e(this,bn,d.unifiedLines),$e(this,Un,d.unifiedHunkLines),$e(this,Kn,d.theme),$e(this,Vr,d.enableTemplate),$e(this,uc,!0),u&&this.notifyAll()},this._getHighlighterName=()=>Y(this,ho,"f")||"",this._getIsPureDiffRender=()=>Y(this,Ei,"f"),this._getTheme=()=>Y(this,Kn,"f"),this._addClonedInstance=d=>{const u=()=>{this._notifyOthers(d),this._mergeFullBundle(d._getFullBundle(),!1)};u.isSyncExternal=!0;const _=d.subscribe(u);Y(this,ts,"f").set(d,_)},this._notifyOthers=d=>{Y(this,ts,"f").forEach((u,_)=>{_!==d&&_.notifyAll(!0)})},this._delClonedInstance=d=>{const u=Y(this,ts,"f").get(d);u==null||u(),Y(this,ts,"f").delete(d)},this._getFullBundle=()=>{const d=this.getBundle(),u=Y(this,un,"f"),_=Y(this,_n,"f"),m=Y(this,$s,"f"),g=Y(this,Ps,"f");return Object.assign(Object.assign({},d),{oldFileResult:u,newFileResult:_,diffLines:m,diffListResults:g,isFullMerge:Y(this,uc,"f")?Y(this,_c,"f"):!0})},this._mergeFullBundle=(d,u=!0)=>{this.mergeBundle(d,u);try{$e(this,un,d.oldFileResult?Bc.createInstance(d.oldFileResult):null,"f"),$e(this,_n,d.newFileResult?Bc.createInstance(d.newFileResult):null,"f"),$e(this,$s,d.diffLines,"f"),$e(this,Ps,d.diffListResults,"f"),$e(this,_c,d.isFullMerge,"f")}catch{}},this._destroy=()=>{this.clearId(),Y(this,ws,"f").splice(0,Y(this,ws,"f").length),Y(this,ts,"f").forEach(d=>d()),Y(this,ts,"f").clear()},this.clear=()=>{this._destroy(),$e(this,un,null),$e(this,_n,null),$e(this,$s,null),$e(this,Ps,null),$e(this,Bs,null),$e(this,Fs,null),$e(this,po,null),$e(this,fo,null),$e(this,Ds,null),$e(this,xs,null),$e(this,Bn,null),$e(this,pr,null),$e(this,kn,null),$e(this,Un,null),$e(this,bn,null),$e(this,Kn,void 0)},Object.defineProperty(this,"__v_skip",{value:!0});const c=Array.from(new Set(s));this._oldFileName=t,this._newFileName=r,this._diffList=c,this._oldFileLang=lv(o||t||a||r)||"txt",this._newFileLang=lv(a||r||o||t)||"txt",this._oldFileContent=n,this._newFileContent=i,this.initId()}initId(){let t="--"+Math.random().toString().slice(2);for(;zm.has(t);)t="--"+Math.random().toString().slice(2);zm.add(t),$e(this,Xl,t)}getId(){return Y(this,Xl,"f")}clearId(){zm.delete(Y(this,Xl,"f"))}initTheme(t){$e(this,jl,Y(this,Kn,"f")),$e(this,Kn,t||Y(this,Kn,"f")||"light")}initRaw(){Y(this,aa,"f")||(Y(this,Bt,"m",SN).call(this),Y(this,Bt,"m",mf).call(this),Y(this,Bt,"m",EN).call(this),Y(this,Bt,"m",gf).call(this),Y(this,Bt,"m",bN).call(this),$e(this,aa,!0))}initSyntax({registerHighlighter:t}={}){Y(this,la,"f")&&(!Y(this,jl,"f")||Y(this,Kn,"f")===Y(this,jl,"f"))||(Y(this,Bt,"m",vN).call(this,{registerHighlighter:t}),Y(this,Bt,"m",gf).call(this),$e(this,la,!0))}init(){this.initRaw(),this.initSyntax()}enableTemplate(){$e(this,Vr,!0)}disableTemplate(){$e(this,Vr,!1)}getIsEnableTemplate(){return Y(this,Vr,"f")}buildSplitDiffLines(){var t,n,r,i,s,o;if(Y(this,ca,"f"))return;let a=1,l=1,c=!0,d=1/0;const u=((t=Y(this,un,"f"))===null||t===void 0?void 0:t.maxLineNumber)||0,_=((n=Y(this,_n,"f"))===null||n===void 0?void 0:n.maxLineNumber)||0;for(;a<=u||l<=_;){const m=Y(this,Bt,"m",Sa).call(this,a),g=Y(this,Bt,"m",ba).call(this,l),p=Y(this,Bt,"m",mc).call(this,a),E=Y(this,Bt,"m",gc).call(this,l),h=Sr.prototype.isIncludeableLine.call(m||{}),f=Sr.prototype.isIncludeableLine.call(g||{}),b=Y(this,kn,"f").length,y=!m&&!g;if(m&&!g){if(m.newLineNumber&&m.newLineNumber>l){l++;continue}(m.newLineNumber===null||m.newLineNumber===void 0)&&l++}if(g&&!m){if(g.oldLineNumber&&g.oldLineNumber>a){a++;continue}(g.oldLineNumber===null||g.oldLineNumber===void 0)&&a++}if(!m&&!p&&!g&&!E)break;if(!m&&!g){if(!((r=Y(this,ns,"f"))===null||r===void 0)&&r[a]&&(!((i=Y(this,rs,"f"))===null||i===void 0)&&i[l])){a++,l++;continue}if(!p&&(!((s=Y(this,rs,"f"))===null||s===void 0)&&s[l])){l++;continue}if(!E&&(!((o=Y(this,ns,"f"))===null||o===void 0)&&o[a])){a++;continue}}if(h&&f||!h&&!f?(Y(this,pr,"f").push({lineNumber:a++,value:p,diff:m,isHidden:y,_isHidden:y}),Y(this,kn,"f").push({lineNumber:l++,value:E,diff:g,isHidden:y,_isHidden:y})):h?(Y(this,pr,"f").push({lineNumber:a++,value:p,diff:m,isHidden:y,_isHidden:y}),Y(this,kn,"f").push({})):f&&(Y(this,pr,"f").push({}),Y(this,kn,"f").push({lineNumber:l++,value:E,diff:g,isHidden:y,_isHidden:y})),!c&&y&&(d=b),y&&(this.hasSomeLineCollapsed=!0),c=y,m!=null&&m.prevHunkLine||g!=null&&g.prevHunkLine){const v=(m==null?void 0:m.prevHunkLine)||g.prevHunkLine;v.isFirst?(v.splitInfo=Object.assign(Object.assign({},v.hunkInfo),{startHiddenIndex:0,endHiddenIndex:v.hunkInfo.newStartIndex-1,plainText:v.text,_startHiddenIndex:0,_endHiddenIndex:v.hunkInfo.newStartIndex-1,_plainText:v.text}),d=1/0):Number.isFinite(d)&&(v.splitInfo=Object.assign(Object.assign({},v.hunkInfo),{startHiddenIndex:d,endHiddenIndex:b,plainText:v.text,_startHiddenIndex:d,_endHiddenIndex:b,_plainText:v.text}),d=1/0),$e(this,Bn,Object.assign(Object.assign({},Y(this,Bn,"f")),{[b]:v}))}}if(Number.isFinite(d)){const g=new Sr("",En.Hunk,null,null,null);g.isLast=!0,g.splitInfo={startHiddenIndex:d,endHiddenIndex:Y(this,kn,"f").length,_startHiddenIndex:d,_endHiddenIndex:Y(this,kn,"f").length,plainText:"",oldStartIndex:0,newStartIndex:0,oldLength:0,newLength:0,_plainText:"",_oldStartIndex:0,_newStartIndex:0,_oldLength:0,_newLength:0},$e(this,Bn,Object.assign(Object.assign({},Y(this,Bn,"f")),{[Y(this,kn,"f").length]:g})),d=1/0}this.splitLineLength=Y(this,kn,"f").length,$e(this,ca,!0),this.notifyAll()}buildUnifiedDiffLines(){var t,n,r,i,s,o;if(Y(this,da,"f"))return;let a=1,l=1,c=!0,d=1/0;const u=((t=Y(this,un,"f"))===null||t===void 0?void 0:t.maxLineNumber)||0,_=((n=Y(this,_n,"f"))===null||n===void 0?void 0:n.maxLineNumber)||0;for(;a<=u||l<=_;){const m=Y(this,Bt,"m",mc).call(this,a),g=Y(this,Bt,"m",Sa).call(this,a),p=Y(this,Bt,"m",gc).call(this,l),E=Y(this,Bt,"m",ba).call(this,l),h=Sr.prototype.isIncludeableLine.call(g||{}),f=Sr.prototype.isIncludeableLine.call(E||{}),b=Y(this,bn,"f").length,y=!g&&!E;if(g&&!E){if(g.newLineNumber&&g.newLineNumber>l){l++;continue}(g.newLineNumber===null||g.newLineNumber===void 0)&&l++}if(E&&!g){if(E.oldLineNumber&&E.oldLineNumber>a){a++;continue}(E.oldLineNumber===null||E.oldLineNumber===void 0)&&a++}if(!m&&!p&&!E&&!g)break;if(!g&&!E){if(!((r=Y(this,ns,"f"))===null||r===void 0)&&r[a]&&(!((i=Y(this,rs,"f"))===null||i===void 0)&&i[l])){a++,l++;continue}if(!m&&(!((s=Y(this,rs,"f"))===null||s===void 0)&&s[l])){l++;continue}if(!p&&(!((o=Y(this,ns,"f"))===null||o===void 0)&&o[a])){a++;continue}}if(!h&&!f?Y(this,bn,"f").push({oldLineNumber:a++,newLineNumber:l++,value:p,diff:E,isHidden:y,_isHidden:y}):h?Y(this,bn,"f").push({oldLineNumber:a++,value:m,diff:g,isHidden:y,_isHidden:y}):f&&Y(this,bn,"f").push({newLineNumber:l++,value:p,diff:E,isHidden:y,_isHidden:y}),!c&&y&&(d=b),y&&(this.hasSomeLineCollapsed=!0),c=y,g!=null&&g.prevHunkLine||E!=null&&E.prevHunkLine){const v=(g==null?void 0:g.prevHunkLine)||E.prevHunkLine;v.isFirst?(v.unifiedInfo=Object.assign(Object.assign({},v.hunkInfo),{startHiddenIndex:0,endHiddenIndex:v.hunkInfo.newStartIndex-1,plainText:v.text,_startHiddenIndex:0,_endHiddenIndex:v.hunkInfo.newStartIndex-1,_plainText:v.text}),d=1/0):Number.isFinite(d)&&(v.unifiedInfo=Object.assign(Object.assign({},v.hunkInfo),{startHiddenIndex:d,endHiddenIndex:b,plainText:v.text,_startHiddenIndex:d,_endHiddenIndex:b,_plainText:v.text}),d=1/0),$e(this,Un,Object.assign(Object.assign({},Y(this,Un,"f")),{[b]:v}))}}if(Number.isFinite(d)){const g=new Sr("",En.Hunk,null,null,null);g.isLast=!0,g.unifiedInfo={startHiddenIndex:d,endHiddenIndex:Y(this,bn,"f").length,_startHiddenIndex:d,_endHiddenIndex:Y(this,bn,"f").length,plainText:"",oldStartIndex:0,newStartIndex:0,oldLength:0,newLength:0,_plainText:"",_oldStartIndex:0,_newStartIndex:0,_oldLength:0,_newLength:0},$e(this,Un,Object.assign(Object.assign({},Y(this,Un,"f")),{[Y(this,bn,"f").length]:g})),d=1/0}this.unifiedLineLength=Y(this,bn,"f").length,$e(this,da,!0),this.notifyAll()}get hasExpandSplitAll(){return Y(this,uo,"f").state}get hasExpandUnifiedAll(){return Y(this,_o,"f").state}}un=new WeakMap,_n=new WeakMap,Ps=new WeakMap,$s=new WeakMap,Fs=new WeakMap,Bs=new WeakMap,fo=new WeakMap,po=new WeakMap,ha=new WeakMap,Ea=new WeakMap,xs=new WeakMap,Ds=new WeakMap,ns=new WeakMap,rs=new WeakMap,pr=new WeakMap,kn=new WeakMap,Bn=new WeakMap,bn=new WeakMap,Un=new WeakMap,ws=new WeakMap,aa=new WeakMap,la=new WeakMap,ca=new WeakMap,da=new WeakMap,Ql=new WeakMap,Ei=new WeakMap,uc=new WeakMap,Vr=new WeakMap,_c=new WeakMap,ho=new WeakMap,Eo=new WeakMap,Kn=new WeakMap,jl=new WeakMap,uo=new WeakMap,_o=new WeakMap,Xl=new WeakMap,ts=new WeakMap,Bt=new WeakSet,EN=function(){this._diffList&&$e(this,Ps,this._diffList.map(t=>x4.parse(t)))},SN=function(){!this._oldFileContent&&!this._newFileContent||(this._oldFileContent&&($e(this,un,Xo(this._oldFileContent,this._oldFileLang,Y(this,Kn,"f"),this._oldFileName,this.uuid?this.uuid+"-old":void 0)),Y(this,un,"f").enableTemplate=Y(this,Vr,"f")),this._newFileContent&&($e(this,_n,Xo(this._newFileContent,this._newFileLang,Y(this,Kn,"f"),this._newFileName,this.uuid?this.uuid+"-new":void 0)),Y(this,_n,"f").enableTemplate=Y(this,Vr,"f")))},mf=function(){var t,n,r,i,s,o,a,l;(t=Y(this,un,"f"))===null||t===void 0||t.doRaw(),$e(this,fo,(n=Y(this,un,"f"))===null||n===void 0?void 0:n.rawFile),$e(this,ha,(r=Y(this,un,"f"))===null||r===void 0?void 0:r.plainFile),(i=Y(this,_n,"f"))===null||i===void 0||i.doRaw(),$e(this,po,(s=Y(this,_n,"f"))===null||s===void 0?void 0:s.rawFile),$e(this,Ea,(o=Y(this,_n,"f"))===null||o===void 0?void 0:o.plainFile),this.fileLineLength=Math.max(this.fileLineLength,((a=Y(this,un,"f"))===null||a===void 0?void 0:a.maxLineNumber)||0,((l=Y(this,_n,"f"))===null||l===void 0?void 0:l.maxLineNumber)||0)},bN=function(){if(this._oldFileContent&&this._newFileContent)return;const t={},n={};if(!this._oldFileContent&&!this._newFileContent){let r=1,i=1,s="",o="",a=!1;for(;i<=this.diffLineLength||r<=this.diffLineLength;){const l=i++,c=r++,d=Y(this,Bt,"m",Sa).call(this,l),u=Y(this,Bt,"m",ba).call(this,c);d?s+=d.text:(s+=`
111
111
  `,t[l]=!0),u?o+=u.text:(o+=`
112
- `,n[c]=!0),!a&&d&&u&&(a=a||d.noTrailingNewLine!==u.noTrailingNewLine)}if(!a&&s===o)return;this._oldFileContent=s,this._newFileContent=o,Pe(this,un,Xo(this._oldFileContent,this._oldFileLang,Y(this,Kn,"f"),this._oldFileName,this.uuid?this.uuid+"-old":void 0)),Y(this,un,"f").enableTemplate=Y(this,Vr,"f"),Pe(this,_n,Xo(this._newFileContent,this._newFileLang,Y(this,Kn,"f"),this._newFileName,this.uuid?this.uuid+"-new":void 0)),Y(this,_n,"f").enableTemplate=Y(this,Vr,"f"),Pe(this,ns,t),Pe(this,rs,n),Pe(this,Ei,!0)}else if(Y(this,un,"f")){let r=1,i=1,s="",o=!1;for(;i<=Y(this,un,"f").maxLineNumber;){const a=Y(this,Bt,"m",ba).call(this,r++),l=Y(this,Bt,"m",Sa).call(this,i);a?(s+=a.text,i=a.oldLineNumber?a.oldLineNumber+1:i):(l||(s+=Y(this,Bt,"m",mc).call(this,i)),i++),!o&&a&&l&&(o=o||a.noTrailingNewLine!==l.noTrailingNewLine)}if(!o&&s===this._oldFileContent)return;this._newFileContent=s,Pe(this,_n,Xo(this._newFileContent,this._newFileLang,Y(this,Kn,"f"),this._newFileName,this.uuid?this.uuid+"-new":void 0)),Y(this,_n,"f").enableTemplate=Y(this,Vr,"f")}else if(Y(this,_n,"f")){let r=1,i=1,s="",o=!1;for(;i<=Y(this,_n,"f").maxLineNumber;){const a=Y(this,Bt,"m",Sa).call(this,r++),l=Y(this,Bt,"m",ba).call(this,i);a?(s+=a.text,i=a.newLineNumber?a.newLineNumber+1:i):(l||(s+=Y(this,Bt,"m",gc).call(this,i)),i++),!o&&l&&a&&(o=o||l.noTrailingNewLine!==a.noTrailingNewLine)}if(!o&&s===this._newFileContent)return;this._oldFileContent=s,Pe(this,un,Xo(this._oldFileContent,this._oldFileLang,Y(this,Kn,"f"),this._oldFileName,this.uuid?this.uuid+"-old":void 0)),Y(this,un,"f").enableTemplate=Y(this,Vr,"f")}Y(this,Bt,"m",mf).call(this)},gf=function(){var t;if(!(!((t=Y(this,Ps,"f"))===null||t===void 0)&&t.length))return;const n=l=>Y(this,Bt,"m",gc).call(this,l),r=l=>Y(this,Bt,"m",mc).call(this,l),i=l=>Y(this,Bt,"m",_v).call(this,l),s=l=>Y(this,Bt,"m",uv).call(this,l);Pe(this,$s,[]),this.additionLength=0,this.deletionLength=0;const o=[];Y(this,Ps,"f").forEach(l=>{l.hunks.forEach(d=>{let u=[],_=[];d.lines.forEach(m=>{m.type===En.Add?(u.push(m),this.additionLength++):m.type===En.Delete?(_.push(m),this.deletionLength++):(cv(u,_,{getAdditionRaw:n,getDeletionRaw:r,getAdditionSyntax:i,getDeletionSyntax:s}),u=[],_=[]),o.push(m)}),cv(u,_,{getAdditionRaw:n,getDeletionRaw:r,getAdditionSyntax:i,getDeletionSyntax:s})})});let a=null;Pe(this,$s,o.map((l,c)=>{var d;const u=l;if(u.index=c,u.isFirst=c===0,u.type===En.Hunk){const _=(d=u.text.split("@@"))===null||d===void 0?void 0:d[1].split(" ").filter(Boolean),m=(_==null?void 0:_[0])||"",g=(_==null?void 0:_[1])||"",[p,E]=m.split(","),[h,f]=g.split(",");u.hunkInfo={oldStartIndex:-Number(p),oldLength:Number(E),newStartIndex:+Number(h),newLength:Number(f),_oldStartIndex:-Number(p),_oldLength:Number(E),_newStartIndex:+Number(h),_newLength:Number(f)},a=u}else if(u.type===En.Context){const _=l;a&&(_.prevHunkLine=a,a=null)}else a=null;return u})),Pe(this,Fs,{}),Pe(this,Bs,{}),Y(this,$s,"f").forEach(l=>{l.oldLineNumber&&(this.diffLineLength=Math.max(this.diffLineLength,l.oldLineNumber),Y(this,Fs,"f")[l.oldLineNumber]=l),l.newLineNumber&&(this.diffLineLength=Math.max(this.diffLineLength,l.newLineNumber),Y(this,Bs,"f")[l.newLineNumber]=l)})},dv=function({registerHighlighter:t}){var n,r,i,s;(n=Y(this,un,"f"))===null||n===void 0||n.doSyntax({registerHighlighter:t,theme:Y(this,Kn,"f")}),Pe(this,xs,(r=Y(this,un,"f"))===null||r===void 0?void 0:r.syntaxFile),(i=Y(this,_n,"f"))===null||i===void 0||i.doSyntax({registerHighlighter:t,theme:Y(this,Kn,"f")}),Pe(this,Ds,(s=Y(this,_n,"f"))===null||s===void 0?void 0:s.syntaxFile)},vN=function({registerHighlighter:t}={}){var n,r,i,s;Y(this,Eo,"f")!=="class"&&(Y(this,uc,"f")&&!Y(this,_c,"f")||(Y(this,Bt,"m",dv).call(this,{registerHighlighter:t}),Pe(this,ho,((n=Y(this,un,"f"))===null||n===void 0?void 0:n.highlighterName)||((r=Y(this,_n,"f"))===null||r===void 0?void 0:r.highlighterName)||Y(this,ho,"f")),Pe(this,Eo,((i=Y(this,un,"f"))===null||i===void 0?void 0:i.highlighterType)||((s=Y(this,_n,"f"))===null||s===void 0?void 0:s.highlighterType)||Y(this,Eo,"f"))))},Sa=function(t){var n;if(t)return(n=Y(this,Fs,"f"))===null||n===void 0?void 0:n[t]},ba=function(t){var n;if(t)return(n=Y(this,Bs,"f"))===null||n===void 0?void 0:n[t]},mc=function(t){var n;return(n=Y(this,fo,"f"))===null||n===void 0?void 0:n[t]},gc=function(t){var n;return(n=Y(this,po,"f"))===null||n===void 0?void 0:n[t]},uv=function(t){var n;return(n=Y(this,xs,"f"))===null||n===void 0?void 0:n[t]},_v=function(t){var n;return(n=Y(this,Ds,"f"))===null||n===void 0?void 0:n[t]};var Xu;(function(e){e[e.hunk=1]="hunk",e[e.content=2]="content",e[e.widget=3]="widget",e[e.extend=4]="extend"})(Xu||(Xu={}));var Me;(function(e){e[e.old=1]="old",e[e.new=2]="new"})(Me||(Me={}));const yN=e=>{const t=e.splitLineLength,n=[];return uN(t,r=>{const i=e.getSplitLeftLine(r),s=e.getSplitRightLine(r);!(i!=null&&i.isHidden)&&!(s!=null&&s.isHidden)&&n.push({type:Xu.content,index:r,lineNumber:r+1,splitLine:{left:i,right:s}})}),n},M4=e=>{const t=e.unifiedLineLength,n=[];return uN(t,r=>{const i=e.getUnifiedLine(r);i.isHidden||n.push({type:Xu.content,index:r,lineNumber:r+1,unifiedLine:i})}),n};/**
112
+ `,n[c]=!0),!a&&d&&u&&(a=a||d.noTrailingNewLine!==u.noTrailingNewLine)}if(!a&&s===o)return;this._oldFileContent=s,this._newFileContent=o,$e(this,un,Xo(this._oldFileContent,this._oldFileLang,Y(this,Kn,"f"),this._oldFileName,this.uuid?this.uuid+"-old":void 0)),Y(this,un,"f").enableTemplate=Y(this,Vr,"f"),$e(this,_n,Xo(this._newFileContent,this._newFileLang,Y(this,Kn,"f"),this._newFileName,this.uuid?this.uuid+"-new":void 0)),Y(this,_n,"f").enableTemplate=Y(this,Vr,"f"),$e(this,ns,t),$e(this,rs,n),$e(this,Ei,!0)}else if(Y(this,un,"f")){let r=1,i=1,s="",o=!1;for(;i<=Y(this,un,"f").maxLineNumber;){const a=Y(this,Bt,"m",ba).call(this,r++),l=Y(this,Bt,"m",Sa).call(this,i);a?(s+=a.text,i=a.oldLineNumber?a.oldLineNumber+1:i):(l||(s+=Y(this,Bt,"m",mc).call(this,i)),i++),!o&&a&&l&&(o=o||a.noTrailingNewLine!==l.noTrailingNewLine)}if(!o&&s===this._oldFileContent)return;this._newFileContent=s,$e(this,_n,Xo(this._newFileContent,this._newFileLang,Y(this,Kn,"f"),this._newFileName,this.uuid?this.uuid+"-new":void 0)),Y(this,_n,"f").enableTemplate=Y(this,Vr,"f")}else if(Y(this,_n,"f")){let r=1,i=1,s="",o=!1;for(;i<=Y(this,_n,"f").maxLineNumber;){const a=Y(this,Bt,"m",Sa).call(this,r++),l=Y(this,Bt,"m",ba).call(this,i);a?(s+=a.text,i=a.newLineNumber?a.newLineNumber+1:i):(l||(s+=Y(this,Bt,"m",gc).call(this,i)),i++),!o&&l&&a&&(o=o||l.noTrailingNewLine!==a.noTrailingNewLine)}if(!o&&s===this._newFileContent)return;this._oldFileContent=s,$e(this,un,Xo(this._oldFileContent,this._oldFileLang,Y(this,Kn,"f"),this._oldFileName,this.uuid?this.uuid+"-old":void 0)),Y(this,un,"f").enableTemplate=Y(this,Vr,"f")}Y(this,Bt,"m",mf).call(this)},gf=function(){var t;if(!(!((t=Y(this,Ps,"f"))===null||t===void 0)&&t.length))return;const n=l=>Y(this,Bt,"m",gc).call(this,l),r=l=>Y(this,Bt,"m",mc).call(this,l),i=l=>Y(this,Bt,"m",_v).call(this,l),s=l=>Y(this,Bt,"m",uv).call(this,l);$e(this,$s,[]),this.additionLength=0,this.deletionLength=0;const o=[];Y(this,Ps,"f").forEach(l=>{l.hunks.forEach(d=>{let u=[],_=[];d.lines.forEach(m=>{m.type===En.Add?(u.push(m),this.additionLength++):m.type===En.Delete?(_.push(m),this.deletionLength++):(cv(u,_,{getAdditionRaw:n,getDeletionRaw:r,getAdditionSyntax:i,getDeletionSyntax:s}),u=[],_=[]),o.push(m)}),cv(u,_,{getAdditionRaw:n,getDeletionRaw:r,getAdditionSyntax:i,getDeletionSyntax:s})})});let a=null;$e(this,$s,o.map((l,c)=>{var d;const u=l;if(u.index=c,u.isFirst=c===0,u.type===En.Hunk){const _=(d=u.text.split("@@"))===null||d===void 0?void 0:d[1].split(" ").filter(Boolean),m=(_==null?void 0:_[0])||"",g=(_==null?void 0:_[1])||"",[p,E]=m.split(","),[h,f]=g.split(",");u.hunkInfo={oldStartIndex:-Number(p),oldLength:Number(E),newStartIndex:+Number(h),newLength:Number(f),_oldStartIndex:-Number(p),_oldLength:Number(E),_newStartIndex:+Number(h),_newLength:Number(f)},a=u}else if(u.type===En.Context){const _=l;a&&(_.prevHunkLine=a,a=null)}else a=null;return u})),$e(this,Fs,{}),$e(this,Bs,{}),Y(this,$s,"f").forEach(l=>{l.oldLineNumber&&(this.diffLineLength=Math.max(this.diffLineLength,l.oldLineNumber),Y(this,Fs,"f")[l.oldLineNumber]=l),l.newLineNumber&&(this.diffLineLength=Math.max(this.diffLineLength,l.newLineNumber),Y(this,Bs,"f")[l.newLineNumber]=l)})},dv=function({registerHighlighter:t}){var n,r,i,s;(n=Y(this,un,"f"))===null||n===void 0||n.doSyntax({registerHighlighter:t,theme:Y(this,Kn,"f")}),$e(this,xs,(r=Y(this,un,"f"))===null||r===void 0?void 0:r.syntaxFile),(i=Y(this,_n,"f"))===null||i===void 0||i.doSyntax({registerHighlighter:t,theme:Y(this,Kn,"f")}),$e(this,Ds,(s=Y(this,_n,"f"))===null||s===void 0?void 0:s.syntaxFile)},vN=function({registerHighlighter:t}={}){var n,r,i,s;Y(this,Eo,"f")!=="class"&&(Y(this,uc,"f")&&!Y(this,_c,"f")||(Y(this,Bt,"m",dv).call(this,{registerHighlighter:t}),$e(this,ho,((n=Y(this,un,"f"))===null||n===void 0?void 0:n.highlighterName)||((r=Y(this,_n,"f"))===null||r===void 0?void 0:r.highlighterName)||Y(this,ho,"f")),$e(this,Eo,((i=Y(this,un,"f"))===null||i===void 0?void 0:i.highlighterType)||((s=Y(this,_n,"f"))===null||s===void 0?void 0:s.highlighterType)||Y(this,Eo,"f"))))},Sa=function(t){var n;if(t)return(n=Y(this,Fs,"f"))===null||n===void 0?void 0:n[t]},ba=function(t){var n;if(t)return(n=Y(this,Bs,"f"))===null||n===void 0?void 0:n[t]},mc=function(t){var n;return(n=Y(this,fo,"f"))===null||n===void 0?void 0:n[t]},gc=function(t){var n;return(n=Y(this,po,"f"))===null||n===void 0?void 0:n[t]},uv=function(t){var n;return(n=Y(this,xs,"f"))===null||n===void 0?void 0:n[t]},_v=function(t){var n;return(n=Y(this,Ds,"f"))===null||n===void 0?void 0:n[t]};var Xu;(function(e){e[e.hunk=1]="hunk",e[e.content=2]="content",e[e.widget=3]="widget",e[e.extend=4]="extend"})(Xu||(Xu={}));var Me;(function(e){e[e.old=1]="old",e[e.new=2]="new"})(Me||(Me={}));const yN=e=>{const t=e.splitLineLength,n=[];return uN(t,r=>{const i=e.getSplitLeftLine(r),s=e.getSplitRightLine(r);!(i!=null&&i.isHidden)&&!(s!=null&&s.isHidden)&&n.push({type:Xu.content,index:r,lineNumber:r+1,splitLine:{left:i,right:s}})}),n},M4=e=>{const t=e.unifiedLineLength,n=[];return uN(t,r=>{const i=e.getUnifiedLine(r);i.isHidden||n.push({type:Xu.content,index:r,lineNumber:r+1,unifiedLine:i})}),n};/**
113
113
  * @vue/shared v3.5.24
114
114
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
115
115
  * @license MIT
@@ -154,26 +154,26 @@ https://github.com/highlightjs/highlight.js/issues/2277`),j=R,P=D),w===void 0&&(
154
154
  ${r}
155
155
  \`\`\``:r}function em(e){if(e==null)return null;if(typeof e=="string")return{text:e};if(typeof e=="number"||typeof e=="boolean")return{text:String(e)};if(Array.isArray(e)){const t=e.map(n=>{const r=em(n);return(r==null?void 0:r.text)??""}).filter(Boolean);return t.length===0?null:{text:t.join(`
156
156
  `)}}if(typeof e=="object")try{return{text:JSON.stringify(e,null,2),language:"json"}}catch(t){return d8.error("Failed to stringify tool call output",t),{text:String(e)}}return null}function TA(e){return YC(e||"")}function CA(e,t){if(!t||!u8.has(e))return null;const{metadata:n,input:r,output:i}=Zn(t),s=[n.diff,i,n.output];let o=null;for(const l of s)if(typeof l=="string"&&K9(l)){o=l;break}if(!o)return null;const a=(typeof r.filePath=="string"?r.filePath:void 0)||(typeof n.filePath=="string"?n.filePath:void 0)||(typeof r.path=="string"?r.path:void 0);return{diffText:o,filePath:a}}function Zn(e){if(!e)return{input:{},metadata:{},output:void 0};const t=ud(e)||Zs(e)||J_(e);return{input:t?e.input||{}:{},metadata:t?e.metadata||{}:{},output:Zs(e)?e.output:void 0}}function tE(e){switch(e){case"task":return"Delegating...";case"bash":return"Writing command...";case"edit":return"Preparing edit...";case"webfetch":return"Fetching from the web...";case"glob":return"Finding files...";case"grep":return"Searching content...";case"list":return"Listing directory...";case"read":return"Reading file...";case"write":return"Preparing write...";case"todowrite":case"todoread":return"Planning...";case"patch":return"Preparing patch...";default:return"Working..."}}const RA={tools:["bash"],getAction:()=>"Writing command...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t),r=Xn("bash"),i=typeof n.description=="string"&&n.description.length>0?n.description:"",s=typeof n.timeout=="number"&&n.timeout>0?n.timeout:void 0,o=i?`${r} ${i}`:r;if(!s)return o;const a=`${s}ms`;return`${o} · Timeout: ${a}`},renderBody({toolState:e,renderMarkdown:t,renderAnsi:n}){const r=e();if(!r||r.status==="pending")return null;const{input:i,metadata:s}=Zn(r),o=typeof i.command=="string"&&i.command.length>0?`$ ${i.command}`:"",a=em(Zs(r)?r.output:(ud(r)||J_(r))&&s.output?s.output:void 0),l=[o,a==null?void 0:a.text].filter(Boolean);if(l.length===0)return null;const c=l.join(`
157
- `);if(r.status==="running")return n({content:c,variant:"running"});const d=n({content:c,requireAnsi:!0,variant:"final"});if(d)return d;const u=qo(c,"bash",!0);return u?t({content:u}):null}},nE={tools:["*"],renderBody({toolState:e,renderMarkdown:t}){const n=e();if(!n||n.status==="pending")return null;const{metadata:r,input:i}=Zn(n),s=Zs(n)?n.output:(ud(n)||J_(n))&&r.output?r.output:r.diff??r.preview??i.content,o=em(s);if(!o)return null;const a=qo(o.text,o.language,!0);return a?t({content:a,disableHighlight:n.status==="running"}):null}},IA={tools:["edit"],getAction:()=>"Preparing edit...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t),r=typeof n.filePath=="string"?n.filePath:"";return r?`${Xn("edit")} ${Mo(r)}`:Xn("edit")},renderBody({toolState:e,toolName:t,renderDiff:n,renderMarkdown:r}){const i=e();if(!i||i.status==="pending")return null;const s=CA(t(),i);if(s)return n(s);const{metadata:o}=Zn(i),a=typeof o.diff=="string"?o.diff:null,l=Zs(i)&&typeof i.output=="string"?i.output:null,c=qo(a||l,"diff",!0);return c?r({content:c,size:"large",disableHighlight:i.status==="running"}):null}},OA={tools:["patch"],getAction:()=>"Preparing patch...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t),r=typeof n.filePath=="string"?n.filePath:"";return r?`${Xn("patch")} ${Mo(r)}`:Xn("patch")},renderBody({toolState:e,toolName:t,renderDiff:n,renderMarkdown:r}){const i=e();if(!i||i.status==="pending")return null;const s=CA(t(),i);if(s)return n(s);const{metadata:o}=Zn(i),a=typeof o.diff=="string"?o.diff:null,l=Zs(i)&&typeof i.output=="string"?i.output:null,c=qo(a||l,"diff",!0);return c?r({content:c,size:"large",disableHighlight:i.status==="running"}):null}},NA={tools:["read"],getAction:()=>"Reading file...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t),r=typeof n.filePath=="string"?n.filePath:"",i=typeof n.offset=="number"?n.offset:void 0,s=typeof n.limit=="number"?n.limit:void 0,o=r?Mo(r):"",a=[];typeof i=="number"&&a.push(`Offset: ${i}`),typeof s=="number"&&a.push(`Limit: ${s}`);const l=o?`${Xn("read")} ${o}`:Xn("read");return a.length?`${l} · ${a.join(" · ")}`:l},renderBody({toolState:e,renderMarkdown:t}){const n=e();if(!n||n.status==="pending")return null;const{metadata:r,input:i}=Zn(n),s=typeof r.preview=="string"?r.preview:null,o=TA(typeof i.filePath=="string"?i.filePath:void 0),a=qo(s,o,!0);return a?t({content:a,disableHighlight:n.status==="running"}):null}},AA={tools:["write"],getAction:()=>"Preparing write...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t),r=typeof n.filePath=="string"?n.filePath:"";return r?`${Xn("write")} ${Mo(r)}`:Xn("write")},renderBody({toolState:e,renderMarkdown:t}){const n=e();if(!n||n.status==="pending")return null;const{metadata:r,input:i}=Zn(n),s=typeof i.content=="string"?i.content:r.content,o=typeof i.filePath=="string"?i.filePath:void 0,a=qo(s??null,TA(o),!0);return a?t({content:a,size:"large",disableHighlight:n.status==="running"}):null}},wA={tools:["webfetch"],getAction:()=>"Fetching from the web...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t);return typeof n.url=="string"&&n.url.length>0?`${Xn("webfetch")} ${n.url}`:Xn("webfetch")},renderBody({toolState:e,renderMarkdown:t}){const n=e();if(!n||n.status==="pending")return null;const{metadata:r}=Zn(n),i=em(n.status==="completed"?n.output:r.output);if(!i)return null;const s=qo(i.text,i.language,!0);return s?t({content:s,disableHighlight:n.status==="running"}):null}};var _8=x("<div class=tool-call-todo-empty>"),m8=x("<div class=tool-call-todo-region><div class=tool-call-todos role=list>"),g8=x("<span>"),f8=x("<div class=tool-call-todo-item role=listitem><span class=tool-call-todo-checkbox></span><div class=tool-call-todo-body><div class=tool-call-todo-heading><span class=tool-call-todo-text>");function p8(e){return e==="completed"||e==="in_progress"||e==="cancelled"?e:"pending"}function xA(e){if(!e)return[];const{metadata:t}=Zn(e),n=Array.isArray(t.todos)?t.todos:[],r=[];for(let i=0;i<n.length;i++){const s=n[i],o=typeof(s==null?void 0:s.content)=="string"?s.content.trim():"";if(!o)continue;const a=p8(s.status),l=typeof(s==null?void 0:s.id)=="string"&&s.id.length>0?s.id:`${i}-${o}`;r.push({id:l,content:o,status:a})}return r}function DA(e){return e.reduce((t,n)=>(t.total+=1,t[n.status]=(t[n.status]||0)+1,t),{total:0,pending:0,in_progress:0,completed:0,cancelled:0})}function h8(e){switch(e){case"completed":return"Completed";case"in_progress":return"In progress";case"cancelled":return"Cancelled";default:return"Pending"}}function LA(e){const t=xA(e.state);return DA(t).total===0?(()=>{var r=_8();return C(r,()=>e.emptyLabel??"No plan items yet."),r})():(()=>{var r=m8(),i=r.firstChild;return C(i,S(_t,{each:t,children:s=>{const o=h8(s.status);return(()=>{var a=f8(),l=a.firstChild,c=l.nextSibling,d=c.firstChild,u=d.firstChild;return Fe(l,"aria-label",o),C(u,()=>s.content),C(d,S(W,{get when(){return e.showStatusLabel!==!1},get children(){var _=g8();return C(_,o),ne(()=>rt(_,`tool-call-todo-status tool-call-todo-status-${s.status}`)),_}}),null),ne(_=>{var m=s.status==="completed",g=s.status==="cancelled",p=s.status==="in_progress",E=s.status;return m!==_.e&&a.classList.toggle("tool-call-todo-item-completed",_.e=m),g!==_.t&&a.classList.toggle("tool-call-todo-item-cancelled",_.t=g),p!==_.a&&a.classList.toggle("tool-call-todo-item-active",_.a=p),E!==_.o&&Fe(l,"data-status",_.o=E),_},{e:void 0,t:void 0,a:void 0,o:void 0}),a})()}})),r})()}function E8(e){if(!e)return"Plan";const t=xA(e);if(e.status!=="completed"||t.length===0)return"Plan";const n=DA(t);return n.pending===n.total?"Creating plan":n.completed===n.total?"Completing plan":"Updating plan"}const $f={tools:["todowrite","todoread"],getAction:()=>"Planning...",getTitle({toolState:e}){return E8(e())},renderBody({toolState:e}){const t=e();return t?S(LA,{state:t}):null}},kA={tools:["invalid"],getTitle({toolState:e}){const t=e();if(!t)return Xn("invalid");const{input:n}=Zn(t);return typeof n.tool=="string"?Xn(n.tool):Xn("invalid")},renderBody(e){return nE.renderBody(e)}},S8={bash:RA,read:NA,write:AA,edit:IA,patch:OA,webfetch:wA,todowrite:$f,todoread:$f,invalid:kA};function b8(e){return S8[e]??nE}function v8(e){return{id:"",type:"tool",tool:e.toolName,state:e.state}}function y8(e){return{toolCall:()=>v8(e),toolState:()=>e.state,toolName:()=>e.toolName,messageVersion:()=>{},partVersion:()=>{},renderMarkdown:()=>null,renderAnsi:()=>null,renderDiff:()=>null,scrollHelpers:void 0}}function MA(e){var a,l;const t=b8(e.toolName),n=y8(e),r=e.state,i=((a=t.getAction)==null?void 0:a.call(t,n))??tE(e.toolName);if(!r||r.status==="pending")return i;const s=typeof r.title=="string"?r.title:void 0;if(s&&s.length>0)return s;const o=(l=t.getTitle)==null?void 0:l.call(t,n);return o||Xn(e.toolName)}var T8=x('<div class="message-text tool-call-markdown tool-call-task-container"><div class=tool-call-task-summary>'),C8=x("<span class=tool-call-task-status>"),R8=x("<div class=tool-call-task-item><span class=tool-call-task-icon></span><span class=tool-call-task-label></span><span class=tool-call-task-separator aria-hidden=true>—</span><span class=tool-call-task-text>");function Dv(e){if(e==="pending"||e==="running"||e==="completed"||e==="error")return e}function I8(e){switch(e){case"pending":return"⏸";case"running":return"⏳";case"completed":return"✓";case"error":return"✗";default:return""}}function O8(e){switch(e){case"pending":return"Pending";case"running":return"Running";case"completed":return"Completed";case"error":return"Error";default:return"Unknown"}}function PA(e){const t=typeof e.description=="string"?e.description:void 0,n=typeof e.subagent_type=="string"?e.subagent_type:void 0,r=Xn("task");return t&&n?`${r}[${n}] ${t}`:t?`${r} ${t}`:r}function N8(e){return e.title&&e.title.length>0?e.title:e.tool==="task"?PA({...e.metadata,...e.input}):e.state?MA({toolName:e.tool,state:e.state}):tE(e.tool)}const A8={tools:["task"],getAction:()=>"Delegating...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t);return PA(n)},renderBody({toolState:e,messageVersion:t,partVersion:n,scrollHelpers:r}){const i=F(()=>{t==null||t(),n==null||n();const s=e();if(!s)return[];const{metadata:o}=Zn(s);return(Array.isArray(o.summary)?o.summary:[]).map((l,c)=>{const d=typeof(l==null?void 0:l.tool)=="string"?l.tool:"unknown",u=typeof(l==null?void 0:l.state)=="object"?l.state:void 0,_=typeof(l==null?void 0:l.metadata)=="object"&&l.metadata?l.metadata:{},m=typeof(l==null?void 0:l.input)=="object"&&l.input?l.input:{},g=typeof(l==null?void 0:l.id)=="string"&&l.id.length>0?l.id:`${d}-${c}`,p=Dv((l==null?void 0:l.status)??(u==null?void 0:u.status)),E=typeof(l==null?void 0:l.title)=="string"?l.title:void 0;return{id:g,tool:d,input:m,metadata:_,state:u,status:p,title:E}})});return i().length===0?null:(()=>{var s=T8(),o=s.firstChild;return Fn(s,"scroll",r?a=>r.handleScroll(a):void 0),wt(a=>r==null?void 0:r.registerContainer(a),s),C(o,S(_t,{get each(){return i()},children:a=>{var p;const l=Gc(a.tool),c=N8(a),d=Xn(a.tool),u=Dv(a.status??((p=a.state)==null?void 0:p.status)),_=I8(u),m=O8(u),g=u??"pending";return(()=>{var E=R8(),h=E.firstChild,f=h.nextSibling,b=f.nextSibling,y=b.nextSibling;return Fe(E,"data-task-status",g),C(h,l),C(f,d),C(y,c),C(E,S(W,{when:_,get children(){var v=C8();return Fe(v,"aria-label",m),Fe(v,"title",m),C(v,_),v}}),null),ne(()=>Fe(E,"data-task-id",a.id)),E})()}})),C(s,()=>{var a;return(a=r==null?void 0:r.renderSentinel)==null?void 0:a.call(r)},null),s})()}},w8={tools:["question"],getAction:()=>"Awaiting answers...",getTitle({toolState:e}){const t=e();return!t||t.status==="completed"?"Questions":"Asking questions"},renderBody(){return null}},x8=[RA,NA,AA,IA,OA,wA,$f,A8,w8,kA],D8=x8.reduce((e,t)=>(t.tools.forEach(n=>{e[n]=t}),e),{});function L8(e){return D8[e]??nE}var va=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],eg={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function k8(e,t){const n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){const r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function Lv(e){const t=e.shift();if(t==="2"){const n=e.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){const n=e.shift();if(n)return{type:"table",index:Number(n)}}}function M8(e){const t=[];for(;e.length>0;){const n=e.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)eg[r]&&t.push({type:"setDecoration",value:eg[r]});else if(r<=29){const i=eg[r-20];i&&(t.push({type:"resetDecoration",value:i}),i==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:va[r-30]}});else if(r===38){const i=Lv(e);i&&t.push({type:"setForegroundColor",value:i})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:va[r-40]}});else if(r===48){const i=Lv(e);i&&t.push({type:"setBackgroundColor",value:i})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:va[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:va[r-100+8]}})}return t}function Ff(){let e=null,t=null,n=new Set;return{parse(r){const i=[];let s=0;do{const o=k8(r,s),a=o.sequence?r.substring(s,o.startPosition):r.substring(s);if(a.length>0&&i.push({value:a,foreground:e,background:t,decorations:new Set(n)}),o.sequence){const l=M8(o.sequence);for(const c of l)c.type==="resetAll"?(e=null,t=null,n.clear()):c.type==="resetForegroundColor"?e=null:c.type==="resetBackgroundColor"?t=null:c.type==="resetDecoration"&&n.delete(c.value);for(const c of l)c.type==="setForegroundColor"?e=c.value:c.type==="setBackgroundColor"?t=c.value:c.type==="setDecoration"&&n.add(c.value)}s=o.position}while(s<r.length);return i}}}var P8={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function $8(e=P8){function t(a){return e[a]}function n(a){return`#${a.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function i(){if(r)return r;r=[];for(let c=0;c<va.length;c++)r.push(t(va[c]));let a=[0,95,135,175,215,255];for(let c=0;c<6;c++)for(let d=0;d<6;d++)for(let u=0;u<6;u++)r.push(n([a[c],a[d],a[u]]));let l=8;for(let c=0;c<24;c++,l+=10)r.push(n([l,l,l]));return r}function s(a){return i()[a]}function o(a){switch(a.type){case"named":return t(a.name);case"rgb":return n(a.rgb);case"table":return s(a.index)}}return{value:o}}const tg="\x1B",F8=/\\u001b|\\x1b|\\033/,B8=/\u001b/,kv=$8();function hc(e){const t=rE(e);return B8.test(t)}function U8(e){const t=rE(e),r=Ff().parse(t);return FA(r)}function $A(){let e=Ff();return{reset(){e=Ff()},render(t){const n=rE(t),r=e.parse(n);return FA(r)}}}function rE(e){return F8.test(e)?e.replace(/\\u001b/gi,tg).replace(/\\x1b/gi,tg).replace(/\\033/g,tg):e}function FA(e){let t="";for(const n of e){if(!n.value)continue;const r=G8(n),i=V8(n.value);if(!r){t+=i;continue}t+=`<span style="${r}">${i}</span>`}return t}function G8(e){const t=e.decorations;let n=e.foreground?kv.value(e.foreground):null,r=e.background?kv.value(e.background):null;if(t.has("reverse")){const o=n;n=r,r=o}const i=[];n&&i.push(`color: ${n}`),r&&i.push(`background-color: ${r}`),t.has("bold")&&i.push("font-weight: 600"),t.has("dim")&&i.push("opacity: 0.7"),t.has("italic")&&i.push("font-style: italic");const s=[];return t.has("underline")&&s.push("underline"),t.has("strikethrough")&&s.push("line-through"),t.has("overline")&&s.push("overline"),s.length>0&&i.push(`text-decoration-line: ${s.join(" ")}`),t.has("hidden")&&(i.push("color: transparent"),i.push("background-color: transparent")),i.length>0?i.join("; "):null}function V8(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;").replace(/'/g,"&#39;")}var H8=x("<div class=tool-call-diagnostics role=region aria-label=Diagnostics><div class=tool-call-diagnostics-body role=list>"),Y8=x("<div class=tool-call-diagnostics-wrapper><button type=button class=tool-call-diagnostics-heading><span class=tool-call-icon aria-hidden=true></span><span class=tool-call-emoji aria-hidden=true>🛠</span><span class=tool-call-summary>Diagnostics</span><span class=tool-call-diagnostics-file>"),z8=x("<div class=tool-call-diagnostic-row role=listitem><span><span class=tool-call-diagnostic-chip-icon></span><span></span></span><span class=tool-call-diagnostic-path><span class=tool-call-diagnostic-coords>:L<!>:C</span></span><span class=tool-call-diagnostic-message>"),W8=x("<div aria-hidden=true class=tool-call-scroll-sentinel style=height:1px>"),q8=x('<div class="message-text tool-call-markdown tool-call-markdown-large tool-call-diff-shell"><div class=tool-call-diff-toolbar role=group aria-label="Diff view mode"><span class=tool-call-diff-toolbar-label></span><div class=tool-call-diff-toggle><button type=button>Split</button><button type=button>Unified'),K8=x('<div><pre class="tool-call-content tool-call-ansi">'),Q8=x('<div><pre class="whitespace-pre-wrap break-words text-sm font-mono">'),j8=x("<div>"),X8=x("<div class=tool-call-error-content><strong>Error:</strong> "),Z8=x("<div class=tool-call-permission-actions><div class=tool-call-permission-buttons><button type=button class=tool-call-permission-button>Allow Once</button><button type=button class=tool-call-permission-button>Always Allow</button><button type=button class=tool-call-permission-button>Deny</button></div><div class=tool-call-permission-shortcuts><kbd class=kbd>Enter</kbd><span>Allow once</span><kbd class=kbd>A</kbd><span>Always allow</span><kbd class=kbd>D</kbd><span>Deny"),Mv=x("<div class=tool-call-permission-error>"),J8=x("<div><div class=tool-call-permission-header><span class=tool-call-permission-label></span><span class=tool-call-permission-type></span></div><div class=tool-call-permission-body><div class=tool-call-permission-title><code>"),e7=x("<div class=tool-call-permission-diff>"),t7=x("<p class=tool-call-permission-queued-text>Waiting for earlier permission responses."),n7=x("<div class=tool-call-permission-actions><div class=tool-call-permission-buttons><button type=button class=tool-call-permission-button>Submit</button><button type=button class=tool-call-permission-button>Dismiss</button></div><div class=tool-call-permission-shortcuts><kbd class=kbd>Enter</kbd><span>Submit</span><kbd class=kbd>Esc</kbd><span>Dismiss"),r7=x("<p class=tool-call-permission-queued-text>Waiting for earlier responses."),i7=x('<div><div class=tool-call-permission-header><span class=tool-call-permission-label></span><span class=tool-call-permission-type></span></div><div class=tool-call-permission-body><div class="flex flex-col gap-4">'),s7=x('<div class="text-xs text-muted">Multiple'),o7=x('<div class="mt-2 flex items-center gap-2"><input class="flex-1 rounded-md border border-base/50 bg-surface px-2 py-1 text-sm"type=text placeholder="Type your own answer"><button type=button class=tool-call-permission-button>'),a7=x('<div class="rounded-md border border-base/60 bg-surface/30 p-3"><div class="flex items-baseline justify-between gap-2"><div class=text-xs>Q<!>: <span class=font-semibold></span></div></div><div class="mt-1 text-sm font-medium"></div><div class="mt-3 flex flex-col gap-1">'),l7=x('<label><input><div class="flex flex-col"><div class="text-sm leading-tight"></div><div class="text-xs text-muted leading-tight">'),c7=x("<div><button class=tool-call-header><span class=tool-call-summary>"),d7=x("<div class=tool-call-pending-message><span class=spinner-small></span><span>Waiting to run..."),u7=x("<div class=tool-call-details>");const ng=vt("session"),_7="tool-call",Pv=48,m7=600,g7=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," ","Spacebar"]);function f7(e,t,n,r="default"){return`${t??"unknown-message"}:${n??e??"unknown-tool-call"}:${r}`}function rg(e){return e.replace(/\\/g,"/")}function p7(e){return e===1?"error":e===2?"warning":"info"}function h7(e){return e==="error"?{label:"ERR",icon:"!",rank:0}:e==="warning"?{label:"WARN",icon:"!",rank:1}:{label:"INFO",icon:"i",rank:2}}function E7(e){var d,u,_,m;if(!e)return[];if(!(ud(e)||Zs(e)||J_(e)))return[];const n=e.metadata||{},r=e.input||{},i=n==null?void 0:n.diagnostics;if(!i)return[];const s=[r.filePath,n.filePath,n.filepath,r.path].find(g=>typeof g=="string"&&g.length>0),o=s?rg(s):void 0;if(!o)return[];const a=Object.entries(i).filter(([,g])=>Array.isArray(g)&&g.length>0);if(a.length===0)return[];const l=a.filter(([g])=>rg(g)===o);if(l.length===0)return[];const c=[];for(const[g,p]of l){if(!Array.isArray(p))continue;const E=rg(g);for(let h=0;h<p.length;h++){const f=p[h];if(!f||typeof f.message!="string")continue;const b=p7(typeof f.severity=="number"?f.severity:void 0),y=h7(b),v=typeof((u=(d=f.range)==null?void 0:d.start)==null?void 0:u.line)=="number"?f.range.start.line+1:0,O=typeof((m=(_=f.range)==null?void 0:_.start)==null?void 0:m.character)=="number"?f.range.start.character+1:0;c.push({id:`${E}-${h}-${f.message}`,severity:y.rank,tone:b,label:y.label,icon:y.icon,message:f.message,filePath:E,displayPath:Mo(E),line:v,column:O})}}return c.sort((g,p)=>g.severity-p.severity)}function S7(e){const t=e[0];return t?t.displayPath:""}function b7(e,t,n,r){return e.length===0?null:(()=>{var i=Y8(),s=i.firstChild,o=s.firstChild,a=o.nextSibling,l=a.nextSibling,c=l.nextSibling;return Fn(s,"click",n,!0),Fe(s,"aria-expanded",t),C(o,t?"▼":"▶"),Fe(c,"title",r),C(c,r),C(i,S(W,{when:t,get children(){var d=H8(),u=d.firstChild;return C(u,S(_t,{each:e,children:_=>(()=>{var m=z8(),g=m.firstChild,p=g.firstChild,E=p.nextSibling,h=g.nextSibling,f=h.firstChild,b=f.firstChild,y=b.nextSibling;y.nextSibling;var v=h.nextSibling;return C(p,()=>_.icon),C(E,()=>_.label),C(h,()=>_.displayPath,f),C(f,()=>_.line||"-",y),C(f,()=>_.column||"-",null),C(v,()=>_.message),ne(O=>{var T=`tool-call-diagnostic-chip tool-call-diagnostic-${_.tone}`,I=_.filePath;return T!==O.e&&rt(g,O.e=T),I!==O.t&&Fe(h,"title",O.t=I),O},{e:void 0,t:void 0}),m})()})),d}}),null),i})()}function iE(e){const{preferences:t,setDiffViewMode:n}=ro(),{isDark:r}=eE(),i=F(()=>e.toolCall),s=F(()=>{var K;return((K=i())==null?void 0:K.tool)||""}),o=F(()=>{var _e;const K=(_e=i())==null?void 0:_e.id;if(!K)throw new Error("Tool call requires a part id");return K}),a=F(()=>{var K;return(K=i())==null?void 0:K.state}),l=F(()=>{var K;return{toolCallId:o(),messageId:e.messageId,partId:((K=i())==null?void 0:K.id)??null}}),c=F(()=>Ut.getOrCreate(e.instanceId)),d=F(()=>cR().get(e.instanceId)??null),u=F(()=>typeof e.partVersion=="number"?String(e.partVersion):typeof e.messageVersion=="number"?String(e.messageVersion):"noversion"),_=(K,_e)=>TO({instanceId:()=>e.instanceId,sessionId:()=>e.sessionId,scope:_7,cacheId:()=>{const Ye=l(),Xe=typeof K=="function"?K():K;return f7(Ye.toolCallId||void 0,Ye.messageId,Ye.partId,Xe)},version:()=>_e?_e():u()}),m=_("diff"),g=_("permission-diff"),p=_("ansi-running",()=>"running"),E=_("ansi-final"),h=$A();let f="";const b=F(()=>c().getPermissionState(e.messageId,o())),y=F(()=>{var _e;const K=b();return K?{permission:K.entry.permission,active:K.active}:(_e=i())==null?void 0:_e.pendingPermission}),v=F(()=>c().getQuestionState(e.messageId,o())),O=F(()=>{const K=v();if(K)return{request:K.entry.request,active:K.active}}),T=F(()=>(t().toolOutputExpansion||"expanded")==="expanded"),I=F(()=>(t().diagnosticsExpansion||"expanded")==="expanded"),k=F(()=>{var Ye;const K=T();return(((Ye=i())==null?void 0:Ye.tool)||"")==="read"?!1:K}),[A,V]=U(null),B=F(()=>{const K=y();if(!(K!=null&&K.permission))return!1;const _e=d();return(_e==null?void 0:_e.kind)==="permission"&&_e.id===K.permission.id}),$=F(()=>{const K=O();if(!(K!=null&&K.request))return!1;const _e=d();return(_e==null?void 0:_e.kind)==="question"&&_e.id===K.request.id}),M=()=>{if(B()||$())return!0;const K=A();return K!==null?K:k()},L=F(()=>{var K;return(K=y())==null?void 0:K.permission}),R=F(()=>{var K;return(K=O())==null?void 0:K.request}),D=F(()=>{const K=L();return K&&B()?K.id:""}),w=F(()=>{const K=R();return K&&$()?K.id:""}),[P,j]=U(!1),[le,me]=U(null),[Ae,ie]=U(void 0),re=()=>{if(B()||$())return!0;const K=Ae();return K!==void 0?K:I()},Ee=F(()=>{const K=a();return K?E7(K):[]}),[Se,q]=U(),[ae,N]=U(null),[H,te]=U(!0),[Q,z]=U(!0);let he,ue,ce,se=null,ke=null,We=0,Oe=0;function je(K=!1){const _e=ue;_e&&(K?(_e.scrollTop=_e.scrollHeight,Oe=_e.scrollTop):_e.scrollTop=Oe)}const dt=K=>{K&&(Oe=K.scrollTop)},Lt=()=>{requestAnimationFrame(()=>{je(H()),M()&&qe()})},be=K=>{ue=K||void 0,q(ue),ue&&je(H())};function ee(){We=(typeof performance<"u"?performance.now():Date.now())+m7}function Re(){return(typeof performance<"u"?performance.now():Date.now())<=We}function He(K){ce&&(ce(),ce=void 0);const _e=()=>ee(),Ye=Xe=>{g7.has(Xe.key)&&ee()};K.addEventListener("wheel",_e,{passive:!0}),K.addEventListener("pointerdown",_e),K.addEventListener("touchstart",_e,{passive:!0}),K.addEventListener("keydown",Ye),ce=()=>{K.removeEventListener("wheel",_e),K.removeEventListener("pointerdown",_e),K.removeEventListener("touchstart",_e),K.removeEventListener("keydown",Ye)}}function qe(K=!1){if(!H())return;const _e=ae(),Ye=ue;!_e||!Ye||(ke!==null&&(cancelAnimationFrame(ke),ke=null),ke=requestAnimationFrame(()=>{ke=null;const Xe=Ye.getBoundingClientRect(),kt=_e.getBoundingClientRect().bottom-Xe.bottom+Pv;Math.abs(kt)>1&&Ye.scrollBy({top:kt,behavior:K?"auto":"smooth"}),Oe=Ye.scrollTop}))}function de(){if(!Se())return;se!==null&&cancelAnimationFrame(se);const _e=Re();se=requestAnimationFrame(()=>{se=null;const Ye=Q();_e&&(Ye?H()||te(!0):H()&&te(!1))})}const Ce={registerContainer:(K,_e)=>{_e!=null&&_e.disableTracking||be(K)},handleScroll:K=>{de(),dt(K.currentTarget)},renderSentinel:K=>K!=null&&K.disableTracking?null:(()=>{var _e=W8();return wt(N,_e),_e})()};J(()=>{const K=Se();K&&(He(K),Ne(()=>{ce&&(ce(),ce=void 0)}))}),J(()=>{const K=Se(),_e=ae();if(!K||!_e)return;const Ye=new IntersectionObserver(Xe=>{Xe.forEach(ot=>{ot.target===_e&&z(ot.isIntersecting)})},{root:K,threshold:0,rootMargin:`0px 0px ${Pv}px 0px`});Ye.observe(_e),Ne(()=>Ye.disconnect())}),J(()=>{M()||(q(void 0),ue=void 0,N(null),te(!0))}),J(()=>{L()||j(!1),me(null)}),J(()=>{(D()||w())&&requestAnimationFrame(()=>{he==null||he.scrollIntoView({block:"center",behavior:"smooth"})})}),J(()=>{if(!D())return;const _e=Ye=>{Ye.key==="Enter"?(Ye.preventDefault(),ar("once")):Ye.key==="a"||Ye.key==="A"?(Ye.preventDefault(),ar("always")):(Ye.key==="d"||Ye.key==="D")&&(Ye.preventDefault(),ar("reject"))};document.addEventListener("keydown",_e),Ne(()=>document.removeEventListener("keydown",_e))});const[Ke,$e]=U(!1),[Be,tt]=U(null),[pt,at]=U({}),[mt,bt]=U({});function Ze(){const K=document.activeElement;return(K==null?void 0:K.tagName)==="TEXTAREA"||(K==null?void 0:K.tagName)==="INPUT"||((K==null?void 0:K.hasAttribute("contenteditable"))??!1)}async function Ve(){const K=R();if(!K||!$())return;const _e=(pt()[K.id]??[]).map(Xe=>Array.isArray(Xe)?Xe:[]),Ye=K.questions.map((Xe,ot)=>_e[ot]??[]);if(Ye.some(Xe=>((Xe==null?void 0:Xe.length)??0)===0)){tt("Please answer all questions before submitting.");return}$e(!0),tt(null);try{const Xe=K.sessionID??K.sessionId??e.sessionId;await SU(e.instanceId,Xe,K.id,Ye)}catch(Xe){ng.error("Failed to send question reply",Xe),tt(Xe instanceof Error?Xe.message:"Unable to reply")}finally{$e(!1)}}async function nt(){const K=R();if(!(!K||!$())){$e(!0),tt(null);try{const _e=K.sessionID??K.sessionId??e.sessionId;await bU(e.instanceId,_e,K.id)}catch(_e){ng.error("Failed to reject question",_e),tt(_e instanceof Error?_e.message:"Unable to dismiss")}finally{$e(!1)}}}J(()=>{if(!w())return;const _e=Ye=>{Ze()||(Ye.key==="Enter"?(Ye.preventDefault(),Ve()):Ye.key==="Escape"&&(Ye.preventDefault(),nt()))};document.addEventListener("keydown",_e),Ne(()=>document.removeEventListener("keydown",_e))});const ut=()=>{var _e;switch(((_e=a())==null?void 0:_e.status)||""){case"pending":return"⏸";case"running":return"⏳";case"completed":return"✓";case"error":return"✗";default:return""}},Yt=()=>{var _e;return`tool-call-status-${((_e=a())==null?void 0:_e.status)||"pending"}`},ye=()=>{const K=Yt();return y()||O()?`${K} tool-call-awaiting-permission`:K};function Ie(){const K=y();K!=null&&K.active||V(_e=>!(_e===null?k():_e))}const Ge=F(()=>L8(s()));function Qe(K,_e){const Ye=K.filePath?Mo(K.filePath):"",Xe=(_e==null?void 0:_e.label)||(Ye?`Diff · ${Ye}`:"Diff"),kt=((_e==null?void 0:_e.variant)==="permission-diff"?"permission-diff":"diff")==="permission-diff"?g:m,Nt=()=>t().diffViewMode||"split",zt=r()?"dark":"light";let Rt;const xn=kt.get(),Ot=Nt();xn&&xn.text===K.diffText&&xn.theme===zt&&xn.mode===Ot&&(Rt=xn.html);const Dn=jt=>{n(jt)},gi=()=>{var jt;_e!=null&&_e.disableScrollTracking||Lt(),(jt=e.onContentRendered)==null||jt.call(e)};return(()=>{var jt=q8(),jr=jt.firstChild,er=jr.firstChild,Ln=er.nextSibling,kr=Ln.firstChild,tr=kr.nextSibling;return Fn(jt,"scroll",_e!=null&&_e.disableScrollTracking?void 0:Ce.handleScroll),wt(Mt=>Ce.registerContainer(Mt,{disableTracking:_e==null?void 0:_e.disableScrollTracking}),jt),C(er,Xe),kr.$$click=()=>Dn("split"),tr.$$click=()=>Dn("unified"),C(jt,S(X9,{get diffText(){return K.diffText},get filePath(){return K.filePath},theme:zt,get mode(){return Nt()},cachedHtml:Rt,get cacheEntryParams(){return kt.params()},onRendered:gi}),null),C(jt,()=>Ce.renderSentinel({disableTracking:_e==null?void 0:_e.disableScrollTracking}),null),ne(Mt=>{var gn=`tool-call-diff-mode-button${Nt()==="split"?" active":""}`,rn=Nt()==="split",Xr=`tool-call-diff-mode-button${Nt()==="unified"?" active":""}`,nr=Nt()==="unified";return gn!==Mt.e&&rt(kr,Mt.e=gn),rn!==Mt.t&&Fe(kr,"aria-pressed",Mt.t=rn),Xr!==Mt.a&&rt(tr,Mt.a=Xr),nr!==Mt.o&&Fe(tr,"aria-pressed",Mt.o=nr),Mt},{e:void 0,t:void 0,a:void 0,o:void 0}),jt})()}function ct(K){if(!K.content)return null;const Ye=`message-text tool-call-markdown${(K.size||"default")==="large"?" tool-call-markdown-large":""}`,Xe=K.variant==="running"?p:E,ot=Xe.get(),kt=typeof e.partVersion=="number"?String(e.partVersion):void 0,Nt=K.variant==="running";let zt;if(Nt){const Rt=K.content;if(!ot||!ot.text||!Rt.startsWith(ot.text)||ot.text!==f)if(hc(Rt)){h.reset();const Dn=h.render(Rt);zt={text:Rt,html:Dn,mode:kt,hasAnsi:!0}}else h.reset(),zt={text:Rt,html:Si(Rt),mode:kt,hasAnsi:!1};else{const Ot=Rt.slice(ot.text.length);if(Ot.length===0)zt={...ot,mode:kt};else if(!ot.hasAnsi&&hc(Ot)){h.reset();const Dn=h.render(Rt);zt={text:Rt,html:Dn,mode:kt,hasAnsi:!0}}else if(ot.hasAnsi){const Dn=h.render(Ot);zt={text:Rt,html:`${ot.html}${Dn}`,mode:kt,hasAnsi:!0}}else zt={text:Rt,html:`${ot.html}${Si(Ot)}`,mode:kt,hasAnsi:!1}}f=zt.text,Xe.set(zt)}else if(ot&&ot.text===K.content)zt={...ot,mode:kt};else{const Rt=hc(K.content),xn=Rt?U8(K.content):Si(K.content);zt={text:K.content,html:xn,mode:kt,hasAnsi:Rt},Xe.set(zt)}return K.requireAnsi&&!zt.hasAnsi?null:(()=>{var Rt=K8(),xn=Rt.firstChild;return Fn(Rt,"scroll",Ce.handleScroll),wt(Ot=>Ce.registerContainer(Ot),Rt),rt(Rt,Ye),C(Rt,()=>Ce.renderSentinel(),null),ne(()=>xn.innerHTML=zt.html),Rt})()}function it(K){var xn;if(!K.content)return null;const _e=K.size||"default",Ye=K.disableHighlight||!1,Xe=`message-text tool-call-markdown${_e==="large"?" tool-call-markdown-large":""}`,ot=a();if(!!(ot&&(ot.status==="running"||ot.status==="pending")&&Ye))return(()=>{var Ot=Q8(),Dn=Ot.firstChild;return Fn(Ot,"scroll",Ce.handleScroll),wt(gi=>Ce.registerContainer(gi),Ot),rt(Ot,Xe),C(Dn,()=>K.content),C(Ot,()=>Ce.renderSentinel(),null),Ot})();const Nt=(xn=i())==null?void 0:xn.id;if(!Nt)throw new Error("Tool call markdown requires a part id");const zt={id:Nt,type:"text",text:K.content,version:e.partVersion},Rt=()=>{var Ot;Lt(),(Ot=e.onContentRendered)==null||Ot.call(e)};return(()=>{var Ot=j8();return Fn(Ot,"scroll",Ce.handleScroll),wt(Dn=>Ce.registerContainer(Dn),Ot),rt(Ot,Xe),C(Ot,S(CO,{part:zt,get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get isDark(){return r()},disableHighlight:Ye,onRendered:Rt}),null),C(Ot,()=>Ce.renderSentinel(),null),Ot})()}const gt=F(()=>e.messageVersion),yt=F(()=>e.partVersion),nn={toolCall:i,toolState:a,toolName:s,messageVersion:gt,partVersion:yt,renderMarkdown:it,renderAnsi:ct,renderDiff:Qe,scrollHelpers:Ce};let Rn;J(()=>{const K=yt();M()&&K!==void 0&&(Rn!==void 0&&K===Rn||(Rn=K,qe()))}),J(()=>{M()&&H()&&qe(!0)});const yr=()=>{var K,_e;return((_e=(K=Ge()).getAction)==null?void 0:_e.call(K,nn))??tE(s())},Rs=()=>{var Xe,ot;const K=a(),_e=s();if(_e!=="task")return MA({toolName:_e,state:K});if(!K||K.status==="pending")return yr();const Ye=(ot=(Xe=Ge()).getTitle)==null?void 0:ot.call(Xe,nn);return Ye||(ud(K)&&K.title||Zs(K)&&K.title?K.title:Xn(_e))},Lr=()=>Ge().renderBody(nn);async function ar(K){const _e=L();if(!(!_e||!B())){j(!0),me(null);try{const Ye=jc(_e)||e.sessionId;await vU(e.instanceId,Ye,_e.id,K)}catch(Ye){ng.error("Failed to send permission response",Ye),me(Ye instanceof Error?Ye.message:"Unable to update permission")}finally{j(!1)}}}const mi=()=>{const K=a()||{};return K.status==="error"&&K.error?(()=>{var _e=X8(),Ye=_e.firstChild;return Ye.nextSibling,C(_e,()=>K.error,null),_e})():null},yl=()=>{const K=L();if(!K)return null;const _e=B(),Ye=K.metadata??{},Xe=typeof Ye.diff=="string"?Ye.diff:null,ot=(()=>{if(typeof Ye.filePath=="string")return Ye.filePath;if(typeof Ye.path=="string")return Ye.path})(),kt=Xe&&Xe.trim().length>0?{diffText:Xe,filePath:ot}:null;return(()=>{var Nt=J8(),zt=Nt.firstChild,Rt=zt.firstChild,xn=Rt.nextSibling,Ot=zt.nextSibling,Dn=Ot.firstChild,gi=Dn.firstChild;return rt(Nt,`tool-call-permission ${_e?"tool-call-permission-active":"tool-call-permission-queued"}`),C(Rt,_e?"Permission Required":"Permission Queued"),C(xn,()=>h_(K)),C(gi,()=>RT(K)),C(Ot,S(W,{when:kt,children:jt=>(()=>{var jr=e7();return C(jr,()=>Qe(jt(),{variant:"permission-diff",disableScrollTracking:!0,label:jt().filePath?`Requested diff · ${Mo(jt().filePath||"")}`:"Requested diff"})),jr})()}),null),C(Ot,S(W,{when:_e,get fallback(){return t7()},get children(){return[(()=>{var jt=Z8(),jr=jt.firstChild,er=jr.firstChild,Ln=er.nextSibling,kr=Ln.nextSibling;return er.$$click=()=>ar("once"),Ln.$$click=()=>ar("always"),kr.$$click=()=>ar("reject"),ne(tr=>{var Mt=P(),gn=P(),rn=P();return Mt!==tr.e&&(er.disabled=tr.e=Mt),gn!==tr.t&&(Ln.disabled=tr.t=gn),rn!==tr.a&&(kr.disabled=tr.a=rn),tr},{e:void 0,t:void 0,a:void 0}),jt})(),S(W,{get when(){return le()},get children(){var jt=Mv();return C(jt,le),jt}})]}}),null),Nt})()},Tl=()=>{var er,Ln,kr,tr;const K=a(),_e=R(),Ye=s()==="question";if(!_e&&!Ye)return null;const Xe=(_e==null?void 0:_e.questions)??((er=K==null?void 0:K.input)==null?void 0:er.questions)??[],ot=Array.isArray(Xe)?Xe:[];if(ot.length===0)return null;const kt=(_e==null?void 0:_e.id)??((Ln=K==null?void 0:K.input)==null?void 0:Ln.requestID)??`question-${((kr=i())==null?void 0:kr.id)??"unknown"}`,Nt=!!(_e&&$()),Rt=(Array.isArray((tr=K==null?void 0:K.metadata)==null?void 0:tr.answers)?K.metadata.answers:void 0)??pt()[kt]??[],xn=mt()[kt]??[],Ot=(Mt,gn)=>{Nt&&at(rn=>{const nr=[...rn[kt]??[]];return nr[Mt]=gn,{...rn,[kt]:nr}})},Dn=(Mt,gn)=>{Nt&&bt(rn=>{const nr=[...rn[kt]??[]];return nr[Mt]=gn,{...rn,[kt]:nr}})},gi=(Mt,gn)=>{const rn=ot[Mt],Xr=(rn==null?void 0:rn.multiple)===!0,nr=Rt[Mt]??[];if(Xr){const Is=nr.includes(gn)?nr.filter(In=>In!==gn):[...nr,gn];Ot(Mt,Is);return}Ot(Mt,[gn])},jt=()=>!Nt||Ke()?!0:ot.some((Mt,gn)=>{var rn;return(((rn=Rt[gn])==null?void 0:rn.length)??0)===0}),jr=()=>Nt;return(()=>{var Mt=i7(),gn=Mt.firstChild,rn=gn.firstChild,Xr=rn.nextSibling,nr=gn.nextSibling,Is=nr.firstChild;return rt(Mt,`tool-call-permission ${Nt?"tool-call-permission-active":"tool-call-permission-queued"}`),C(rn,Nt?"Question Required":_e?"Question Queued":"Questions"),C(Xr,()=>ot.length===1?"Question":"Questions"),C(Is,S(_t,{each:ot,children:(In,Os)=>{const gr=()=>Os(),Z=()=>(In==null?void 0:In.multiple)===!0,fe=()=>Rt[gr()]??[],Ue=()=>xn[gr()]??"",st=()=>Z()?"checkbox":"radio",At=()=>`question-${kt}-${gr()}`;return(()=>{var Ct=a7(),xt=Ct.firstChild,Pt=xt.firstChild,Vt=Pt.firstChild,On=Vt.nextSibling,fr=On.nextSibling,xi=fr.nextSibling,Mr=xt.nextSibling,ji=Mr.nextSibling;return C(Pt,()=>gr()+1,On),C(xi,()=>In==null?void 0:In.header),C(xt,S(W,{get when(){return Z()},get children(){return s7()}}),null),C(Mr,()=>In==null?void 0:In.question),C(ji,S(_t,{get each(){return(In==null?void 0:In.options)??[]},children:fn=>{const Wn=()=>fe().includes(fn.label);return(()=>{var rr=l7(),sn=rr.firstChild,Xi=sn.nextSibling,Zi=Xi.firstChild,mE=Zi.nextSibling;return rt(rr,`flex items-start gap-2 py-1 ${Nt?"cursor-pointer":_e?"opacity-80":""}`),sn.addEventListener("change",()=>gi(gr(),fn.label)),C(Zi,()=>fn.label),C(mE,()=>fn.description),ne(Ji=>{var gE=fn.description,fE=st(),pE=At(),hE=!Nt||Ke();return gE!==Ji.e&&Fe(rr,"title",Ji.e=gE),fE!==Ji.t&&Fe(sn,"type",Ji.t=fE),pE!==Ji.a&&Fe(sn,"name",Ji.a=pE),hE!==Ji.o&&(sn.disabled=Ji.o=hE),Ji},{e:void 0,t:void 0,a:void 0,o:void 0}),ne(()=>sn.checked=Wn()),rr})()}}),null),C(ji,S(W,{when:Nt,get children(){var fn=o7(),Wn=fn.firstChild,rr=Wn.nextSibling;return Wn.$$input=sn=>Dn(gr(),sn.currentTarget.value),rr.$$click=()=>{const sn=Ue().trim();sn&&(Dn(gr(),sn),gi(gr(),sn))},C(rr,()=>Z()?"Toggle":"Select"),ne(sn=>{var Xi=!Nt||Ke(),Zi=!Nt||Ke()||!Ue().trim();return Xi!==sn.e&&(Wn.disabled=sn.e=Xi),Zi!==sn.t&&(rr.disabled=sn.t=Zi),sn},{e:void 0,t:void 0}),ne(()=>Wn.value=Ue()),fn}}),null),Ct})()}}),null),C(Is,S(W,{get when(){return jr()},get children(){var In=n7(),Os=In.firstChild,gr=Os.firstChild,Z=gr.nextSibling;return Os.nextSibling,gr.$$click=()=>Ve(),Z.$$click=()=>nt(),C(In,S(W,{get when(){return Be()},get children(){var fe=Mv();return C(fe,Be),fe}}),null),ne(fe=>{var Ue=jt(),st=Ke();return Ue!==fe.e&&(gr.disabled=fe.e=Ue),st!==fe.t&&(Z.disabled=fe.t=st),fe},{e:void 0,t:void 0}),In}}),null),C(Is,S(W,{when:!Nt&&_e,get children(){return r7()}}),null),Mt})()};J(()=>{const K=R();if(!K){$e(!1),tt(null);return}tt(null);const _e=K.id;at(Ye=>{if(Ye[_e])return Ye;const Xe=K.questions.map(()=>[]);return{...Ye,[_e]:Xe}}),bt(Ye=>{if(Ye[_e])return Ye;const Xe=K.questions.map(()=>"");return{...Ye,[_e]:Xe}})});const Cl=()=>{var K;return((K=a())==null?void 0:K.status)||""};return Ne(()=>{se!==null&&(cancelAnimationFrame(se),se=null),ke!==null&&(cancelAnimationFrame(ke),ke=null),ce&&(ce(),ce=void 0)}),(()=>{var K=c7(),_e=K.firstChild,Ye=_e.firstChild;return wt(Xe=>{he=Xe||void 0},K),_e.$$click=Ie,C(Ye,Rs),C(K,(()=>{var Xe=we(()=>!!M());return()=>Xe()&&(()=>{var ot=u7();return C(ot,Lr,null),C(ot,mi,null),C(ot,yl,null),C(ot,Tl,null),C(ot,S(W,{get when(){return we(()=>Cl()==="pending")()&&!y()},get children(){return d7()}}),null),ot})()})(),null),C(K,S(W,{get when(){return Ee().length},get children(){return b7(Ee(),re(),()=>ie(Xe=>!(Xe===void 0?I():Xe)),S7(Ee()))}}),null),ne(Xe=>{var ot=`tool-call ${ye()}`,kt=M(),Nt=ut(),zt=Gc(s());return ot!==Xe.e&&rt(K,Xe.e=ot),kt!==Xe.t&&Fe(_e,"aria-expanded",Xe.t=kt),Nt!==Xe.a&&Fe(_e,"data-status-icon",Xe.a=Nt),zt!==Xe.o&&Fe(Ye,"data-tool-icon",Xe.o=zt),Xe},{e:void 0,t:void 0,a:void 0,o:void 0}),K})()}Ht(["click","input"]);const[Yne,zne]=U(new Set);var v7=x("<div>"),y7=x("<span>");function T7(e){const{isDark:t}=eE(),{preferences:n}=ro(),r=()=>{var l;return((l=e.part)==null?void 0:l.type)||""},i=()=>e.messageType==="assistant",s=()=>i()?"message-text message-text-assistant":"message-text",o=()=>{const l=e.part;return(l.type==="text"||l.type==="reasoning")&&typeof l.text=="string"?l.text:""},a=()=>{const l=e.part;return(l.type==="text"||l.type==="reasoning")&&typeof l.text=="string"?{id:l.id,type:"text",text:l.text,synthetic:l.type==="text"?l.synthetic:!1,version:l.version}:{id:l.id,type:"text",text:"",synthetic:!1}};return S(Wc,{get children(){return[S(sr,{get when(){return r()==="text"},get children(){return S(W,{get when(){return we(()=>!(e.part.type==="text"&&e.part.synthetic))()&&yh(e.part)},get children(){var l=v7();return C(l,S(W,{get when(){return i()},get fallback(){return(()=>{var c=y7();return C(c,o),c})()},get children(){return S(CO,{get part(){return a()},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get isDark(){return t()},get size(){return i()?"tight":"base"},get onRendered(){return e.onRendered}})}})),ne(()=>rt(l,s())),l}})}}),S(sr,{get when(){return r()==="tool"},get children(){return S(iE,{get toolCall(){return e.part},get toolCallId(){var l;return(l=e.part)==null?void 0:l.id},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId}})}})]}})}var C7=x('<button class=message-action-button title="Revert to this message"aria-label="Revert to this message">Revert'),R7=x('<button class=message-action-button title="Fork from this message"aria-label="Fork from this message">Fork'),I7=x('<div class=message-action-group><button class=message-action-button title="Copy message"aria-label="Copy message">'),O7=x('<button class=message-action-button title="Copy message"aria-label="Copy message">'),N7=x("<div class=message-queued-badge>QUEUED"),A7=x("<div class=message-error-block>⚠️ "),w7=x("<div class=message-generating><span class=generating-spinner>⏳</span> Generating..."),x7=x('<div class="message-attachments mt-1">'),D7=x("<div class=message-sending><span class=generating-spinner>●</span> Sending..."),L7=x("<div class=message-error>⚠ Message failed to send"),k7=x('<div><header><div class=message-speaker><span class=message-speaker-label></span></div><div class=message-item-actions><time class=message-timestamp></time></div></header><div class="pt-1 whitespace-pre-wrap break-words leading-[1.1]">'),M7=x("<span class=message-agent-meta>"),P7=x('<img class="h-5 w-5 rounded object-cover">'),$7=x("<div class=attachment-chip-preview><img>"),F7=x('<div><span class="truncate max-w-[180px]"></span><button type=button class=attachment-download><svg class="h-3 w-3"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M4 16v2a2 2 0 002 2h12a2 2 0 002-2v-2"></path><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M8 12l4 4 4-4m-4-8v12">'),B7=x('<svg class="h-3 w-3"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2">');function U7(e){const[t,n]=U(!1),r=()=>e.record.role==="user",i=()=>{var T,I;return((I=(T=e.messageInfo)==null?void 0:T.time)==null?void 0:I.created)??e.record.createdAt},s=()=>new Date(i()).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),o=()=>new Date(i()).toISOString(),a=()=>e.parts,l=()=>a().filter(T=>(T==null?void 0:T.type)==="file"&&typeof T.url=="string"),c=T=>{if(T.filename&&T.filename.trim().length>0)return T.filename;const I=T.url||"";if(I.startsWith("data:"))return"attachment";try{return new URL(I).pathname.split("/").pop()||"attachment"}catch{const A=I.split("/").pop();return A&&A.length>0?A:"attachment"}},d=T=>T.mime&&typeof T.mime=="string"&&T.mime.startsWith("image/")?!0:typeof T.url=="string"&&T.url.startsWith("data:image/"),u=async T=>{const I=T.url;if(!I)return;const k=c(T),A=V=>{const B=document.createElement("a");B.href=V,B.download=k,B.target="_blank",B.rel="noopener",document.body.appendChild(B),B.click(),document.body.removeChild(B)};if(I.startsWith("data:")){A(I);return}if(I.startsWith("file://")){window.open(I,"_blank","noopener");return}try{const V=await fetch(I);if(!V.ok)throw new Error(`Failed to fetch attachment: ${V.status}`);const B=await V.blob(),$=URL.createObjectURL(B);A($),URL.revokeObjectURL($)}catch{A(I)}},_=()=>{var k,A;const T=e.messageInfo;if(!T||T.role!=="assistant"||!T.error)return null;const I=T.error;return I.name==="ProviderAuthError"?((k=I.data)==null?void 0:k.message)||"Authentication error":I.name==="MessageOutputLengthError"?"Message output length exceeded":I.name==="MessageAbortedError"?"Request was aborted":I.name==="UnknownError"?((A=I.data)==null?void 0:A.message)||"Unknown error occurred":null},m=()=>_()!==null?!0:a().some(T=>yh(T)),g=()=>{const T=e.messageInfo;return!m()&&T&&T.role==="assistant"&&T.time.completed!==void 0&&T.time.completed===0},p=()=>{e.onRevert&&r()&&e.onRevert(e.record.id)},E=()=>e.parts.filter(T=>T.type==="text").map(T=>T.text||"").filter(T=>T.trim().length>0).join(`
157
+ `);if(r.status==="running")return n({content:c,variant:"running"});const d=n({content:c,requireAnsi:!0,variant:"final"});if(d)return d;const u=qo(c,"bash",!0);return u?t({content:u}):null}},nE={tools:["*"],renderBody({toolState:e,renderMarkdown:t}){const n=e();if(!n||n.status==="pending")return null;const{metadata:r,input:i}=Zn(n),s=Zs(n)?n.output:(ud(n)||J_(n))&&r.output?r.output:r.diff??r.preview??i.content,o=em(s);if(!o)return null;const a=qo(o.text,o.language,!0);return a?t({content:a,disableHighlight:n.status==="running"}):null}},IA={tools:["edit"],getAction:()=>"Preparing edit...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t),r=typeof n.filePath=="string"?n.filePath:"";return r?`${Xn("edit")} ${Mo(r)}`:Xn("edit")},renderBody({toolState:e,toolName:t,renderDiff:n,renderMarkdown:r}){const i=e();if(!i||i.status==="pending")return null;const s=CA(t(),i);if(s)return n(s);const{metadata:o}=Zn(i),a=typeof o.diff=="string"?o.diff:null,l=Zs(i)&&typeof i.output=="string"?i.output:null,c=qo(a||l,"diff",!0);return c?r({content:c,size:"large",disableHighlight:i.status==="running"}):null}},OA={tools:["patch"],getAction:()=>"Preparing patch...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t),r=typeof n.filePath=="string"?n.filePath:"";return r?`${Xn("patch")} ${Mo(r)}`:Xn("patch")},renderBody({toolState:e,toolName:t,renderDiff:n,renderMarkdown:r}){const i=e();if(!i||i.status==="pending")return null;const s=CA(t(),i);if(s)return n(s);const{metadata:o}=Zn(i),a=typeof o.diff=="string"?o.diff:null,l=Zs(i)&&typeof i.output=="string"?i.output:null,c=qo(a||l,"diff",!0);return c?r({content:c,size:"large",disableHighlight:i.status==="running"}):null}},NA={tools:["read"],getAction:()=>"Reading file...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t),r=typeof n.filePath=="string"?n.filePath:"",i=typeof n.offset=="number"?n.offset:void 0,s=typeof n.limit=="number"?n.limit:void 0,o=r?Mo(r):"",a=[];typeof i=="number"&&a.push(`Offset: ${i}`),typeof s=="number"&&a.push(`Limit: ${s}`);const l=o?`${Xn("read")} ${o}`:Xn("read");return a.length?`${l} · ${a.join(" · ")}`:l},renderBody({toolState:e,renderMarkdown:t}){const n=e();if(!n||n.status==="pending")return null;const{metadata:r,input:i}=Zn(n),s=typeof r.preview=="string"?r.preview:null,o=TA(typeof i.filePath=="string"?i.filePath:void 0),a=qo(s,o,!0);return a?t({content:a,disableHighlight:n.status==="running"}):null}},AA={tools:["write"],getAction:()=>"Preparing write...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t),r=typeof n.filePath=="string"?n.filePath:"";return r?`${Xn("write")} ${Mo(r)}`:Xn("write")},renderBody({toolState:e,renderMarkdown:t}){const n=e();if(!n||n.status==="pending")return null;const{metadata:r,input:i}=Zn(n),s=typeof i.content=="string"?i.content:r.content,o=typeof i.filePath=="string"?i.filePath:void 0,a=qo(s??null,TA(o),!0);return a?t({content:a,size:"large",disableHighlight:n.status==="running"}):null}},wA={tools:["webfetch"],getAction:()=>"Fetching from the web...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t);return typeof n.url=="string"&&n.url.length>0?`${Xn("webfetch")} ${n.url}`:Xn("webfetch")},renderBody({toolState:e,renderMarkdown:t}){const n=e();if(!n||n.status==="pending")return null;const{metadata:r}=Zn(n),i=em(n.status==="completed"?n.output:r.output);if(!i)return null;const s=qo(i.text,i.language,!0);return s?t({content:s,disableHighlight:n.status==="running"}):null}};var _8=x("<div class=tool-call-todo-empty>"),m8=x("<div class=tool-call-todo-region><div class=tool-call-todos role=list>"),g8=x("<span>"),f8=x("<div class=tool-call-todo-item role=listitem><span class=tool-call-todo-checkbox></span><div class=tool-call-todo-body><div class=tool-call-todo-heading><span class=tool-call-todo-text>");function p8(e){return e==="completed"||e==="in_progress"||e==="cancelled"?e:"pending"}function xA(e){if(!e)return[];const{metadata:t}=Zn(e),n=Array.isArray(t.todos)?t.todos:[],r=[];for(let i=0;i<n.length;i++){const s=n[i],o=typeof(s==null?void 0:s.content)=="string"?s.content.trim():"";if(!o)continue;const a=p8(s.status),l=typeof(s==null?void 0:s.id)=="string"&&s.id.length>0?s.id:`${i}-${o}`;r.push({id:l,content:o,status:a})}return r}function DA(e){return e.reduce((t,n)=>(t.total+=1,t[n.status]=(t[n.status]||0)+1,t),{total:0,pending:0,in_progress:0,completed:0,cancelled:0})}function h8(e){switch(e){case"completed":return"Completed";case"in_progress":return"In progress";case"cancelled":return"Cancelled";default:return"Pending"}}function LA(e){const t=xA(e.state);return DA(t).total===0?(()=>{var r=_8();return C(r,()=>e.emptyLabel??"No plan items yet."),r})():(()=>{var r=m8(),i=r.firstChild;return C(i,S(_t,{each:t,children:s=>{const o=h8(s.status);return(()=>{var a=f8(),l=a.firstChild,c=l.nextSibling,d=c.firstChild,u=d.firstChild;return Fe(l,"aria-label",o),C(u,()=>s.content),C(d,S(W,{get when(){return e.showStatusLabel!==!1},get children(){var _=g8();return C(_,o),ne(()=>rt(_,`tool-call-todo-status tool-call-todo-status-${s.status}`)),_}}),null),ne(_=>{var m=s.status==="completed",g=s.status==="cancelled",p=s.status==="in_progress",E=s.status;return m!==_.e&&a.classList.toggle("tool-call-todo-item-completed",_.e=m),g!==_.t&&a.classList.toggle("tool-call-todo-item-cancelled",_.t=g),p!==_.a&&a.classList.toggle("tool-call-todo-item-active",_.a=p),E!==_.o&&Fe(l,"data-status",_.o=E),_},{e:void 0,t:void 0,a:void 0,o:void 0}),a})()}})),r})()}function E8(e){if(!e)return"Plan";const t=xA(e);if(e.status!=="completed"||t.length===0)return"Plan";const n=DA(t);return n.pending===n.total?"Creating plan":n.completed===n.total?"Completing plan":"Updating plan"}const $f={tools:["todowrite","todoread"],getAction:()=>"Planning...",getTitle({toolState:e}){return E8(e())},renderBody({toolState:e}){const t=e();return t?S(LA,{state:t}):null}},kA={tools:["invalid"],getTitle({toolState:e}){const t=e();if(!t)return Xn("invalid");const{input:n}=Zn(t);return typeof n.tool=="string"?Xn(n.tool):Xn("invalid")},renderBody(e){return nE.renderBody(e)}},S8={bash:RA,read:NA,write:AA,edit:IA,patch:OA,webfetch:wA,todowrite:$f,todoread:$f,invalid:kA};function b8(e){return S8[e]??nE}function v8(e){return{id:"",type:"tool",tool:e.toolName,state:e.state}}function y8(e){return{toolCall:()=>v8(e),toolState:()=>e.state,toolName:()=>e.toolName,messageVersion:()=>{},partVersion:()=>{},renderMarkdown:()=>null,renderAnsi:()=>null,renderDiff:()=>null,scrollHelpers:void 0}}function MA(e){var a,l;const t=b8(e.toolName),n=y8(e),r=e.state,i=((a=t.getAction)==null?void 0:a.call(t,n))??tE(e.toolName);if(!r||r.status==="pending")return i;const s=typeof r.title=="string"?r.title:void 0;if(s&&s.length>0)return s;const o=(l=t.getTitle)==null?void 0:l.call(t,n);return o||Xn(e.toolName)}var T8=x('<div class="message-text tool-call-markdown tool-call-task-container"><div class=tool-call-task-summary>'),C8=x("<span class=tool-call-task-status>"),R8=x("<div class=tool-call-task-item><span class=tool-call-task-icon></span><span class=tool-call-task-label></span><span class=tool-call-task-separator aria-hidden=true>—</span><span class=tool-call-task-text>");function Dv(e){if(e==="pending"||e==="running"||e==="completed"||e==="error")return e}function I8(e){switch(e){case"pending":return"⏸";case"running":return"⏳";case"completed":return"✓";case"error":return"✗";default:return""}}function O8(e){switch(e){case"pending":return"Pending";case"running":return"Running";case"completed":return"Completed";case"error":return"Error";default:return"Unknown"}}function PA(e){const t=typeof e.description=="string"?e.description:void 0,n=typeof e.subagent_type=="string"?e.subagent_type:void 0,r=Xn("task");return t&&n?`${r}[${n}] ${t}`:t?`${r} ${t}`:r}function N8(e){return e.title&&e.title.length>0?e.title:e.tool==="task"?PA({...e.metadata,...e.input}):e.state?MA({toolName:e.tool,state:e.state}):tE(e.tool)}const A8={tools:["task"],getAction:()=>"Delegating...",getTitle({toolState:e}){const t=e();if(!t)return;const{input:n}=Zn(t);return PA(n)},renderBody({toolState:e,messageVersion:t,partVersion:n,scrollHelpers:r}){const i=F(()=>{t==null||t(),n==null||n();const s=e();if(!s)return[];const{metadata:o}=Zn(s);return(Array.isArray(o.summary)?o.summary:[]).map((l,c)=>{const d=typeof(l==null?void 0:l.tool)=="string"?l.tool:"unknown",u=typeof(l==null?void 0:l.state)=="object"?l.state:void 0,_=typeof(l==null?void 0:l.metadata)=="object"&&l.metadata?l.metadata:{},m=typeof(l==null?void 0:l.input)=="object"&&l.input?l.input:{},g=typeof(l==null?void 0:l.id)=="string"&&l.id.length>0?l.id:`${d}-${c}`,p=Dv((l==null?void 0:l.status)??(u==null?void 0:u.status)),E=typeof(l==null?void 0:l.title)=="string"?l.title:void 0;return{id:g,tool:d,input:m,metadata:_,state:u,status:p,title:E}})});return i().length===0?null:(()=>{var s=T8(),o=s.firstChild;return Fn(s,"scroll",r?a=>r.handleScroll(a):void 0),wt(a=>r==null?void 0:r.registerContainer(a),s),C(o,S(_t,{get each(){return i()},children:a=>{var p;const l=Gc(a.tool),c=N8(a),d=Xn(a.tool),u=Dv(a.status??((p=a.state)==null?void 0:p.status)),_=I8(u),m=O8(u),g=u??"pending";return(()=>{var E=R8(),h=E.firstChild,f=h.nextSibling,b=f.nextSibling,y=b.nextSibling;return Fe(E,"data-task-status",g),C(h,l),C(f,d),C(y,c),C(E,S(W,{when:_,get children(){var v=C8();return Fe(v,"aria-label",m),Fe(v,"title",m),C(v,_),v}}),null),ne(()=>Fe(E,"data-task-id",a.id)),E})()}})),C(s,()=>{var a;return(a=r==null?void 0:r.renderSentinel)==null?void 0:a.call(r)},null),s})()}},w8={tools:["question"],getAction:()=>"Awaiting answers...",getTitle({toolState:e}){const t=e();return!t||t.status==="completed"?"Questions":"Asking questions"},renderBody(){return null}},x8=[RA,NA,AA,IA,OA,wA,$f,A8,w8,kA],D8=x8.reduce((e,t)=>(t.tools.forEach(n=>{e[n]=t}),e),{});function L8(e){return D8[e]??nE}var va=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],eg={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function k8(e,t){const n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){const r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function Lv(e){const t=e.shift();if(t==="2"){const n=e.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){const n=e.shift();if(n)return{type:"table",index:Number(n)}}}function M8(e){const t=[];for(;e.length>0;){const n=e.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)eg[r]&&t.push({type:"setDecoration",value:eg[r]});else if(r<=29){const i=eg[r-20];i&&(t.push({type:"resetDecoration",value:i}),i==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:va[r-30]}});else if(r===38){const i=Lv(e);i&&t.push({type:"setForegroundColor",value:i})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:va[r-40]}});else if(r===48){const i=Lv(e);i&&t.push({type:"setBackgroundColor",value:i})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:va[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:va[r-100+8]}})}return t}function Ff(){let e=null,t=null,n=new Set;return{parse(r){const i=[];let s=0;do{const o=k8(r,s),a=o.sequence?r.substring(s,o.startPosition):r.substring(s);if(a.length>0&&i.push({value:a,foreground:e,background:t,decorations:new Set(n)}),o.sequence){const l=M8(o.sequence);for(const c of l)c.type==="resetAll"?(e=null,t=null,n.clear()):c.type==="resetForegroundColor"?e=null:c.type==="resetBackgroundColor"?t=null:c.type==="resetDecoration"&&n.delete(c.value);for(const c of l)c.type==="setForegroundColor"?e=c.value:c.type==="setBackgroundColor"?t=c.value:c.type==="setDecoration"&&n.add(c.value)}s=o.position}while(s<r.length);return i}}}var P8={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function $8(e=P8){function t(a){return e[a]}function n(a){return`#${a.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function i(){if(r)return r;r=[];for(let c=0;c<va.length;c++)r.push(t(va[c]));let a=[0,95,135,175,215,255];for(let c=0;c<6;c++)for(let d=0;d<6;d++)for(let u=0;u<6;u++)r.push(n([a[c],a[d],a[u]]));let l=8;for(let c=0;c<24;c++,l+=10)r.push(n([l,l,l]));return r}function s(a){return i()[a]}function o(a){switch(a.type){case"named":return t(a.name);case"rgb":return n(a.rgb);case"table":return s(a.index)}}return{value:o}}const tg="\x1B",F8=/\\u001b|\\x1b|\\033/,B8=/\u001b/,kv=$8();function hc(e){const t=rE(e);return B8.test(t)}function U8(e){const t=rE(e),r=Ff().parse(t);return FA(r)}function $A(){let e=Ff();return{reset(){e=Ff()},render(t){const n=rE(t),r=e.parse(n);return FA(r)}}}function rE(e){return F8.test(e)?e.replace(/\\u001b/gi,tg).replace(/\\x1b/gi,tg).replace(/\\033/g,tg):e}function FA(e){let t="";for(const n of e){if(!n.value)continue;const r=G8(n),i=V8(n.value);if(!r){t+=i;continue}t+=`<span style="${r}">${i}</span>`}return t}function G8(e){const t=e.decorations;let n=e.foreground?kv.value(e.foreground):null,r=e.background?kv.value(e.background):null;if(t.has("reverse")){const o=n;n=r,r=o}const i=[];n&&i.push(`color: ${n}`),r&&i.push(`background-color: ${r}`),t.has("bold")&&i.push("font-weight: 600"),t.has("dim")&&i.push("opacity: 0.7"),t.has("italic")&&i.push("font-style: italic");const s=[];return t.has("underline")&&s.push("underline"),t.has("strikethrough")&&s.push("line-through"),t.has("overline")&&s.push("overline"),s.length>0&&i.push(`text-decoration-line: ${s.join(" ")}`),t.has("hidden")&&(i.push("color: transparent"),i.push("background-color: transparent")),i.length>0?i.join("; "):null}function V8(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;").replace(/'/g,"&#39;")}var H8=x("<div class=tool-call-diagnostics role=region aria-label=Diagnostics><div class=tool-call-diagnostics-body role=list>"),Y8=x("<div class=tool-call-diagnostics-wrapper><button type=button class=tool-call-diagnostics-heading><span class=tool-call-icon aria-hidden=true></span><span class=tool-call-emoji aria-hidden=true>🛠</span><span class=tool-call-summary>Diagnostics</span><span class=tool-call-diagnostics-file>"),z8=x("<div class=tool-call-diagnostic-row role=listitem><span><span class=tool-call-diagnostic-chip-icon></span><span></span></span><span class=tool-call-diagnostic-path><span class=tool-call-diagnostic-coords>:L<!>:C</span></span><span class=tool-call-diagnostic-message>"),W8=x("<div aria-hidden=true class=tool-call-scroll-sentinel style=height:1px>"),q8=x('<div class="message-text tool-call-markdown tool-call-markdown-large tool-call-diff-shell"><div class=tool-call-diff-toolbar role=group aria-label="Diff view mode"><span class=tool-call-diff-toolbar-label></span><div class=tool-call-diff-toggle><button type=button>Split</button><button type=button>Unified'),K8=x('<div><pre class="tool-call-content tool-call-ansi">'),Q8=x('<div><pre class="whitespace-pre-wrap break-words text-sm font-mono">'),j8=x("<div>"),X8=x("<div class=tool-call-error-content><strong>Error:</strong> "),Z8=x("<div class=tool-call-permission-actions><div class=tool-call-permission-buttons><button type=button class=tool-call-permission-button>Allow Once</button><button type=button class=tool-call-permission-button>Always Allow</button><button type=button class=tool-call-permission-button>Deny</button></div><div class=tool-call-permission-shortcuts><kbd class=kbd>Enter</kbd><span>Allow once</span><kbd class=kbd>A</kbd><span>Always allow</span><kbd class=kbd>D</kbd><span>Deny"),Mv=x("<div class=tool-call-permission-error>"),J8=x("<div><div class=tool-call-permission-header><span class=tool-call-permission-label></span><span class=tool-call-permission-type></span></div><div class=tool-call-permission-body><div class=tool-call-permission-title><code>"),e7=x("<div class=tool-call-permission-diff>"),t7=x("<p class=tool-call-permission-queued-text>Waiting for earlier permission responses."),n7=x("<div class=tool-call-permission-actions><div class=tool-call-permission-buttons><button type=button class=tool-call-permission-button>Submit</button><button type=button class=tool-call-permission-button>Dismiss</button></div><div class=tool-call-permission-shortcuts><kbd class=kbd>Enter</kbd><span>Submit</span><kbd class=kbd>Esc</kbd><span>Dismiss"),r7=x("<p class=tool-call-permission-queued-text>Waiting for earlier responses."),i7=x('<div><div class=tool-call-permission-header><span class=tool-call-permission-label></span><span class=tool-call-permission-type></span></div><div class=tool-call-permission-body><div class="flex flex-col gap-4">'),s7=x('<div class="text-xs text-muted">Multiple'),o7=x('<div class="mt-2 flex items-center gap-2"><input class="flex-1 rounded-md border border-base/50 bg-surface px-2 py-1 text-sm"type=text placeholder="Type your own answer"><button type=button class=tool-call-permission-button>'),a7=x('<div class="rounded-md border border-base/60 bg-surface/30 p-3"><div class="flex items-baseline justify-between gap-2"><div class=text-xs>Q<!>: <span class=font-semibold></span></div></div><div class="mt-1 text-sm font-medium"></div><div class="mt-3 flex flex-col gap-1">'),l7=x('<label><input><div class="flex flex-col"><div class="text-sm leading-tight"></div><div class="text-xs text-muted leading-tight">'),c7=x("<div><button class=tool-call-header><span class=tool-call-summary>"),d7=x("<div class=tool-call-pending-message><span class=spinner-small></span><span>Waiting to run..."),u7=x("<div class=tool-call-details>");const ng=vt("session"),_7="tool-call",Pv=48,m7=600,g7=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," ","Spacebar"]);function f7(e,t,n,r="default"){return`${t??"unknown-message"}:${n??e??"unknown-tool-call"}:${r}`}function rg(e){return e.replace(/\\/g,"/")}function p7(e){return e===1?"error":e===2?"warning":"info"}function h7(e){return e==="error"?{label:"ERR",icon:"!",rank:0}:e==="warning"?{label:"WARN",icon:"!",rank:1}:{label:"INFO",icon:"i",rank:2}}function E7(e){var d,u,_,m;if(!e)return[];if(!(ud(e)||Zs(e)||J_(e)))return[];const n=e.metadata||{},r=e.input||{},i=n==null?void 0:n.diagnostics;if(!i)return[];const s=[r.filePath,n.filePath,n.filepath,r.path].find(g=>typeof g=="string"&&g.length>0),o=s?rg(s):void 0;if(!o)return[];const a=Object.entries(i).filter(([,g])=>Array.isArray(g)&&g.length>0);if(a.length===0)return[];const l=a.filter(([g])=>rg(g)===o);if(l.length===0)return[];const c=[];for(const[g,p]of l){if(!Array.isArray(p))continue;const E=rg(g);for(let h=0;h<p.length;h++){const f=p[h];if(!f||typeof f.message!="string")continue;const b=p7(typeof f.severity=="number"?f.severity:void 0),y=h7(b),v=typeof((u=(d=f.range)==null?void 0:d.start)==null?void 0:u.line)=="number"?f.range.start.line+1:0,O=typeof((m=(_=f.range)==null?void 0:_.start)==null?void 0:m.character)=="number"?f.range.start.character+1:0;c.push({id:`${E}-${h}-${f.message}`,severity:y.rank,tone:b,label:y.label,icon:y.icon,message:f.message,filePath:E,displayPath:Mo(E),line:v,column:O})}}return c.sort((g,p)=>g.severity-p.severity)}function S7(e){const t=e[0];return t?t.displayPath:""}function b7(e,t,n,r){return e.length===0?null:(()=>{var i=Y8(),s=i.firstChild,o=s.firstChild,a=o.nextSibling,l=a.nextSibling,c=l.nextSibling;return Fn(s,"click",n,!0),Fe(s,"aria-expanded",t),C(o,t?"▼":"▶"),Fe(c,"title",r),C(c,r),C(i,S(W,{when:t,get children(){var d=H8(),u=d.firstChild;return C(u,S(_t,{each:e,children:_=>(()=>{var m=z8(),g=m.firstChild,p=g.firstChild,E=p.nextSibling,h=g.nextSibling,f=h.firstChild,b=f.firstChild,y=b.nextSibling;y.nextSibling;var v=h.nextSibling;return C(p,()=>_.icon),C(E,()=>_.label),C(h,()=>_.displayPath,f),C(f,()=>_.line||"-",y),C(f,()=>_.column||"-",null),C(v,()=>_.message),ne(O=>{var T=`tool-call-diagnostic-chip tool-call-diagnostic-${_.tone}`,I=_.filePath;return T!==O.e&&rt(g,O.e=T),I!==O.t&&Fe(h,"title",O.t=I),O},{e:void 0,t:void 0}),m})()})),d}}),null),i})()}function iE(e){const{preferences:t,setDiffViewMode:n}=ro(),{isDark:r}=eE(),i=F(()=>e.toolCall),s=F(()=>{var K;return((K=i())==null?void 0:K.tool)||""}),o=F(()=>{var _e;const K=(_e=i())==null?void 0:_e.id;if(!K)throw new Error("Tool call requires a part id");return K}),a=F(()=>{var K;return(K=i())==null?void 0:K.state}),l=F(()=>{var K;return{toolCallId:o(),messageId:e.messageId,partId:((K=i())==null?void 0:K.id)??null}}),c=F(()=>Ut.getOrCreate(e.instanceId)),d=F(()=>cR().get(e.instanceId)??null),u=F(()=>typeof e.partVersion=="number"?String(e.partVersion):typeof e.messageVersion=="number"?String(e.messageVersion):"noversion"),_=(K,_e)=>TO({instanceId:()=>e.instanceId,sessionId:()=>e.sessionId,scope:_7,cacheId:()=>{const Ye=l(),Xe=typeof K=="function"?K():K;return f7(Ye.toolCallId||void 0,Ye.messageId,Ye.partId,Xe)},version:()=>_e?_e():u()}),m=_("diff"),g=_("permission-diff"),p=_("ansi-running",()=>"running"),E=_("ansi-final"),h=$A();let f="";const b=F(()=>c().getPermissionState(e.messageId,o())),y=F(()=>{var _e;const K=b();return K?{permission:K.entry.permission,active:K.active}:(_e=i())==null?void 0:_e.pendingPermission}),v=F(()=>c().getQuestionState(e.messageId,o())),O=F(()=>{const K=v();if(K)return{request:K.entry.request,active:K.active}}),T=F(()=>(t().toolOutputExpansion||"expanded")==="expanded"),I=F(()=>(t().diagnosticsExpansion||"expanded")==="expanded"),k=F(()=>{var Ye;const K=T();return(((Ye=i())==null?void 0:Ye.tool)||"")==="read"?!1:K}),[A,V]=U(null),B=F(()=>{const K=y();if(!(K!=null&&K.permission))return!1;const _e=d();return(_e==null?void 0:_e.kind)==="permission"&&_e.id===K.permission.id}),$=F(()=>{const K=O();if(!(K!=null&&K.request))return!1;const _e=d();return(_e==null?void 0:_e.kind)==="question"&&_e.id===K.request.id}),M=()=>{if(B()||$())return!0;const K=A();return K!==null?K:k()},L=F(()=>{var K;return(K=y())==null?void 0:K.permission}),R=F(()=>{var K;return(K=O())==null?void 0:K.request}),D=F(()=>{const K=L();return K&&B()?K.id:""}),w=F(()=>{const K=R();return K&&$()?K.id:""}),[P,j]=U(!1),[le,me]=U(null),[Ae,ie]=U(void 0),re=()=>{if(B()||$())return!0;const K=Ae();return K!==void 0?K:I()},Ee=F(()=>{const K=a();return K?E7(K):[]}),[Se,q]=U(),[ae,N]=U(null),[H,te]=U(!0),[Q,z]=U(!0);let he,ue,ce,se=null,ke=null,We=0,Oe=0;function je(K=!1){const _e=ue;_e&&(K?(_e.scrollTop=_e.scrollHeight,Oe=_e.scrollTop):_e.scrollTop=Oe)}const dt=K=>{K&&(Oe=K.scrollTop)},Lt=()=>{requestAnimationFrame(()=>{je(H()),M()&&qe()})},be=K=>{ue=K||void 0,q(ue),ue&&je(H())};function ee(){We=(typeof performance<"u"?performance.now():Date.now())+m7}function Re(){return(typeof performance<"u"?performance.now():Date.now())<=We}function He(K){ce&&(ce(),ce=void 0);const _e=()=>ee(),Ye=Xe=>{g7.has(Xe.key)&&ee()};K.addEventListener("wheel",_e,{passive:!0}),K.addEventListener("pointerdown",_e),K.addEventListener("touchstart",_e,{passive:!0}),K.addEventListener("keydown",Ye),ce=()=>{K.removeEventListener("wheel",_e),K.removeEventListener("pointerdown",_e),K.removeEventListener("touchstart",_e),K.removeEventListener("keydown",Ye)}}function qe(K=!1){if(!H())return;const _e=ae(),Ye=ue;!_e||!Ye||(ke!==null&&(cancelAnimationFrame(ke),ke=null),ke=requestAnimationFrame(()=>{ke=null;const Xe=Ye.getBoundingClientRect(),kt=_e.getBoundingClientRect().bottom-Xe.bottom+Pv;Math.abs(kt)>1&&Ye.scrollBy({top:kt,behavior:K?"auto":"smooth"}),Oe=Ye.scrollTop}))}function de(){if(!Se())return;se!==null&&cancelAnimationFrame(se);const _e=Re();se=requestAnimationFrame(()=>{se=null;const Ye=Q();_e&&(Ye?H()||te(!0):H()&&te(!1))})}const Ce={registerContainer:(K,_e)=>{_e!=null&&_e.disableTracking||be(K)},handleScroll:K=>{de(),dt(K.currentTarget)},renderSentinel:K=>K!=null&&K.disableTracking?null:(()=>{var _e=W8();return wt(N,_e),_e})()};J(()=>{const K=Se();K&&(He(K),Ne(()=>{ce&&(ce(),ce=void 0)}))}),J(()=>{const K=Se(),_e=ae();if(!K||!_e)return;const Ye=new IntersectionObserver(Xe=>{Xe.forEach(ot=>{ot.target===_e&&z(ot.isIntersecting)})},{root:K,threshold:0,rootMargin:`0px 0px ${Pv}px 0px`});Ye.observe(_e),Ne(()=>Ye.disconnect())}),J(()=>{M()||(q(void 0),ue=void 0,N(null),te(!0))}),J(()=>{L()||j(!1),me(null)}),J(()=>{(D()||w())&&requestAnimationFrame(()=>{he==null||he.scrollIntoView({block:"center",behavior:"smooth"})})}),J(()=>{if(!D())return;const _e=Ye=>{Ye.key==="Enter"?(Ye.preventDefault(),ar("once")):Ye.key==="a"||Ye.key==="A"?(Ye.preventDefault(),ar("always")):(Ye.key==="d"||Ye.key==="D")&&(Ye.preventDefault(),ar("reject"))};document.addEventListener("keydown",_e),Ne(()=>document.removeEventListener("keydown",_e))});const[Ke,Pe]=U(!1),[Be,nt]=U(null),[pt,at]=U({}),[mt,bt]=U({});function Ze(){const K=document.activeElement;return(K==null?void 0:K.tagName)==="TEXTAREA"||(K==null?void 0:K.tagName)==="INPUT"||((K==null?void 0:K.hasAttribute("contenteditable"))??!1)}async function Ve(){const K=R();if(!K||!$())return;const _e=(pt()[K.id]??[]).map(Xe=>Array.isArray(Xe)?Xe:[]),Ye=K.questions.map((Xe,ot)=>_e[ot]??[]);if(Ye.some(Xe=>((Xe==null?void 0:Xe.length)??0)===0)){nt("Please answer all questions before submitting.");return}Pe(!0),nt(null);try{const Xe=K.sessionID??K.sessionId??e.sessionId;await SU(e.instanceId,Xe,K.id,Ye)}catch(Xe){ng.error("Failed to send question reply",Xe),nt(Xe instanceof Error?Xe.message:"Unable to reply")}finally{Pe(!1)}}async function tt(){const K=R();if(!(!K||!$())){Pe(!0),nt(null);try{const _e=K.sessionID??K.sessionId??e.sessionId;await bU(e.instanceId,_e,K.id)}catch(_e){ng.error("Failed to reject question",_e),nt(_e instanceof Error?_e.message:"Unable to dismiss")}finally{Pe(!1)}}}J(()=>{if(!w())return;const _e=Ye=>{Ze()||(Ye.key==="Enter"?(Ye.preventDefault(),Ve()):Ye.key==="Escape"&&(Ye.preventDefault(),tt()))};document.addEventListener("keydown",_e),Ne(()=>document.removeEventListener("keydown",_e))});const ut=()=>{var _e;switch(((_e=a())==null?void 0:_e.status)||""){case"pending":return"⏸";case"running":return"⏳";case"completed":return"✓";case"error":return"✗";default:return""}},Yt=()=>{var _e;return`tool-call-status-${((_e=a())==null?void 0:_e.status)||"pending"}`},ye=()=>{const K=Yt();return y()||O()?`${K} tool-call-awaiting-permission`:K};function Ie(){const K=y();K!=null&&K.active||V(_e=>!(_e===null?k():_e))}const Ge=F(()=>L8(s()));function Qe(K,_e){const Ye=K.filePath?Mo(K.filePath):"",Xe=(_e==null?void 0:_e.label)||(Ye?`Diff · ${Ye}`:"Diff"),kt=((_e==null?void 0:_e.variant)==="permission-diff"?"permission-diff":"diff")==="permission-diff"?g:m,Nt=()=>t().diffViewMode||"split",zt=r()?"dark":"light";let Rt;const xn=kt.get(),Ot=Nt();xn&&xn.text===K.diffText&&xn.theme===zt&&xn.mode===Ot&&(Rt=xn.html);const Dn=jt=>{n(jt)},gi=()=>{var jt;_e!=null&&_e.disableScrollTracking||Lt(),(jt=e.onContentRendered)==null||jt.call(e)};return(()=>{var jt=q8(),jr=jt.firstChild,er=jr.firstChild,Ln=er.nextSibling,kr=Ln.firstChild,tr=kr.nextSibling;return Fn(jt,"scroll",_e!=null&&_e.disableScrollTracking?void 0:Ce.handleScroll),wt(Mt=>Ce.registerContainer(Mt,{disableTracking:_e==null?void 0:_e.disableScrollTracking}),jt),C(er,Xe),kr.$$click=()=>Dn("split"),tr.$$click=()=>Dn("unified"),C(jt,S(X9,{get diffText(){return K.diffText},get filePath(){return K.filePath},theme:zt,get mode(){return Nt()},cachedHtml:Rt,get cacheEntryParams(){return kt.params()},onRendered:gi}),null),C(jt,()=>Ce.renderSentinel({disableTracking:_e==null?void 0:_e.disableScrollTracking}),null),ne(Mt=>{var gn=`tool-call-diff-mode-button${Nt()==="split"?" active":""}`,rn=Nt()==="split",Xr=`tool-call-diff-mode-button${Nt()==="unified"?" active":""}`,nr=Nt()==="unified";return gn!==Mt.e&&rt(kr,Mt.e=gn),rn!==Mt.t&&Fe(kr,"aria-pressed",Mt.t=rn),Xr!==Mt.a&&rt(tr,Mt.a=Xr),nr!==Mt.o&&Fe(tr,"aria-pressed",Mt.o=nr),Mt},{e:void 0,t:void 0,a:void 0,o:void 0}),jt})()}function ct(K){if(!K.content)return null;const Ye=`message-text tool-call-markdown${(K.size||"default")==="large"?" tool-call-markdown-large":""}`,Xe=K.variant==="running"?p:E,ot=Xe.get(),kt=typeof e.partVersion=="number"?String(e.partVersion):void 0,Nt=K.variant==="running";let zt;if(Nt){const Rt=K.content;if(!ot||!ot.text||!Rt.startsWith(ot.text)||ot.text!==f)if(hc(Rt)){h.reset();const Dn=h.render(Rt);zt={text:Rt,html:Dn,mode:kt,hasAnsi:!0}}else h.reset(),zt={text:Rt,html:Si(Rt),mode:kt,hasAnsi:!1};else{const Ot=Rt.slice(ot.text.length);if(Ot.length===0)zt={...ot,mode:kt};else if(!ot.hasAnsi&&hc(Ot)){h.reset();const Dn=h.render(Rt);zt={text:Rt,html:Dn,mode:kt,hasAnsi:!0}}else if(ot.hasAnsi){const Dn=h.render(Ot);zt={text:Rt,html:`${ot.html}${Dn}`,mode:kt,hasAnsi:!0}}else zt={text:Rt,html:`${ot.html}${Si(Ot)}`,mode:kt,hasAnsi:!1}}f=zt.text,Xe.set(zt)}else if(ot&&ot.text===K.content)zt={...ot,mode:kt};else{const Rt=hc(K.content),xn=Rt?U8(K.content):Si(K.content);zt={text:K.content,html:xn,mode:kt,hasAnsi:Rt},Xe.set(zt)}return K.requireAnsi&&!zt.hasAnsi?null:(()=>{var Rt=K8(),xn=Rt.firstChild;return Fn(Rt,"scroll",Ce.handleScroll),wt(Ot=>Ce.registerContainer(Ot),Rt),rt(Rt,Ye),C(Rt,()=>Ce.renderSentinel(),null),ne(()=>xn.innerHTML=zt.html),Rt})()}function it(K){var xn;if(!K.content)return null;const _e=K.size||"default",Ye=K.disableHighlight||!1,Xe=`message-text tool-call-markdown${_e==="large"?" tool-call-markdown-large":""}`,ot=a();if(!!(ot&&(ot.status==="running"||ot.status==="pending")&&Ye))return(()=>{var Ot=Q8(),Dn=Ot.firstChild;return Fn(Ot,"scroll",Ce.handleScroll),wt(gi=>Ce.registerContainer(gi),Ot),rt(Ot,Xe),C(Dn,()=>K.content),C(Ot,()=>Ce.renderSentinel(),null),Ot})();const Nt=(xn=i())==null?void 0:xn.id;if(!Nt)throw new Error("Tool call markdown requires a part id");const zt={id:Nt,type:"text",text:K.content,version:e.partVersion},Rt=()=>{var Ot;Lt(),(Ot=e.onContentRendered)==null||Ot.call(e)};return(()=>{var Ot=j8();return Fn(Ot,"scroll",Ce.handleScroll),wt(Dn=>Ce.registerContainer(Dn),Ot),rt(Ot,Xe),C(Ot,S(CO,{part:zt,get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get isDark(){return r()},disableHighlight:Ye,onRendered:Rt}),null),C(Ot,()=>Ce.renderSentinel(),null),Ot})()}const gt=F(()=>e.messageVersion),yt=F(()=>e.partVersion),nn={toolCall:i,toolState:a,toolName:s,messageVersion:gt,partVersion:yt,renderMarkdown:it,renderAnsi:ct,renderDiff:Qe,scrollHelpers:Ce};let Rn;J(()=>{const K=yt();M()&&K!==void 0&&(Rn!==void 0&&K===Rn||(Rn=K,qe()))}),J(()=>{M()&&H()&&qe(!0)});const yr=()=>{var K,_e;return((_e=(K=Ge()).getAction)==null?void 0:_e.call(K,nn))??tE(s())},Rs=()=>{var Xe,ot;const K=a(),_e=s();if(_e!=="task")return MA({toolName:_e,state:K});if(!K||K.status==="pending")return yr();const Ye=(ot=(Xe=Ge()).getTitle)==null?void 0:ot.call(Xe,nn);return Ye||(ud(K)&&K.title||Zs(K)&&K.title?K.title:Xn(_e))},Lr=()=>Ge().renderBody(nn);async function ar(K){const _e=L();if(!(!_e||!B())){j(!0),me(null);try{const Ye=jc(_e)||e.sessionId;await vU(e.instanceId,Ye,_e.id,K)}catch(Ye){ng.error("Failed to send permission response",Ye),me(Ye instanceof Error?Ye.message:"Unable to update permission")}finally{j(!1)}}}const mi=()=>{const K=a()||{};return K.status==="error"&&K.error?(()=>{var _e=X8(),Ye=_e.firstChild;return Ye.nextSibling,C(_e,()=>K.error,null),_e})():null},yl=()=>{const K=L();if(!K)return null;const _e=B(),Ye=K.metadata??{},Xe=typeof Ye.diff=="string"?Ye.diff:null,ot=(()=>{if(typeof Ye.filePath=="string")return Ye.filePath;if(typeof Ye.path=="string")return Ye.path})(),kt=Xe&&Xe.trim().length>0?{diffText:Xe,filePath:ot}:null;return(()=>{var Nt=J8(),zt=Nt.firstChild,Rt=zt.firstChild,xn=Rt.nextSibling,Ot=zt.nextSibling,Dn=Ot.firstChild,gi=Dn.firstChild;return rt(Nt,`tool-call-permission ${_e?"tool-call-permission-active":"tool-call-permission-queued"}`),C(Rt,_e?"Permission Required":"Permission Queued"),C(xn,()=>h_(K)),C(gi,()=>RT(K)),C(Ot,S(W,{when:kt,children:jt=>(()=>{var jr=e7();return C(jr,()=>Qe(jt(),{variant:"permission-diff",disableScrollTracking:!0,label:jt().filePath?`Requested diff · ${Mo(jt().filePath||"")}`:"Requested diff"})),jr})()}),null),C(Ot,S(W,{when:_e,get fallback(){return t7()},get children(){return[(()=>{var jt=Z8(),jr=jt.firstChild,er=jr.firstChild,Ln=er.nextSibling,kr=Ln.nextSibling;return er.$$click=()=>ar("once"),Ln.$$click=()=>ar("always"),kr.$$click=()=>ar("reject"),ne(tr=>{var Mt=P(),gn=P(),rn=P();return Mt!==tr.e&&(er.disabled=tr.e=Mt),gn!==tr.t&&(Ln.disabled=tr.t=gn),rn!==tr.a&&(kr.disabled=tr.a=rn),tr},{e:void 0,t:void 0,a:void 0}),jt})(),S(W,{get when(){return le()},get children(){var jt=Mv();return C(jt,le),jt}})]}}),null),Nt})()},Tl=()=>{var er,Ln,kr,tr;const K=a(),_e=R(),Ye=s()==="question";if(!_e&&!Ye)return null;const Xe=(_e==null?void 0:_e.questions)??((er=K==null?void 0:K.input)==null?void 0:er.questions)??[],ot=Array.isArray(Xe)?Xe:[];if(ot.length===0)return null;const kt=(_e==null?void 0:_e.id)??((Ln=K==null?void 0:K.input)==null?void 0:Ln.requestID)??`question-${((kr=i())==null?void 0:kr.id)??"unknown"}`,Nt=!!(_e&&$()),Rt=(Array.isArray((tr=K==null?void 0:K.metadata)==null?void 0:tr.answers)?K.metadata.answers:void 0)??pt()[kt]??[],xn=mt()[kt]??[],Ot=(Mt,gn)=>{Nt&&at(rn=>{const nr=[...rn[kt]??[]];return nr[Mt]=gn,{...rn,[kt]:nr}})},Dn=(Mt,gn)=>{Nt&&bt(rn=>{const nr=[...rn[kt]??[]];return nr[Mt]=gn,{...rn,[kt]:nr}})},gi=(Mt,gn)=>{const rn=ot[Mt],Xr=(rn==null?void 0:rn.multiple)===!0,nr=Rt[Mt]??[];if(Xr){const Is=nr.includes(gn)?nr.filter(In=>In!==gn):[...nr,gn];Ot(Mt,Is);return}Ot(Mt,[gn])},jt=()=>!Nt||Ke()?!0:ot.some((Mt,gn)=>{var rn;return(((rn=Rt[gn])==null?void 0:rn.length)??0)===0}),jr=()=>Nt;return(()=>{var Mt=i7(),gn=Mt.firstChild,rn=gn.firstChild,Xr=rn.nextSibling,nr=gn.nextSibling,Is=nr.firstChild;return rt(Mt,`tool-call-permission ${Nt?"tool-call-permission-active":"tool-call-permission-queued"}`),C(rn,Nt?"Question Required":_e?"Question Queued":"Questions"),C(Xr,()=>ot.length===1?"Question":"Questions"),C(Is,S(_t,{each:ot,children:(In,Os)=>{const gr=()=>Os(),Z=()=>(In==null?void 0:In.multiple)===!0,fe=()=>Rt[gr()]??[],Ue=()=>xn[gr()]??"",st=()=>Z()?"checkbox":"radio",At=()=>`question-${kt}-${gr()}`;return(()=>{var Ct=a7(),xt=Ct.firstChild,Pt=xt.firstChild,Vt=Pt.firstChild,On=Vt.nextSibling,fr=On.nextSibling,xi=fr.nextSibling,Mr=xt.nextSibling,ji=Mr.nextSibling;return C(Pt,()=>gr()+1,On),C(xi,()=>In==null?void 0:In.header),C(xt,S(W,{get when(){return Z()},get children(){return s7()}}),null),C(Mr,()=>In==null?void 0:In.question),C(ji,S(_t,{get each(){return(In==null?void 0:In.options)??[]},children:fn=>{const Wn=()=>fe().includes(fn.label);return(()=>{var rr=l7(),sn=rr.firstChild,Xi=sn.nextSibling,Zi=Xi.firstChild,mE=Zi.nextSibling;return rt(rr,`flex items-start gap-2 py-1 ${Nt?"cursor-pointer":_e?"opacity-80":""}`),sn.addEventListener("change",()=>gi(gr(),fn.label)),C(Zi,()=>fn.label),C(mE,()=>fn.description),ne(Ji=>{var gE=fn.description,fE=st(),pE=At(),hE=!Nt||Ke();return gE!==Ji.e&&Fe(rr,"title",Ji.e=gE),fE!==Ji.t&&Fe(sn,"type",Ji.t=fE),pE!==Ji.a&&Fe(sn,"name",Ji.a=pE),hE!==Ji.o&&(sn.disabled=Ji.o=hE),Ji},{e:void 0,t:void 0,a:void 0,o:void 0}),ne(()=>sn.checked=Wn()),rr})()}}),null),C(ji,S(W,{when:Nt,get children(){var fn=o7(),Wn=fn.firstChild,rr=Wn.nextSibling;return Wn.$$input=sn=>Dn(gr(),sn.currentTarget.value),rr.$$click=()=>{const sn=Ue().trim();sn&&(Dn(gr(),sn),gi(gr(),sn))},C(rr,()=>Z()?"Toggle":"Select"),ne(sn=>{var Xi=!Nt||Ke(),Zi=!Nt||Ke()||!Ue().trim();return Xi!==sn.e&&(Wn.disabled=sn.e=Xi),Zi!==sn.t&&(rr.disabled=sn.t=Zi),sn},{e:void 0,t:void 0}),ne(()=>Wn.value=Ue()),fn}}),null),Ct})()}}),null),C(Is,S(W,{get when(){return jr()},get children(){var In=n7(),Os=In.firstChild,gr=Os.firstChild,Z=gr.nextSibling;return Os.nextSibling,gr.$$click=()=>Ve(),Z.$$click=()=>tt(),C(In,S(W,{get when(){return Be()},get children(){var fe=Mv();return C(fe,Be),fe}}),null),ne(fe=>{var Ue=jt(),st=Ke();return Ue!==fe.e&&(gr.disabled=fe.e=Ue),st!==fe.t&&(Z.disabled=fe.t=st),fe},{e:void 0,t:void 0}),In}}),null),C(Is,S(W,{when:!Nt&&_e,get children(){return r7()}}),null),Mt})()};J(()=>{const K=R();if(!K){Pe(!1),nt(null);return}nt(null);const _e=K.id;at(Ye=>{if(Ye[_e])return Ye;const Xe=K.questions.map(()=>[]);return{...Ye,[_e]:Xe}}),bt(Ye=>{if(Ye[_e])return Ye;const Xe=K.questions.map(()=>"");return{...Ye,[_e]:Xe}})});const Cl=()=>{var K;return((K=a())==null?void 0:K.status)||""};return Ne(()=>{se!==null&&(cancelAnimationFrame(se),se=null),ke!==null&&(cancelAnimationFrame(ke),ke=null),ce&&(ce(),ce=void 0)}),(()=>{var K=c7(),_e=K.firstChild,Ye=_e.firstChild;return wt(Xe=>{he=Xe||void 0},K),_e.$$click=Ie,C(Ye,Rs),C(K,(()=>{var Xe=we(()=>!!M());return()=>Xe()&&(()=>{var ot=u7();return C(ot,Lr,null),C(ot,mi,null),C(ot,yl,null),C(ot,Tl,null),C(ot,S(W,{get when(){return we(()=>Cl()==="pending")()&&!y()},get children(){return d7()}}),null),ot})()})(),null),C(K,S(W,{get when(){return Ee().length},get children(){return b7(Ee(),re(),()=>ie(Xe=>!(Xe===void 0?I():Xe)),S7(Ee()))}}),null),ne(Xe=>{var ot=`tool-call ${ye()}`,kt=M(),Nt=ut(),zt=Gc(s());return ot!==Xe.e&&rt(K,Xe.e=ot),kt!==Xe.t&&Fe(_e,"aria-expanded",Xe.t=kt),Nt!==Xe.a&&Fe(_e,"data-status-icon",Xe.a=Nt),zt!==Xe.o&&Fe(Ye,"data-tool-icon",Xe.o=zt),Xe},{e:void 0,t:void 0,a:void 0,o:void 0}),K})()}Ht(["click","input"]);const[Yne,zne]=U(new Set);var v7=x("<div>"),y7=x("<span>");function T7(e){const{isDark:t}=eE(),{preferences:n}=ro(),r=()=>{var l;return((l=e.part)==null?void 0:l.type)||""},i=()=>e.messageType==="assistant",s=()=>i()?"message-text message-text-assistant":"message-text",o=()=>{const l=e.part;return(l.type==="text"||l.type==="reasoning")&&typeof l.text=="string"?l.text:""},a=()=>{const l=e.part;return(l.type==="text"||l.type==="reasoning")&&typeof l.text=="string"?{id:l.id,type:"text",text:l.text,synthetic:l.type==="text"?l.synthetic:!1,version:l.version}:{id:l.id,type:"text",text:"",synthetic:!1}};return S(Wc,{get children(){return[S(sr,{get when(){return r()==="text"},get children(){return S(W,{get when(){return we(()=>!(e.part.type==="text"&&e.part.synthetic))()&&yh(e.part)},get children(){var l=v7();return C(l,S(W,{get when(){return i()},get fallback(){return(()=>{var c=y7();return C(c,o),c})()},get children(){return S(CO,{get part(){return a()},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get isDark(){return t()},get size(){return i()?"tight":"base"},get onRendered(){return e.onRendered}})}})),ne(()=>rt(l,s())),l}})}}),S(sr,{get when(){return r()==="tool"},get children(){return S(iE,{get toolCall(){return e.part},get toolCallId(){var l;return(l=e.part)==null?void 0:l.id},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId}})}})]}})}var C7=x('<button class=message-action-button title="Revert to this message"aria-label="Revert to this message">Revert'),R7=x('<button class=message-action-button title="Fork from this message"aria-label="Fork from this message">Fork'),I7=x('<div class=message-action-group><button class=message-action-button title="Copy message"aria-label="Copy message">'),O7=x('<button class=message-action-button title="Copy message"aria-label="Copy message">'),N7=x("<div class=message-queued-badge>QUEUED"),A7=x("<div class=message-error-block>⚠️ "),w7=x("<div class=message-generating><span class=generating-spinner>⏳</span> Generating..."),x7=x('<div class="message-attachments mt-1">'),D7=x("<div class=message-sending><span class=generating-spinner>●</span> Sending..."),L7=x("<div class=message-error>⚠ Message failed to send"),k7=x('<div><header><div class=message-speaker><span class=message-speaker-label></span></div><div class=message-item-actions><time class=message-timestamp></time></div></header><div class="pt-1 whitespace-pre-wrap break-words leading-[1.1]">'),M7=x("<span class=message-agent-meta>"),P7=x('<img class="h-5 w-5 rounded object-cover">'),$7=x("<div class=attachment-chip-preview><img>"),F7=x('<div><span class="truncate max-w-[180px]"></span><button type=button class=attachment-download><svg class="h-3 w-3"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M4 16v2a2 2 0 002 2h12a2 2 0 002-2v-2"></path><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M8 12l4 4 4-4m-4-8v12">'),B7=x('<svg class="h-3 w-3"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2">');function U7(e){const[t,n]=U(!1),r=()=>e.record.role==="user",i=()=>{var T,I;return((I=(T=e.messageInfo)==null?void 0:T.time)==null?void 0:I.created)??e.record.createdAt},s=()=>new Date(i()).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),o=()=>new Date(i()).toISOString(),a=()=>e.parts,l=()=>a().filter(T=>(T==null?void 0:T.type)==="file"&&typeof T.url=="string"),c=T=>{if(T.filename&&T.filename.trim().length>0)return T.filename;const I=T.url||"";if(I.startsWith("data:"))return"attachment";try{return new URL(I).pathname.split("/").pop()||"attachment"}catch{const A=I.split("/").pop();return A&&A.length>0?A:"attachment"}},d=T=>T.mime&&typeof T.mime=="string"&&T.mime.startsWith("image/")?!0:typeof T.url=="string"&&T.url.startsWith("data:image/"),u=async T=>{const I=T.url;if(!I)return;const k=c(T),A=V=>{const B=document.createElement("a");B.href=V,B.download=k,B.target="_blank",B.rel="noopener",document.body.appendChild(B),B.click(),document.body.removeChild(B)};if(I.startsWith("data:")){A(I);return}if(I.startsWith("file://")){window.open(I,"_blank","noopener");return}try{const V=await fetch(I);if(!V.ok)throw new Error(`Failed to fetch attachment: ${V.status}`);const B=await V.blob(),$=URL.createObjectURL(B);A($),URL.revokeObjectURL($)}catch{A(I)}},_=()=>{var k,A;const T=e.messageInfo;if(!T||T.role!=="assistant"||!T.error)return null;const I=T.error;return I.name==="ProviderAuthError"?((k=I.data)==null?void 0:k.message)||"Authentication error":I.name==="MessageOutputLengthError"?"Message output length exceeded":I.name==="MessageAbortedError"?"Request was aborted":I.name==="UnknownError"?((A=I.data)==null?void 0:A.message)||"Unknown error occurred":null},m=()=>_()!==null?!0:a().some(T=>yh(T)),g=()=>{const T=e.messageInfo;return!m()&&T&&T.role==="assistant"&&T.time.completed!==void 0&&T.time.completed===0},p=()=>{e.onRevert&&r()&&e.onRevert(e.record.id)},E=()=>e.parts.filter(T=>T.type==="text").map(T=>T.text||"").filter(T=>T.trim().length>0).join(`
158
158
 
159
159
  `),h=async()=>{const T=E();if(!T)return;const I=await Th(T);n(I),setTimeout(()=>n(!1),2e3)};if(!r()&&!m())return null;const f=()=>r()?"message-item-base bg-[var(--message-user-bg)] border-l-4 border-[var(--message-user-border)]":"message-item-base assistant-message bg-[var(--message-assistant-bg)] border-l-4 border-[var(--message-assistant-border)]",b=()=>r()?"You":"Assistant",y=()=>{if(r())return"";const T=e.messageInfo;return!T||T.role!=="assistant"?"":T.mode||""},v=()=>{if(r())return"";const T=e.messageInfo;if(!T||T.role!=="assistant")return"";const I=T.modelID||"",k=T.providerID||"";return I&&k?`${k}/${I}`:I},O=()=>{if(r()||!e.showAgentMeta)return"";const T=[],I=y(),k=v();return I&&T.push(`Agent: ${I}`),k&&T.push(`Model: ${k}`),T.join(" • ")};return(()=>{var T=k7(),I=T.firstChild,k=I.firstChild,A=k.firstChild,V=k.nextSibling,B=V.firstChild,$=I.nextSibling;return C(A,b),C(k,S(W,{get when(){return O()},children:M=>(()=>{var L=M7();return C(L,M),L})()}),null),C(V,S(W,{get when(){return r()},get children(){var M=I7(),L=M.firstChild;return C(M,S(W,{get when(){return e.onRevert},get children(){var R=C7();return R.$$click=p,R}}),L),C(M,S(W,{get when(){return e.onFork},get children(){var R=R7();return R.$$click=()=>{var D;return(D=e.onFork)==null?void 0:D.call(e,e.record.id)},R}}),L),L.$$click=h,C(L,S(W,{get when(){return t()},fallback:"Copy",children:"Copied!"})),M}}),B),C(V,S(W,{get when(){return!r()},get children(){var M=O7();return M.$$click=h,C(M,S(W,{get when(){return t()},fallback:"Copy",children:"Copied!"})),M}}),B),C(B,s),C($,S(W,{get when(){return we(()=>!!e.isQueued)()&&r()},get children(){return N7()}}),null),C($,S(W,{get when(){return _()},get children(){var M=A7();return M.firstChild,C(M,_,null),M}}),null),C($,S(W,{get when(){return g()},get children(){return w7()}}),null),C($,S(_t,{get each(){return a()},children:M=>S(T7,{part:M,get messageType(){return e.record.role},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get onRendered(){return e.onContentRendered}})}),null),C($,S(W,{get when(){return l().length>0},get children(){var M=x7();return C(M,S(_t,{get each(){return l()},children:L=>{const R=c(L),D=d(L);return(()=>{var w=F7(),P=w.firstChild,j=P.nextSibling;return rt(w,`attachment-chip ${D?"attachment-chip-image":""}`),Fe(w,"title",R),C(w,S(W,{when:D,get fallback(){return B7()},get children(){var le=P7();return Fe(le,"alt",R),ne(()=>Fe(le,"src",L.url)),le}}),P),C(P,R),j.$$click=()=>void u(L),Fe(j,"aria-label",`Download ${R}`),C(w,S(W,{when:D,get children(){var le=$7(),me=le.firstChild;return Fe(me,"alt",R),ne(()=>Fe(me,"src",L.url)),le}}),null),w})()}})),M}}),null),C($,S(W,{get when(){return e.record.status==="sending"},get children(){return D7()}}),null),C($,S(W,{get when(){return e.record.status==="error"},get children(){return L7()}}),null),ne(M=>{var L=f(),R=`message-item-header ${r()?"pb-0.5":"pb-0"}`,D=r()?"user":"assistant",w=o();return L!==M.e&&rt(T,M.e=L),R!==M.t&&rt(I,M.t=R),D!==M.a&&Fe(A,"data-role",M.a=D),w!==M.o&&Fe(B,"datetime",M.o=w),M},{e:void 0,t:void 0,a:void 0,o:void 0}),T})()}Ht(["click"]);function yi(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:e.toLocaleString()}var G7=x("<div class=message-stream-block>"),V7=x("<button class=tool-call-header-button type=button>Go to Session"),H7=x("<div class=tool-call-message><div class=tool-call-header-label><div class=tool-call-header-meta><span class=tool-call-icon>🔧</span><span>Tool Call</span><span class=tool-name>"),Y7=x('<div role=status aria-label="Session compaction"><div class=message-compaction-row><span class=message-compaction-label>'),z7=x("<div class=message-step-usage>"),W7=x("<span class=message-step-usage-chip>"),q7=x('<div class="message-step-card message-step-finish message-step-finish-flush">'),BA=x("<span class=message-step-meta-inline>"),K7=x('<div class="message-step-card message-step-start"><div class=message-step-heading><div class=message-step-title><div class=message-step-title-left></div><span class=message-step-time>'),Q7=x("<span>Agent: "),j7=x("<span>Model: "),X7=x('<div class=message-reasoning-expanded><div class=message-reasoning-body><div class=message-reasoning-output role=region aria-label="Reasoning details"><pre class=message-reasoning-text>'),Z7=x('<div class=message-reasoning-card><button type=button class=message-reasoning-toggle><span class="message-reasoning-label flex flex-wrap items-center gap-2"><span>Thinking</span></span><span class=message-reasoning-meta><span class=message-reasoning-indicator></span><span class=message-reasoning-time>'),J7=x('<span class="font-medium text-[var(--message-assistant-border)]">Agent: '),ej=x('<span class="font-medium text-[var(--message-assistant-border)]">Model: ');const uu="var(--message-user-border)",$v="var(--message-assistant-border)",tj="var(--message-tool-border)";function nj(e){return!!(e&&e.status==="running")}function rj(e){return!!(e&&e.status==="completed")}function ij(e){return!!(e&&e.status==="error")}function sj(e){if(!e)return"";const t=e.metadata??{},n=(t==null?void 0:t.sessionId)??(t==null?void 0:t.sessionID);return typeof n=="string"?n:""}function oj(e){if(!e||e.type!=="reasoning")return!1;const t=n=>{if(typeof n=="string")return n.trim().length>0;if(n&&typeof n=="object"){const r=n;if(typeof r.text=="string"&&r.text.trim().length>0||typeof r.value=="string"&&r.value.trim().length>0)return!0;if(Array.isArray(r.content))return r.content.some(i=>t(i))}return!1};return t(e.text)?!0:Array.isArray(e.content)?e.content.some(n=>t(n)):!1}function aj(e,t){var r;if(!e)return null;if(t){const i=(r=Ft().get(t))==null?void 0:r.get(e);if(i)return{sessionId:i.id,instanceId:t,parentId:i.parentId??null}}const n=Ft();for(const[i,s]of n){const o=s==null?void 0:s.get(e);if(o)return{sessionId:o.id,instanceId:i,parentId:o.parentId??null}}return null}function lj(e){ps(e.instanceId);const t=e.parentId??e.sessionId;Ss(e.instanceId,t),e.parentId&&Es(e.instanceId,e.sessionId)}const Vc=new Map;function UA(e,t){return`${e}:${t}`}function cj(e,t){Vc.delete(UA(e,t))}function dj(e,t){const n=UA(e,t);let r=Vc.get(n);return r||(r={messageItems:new Map,toolItems:new Map,messageBlocks:new Map},Vc.set(n,r)),r}function uj(e){UM(e);const t=`${e}:`;for(const n of Vc.keys())n.startsWith(t)&&Vc.delete(n)}Ut.onInstanceDestroyed(uj);function GA(e){const t=F(()=>e.store().getMessage(e.messageId)),n=F(()=>e.store().getMessageInfo(e.messageId)),r=dj(e.instanceId,e.sessionId),i=F(()=>{const s=t();if(!s)return null;const o=e.messageIndex,a=e.lastAssistantIndex(),l=s.role==="user"&&(a===-1||o>a),c=Wr(n),d=[s.id,s.revision,l?1:0,e.showThinking()?1:0,e.thinkingDefaultExpanded()?1:0,e.showUsageMetrics()?1:0].join("|"),u=r.messageBlocks.get(s.id);if(u&&u.signature===d)return u.block;const{orderedParts:_}=FT(e.instanceId,s),m=[],g=[],p=[];let E=0,h=[],f=s.role!=="assistant";const b=s.role==="user"?uu:$v;let y=b;const v=()=>{if(h.length===0)return;const I=`${s.id}:segment:${E}`;E+=1;const k=s.role==="assistant"&&!f&&h.some(V=>yh(V));let A=r.messageItems.get(I);A?(A.record=s,A.parts=h.slice(),A.messageInfo=c,A.isQueued=l,A.showAgentMeta=k):(A={type:"content",key:I,record:s,parts:h.slice(),messageInfo:c,isQueued:l,showAgentMeta:k},r.messageItems.set(I,A)),k&&(f=!0),m.push(A),g.push(I),y=b,h=[]};_.forEach((I,k)=>{if(I.type==="tool"){v();const A=typeof I.revision=="number"?I.revision:0,V=s.revision,B=`${s.id}:${I.id??k}`;let $=r.toolItems.get(B);$?($.key=B,$.toolPart=I,$.messageInfo=c,$.messageId=s.id,$.messageVersion=V,$.partVersion=A):($={type:"tool",key:B,toolPart:I,messageInfo:c,messageId:s.id,messageVersion:V,partVersion:A},r.toolItems.set(B,$)),m.push($),p.push(B),y=tj;return}if(I.type==="compaction"){v();const A=`${s.id}:${I.id??k}:compaction`,V=!!(I!=null&&I.auto);m.push({type:"compaction",key:A,part:I,messageInfo:c,accentColor:V?"var(--session-status-compacting-fg)":uu}),y=V?"var(--session-status-compacting-fg)":uu;return}if(I.type==="step-start"){v();return}if(I.type==="step-finish"){if(v(),e.showUsageMetrics()){const A=`${s.id}:${I.id??k}:${I.type}`,V=y||b;m.push({type:I.type,key:A,part:I,messageInfo:c,accentColor:V}),y=V}return}if(I.type==="reasoning"){if(v(),e.showThinking()&&oj(I)){const A=`${s.id}:${I.id??k}:reasoning`,V=s.role==="assistant"&&!f;V&&(f=!0),m.push({type:"reasoning",key:A,part:I,messageInfo:c,showAgentMeta:V,defaultExpanded:e.thinkingDefaultExpanded()}),y=$v}return}h.push(I)}),v();const O={record:s,items:m};r.messageBlocks.set(s.id,{signature:d,block:O,contentKeys:g.slice(),toolKeys:p.slice()});const T=`${s.id}:`;for(const[I]of r.messageItems)I.startsWith(T)&&!g.includes(I)&&r.messageItems.delete(I);for(const[I]of r.toolItems)I.startsWith(T)&&!p.includes(I)&&r.toolItems.delete(I);return O});return S(W,{get when(){return i()},keyed:!0,children:s=>(()=>{var o=G7();return C(o,S(_t,{get each(){return s.items},children:a=>S(Wc,{get children(){return[S(sr,{get when(){return a.type==="content"},get children(){return S(U7,{get record(){return a.record},get messageInfo(){return a.messageInfo},get parts(){return a.parts},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get isQueued(){return a.isQueued},get showAgentMeta(){return a.showAgentMeta},get onRevert(){return e.onRevert},get onFork(){return e.onFork},get onContentRendered(){return e.onContentRendered}})}}),S(sr,{get when(){return a.type==="tool"},get children(){return(()=>{const l=a,c=l.toolPart.state,u=!!c&&(nj(c)||rj(c)||ij(c))?sj(c):"",_=u?aj(u,e.instanceId):null,m=g=>{g.preventDefault(),g.stopPropagation(),_&&lj(_)};return(()=>{var g=H7(),p=g.firstChild,E=p.firstChild,h=E.firstChild,f=h.nextSibling,b=f.nextSibling;return C(b,()=>l.toolPart.tool||"unknown"),C(p,S(W,{when:u,get children(){var y=V7();return y.$$click=m,y.disabled=!_,Fe(y,"title",_?"Go to session":"Session not available yet"),y}}),null),C(g,S(iE,{get toolCall(){return l.toolPart},get toolCallId(){return l.toolPart.id},get messageId(){return l.messageId},get messageVersion(){return l.messageVersion},get partVersion(){return l.partVersion},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get onContentRendered(){return e.onContentRendered}}),null),ne(()=>Fe(g,"data-key",l.key)),g})()})()}}),S(sr,{get when(){return a.type==="step-start"},get children(){return S(Fv,{kind:"start",get part(){return a.part},get messageInfo(){return a.messageInfo},showAgentMeta:!0})}}),S(sr,{get when(){return a.type==="step-finish"},get children(){return S(Fv,{kind:"finish",get part(){return a.part},get messageInfo(){return a.messageInfo},get showUsage(){return e.showUsageMetrics()},get borderColor(){return a.accentColor}})}}),S(sr,{get when(){return a.type==="compaction"},get children(){return S(_j,{get part(){return a.part},get messageInfo(){return a.messageInfo},get borderColor(){return a.accentColor}})}}),S(sr,{get when(){return a.type==="reasoning"},get children(){return S(gj,{get part(){return a.part},get messageInfo(){return a.messageInfo},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get showAgentMeta(){return a.showAgentMeta},get defaultExpanded(){return a.defaultExpanded}})}})]}})})),ne(()=>Fe(o,"data-message-id",s.record.id)),o})()})}function _j(e){const t=()=>{var s;return!!((s=e.part)!=null&&s.auto)},n=()=>t()?"Session auto-compacted":"Session compacted by you",r=()=>e.borderColor??(t()?"var(--session-status-compacting-fg)":uu),i=()=>`message-compaction-card ${t()?"message-compaction-card--auto":"message-compaction-card--manual"}`;return(()=>{var s=Y7(),o=s.firstChild,a=o.firstChild;return C(o,S(tT,{class:"message-compaction-icon w-4 h-4","aria-hidden":"true"}),a),C(a,n),ne(l=>{var c=i(),d=`4px solid ${r()}`;return c!==l.e&&rt(s,l.e=c),d!==l.t&&Ci(s,"border-left",l.t=d),l},{e:void 0,t:void 0}),s})()}function Fv(e){const t=()=>{var c,d,u,_;const a=((d=(c=e.messageInfo)==null?void 0:c.time)==null?void 0:d.created)??((_=(u=e.part)==null?void 0:u.time)==null?void 0:_.start)??Date.now();return new Date(a).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},n=()=>{if(!e.showAgentMeta)return"";const a=e.messageInfo;return!a||a.role!=="assistant"?"":a.mode||""},r=()=>{if(!e.showAgentMeta)return"";const a=e.messageInfo;if(!a||a.role!=="assistant")return"";const l=a.modelID||"",c=a.providerID||"";return l&&c?`${c}/${l}`:l},i=()=>{var c,d;if(e.kind!=="finish"||!e.showUsage)return null;const a=e.messageInfo;if(!a||a.role!=="assistant"||!a.tokens)return null;const l=a.tokens;return{input:l.input??0,output:l.output??0,reasoning:l.reasoning??0,cacheRead:((c=l.cache)==null?void 0:c.read)??0,cacheWrite:((d=l.cache)==null?void 0:d.write)??0,cost:a.cost??0}},s=()=>e.borderColor?{"border-left-color":e.borderColor}:void 0,o=a=>{const l=[{label:"Input",value:a.input,formatter:yi},{label:"Output",value:a.output,formatter:yi},{label:"Reasoning",value:a.reasoning,formatter:yi},{label:"Cache Read",value:a.cacheRead,formatter:yi},{label:"Cache Write",value:a.cacheWrite,formatter:yi},{label:"Cost",value:a.cost,formatter:mj}];return(()=>{var c=z7();return C(c,S(_t,{each:l,children:d=>(()=>{var u=W7();return C(u,()=>d.formatter(d.value)),ne(()=>Fe(u,"data-label",d.label)),u})()})),c})()};if(e.kind==="finish"){const a=i();return a?(()=>{var l=q7();return C(l,()=>o(a)),ne(c=>ri(l,s(),c)),l})():null}return(()=>{var a=K7(),l=a.firstChild,c=l.firstChild,d=c.firstChild,u=d.nextSibling;return C(d,S(W,{get when(){return we(()=>!!e.showAgentMeta)()&&(n()||r())},get children(){var _=BA();return C(_,S(W,{get when(){return n()},children:m=>(()=>{var g=Q7();return g.firstChild,C(g,m,null),g})()}),null),C(_,S(W,{get when(){return r()},children:m=>(()=>{var g=j7();return g.firstChild,C(g,m,null),g})()}),null),_}})),C(u,t),a})()}function mj(e){return e?e<.01?`$${e.toPrecision(2)}`:`$${e.toFixed(2)}`:"$0.00"}function gj(e){const[t,n]=U(!!e.defaultExpanded);J(()=>{n(!!e.defaultExpanded)});const r=()=>{var d,u,_,m;const l=((u=(d=e.messageInfo)==null?void 0:d.time)==null?void 0:u.created)??((m=(_=e.part)==null?void 0:_.time)==null?void 0:m.start)??Date.now();return new Date(l).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},i=()=>{const l=e.messageInfo;return!l||l.role!=="assistant"?"":l.mode||""},s=()=>{const l=e.messageInfo;if(!l||l.role!=="assistant")return"";const c=l.modelID||"",d=l.providerID||"";return c&&d?`${d}/${c}`:c},o=()=>{const l=e.part;if(!l)return"";const c=u=>{if(typeof u=="string")return u;if(u&&typeof u=="object"){const _=u,m=[];return typeof _.text=="string"&&m.push(_.text),typeof _.value=="string"&&m.push(_.value),Array.isArray(_.content)&&m.push(_.content.map(g=>c(g)).join(`
160
160
  `)),m.filter(g=>g&&g.trim().length>0).join(`
161
161
  `)}return""},d=c(l.text);return d.trim().length>0?d:Array.isArray(l.content)?l.content.map(u=>c(u)).join(`
162
- `):""},a=()=>n(l=>!l);return(()=>{var l=Z7(),c=l.firstChild,d=c.firstChild;d.firstChild;var u=d.nextSibling,_=u.firstChild,m=_.nextSibling;return c.$$click=a,C(d,S(W,{get when(){return we(()=>!!e.showAgentMeta)()&&(i()||s())},get children(){var g=BA();return C(g,S(W,{get when(){return i()},children:p=>(()=>{var E=J7();return E.firstChild,C(E,p,null),E})()}),null),C(g,S(W,{get when(){return s()},children:p=>(()=>{var E=ej();return E.firstChild,C(E,p,null),E})()}),null),g}}),null),C(_,()=>t()?"Hide":"View"),C(m,r),C(l,S(W,{get when(){return t()},get children(){var g=X7(),p=g.firstChild,E=p.firstChild,h=E.firstChild;return C(h,()=>o()||""),g}}),null),ne(g=>{var p=t(),E=t()?"Collapse thinking":"Expand thinking";return p!==g.e&&Fe(c,"aria-expanded",g.e=p),E!==g.t&&Fe(c,"aria-label",g.t=E),g},{e:void 0,t:void 0}),l})()}Ht(["click"]);const[fj,VA]=U(new Map);function HA(e,t){VA(n=>{const r=new Map(n);return r.set(e,t),r})}function YA(e){e&&HA(e,!0)}function zA(e){if(!e){VA(new Map);return}HA(e,!1)}function pj(e){return fj().get(e)??!1}var hj=x('<form class="mt-4 space-y-4"><div class=space-y-2><label class="text-sm font-medium text-secondary">Session name</label><input type=text placeholder="Enter a session name"class="w-full px-3 py-2 text-sm bg-surface-base border border-base rounded text-primary focus-ring-accent"></div><div class="flex justify-end gap-3"><button type=button class=button-tertiary>Cancel</button><button type=submit class="button-primary flex items-center gap-2 disabled:opacity-60 disabled:cursor-not-allowed">'),Ej=x('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),Sj=x('<svg class="animate-spin h-4 w-4"fill=none viewBox="0 0 24 24"><circle class=opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=opacity-75 fill=currentColor d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">'),bj=x("<span>Renaming…");const WA=e=>{const[t,n]=U(""),r=`session-rename-${Math.random().toString(36).slice(2)}`;let i;J(()=>{e.open&&n(e.currentTitle??"")}),J(()=>{e.open&&(typeof window>"u"||typeof window.requestAnimationFrame!="function"||window.requestAnimationFrame(()=>{i==null||i.focus(),i==null||i.select()}))});const s=()=>!!e.isSubmitting,o=()=>s()||!t().trim();async function a(c){c==null||c.preventDefault(),!o()&&await e.onRename(t().trim())}const l=()=>e.sessionLabel&&e.sessionLabel.trim()?`Update the title for "${e.sessionLabel}".`:"Set a new title for this session.";return S(ft,{get open(){return e.open},onOpenChange:c=>{!c&&!s()&&e.onClose()},get children(){return S(ft.Portal,{get children(){return[S(ft.Overlay,{class:"modal-overlay"}),(()=>{var c=Ej();return C(c,S(ft.Content,{class:"modal-surface w-full max-w-sm p-6",tabIndex:-1,get children(){return[S(ft.Title,{class:"text-lg font-semibold text-primary",children:"Rename Session"}),S(ft.Description,{class:"text-sm text-secondary mt-1",get children(){return l()}}),(()=>{var d=hj(),u=d.firstChild,_=u.firstChild,m=_.nextSibling,g=u.nextSibling,p=g.firstChild,E=p.nextSibling;return d.addEventListener("submit",a),Fe(_,"for",r),m.$$input=h=>n(h.currentTarget.value),wt(h=>{i=h},m),Fe(m,"id",r),p.$$click=()=>{s()||e.onClose()},C(E,S(W,{get when(){return!s()},get fallback(){return[Sj(),bj()]},children:"Rename"})),ne(h=>{var f=s(),b=o();return f!==h.e&&(p.disabled=h.e=f),b!==h.t&&(E.disabled=h.t=b),h},{e:void 0,t:void 0}),ne(()=>m.value=t()),d})()]}})),c})()]}})}})};Ht(["input","click"]);var vj=x("<span role=button tabindex=0>"),yj=x('<div class="session-list-item group"><button role=button><div class="session-item-row session-item-header"><div class=session-item-title-row><span class="session-item-title session-item-title--clamp"></span></div></div><div class="session-item-row session-item-meta"><div class="flex items-center gap-2 min-w-0"><span></span></div><div class=session-item-actions><span role=button tabindex=0 aria-label="Copy session ID"title="Copy session ID"></span><span role=button tabindex=0 aria-label="Rename session"title="Rename session"></span><span role=button tabindex=0 aria-label="Delete session"title="Delete session">'),Tj=x('<span class="session-item-expander session-item-expander--spacer"aria-hidden=true>'),Cj=x("<span class=status-dot>"),Rj=x('<svg class="animate-spin h-3 w-3"fill=none viewBox="0 0 24 24"><circle class=opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=opacity-75 fill=currentColor d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">'),Ij=x('<div class="session-list-header p-3 border-b border-base">'),Oj=x("<div class=session-section>"),Nj=x('<div class="session-list-footer p-3 border-t border-base">'),Aj=x('<div class="session-list-container bg-surface-secondary border-r border-base flex flex-col w-full"><div class="session-list flex-1 overflow-y-auto">'),wj=x('<div class="flex items-center justify-between gap-3"><h3 class="text-sm font-semibold text-primary">Sessions');const ig=vt("session");function xj(e){switch(e){case"working":return"Working";case"compacting":return"Compacting";default:return"Idle"}}const Dj=e=>{const[t,n]=U(null),[r,i]=U(!1),s=h=>{const f=xc().deletingSession.get(e.instanceId);return f?f.has(h):!1},o=h=>{var y;const f=(y=Ft().get(e.instanceId))==null?void 0:y.get(h),b=(f==null?void 0:f.parentId)??(f==null?void 0:f.id);b&&Zg(e.instanceId,b),e.onSelect(h)},a=async(h,f)=>{h.stopPropagation();try{const b=await Th(f);Pi(b?{message:"Session ID copied",variant:"success"}:{message:"Unable to copy session ID",variant:"error"})}catch(b){ig.error(`Failed to copy session ID ${f}:`,b),Pi({message:"Unable to copy session ID",variant:"error"})}},l=async(h,f)=>{if(h.stopPropagation(),s(f))return;const b=e.activeSessionId===f;let y;if(b){const v=Dc(e.instanceId),O=v.indexOf(f),T=v.filter(I=>I!==f);if(T.length>0){if(O!==-1){for(let I=O;I<v.length;I++){const k=v[I];if(k&&k!==f){y=k;break}}if(!y)for(let I=O-1;I>=0;I--){const k=v[I];if(k&&k!==f){y=k;break}}}y??(y=T[0])}}try{await Hp(e.instanceId,f),y&&Ka(e.instanceId,y)}catch(v){ig.error(`Failed to delete session ${f}:`,v),Pi({message:"Unable to delete session",variant:"error"})}},c=h=>{var y;const f=(y=Ft().get(e.instanceId))==null?void 0:y.get(h);if(!f)return;const b=f.title&&f.title.trim()?f.title:h;n({id:h,title:f.title??"",label:b})},d=()=>{n(null)},u=async h=>{const f=t();if(f){i(!0);try{await WT(e.instanceId,f.id,h),n(null)}catch(b){ig.error(`Failed to rename session ${f.id}:`,b),Pi({message:"Unable to rename session",variant:"error"})}finally{i(!1)}}},_=h=>{const f=F(()=>{var B;return(B=Ft().get(e.instanceId))==null?void 0:B.get(h.sessionId)});if(!f())return[];const b=()=>e.activeSessionId===h.sessionId,y=()=>{var B;return((B=f())==null?void 0:B.title)||"Untitled"},v=()=>DR(e.instanceId,h.sessionId),O=()=>xj(v()),T=()=>{var B;return!!((B=f())!=null&&B.pendingPermission)},I=()=>{var B;return!!((B=f())!=null&&B.pendingQuestion)},k=()=>T()||I(),A=()=>k()?"session-permission":`session-${v()}`,V=()=>T()?"Needs Permission":I()?"Needs Input":O();return(()=>{var B=yj(),$=B.firstChild,M=$.firstChild,L=M.firstChild,R=L.firstChild,D=M.nextSibling,w=D.firstChild,P=w.firstChild,j=w.nextSibling,le=j.firstChild,me=le.nextSibling,Ae=me.nextSibling;return $.$$click=()=>o(h.sessionId),C(L,(()=>{var ie=we(()=>!!h.isChild);return()=>ie()?S(eT,{class:"w-4 h-4 flex-shrink-0"}):S(sT,{class:"w-4 h-4 flex-shrink-0"})})(),R),C(R,y),C(w,S(W,{get when(){return we(()=>!!h.hasChildren)()&&!h.isChild},get fallback(){return we(()=>!!h.isChild)()?null:Tj()},get children(){var ie=vj();return ie.$$click=re=>{var Ee;re.stopPropagation(),(Ee=h.onToggleExpand)==null||Ee.call(h)},C(ie,S(Qc,{get class(){return`w-3.5 h-3.5 transition-transform ${h.expanded?"":"-rotate-90"}`}})),ne(re=>{var Ee=`session-item-expander opacity-80 hover:opacity-100 ${b()?"hover:bg-white/20":"hover:bg-surface-hover"}`,Se=h.expanded?"Collapse session":"Expand session",q=h.expanded?"Collapse":"Expand";return Ee!==re.e&&rt(ie,re.e=Ee),Se!==re.t&&Fe(ie,"aria-label",re.t=Se),q!==re.a&&Fe(ie,"title",re.a=q),re},{e:void 0,t:void 0,a:void 0}),ie}}),P),C(P,(()=>{var ie=we(()=>!!k());return()=>ie()?S(__,{class:"w-3.5 h-3.5","aria-hidden":"true"}):Cj()})(),null),C(P,V,null),le.$$click=ie=>a(ie,h.sessionId),C(le,S($D,{class:"w-3 h-3"})),me.$$click=ie=>{ie.stopPropagation(),c(h.sessionId)},C(me,S(iT,{class:"w-3 h-3"})),Ae.$$click=ie=>l(ie,h.sessionId),C(Ae,S(W,{get when(){return!s(h.sessionId)},get fallback(){return Rj()},get children(){return S(al,{class:"w-3 h-3"})}})),ne(ie=>{var re=`session-item-base ${h.isChild?`session-item-child${h.isLastChild?" session-item-child-last":""} session-item-border-assistant session-item-kind-assistant`:"session-item-border-user session-item-kind-user"} ${b()?"session-item-active":"session-item-inactive"}`,Ee=h.sessionId,Se=y(),q=b(),ae=h.hasChildren?!!h.expanded:void 0,N=`status-indicator session-status session-status-list ${A()}`,H=`session-item-close opacity-80 hover:opacity-100 ${b()?"hover:bg-white/20":"hover:bg-surface-hover"}`,te=`session-item-close opacity-80 hover:opacity-100 ${b()?"hover:bg-white/20":"hover:bg-surface-hover"}`,Q=`session-item-close opacity-80 hover:opacity-100 ${b()?"hover:bg-white/20":"hover:bg-surface-hover"}`;return re!==ie.e&&rt($,ie.e=re),Ee!==ie.t&&Fe($,"data-session-id",ie.t=Ee),Se!==ie.a&&Fe($,"title",ie.a=Se),q!==ie.o&&Fe($,"aria-selected",ie.o=q),ae!==ie.i&&Fe($,"aria-expanded",ie.i=ae),N!==ie.n&&rt(P,ie.n=N),H!==ie.s&&rt(le,ie.s=H),te!==ie.h&&rt(me,ie.h=te),Q!==ie.r&&rt(Ae,ie.r=Q),ie},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),B})()},m=F(()=>{var b;const h=e.activeSessionId;if(!h||h==="info")return null;const f=(b=Ft().get(e.instanceId))==null?void 0:b.get(h);return f?f.parentId??f.id:null});J(()=>{const h=m();h&&Zg(e.instanceId,h)});const g=U(null),p=h=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(h):h.replace(/\\/g,"\\\\").replace(/\"/g,'\\"'),E=h=>{const f=g[0]();if(!f)return;const b=`[data-session-id="${p(h)}"]`,y=()=>{const T=f.querySelector(b);T&&T.scrollIntoView({block:"nearest",inline:"nearest"})};if(typeof requestAnimationFrame>"u"){y();return}let v=0,O=0;v=requestAnimationFrame(()=>{O=requestAnimationFrame(()=>{y()})}),Ne(()=>{v&&cancelAnimationFrame(v),O&&cancelAnimationFrame(O)})};return J(()=>{const h=e.activeSessionId;!h||h==="info"||E(h)}),(()=>{var h=Aj(),f=h.firstChild;return C(h,S(W,{get when(){return e.showHeader!==!1},get children(){var b=Ij();return C(b,()=>e.headerContent??(()=>{var y=wj();return y.firstChild,C(y,S(Qp,{get shortcuts(){return[Hn.get("session-prev"),Hn.get("session-next")].filter(Boolean)}}),null),y})()),b}}),f),wt(b=>g[1](b),f),C(f,S(W,{get when(){return e.threads.length>0},get children(){var b=Oj();return C(b,S(_t,{get each(){return e.threads},children:y=>{const v=()=>wR(e.instanceId,y.parent.id);return[S(_,{get sessionId(){return y.parent.id},get hasChildren(){return y.children.length>0},get expanded(){return v()},onToggleExpand:()=>GU(e.instanceId,y.parent.id)}),S(W,{get when(){return we(()=>!!v())()&&y.children.length>0},get children(){return S(_t,{get each(){return y.children},children:(O,T)=>S(_,{get sessionId(){return O.id},isChild:!0,get isLastChild(){return T()===y.children.length-1}})})}})]}})),b}})),C(h,S(W,{get when(){return e.showFooter!==!1},get children(){var b=Nj();return C(b,()=>e.footerContent??null),b}}),null),C(h,S(WA,{get open(){return!!t()},get currentTitle(){var b;return((b=t())==null?void 0:b.title)??""},get sessionLabel(){var b;return(b=t())==null?void 0:b.label},get isSubmitting(){return r()},onRename:u,onClose:d}),null),h})()};Ht(["click"]);const Bv=vt("session"),sg=new Set;function Bf(e){return e?"project"in e&&"mcpStatus"in e&&"lspStatus"in e&&"plugins"in e:!1}async function Lj(e,t){const n=e.client;if(!n){Bv.warn("[metadata] Skipping fetch; client missing",{instanceId:e.id});return}const r=iu(e.id)??e.metadata;if(!(!(t!=null&&t.force)&&Bf(r))&&!sg.has(e.id)){sg.add(e.id);try{const[i,s,o,a]=await Promise.allSettled([n.project.current(),n.mcp.status(),pR(e.id),n.config.get()]),l=i.status==="fulfilled"?i.value.data:void 0,c=s.status==="fulfilled"?s.value.data:void 0,d=o.status==="fulfilled"?o.value??[]:void 0,u=a.status==="fulfilled"?a.value.data:void 0,_=Array.isArray(u==null?void 0:u.plugin)?(u==null?void 0:u.plugin).map(g=>g.startsWith("file://")?g.slice(7):g):void 0,m={...r??{}};i.status==="fulfilled"&&(m.project=l??null),s.status==="fulfilled"&&(m.mcpStatus=c??{}),o.status==="fulfilled"&&(m.lspStatus=d??[]),a.status==="fulfilled"&&(m.plugins=_??[]),!(m!=null&&m.version)&&e.binaryVersion&&(m.version=e.binaryVersion),oR(e.id,m)}catch(i){Bv.error("Failed to load instance metadata",i)}finally{sg.delete(e.id)}}}const qA=Jt(null),kj=e=>{const t=F(()=>Et().get(e.instance.id)??e.instance),[n,r]=U(!0),i=async(o=!1)=>{const a=t();if(!a){r(!1);return}const l=iu(a.id)??a.metadata;if(!o&&Bf(l)){r(!1);return}r(!0),await Lj(a,{force:o}),r(!1)};J(()=>{const o=t();if(!o){r(!1);return}const a=iu(o.id)??o.metadata;if(!a||!Bf(a)){i();return}r(!1)});const s={isLoading:n,instance:t,metadata:()=>iu(t().id)??t().metadata,refreshMetadata:()=>i(!0)};return S(qA.Provider,{value:s,get children(){return e.children}})};function KA(){return en(qA)}const Mj=Jt();function Pj(){return en(Mj)}const $j=Jt();function Fj(){return en($j)}function Bj(e){const t=e.controlled()!==void 0,[n,r]=U(e.default()),i=F(()=>t?e.controlled():n());return t&&J(()=>{r(()=>i())}),[i,o=>{t||r(o)}]}function Uj(e){return xr("PrivateSwitchBase",e)}Dr("PrivateSwitchBase",["root","checked","disabled","input","edgeStart","edgeEnd"]);const Uv=Cn()({name:"MuiSwitchBase",selfPropNames:["autoFocus","checked","checkedIcon","classes","defaultChecked","disableFocusRipple","disableRipple","disabled","edge","icon","id","inputProps","inputRef","name","onChange","readOnly","required","tabIndex","type","value"],autoCallUseClasses:!1,propDefaults:({set:e})=>e({disableFocusRipple:!1,edge:!1}),utilityClass:Uj,slotClasses:e=>({root:["root",!!e.checked&&"checked",!!e.disabled&&"disabled",e.edge&&`edge${Zt(e.edge)}`],input:["input"]})}),Gj=Sn(yO)(({ownerState:e})=>({padding:9,borderRadius:"50%",...e.edge==="start"&&{marginLeft:e.size==="small"?-3:-12},...e.edge==="end"&&{marginRight:e.size==="small"?-3:-12}})),Vj=Sn("input")({cursor:"inherit",position:"absolute",opacity:0,width:"100%",height:"100%",top:0,left:0,margin:0,padding:0,zIndex:1}),Hj=Uv.component(function({allProps:t,otherProps:n,props:r}){const i=Fj(),[s,o]=Bj({controlled:()=>r.checked??(i==null?void 0:i.checked),default:()=>!!r.defaultChecked,name:"SwitchBase",state:"checked"}),a=Pj(),l=()=>typeof(i==null?void 0:i.disabled)<"u"?i.disabled:a&&typeof r.disabled>"u"?a.disabled:r.disabled;J(()=>{i&&i.setDisabled(!!l())});const c=()=>r.type==="checkbox"||r.type==="radio",d=oe(t,{get checked(){return s()},get disabled(){return l()}}),u=Uv.useClasses(d),_=Hu(()=>r.inputRef),m=()=>r.value??(i==null?void 0:i.value);return J(()=>{typeof r.defaultChecked=="boolean"&&(_.ref.defaultChecked=r.defaultChecked)}),J(()=>{const g=s();typeof g=="boolean"&&(_.ref.checked=g)}),S(Gj,oe(n,{component:"span",get class(){return Xt(u.root,n.class)},centerRipple:!0,get focusRipple(){return!r.disableFocusRipple},get disabled(){return l()},tabIndex:null,role:void 0,onFocus:g=>{var p;typeof n.onFocus=="function"&&n.onFocus(g),(p=a==null?void 0:a.onFocus)==null||p.call(a)},onBlur:g=>{var p;typeof n.onBlur=="function"&&n.onBlur(g),(p=a==null?void 0:a.onBlur)==null||p.call(a)},ownerState:d,get children(){return[S(Vj,oe({as:"input",get autofocus(){return r.autoFocus},get class(){return u.input},get disabled(){return l()},get id(){return we(()=>!!c())()?r.id:void 0},get name(){return r.name??(i==null?void 0:i.name)},onClick:g=>{var E;if(g.defaultPrevented)return;const p=g.currentTarget.checked;g.currentTarget.checked=!p,o(p),typeof r.onChange=="function"?r.onChange(g,p):(E=i==null?void 0:i.onChange)==null||E.call(i,g,p),typeof n.onClick=="function"&&n.onClick(g)},get readOnly(){return r.readOnly},ref:g=>{var p;_(g),r.inputRef||(p=i==null?void 0:i.inputRef)==null||p.call(i,g)},get required(){return r.required},ownerState:d,get tabIndex(){return r.tabIndex},get type(){return r.type},get value(){return m()}},()=>r.inputProps||{})),we(()=>we(()=>!!s())()?r.checkedIcon:r.icon),we(()=>n.children)]}}))});function Yj(e){return xr("MuiSwitch",e)}const hr=Dr("MuiSwitch",["root","edgeStart","edgeEnd","switchBase","colorPrimary","colorSecondary","sizeSmall","sizeMedium","checked","disabled","input","thumb","track"]),zj=Cn()({name:"MuiSwitch",selfPropNames:["checkedIcon","classes","color","disabled","icon","size","value"],propDefaults:({set:e})=>e({color:"primary",size:"medium"}),utilityClass:Yj,slotClasses:e=>({root:["root",!!e.edge&&`edge${Zt(e.edge)}`,`size${Zt(e.size)}`],switchBase:["switchBase",`color${Zt(e.color)}`,!!e.checked&&"checked",!!e.disabled&&"disabled"],thumb:["thumb"],track:["track"],input:["input"]})}),Wj=Sn("span",{name:"MuiSwitch",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,n.edge&&t[`edge${Zt(n.edge)}`],t[`size${Zt(n.size)}`]]}})(({ownerState:e})=>({display:"inline-flex",width:34+12*2,height:14+12*2,overflow:"hidden",padding:12,boxSizing:"border-box",position:"relative",flexShrink:0,zIndex:0,verticalAlign:"middle","@media print":{colorAdjust:"exact"},...e.edge==="start"&&{marginLeft:-8},...e.edge==="end"&&{marginRight:-8},...e.size==="small"&&{width:40,height:24,padding:7,[`& .${hr.thumb}`]:{width:16,height:16},[`& .${hr.switchBase}`]:{padding:4,[`&.${hr.checked}`]:{transform:"translateX(16px)"}}}})),qj=Sn(Hj,{name:"MuiSwitch",slot:"SwitchBase",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.switchBase,{[`& .${hr.input}`]:t.input},n.color!=="default"&&t[`color${Zt(n.color)}`]]}})(({theme:e})=>({position:"absolute",top:0,left:0,zIndex:1,color:e.palette.mode==="light"?e.palette.common.white:e.palette.grey[300],transition:e.transitions.create(["left","transform"],{duration:e.transitions.duration.shortest}),[`&.${hr.checked}`]:{transform:"translateX(20px)"},[`&.${hr.disabled}`]:{color:e.palette.mode==="light"?e.palette.grey[100]:e.palette.grey[600]},[`&.${hr.checked} + .${hr.track}`]:{opacity:.5},[`&.${hr.disabled} + .${hr.track}`]:{opacity:e.palette.mode==="light"?.12:.2},[`& .${hr.input}`]:{left:"-100%",width:"300%"}}),({theme:e,ownerState:t})=>({"&:hover":{backgroundColor:ko(e.palette.action.active,e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},...t.color!=="default"&&{[`&.${hr.checked}`]:{color:e.palette[t.color].main,"&:hover":{backgroundColor:ko(e.palette[t.color].main,e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${hr.disabled}`]:{color:e.palette.mode==="light"?YI(e.palette[t.color].main,.62):HI(e.palette[t.color].main,.55)}},[`&.${hr.checked} + .${hr.track}`]:{backgroundColor:e.palette[t.color].main}}})),Kj=Sn("span",{name:"MuiSwitch",slot:"Track",overridesResolver:(e,t)=>t.track})(({theme:e})=>({height:"100%",width:"100%",borderRadius:14/2,zIndex:-1,transition:e.transitions.create(["opacity","background-color"],{duration:e.transitions.duration.shortest}),backgroundColor:e.palette.mode==="light"?e.palette.common.black:e.palette.common.white,opacity:e.palette.mode==="light"?.38:.3})),Qj=Sn("span",{name:"MuiSwitch",slot:"Thumb",overridesResolver:(e,t)=>t.thumb})(({theme:e})=>({boxShadow:e.shadows[1],backgroundColor:"currentColor",width:20,height:20,borderRadius:"50%"})),jj=zj.component(function({allProps:t,props:n,classes:r,otherProps:i}){const s=()=>S(Qj,{get class(){return r.thumb},ownerState:t}),o=oe(r,{get root(){return r.switchBase}}),[,a]=lt(i,["sx"]),l=oe(a,{get checkedIcon(){return n.checkedIcon||s},get disabled(){return n.disabled},get icon(){return n.icon||s},get value(){return n.value}});return S(Wj,{get class(){return Xt(r.root,i.class)},get sx(){return i.sx},ownerState:t,get children(){return[S(qj,oe({type:"checkbox",ownerState:t},l,{classes:o})),S(Kj,{get class(){return r.track},ownerState:t})]}})});var Xj=x('<p class="text-[11px] text-secondary italic"role=status>'),Zj=x('<div class="text-xs font-medium text-muted uppercase tracking-wide">LSP Servers'),og=x("<div class=space-y-1.5>"),ag=x("<section class=space-y-1.5>"),Jj=x('<div class="px-2 py-1.5 rounded border bg-surface-secondary border-base"><div class="flex items-center justify-between gap-2"><div class="flex flex-col flex-1 min-w-0"><span class="text-xs text-primary font-medium truncate"></span><span class="text-[11px] text-secondary truncate"></span></div><div class="flex items-center gap-1.5 flex-shrink-0 text-xs text-secondary"><div></div><span>'),eX=x('<div class="text-xs font-medium text-muted uppercase tracking-wide">MCP Servers'),tX=x('<svg class="animate-spin h-3 w-3"fill=none viewBox="0 0 24 24"><circle class=opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=opacity-75 fill=currentColor d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">'),nX=x('<div class="px-2 py-1.5 rounded border bg-surface-secondary border-base"><div class="flex items-center justify-between gap-2"><span class="text-xs text-primary font-medium truncate"></span><div class="flex items-center gap-3 flex-shrink-0"><div class="flex items-center gap-1.5 text-xs text-secondary"><div></div></div><div class="flex items-center gap-1.5">'),rX=x('<div class="text-[11px] mt-1 break-words"style=color:var(--status-error)>'),iX=x('<div class="text-xs font-medium text-muted uppercase tracking-wide">Plugins'),sX=x('<div class="px-2 py-1.5 rounded border bg-surface-secondary border-base"><div class="text-xs text-primary font-medium break-words whitespace-normal">'),oX=x("<div>");const aX=vt("session");function lX(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||typeof r!="object")continue;const i=r.status;if(!i)continue;let s;i==="connected"?s="running":i==="failed"?s="error":s="stopped",t.push({name:n,status:s,error:typeof r.error=="string"?r.error:void 0})}return t}const _u=e=>{const t=KA(),n=(t==null?void 0:t.instance)??(()=>{if(e.initialInstance)return e.initialInstance;throw new Error("InstanceServiceStatus requires InstanceMetadataProvider or initialInstance prop")}),r=(t==null?void 0:t.isLoading)??(()=>!1),i=(t==null?void 0:t.refreshMetadata)??(async()=>Promise.resolve()),s=F(()=>e.sections??["lsp","mcp","plugins"]),o=F(()=>s().includes("lsp")),a=F(()=>s().includes("mcp")),l=F(()=>s().includes("plugins")),c=()=>e.showSectionHeadings!==!1,d=(t==null?void 0:t.metadata)??(()=>n().metadata),u=F(()=>d()),_=()=>{var $;return(($=u())==null?void 0:$.lspStatus)!==void 0},m=()=>{var $;return(($=u())==null?void 0:$.mcpStatus)!==void 0},g=()=>{var $;return(($=u())==null?void 0:$.plugins)!==void 0},p=F(()=>{var $;return(($=u())==null?void 0:$.lspStatus)??[]}),E=F(()=>{var $;return lX((($=u())==null?void 0:$.mcpStatus)??void 0)}),h=F(()=>{var $;return(($=u())==null?void 0:$.plugins)??[]}),f=()=>r()||!_(),b=()=>r()||!m(),y=()=>r()||!g(),[v,O]=U({}),T=($,M)=>{O(L=>{const R={...L};return M?R[$]=M:delete R[$],R})},I=async($,M)=>{const L=n().client;if(!(L!=null&&L.mcp))return;const R=M?"connect":"disconnect";T($,R);try{M?await L.mcp.connect({name:$}):await L.mcp.disconnect({name:$}),await i()}catch(D){aX.error("Failed to toggle MCP server",{serverName:$,action:R,error:D})}finally{T($)}},k=$=>(()=>{var M=Xj();return C(M,$),M})(),A=()=>(()=>{var $=ag();return C($,S(W,{get when(){return c()},get children(){return Zj()}}),null),C($,S(W,{get when(){return we(()=>!f())()&&p().length>0},get fallback(){return k(f()?"Loading LSP servers...":"No LSP servers detected.")},get children(){var M=og();return C(M,S(_t,{get each(){return p()},children:L=>(()=>{var R=Jj(),D=R.firstChild,w=D.firstChild,P=w.firstChild,j=P.nextSibling,le=w.nextSibling,me=le.firstChild,Ae=me.nextSibling;return C(P,()=>L.name??L.id),C(j,()=>L.root),C(Ae,()=>L.status==="connected"?"Connected":"Error"),ne(ie=>{var re=L.root,Ee=`status-dot ${L.status==="connected"?"ready animate-pulse":"error"}`;return re!==ie.e&&Fe(j,"title",ie.e=re),Ee!==ie.t&&rt(me,ie.t=Ee),ie},{e:void 0,t:void 0}),R})()})),M}}),null),$})(),V=()=>(()=>{var $=ag();return C($,S(W,{get when(){return c()},get children(){return eX()}}),null),C($,S(W,{get when(){return we(()=>!b())()&&E().length>0},get fallback(){return k(b()?"Loading MCP servers...":"No MCP servers detected.")},get children(){var M=og();return C(M,S(_t,{get each(){return E()},children:L=>{const R=()=>v()[L.name],D=()=>!!R(),w=()=>L.status==="running",P=()=>D()||!n().client,j=()=>D()?"status-dot animate-pulse":L.status==="running"?"status-dot ready animate-pulse":L.status==="error"?"status-dot error":"status-dot stopped",le=()=>D()?{background:"var(--status-warning)"}:void 0;return(()=>{var me=nX(),Ae=me.firstChild,ie=Ae.firstChild,re=ie.nextSibling,Ee=re.firstChild,Se=Ee.firstChild,q=Ee.nextSibling;return C(ie,()=>L.name),C(Ee,S(W,{get when(){return D()},get children(){return tX()}}),Se),C(q,S(jj,{get checked(){return w()},get disabled(){return P()},color:"success",size:"small",get inputProps(){return{"aria-label":`Toggle ${L.name} MCP server`}},onChange:(ae,N)=>{P()||I(L.name,!!N)}})),C(me,S(W,{get when(){return L.error},children:ae=>(()=>{var N=rX();return C(N,ae),N})()}),null),ne(ae=>{var N=j(),H=le();return N!==ae.e&&rt(Se,ae.e=N),ae.t=ri(Se,H,ae.t),ae},{e:void 0,t:void 0}),me})()}})),M}}),null),$})(),B=()=>(()=>{var $=ag();return C($,S(W,{get when(){return c()},get children(){return iX()}}),null),C($,S(W,{get when(){return we(()=>!y())()&&h().length>0},get fallback(){return k(y()?"Loading plugins...":"No plugins configured.")},get children(){var M=og();return C(M,S(_t,{get each(){return h()},children:L=>(()=>{var R=sX(),D=R.firstChild;return C(D,L),R})()})),M}}),null),$})();return(()=>{var $=oX();return C($,S(W,{get when(){return o()},get children(){return A()}}),null),C($,S(W,{get when(){return a()},get children(){return V()}}),null),C($,S(W,{get when(){return l()},get children(){return B()}}),null),ne(()=>rt($,e.class)),$})()};var cX=x('<div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1">OpenCode Version</div><div class="text-xs px-2 py-1.5 rounded border bg-surface-secondary border-base text-primary">v'),dX=x('<div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1">Binary Path</div><div class="text-xs font-mono break-all px-2 py-1.5 rounded border bg-surface-secondary border-base text-primary">'),uX=x('<div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1.5">Environment Variables (<!>)</div><div class=space-y-1>'),_X=x('<div class="text-xs text-muted py-1"><div class="flex items-center gap-1.5"><svg class="animate-spin h-3 w-3 icon-muted"fill=none viewBox="0 0 24 24"><circle class=opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=opacity-75 fill=currentColor d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>Loading...'),mX=x('<div class=panel><div class=panel-header><h2 class=panel-title>Instance Information</h2></div><div class="panel-body space-y-3"><div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1">Folder</div><div class="text-xs text-primary font-mono break-all px-2 py-1.5 rounded border bg-surface-secondary border-base"></div></div><div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1.5">Server</div><div class="space-y-1 text-xs"><div class="flex justify-between items-center"><span class=text-secondary>Port:</span><span class="text-primary font-mono"></span></div><div class="flex justify-between items-center"><span class=text-secondary>PID:</span><span class="text-primary font-mono"></span></div><div class="flex justify-between items-center"><span class=text-secondary>Status:</span><span><div>'),gX=x('<div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1">Project</div><div class="text-xs font-mono px-2 py-1.5 rounded border truncate bg-surface-secondary border-base text-primary">'),fX=x('<div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1">Version Control</div><div class="flex items-center gap-2 text-xs text-primary"><svg class="w-3.5 h-3.5"fill=currentColor viewBox="0 0 24 24"style=color:var(--status-warning)><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"></path></svg><span class=capitalize>'),pX=x('<div class="flex items-center gap-2 px-2 py-1.5 rounded border bg-surface-secondary border-base"><span class="text-xs font-mono font-medium flex-1 text-primary"></span><span class="text-xs font-mono flex-1 text-secondary">');const Uf=e=>{const t=KA(),n=(t==null?void 0:t.isLoading)??(()=>!1),r=(t==null?void 0:t.instance)??(()=>e.instance),i=(t==null?void 0:t.metadata)??(()=>e.instance.metadata),s=()=>r(),o=()=>i(),a=()=>{var d;return s().binaryVersion||((d=o())==null?void 0:d.version)},l=()=>s().environmentVariables,c=F(()=>{const d=l();return d?Object.entries(d):[]});return(()=>{var d=mX(),u=d.firstChild,_=u.nextSibling,m=_.firstChild,g=m.firstChild,p=g.nextSibling,E=m.nextSibling,h=E.firstChild,f=h.nextSibling,b=f.firstChild,y=b.firstChild,v=y.nextSibling,O=b.nextSibling,T=O.firstChild,I=T.nextSibling,k=O.nextSibling,A=k.firstChild,V=A.nextSibling,B=V.firstChild;return C(p,()=>s().folder),C(_,S(W,{get when(){var $;return we(()=>!n())()&&(($=o())==null?void 0:$.project)},children:$=>[(()=>{var M=gX(),L=M.firstChild,R=L.nextSibling;return C(R,()=>$().id),M})(),S(W,{get when(){return $().vcs},get children(){var M=fX(),L=M.firstChild,R=L.nextSibling,D=R.firstChild,w=D.nextSibling;return C(w,()=>$().vcs),M}})]}),E),C(_,S(W,{get when(){return a()},get children(){var $=cX(),M=$.firstChild,L=M.nextSibling;return L.firstChild,C(L,a,null),$}}),E),C(_,S(W,{get when(){return s().binaryPath},get children(){var $=dX(),M=$.firstChild,L=M.nextSibling;return C(L,()=>s().binaryPath),$}}),E),C(_,S(W,{get when(){return c().length>0},get children(){var $=uX(),M=$.firstChild,L=M.firstChild,R=L.nextSibling;R.nextSibling;var D=M.nextSibling;return C(M,()=>c().length,R),C(D,S(_t,{get each(){return c()},children:([w,P])=>(()=>{var j=pX(),le=j.firstChild,me=le.nextSibling;return Fe(le,"title",w),C(le,w),Fe(me,"title",P),C(me,P),j})()})),$}}),E),C(_,S(_u,{get initialInstance(){return e.instance},class:"space-y-3"}),E),C(_,S(W,{get when(){return n()},get children(){return _X()}}),E),C(v,()=>s().port),C(I,()=>s().pid),C(V,()=>s().status,null),ne($=>{var M=`status-badge ${s().status}`,L=`status-dot ${s().status==="ready"?"ready":s().status==="starting"?"starting":s().status==="error"?"error":"stopped"} ${s().status==="ready"||s().status==="starting"?"animate-pulse":""}`;return M!==$.e&&rt(V,$.e=M),L!==$.t&&rt(B,$.t=L),$},{e:void 0,t:void 0}),d})()};var hX=x('<button type=button class="button-tertiary lg:hidden flex-shrink-0">View Instance Info'),EX=x('<div class="panel flex flex-col flex-1 min-h-0"><div class=panel-header><div class="flex flex-row flex-wrap items-center gap-2 justify-between"><div><h2 class=panel-title>Resume Session</h2><p class=panel-subtitle> <!> available</p></div></div></div><div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto">'),SX=x('<div class="fixed inset-0 z-40 bg-black/60 backdrop-blur-sm lg:hidden"><div class="flex min-h-full items-start justify-center p-4 overflow-y-auto"><div class="w-full max-w-md space-y-3"><div class="flex justify-end"><button type=button class=button-tertiary>Close</button></div><div class="max-h-[85vh] overflow-y-auto pr-1">'),bX=x('<div class="flex-1 flex flex-col overflow-hidden bg-surface-secondary"><div class="flex-1 flex flex-col lg:flex-row gap-4 p-4 overflow-auto min-w-0"><div class="flex-1 flex flex-col gap-4 min-h-0 min-w-0"><div class="panel flex-shrink-0"><div class=panel-header><h2 class=panel-title>Start New Session</h2><p class=panel-subtitle>We’ll reuse your last agent/model automatically</p></div><div class=panel-body><div class=space-y-3><button type=button class="button-primary w-full flex items-center justify-center text-sm disabled:cursor-not-allowed"><div class="flex items-center gap-2"><span>Create Session</span></div></button></div></div></div></div><div class="hidden lg:block lg:w-80 flex-shrink-0"><div class="sticky top-0 max-h-full overflow-y-auto pr-1"></div></div></div><div class="panel-footer hidden sm:block"><div class=panel-footer-hints><div class="flex items-center gap-1.5"><kbd class=kbd>↑</kbd><kbd class=kbd>↓</kbd><span>Navigate</span></div><div class="flex items-center gap-1.5"><kbd class=kbd>PgUp</kbd><kbd class=kbd>PgDn</kbd><span>Jump</span></div><div class="flex items-center gap-1.5"><kbd class=kbd>Home</kbd><kbd class=kbd>End</kbd><span>First/Last</span></div><div class="flex items-center gap-1.5"><kbd class=kbd>Enter</kbd><span>Resume</span></div><div class="flex items-center gap-1.5"><kbd class=kbd>Del</kbd><span>Delete'),vX=x('<div class="panel panel-empty-state flex-1 flex flex-col justify-center"><div class=panel-empty-state-icon></div><p class=panel-empty-state-title>Loading Sessions</p><p class=panel-empty-state-description>Fetching your previous sessions...'),yX=x('<button type=button class="button-tertiary mt-4 lg:hidden">View Instance Info'),TX=x('<div class="panel panel-empty-state flex-1 flex flex-col justify-center"><div class=panel-empty-state-icon><svg class="w-12 h-12 mx-auto"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"></path></svg></div><p class=panel-empty-state-title>No Previous Sessions</p><p class=panel-empty-state-description>Create a new session below to get started'),CX=x('<div class="flex items-center gap-2 flex-shrink-0"><kbd class="kbd flex-shrink-0">↵</kbd><button type=button class="p-1.5 rounded transition-colors text-muted hover:text-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent"title="Rename session"></button><button type=button class="p-1.5 rounded transition-colors text-muted hover:text-red-500 dark:hover:text-red-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent"title="Delete session">'),RX=x('<div class=panel-list-item><div class="flex items-center gap-2 w-full px-1"><button type=button class="panel-list-item-content group flex-1"><div class="flex items-center justify-between gap-3 w-full"><div class="flex-1 min-w-0"><div class="flex items-center gap-2"><span class="text-sm font-medium text-primary whitespace-normal break-words transition-colors"></span></div><div class="flex items-center gap-3 text-xs text-muted mt-0.5"><span></span><span>•</span><span>'),Gv=x('<svg class="animate-spin h-4 w-4"fill=none viewBox="0 0 24 24"><circle class=opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=opacity-75 fill=currentColor d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">'),IX=x('<svg class="w-4 h-4"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M12 4v16m8-8H4">');const lg=vt("actions"),OX=e=>{const[t,n]=U(!1),[r,i]=U(0),[s,o]=U("sessions"),[a,l]=U(!1),[c,d]=U(typeof window<"u"?window.matchMedia("(min-width: 1024px)").matches:!1),[u,_]=U(null),[m,g]=U(!1),p=()=>$U(e.instance.id),E=F(()=>!!xc().fetchingSessions.get(e.instance.id)),h=R=>{const D=xc().deletingSession.get(e.instance.id);return D?D.has(R):!1};F(()=>{const R=Hn.get("session-new");return R||{id:"session-new-display",key:"n",modifiers:{shift:!0,meta:vo(),ctrl:!vo()},handler:()=>{},description:"New Session",context:"global"}});const f=F(()=>vo()?"cmd+shift+n":"ctrl+shift+n");J(()=>{p().length===0?(o("new-session"),i(0)):(o("sessions"),i(0))});const b=()=>{c()||l(!0)},y=()=>l(!1);function v(R){const D=document.querySelector(`[data-session-index="${R}"]`);D&&D.scrollIntoView({block:"nearest",behavior:"auto"})}function O(R){let D=null;typeof document<"u"&&(D=document.activeElement);const w=(D==null?void 0:D.closest(".modal-surface"))||(D==null?void 0:D.closest("[role='dialog']"));if(D&&(["INPUT","TEXTAREA","SELECT"].includes(D.tagName)||D.isContentEditable||!!w)){w&&R.key==="Escape"&&u()&&(R.preventDefault(),$());return}if(a()){R.key==="Escape"&&(R.preventDefault(),y());return}const j=p();if((R.metaKey||R.ctrlKey)&&R.shiftKey&&R.key.toLowerCase()==="n"){R.preventDefault(),L();return}if(j.length===0)return;const le=s()==="sessions";if(R.key==="ArrowDown"){le||(o("sessions"),i(0)),R.preventDefault();const me=Math.min(r()+1,j.length-1);i(me),v(me);return}if(R.key==="ArrowUp"){le||(o("sessions"),i(Math.max(p().length-1,0))),R.preventDefault();const me=Math.max(r()-1,0);i(me),v(me);return}if(le)if(R.key==="PageDown"){R.preventDefault();const Ae=Math.min(r()+5,j.length-1);i(Ae),v(Ae)}else if(R.key==="PageUp"){R.preventDefault();const Ae=Math.max(r()-5,0);i(Ae),v(Ae)}else if(R.key==="Home")R.preventDefault(),i(0),v(0);else if(R.key==="End"){R.preventDefault();const me=j.length-1;i(me),v(me)}else R.key==="Enter"?(R.preventDefault(),T()):(R.key==="Delete"||R.key==="Backspace")&&(R.preventDefault(),I())}async function T(){const R=p(),D=r();D<R.length&&await A(R[D].id)}async function I(){const R=p(),D=r();if(D>=R.length)return;await V(R[D].id);const w=p();if(w.length===0){o("new-session"),i(0);return}const P=Math.min(D,w.length-1);i(P),o("sessions"),v(P)}Tn(()=>{window.addEventListener("keydown",O),Ne(()=>{window.removeEventListener("keydown",O)})}),Tn(()=>{const R=window.matchMedia("(min-width: 1024px)"),D=P=>{d(P),P&&y()},w=P=>D(P.matches);typeof R.addEventListener=="function"?(R.addEventListener("change",w),Ne(()=>{R.removeEventListener("change",w)})):(R.addListener(w),Ne(()=>{R.removeListener(w)})),D(R.matches)});function k(R){const D=Math.floor((Date.now()-R)/1e3),w=Math.floor(D/60),P=Math.floor(w/60),j=Math.floor(P/24);return j>0?`${j}d ago`:P>0?`${P}h ago`:w>0?`${w}m ago`:"just now"}async function A(R){Ss(e.instance.id,R)}async function V(R){if(!h(R))try{await Hp(e.instance.id,R)}catch(D){lg.error("Failed to delete session:",D)}}function B(R,D){const w=D&&D.trim()?D:R;_({id:R,title:D??"",label:w})}function $(){_(null)}async function M(R){const D=u();if(D){g(!0);try{await WT(e.instance.id,D.id,R),_(null)}catch(w){lg.error("Failed to rename session:",w),Pi({message:"Unable to rename session",variant:"error"})}finally{g(!1)}}}async function L(){if(!t()){n(!0);try{const R=await vR(e.instance.id);Ss(e.instance.id,R.id)}catch(R){lg.error("Failed to create session:",R)}finally{n(!1)}}}return(()=>{var R=bX(),D=R.firstChild,w=D.firstChild,P=w.firstChild,j=P.firstChild,le=j.nextSibling,me=le.firstChild,Ae=me.firstChild,ie=Ae.firstChild,re=ie.firstChild,Ee=w.nextSibling,Se=Ee.firstChild,q=D.nextSibling;return C(w,S(W,{get when(){return p().length>0},get fallback(){return S(W,{get when(){return E()},get fallback(){return(()=>{var ae=TX(),N=ae.firstChild,H=N.nextSibling;return H.nextSibling,C(ae,S(W,{get when(){return we(()=>!c())()&&!a()},get children(){var te=yX();return te.$$click=b,te}}),null),ae})()},get children(){var ae=vX(),N=ae.firstChild;return C(N,S(Ro,{class:"w-12 h-12 mx-auto animate-spin text-muted"})),ae}})},get children(){var ae=EX(),N=ae.firstChild,H=N.firstChild,te=H.firstChild,Q=te.firstChild,z=Q.nextSibling,he=z.firstChild,ue=he.nextSibling;ue.nextSibling;var ce=N.nextSibling;return C(z,()=>p().length,he),C(z,()=>p().length===1?"session":"sessions",ue),C(H,S(W,{get when(){return we(()=>!c())()&&!a()},get children(){var se=hX();return se.$$click=b,se}}),null),C(ce,S(_t,{get each(){return p()},children:(se,ke)=>{const We=()=>s()==="sessions"&&r()===ke();return(()=>{var Oe=RX(),je=Oe.firstChild,dt=je.firstChild,Lt=dt.firstChild,be=Lt.firstChild,ee=be.firstChild,Re=ee.firstChild,He=ee.nextSibling,qe=He.firstChild,de=qe.nextSibling,ge=de.nextSibling;return dt.addEventListener("mouseenter",()=>{o("sessions"),i(ke())}),dt.$$click=()=>A(se.id),C(Re,()=>se.title||"Untitled Session"),C(qe,()=>se.agent),C(ge,()=>k(se.time.updated)),C(je,S(W,{get when(){return We()},get children(){var Ce=CX(),Ke=Ce.firstChild,$e=Ke.nextSibling,Be=$e.nextSibling;return $e.$$click=tt=>{tt.preventDefault(),tt.stopPropagation(),B(se.id,se.title||"")},C($e,S(iT,{class:"w-4 h-4"})),Be.$$click=tt=>{tt.preventDefault(),tt.stopPropagation(),V(se.id)},C(Be,S(W,{get when(){return!h(se.id)},get fallback(){return Gv()},get children(){return S(al,{class:"w-4 h-4"})}})),ne(()=>Be.disabled=h(se.id)),Ce}}),null),ne(Ce=>{var Ke=!!We(),$e=ke(),Be=!!We();return Ke!==Ce.e&&Oe.classList.toggle("panel-list-item-highlight",Ce.e=Ke),$e!==Ce.t&&Fe(dt,"data-session-index",Ce.t=$e),Be!==Ce.a&&Re.classList.toggle("text-accent",Ce.a=Be),Ce},{e:void 0,t:void 0,a:void 0}),Oe})()}})),ae}}),P),Ae.$$click=L,C(ie,(()=>{var ae=we(()=>!!t());return()=>ae()?Gv():IX()})(),re),C(Ae,S(ir,{get shortcut(){return f()},class:"ml-2"}),null),C(Se,S(Uf,{get instance(){return e.instance}})),C(R,S(W,{get when(){return we(()=>!c())()&&a()},get children(){var ae=SX(),N=ae.firstChild,H=N.firstChild,te=H.firstChild,Q=te.firstChild,z=te.nextSibling;return ae.$$click=y,H.$$click=he=>he.stopPropagation(),Q.$$click=y,C(z,S(Uf,{get instance(){return e.instance}})),ae}}),q),C(R,S(WA,{get open(){return!!u()},get currentTitle(){var ae;return((ae=u())==null?void 0:ae.title)??""},get sessionLabel(){var ae;return(ae=u())==null?void 0:ae.label},get isSubmitting(){return m()},onRename:M,onClose:$}),null),ne(()=>Ae.disabled=t()),R})()};Ht(["click"]);var NX=x("<button type=button class=button-tertiary>Hide server logs"),AX=x("<button class=scroll-to-bottom>Scroll to bottom"),wX=x('<div class=log-container><div class="flex-1 flex flex-col lg:flex-row gap-4 p-4 overflow-hidden"><div class="lg:w-80 flex-shrink-0 overflow-y-auto"></div><div class="panel flex-1 flex flex-col min-h-0 overflow-hidden"><div class=log-header><h2 class=panel-title>Server Logs</h2><div class="flex items-center gap-2"></div></div><div class=log-content>'),xX=x("<button type=button class=button-tertiary>Show server logs"),DX=x("<div class=log-paused-state><p class=log-paused-title>Server logs are paused</p><p class=log-paused-description>Enable streaming to watch your OpenCode server activity.</p><button type=button class=button-primary>Show server logs"),LX=x("<div class=log-empty-state>Waiting for server output..."),kX=x("<div class=log-entry><span class=log-timestamp></span><span>");const Vv=new Map,MX=e=>{let t;const n=Vv.get(e.instanceId),[r,i]=U((n==null?void 0:n.autoScroll)??!1),s=()=>Et().get(e.instanceId),o=F(()=>eU(e.instanceId)),a=F(()=>mR(e.instanceId)),l=()=>qS(e.instanceId,!0),c=()=>qS(e.instanceId,!1);Tn(()=>{t&&n&&(t.scrollTop=n.scrollTop)}),Ne(()=>{t&&Vv.set(e.instanceId,{scrollTop:t.scrollTop,autoScroll:r()})}),J(()=>{r()&&t&&o().length>0&&(t.scrollTop=t.scrollHeight)});const d=()=>{if(!t)return;const g=t.scrollHeight-t.scrollTop<=t.clientHeight+50;i(g)},u=()=>{t&&(t.scrollTop=t.scrollHeight,i(!0))},_=g=>new Date(g).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),m=g=>{switch(g){case"error":return"log-level-error";case"warn":return"log-level-warn";case"debug":return"log-level-debug";default:return"log-level-default"}};return(()=>{var g=wX(),p=g.firstChild,E=p.firstChild,h=E.nextSibling,f=h.firstChild,b=f.firstChild,y=b.nextSibling,v=f.nextSibling;C(E,S(W,{get when(){return s()},children:T=>S(Uf,{get instance(){return T()}})})),C(y,S(W,{get when(){return a()},get fallback(){return(()=>{var T=xX();return T.$$click=l,T})()},get children(){var T=NX();return T.$$click=c,T}})),v.addEventListener("scroll",d);var O=t;return typeof O=="function"?wt(O,v):t=v,C(v,S(W,{get when(){return a()},get fallback(){return(()=>{var T=DX(),I=T.firstChild,k=I.nextSibling,A=k.nextSibling;return A.$$click=l,T})()},get children(){return S(W,{get when(){return o().length>0},get fallback(){return LX()},get children(){return S(_t,{get each(){return o()},children:T=>(()=>{var I=kX(),k=I.firstChild,A=k.nextSibling;return C(k,()=>_(T.timestamp)),C(A,()=>T.message),ne(()=>rt(A,`log-message ${m(T.level)}`)),I})()})}})}})),C(h,S(W,{get when(){return we(()=>!r())()&&a()},get children(){var T=AX(),I=T.firstChild;return T.$$click=u,C(T,S(Qc,{class:"w-4 h-4"}),I),T}}),null),g})()};Ht(["click"]);var PX=x("<div class=sidebar-selector>"),$X=x("<span>"),FX=x("<span class=neutral-badge>subagent"),BX=x('<div class="flex flex-col flex-1 min-w-0">'),UX=x("<div class=selector-trigger-label><span class=selector-trigger-primary>Agent: ");const GX=vt("session");function VX(e){const t=()=>A_().get(e.instanceId)||[],n=F(()=>{const o=Ft().get(e.instanceId);return o==null?void 0:o.get(e.sessionId)}),r=F(()=>{var o,a;return((o=n())==null?void 0:o.parentId)!==null&&((a=n())==null?void 0:a.parentId)!==void 0}),i=F(()=>{const o=t();if(r())return o;const a=o.filter(c=>c.mode!=="subagent"),l=o.find(c=>c.name===e.currentAgent);return l&&!a.find(c=>c.name===e.currentAgent)?[l,...a]:a});J(()=>{const o=i();o.length!==0&&(o.some(a=>a.name===e.currentAgent)||e.onAgentChange(o[0].name))}),J(()=>{t().length===0&&yR(e.instanceId).catch(o=>GX.error("Failed to fetch agents",o))});const s=async o=>{o&&o.name!==e.currentAgent&&await e.onAgentChange(o.name)};return(()=>{var o=PX();return C(o,S(pi,{get value(){return i().find(a=>a.name===e.currentAgent)},onChange:s,get options(){return i()},optionValue:"name",optionTextValue:"name",placeholder:"Select agent...",itemComponent:a=>S(pi.Item,{get item(){return a.item},class:"selector-option",get children(){var l=BX();return C(l,S(pi.ItemLabel,{class:"selector-option-label flex items-center gap-2",get children(){return[(()=>{var c=$X();return C(c,()=>a.item.rawValue.name),c})(),S(W,{get when(){return a.item.rawValue.mode==="subagent"},get children(){return FX()}})]}}),null),C(l,S(W,{get when(){return a.item.rawValue.description},get children(){return S(pi.ItemDescription,{class:"selector-option-description",get children(){return we(()=>a.item.rawValue.description.length>50)()?a.item.rawValue.description.slice(0,50)+"...":a.item.rawValue.description}})}}),null),l}}),get children(){return[S(pi.Trigger,{"data-agent-selector":!0,class:"selector-trigger",get children(){return[S(pi.Value,{children:a=>(()=>{var l=UX(),c=l.firstChild;return c.firstChild,C(c,()=>{var d;return((d=a.selectedOption())==null?void 0:d.name)??"None"},null),l})()}),S(pi.Icon,{class:"selector-trigger-icon",get children(){return S(Qc,{class:"w-3 h-3"})}})]}}),S(pi.Portal,{get children(){return S(pi.Content,{class:"selector-popover max-h-80 overflow-auto p-1",get children(){return S(pi.Listbox,{class:"selector-listbox"})}})}})]}})),o})()}var HX=x('<div class="selector-trigger-label selector-trigger-label--stacked"><span class="selector-trigger-primary selector-trigger-primary--align-left">Model: '),YX=x("<div class=selector-search-container>"),zX=x("<div class=sidebar-selector>"),WX=x("<div class=selector-option-content>"),qX=x('<svg class="w-4 h-4"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M5 13l4 4L19 7">'),KX=x("<span class=selector-trigger-secondary>/");const QX=vt("session");function jX(e){const t=()=>ul().get(e.instanceId)||[],[n,r]=U(!1);let i,s;J(()=>{t().length===0&&TR(e.instanceId).catch(d=>QX.error("Failed to fetch providers",d))});const o=F(()=>t().flatMap(d=>d.models.map(u=>({...u,providerName:d.name,key:`${u.providerId}/${u.id}`,searchText:`${u.name} ${d.name} ${u.providerId} ${u.id} ${u.providerId}/${u.id}`})))),a=F(()=>o().find(d=>d.providerId===e.currentModel.providerId&&d.id===e.currentModel.modelId)),l=async d=>{d&&await e.onModelChange({providerId:d.providerId,modelId:d.id})},c=(d,u)=>d.searchText.toLowerCase().includes(u.toLowerCase());return J(()=>{n()&&setTimeout(()=>{s==null||s.focus()},100)}),(()=>{var d=zX();return C(d,S(Tr,{get value(){return a()},onChange:l,onOpenChange:r,get options(){return o()},optionValue:"key",optionTextValue:"searchText",optionLabel:"name",placeholder:"Search models...",defaultFilter:c,allowsEmptyCollection:!0,itemComponent:u=>S(Tr.Item,{get item(){return u.item},class:"selector-option",get children(){return[(()=>{var _=WX();return C(_,S(Tr.ItemLabel,{class:"selector-option-label",get children(){return u.item.rawValue.name}}),null),C(_,S(Tr.ItemDescription,{class:"selector-option-description",get children(){return[we(()=>u.item.rawValue.providerName)," • ",we(()=>u.item.rawValue.providerId),"/",we(()=>u.item.rawValue.id)]}}),null),_})(),S(Tr.ItemIndicator,{class:"selector-option-indicator",get children(){return qX()}})]}}),get children(){return[S(Tr.Control,{class:"relative w-full","data-model-selector-control":!0,get children(){return[S(Tr.Input,{class:"sr-only","data-model-selector":!0}),S(Tr.Trigger,{ref(u){var _=i;typeof _=="function"?_(u):i=u},class:"selector-trigger",get children(){return[(()=>{var u=HX(),_=u.firstChild;return _.firstChild,C(_,()=>{var m;return((m=a())==null?void 0:m.name)??"None"},null),C(u,(()=>{var m=we(()=>!!a());return()=>m()&&(()=>{var g=KX(),p=g.firstChild;return C(g,()=>a().providerId,p),C(g,()=>a().id,null),g})()})(),null),u})(),S(Tr.Icon,{class:"selector-trigger-icon",get children(){return S(Qc,{class:"w-3 h-3"})}})]}})]}}),S(Tr.Portal,{get children(){return S(Tr.Content,{class:"selector-popover",get children(){return[(()=>{var u=YX();return C(u,S(Tr.Input,{ref(_){var m=s;typeof m=="function"?m(_):s=_},class:"selector-search-input",placeholder:"Search models..."})),u})(),S(Tr.Listbox,{class:"selector-listbox"})]}})}})]}})),d})()}var XX=x('<div class=modal-search-container><div class="flex items-center gap-3"><svg class="w-5 h-5 modal-search-icon"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg><input type=text placeholder="Type a command or search..."class=modal-search-input>'),ZX=x("<div class=modal-list-container>"),JX=x('<div class="fixed inset-0 z-50 flex items-start justify-center pt-[20vh]">'),eZ=x('<div class=modal-empty-state>No commands found for "<!>"'),tZ=x("<div class=py-2><div class=modal-section-header>"),nZ=x("<div class=mt-1>"),rZ=x('<button type=button><div class="flex-1 min-w-0"><div class=modal-item-label></div><div class=modal-item-description>');function iZ(e){if(!e)return"";const t=[];return(e.meta||e.ctrl)&&t.push("cmd"),e.shift&&t.push("shift"),e.alt&&t.push("alt"),t.push(e.key),t.join("+")}const sZ=e=>{const[t,n]=U(""),[r,i]=U(null),[s,o]=U(!1);let a,l;const c=["Custom Commands","Instance","Session","Agent & Model","Input & Focus","System","Other"],d=F(()=>{const h=e.commands??[],f=t().trim().toLowerCase(),b=f?h.filter(k=>{var L,R;const V=(typeof k.label=="function"?k.label():k.label).toLowerCase().includes(f),B=k.description.toLowerCase().includes(f),$=(L=k.keywords)==null?void 0:L.some(D=>D.toLowerCase().includes(f)),M=(R=k.category)==null?void 0:R.toLowerCase().includes(f);return V||B||$||M}):h,y=new Map;for(const k of b){const A=k.category||"Other",V=y.get(A);V?V.push(k):y.set(A,[k])}const v=[],O=[],T=new Set,I=k=>{const A=y.get(k);!A||A.length===0||T.has(k)||(v.push({category:k,commands:A,startIndex:O.length}),O.push(...A),T.add(k))};for(const k of c)I(k);for(const[k]of y)I(k);return{groups:v,ordered:O}}),u=()=>d().groups,_=()=>d().ordered,m=F(()=>{const h=_();if(h.length===0)return-1;const f=r();if(!f)return 0;const b=h.findIndex(y=>y.id===f);return b>=0?b:0});J(()=>{e.open&&(n(""),i(null),o(!1),setTimeout(()=>a==null?void 0:a.focus(),100))}),J(()=>{const h=_();if(h.length===0){r()!==null&&i(null);return}const f=r();(!f||!h.some(b=>b.id===f))&&i(h[0].id)}),J(()=>{const h=m();if(!l||h<0)return;const f=l.querySelector(`[data-command-index="${h}"]`);f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})});function g(h){var b,y;const f=_();if(h.key==="Escape"){h.preventDefault(),h.stopPropagation(),e.onClose();return}if(f.length===0){(h.key==="ArrowDown"||h.key==="ArrowUp"||h.key==="Enter")&&(h.preventDefault(),h.stopPropagation());return}if(h.key==="ArrowDown"){h.preventDefault(),h.stopPropagation(),o(!1);const v=m(),O=Math.min((v<0?0:v)+1,f.length-1);i(((b=f[O])==null?void 0:b.id)??null)}else if(h.key==="ArrowUp"){h.preventDefault(),h.stopPropagation(),o(!1);const v=m(),O=v<=0?f.length-1:v-1;i(((y=f[O])==null?void 0:y.id)??null)}else if(h.key==="Enter"){h.preventDefault(),h.stopPropagation();const v=m();if(v<0||v>=f.length)return;const O=f[v];if(!O)return;e.onExecute(O),e.onClose()}}function p(h){e.onExecute(h),e.onClose()}function E(){o(!1)}return S(ft,{get open(){return e.open},onOpenChange:h=>!h&&e.onClose(),get children(){return S(ft.Portal,{get children(){return[S(ft.Overlay,{class:"modal-overlay"}),(()=>{var h=JX();return C(h,S(ft.Content,{class:"modal-surface w-full max-w-2xl max-h-[60vh]",onKeyDown:g,get children(){return[S(ft.Title,{class:"sr-only",children:"Command Palette"}),S(ft.Description,{class:"sr-only",children:"Search and execute commands"}),(()=>{var f=XX(),b=f.firstChild,y=b.firstChild,v=y.nextSibling;v.$$input=T=>{n(T.currentTarget.value),i(null)};var O=a;return typeof O=="function"?wt(O,v):a=v,ne(()=>v.value=t()),f})(),(()=>{var f=ZX();f.addEventListener("pointerleave",E);var b=l;return typeof b=="function"?wt(b,f):l=f,C(f,S(W,{get when(){return _().length>0},get fallback(){return(()=>{var y=eZ(),v=y.firstChild,O=v.nextSibling;return O.nextSibling,C(y,t,O),y})()},get children(){return S(_t,{get each(){return u()},children:y=>(()=>{var v=tZ(),O=v.firstChild;return C(O,()=>y.category),C(v,S(_t,{get each(){return y.commands},children:(T,I)=>{const k=y.startIndex+I();return(()=>{var A=rZ(),V=A.firstChild,B=V.firstChild,$=B.nextSibling;return A.$$pointermove=M=>{M.movementX===0&&M.movementY===0||(M.pointerType==="mouse"||M.pointerType==="pen"||M.pointerType==="touch")&&(s()||o(!0),i(T.id))},A.$$click=()=>p(T),Fe(A,"data-command-index",k),C(B,(()=>{var M=we(()=>typeof T.label=="function");return()=>M()?T.label():T.label})()),C($,()=>T.description),C(A,S(W,{get when(){return T.shortcut},get children(){var M=nZ();return C(M,S(ir,{get shortcut(){return iZ(T.shortcut)}})),M}}),null),ne(()=>rt(A,`modal-item ${r()===T.id?"modal-item-highlight":""}`)),A})()}}),null),v})()})}})),ne(()=>Fe(f,"data-pointer-mode",s()?"pointer":"keyboard")),f})()]}})),h})()]}})}})};Ht(["input","click","pointermove"]);var oZ=x("<button type=button class=permission-center-trigger><span class=permission-center-count aria-hidden=true>");const Hv=e=>{const t=F(()=>sU(e.instanceId)),n=F(()=>oU(e.instanceId)),r=F(()=>t()+n()),i=F(()=>r()>0),s=F(()=>{const o=r(),a=[];t()>0&&a.push(`${t()} permission${t()===1?"":"s"}`),n()>0&&a.push(`${n()} question${n()===1?"":"s"}`);const l=a.length?` (${a.join(", ")})`:"";return`${o} pending request${o===1?"":"s"}${l}`});return S(W,{get when(){return i()},get children(){var o=oZ(),a=o.firstChild;return Fn(o,"click",e.onClick,!0),C(o,S(__,{class:"permission-center-icon","aria-hidden":"true"}),a),C(a,(()=>{var l=we(()=>r()>9);return()=>l()?"9+":r()})()),ne(l=>{var c=s(),d=s();return c!==l.e&&Fe(o,"aria-label",l.e=c),d!==l.t&&Fe(o,"title",l.t=d),l},{e:void 0,t:void 0}),o}})};Ht(["click"]);var aZ=x("<span class=permission-center-modal-count>"),lZ=x("<div class=permission-center-list role=list>"),cZ=x("<div class=permission-center-modal-backdrop><div class=permission-center-modal role=dialog aria-modal=true aria-labelledby=permission-center-title><div class=permission-center-modal-header><div class=permission-center-modal-title-row><h2 id=permission-center-title class=permission-center-modal-title>Requests</h2></div><button type=button class=permission-center-modal-close aria-label=Close>✕</button></div><div class=permission-center-modal-body>"),dZ=x("<div class=permission-center-empty>No pending requests."),uZ=x("<span class=permission-center-item-chip>Active"),_Z=x("<button type=button class=permission-center-item-action>"),mZ=x("<div role=listitem><div class=permission-center-item-header><div class=permission-center-item-heading><span></span><span class=permission-center-item-kind></span></div><div class=permission-center-item-actions><button type=button class=permission-center-item-action>Go to Session"),gZ=x("<div class=permission-center-fallback><div class=permission-center-fallback-title><code></code></div><div class=permission-center-fallback-hint>Load session for more information.");function fZ(e,t){var d;const n=jc(t),r=TT(t);if(!n||!r)return null;const i=Ut.getInstance(e);if(!i)return null;const s=i.getMessage(r);if(!s)return null;const o=t.metadata||{},a=t.partID??t.partId??o.partID??o.partId??void 0,l=CT(t),c=u=>{var g;const _=(g=s.parts)==null?void 0:g[u],m=_==null?void 0:_.data;return!m||m.type!=="tool"?null:{toolPart:m,partVersion:_.revision??0}};if(typeof a=="string"&&a.length>0){const u=c(a);if(u)return{messageId:r,sessionId:n,toolPart:u.toolPart,messageVersion:s.revision,partVersion:u.partVersion}}if(l)for(const u of s.partIds){const _=(d=s.parts)==null?void 0:d[u],m=_==null?void 0:_.data;if(!m||m.type!=="tool")continue;if((m.callID??m.callId??m.toolCallID??m.toolCallId??void 0)===l&&typeof m.id=="string"&&m.id.length>0)return{messageId:r,sessionId:n,toolPart:m,messageVersion:s.revision,partVersion:_.revision??0}}return null}function pZ(e,t){var a;const n=E_(t),r=IT(t);if(!n||!r)return null;const i=Ut.getInstance(e);if(!i)return null;const s=i.getMessage(r);if(!s)return null;const o=OT(t);if(!o)return null;for(const l of s.partIds){const c=(a=s.parts)==null?void 0:a[l],d=c==null?void 0:c.data;if(!(!d||d.type!=="tool"||(d.callID??d.callId??d.toolCallID??d.toolCallId??void 0)!==o)&&!(typeof d.id!="string"||d.id.length===0))return{messageId:r,sessionId:n,toolPart:d,messageVersion:s.revision,partVersion:(c==null?void 0:c.revision)??0}}return null}const hZ=e=>{const[t,n]=U(null),r=F(()=>td(e.instanceId)),i=F(()=>Vo(e.instanceId)),s=F(()=>cR().get(e.instanceId)??null),o=F(()=>{const _=r().map(g=>{var p;return{kind:"permission",id:g.id,sessionId:jc(g)||"",createdAt:((p=g==null?void 0:g.time)==null?void 0:p.created)??Date.now(),payload:g}}),m=i().map(g=>({kind:"question",id:g.id,sessionId:E_(g)||"",createdAt:aU(e.instanceId,g.id),payload:g}));return[..._,...m].sort((g,p)=>g.createdAt-p.createdAt)}),a=F(()=>o().length>0),l=_=>{_.key==="Escape"&&(_.preventDefault(),e.onClose())};J(()=>{e.isOpen&&(document.addEventListener("keydown",l),Ne(()=>document.removeEventListener("keydown",l)))}),J(()=>{e.isOpen&&o().length===0&&e.onClose()});function c(_){_.target===_.currentTarget&&e.onClose()}async function d(_){if(_){n(_);try{await Pu(e.instanceId,_)}finally{n(m=>m===_?null:m)}}}function u(_){var p;if(!_)return;const m=(p=Ft().get(e.instanceId))==null?void 0:p.get(_),g=(m==null?void 0:m.parentId)??(m==null?void 0:m.id);g&&Zg(e.instanceId,g),Ka(e.instanceId,_),e.onClose()}return S(W,{get when(){return e.isOpen},get children(){var _=cZ(),m=_.firstChild,g=m.firstChild,p=g.firstChild;p.firstChild;var E=p.nextSibling,h=g.nextSibling;return _.$$click=c,C(p,S(W,{get when(){return o().length>0},get children(){var f=aZ();return C(f,()=>o().length),f}}),null),Fn(E,"click",e.onClose,!0),C(h,S(W,{get when(){return a()},get fallback(){return dZ()},get children(){var f=lZ();return C(f,S(_t,{get each(){return o()},children:b=>{const y=()=>{var B,$;return((B=s())==null?void 0:B.kind)===b.kind&&(($=s())==null?void 0:$.id)===b.id},v=()=>b.sessionId,O=F(()=>b.kind==="permission"?fZ(e.instanceId,b.payload):pZ(e.instanceId,b.payload)),T=()=>!O(),I=()=>b.kind==="permission"?"Permission":"Question",k=()=>{var $,M;if(b.kind==="permission")return RT(b.payload);const B=(M=($=b.payload.questions)==null?void 0:$[0])==null?void 0:M.question;return typeof B=="string"&&B.trim().length>0?B:"Question"},A=()=>{var $;if(b.kind==="permission")return h_(b.payload);const B=(($=b.payload.questions)==null?void 0:$.length)??0;return B===1?"1 question":`${B} questions`},V=()=>{b.kind==="permission"?hU(e.instanceId,b.id):EU(e.instanceId,b.id)};return(()=>{var B=mZ(),$=B.firstChild,M=$.firstChild,L=M.firstChild,R=L.nextSibling,D=M.nextSibling,w=D.firstChild;return B.$$click=V,C(L,I),C(R,A),C(M,S(W,{get when(){return y()},get children(){return uZ()}}),null),w.$$click=P=>{P.stopPropagation(),u(v())},C(D,S(W,{get when(){return T()},get children(){var P=_Z();return P.$$click=j=>{j.stopPropagation(),d(v())},C(P,()=>t()===v()?"Loading…":"Load Session"),ne(()=>P.disabled=t()===v()),P}}),null),C(B,S(W,{get when(){return O()},get fallback(){return(()=>{var P=gZ(),j=P.firstChild,le=j.firstChild;return C(le,k),P})()},children:P=>S(iE,{get toolCall(){return P().toolPart},get toolCallId(){return P().toolPart.id},get messageId(){return P().messageId},get messageVersion(){return P().messageVersion},get partVersion(){return P().partVersion},get instanceId(){return e.instanceId},get sessionId(){return P().sessionId}})}),null),ne(P=>{var j=`permission-center-item${y()?" permission-center-item-active":""}`,le=`permission-center-item-chip permission-center-item-chip-${b.kind}`;return j!==P.e&&rt(B,P.e=j),le!==P.t&&rt(L,P.t=le),P},{e:void 0,t:void 0}),B})()}})),f}})),_}})};Ht(["click"]);var EZ=x('<div class="session-context-panel border-r border-base border-b px-3 py-3 space-y-3"><div class="flex flex-wrap items-center gap-2 text-xs text-primary/90"><div class="text-xs font-semibold text-primary/70 uppercase tracking-wide">Tokens</div><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Input</span><span class="font-semibold text-primary"></span></div><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Output</span><span class="font-semibold text-primary"></span></div><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Cost</span><span class="font-semibold text-primary"></span></div></div><div class="flex flex-wrap items-center gap-2 text-xs text-primary/90"><div class="text-xs font-semibold text-primary/70 uppercase tracking-wide">Context</div><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Used</span><span class="font-semibold text-primary"></span></div><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Avail</span><span class="font-semibold text-primary">');const SZ=e=>{const t=F(()=>Kp(e.instanceId,e.sessionId)??{cost:0,contextWindow:0,isSubscriptionModel:!1,inputTokens:0,outputTokens:0,reasoningTokens:0,actualUsageTokens:0,modelOutputLimit:0,contextAvailableTokens:null}),n=F(()=>t().inputTokens??0),r=F(()=>t().outputTokens??0),i=F(()=>t().actualUsageTokens??0),s=F(()=>t().contextAvailableTokens);F(()=>t().modelOutputLimit??0);const o=F(()=>{const c=t().isSubscriptionModel?0:t().cost;return c>0?c:0}),a=c=>c==null?"--":yi(c),l=F(()=>`$${o().toFixed(2)}`);return(()=>{var c=EZ(),d=c.firstChild,u=d.firstChild,_=u.nextSibling,m=_.firstChild,g=m.nextSibling,p=_.nextSibling,E=p.firstChild,h=E.nextSibling,f=p.nextSibling,b=f.firstChild,y=b.nextSibling,v=d.nextSibling,O=v.firstChild,T=O.nextSibling,I=T.firstChild,k=I.nextSibling,A=T.nextSibling,V=A.firstChild,B=V.nextSibling;return C(g,()=>yi(n())),C(h,()=>yi(r())),C(y,l),C(k,()=>yi(i())),C(B,()=>a(s())),c})()};var bZ=x("<div style=width:100%><div style=width:100%><div>");const Ml=new Map,vZ=600,yZ=32,Yv=48,TZ="__null__",zv=new WeakMap;let CZ=0;const cg=new Map;function RZ(e,t){if(!e)return`${TZ}:${t}`;let n=zv.get(e);return n===void 0&&(n=++CZ,zv.set(e,n)),`${n}:${t}`}function IZ(e,t){const n=new Map;return{observer:new IntersectionObserver(i=>{i.forEach(s=>{const o=n.get(s.target);o&&o.forEach(a=>a(s))})},{root:e??void 0,rootMargin:`${t}px 0px ${t}px 0px`}),listeners:n}}function OZ(e){const t=e.rootBounds;if(!t)return e.isIntersecting;const n=t.top-e.boundingClientRect.bottom,r=e.boundingClientRect.top-t.bottom;return!(n>Yv||r>Yv)}function NZ(e,t,n,r){if(typeof IntersectionObserver>"u")return r({isIntersecting:!0}),()=>{};const i=RZ(t,n);let s=cg.get(i);s||(s=IZ(t,n),cg.set(i,s));let o=s.listeners.get(e);return o||(o=new Set,s.listeners.set(e,o),s.observer.observe(e)),o.add(r),()=>{const a=s==null?void 0:s.listeners.get(e);a&&(a.delete(r),a.size===0&&(s==null||s.listeners.delete(e),s==null||s.observer.unobserve(e))),s&&s.listeners.size===0&&(s.observer.disconnect(),cg.delete(i))}}function AZ(e){const t=$o(()=>e.children),n=Ml.get(e.cacheKey),[r,i]=U(!0),[s,o]=U(n??0),[a,l]=U(n!==void 0);let c=!!(n&&n>0),d=null,u=null;const _=()=>{u!==null&&(cancelAnimationFrame(u),u=null),d!==null&&(i(d),d=null)},m=w=>{d=w,u===null&&(u=requestAnimationFrame(()=>{u=null,d!==null&&(i(d),d=null)}))},g=()=>e.virtualizationEnabled?e.virtualizationEnabled():!0,p=F(()=>{var w;return(w=e.forceVisible)!=null&&w.call(e)||!g()?!1:!r()}),E=()=>{var w;return!!((w=e.suspendMeasurements)!=null&&w.call(e))};let h,f,b,y;function v(){b&&(b.disconnect(),b=void 0)}function O(){y&&(y(),y=void 0)}function T(w){var me,Ae;if(!Number.isFinite(w)||w<0)return;const P=w,j=Ml.get(e.cacheKey)??s();if(j>0&&(P===0||P>0&&P<j)){c||(c=!0,(me=e.onMeasured)==null||me.call(e)),l(!0),Ml.set(e.cacheKey,j),o(j);return}P>0&&(Ml.set(e.cacheKey,P),l(!0),c||(c=!0,(Ae=e.onMeasured)==null||Ae.call(e))),o(P)}function I(){if(!f||E())return;const w=f.offsetHeight;w!==s()&&T(w)}function k(){if(!(!f||E())){if(v(),typeof ResizeObserver>"u"){I();return}b=new ResizeObserver(()=>{E()||I()}),b.observe(f)}}function A(w){if(O(),!h){i(!0);return}if(typeof IntersectionObserver>"u"){i(!0);return}const P=e.threshold??vZ;y=NZ(h,w,P,j=>{const le=OZ(j);m(le)})}function V(w){h=w??void 0;const P=e.scrollContainer?e.scrollContainer():null;A(P??null)}function B(w){f=w??void 0,f?queueMicrotask(()=>{p()||E()||(I(),k())}):v()}J(()=>{p()||E()?v():f&&queueMicrotask(()=>{I(),k()})}),J(()=>{const w=e.cacheKey,P=Ml.get(w);P!==void 0?(o(P),l(!0)):(o(0),l(!1))}),J(()=>{E();const w=e.scrollContainer?e.scrollContainer():null;A(w??null)});const $=F(()=>{const w=s();return w>0?w:e.minPlaceholderHeight??yZ});Ne(()=>{v(),O(),_()});const M=()=>["virtual-item-wrapper",e.class].filter(Boolean).join(" "),L=()=>{const w=["virtual-item-content",e.contentClass];return p()&&w.push("virtual-item-content-hidden"),w.filter(Boolean).join(" ")},R=()=>["virtual-item-placeholder",e.placeholderClass].filter(Boolean).join(" "),D=F(()=>p()?null:t());return(()=>{var w=bZ(),P=w.firstChild,j=P.firstChild,le=V;typeof le=="function"?wt(le,w):V=w;var me=B;return typeof me=="function"?wt(me,j):B=j,C(j,D),ne(Ae=>{var ie=e.id,re=M(),Ee=R(),Se=p()?`${$()}px`:void 0,q=L();return ie!==Ae.e&&Fe(w,"id",Ae.e=ie),re!==Ae.t&&rt(w,Ae.t=re),Ee!==Ae.a&&rt(P,Ae.a=Ee),Se!==Ae.o&&Ci(P,"height",Ae.o=Se),q!==Ae.i&&rt(j,Ae.i=q),Ae},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),w})()}var wZ=x("<div aria-hidden=true style=height:1px>");function Gf(e){return`message-anchor-${e}`}const xZ=800;function DZ(e){return[S(Cw,{get each(){return e.messageIds()},children:(t,n)=>S(AZ,{get id(){return Gf(t())},get cacheKey(){return t()},get scrollContainer(){return e.scrollContainer},threshold:xZ,placeholderClass:"message-stream-placeholder",virtualizationEnabled:()=>!e.loading,get suspendMeasurements(){return e.suspendMeasurements},get children(){return S(GA,{get messageId(){return t()},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get store(){return e.store},messageIndex:n,get lastAssistantIndex(){return e.lastAssistantIndex},get showThinking(){return e.showThinking},get thinkingDefaultExpanded(){return e.thinkingDefaultExpanded},get showUsageMetrics(){return e.showUsageMetrics},get onRevert(){return e.onRevert},get onFork(){return e.onFork},get onContentRendered(){return e.onContentRendered}})}})}),(()=>{var t=wZ(),n=e.setBottomSentinel;return typeof n=="function"?wt(n,t):e.setBottomSentinel=t,t})()]}var LZ=x('<div class="message-preview message-stream">');const kZ=e=>{const t=()=>0;return(()=>{var n=LZ();return C(n,S(GA,{get messageId(){return e.messageId},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get store(){return e.store},messageIndex:0,lastAssistantIndex:t,showThinking:()=>!1,thinkingDefaultExpanded:()=>!1,showUsageMetrics:()=>!1})),n})()};var MZ=x('<div class=message-timeline role=navigation aria-label="Message timeline">'),PZ=x('<button type=button><span class="message-timeline-label message-timeline-label-full"></span><span class="message-timeline-label message-timeline-label-short">'),$Z=x("<div class=message-timeline-tooltip>");const Wv={user:"You",assistant:"Asst",tool:"Tool",compaction:"Compaction"},Hc="Tool Call",qv=220;function QA(e){return e.length<=qv?e:`${e.slice(0,qv-1).trimEnd()}…`}function jA(e){const t=n=>{if(typeof n=="string")return n;if(n&&typeof n=="object"){const r=n,i=[];return typeof r.text=="string"&&i.push(r.text),typeof r.value=="string"&&i.push(r.value),Array.isArray(r.content)&&i.push(r.content.map(s=>t(s)).join(`
162
+ `):""},a=()=>n(l=>!l);return(()=>{var l=Z7(),c=l.firstChild,d=c.firstChild;d.firstChild;var u=d.nextSibling,_=u.firstChild,m=_.nextSibling;return c.$$click=a,C(d,S(W,{get when(){return we(()=>!!e.showAgentMeta)()&&(i()||s())},get children(){var g=BA();return C(g,S(W,{get when(){return i()},children:p=>(()=>{var E=J7();return E.firstChild,C(E,p,null),E})()}),null),C(g,S(W,{get when(){return s()},children:p=>(()=>{var E=ej();return E.firstChild,C(E,p,null),E})()}),null),g}}),null),C(_,()=>t()?"Hide":"View"),C(m,r),C(l,S(W,{get when(){return t()},get children(){var g=X7(),p=g.firstChild,E=p.firstChild,h=E.firstChild;return C(h,()=>o()||""),g}}),null),ne(g=>{var p=t(),E=t()?"Collapse thinking":"Expand thinking";return p!==g.e&&Fe(c,"aria-expanded",g.e=p),E!==g.t&&Fe(c,"aria-label",g.t=E),g},{e:void 0,t:void 0}),l})()}Ht(["click"]);const[fj,VA]=U(new Map);function HA(e,t){VA(n=>{const r=new Map(n);return r.set(e,t),r})}function YA(e){e&&HA(e,!0)}function zA(e){if(!e){VA(new Map);return}HA(e,!1)}function pj(e){return fj().get(e)??!1}var hj=x('<form class="mt-4 space-y-4"><div class=space-y-2><label class="text-sm font-medium text-secondary">Session name</label><input type=text placeholder="Enter a session name"class="w-full px-3 py-2 text-sm bg-surface-base border border-base rounded text-primary focus-ring-accent"></div><div class="flex justify-end gap-3"><button type=button class=button-tertiary>Cancel</button><button type=submit class="button-primary flex items-center gap-2 disabled:opacity-60 disabled:cursor-not-allowed">'),Ej=x('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),Sj=x('<svg class="animate-spin h-4 w-4"fill=none viewBox="0 0 24 24"><circle class=opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=opacity-75 fill=currentColor d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">'),bj=x("<span>Renaming…");const WA=e=>{const[t,n]=U(""),r=`session-rename-${Math.random().toString(36).slice(2)}`;let i;J(()=>{e.open&&n(e.currentTitle??"")}),J(()=>{e.open&&(typeof window>"u"||typeof window.requestAnimationFrame!="function"||window.requestAnimationFrame(()=>{i==null||i.focus(),i==null||i.select()}))});const s=()=>!!e.isSubmitting,o=()=>s()||!t().trim();async function a(c){c==null||c.preventDefault(),!o()&&await e.onRename(t().trim())}const l=()=>e.sessionLabel&&e.sessionLabel.trim()?`Update the title for "${e.sessionLabel}".`:"Set a new title for this session.";return S(ft,{get open(){return e.open},onOpenChange:c=>{!c&&!s()&&e.onClose()},get children(){return S(ft.Portal,{get children(){return[S(ft.Overlay,{class:"modal-overlay"}),(()=>{var c=Ej();return C(c,S(ft.Content,{class:"modal-surface w-full max-w-sm p-6",tabIndex:-1,get children(){return[S(ft.Title,{class:"text-lg font-semibold text-primary",children:"Rename Session"}),S(ft.Description,{class:"text-sm text-secondary mt-1",get children(){return l()}}),(()=>{var d=hj(),u=d.firstChild,_=u.firstChild,m=_.nextSibling,g=u.nextSibling,p=g.firstChild,E=p.nextSibling;return d.addEventListener("submit",a),Fe(_,"for",r),m.$$input=h=>n(h.currentTarget.value),wt(h=>{i=h},m),Fe(m,"id",r),p.$$click=()=>{s()||e.onClose()},C(E,S(W,{get when(){return!s()},get fallback(){return[Sj(),bj()]},children:"Rename"})),ne(h=>{var f=s(),b=o();return f!==h.e&&(p.disabled=h.e=f),b!==h.t&&(E.disabled=h.t=b),h},{e:void 0,t:void 0}),ne(()=>m.value=t()),d})()]}})),c})()]}})}})};Ht(["input","click"]);var vj=x("<span role=button tabindex=0>"),yj=x('<div class="session-list-item group"><button role=button><div class="session-item-row session-item-header"><div class=session-item-title-row><span class="session-item-title session-item-title--clamp"></span></div></div><div class="session-item-row session-item-meta"><div class="flex items-center gap-2 min-w-0"><span></span></div><div class=session-item-actions><span role=button tabindex=0 aria-label="Copy session ID"title="Copy session ID"></span><span role=button tabindex=0 aria-label="Rename session"title="Rename session"></span><span role=button tabindex=0 aria-label="Delete session"title="Delete session">'),Tj=x('<span class="session-item-expander session-item-expander--spacer"aria-hidden=true>'),Cj=x("<span class=status-dot>"),Rj=x('<svg class="animate-spin h-3 w-3"fill=none viewBox="0 0 24 24"><circle class=opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=opacity-75 fill=currentColor d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">'),Ij=x('<div class="session-list-header p-3 border-b border-base">'),Oj=x("<div class=session-section>"),Nj=x('<div class="session-list-footer p-3 border-t border-base">'),Aj=x('<div class="session-list-container bg-surface-secondary border-r border-base flex flex-col w-full"><div class="session-list flex-1 overflow-y-auto">'),wj=x('<div class="flex items-center justify-between gap-3"><h3 class="text-sm font-semibold text-primary">Sessions');const ig=vt("session");function xj(e){switch(e){case"working":return"Working";case"compacting":return"Compacting";default:return"Idle"}}const Dj=e=>{const[t,n]=U(null),[r,i]=U(!1),s=h=>{const f=xc().deletingSession.get(e.instanceId);return f?f.has(h):!1},o=h=>{var y;const f=(y=Ft().get(e.instanceId))==null?void 0:y.get(h),b=(f==null?void 0:f.parentId)??(f==null?void 0:f.id);b&&Zg(e.instanceId,b),e.onSelect(h)},a=async(h,f)=>{h.stopPropagation();try{const b=await Th(f);Pi(b?{message:"Session ID copied",variant:"success"}:{message:"Unable to copy session ID",variant:"error"})}catch(b){ig.error(`Failed to copy session ID ${f}:`,b),Pi({message:"Unable to copy session ID",variant:"error"})}},l=async(h,f)=>{if(h.stopPropagation(),s(f))return;const b=e.activeSessionId===f;let y;if(b){const v=Dc(e.instanceId),O=v.indexOf(f),T=v.filter(I=>I!==f);if(T.length>0){if(O!==-1){for(let I=O;I<v.length;I++){const k=v[I];if(k&&k!==f){y=k;break}}if(!y)for(let I=O-1;I>=0;I--){const k=v[I];if(k&&k!==f){y=k;break}}}y??(y=T[0])}}try{await Hp(e.instanceId,f),y&&Ka(e.instanceId,y)}catch(v){ig.error(`Failed to delete session ${f}:`,v),Pi({message:"Unable to delete session",variant:"error"})}},c=h=>{var y;const f=(y=Ft().get(e.instanceId))==null?void 0:y.get(h);if(!f)return;const b=f.title&&f.title.trim()?f.title:h;n({id:h,title:f.title??"",label:b})},d=()=>{n(null)},u=async h=>{const f=t();if(f){i(!0);try{await WT(e.instanceId,f.id,h),n(null)}catch(b){ig.error(`Failed to rename session ${f.id}:`,b),Pi({message:"Unable to rename session",variant:"error"})}finally{i(!1)}}},_=h=>{const f=F(()=>{var B;return(B=Ft().get(e.instanceId))==null?void 0:B.get(h.sessionId)});if(!f())return[];const b=()=>e.activeSessionId===h.sessionId,y=()=>{var B;return((B=f())==null?void 0:B.title)||"Untitled"},v=()=>DR(e.instanceId,h.sessionId),O=()=>xj(v()),T=()=>{var B;return!!((B=f())!=null&&B.pendingPermission)},I=()=>{var B;return!!((B=f())!=null&&B.pendingQuestion)},k=()=>T()||I(),A=()=>k()?"session-permission":`session-${v()}`,V=()=>T()?"Needs Permission":I()?"Needs Input":O();return(()=>{var B=yj(),$=B.firstChild,M=$.firstChild,L=M.firstChild,R=L.firstChild,D=M.nextSibling,w=D.firstChild,P=w.firstChild,j=w.nextSibling,le=j.firstChild,me=le.nextSibling,Ae=me.nextSibling;return $.$$click=()=>o(h.sessionId),C(L,(()=>{var ie=we(()=>!!h.isChild);return()=>ie()?S(eT,{class:"w-4 h-4 flex-shrink-0"}):S(sT,{class:"w-4 h-4 flex-shrink-0"})})(),R),C(R,y),C(w,S(W,{get when(){return we(()=>!!h.hasChildren)()&&!h.isChild},get fallback(){return we(()=>!!h.isChild)()?null:Tj()},get children(){var ie=vj();return ie.$$click=re=>{var Ee;re.stopPropagation(),(Ee=h.onToggleExpand)==null||Ee.call(h)},C(ie,S(Qc,{get class(){return`w-3.5 h-3.5 transition-transform ${h.expanded?"":"-rotate-90"}`}})),ne(re=>{var Ee=`session-item-expander opacity-80 hover:opacity-100 ${b()?"hover:bg-white/20":"hover:bg-surface-hover"}`,Se=h.expanded?"Collapse session":"Expand session",q=h.expanded?"Collapse":"Expand";return Ee!==re.e&&rt(ie,re.e=Ee),Se!==re.t&&Fe(ie,"aria-label",re.t=Se),q!==re.a&&Fe(ie,"title",re.a=q),re},{e:void 0,t:void 0,a:void 0}),ie}}),P),C(P,(()=>{var ie=we(()=>!!k());return()=>ie()?S(__,{class:"w-3.5 h-3.5","aria-hidden":"true"}):Cj()})(),null),C(P,V,null),le.$$click=ie=>a(ie,h.sessionId),C(le,S($D,{class:"w-3 h-3"})),me.$$click=ie=>{ie.stopPropagation(),c(h.sessionId)},C(me,S(iT,{class:"w-3 h-3"})),Ae.$$click=ie=>l(ie,h.sessionId),C(Ae,S(W,{get when(){return!s(h.sessionId)},get fallback(){return Rj()},get children(){return S(al,{class:"w-3 h-3"})}})),ne(ie=>{var re=`session-item-base ${h.isChild?`session-item-child${h.isLastChild?" session-item-child-last":""} session-item-border-assistant session-item-kind-assistant`:"session-item-border-user session-item-kind-user"} ${b()?"session-item-active":"session-item-inactive"}`,Ee=h.sessionId,Se=y(),q=b(),ae=h.hasChildren?!!h.expanded:void 0,N=`status-indicator session-status session-status-list ${A()}`,H=`session-item-close opacity-80 hover:opacity-100 ${b()?"hover:bg-white/20":"hover:bg-surface-hover"}`,te=`session-item-close opacity-80 hover:opacity-100 ${b()?"hover:bg-white/20":"hover:bg-surface-hover"}`,Q=`session-item-close opacity-80 hover:opacity-100 ${b()?"hover:bg-white/20":"hover:bg-surface-hover"}`;return re!==ie.e&&rt($,ie.e=re),Ee!==ie.t&&Fe($,"data-session-id",ie.t=Ee),Se!==ie.a&&Fe($,"title",ie.a=Se),q!==ie.o&&Fe($,"aria-selected",ie.o=q),ae!==ie.i&&Fe($,"aria-expanded",ie.i=ae),N!==ie.n&&rt(P,ie.n=N),H!==ie.s&&rt(le,ie.s=H),te!==ie.h&&rt(me,ie.h=te),Q!==ie.r&&rt(Ae,ie.r=Q),ie},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),B})()},m=F(()=>{var b;const h=e.activeSessionId;if(!h||h==="info")return null;const f=(b=Ft().get(e.instanceId))==null?void 0:b.get(h);return f?f.parentId??f.id:null});J(()=>{const h=m();h&&Zg(e.instanceId,h)});const g=U(null),p=h=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(h):h.replace(/\\/g,"\\\\").replace(/\"/g,'\\"'),E=h=>{const f=g[0]();if(!f)return;const b=`[data-session-id="${p(h)}"]`,y=()=>{const T=f.querySelector(b);T&&T.scrollIntoView({block:"nearest",inline:"nearest"})};if(typeof requestAnimationFrame>"u"){y();return}let v=0,O=0;v=requestAnimationFrame(()=>{O=requestAnimationFrame(()=>{y()})}),Ne(()=>{v&&cancelAnimationFrame(v),O&&cancelAnimationFrame(O)})};return J(()=>{const h=e.activeSessionId;!h||h==="info"||E(h)}),(()=>{var h=Aj(),f=h.firstChild;return C(h,S(W,{get when(){return e.showHeader!==!1},get children(){var b=Ij();return C(b,()=>e.headerContent??(()=>{var y=wj();return y.firstChild,C(y,S(Qp,{get shortcuts(){return[Hn.get("session-prev"),Hn.get("session-next")].filter(Boolean)}}),null),y})()),b}}),f),wt(b=>g[1](b),f),C(f,S(W,{get when(){return e.threads.length>0},get children(){var b=Oj();return C(b,S(_t,{get each(){return e.threads},children:y=>{const v=()=>wR(e.instanceId,y.parent.id);return[S(_,{get sessionId(){return y.parent.id},get hasChildren(){return y.children.length>0},get expanded(){return v()},onToggleExpand:()=>GU(e.instanceId,y.parent.id)}),S(W,{get when(){return we(()=>!!v())()&&y.children.length>0},get children(){return S(_t,{get each(){return y.children},children:(O,T)=>S(_,{get sessionId(){return O.id},isChild:!0,get isLastChild(){return T()===y.children.length-1}})})}})]}})),b}})),C(h,S(W,{get when(){return e.showFooter!==!1},get children(){var b=Nj();return C(b,()=>e.footerContent??null),b}}),null),C(h,S(WA,{get open(){return!!t()},get currentTitle(){var b;return((b=t())==null?void 0:b.title)??""},get sessionLabel(){var b;return(b=t())==null?void 0:b.label},get isSubmitting(){return r()},onRename:u,onClose:d}),null),h})()};Ht(["click"]);const Bv=vt("session"),sg=new Set;function Bf(e){return e?"project"in e&&"mcpStatus"in e&&"lspStatus"in e&&"plugins"in e:!1}async function Lj(e,t){const n=e.client;if(!n){Bv.warn("[metadata] Skipping fetch; client missing",{instanceId:e.id});return}const r=iu(e.id)??e.metadata;if(!(!(t!=null&&t.force)&&Bf(r))&&!sg.has(e.id)){sg.add(e.id);try{const[i,s,o,a]=await Promise.allSettled([n.project.current(),n.mcp.status(),pR(e.id),n.config.get()]),l=i.status==="fulfilled"?i.value.data:void 0,c=s.status==="fulfilled"?s.value.data:void 0,d=o.status==="fulfilled"?o.value??[]:void 0,u=a.status==="fulfilled"?a.value.data:void 0,_=Array.isArray(u==null?void 0:u.plugin)?(u==null?void 0:u.plugin).map(g=>g.startsWith("file://")?g.slice(7):g):void 0,m={...r??{}};i.status==="fulfilled"&&(m.project=l??null),s.status==="fulfilled"&&(m.mcpStatus=c??{}),o.status==="fulfilled"&&(m.lspStatus=d??[]),a.status==="fulfilled"&&(m.plugins=_??[]),!(m!=null&&m.version)&&e.binaryVersion&&(m.version=e.binaryVersion),oR(e.id,m)}catch(i){Bv.error("Failed to load instance metadata",i)}finally{sg.delete(e.id)}}}const qA=Jt(null),kj=e=>{const t=F(()=>Et().get(e.instance.id)??e.instance),[n,r]=U(!0),i=async(o=!1)=>{const a=t();if(!a){r(!1);return}const l=iu(a.id)??a.metadata;if(!o&&Bf(l)){r(!1);return}r(!0),await Lj(a,{force:o}),r(!1)};J(()=>{const o=t();if(!o){r(!1);return}const a=iu(o.id)??o.metadata;if(!a||!Bf(a)){i();return}r(!1)});const s={isLoading:n,instance:t,metadata:()=>iu(t().id)??t().metadata,refreshMetadata:()=>i(!0)};return S(qA.Provider,{value:s,get children(){return e.children}})};function KA(){return en(qA)}const Mj=Jt();function Pj(){return en(Mj)}const $j=Jt();function Fj(){return en($j)}function Bj(e){const t=e.controlled()!==void 0,[n,r]=U(e.default()),i=F(()=>t?e.controlled():n());return t&&J(()=>{r(()=>i())}),[i,o=>{t||r(o)}]}function Uj(e){return xr("PrivateSwitchBase",e)}Dr("PrivateSwitchBase",["root","checked","disabled","input","edgeStart","edgeEnd"]);const Uv=Cn()({name:"MuiSwitchBase",selfPropNames:["autoFocus","checked","checkedIcon","classes","defaultChecked","disableFocusRipple","disableRipple","disabled","edge","icon","id","inputProps","inputRef","name","onChange","readOnly","required","tabIndex","type","value"],autoCallUseClasses:!1,propDefaults:({set:e})=>e({disableFocusRipple:!1,edge:!1}),utilityClass:Uj,slotClasses:e=>({root:["root",!!e.checked&&"checked",!!e.disabled&&"disabled",e.edge&&`edge${Zt(e.edge)}`],input:["input"]})}),Gj=Sn(yO)(({ownerState:e})=>({padding:9,borderRadius:"50%",...e.edge==="start"&&{marginLeft:e.size==="small"?-3:-12},...e.edge==="end"&&{marginRight:e.size==="small"?-3:-12}})),Vj=Sn("input")({cursor:"inherit",position:"absolute",opacity:0,width:"100%",height:"100%",top:0,left:0,margin:0,padding:0,zIndex:1}),Hj=Uv.component(function({allProps:t,otherProps:n,props:r}){const i=Fj(),[s,o]=Bj({controlled:()=>r.checked??(i==null?void 0:i.checked),default:()=>!!r.defaultChecked,name:"SwitchBase",state:"checked"}),a=Pj(),l=()=>typeof(i==null?void 0:i.disabled)<"u"?i.disabled:a&&typeof r.disabled>"u"?a.disabled:r.disabled;J(()=>{i&&i.setDisabled(!!l())});const c=()=>r.type==="checkbox"||r.type==="radio",d=oe(t,{get checked(){return s()},get disabled(){return l()}}),u=Uv.useClasses(d),_=Hu(()=>r.inputRef),m=()=>r.value??(i==null?void 0:i.value);return J(()=>{typeof r.defaultChecked=="boolean"&&(_.ref.defaultChecked=r.defaultChecked)}),J(()=>{const g=s();typeof g=="boolean"&&(_.ref.checked=g)}),S(Gj,oe(n,{component:"span",get class(){return Xt(u.root,n.class)},centerRipple:!0,get focusRipple(){return!r.disableFocusRipple},get disabled(){return l()},tabIndex:null,role:void 0,onFocus:g=>{var p;typeof n.onFocus=="function"&&n.onFocus(g),(p=a==null?void 0:a.onFocus)==null||p.call(a)},onBlur:g=>{var p;typeof n.onBlur=="function"&&n.onBlur(g),(p=a==null?void 0:a.onBlur)==null||p.call(a)},ownerState:d,get children(){return[S(Vj,oe({as:"input",get autofocus(){return r.autoFocus},get class(){return u.input},get disabled(){return l()},get id(){return we(()=>!!c())()?r.id:void 0},get name(){return r.name??(i==null?void 0:i.name)},onClick:g=>{var E;if(g.defaultPrevented)return;const p=g.currentTarget.checked;g.currentTarget.checked=!p,o(p),typeof r.onChange=="function"?r.onChange(g,p):(E=i==null?void 0:i.onChange)==null||E.call(i,g,p),typeof n.onClick=="function"&&n.onClick(g)},get readOnly(){return r.readOnly},ref:g=>{var p;_(g),r.inputRef||(p=i==null?void 0:i.inputRef)==null||p.call(i,g)},get required(){return r.required},ownerState:d,get tabIndex(){return r.tabIndex},get type(){return r.type},get value(){return m()}},()=>r.inputProps||{})),we(()=>we(()=>!!s())()?r.checkedIcon:r.icon),we(()=>n.children)]}}))});function Yj(e){return xr("MuiSwitch",e)}const hr=Dr("MuiSwitch",["root","edgeStart","edgeEnd","switchBase","colorPrimary","colorSecondary","sizeSmall","sizeMedium","checked","disabled","input","thumb","track"]),zj=Cn()({name:"MuiSwitch",selfPropNames:["checkedIcon","classes","color","disabled","icon","size","value"],propDefaults:({set:e})=>e({color:"primary",size:"medium"}),utilityClass:Yj,slotClasses:e=>({root:["root",!!e.edge&&`edge${Zt(e.edge)}`,`size${Zt(e.size)}`],switchBase:["switchBase",`color${Zt(e.color)}`,!!e.checked&&"checked",!!e.disabled&&"disabled"],thumb:["thumb"],track:["track"],input:["input"]})}),Wj=Sn("span",{name:"MuiSwitch",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,n.edge&&t[`edge${Zt(n.edge)}`],t[`size${Zt(n.size)}`]]}})(({ownerState:e})=>({display:"inline-flex",width:34+12*2,height:14+12*2,overflow:"hidden",padding:12,boxSizing:"border-box",position:"relative",flexShrink:0,zIndex:0,verticalAlign:"middle","@media print":{colorAdjust:"exact"},...e.edge==="start"&&{marginLeft:-8},...e.edge==="end"&&{marginRight:-8},...e.size==="small"&&{width:40,height:24,padding:7,[`& .${hr.thumb}`]:{width:16,height:16},[`& .${hr.switchBase}`]:{padding:4,[`&.${hr.checked}`]:{transform:"translateX(16px)"}}}})),qj=Sn(Hj,{name:"MuiSwitch",slot:"SwitchBase",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.switchBase,{[`& .${hr.input}`]:t.input},n.color!=="default"&&t[`color${Zt(n.color)}`]]}})(({theme:e})=>({position:"absolute",top:0,left:0,zIndex:1,color:e.palette.mode==="light"?e.palette.common.white:e.palette.grey[300],transition:e.transitions.create(["left","transform"],{duration:e.transitions.duration.shortest}),[`&.${hr.checked}`]:{transform:"translateX(20px)"},[`&.${hr.disabled}`]:{color:e.palette.mode==="light"?e.palette.grey[100]:e.palette.grey[600]},[`&.${hr.checked} + .${hr.track}`]:{opacity:.5},[`&.${hr.disabled} + .${hr.track}`]:{opacity:e.palette.mode==="light"?.12:.2},[`& .${hr.input}`]:{left:"-100%",width:"300%"}}),({theme:e,ownerState:t})=>({"&:hover":{backgroundColor:ko(e.palette.action.active,e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},...t.color!=="default"&&{[`&.${hr.checked}`]:{color:e.palette[t.color].main,"&:hover":{backgroundColor:ko(e.palette[t.color].main,e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${hr.disabled}`]:{color:e.palette.mode==="light"?YI(e.palette[t.color].main,.62):HI(e.palette[t.color].main,.55)}},[`&.${hr.checked} + .${hr.track}`]:{backgroundColor:e.palette[t.color].main}}})),Kj=Sn("span",{name:"MuiSwitch",slot:"Track",overridesResolver:(e,t)=>t.track})(({theme:e})=>({height:"100%",width:"100%",borderRadius:14/2,zIndex:-1,transition:e.transitions.create(["opacity","background-color"],{duration:e.transitions.duration.shortest}),backgroundColor:e.palette.mode==="light"?e.palette.common.black:e.palette.common.white,opacity:e.palette.mode==="light"?.38:.3})),Qj=Sn("span",{name:"MuiSwitch",slot:"Thumb",overridesResolver:(e,t)=>t.thumb})(({theme:e})=>({boxShadow:e.shadows[1],backgroundColor:"currentColor",width:20,height:20,borderRadius:"50%"})),jj=zj.component(function({allProps:t,props:n,classes:r,otherProps:i}){const s=()=>S(Qj,{get class(){return r.thumb},ownerState:t}),o=oe(r,{get root(){return r.switchBase}}),[,a]=lt(i,["sx"]),l=oe(a,{get checkedIcon(){return n.checkedIcon||s},get disabled(){return n.disabled},get icon(){return n.icon||s},get value(){return n.value}});return S(Wj,{get class(){return Xt(r.root,i.class)},get sx(){return i.sx},ownerState:t,get children(){return[S(qj,oe({type:"checkbox",ownerState:t},l,{classes:o})),S(Kj,{get class(){return r.track},ownerState:t})]}})});var Xj=x('<p class="text-[11px] text-secondary italic"role=status>'),Zj=x('<div class="text-xs font-medium text-muted uppercase tracking-wide">LSP Servers'),og=x("<div class=space-y-1.5>"),ag=x("<section class=space-y-1.5>"),Jj=x('<div class="px-2 py-1.5 rounded border bg-surface-secondary border-base"><div class="flex items-center justify-between gap-2"><div class="flex flex-col flex-1 min-w-0"><span class="text-xs text-primary font-medium truncate"></span><span class="text-[11px] text-secondary truncate"></span></div><div class="flex items-center gap-1.5 flex-shrink-0 text-xs text-secondary"><div></div><span>'),eX=x('<div class="text-xs font-medium text-muted uppercase tracking-wide">MCP Servers'),tX=x('<svg class="animate-spin h-3 w-3"fill=none viewBox="0 0 24 24"><circle class=opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=opacity-75 fill=currentColor d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">'),nX=x('<div class="px-2 py-1.5 rounded border bg-surface-secondary border-base"><div class="flex items-center justify-between gap-2"><span class="text-xs text-primary font-medium truncate"></span><div class="flex items-center gap-3 flex-shrink-0"><div class="flex items-center gap-1.5 text-xs text-secondary"><div></div></div><div class="flex items-center gap-1.5">'),rX=x('<div class="text-[11px] mt-1 break-words"style=color:var(--status-error)>'),iX=x('<div class="text-xs font-medium text-muted uppercase tracking-wide">Plugins'),sX=x('<div class="px-2 py-1.5 rounded border bg-surface-secondary border-base"><div class="text-xs text-primary font-medium break-words whitespace-normal">'),oX=x("<div>");const aX=vt("session");function lX(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||typeof r!="object")continue;const i=r.status;if(!i)continue;let s;i==="connected"?s="running":i==="failed"?s="error":s="stopped",t.push({name:n,status:s,error:typeof r.error=="string"?r.error:void 0})}return t}const _u=e=>{const t=KA(),n=(t==null?void 0:t.instance)??(()=>{if(e.initialInstance)return e.initialInstance;throw new Error("InstanceServiceStatus requires InstanceMetadataProvider or initialInstance prop")}),r=(t==null?void 0:t.isLoading)??(()=>!1),i=(t==null?void 0:t.refreshMetadata)??(async()=>Promise.resolve()),s=F(()=>e.sections??["lsp","mcp","plugins"]),o=F(()=>s().includes("lsp")),a=F(()=>s().includes("mcp")),l=F(()=>s().includes("plugins")),c=()=>e.showSectionHeadings!==!1,d=(t==null?void 0:t.metadata)??(()=>n().metadata),u=F(()=>d()),_=()=>{var $;return(($=u())==null?void 0:$.lspStatus)!==void 0},m=()=>{var $;return(($=u())==null?void 0:$.mcpStatus)!==void 0},g=()=>{var $;return(($=u())==null?void 0:$.plugins)!==void 0},p=F(()=>{var $;return(($=u())==null?void 0:$.lspStatus)??[]}),E=F(()=>{var $;return lX((($=u())==null?void 0:$.mcpStatus)??void 0)}),h=F(()=>{var $;return(($=u())==null?void 0:$.plugins)??[]}),f=()=>r()||!_(),b=()=>r()||!m(),y=()=>r()||!g(),[v,O]=U({}),T=($,M)=>{O(L=>{const R={...L};return M?R[$]=M:delete R[$],R})},I=async($,M)=>{const L=n().client;if(!(L!=null&&L.mcp))return;const R=M?"connect":"disconnect";T($,R);try{M?await L.mcp.connect({name:$}):await L.mcp.disconnect({name:$}),await i()}catch(D){aX.error("Failed to toggle MCP server",{serverName:$,action:R,error:D})}finally{T($)}},k=$=>(()=>{var M=Xj();return C(M,$),M})(),A=()=>(()=>{var $=ag();return C($,S(W,{get when(){return c()},get children(){return Zj()}}),null),C($,S(W,{get when(){return we(()=>!f())()&&p().length>0},get fallback(){return k(f()?"Loading LSP servers...":"No LSP servers detected.")},get children(){var M=og();return C(M,S(_t,{get each(){return p()},children:L=>(()=>{var R=Jj(),D=R.firstChild,w=D.firstChild,P=w.firstChild,j=P.nextSibling,le=w.nextSibling,me=le.firstChild,Ae=me.nextSibling;return C(P,()=>L.name??L.id),C(j,()=>L.root),C(Ae,()=>L.status==="connected"?"Connected":"Error"),ne(ie=>{var re=L.root,Ee=`status-dot ${L.status==="connected"?"ready animate-pulse":"error"}`;return re!==ie.e&&Fe(j,"title",ie.e=re),Ee!==ie.t&&rt(me,ie.t=Ee),ie},{e:void 0,t:void 0}),R})()})),M}}),null),$})(),V=()=>(()=>{var $=ag();return C($,S(W,{get when(){return c()},get children(){return eX()}}),null),C($,S(W,{get when(){return we(()=>!b())()&&E().length>0},get fallback(){return k(b()?"Loading MCP servers...":"No MCP servers detected.")},get children(){var M=og();return C(M,S(_t,{get each(){return E()},children:L=>{const R=()=>v()[L.name],D=()=>!!R(),w=()=>L.status==="running",P=()=>D()||!n().client,j=()=>D()?"status-dot animate-pulse":L.status==="running"?"status-dot ready animate-pulse":L.status==="error"?"status-dot error":"status-dot stopped",le=()=>D()?{background:"var(--status-warning)"}:void 0;return(()=>{var me=nX(),Ae=me.firstChild,ie=Ae.firstChild,re=ie.nextSibling,Ee=re.firstChild,Se=Ee.firstChild,q=Ee.nextSibling;return C(ie,()=>L.name),C(Ee,S(W,{get when(){return D()},get children(){return tX()}}),Se),C(q,S(jj,{get checked(){return w()},get disabled(){return P()},color:"success",size:"small",get inputProps(){return{"aria-label":`Toggle ${L.name} MCP server`}},onChange:(ae,N)=>{P()||I(L.name,!!N)}})),C(me,S(W,{get when(){return L.error},children:ae=>(()=>{var N=rX();return C(N,ae),N})()}),null),ne(ae=>{var N=j(),H=le();return N!==ae.e&&rt(Se,ae.e=N),ae.t=ri(Se,H,ae.t),ae},{e:void 0,t:void 0}),me})()}})),M}}),null),$})(),B=()=>(()=>{var $=ag();return C($,S(W,{get when(){return c()},get children(){return iX()}}),null),C($,S(W,{get when(){return we(()=>!y())()&&h().length>0},get fallback(){return k(y()?"Loading plugins...":"No plugins configured.")},get children(){var M=og();return C(M,S(_t,{get each(){return h()},children:L=>(()=>{var R=sX(),D=R.firstChild;return C(D,L),R})()})),M}}),null),$})();return(()=>{var $=oX();return C($,S(W,{get when(){return o()},get children(){return A()}}),null),C($,S(W,{get when(){return a()},get children(){return V()}}),null),C($,S(W,{get when(){return l()},get children(){return B()}}),null),ne(()=>rt($,e.class)),$})()};var cX=x('<div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1">OpenCode Version</div><div class="text-xs px-2 py-1.5 rounded border bg-surface-secondary border-base text-primary">v'),dX=x('<div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1">Binary Path</div><div class="text-xs font-mono break-all px-2 py-1.5 rounded border bg-surface-secondary border-base text-primary">'),uX=x('<div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1.5">Environment Variables (<!>)</div><div class=space-y-1>'),_X=x('<div class="text-xs text-muted py-1"><div class="flex items-center gap-1.5"><svg class="animate-spin h-3 w-3 icon-muted"fill=none viewBox="0 0 24 24"><circle class=opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=opacity-75 fill=currentColor d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>Loading...'),mX=x('<div class=panel><div class=panel-header><h2 class=panel-title>Instance Information</h2></div><div class="panel-body space-y-3"><div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1">Folder</div><div class="text-xs text-primary font-mono break-all px-2 py-1.5 rounded border bg-surface-secondary border-base"></div></div><div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1.5">Server</div><div class="space-y-1 text-xs"><div class="flex justify-between items-center"><span class=text-secondary>Port:</span><span class="text-primary font-mono"></span></div><div class="flex justify-between items-center"><span class=text-secondary>PID:</span><span class="text-primary font-mono"></span></div><div class="flex justify-between items-center"><span class=text-secondary>Status:</span><span><div>'),gX=x('<div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1">Project</div><div class="text-xs font-mono px-2 py-1.5 rounded border truncate bg-surface-secondary border-base text-primary">'),fX=x('<div><div class="text-xs font-medium text-muted uppercase tracking-wide mb-1">Version Control</div><div class="flex items-center gap-2 text-xs text-primary"><svg class="w-3.5 h-3.5"fill=currentColor viewBox="0 0 24 24"style=color:var(--status-warning)><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"></path></svg><span class=capitalize>'),pX=x('<div class="flex items-center gap-2 px-2 py-1.5 rounded border bg-surface-secondary border-base"><span class="text-xs font-mono font-medium flex-1 text-primary"></span><span class="text-xs font-mono flex-1 text-secondary">');const Uf=e=>{const t=KA(),n=(t==null?void 0:t.isLoading)??(()=>!1),r=(t==null?void 0:t.instance)??(()=>e.instance),i=(t==null?void 0:t.metadata)??(()=>e.instance.metadata),s=()=>r(),o=()=>i(),a=()=>{var d;return s().binaryVersion||((d=o())==null?void 0:d.version)},l=()=>s().environmentVariables,c=F(()=>{const d=l();return d?Object.entries(d):[]});return(()=>{var d=mX(),u=d.firstChild,_=u.nextSibling,m=_.firstChild,g=m.firstChild,p=g.nextSibling,E=m.nextSibling,h=E.firstChild,f=h.nextSibling,b=f.firstChild,y=b.firstChild,v=y.nextSibling,O=b.nextSibling,T=O.firstChild,I=T.nextSibling,k=O.nextSibling,A=k.firstChild,V=A.nextSibling,B=V.firstChild;return C(p,()=>s().folder),C(_,S(W,{get when(){var $;return we(()=>!n())()&&(($=o())==null?void 0:$.project)},children:$=>[(()=>{var M=gX(),L=M.firstChild,R=L.nextSibling;return C(R,()=>$().id),M})(),S(W,{get when(){return $().vcs},get children(){var M=fX(),L=M.firstChild,R=L.nextSibling,D=R.firstChild,w=D.nextSibling;return C(w,()=>$().vcs),M}})]}),E),C(_,S(W,{get when(){return a()},get children(){var $=cX(),M=$.firstChild,L=M.nextSibling;return L.firstChild,C(L,a,null),$}}),E),C(_,S(W,{get when(){return s().binaryPath},get children(){var $=dX(),M=$.firstChild,L=M.nextSibling;return C(L,()=>s().binaryPath),$}}),E),C(_,S(W,{get when(){return c().length>0},get children(){var $=uX(),M=$.firstChild,L=M.firstChild,R=L.nextSibling;R.nextSibling;var D=M.nextSibling;return C(M,()=>c().length,R),C(D,S(_t,{get each(){return c()},children:([w,P])=>(()=>{var j=pX(),le=j.firstChild,me=le.nextSibling;return Fe(le,"title",w),C(le,w),Fe(me,"title",P),C(me,P),j})()})),$}}),E),C(_,S(_u,{get initialInstance(){return e.instance},class:"space-y-3"}),E),C(_,S(W,{get when(){return n()},get children(){return _X()}}),E),C(v,()=>s().port),C(I,()=>s().pid),C(V,()=>s().status,null),ne($=>{var M=`status-badge ${s().status}`,L=`status-dot ${s().status==="ready"?"ready":s().status==="starting"?"starting":s().status==="error"?"error":"stopped"} ${s().status==="ready"||s().status==="starting"?"animate-pulse":""}`;return M!==$.e&&rt(V,$.e=M),L!==$.t&&rt(B,$.t=L),$},{e:void 0,t:void 0}),d})()};var hX=x('<button type=button class="button-tertiary lg:hidden flex-shrink-0">View Instance Info'),EX=x('<div class="panel flex flex-col flex-1 min-h-0"><div class=panel-header><div class="flex flex-row flex-wrap items-center gap-2 justify-between"><div><h2 class=panel-title>Resume Session</h2><p class=panel-subtitle> <!> available</p></div></div></div><div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto">'),SX=x('<div class="fixed inset-0 z-40 bg-black/60 backdrop-blur-sm lg:hidden"><div class="flex min-h-full items-start justify-center p-4 overflow-y-auto"><div class="w-full max-w-md space-y-3"><div class="flex justify-end"><button type=button class=button-tertiary>Close</button></div><div class="max-h-[85vh] overflow-y-auto pr-1">'),bX=x('<div class="flex-1 flex flex-col overflow-hidden bg-surface-secondary"><div class="flex-1 flex flex-col lg:flex-row gap-4 p-4 overflow-auto min-w-0"><div class="flex-1 flex flex-col gap-4 min-h-0 min-w-0"><div class="panel flex-shrink-0"><div class=panel-header><h2 class=panel-title>Start New Session</h2><p class=panel-subtitle>We’ll reuse your last agent/model automatically</p></div><div class=panel-body><div class=space-y-3><button type=button class="button-primary w-full flex items-center justify-center text-sm disabled:cursor-not-allowed"><div class="flex items-center gap-2"><span>Create Session</span></div></button></div></div></div></div><div class="hidden lg:block lg:w-80 flex-shrink-0"><div class="sticky top-0 max-h-full overflow-y-auto pr-1"></div></div></div><div class="panel-footer hidden sm:block"><div class=panel-footer-hints><div class="flex items-center gap-1.5"><kbd class=kbd>↑</kbd><kbd class=kbd>↓</kbd><span>Navigate</span></div><div class="flex items-center gap-1.5"><kbd class=kbd>PgUp</kbd><kbd class=kbd>PgDn</kbd><span>Jump</span></div><div class="flex items-center gap-1.5"><kbd class=kbd>Home</kbd><kbd class=kbd>End</kbd><span>First/Last</span></div><div class="flex items-center gap-1.5"><kbd class=kbd>Enter</kbd><span>Resume</span></div><div class="flex items-center gap-1.5"><kbd class=kbd>Del</kbd><span>Delete'),vX=x('<div class="panel panel-empty-state flex-1 flex flex-col justify-center"><div class=panel-empty-state-icon></div><p class=panel-empty-state-title>Loading Sessions</p><p class=panel-empty-state-description>Fetching your previous sessions...'),yX=x('<button type=button class="button-tertiary mt-4 lg:hidden">View Instance Info'),TX=x('<div class="panel panel-empty-state flex-1 flex flex-col justify-center"><div class=panel-empty-state-icon><svg class="w-12 h-12 mx-auto"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"></path></svg></div><p class=panel-empty-state-title>No Previous Sessions</p><p class=panel-empty-state-description>Create a new session below to get started'),CX=x('<div class="flex items-center gap-2 flex-shrink-0"><kbd class="kbd flex-shrink-0">↵</kbd><button type=button class="p-1.5 rounded transition-colors text-muted hover:text-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent"title="Rename session"></button><button type=button class="p-1.5 rounded transition-colors text-muted hover:text-red-500 dark:hover:text-red-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent"title="Delete session">'),RX=x('<div class=panel-list-item><div class="flex items-center gap-2 w-full px-1"><button type=button class="panel-list-item-content group flex-1"><div class="flex items-center justify-between gap-3 w-full"><div class="flex-1 min-w-0"><div class="flex items-center gap-2"><span class="text-sm font-medium text-primary whitespace-normal break-words transition-colors"></span></div><div class="flex items-center gap-3 text-xs text-muted mt-0.5"><span></span><span>•</span><span>'),Gv=x('<svg class="animate-spin h-4 w-4"fill=none viewBox="0 0 24 24"><circle class=opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=opacity-75 fill=currentColor d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">'),IX=x('<svg class="w-4 h-4"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M12 4v16m8-8H4">');const lg=vt("actions"),OX=e=>{const[t,n]=U(!1),[r,i]=U(0),[s,o]=U("sessions"),[a,l]=U(!1),[c,d]=U(typeof window<"u"?window.matchMedia("(min-width: 1024px)").matches:!1),[u,_]=U(null),[m,g]=U(!1),p=()=>$U(e.instance.id),E=F(()=>!!xc().fetchingSessions.get(e.instance.id)),h=R=>{const D=xc().deletingSession.get(e.instance.id);return D?D.has(R):!1};F(()=>{const R=Hn.get("session-new");return R||{id:"session-new-display",key:"n",modifiers:{shift:!0,meta:vo(),ctrl:!vo()},handler:()=>{},description:"New Session",context:"global"}});const f=F(()=>vo()?"cmd+shift+n":"ctrl+shift+n");J(()=>{p().length===0?(o("new-session"),i(0)):(o("sessions"),i(0))});const b=()=>{c()||l(!0)},y=()=>l(!1);function v(R){const D=document.querySelector(`[data-session-index="${R}"]`);D&&D.scrollIntoView({block:"nearest",behavior:"auto"})}function O(R){let D=null;typeof document<"u"&&(D=document.activeElement);const w=(D==null?void 0:D.closest(".modal-surface"))||(D==null?void 0:D.closest("[role='dialog']"));if(D&&(["INPUT","TEXTAREA","SELECT"].includes(D.tagName)||D.isContentEditable||!!w)){w&&R.key==="Escape"&&u()&&(R.preventDefault(),$());return}if(a()){R.key==="Escape"&&(R.preventDefault(),y());return}const j=p();if((R.metaKey||R.ctrlKey)&&R.shiftKey&&R.key.toLowerCase()==="n"){R.preventDefault(),L();return}if(j.length===0)return;const le=s()==="sessions";if(R.key==="ArrowDown"){le||(o("sessions"),i(0)),R.preventDefault();const me=Math.min(r()+1,j.length-1);i(me),v(me);return}if(R.key==="ArrowUp"){le||(o("sessions"),i(Math.max(p().length-1,0))),R.preventDefault();const me=Math.max(r()-1,0);i(me),v(me);return}if(le)if(R.key==="PageDown"){R.preventDefault();const Ae=Math.min(r()+5,j.length-1);i(Ae),v(Ae)}else if(R.key==="PageUp"){R.preventDefault();const Ae=Math.max(r()-5,0);i(Ae),v(Ae)}else if(R.key==="Home")R.preventDefault(),i(0),v(0);else if(R.key==="End"){R.preventDefault();const me=j.length-1;i(me),v(me)}else R.key==="Enter"?(R.preventDefault(),T()):(R.key==="Delete"||R.key==="Backspace")&&(R.preventDefault(),I())}async function T(){const R=p(),D=r();D<R.length&&await A(R[D].id)}async function I(){const R=p(),D=r();if(D>=R.length)return;await V(R[D].id);const w=p();if(w.length===0){o("new-session"),i(0);return}const P=Math.min(D,w.length-1);i(P),o("sessions"),v(P)}Tn(()=>{window.addEventListener("keydown",O),Ne(()=>{window.removeEventListener("keydown",O)})}),Tn(()=>{const R=window.matchMedia("(min-width: 1024px)"),D=P=>{d(P),P&&y()},w=P=>D(P.matches);typeof R.addEventListener=="function"?(R.addEventListener("change",w),Ne(()=>{R.removeEventListener("change",w)})):(R.addListener(w),Ne(()=>{R.removeListener(w)})),D(R.matches)});function k(R){const D=Math.floor((Date.now()-R)/1e3),w=Math.floor(D/60),P=Math.floor(w/60),j=Math.floor(P/24);return j>0?`${j}d ago`:P>0?`${P}h ago`:w>0?`${w}m ago`:"just now"}async function A(R){Ss(e.instance.id,R)}async function V(R){if(!h(R))try{await Hp(e.instance.id,R)}catch(D){lg.error("Failed to delete session:",D)}}function B(R,D){const w=D&&D.trim()?D:R;_({id:R,title:D??"",label:w})}function $(){_(null)}async function M(R){const D=u();if(D){g(!0);try{await WT(e.instance.id,D.id,R),_(null)}catch(w){lg.error("Failed to rename session:",w),Pi({message:"Unable to rename session",variant:"error"})}finally{g(!1)}}}async function L(){if(!t()){n(!0);try{const R=await vR(e.instance.id);Ss(e.instance.id,R.id)}catch(R){lg.error("Failed to create session:",R)}finally{n(!1)}}}return(()=>{var R=bX(),D=R.firstChild,w=D.firstChild,P=w.firstChild,j=P.firstChild,le=j.nextSibling,me=le.firstChild,Ae=me.firstChild,ie=Ae.firstChild,re=ie.firstChild,Ee=w.nextSibling,Se=Ee.firstChild,q=D.nextSibling;return C(w,S(W,{get when(){return p().length>0},get fallback(){return S(W,{get when(){return E()},get fallback(){return(()=>{var ae=TX(),N=ae.firstChild,H=N.nextSibling;return H.nextSibling,C(ae,S(W,{get when(){return we(()=>!c())()&&!a()},get children(){var te=yX();return te.$$click=b,te}}),null),ae})()},get children(){var ae=vX(),N=ae.firstChild;return C(N,S(Ro,{class:"w-12 h-12 mx-auto animate-spin text-muted"})),ae}})},get children(){var ae=EX(),N=ae.firstChild,H=N.firstChild,te=H.firstChild,Q=te.firstChild,z=Q.nextSibling,he=z.firstChild,ue=he.nextSibling;ue.nextSibling;var ce=N.nextSibling;return C(z,()=>p().length,he),C(z,()=>p().length===1?"session":"sessions",ue),C(H,S(W,{get when(){return we(()=>!c())()&&!a()},get children(){var se=hX();return se.$$click=b,se}}),null),C(ce,S(_t,{get each(){return p()},children:(se,ke)=>{const We=()=>s()==="sessions"&&r()===ke();return(()=>{var Oe=RX(),je=Oe.firstChild,dt=je.firstChild,Lt=dt.firstChild,be=Lt.firstChild,ee=be.firstChild,Re=ee.firstChild,He=ee.nextSibling,qe=He.firstChild,de=qe.nextSibling,ge=de.nextSibling;return dt.addEventListener("mouseenter",()=>{o("sessions"),i(ke())}),dt.$$click=()=>A(se.id),C(Re,()=>se.title||"Untitled Session"),C(qe,()=>se.agent),C(ge,()=>k(se.time.updated)),C(je,S(W,{get when(){return We()},get children(){var Ce=CX(),Ke=Ce.firstChild,Pe=Ke.nextSibling,Be=Pe.nextSibling;return Pe.$$click=nt=>{nt.preventDefault(),nt.stopPropagation(),B(se.id,se.title||"")},C(Pe,S(iT,{class:"w-4 h-4"})),Be.$$click=nt=>{nt.preventDefault(),nt.stopPropagation(),V(se.id)},C(Be,S(W,{get when(){return!h(se.id)},get fallback(){return Gv()},get children(){return S(al,{class:"w-4 h-4"})}})),ne(()=>Be.disabled=h(se.id)),Ce}}),null),ne(Ce=>{var Ke=!!We(),Pe=ke(),Be=!!We();return Ke!==Ce.e&&Oe.classList.toggle("panel-list-item-highlight",Ce.e=Ke),Pe!==Ce.t&&Fe(dt,"data-session-index",Ce.t=Pe),Be!==Ce.a&&Re.classList.toggle("text-accent",Ce.a=Be),Ce},{e:void 0,t:void 0,a:void 0}),Oe})()}})),ae}}),P),Ae.$$click=L,C(ie,(()=>{var ae=we(()=>!!t());return()=>ae()?Gv():IX()})(),re),C(Ae,S(ir,{get shortcut(){return f()},class:"ml-2"}),null),C(Se,S(Uf,{get instance(){return e.instance}})),C(R,S(W,{get when(){return we(()=>!c())()&&a()},get children(){var ae=SX(),N=ae.firstChild,H=N.firstChild,te=H.firstChild,Q=te.firstChild,z=te.nextSibling;return ae.$$click=y,H.$$click=he=>he.stopPropagation(),Q.$$click=y,C(z,S(Uf,{get instance(){return e.instance}})),ae}}),q),C(R,S(WA,{get open(){return!!u()},get currentTitle(){var ae;return((ae=u())==null?void 0:ae.title)??""},get sessionLabel(){var ae;return(ae=u())==null?void 0:ae.label},get isSubmitting(){return m()},onRename:M,onClose:$}),null),ne(()=>Ae.disabled=t()),R})()};Ht(["click"]);var NX=x("<button type=button class=button-tertiary>Hide server logs"),AX=x("<button class=scroll-to-bottom>Scroll to bottom"),wX=x('<div class=log-container><div class="flex-1 flex flex-col lg:flex-row gap-4 p-4 overflow-hidden"><div class="lg:w-80 flex-shrink-0 overflow-y-auto"></div><div class="panel flex-1 flex flex-col min-h-0 overflow-hidden"><div class=log-header><h2 class=panel-title>Server Logs</h2><div class="flex items-center gap-2"></div></div><div class=log-content>'),xX=x("<button type=button class=button-tertiary>Show server logs"),DX=x("<div class=log-paused-state><p class=log-paused-title>Server logs are paused</p><p class=log-paused-description>Enable streaming to watch your OpenCode server activity.</p><button type=button class=button-primary>Show server logs"),LX=x("<div class=log-empty-state>Waiting for server output..."),kX=x("<div class=log-entry><span class=log-timestamp></span><span>");const Vv=new Map,MX=e=>{let t;const n=Vv.get(e.instanceId),[r,i]=U((n==null?void 0:n.autoScroll)??!1),s=()=>Et().get(e.instanceId),o=F(()=>eU(e.instanceId)),a=F(()=>mR(e.instanceId)),l=()=>qS(e.instanceId,!0),c=()=>qS(e.instanceId,!1);Tn(()=>{t&&n&&(t.scrollTop=n.scrollTop)}),Ne(()=>{t&&Vv.set(e.instanceId,{scrollTop:t.scrollTop,autoScroll:r()})}),J(()=>{r()&&t&&o().length>0&&(t.scrollTop=t.scrollHeight)});const d=()=>{if(!t)return;const g=t.scrollHeight-t.scrollTop<=t.clientHeight+50;i(g)},u=()=>{t&&(t.scrollTop=t.scrollHeight,i(!0))},_=g=>new Date(g).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),m=g=>{switch(g){case"error":return"log-level-error";case"warn":return"log-level-warn";case"debug":return"log-level-debug";default:return"log-level-default"}};return(()=>{var g=wX(),p=g.firstChild,E=p.firstChild,h=E.nextSibling,f=h.firstChild,b=f.firstChild,y=b.nextSibling,v=f.nextSibling;C(E,S(W,{get when(){return s()},children:T=>S(Uf,{get instance(){return T()}})})),C(y,S(W,{get when(){return a()},get fallback(){return(()=>{var T=xX();return T.$$click=l,T})()},get children(){var T=NX();return T.$$click=c,T}})),v.addEventListener("scroll",d);var O=t;return typeof O=="function"?wt(O,v):t=v,C(v,S(W,{get when(){return a()},get fallback(){return(()=>{var T=DX(),I=T.firstChild,k=I.nextSibling,A=k.nextSibling;return A.$$click=l,T})()},get children(){return S(W,{get when(){return o().length>0},get fallback(){return LX()},get children(){return S(_t,{get each(){return o()},children:T=>(()=>{var I=kX(),k=I.firstChild,A=k.nextSibling;return C(k,()=>_(T.timestamp)),C(A,()=>T.message),ne(()=>rt(A,`log-message ${m(T.level)}`)),I})()})}})}})),C(h,S(W,{get when(){return we(()=>!r())()&&a()},get children(){var T=AX(),I=T.firstChild;return T.$$click=u,C(T,S(Qc,{class:"w-4 h-4"}),I),T}}),null),g})()};Ht(["click"]);var PX=x("<div class=sidebar-selector>"),$X=x("<span>"),FX=x("<span class=neutral-badge>subagent"),BX=x('<div class="flex flex-col flex-1 min-w-0">'),UX=x("<div class=selector-trigger-label><span class=selector-trigger-primary>Agent: ");const GX=vt("session");function VX(e){const t=()=>A_().get(e.instanceId)||[],n=F(()=>{const o=Ft().get(e.instanceId);return o==null?void 0:o.get(e.sessionId)}),r=F(()=>{var o,a;return((o=n())==null?void 0:o.parentId)!==null&&((a=n())==null?void 0:a.parentId)!==void 0}),i=F(()=>{const o=t();if(r())return o;const a=o.filter(c=>c.mode!=="subagent"),l=o.find(c=>c.name===e.currentAgent);return l&&!a.find(c=>c.name===e.currentAgent)?[l,...a]:a});J(()=>{const o=i();o.length!==0&&(o.some(a=>a.name===e.currentAgent)||e.onAgentChange(o[0].name))}),J(()=>{t().length===0&&yR(e.instanceId).catch(o=>GX.error("Failed to fetch agents",o))});const s=async o=>{o&&o.name!==e.currentAgent&&await e.onAgentChange(o.name)};return(()=>{var o=PX();return C(o,S(pi,{get value(){return i().find(a=>a.name===e.currentAgent)},onChange:s,get options(){return i()},optionValue:"name",optionTextValue:"name",placeholder:"Select agent...",itemComponent:a=>S(pi.Item,{get item(){return a.item},class:"selector-option",get children(){var l=BX();return C(l,S(pi.ItemLabel,{class:"selector-option-label flex items-center gap-2",get children(){return[(()=>{var c=$X();return C(c,()=>a.item.rawValue.name),c})(),S(W,{get when(){return a.item.rawValue.mode==="subagent"},get children(){return FX()}})]}}),null),C(l,S(W,{get when(){return a.item.rawValue.description},get children(){return S(pi.ItemDescription,{class:"selector-option-description",get children(){return we(()=>a.item.rawValue.description.length>50)()?a.item.rawValue.description.slice(0,50)+"...":a.item.rawValue.description}})}}),null),l}}),get children(){return[S(pi.Trigger,{"data-agent-selector":!0,class:"selector-trigger",get children(){return[S(pi.Value,{children:a=>(()=>{var l=UX(),c=l.firstChild;return c.firstChild,C(c,()=>{var d;return((d=a.selectedOption())==null?void 0:d.name)??"None"},null),l})()}),S(pi.Icon,{class:"selector-trigger-icon",get children(){return S(Qc,{class:"w-3 h-3"})}})]}}),S(pi.Portal,{get children(){return S(pi.Content,{class:"selector-popover max-h-80 overflow-auto p-1",get children(){return S(pi.Listbox,{class:"selector-listbox"})}})}})]}})),o})()}var HX=x('<div class="selector-trigger-label selector-trigger-label--stacked"><span class="selector-trigger-primary selector-trigger-primary--align-left">Model: '),YX=x("<div class=selector-search-container>"),zX=x("<div class=sidebar-selector>"),WX=x("<div class=selector-option-content>"),qX=x('<svg class="w-4 h-4"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M5 13l4 4L19 7">'),KX=x("<span class=selector-trigger-secondary>/");const QX=vt("session");function jX(e){const t=()=>ul().get(e.instanceId)||[],[n,r]=U(!1);let i,s;J(()=>{t().length===0&&TR(e.instanceId).catch(d=>QX.error("Failed to fetch providers",d))});const o=F(()=>t().flatMap(d=>d.models.map(u=>({...u,providerName:d.name,key:`${u.providerId}/${u.id}`,searchText:`${u.name} ${d.name} ${u.providerId} ${u.id} ${u.providerId}/${u.id}`})))),a=F(()=>o().find(d=>d.providerId===e.currentModel.providerId&&d.id===e.currentModel.modelId)),l=async d=>{d&&await e.onModelChange({providerId:d.providerId,modelId:d.id})},c=(d,u)=>d.searchText.toLowerCase().includes(u.toLowerCase());return J(()=>{n()&&setTimeout(()=>{s==null||s.focus()},100)}),(()=>{var d=zX();return C(d,S(Tr,{get value(){return a()},onChange:l,onOpenChange:r,get options(){return o()},optionValue:"key",optionTextValue:"searchText",optionLabel:"name",placeholder:"Search models...",defaultFilter:c,allowsEmptyCollection:!0,itemComponent:u=>S(Tr.Item,{get item(){return u.item},class:"selector-option",get children(){return[(()=>{var _=WX();return C(_,S(Tr.ItemLabel,{class:"selector-option-label",get children(){return u.item.rawValue.name}}),null),C(_,S(Tr.ItemDescription,{class:"selector-option-description",get children(){return[we(()=>u.item.rawValue.providerName)," • ",we(()=>u.item.rawValue.providerId),"/",we(()=>u.item.rawValue.id)]}}),null),_})(),S(Tr.ItemIndicator,{class:"selector-option-indicator",get children(){return qX()}})]}}),get children(){return[S(Tr.Control,{class:"relative w-full","data-model-selector-control":!0,get children(){return[S(Tr.Input,{class:"sr-only","data-model-selector":!0}),S(Tr.Trigger,{ref(u){var _=i;typeof _=="function"?_(u):i=u},class:"selector-trigger",get children(){return[(()=>{var u=HX(),_=u.firstChild;return _.firstChild,C(_,()=>{var m;return((m=a())==null?void 0:m.name)??"None"},null),C(u,(()=>{var m=we(()=>!!a());return()=>m()&&(()=>{var g=KX(),p=g.firstChild;return C(g,()=>a().providerId,p),C(g,()=>a().id,null),g})()})(),null),u})(),S(Tr.Icon,{class:"selector-trigger-icon",get children(){return S(Qc,{class:"w-3 h-3"})}})]}})]}}),S(Tr.Portal,{get children(){return S(Tr.Content,{class:"selector-popover",get children(){return[(()=>{var u=YX();return C(u,S(Tr.Input,{ref(_){var m=s;typeof m=="function"?m(_):s=_},class:"selector-search-input",placeholder:"Search models..."})),u})(),S(Tr.Listbox,{class:"selector-listbox"})]}})}})]}})),d})()}var XX=x('<div class=modal-search-container><div class="flex items-center gap-3"><svg class="w-5 h-5 modal-search-icon"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg><input type=text placeholder="Type a command or search..."class=modal-search-input>'),ZX=x("<div class=modal-list-container>"),JX=x('<div class="fixed inset-0 z-50 flex items-start justify-center pt-[20vh]">'),eZ=x('<div class=modal-empty-state>No commands found for "<!>"'),tZ=x("<div class=py-2><div class=modal-section-header>"),nZ=x("<div class=mt-1>"),rZ=x('<button type=button><div class="flex-1 min-w-0"><div class=modal-item-label></div><div class=modal-item-description>');function iZ(e){if(!e)return"";const t=[];return(e.meta||e.ctrl)&&t.push("cmd"),e.shift&&t.push("shift"),e.alt&&t.push("alt"),t.push(e.key),t.join("+")}const sZ=e=>{const[t,n]=U(""),[r,i]=U(null),[s,o]=U(!1);let a,l;const c=["Custom Commands","Instance","Session","Agent & Model","Input & Focus","System","Other"],d=F(()=>{const h=e.commands??[],f=t().trim().toLowerCase(),b=f?h.filter(k=>{var L,R;const V=(typeof k.label=="function"?k.label():k.label).toLowerCase().includes(f),B=k.description.toLowerCase().includes(f),$=(L=k.keywords)==null?void 0:L.some(D=>D.toLowerCase().includes(f)),M=(R=k.category)==null?void 0:R.toLowerCase().includes(f);return V||B||$||M}):h,y=new Map;for(const k of b){const A=k.category||"Other",V=y.get(A);V?V.push(k):y.set(A,[k])}const v=[],O=[],T=new Set,I=k=>{const A=y.get(k);!A||A.length===0||T.has(k)||(v.push({category:k,commands:A,startIndex:O.length}),O.push(...A),T.add(k))};for(const k of c)I(k);for(const[k]of y)I(k);return{groups:v,ordered:O}}),u=()=>d().groups,_=()=>d().ordered,m=F(()=>{const h=_();if(h.length===0)return-1;const f=r();if(!f)return 0;const b=h.findIndex(y=>y.id===f);return b>=0?b:0});J(()=>{e.open&&(n(""),i(null),o(!1),setTimeout(()=>a==null?void 0:a.focus(),100))}),J(()=>{const h=_();if(h.length===0){r()!==null&&i(null);return}const f=r();(!f||!h.some(b=>b.id===f))&&i(h[0].id)}),J(()=>{const h=m();if(!l||h<0)return;const f=l.querySelector(`[data-command-index="${h}"]`);f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})});function g(h){var b,y;const f=_();if(h.key==="Escape"){h.preventDefault(),h.stopPropagation(),e.onClose();return}if(f.length===0){(h.key==="ArrowDown"||h.key==="ArrowUp"||h.key==="Enter")&&(h.preventDefault(),h.stopPropagation());return}if(h.key==="ArrowDown"){h.preventDefault(),h.stopPropagation(),o(!1);const v=m(),O=Math.min((v<0?0:v)+1,f.length-1);i(((b=f[O])==null?void 0:b.id)??null)}else if(h.key==="ArrowUp"){h.preventDefault(),h.stopPropagation(),o(!1);const v=m(),O=v<=0?f.length-1:v-1;i(((y=f[O])==null?void 0:y.id)??null)}else if(h.key==="Enter"){h.preventDefault(),h.stopPropagation();const v=m();if(v<0||v>=f.length)return;const O=f[v];if(!O)return;e.onExecute(O),e.onClose()}}function p(h){e.onExecute(h),e.onClose()}function E(){o(!1)}return S(ft,{get open(){return e.open},onOpenChange:h=>!h&&e.onClose(),get children(){return S(ft.Portal,{get children(){return[S(ft.Overlay,{class:"modal-overlay"}),(()=>{var h=JX();return C(h,S(ft.Content,{class:"modal-surface w-full max-w-2xl max-h-[60vh]",onKeyDown:g,get children(){return[S(ft.Title,{class:"sr-only",children:"Command Palette"}),S(ft.Description,{class:"sr-only",children:"Search and execute commands"}),(()=>{var f=XX(),b=f.firstChild,y=b.firstChild,v=y.nextSibling;v.$$input=T=>{n(T.currentTarget.value),i(null)};var O=a;return typeof O=="function"?wt(O,v):a=v,ne(()=>v.value=t()),f})(),(()=>{var f=ZX();f.addEventListener("pointerleave",E);var b=l;return typeof b=="function"?wt(b,f):l=f,C(f,S(W,{get when(){return _().length>0},get fallback(){return(()=>{var y=eZ(),v=y.firstChild,O=v.nextSibling;return O.nextSibling,C(y,t,O),y})()},get children(){return S(_t,{get each(){return u()},children:y=>(()=>{var v=tZ(),O=v.firstChild;return C(O,()=>y.category),C(v,S(_t,{get each(){return y.commands},children:(T,I)=>{const k=y.startIndex+I();return(()=>{var A=rZ(),V=A.firstChild,B=V.firstChild,$=B.nextSibling;return A.$$pointermove=M=>{M.movementX===0&&M.movementY===0||(M.pointerType==="mouse"||M.pointerType==="pen"||M.pointerType==="touch")&&(s()||o(!0),i(T.id))},A.$$click=()=>p(T),Fe(A,"data-command-index",k),C(B,(()=>{var M=we(()=>typeof T.label=="function");return()=>M()?T.label():T.label})()),C($,()=>T.description),C(A,S(W,{get when(){return T.shortcut},get children(){var M=nZ();return C(M,S(ir,{get shortcut(){return iZ(T.shortcut)}})),M}}),null),ne(()=>rt(A,`modal-item ${r()===T.id?"modal-item-highlight":""}`)),A})()}}),null),v})()})}})),ne(()=>Fe(f,"data-pointer-mode",s()?"pointer":"keyboard")),f})()]}})),h})()]}})}})};Ht(["input","click","pointermove"]);var oZ=x("<button type=button class=permission-center-trigger><span class=permission-center-count aria-hidden=true>");const Hv=e=>{const t=F(()=>sU(e.instanceId)),n=F(()=>oU(e.instanceId)),r=F(()=>t()+n()),i=F(()=>r()>0),s=F(()=>{const o=r(),a=[];t()>0&&a.push(`${t()} permission${t()===1?"":"s"}`),n()>0&&a.push(`${n()} question${n()===1?"":"s"}`);const l=a.length?` (${a.join(", ")})`:"";return`${o} pending request${o===1?"":"s"}${l}`});return S(W,{get when(){return i()},get children(){var o=oZ(),a=o.firstChild;return Fn(o,"click",e.onClick,!0),C(o,S(__,{class:"permission-center-icon","aria-hidden":"true"}),a),C(a,(()=>{var l=we(()=>r()>9);return()=>l()?"9+":r()})()),ne(l=>{var c=s(),d=s();return c!==l.e&&Fe(o,"aria-label",l.e=c),d!==l.t&&Fe(o,"title",l.t=d),l},{e:void 0,t:void 0}),o}})};Ht(["click"]);var aZ=x("<span class=permission-center-modal-count>"),lZ=x("<div class=permission-center-list role=list>"),cZ=x("<div class=permission-center-modal-backdrop><div class=permission-center-modal role=dialog aria-modal=true aria-labelledby=permission-center-title><div class=permission-center-modal-header><div class=permission-center-modal-title-row><h2 id=permission-center-title class=permission-center-modal-title>Requests</h2></div><button type=button class=permission-center-modal-close aria-label=Close>✕</button></div><div class=permission-center-modal-body>"),dZ=x("<div class=permission-center-empty>No pending requests."),uZ=x("<span class=permission-center-item-chip>Active"),_Z=x("<button type=button class=permission-center-item-action>"),mZ=x("<div role=listitem><div class=permission-center-item-header><div class=permission-center-item-heading><span></span><span class=permission-center-item-kind></span></div><div class=permission-center-item-actions><button type=button class=permission-center-item-action>Go to Session"),gZ=x("<div class=permission-center-fallback><div class=permission-center-fallback-title><code></code></div><div class=permission-center-fallback-hint>Load session for more information.");function fZ(e,t){var d;const n=jc(t),r=TT(t);if(!n||!r)return null;const i=Ut.getInstance(e);if(!i)return null;const s=i.getMessage(r);if(!s)return null;const o=t.metadata||{},a=t.partID??t.partId??o.partID??o.partId??void 0,l=CT(t),c=u=>{var g;const _=(g=s.parts)==null?void 0:g[u],m=_==null?void 0:_.data;return!m||m.type!=="tool"?null:{toolPart:m,partVersion:_.revision??0}};if(typeof a=="string"&&a.length>0){const u=c(a);if(u)return{messageId:r,sessionId:n,toolPart:u.toolPart,messageVersion:s.revision,partVersion:u.partVersion}}if(l)for(const u of s.partIds){const _=(d=s.parts)==null?void 0:d[u],m=_==null?void 0:_.data;if(!m||m.type!=="tool")continue;if((m.callID??m.callId??m.toolCallID??m.toolCallId??void 0)===l&&typeof m.id=="string"&&m.id.length>0)return{messageId:r,sessionId:n,toolPart:m,messageVersion:s.revision,partVersion:_.revision??0}}return null}function pZ(e,t){var a;const n=E_(t),r=IT(t);if(!n||!r)return null;const i=Ut.getInstance(e);if(!i)return null;const s=i.getMessage(r);if(!s)return null;const o=OT(t);if(!o)return null;for(const l of s.partIds){const c=(a=s.parts)==null?void 0:a[l],d=c==null?void 0:c.data;if(!(!d||d.type!=="tool"||(d.callID??d.callId??d.toolCallID??d.toolCallId??void 0)!==o)&&!(typeof d.id!="string"||d.id.length===0))return{messageId:r,sessionId:n,toolPart:d,messageVersion:s.revision,partVersion:(c==null?void 0:c.revision)??0}}return null}const hZ=e=>{const[t,n]=U(null),r=F(()=>td(e.instanceId)),i=F(()=>Vo(e.instanceId)),s=F(()=>cR().get(e.instanceId)??null),o=F(()=>{const _=r().map(g=>{var p;return{kind:"permission",id:g.id,sessionId:jc(g)||"",createdAt:((p=g==null?void 0:g.time)==null?void 0:p.created)??Date.now(),payload:g}}),m=i().map(g=>({kind:"question",id:g.id,sessionId:E_(g)||"",createdAt:aU(e.instanceId,g.id),payload:g}));return[..._,...m].sort((g,p)=>g.createdAt-p.createdAt)}),a=F(()=>o().length>0),l=_=>{_.key==="Escape"&&(_.preventDefault(),e.onClose())};J(()=>{e.isOpen&&(document.addEventListener("keydown",l),Ne(()=>document.removeEventListener("keydown",l)))}),J(()=>{e.isOpen&&o().length===0&&e.onClose()});function c(_){_.target===_.currentTarget&&e.onClose()}async function d(_){if(_){n(_);try{await Pu(e.instanceId,_)}finally{n(m=>m===_?null:m)}}}function u(_){var p;if(!_)return;const m=(p=Ft().get(e.instanceId))==null?void 0:p.get(_),g=(m==null?void 0:m.parentId)??(m==null?void 0:m.id);g&&Zg(e.instanceId,g),Ka(e.instanceId,_),e.onClose()}return S(W,{get when(){return e.isOpen},get children(){var _=cZ(),m=_.firstChild,g=m.firstChild,p=g.firstChild;p.firstChild;var E=p.nextSibling,h=g.nextSibling;return _.$$click=c,C(p,S(W,{get when(){return o().length>0},get children(){var f=aZ();return C(f,()=>o().length),f}}),null),Fn(E,"click",e.onClose,!0),C(h,S(W,{get when(){return a()},get fallback(){return dZ()},get children(){var f=lZ();return C(f,S(_t,{get each(){return o()},children:b=>{const y=()=>{var B,$;return((B=s())==null?void 0:B.kind)===b.kind&&(($=s())==null?void 0:$.id)===b.id},v=()=>b.sessionId,O=F(()=>b.kind==="permission"?fZ(e.instanceId,b.payload):pZ(e.instanceId,b.payload)),T=()=>!O(),I=()=>b.kind==="permission"?"Permission":"Question",k=()=>{var $,M;if(b.kind==="permission")return RT(b.payload);const B=(M=($=b.payload.questions)==null?void 0:$[0])==null?void 0:M.question;return typeof B=="string"&&B.trim().length>0?B:"Question"},A=()=>{var $;if(b.kind==="permission")return h_(b.payload);const B=(($=b.payload.questions)==null?void 0:$.length)??0;return B===1?"1 question":`${B} questions`},V=()=>{b.kind==="permission"?hU(e.instanceId,b.id):EU(e.instanceId,b.id)};return(()=>{var B=mZ(),$=B.firstChild,M=$.firstChild,L=M.firstChild,R=L.nextSibling,D=M.nextSibling,w=D.firstChild;return B.$$click=V,C(L,I),C(R,A),C(M,S(W,{get when(){return y()},get children(){return uZ()}}),null),w.$$click=P=>{P.stopPropagation(),u(v())},C(D,S(W,{get when(){return T()},get children(){var P=_Z();return P.$$click=j=>{j.stopPropagation(),d(v())},C(P,()=>t()===v()?"Loading…":"Load Session"),ne(()=>P.disabled=t()===v()),P}}),null),C(B,S(W,{get when(){return O()},get fallback(){return(()=>{var P=gZ(),j=P.firstChild,le=j.firstChild;return C(le,k),P})()},children:P=>S(iE,{get toolCall(){return P().toolPart},get toolCallId(){return P().toolPart.id},get messageId(){return P().messageId},get messageVersion(){return P().messageVersion},get partVersion(){return P().partVersion},get instanceId(){return e.instanceId},get sessionId(){return P().sessionId}})}),null),ne(P=>{var j=`permission-center-item${y()?" permission-center-item-active":""}`,le=`permission-center-item-chip permission-center-item-chip-${b.kind}`;return j!==P.e&&rt(B,P.e=j),le!==P.t&&rt(L,P.t=le),P},{e:void 0,t:void 0}),B})()}})),f}})),_}})};Ht(["click"]);var EZ=x('<div class="session-context-panel border-r border-base border-b px-3 py-3 space-y-3"><div class="flex flex-wrap items-center gap-2 text-xs text-primary/90"><div class="text-xs font-semibold text-primary/70 uppercase tracking-wide">Tokens</div><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Input</span><span class="font-semibold text-primary"></span></div><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Output</span><span class="font-semibold text-primary"></span></div><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Cost</span><span class="font-semibold text-primary"></span></div></div><div class="flex flex-wrap items-center gap-2 text-xs text-primary/90"><div class="text-xs font-semibold text-primary/70 uppercase tracking-wide">Context</div><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Used</span><span class="font-semibold text-primary"></span></div><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Avail</span><span class="font-semibold text-primary">');const SZ=e=>{const t=F(()=>Kp(e.instanceId,e.sessionId)??{cost:0,contextWindow:0,isSubscriptionModel:!1,inputTokens:0,outputTokens:0,reasoningTokens:0,actualUsageTokens:0,modelOutputLimit:0,contextAvailableTokens:null}),n=F(()=>t().inputTokens??0),r=F(()=>t().outputTokens??0),i=F(()=>t().actualUsageTokens??0),s=F(()=>t().contextAvailableTokens);F(()=>t().modelOutputLimit??0);const o=F(()=>{const c=t().isSubscriptionModel?0:t().cost;return c>0?c:0}),a=c=>c==null?"--":yi(c),l=F(()=>`$${o().toFixed(2)}`);return(()=>{var c=EZ(),d=c.firstChild,u=d.firstChild,_=u.nextSibling,m=_.firstChild,g=m.nextSibling,p=_.nextSibling,E=p.firstChild,h=E.nextSibling,f=p.nextSibling,b=f.firstChild,y=b.nextSibling,v=d.nextSibling,O=v.firstChild,T=O.nextSibling,I=T.firstChild,k=I.nextSibling,A=T.nextSibling,V=A.firstChild,B=V.nextSibling;return C(g,()=>yi(n())),C(h,()=>yi(r())),C(y,l),C(k,()=>yi(i())),C(B,()=>a(s())),c})()};var bZ=x("<div style=width:100%><div style=width:100%><div>");const Ml=new Map,vZ=600,yZ=32,Yv=48,TZ="__null__",zv=new WeakMap;let CZ=0;const cg=new Map;function RZ(e,t){if(!e)return`${TZ}:${t}`;let n=zv.get(e);return n===void 0&&(n=++CZ,zv.set(e,n)),`${n}:${t}`}function IZ(e,t){const n=new Map;return{observer:new IntersectionObserver(i=>{i.forEach(s=>{const o=n.get(s.target);o&&o.forEach(a=>a(s))})},{root:e??void 0,rootMargin:`${t}px 0px ${t}px 0px`}),listeners:n}}function OZ(e){const t=e.rootBounds;if(!t)return e.isIntersecting;const n=t.top-e.boundingClientRect.bottom,r=e.boundingClientRect.top-t.bottom;return!(n>Yv||r>Yv)}function NZ(e,t,n,r){if(typeof IntersectionObserver>"u")return r({isIntersecting:!0}),()=>{};const i=RZ(t,n);let s=cg.get(i);s||(s=IZ(t,n),cg.set(i,s));let o=s.listeners.get(e);return o||(o=new Set,s.listeners.set(e,o),s.observer.observe(e)),o.add(r),()=>{const a=s==null?void 0:s.listeners.get(e);a&&(a.delete(r),a.size===0&&(s==null||s.listeners.delete(e),s==null||s.observer.unobserve(e))),s&&s.listeners.size===0&&(s.observer.disconnect(),cg.delete(i))}}function AZ(e){const t=$o(()=>e.children),n=Ml.get(e.cacheKey),[r,i]=U(!0),[s,o]=U(n??0),[a,l]=U(n!==void 0);let c=!!(n&&n>0),d=null,u=null;const _=()=>{u!==null&&(cancelAnimationFrame(u),u=null),d!==null&&(i(d),d=null)},m=w=>{d=w,u===null&&(u=requestAnimationFrame(()=>{u=null,d!==null&&(i(d),d=null)}))},g=()=>e.virtualizationEnabled?e.virtualizationEnabled():!0,p=F(()=>{var w;return(w=e.forceVisible)!=null&&w.call(e)||!g()?!1:!r()}),E=()=>{var w;return!!((w=e.suspendMeasurements)!=null&&w.call(e))};let h,f,b,y;function v(){b&&(b.disconnect(),b=void 0)}function O(){y&&(y(),y=void 0)}function T(w){var me,Ae;if(!Number.isFinite(w)||w<0)return;const P=w,j=Ml.get(e.cacheKey)??s();if(j>0&&(P===0||P>0&&P<j)){c||(c=!0,(me=e.onMeasured)==null||me.call(e)),l(!0),Ml.set(e.cacheKey,j),o(j);return}P>0&&(Ml.set(e.cacheKey,P),l(!0),c||(c=!0,(Ae=e.onMeasured)==null||Ae.call(e))),o(P)}function I(){if(!f||E())return;const w=f.offsetHeight;w!==s()&&T(w)}function k(){if(!(!f||E())){if(v(),typeof ResizeObserver>"u"){I();return}b=new ResizeObserver(()=>{E()||I()}),b.observe(f)}}function A(w){if(O(),!h){i(!0);return}if(typeof IntersectionObserver>"u"){i(!0);return}const P=e.threshold??vZ;y=NZ(h,w,P,j=>{const le=OZ(j);m(le)})}function V(w){h=w??void 0;const P=e.scrollContainer?e.scrollContainer():null;A(P??null)}function B(w){f=w??void 0,f?queueMicrotask(()=>{p()||E()||(I(),k())}):v()}J(()=>{p()||E()?v():f&&queueMicrotask(()=>{I(),k()})}),J(()=>{const w=e.cacheKey,P=Ml.get(w);P!==void 0?(o(P),l(!0)):(o(0),l(!1))}),J(()=>{E();const w=e.scrollContainer?e.scrollContainer():null;A(w??null)});const $=F(()=>{const w=s();return w>0?w:e.minPlaceholderHeight??yZ});Ne(()=>{v(),O(),_()});const M=()=>["virtual-item-wrapper",e.class].filter(Boolean).join(" "),L=()=>{const w=["virtual-item-content",e.contentClass];return p()&&w.push("virtual-item-content-hidden"),w.filter(Boolean).join(" ")},R=()=>["virtual-item-placeholder",e.placeholderClass].filter(Boolean).join(" "),D=F(()=>p()?null:t());return(()=>{var w=bZ(),P=w.firstChild,j=P.firstChild,le=V;typeof le=="function"?wt(le,w):V=w;var me=B;return typeof me=="function"?wt(me,j):B=j,C(j,D),ne(Ae=>{var ie=e.id,re=M(),Ee=R(),Se=p()?`${$()}px`:void 0,q=L();return ie!==Ae.e&&Fe(w,"id",Ae.e=ie),re!==Ae.t&&rt(w,Ae.t=re),Ee!==Ae.a&&rt(P,Ae.a=Ee),Se!==Ae.o&&Ci(P,"height",Ae.o=Se),q!==Ae.i&&rt(j,Ae.i=q),Ae},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),w})()}var wZ=x("<div aria-hidden=true style=height:1px>");function Gf(e){return`message-anchor-${e}`}const xZ=800;function DZ(e){return[S(Cw,{get each(){return e.messageIds()},children:(t,n)=>S(AZ,{get id(){return Gf(t())},get cacheKey(){return t()},get scrollContainer(){return e.scrollContainer},threshold:xZ,placeholderClass:"message-stream-placeholder",virtualizationEnabled:()=>!e.loading,get suspendMeasurements(){return e.suspendMeasurements},get children(){return S(GA,{get messageId(){return t()},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get store(){return e.store},messageIndex:n,get lastAssistantIndex(){return e.lastAssistantIndex},get showThinking(){return e.showThinking},get thinkingDefaultExpanded(){return e.thinkingDefaultExpanded},get showUsageMetrics(){return e.showUsageMetrics},get onRevert(){return e.onRevert},get onFork(){return e.onFork},get onContentRendered(){return e.onContentRendered}})}})}),(()=>{var t=wZ(),n=e.setBottomSentinel;return typeof n=="function"?wt(n,t):e.setBottomSentinel=t,t})()]}var LZ=x('<div class="message-preview message-stream">');const kZ=e=>{const t=()=>0;return(()=>{var n=LZ();return C(n,S(GA,{get messageId(){return e.messageId},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get store(){return e.store},messageIndex:0,lastAssistantIndex:t,showThinking:()=>!1,thinkingDefaultExpanded:()=>!1,showUsageMetrics:()=>!1})),n})()};var MZ=x('<div class=message-timeline role=navigation aria-label="Message timeline">'),PZ=x('<button type=button><span class="message-timeline-label message-timeline-label-full"></span><span class="message-timeline-label message-timeline-label-short">'),$Z=x("<div class=message-timeline-tooltip>");const Wv={user:"You",assistant:"Asst",tool:"Tool",compaction:"Compaction"},Hc="Tool Call",qv=220;function QA(e){return e.length<=qv?e:`${e.slice(0,qv-1).trimEnd()}…`}function jA(e){const t=n=>{if(typeof n=="string")return n;if(n&&typeof n=="object"){const r=n,i=[];return typeof r.text=="string"&&i.push(r.text),typeof r.value=="string"&&i.push(r.value),Array.isArray(r.content)&&i.push(r.content.map(s=>t(s)).join(`
163
163
  `)),i.filter(Boolean).join(`
164
164
  `)}return""};return typeof(e==null?void 0:e.text)=="string"?e.text:Array.isArray(e==null?void 0:e.content)?e.content.map(n=>t(n)).join(`
165
165
  `):""}function FZ(e){if(!e)return"";if(typeof e.text=="string")return e.text;if(e.type==="reasoning")return jA(e);if(Array.isArray(e==null?void 0:e.content))return e.content.map(t=>typeof t=="string"?t:"").filter(Boolean).join(`
166
166
  `);if(e.type==="file"){const t=e==null?void 0:e.filename;return typeof t=="string"&&t.length>0?`[File] ${t}`:"Attachment"}return""}function BZ(e){var r;const t=((r=e==null?void 0:e.state)==null?void 0:r.metadata)||{},n=typeof t.title=="string"&&t.title.length>0?t.title:void 0;return n||(typeof e.tool=="string"&&e.tool.length>0?e.tool:Hc)}function UZ(e){return typeof e.tool=="string"&&e.tool.trim().length>0?e.tool.trim().slice(0,4):Hc.slice(0,4)}function GZ(e,t){const n=e.map(r=>r.trim()).filter(r=>r.length>0).join(`
167
167
 
168
- `);return n.length>0?QA(n):t}function VZ(e){return e.length===0?Hc:QA(`${Hc}: ${e.join(", ")}`)}function dg(e,t){if(!t)return[];const{orderedParts:n}=FT(e,t);if(!n||n.length===0)return[];const r=[];let i=0,s=null;const o=()=>{if(!s)return;if(s.type==="assistant"&&!s.hasPrimaryText){s=null;return}const c=s.type==="tool",d=c?s.toolTypeLabels[0]||Hc.slice(0,4):Wv[s.type],u=c?s.toolIcons[0]||Gc("tool"):void 0,_=c?VZ(s.toolTitles):GZ([...s.texts,...s.reasoningTexts],s.type==="user"?"User message":"Assistant response");r.push({id:`${t.id}:${i}`,messageId:t.id,type:s.type,label:d,tooltip:_,shortLabel:u,toolPartIds:c?s.toolPartIds:void 0}),i+=1,s=null},a=c=>((!s||s.type!==c)&&(o(),s={type:c,texts:[],reasoningTexts:[],toolTitles:[],toolTypeLabels:[],toolIcons:[],toolPartIds:[],hasPrimaryText:c!=="assistant"}),s),l=t.role==="user"?"user":"assistant";for(const c of n){if(!c||typeof c!="object")continue;if(c.type==="tool"){const _=a("tool"),m=c;_.toolTitles.push(BZ(m)),_.toolTypeLabels.push(UZ(m)),_.toolIcons.push(Gc(typeof m.tool=="string"?m.tool:"tool")),typeof m.id=="string"&&m.id.length>0&&_.toolPartIds.push(m.id);continue}if(c.type==="reasoning"){const _=jA(c);if(_.trim().length===0)continue;const m=a(l);m&&m.reasoningTexts.push(_);continue}if(c.type==="compaction"){o();const _=!!(c!=null&&c.auto);r.push({id:`${t.id}:${i}`,messageId:t.id,type:"compaction",label:Wv.compaction,tooltip:_?"Auto Compaction":"User Compaction",variant:_?"auto":"manual"}),i+=1;continue}if(c.type==="step-start"||c.type==="step-finish")continue;const d=FZ(c);if(d.trim().length===0)continue;const u=a(l);u&&(u.texts.push(d),u.hasPrimaryText=!0)}return o(),r}const HZ=e=>{const t=new Map,n=()=>Ut.getOrCreate(e.instanceId),[r,i]=U(null),[s,o]=U({top:0,left:0}),[a,l]=U(null),[c,d]=U({width:360,height:420}),[u,_]=U(null);let m=null;const g=()=>e.showToolSegments??!0,p=(y,v)=>{v?t.set(y,v):t.delete(y)},E=()=>{m!==null&&typeof window<"u"&&(window.clearTimeout(m),m=null)},h=(y,v)=>{if(typeof window>"u")return;E();const O=v.currentTarget;m=window.setTimeout(()=>{const T=O.getBoundingClientRect();l({top:T.top,left:T.left,width:T.width,height:T.height}),i(y)},200)},f=()=>{E(),i(null),l(null)};J(()=>{if(typeof window>"u")return;const y=a(),v=r();if(!y||!v)return;const{width:O,height:T}=c(),I=16,k=16,A=y.top+y.height/2-T/2,V=window.innerHeight-T-I,B=Math.min(V,Math.max(I,A)),$=y.left-O-k,M=Math.max(k,$);o({top:B,left:M})}),Ne(()=>E()),J(()=>{const y=e.activeMessageId;if(!y)return;const v=e.segments.find(I=>I.messageId===y);if(!v)return;const O=t.get(v.id);if(!O)return;const T=typeof window<"u"?window.setTimeout(()=>{O.scrollIntoView({block:"nearest",behavior:"smooth"})},120):null;Ne(()=>{T!==null&&typeof window<"u"&&window.clearTimeout(T)})}),J(()=>{const y=u();if(!y||typeof window>"u")return;const v=()=>{const T=y.getBoundingClientRect();d({width:T.width,height:T.height})};if(v(),typeof ResizeObserver>"u")return;const O=new ResizeObserver(()=>v());O.observe(y),Ne(()=>O.disconnect())});const b=F(()=>{const y=r();return!y||!n().getMessage(y.messageId)?null:{messageId:y.messageId}});return(()=>{var y=MZ();return C(y,S(_t,{get each(){return e.segments},children:v=>{Ne(()=>t.delete(v.id));const O=()=>e.activeMessageId===v.messageId,T=()=>{if(v.type!=="tool")return!1;const A=v.toolPartIds??[];if(A.length===0)return!1;for(const V of A){const B=n().getPermissionState(v.messageId,V);if(B!=null&&B.active)return!0}return!1},I=()=>v.type==="tool"&&!(g()||O()||T()),k=()=>v.type==="tool"?T()?S(__,{class:"message-timeline-icon","aria-hidden":"true"}):v.shortLabel??Gc("tool"):v.type==="compaction"?S(tT,{class:"message-timeline-icon","aria-hidden":"true"}):v.type==="user"?S(sT,{class:"message-timeline-icon","aria-hidden":"true"}):S(eT,{class:"message-timeline-icon","aria-hidden":"true"});return(()=>{var A=PZ(),V=A.firstChild,B=V.nextSibling;return A.addEventListener("mouseleave",f),A.addEventListener("mouseenter",$=>h(v,$)),A.$$click=()=>{var $;return($=e.onSegmentClick)==null?void 0:$.call(e,v)},wt($=>p(v.id,$),A),C(V,()=>v.label),C(B,k),ne($=>{var M=v.variant,L=`message-timeline-segment message-timeline-${v.type} ${T()?"message-timeline-segment-permission":""} ${v.type==="compaction"?`message-timeline-compaction-${v.variant??"manual"}`:""} ${O()?"message-timeline-segment-active":""} ${I()?"message-timeline-segment-hidden":""}`,R=O()?"true":void 0,D=I()?"true":void 0;return M!==$.e&&Fe(A,"data-variant",$.e=M),L!==$.t&&rt(A,$.t=L),R!==$.a&&Fe(A,"aria-current",$.a=R),D!==$.o&&Fe(A,"aria-hidden",$.o=D),$},{e:void 0,t:void 0,a:void 0,o:void 0}),A})()}}),null),C(y,S(W,{get when(){return b()},children:v=>(Ne(()=>_(null)),(()=>{var O=$Z();return wt(T=>_(T),O),C(O,S(kZ,{get messageId(){return v().messageId},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},store:n})),ne(T=>{var I=`${s().top}px`,k=`${s().left}px`;return I!==T.e&&Ci(O,"top",T.e=I),k!==T.t&&Ci(O,"left",T.t=k),T},{e:void 0,t:void 0}),O})())}),null),y})()};Ht(["click"]);const YZ=48;function zZ(e){const t=F(()=>({instanceId:ug(e.instanceId),sessionId:ug(e.sessionId),scope:ug(e.scope)})),n=F(()=>{const{instanceId:s}=t();return Ut.getOrCreate(s)});function r(s,o){if(!s)return;const a=t();if(!a.sessionId)return;const l={scrollTop:s.scrollTop,atBottom:WZ(s,(o==null?void 0:o.atBottomOffset)??YZ)};return n().setScrollSnapshot(a.sessionId,a.scope,l),{...l,updatedAt:Date.now()}}function i(s,o){var c,d;const a=t();if(!s||!a.sessionId){(c=o==null?void 0:o.fallback)==null||c.call(o),(d=o==null?void 0:o.onApplied)==null||d.call(o,void 0);return}const l=n().getScrollSnapshot(a.sessionId,a.scope);requestAnimationFrame(()=>{var g,p,E,h;if(!s){(g=o==null?void 0:o.onApplied)==null||g.call(o,l);return}if(!l){(p=o==null?void 0:o.fallback)==null||p.call(o),(E=o==null?void 0:o.onApplied)==null||E.call(o,void 0);return}const u=Math.max(s.scrollHeight-s.clientHeight,0),_=l.atBottom?u:Math.min(l.scrollTop,u),m=(o==null?void 0:o.behavior)??"auto";s.scrollTo({top:_,behavior:m}),(h=o==null?void 0:o.onApplied)==null||h.call(o,l)})}return{persist:r,restore:i}}function WZ(e,t){const{scrollTop:n,scrollHeight:r,clientHeight:i}=e;return r-(n+i)<=t}function ug(e){return typeof e=="function"?e():e}var qZ=x('<div class=empty-state><div class=empty-state-content><div class="flex flex-col items-center gap-3 mb-6"><img alt="CodeNomad logo"class="h-48 w-auto"loading=lazy><h1 class="text-3xl font-semibold text-primary">CodeNomad</h1></div><h3>Start a conversation</h3><p>Type a message below or open the Command Palette:</p><ul><li><span>Command Palette</span></li><li>Ask about your codebase</li><li>Attach files with <code>@',!0,!1,!1),KZ=x("<div class=loading-state><div class=spinner></div><p>Loading messages..."),QZ=x('<button type=button class=message-scroll-button aria-label="Scroll to first message"><span class=message-scroll-icon aria-hidden=true>↑'),jZ=x('<button type=button class=message-scroll-button aria-label="Scroll to latest message"><span class=message-scroll-icon aria-hidden=true>↓'),XZ=x("<div class=message-scroll-button-wrapper>"),ZZ=x("<div class=message-timeline-sidebar>"),JZ=x("<div class=message-stream-container><div><div class=message-stream-shell><div class=message-stream><div aria-hidden=true style=height:1px>"),eJ=x("<div class=message-quote-popover><div class=message-quote-button-group><button type=button class=message-quote-button>Add as quote</button><button type=button class=message-quote-button>Add as code");const tJ="session",Kv=48,nJ=600,rJ=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," ","Spacebar"]),Qv=2e3,iJ=new URL("/assets/CodeNomad-Icon-bmTWNPXy.png",import.meta.url).href;function sJ(e){const{preferences:t}=ro(),n=()=>t().showUsageMetrics??!0,r=()=>t().showTimelineTools??!0,i=F(()=>Ut.getOrCreate(e.instanceId)),s=F(()=>i().getSessionMessageIds(e.sessionId)),o=F(()=>i().getSessionRevision(e.sessionId)),a=F(()=>i().getSessionUsage(e.sessionId)),l=F(()=>Kp(e.instanceId,e.sessionId)??{cost:0,contextWindow:0,isSubscriptionModel:!1,inputTokens:0,outputTokens:0,reasoningTokens:0,actualUsageTokens:0,modelOutputLimit:0,contextAvailableTokens:null});F(()=>{const ye=a(),Ie=l();return{used:(ye==null?void 0:ye.actualUsageTokens)??Ie.actualUsageTokens??0,avail:Ie.contextAvailableTokens}});const c=F(()=>{const ye=t(),Ie=ye.showThinkingBlocks?1:0,Ge=ye.thinkingBlocksExpansion??"expanded",Qe=ye.showUsageMetrics??!0?1:0;return`${Ie}|${Ge}|${Qe}`}),d=ye=>{if(typeof document>"u")return;const Ie=document.getElementById(Gf(ye.messageId));Ie==null||Ie.scrollIntoView({block:"start",behavior:"smooth"})},u=F(()=>{const ye=s(),Ie=i();for(let Ge=ye.length-1;Ge>=0;Ge--){const Qe=Ie.getMessage(ye[Ge]);if((Qe==null?void 0:Qe.role)==="assistant")return Ge}return-1}),[_,m]=U([]),g=()=>_().length>0,p=new Set,E=new Set;function h(ye){return`${ye.messageId}:${ye.id}:${ye.type}`}function f(){p.clear(),E.clear();const ye=Wr(s),Ie=Wr(i),Ge=[];ye.forEach(Qe=>{const ct=Ie.getMessage(Qe);if(!ct)return;p.add(Qe),dg(e.instanceId,ct).forEach(gt=>{const yt=h(gt);E.has(yt)||(E.add(yt),Ge.push(gt))})}),m(Ge)}function b(ye){const Ie=Wr(()=>i().getMessage(ye));if(!Ie)return;const Ge=dg(e.instanceId,Ie);if(Ge.length===0)return;const Qe=[];Ge.forEach(ct=>{const it=h(ct);E.has(it)||(E.add(it),Qe.push(ct))}),Qe.length>0&&m(ct=>[...ct,...Qe])}const[y,v]=U(null),O=F(()=>String(o())),T=F(()=>e.isActive!==!1);zZ({instanceId:()=>e.instanceId,sessionId:()=>e.sessionId,scope:tJ});const[I,k]=U(),[A,V]=U(null),[B,$]=U(null),M=()=>B(),L=ye=>{$(ye),ge()},[R,D]=U(!0),[w,P]=U(!1),[j,le]=U(!1),[me,Ae]=U(!0),[ie,re]=U(!0),[Ee,Se]=U(null);let q,ae,N=null,H=null,te=null,Q=0,z,he=!1,ue=!1,ce=!1,se=null,ke=null,We=!0;function Oe(){Q=(typeof performance<"u"?performance.now():Date.now())+nJ}function je(){return(typeof performance<"u"?performance.now():Date.now())<=Q}function dt(ye){if(z&&(z(),z=void 0),!ye)return;const Ie=()=>Oe(),Ge=Qe=>{rJ.has(Qe.key)&&Oe()};ye.addEventListener("wheel",Ie,{passive:!0}),ye.addEventListener("pointerdown",Ie),ye.addEventListener("touchstart",Ie,{passive:!0}),ye.addEventListener("keydown",Ge),z=()=>{ye.removeEventListener("wheel",Ie),ye.removeEventListener("pointerdown",Ie),ye.removeEventListener("touchstart",Ie),ye.removeEventListener("keydown",Ge)}}function Lt(ye){if(q=ye||void 0,k(q),dt(q),!q){$e();return}ge()}function be(ye){ae=ye||void 0,ae||$e()}function ee(){const ye=s().length>0,Ie=ie(),Ge=me();le(ye&&!Ie),P(ye&&!Ge)}function Re(){te===null&&(te=requestAnimationFrame(()=>{te=null}))}function He(ye=!1,Ie){if(!q)return;const Ge=M(),Qe=ye?"auto":"smooth";((Ie==null?void 0:Ie.suppressAutoAnchor)??!ye)&&(ue=!0),Ge==null||Ge.scrollIntoView({block:"end",inline:"nearest",behavior:Qe}),D(!0),Re()}function qe(){se!==null&&(cancelAnimationFrame(se),se=null),ke!==null&&(cancelAnimationFrame(ke),ke=null)}function de(ye=!0){if(!T()){ce=!0;return}if(!q||!M()){ce=!0;return}ce=!1,qe(),se=requestAnimationFrame(()=>{se=null,ke=requestAnimationFrame(()=>{ke=null,He(ye)})})}function ge(){ce&&T()&&de(!0)}function Ce(ye=!1){var Ge;if(!q)return;const Ie=ye?"auto":"smooth";D(!1),(Ge=A())==null||Ge.scrollIntoView({block:"start",inline:"nearest",behavior:Ie}),Re()}function Ke(ye=!1){if(!R())return;if(!T()){ce=!0;return}const Ie=M();if(!Ie){ce=!0;return}H!==null&&(cancelAnimationFrame(H),H=null),H=requestAnimationFrame(()=>{H=null,Ie.scrollIntoView({block:"end",inline:"nearest",behavior:ye?"auto":"smooth"})})}function $e(){Se(null)}function Be(ye){if(!ye||!q)return!1;const Ie=ye.commonAncestorContainer;return Ie?q.contains(Ie):!1}function tt(){if(!e.onQuoteSelection||typeof window>"u"){$e();return}const ye=window.getSelection();if(!ye||ye.rangeCount===0||ye.isCollapsed){$e();return}const Ie=ye.getRangeAt(0);if(!Be(Ie)){$e();return}const Ge=ae;if(!Ge){$e();return}const Qe=ye.toString().trim();if(!Qe){$e();return}const ct=Qe.length>Qv?Qe.slice(0,Qv).trimEnd():Qe;if(!ct){$e();return}const it=Ie.getClientRects(),gt=it.length>0?it[0]:Ie.getBoundingClientRect(),yt=Ge.getBoundingClientRect(),nn=Math.max(gt.top-yt.top-40,8),Rn=Math.max(Ge.clientWidth-180,8),yr=Math.min(Math.max(gt.left-yt.left,8),Rn);Se({text:ct,top:nn,left:yr})}function pt(){tt()}function at(ye){const Ie=Ee();if(!(!Ie||!e.onQuoteSelection)&&(e.onQuoteSelection(Ie.text,ye),$e(),typeof window<"u")){const Ge=window.getSelection();Ge==null||Ge.removeAllRanges()}}function mt(){e.loading||Ke()}function bt(){if(!q)return;N!==null&&cancelAnimationFrame(N);const ye=je();N=requestAnimationFrame(()=>{if(N=null,!q)return;const Ie=ie();ye&&(Ie?R()||D(!0):R()&&D(!1)),$e(),Re()})}J(()=>{e.registerScrollToBottom&&e.registerScrollToBottom(()=>de(!0))});let Ze=!1;J(()=>{const ye=T();ye?(ge(),!Ze&&R()&&de(!0)):R()&&(ce=!0),Ze=ye}),J(()=>{if(!!e.loading){We=!0;return}if(!We)return;const Ie=I(),Ge=M();!Ie||!Ge||s().length===0||(We=!1,de(!0))});let Ve=[],nt=null,ut=0;J(()=>{const ye=!!e.loading,Ie=s();if(ye){Ve=[],nt=null,ut=0,m([]),p.clear(),E.clear();return}if(Ve.length===0&&Ie.length>0){f(),Ve=Ie.slice();return}if(Ie.length<Ve.length){f(),Ve=Ie.slice();return}if(Ie.length===Ve.length){let Qe=-1,ct=0;for(let it=0;it<Ie.length&&!(Ie[it]!==Ve[it]&&(Qe=it,ct+=1,ct>1));it++);if(ct===1&&Qe>=0){const it=Ve[Qe],gt=Ie[Qe];if(p.has(it)&&!p.has(gt)){p.delete(it),p.add(gt),m(yt=>{const nn=yt.map(Rn=>{if(Rn.messageId!==it)return Rn;const yr=Rn.id.replace(it,gt);return{...Rn,messageId:gt,id:yr}});return E.clear(),nn.forEach(Rn=>E.add(h(Rn))),nn}),Ve=Ie.slice();return}}}const Ge=[];Ie.forEach(Qe=>{p.has(Qe)||Ge.push(Qe)}),Ge.length>0&&Ge.forEach(Qe=>{p.add(Qe),b(Qe)}),Ve=Ie.slice()}),J(()=>{if(e.loading)return;const ye=s();if(ye.length===0)return;const Ie=ye[ye.length-1];if(!Ie)return;const Ge=i().getMessage(Ie);if(!Ge)return;const Qe=Ge.partIds.length;if(Ie===nt&&Qe===ut)return;nt=Ie,ut=Qe;const ct=dg(e.instanceId,Ge),it=[];ct.forEach(gt=>{const yt=h(gt);E.has(yt)||(E.add(yt),it.push(gt))}),it.length>0&&m(gt=>[...gt,...it])}),J(()=>{e.onQuoteSelection||$e()}),J(()=>{if(typeof document>"u")return;const ye=()=>tt(),Ie=Ge=>{ae&&(ae.contains(Ge.target)||$e())};document.addEventListener("selectionchange",ye),document.addEventListener("pointerdown",Ie),Ne(()=>{document.removeEventListener("selectionchange",ye),document.removeEventListener("pointerdown",Ie)})}),J(()=>{e.loading&&$e()}),J(()=>{const ye=q,Ie=e.loading;!ye||Ie||he||(he=!0)});let Yt;return J(()=>{const ye=O();if(!(e.loading||!ye||ye===Yt)){if(Yt=ye,ue){ue=!1;return}R()&&Ke(!0)}}),J(()=>{if(c(),!(e.loading||!R())){if(ue){ue=!1;return}Ke(!0)}}),J(()=>{if(s().length===0){P(!1),le(!1),D(!0);return}ee()}),J(()=>{const ye=I(),Ie=A(),Ge=M();if(!ye||!Ie||!Ge)return;const Qe=new IntersectionObserver(ct=>{let it=!1;for(const gt of ct)gt.target===Ie?(Ae(gt.isIntersecting),it=!0):gt.target===Ge&&(re(gt.isIntersecting),it=!0);it&&ee()},{root:ye,threshold:0,rootMargin:`${Kv}px 0px ${Kv}px 0px`});Qe.observe(Ie),Qe.observe(Ge),Ne(()=>Qe.disconnect())}),J(()=>{const ye=I(),Ie=s();if(!ye||Ie.length===0||typeof document>"u")return;const Ge=new IntersectionObserver(Qe=>{let ct=null;for(const it of Qe)it.isIntersecting&&(!ct||it.boundingClientRect.top<ct.boundingClientRect.top)&&(ct=it);if(ct){const it=ct.target.id,gt=it.startsWith("message-anchor-")?it.slice(15):it;v(yt=>yt===gt?yt:gt)}},{root:ye,rootMargin:"-10% 0px -80% 0px",threshold:0});Ie.forEach(Qe=>{const ct=document.getElementById(Gf(Qe));ct&&Ge.observe(ct)}),Ne(()=>Ge.disconnect())}),Ne(()=>{N!==null&&cancelAnimationFrame(N),te!==null&&cancelAnimationFrame(te),H!==null&&cancelAnimationFrame(H),qe(),z&&z(),$e()}),(()=>{var ye=JZ(),Ie=ye.firstChild,Ge=Ie.firstChild,Qe=Ge.firstChild,ct=Qe.firstChild,it=be;typeof it=="function"?wt(it,Ge):be=Ge,Qe.$$mouseup=pt,Qe.addEventListener("scroll",bt);var gt=Lt;return typeof gt=="function"?wt(gt,Qe):Lt=Qe,wt(V,ct),C(Qe,S(W,{get when(){return we(()=>!e.loading)()&&s().length===0},get children(){var yt=qZ(),nn=yt.firstChild,Rn=nn.firstChild,yr=Rn.firstChild,Rs=Rn.nextSibling,Lr=Rs.nextSibling,ar=Lr.nextSibling,mi=ar.firstChild;return mi.firstChild,Fe(yr,"src",iJ),C(mi,S(ir,{shortcut:"cmd+shift+p",class:"ml-2"}),null),yt}}),null),C(Qe,S(W,{get when(){return e.loading},get children(){return KZ()}}),null),C(Qe,S(DZ,{get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},store:i,messageIds:s,lastAssistantIndex:u,showThinking:()=>t().showThinkingBlocks,thinkingDefaultExpanded:()=>(t().thinkingBlocksExpansion??"expanded")==="expanded",showUsageMetrics:n,scrollContainer:I,get loading(){return e.loading},get onRevert(){return e.onRevert},get onFork(){return e.onFork},onContentRendered:mt,setBottomSentinel:L,suspendMeasurements:()=>!T()}),null),C(Ge,S(W,{get when(){return w()||j()},get children(){var yt=XZ();return C(yt,S(W,{get when(){return w()},get children(){var nn=QZ();return nn.$$click=()=>Ce(),nn}}),null),C(yt,S(W,{get when(){return j()},get children(){var nn=jZ();return nn.$$click=()=>He(!1,{suppressAutoAnchor:!1}),nn}}),null),yt}}),null),C(Ge,S(W,{get when(){return Ee()},children:yt=>(()=>{var nn=eJ(),Rn=nn.firstChild,yr=Rn.firstChild,Rs=yr.nextSibling;return yr.$$click=()=>at("quote"),Rs.$$click=()=>at("code"),ne(Lr=>{var ar=`${yt().top}px`,mi=`${yt().left}px`;return ar!==Lr.e&&Ci(nn,"top",Lr.e=ar),mi!==Lr.t&&Ci(nn,"left",Lr.t=mi),Lr},{e:void 0,t:void 0}),nn})()}),null),C(Ie,S(W,{get when(){return g()},get children(){var yt=ZZ();return C(yt,S(HZ,{get segments(){return _()},onSegmentClick:d,get activeMessageId(){return y()},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get showToolSegments(){return r()}})),yt}}),null),ne(()=>rt(Ie,`message-layout${g()?" message-layout--with-timeline":""}`)),ye})()}Ht(["mouseup","click"]);var oJ=x("<span class=ml-2>"),aJ=x("<div class=dropdown-empty>No results found"),lJ=x("<div class=dropdown-section-header>COMMANDS"),cJ=x("<div class=dropdown-section-header>AGENTS"),dJ=x("<div class=dropdown-section-header>FILES"),uJ=x('<div class="dropdown-surface bottom-full left-0 mb-1 max-w-md"><div class=dropdown-header><div class=dropdown-header-title></div></div><div class="dropdown-content max-h-60"></div><div class=dropdown-footer><div><span class=font-medium>↑↓</span> navigate • <span class=font-medium>Enter</span> select • <span class=font-medium>Esc</span> close'),jv=x('<div class="mt-0.5 text-xs"style=color:var(--text-muted)>'),_J=x('<div><div class="flex items-start gap-2"><svg class="dropdown-icon-accent h-4 w-4 mt-0.5"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M4 6h16M4 12h16M4 18h16"></path></svg><div class=flex-1><div class="text-sm font-medium">/'),mJ=x("<span class=dropdown-badge>subagent"),gJ=x('<div><div class="flex items-start gap-2"><svg class="dropdown-icon-accent h-4 w-4 mt-0.5"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path></svg><div class=flex-1><div class="flex items-center gap-2"><span class="text-sm font-medium">'),fJ=x('<svg class="dropdown-icon-accent h-4 w-4"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z">'),pJ=x('<div><div class="flex items-center gap-2 text-sm"><span class=truncate>'),hJ=x('<svg class="dropdown-icon h-4 w-4"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z">');const Xv=vt("actions"),EJ=100,SJ=200;function bJ(e,t){if(!t)return e;const n=e.replace(/\/+$/,"");return n.length>0?`${n}/`:"./"}function vJ(e){return e==="."||e==="./"||e==="/"}function yJ(e,t){if(vJ(e))return".";const n=e.replace(/^\.\/+/,"");return t?n.replace(/\/+$/,"")||".":n}function _g(e){const t=e.trim();return!t||t==="."||t==="./"?"":t.replace(/^(\.\/)+/,"").replace(/^\/+/,"")}function Zv(e){return e.map(t=>{const n=t.type==="directory";return{path:bJ(t.path,n),relativePath:yJ(t.path,n),isDirectory:n,isGitFile:!1}})}const TJ=e=>{const t=()=>e.mode??"mention",[n,r]=U([]),[i,s]=U([]),[o,a]=U(0),[l,c]=U("idle"),[d,u]=U([]),[_,m]=U(!1),[g,p]=U(null);let E,h,f=null,b="",y=null,v=null,O=0,T=null;function I(){setTimeout(()=>{h&&(h.scrollTop=0)},0)}function k(q){r(q),a(0),I()}async function A(q){return y===q&&v||(y=q,v=vn.listWorkspaceFiles(q).then(ae=>Zv(ae)).then(ae=>(u(ae),p(q),ae)).catch(ae=>{throw Xv.error("[UnifiedPicker] Failed to load workspace files:",ae),u([]),p(null),ae}).finally(()=>{y===q&&(y=null,v=null)})),v}async function V(q){return g()===q&&d().length>0?d():A(q)}async function B(q,ae){const N=_g(q),H=++O,te=!N&&g()===ae&&d().length>0,Q=N?"search":te?"idle":"listing";c(Q!=="idle"?Q:"idle");try{if(!N){const he=await V(ae);if(!L(H,ae))return;k(he);return}const z=await vn.searchWorkspaceFiles(ae,N,{limit:EJ});if(!L(H,ae))return;k(Zv(z))}catch(z){ae===e.workspaceId&&(Xv.error("[UnifiedPicker] Failed to fetch files:",z),L(H,ae)&&k([]))}finally{R(H,ae)&&c("idle")}}function $(){T&&(clearTimeout(T),T=null)}function M(q,ae,N=!1){$();const H=_g(q);if(!N&&H.length>0){T=setTimeout(()=>{T=null,B(q,ae)},SJ);return}B(q,ae)}function L(q,ae){return e.open&&ae===e.workspaceId&&q===O}function R(q,ae){return ae===e.workspaceId&&q===O}function D(){$(),r([]),u([]),p(null),m(!1),a(0),c("idle"),f=null,b="",O=0}Ne(()=>{$()}),J(()=>{if(!e.open){D();return}if(t()!=="mention")return;const q=f!==e.workspaceId,ae=b!==e.searchQuery;if(!_()||q||ae){m(!0),f=e.workspaceId,b=e.searchQuery;const N=q||_g(e.searchQuery).length===0;M(e.searchQuery,e.workspaceId,N)}}),J(()=>{if(!e.open||t()!=="mention")return;const q=e.searchQuery.toLowerCase(),ae=q?e.agents.filter(N=>N.name.toLowerCase().includes(q)||N.description&&N.description.toLowerCase().includes(q)):e.agents;s(ae)});const w=F(()=>{if(t()!=="command")return[];const q=e.searchQuery.trim().toLowerCase(),ae=e.commands??[];return q?ae.filter(N=>{const H=N.name.toLowerCase().includes(q),te=(N.description??"").toLowerCase().includes(q);return H||te}):ae}),P=()=>{const q=[];return t()==="command"?(w().forEach(ae=>q.push({type:"command",command:ae})),q):(i().forEach(ae=>q.push({type:"agent",agent:ae})),n().forEach(ae=>q.push({type:"file",file:ae})),q)};function j(){setTimeout(()=>{const q=E==null?void 0:E.querySelector('[data-picker-selected="true"]');q&&q.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}function le(q){e.onSelect(q)}function me(q){if(!e.open)return;const ae=P();if(q.key==="ArrowDown")q.preventDefault(),a(N=>Math.min(N+1,ae.length-1)),j();else if(q.key==="ArrowUp")q.preventDefault(),a(N=>Math.max(N-1,0)),j();else if(q.key==="Enter"){q.preventDefault();const N=ae[o()];N&&le(N)}else q.key==="Escape"&&(q.preventDefault(),e.onClose())}J(()=>{e.open&&(document.addEventListener("keydown",me),Ne(()=>{document.removeEventListener("keydown",me)}))});const Ae=()=>w().length,ie=()=>i().length,re=()=>n().length,Ee=()=>t()==="mention"&&l()!=="idle",Se=()=>l()==="search"?"Searching...":l()==="listing"?"Loading workspace...":"";return S(W,{get when(){return e.open},get children(){var q=uJ(),ae=q.firstChild,N=ae.firstChild,H=ae.nextSibling,te=E;typeof te=="function"?wt(te,q):E=q,C(N,S(W,{get when(){return t()==="command"},fallback:"Select Agent or File",children:"Select Command"}),null),C(N,S(W,{get when(){return Ee()},get children(){var z=oJ();return C(z,Se),z}}),null);var Q=h;return typeof Q=="function"?wt(Q,H):h=H,C(H,S(W,{get when(){return we(()=>t()==="command")()?Ae()===0:we(()=>ie()===0)()&&re()===0},get children(){return aJ()}}),null),C(H,S(W,{get when(){return we(()=>t()==="command")()&&Ae()>0},get children(){return[lJ(),S(_t,{get each(){return w()},children:z=>{const he=P().findIndex(ue=>ue.type==="command"&&ue.command.name===z.name);return(()=>{var ue=_J(),ce=ue.firstChild,se=ce.firstChild,ke=se.nextSibling,We=ke.firstChild;return We.firstChild,ue.$$click=()=>le({type:"command",command:z}),C(We,()=>z.name,null),C(ke,S(W,{get when(){return z.description},get children(){var Oe=jv();return C(Oe,(()=>{var je=we(()=>(z.description??"").length>80);return()=>je()?(z.description??"").slice(0,80)+"...":z.description})()),Oe}}),null),ne(Oe=>{var je=`dropdown-item ${he===o()?"dropdown-item-highlight":""}`,dt=he===o();return je!==Oe.e&&rt(ue,Oe.e=je),dt!==Oe.t&&Fe(ue,"data-picker-selected",Oe.t=dt),Oe},{e:void 0,t:void 0}),ue})()}})]}}),null),C(H,S(W,{get when(){return we(()=>t()==="mention")()&&ie()>0},get children(){return[cJ(),S(_t,{get each(){return i()},children:z=>{const he=P().findIndex(ue=>ue.type==="agent"&&ue.agent.name===z.name);return(()=>{var ue=gJ(),ce=ue.firstChild,se=ce.firstChild,ke=se.nextSibling,We=ke.firstChild,Oe=We.firstChild;return ue.$$click=()=>le({type:"agent",agent:z}),C(Oe,()=>z.name),C(We,S(W,{get when(){return z.mode==="subagent"},get children(){return mJ()}}),null),C(ke,S(W,{get when(){return z.description},get children(){var je=jv();return C(je,(()=>{var dt=we(()=>!!(z.description&&z.description.length>80));return()=>dt()?z.description.slice(0,80)+"...":z.description})()),je}}),null),ne(je=>{var dt=`dropdown-item ${he===o()?"dropdown-item-highlight":""}`,Lt=he===o();return dt!==je.e&&rt(ue,je.e=dt),Lt!==je.t&&Fe(ue,"data-picker-selected",je.t=Lt),je},{e:void 0,t:void 0}),ue})()}})]}}),null),C(H,S(W,{get when(){return we(()=>t()==="mention")()&&re()>0},get children(){return[dJ(),S(_t,{get each(){return n()},children:z=>{const he=P().findIndex(ce=>ce.type==="file"&&ce.file.relativePath===z.relativePath),ue=z.isDirectory;return(()=>{var ce=pJ(),se=ce.firstChild,ke=se.firstChild;return ce.$$click=()=>le({type:"file",file:z}),C(se,S(W,{when:ue,get fallback(){return hJ()},get children(){return fJ()}}),ke),C(ke,()=>z.path),ne(We=>{var Oe=`dropdown-item py-1.5 ${he===o()?"dropdown-item-highlight":""}`,je=he===o();return Oe!==We.e&&rt(ce,We.e=Oe),je!==We.t&&Fe(ce,"data-picker-selected",We.t=je),We},{e:void 0,t:void 0}),ce})()}})]}}),null),q}})};Ht(["click"]);var CJ=x('<button type=button class=prompt-expand-button aria-label="Toggle chat input height">');function RJ(e){function t(){const n=e.expandState();e.onToggleExpand(n==="normal"?"expanded":"normal")}return(()=>{var n=CJ();return n.$$click=t,C(n,S(W,{get when(){return e.expandState()==="normal"},get fallback(){return S(i0,{class:"h-4 w-4","aria-hidden":"true"})},get children(){return S(n0,{class:"h-4 w-4","aria-hidden":"true"})}})),n})()}Ht(["click"]);const Jv=100;async function IJ(e,t){!e||!t||(await Bo(e),await up(e,n=>{const r=[t,...n.messageHistory??[]];r.length>Jv&&(r.length=Jv),n.messageHistory=r}))}async function OJ(e){return e?(await Bo(e),[..._p(e).messageHistory??[]]):[]}const[NJ,sE]=U(new Map);function tm(e,t){return`${e}:${t}`}function Vf(e,t){const n=tm(e,t);return NJ().get(n)||[]}function Pl(e,t,n){const r=tm(e,t);sE(i=>{const s=new Map(i),o=s.get(r)||[];return s.set(r,[...o,n]),s})}function Ec(e,t,n){const r=tm(e,t);sE(i=>{const s=new Map(i),o=s.get(r)||[];return s.set(r,o.filter(a=>a.id!==n)),s})}function AJ(e,t){const n=tm(e,t);sE(r=>{const i=new Map(r);return i.delete(n),i})}function oE(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function mg(e,t,n="text/plain",r,i){let s=e;return i&&!e.startsWith("file://")?s=`file://${e.startsWith("/")?e:`${i}/${e}`}`:!e.startsWith("file://")&&e.startsWith("/")&&(s=`file://${e}`),{id:oE(),type:"file",display:`@${t}`,url:s,filename:t,mediaType:n,source:{type:"file",path:e,mime:n,data:r}}}function wJ(e,t,n){const r=xJ(e);return{id:oE(),type:"text",display:t,url:`data:text/plain;base64,${r}`,filename:n,mediaType:"text/plain",source:{type:"text",value:e}}}function xJ(e){if(typeof TextEncoder<"u"){const n=new TextEncoder().encode(e);let r="";const i=32768;for(let s=0;s<n.length;s+=i){const o=n.subarray(s,Math.min(s+i,n.length));r+=String.fromCharCode(...o)}return btoa(r)}return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(Number.parseInt(n,16))))}function DJ(e){return{id:oE(),type:"agent",display:`@${e}`,url:"",filename:e,mediaType:"text/plain",source:{type:"agent",name:e}}}var LJ=x('<button type=button class=prompt-history-button aria-label="Previous prompt">'),kJ=x('<button type=button class=prompt-history-button aria-label="Next prompt">'),MJ=x('<span class="prompt-overlay-text prompt-overlay-warning">Press <!> again to abort session'),ey=x("<span class=prompt-overlay-shell-active>Shell mode active"),PJ=x("<div>"),$J=x('<svg class=shell-icon viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><path stroke-linecap=round stroke-linejoin=round d="M5 8l5 4-5 4"></path><path stroke-linecap=round stroke-linejoin=round d="M13 16h6">'),FJ=x('<div class=prompt-input-container><div><div class="flex flex-1 flex-col"><div><div><textarea autocorrect=off autocapitalize=off autocomplete=off></textarea><div class=prompt-nav-buttons></div></div></div></div><div class=prompt-input-actions><button type=button class=stop-button aria-label="Stop session"title="Stop session"><svg class=stop-icon viewBox="0 0 20 20"fill=currentColor aria-hidden=true><rect x=4 y=4 width=12 height=12 rx=2></rect></svg></button><button type=button aria-label="Send message">'),BJ=x("<span class=prompt-overlay-text> New line • <!> Send • <!> Files/agents • <!> History"),UJ=x('<span class="prompt-overlay-text prompt-overlay-muted">• <!> file(s) attached'),ty=x("<span class=prompt-overlay-text>• <!> "),GJ=x("<span class=send-icon>▶");const ny=vt("actions");function VJ(e){const[t,n]=U(""),[r,i]=U([]),s=100,[o,a]=U(-1),[l,c]=U(null),[,d]=U(!1),[u,_]=U(!1),[m,g]=U("mention"),[p,E]=U(""),[h,f]=U(null),[b,y]=U(!1),[v,O]=U(new Set),[T,I]=U(0),[k,A]=U(0),[V,B]=U("normal"),[$,M]=U("normal"),L=2e3;let R;const D=()=>V()==="shell"?"Run a shell command (Esc to exit)...":"Type your message, @file, @agent, or paste images and text...",w=()=>Vf(e.instanceId,e.sessionId),P=()=>A_().get(e.instanceId)||[];J(()=>{if(!e.registerQuoteHandler)return;const de=e.registerQuoteHandler((ge,Ce)=>{Ce==="code"?We(ge):ke(ge)});Ne(()=>{typeof de=="function"&&de()})});const j=de=>{n(de),wm(e.instanceId,e.sessionId,de)},le=()=>{NR(e.instanceId,e.sessionId),n(""),c(null),B("normal")};function me(de,ge){let Ce=0,Ke=0;for(const $e of de.matchAll(/\[pasted #(\d+)\]/g)){const Be=Number.parseInt($e[1],10);Number.isNaN(Be)||(Ce=Math.max(Ce,Be))}for(const $e of ge){if($e.source.type==="text"){const Be=$e.display.match(/pasted #(\d+)/);if(Be){const tt=Number.parseInt(Be[1],10);Number.isNaN(tt)||(Ce=Math.max(Ce,tt))}}if($e.source.type==="file"&&$e.mediaType.startsWith("image/")){const Be=$e.display.match(/Image #(\d+)/);if(Be){const tt=Number.parseInt(Be[1],10);Number.isNaN(tt)||(Ke=Math.max(Ke,tt))}}}for(const $e of de.matchAll(/\[Image #(\d+)\]/g)){const Be=Number.parseInt($e[1],10);Number.isNaN(Be)||(Ke=Math.max(Ke,Be))}I(Ce),A(Ke)}J(qr(()=>`${e.instanceId}:${e.sessionId}`,()=>{const de=e.instanceId,ge=e.sessionId;Ne(()=>{wm(de,ge,t())});const Ce=LU(de,ge),Ke=Wr(()=>Vf(de,ge));n(Ce),wm(de,ge,Ce),a(-1),c(null),O(new Set),_(!1),f(null),E(""),me(Ce,Ke)}));async function Ae(de){var tt,pt;const ge=(tt=de.clipboardData)==null?void 0:tt.items;if(!ge)return;for(let at=0;at<ge.length;at++){const mt=ge[at];if(mt.type.startsWith("image/")){de.preventDefault();const bt=mt.getAsFile();if(!bt)continue;const Ze=k()+1;A(Ze);const Ve=new FileReader;Ve.onload=()=>{const nt=Ve.result.split(",")[1],ut=`[Image #${Ze}]`,Yt=`image-${Ze}.png`,ye=mg(Yt,Yt,"image/png",new TextEncoder().encode(nt),e.instanceFolder);ye.url=`data:image/png;base64,${nt}`,ye.display=ut,Pl(e.instanceId,e.sessionId,ye);const Ie=R;if(Ie){const Ge=Ie.selectionStart,Qe=Ie.selectionEnd,ct=t(),it=`[Image #${Ze}]`,gt=ct.substring(0,Ge)+it+ct.substring(Qe);j(gt),setTimeout(()=>{const yt=Ge+it.length;Ie.setSelectionRange(yt,yt),Ie.focus()},0)}},Ve.readAsDataURL(bt);return}}const Ce=(pt=de.clipboardData)==null?void 0:pt.getData("text/plain");if(!Ce)return;const Ke=Ce.split(`
169
- `).length,$e=Ce.length;if($e>150||Ke>3){de.preventDefault();const at=T()+1;I(at);const mt=Ke>1?`${Ke} lines`:`${$e} chars`,bt=`pasted #${at} (${mt})`,Ze=`paste-${at}.txt`,Ve=wJ(Ce,bt,Ze);Pl(e.instanceId,e.sessionId,Ve);const nt=R;if(nt){const ut=nt.selectionStart,Yt=nt.selectionEnd,ye=t(),Ie=`[pasted #${at}]`,Ge=ye.substring(0,ut)+Ie+ye.substring(Yt);j(Ge),setTimeout(()=>{const Qe=ut+Ie.length;nt.setSelectionRange(Qe,Qe),nt.focus()},0)}}}Tn(()=>{const de=ge=>{const Ce=document.activeElement;(Ce==null?void 0:Ce.tagName)==="INPUT"||(Ce==null?void 0:Ce.tagName)==="TEXTAREA"||(Ce==null?void 0:Ce.tagName)==="SELECT"||Ce!=null&&Ce.isContentEditable||ge.ctrlKey||ge.metaKey||ge.altKey||ge.key==="Tab"||ge.key==="Enter"||ge.key.startsWith("Arrow")||ge.key==="Backspace"||ge.key==="Delete"||ge.key.length===1&&R&&!e.disabled&&R.focus()};document.addEventListener("keydown",de),Ne(()=>{document.removeEventListener("keydown",de)}),(async()=>{const ge=await OJ(e.instanceFolder);i(ge)})()});function ie(de){const ge=R;if(!ge)return;const Ce=t(),Ke=ge.selectionStart===0&&ge.selectionEnd===0,$e=V()==="shell";if(!$e&&de.key==="!"&&Ke&&Ce.length===0&&!e.disabled){de.preventDefault(),B("shell");return}if(u()&&de.key==="Escape"){de.preventDefault(),de.stopPropagation(),z();return}if($e){if(de.key==="Escape"){de.preventDefault(),de.stopPropagation(),B("normal");return}if(de.key==="Backspace"&&Ke&&Ce.length===0){de.preventDefault(),B("normal");return}}if(de.key==="Backspace"||de.key==="Delete"){const Be=ge.selectionStart,tt=Ce,pt=/\[pasted #(\d+)\]/g;let at;for(;(at=pt.exec(tt))!==null;){const nt=at.index,ut=at.index+at[0].length,Yt=at[1],ye=de.key==="Backspace"&&Be===ut,Ie=de.key==="Delete"&&Be===nt,Ge=ge.selectionStart<=nt&&ge.selectionEnd>=ut&&ge.selectionStart!==ge.selectionEnd;if(ye||Ie||Ge){de.preventDefault();const ct=w().find(gt=>gt.source.type==="text"&&gt.display.includes(`pasted #${Yt}`));ct&&Ec(e.instanceId,e.sessionId,ct.id);const it=tt.substring(0,nt)+tt.substring(ut);j(it),setTimeout(()=>{ge.setSelectionRange(nt,nt)},0);return}}const mt=/\[Image #(\d+)\]/g;let bt;for(;(bt=mt.exec(tt))!==null;){const nt=bt.index,ut=bt.index+bt[0].length,Yt=bt[1],ye=de.key==="Backspace"&&Be===ut,Ie=de.key==="Delete"&&Be===nt,Ge=ge.selectionStart<=nt&&ge.selectionEnd>=ut&&ge.selectionStart!==ge.selectionEnd;if(ye||Ie||Ge){de.preventDefault();const ct=w().find(gt=>gt.source.type==="file"&&gt.mediaType.startsWith("image/")&&gt.display.includes(`Image #${Yt}`));ct&&Ec(e.instanceId,e.sessionId,ct.id);const it=tt.substring(0,nt)+tt.substring(ut);j(it),setTimeout(()=>{ge.setSelectionRange(nt,nt)},0);return}}const Ze=/@(\S+)/g;let Ve;for(;(Ve=Ze.exec(tt))!==null;){const nt=Ve.index,ut=Ve.index+Ve[0].length,Yt=Ve[1],ye=de.key==="Backspace"&&Be===ut,Ie=de.key==="Delete"&&Be===nt,Ge=ge.selectionStart<=nt&&ge.selectionEnd>=ut&&ge.selectionStart!==ge.selectionEnd;if(ye||Ie||Ge){const ct=w().find(it=>(it.source.type==="file"||it.source.type==="agent")&&it.filename===Yt);if(ct){de.preventDefault(),Ec(e.instanceId,e.sessionId,ct.id),O(gt=>{const yt=new Set(gt);return yt.delete(nt),yt});const it=tt.substring(0,nt)+tt.substring(ut);j(it),setTimeout(()=>{ge.setSelectionRange(nt,nt)},0);return}}}}if(de.key==="Enter"&&(de.metaKey||de.ctrlKey)){de.preventDefault(),u()&&z(),re();return}if(de.key==="ArrowUp"&&q()){de.preventDefault();return}if(de.key==="ArrowDown"&&ae()){de.preventDefault();return}}async function re(){const de=t().trim(),ge=w();if(e.disabled||!de&&ge.length===0)return;const Ce=V()==="shell",Ke=!Ce&&de.startsWith("/"),$e=Ke?de.indexOf(" "):-1,Be=Ke?$e===-1?de:de.slice(0,$e):"",tt=Ke?Be.slice(1):"",pt=Ke?$e===-1?"":de.slice($e+1).trimStart():"",at=Ke&&tt.length>0&&YS(e.instanceId).some(Ve=>Ve.name===tt),mt=at?de:PT(de,ge),bt=mt,Ze=async()=>{try{await IJ(e.instanceFolder,bt),i(Ve=>{const nt=[bt,...Ve];return nt.length>s&&(nt.length=s),nt}),a(-1)}catch(Ve){ny.error("Failed to update prompt history:",Ve)}};le(),at?(me("",ge),O(new Set)):(AJ(e.instanceId,e.sessionId),I(0),A(0),O(new Set)),c(null),at&&Ze();try{Ce?e.onRunShell?await e.onRunShell(mt):await e.onSend(mt,[]):at?await JM(e.instanceId,e.sessionId,tt,pt):await e.onSend(mt,ge),at||Ze()}catch(Ve){ny.error("Failed to send message:",Ve),Gs("Failed to send message",{title:"Send failed",detail:Ve instanceof Error?Ve.message:String(Ve),variant:"error"})}finally{R==null||R.focus()}}function Ee(){R&&setTimeout(()=>{if(!R)return;const de=R.value.length;R.setSelectionRange(de,de),R.focus()},0)}function Se(de=!1){if(de)return!0;if(u())return!1;const ge=R;return ge?ge.selectionStart===0&&ge.selectionEnd===0:!1}function q(de=!1){const ge=r();if(ge.length===0||!Se(de))return!1;o()===-1&&c(t());const Ce=o()===-1?0:Math.min(o()+1,ge.length-1);return a(Ce),j(ge[Ce]),Ee(),!0}function ae(de=!1){const ge=r();if(ge.length===0||!Se(de)||o()===-1)return!1;const Ce=o()-1;if(Ce>=0)a(Ce),j(ge[Ce]);else{a(-1);const Ke=l();j(Ke??""),c(null)}return Ee(),!0}function N(){!e.onAbortSession||!e.isSessionBusy||e.onAbortSession()}function H(de){M(de),R==null||R.focus()}function te(de){const ge=de.target,Ce=ge.value;j(Ce),a(-1),c(null);const Ke=ge.selectionStart;if(Ce.startsWith("/")&&Ke>=1){const pt=Ce.slice(1).search(/\s/),at=pt===-1?Ce.length:pt+1;if(Ke<=at){g("command"),f(0),E(Ce.substring(1,Ke)),_(!0);return}}const Be=Ce.substring(0,Ke).lastIndexOf("@"),tt=h();if(Be===-1?O(new Set):tt!==null&&Be!==tt&&O(pt=>{const at=new Set(pt);return at.delete(tt),at}),Be!==-1){const pt=Ce.substring(Be+1,Ke);if(!(pt.includes(" ")||pt.includes(`
170
- `))&&Ke===Be+pt.length+1){v().has(Be)||(g("mention"),f(Be),E(pt),_(!0));return}}_(!1),f(null)}function Q(de){if(de.type==="command"){const ge=de.command.name,Ce=t(),$e=Ce.slice(1).search(/\s/),Be=$e===-1?Ce.length:$e+1,tt="",pt=Ce.substring(Be),at=tt+`/${ge} `+pt;j(at),setTimeout(()=>{if(R){const mt=`/${ge} `.length;R.setSelectionRange(mt,mt),R.focus()}},0)}else if(de.type==="agent"){const ge=de.agent.name;if(!w().some(pt=>pt.source.type==="agent"&&pt.source.name===ge)){const pt=DJ(ge);Pl(e.instanceId,e.sessionId,pt)}const $e=t(),Be=h(),tt=(R==null?void 0:R.selectionStart)||0;if(Be!==null){const pt=$e.substring(0,Be),at=$e.substring(tt),mt=`@${ge}`,bt=pt+mt+" "+at;j(bt),setTimeout(()=>{if(R){const Ze=Be+mt.length+1;R.setSelectionRange(Ze,Ze)}},0)}}else if(de.type==="file"){const ge=de.file.path,Ce=de.file.relativePath??ge;if(de.file.isDirectory??ge.endsWith("/")){const Ve=t(),nt=h(),ut=(R==null?void 0:R.selectionStart)||0,Yt=Ce==="."||Ce===""?"/":ge;if(nt!==null){const ye=Ve.substring(0,nt+1),Ie=Ve.substring(ut),Ge=ye+Yt+Ie;j(Ge),E(Yt),setTimeout(()=>{if(R){const Qe=nt+1+Yt.length;R.setSelectionRange(Qe,Qe)}},0)}return}const $e=Ce.replace(/\/+$/,"")||Ce,Be=$e.split("/"),tt=(()=>{const Ve=Be[Be.length-1]||$e;return Ve==="."?"/":Ve})();if(!w().some(Ve=>Ve.source.type==="file"&&Ve.source.path===$e)){const Ve=mg($e,tt,"text/plain",void 0,e.instanceFolder);Pl(e.instanceId,e.sessionId,Ve)}const mt=t(),bt=h(),Ze=(R==null?void 0:R.selectionStart)||0;if(bt!==null){const Ve=mt.substring(0,bt),nt=mt.substring(Ze),ut=`@${tt}`,Yt=Ve+ut+" "+nt;j(Yt),setTimeout(()=>{if(R){const ye=bt+ut.length+1;R.setSelectionRange(ye,ye)}},0)}}_(!1),f(null),E(""),R==null||R.focus()}function z(){const de=h();m()==="mention"&&de!==null&&O(ge=>new Set(ge).add(de)),_(!1),f(null),E(""),setTimeout(()=>R==null?void 0:R.focus(),0)}function he(de){de.preventDefault(),de.stopPropagation(),y(!0)}function ue(de){de.preventDefault(),de.stopPropagation(),y(!1)}function ce(de){var Ce;de.preventDefault(),de.stopPropagation(),y(!1);const ge=(Ce=de.dataTransfer)==null?void 0:Ce.files;if(!(!ge||ge.length===0)){for(let Ke=0;Ke<ge.length;Ke++){const $e=ge[Ke],Be=$e.path||$e.name,tt=$e.name,pt=$e.type||"text/plain",at=mt=>{const bt=mg(Be,tt,pt,void 0,e.instanceFolder);mt&&(pt.startsWith("image/")||pt.startsWith("text/"))&&(bt.url=mt),Pl(e.instanceId,e.sessionId,bt)};if(pt.startsWith("image/")&&typeof FileReader<"u"){const mt=new FileReader;mt.onload=()=>{const bt=typeof mt.result=="string"?mt.result:void 0;at(bt)},mt.readAsDataURL($e)}else if(pt.startsWith("text/")&&typeof FileReader<"u"){const mt=new FileReader;mt.onload=()=>{const bt=typeof mt.result=="string"?mt.result:void 0;at(bt)},mt.readAsDataURL($e)}else at()}R==null||R.focus()}}function se(de){const ge=R,Ce=t(),Ke=ge?ge.selectionStart:Ce.length,$e=ge?ge.selectionEnd:Ce.length,Be=Ce.substring(0,Ke),tt=Ce.substring($e),at=`${Be.length>0&&!Be.endsWith(`
168
+ `);return n.length>0?QA(n):t}function VZ(e){return e.length===0?Hc:QA(`${Hc}: ${e.join(", ")}`)}function dg(e,t){if(!t)return[];const{orderedParts:n}=FT(e,t);if(!n||n.length===0)return[];const r=[];let i=0,s=null;const o=()=>{if(!s)return;if(s.type==="assistant"&&!s.hasPrimaryText){s=null;return}const c=s.type==="tool",d=c?s.toolTypeLabels[0]||Hc.slice(0,4):Wv[s.type],u=c?s.toolIcons[0]||Gc("tool"):void 0,_=c?VZ(s.toolTitles):GZ([...s.texts,...s.reasoningTexts],s.type==="user"?"User message":"Assistant response");r.push({id:`${t.id}:${i}`,messageId:t.id,type:s.type,label:d,tooltip:_,shortLabel:u,toolPartIds:c?s.toolPartIds:void 0}),i+=1,s=null},a=c=>((!s||s.type!==c)&&(o(),s={type:c,texts:[],reasoningTexts:[],toolTitles:[],toolTypeLabels:[],toolIcons:[],toolPartIds:[],hasPrimaryText:c!=="assistant"}),s),l=t.role==="user"?"user":"assistant";for(const c of n){if(!c||typeof c!="object")continue;if(c.type==="tool"){const _=a("tool"),m=c;_.toolTitles.push(BZ(m)),_.toolTypeLabels.push(UZ(m)),_.toolIcons.push(Gc(typeof m.tool=="string"?m.tool:"tool")),typeof m.id=="string"&&m.id.length>0&&_.toolPartIds.push(m.id);continue}if(c.type==="reasoning"){const _=jA(c);if(_.trim().length===0)continue;const m=a(l);m&&m.reasoningTexts.push(_);continue}if(c.type==="compaction"){o();const _=!!(c!=null&&c.auto);r.push({id:`${t.id}:${i}`,messageId:t.id,type:"compaction",label:Wv.compaction,tooltip:_?"Auto Compaction":"User Compaction",variant:_?"auto":"manual"}),i+=1;continue}if(c.type==="step-start"||c.type==="step-finish")continue;const d=FZ(c);if(d.trim().length===0)continue;const u=a(l);u&&(u.texts.push(d),u.hasPrimaryText=!0)}return o(),r}const HZ=e=>{const t=new Map,n=()=>Ut.getOrCreate(e.instanceId),[r,i]=U(null),[s,o]=U({top:0,left:0}),[a,l]=U(null),[c,d]=U({width:360,height:420}),[u,_]=U(null);let m=null;const g=()=>e.showToolSegments??!0,p=(y,v)=>{v?t.set(y,v):t.delete(y)},E=()=>{m!==null&&typeof window<"u"&&(window.clearTimeout(m),m=null)},h=(y,v)=>{if(typeof window>"u")return;E();const O=v.currentTarget;m=window.setTimeout(()=>{const T=O.getBoundingClientRect();l({top:T.top,left:T.left,width:T.width,height:T.height}),i(y)},200)},f=()=>{E(),i(null),l(null)};J(()=>{if(typeof window>"u")return;const y=a(),v=r();if(!y||!v)return;const{width:O,height:T}=c(),I=16,k=16,A=y.top+y.height/2-T/2,V=window.innerHeight-T-I,B=Math.min(V,Math.max(I,A)),$=y.left-O-k,M=Math.max(k,$);o({top:B,left:M})}),Ne(()=>E()),J(()=>{const y=e.activeMessageId;if(!y)return;const v=e.segments.find(I=>I.messageId===y);if(!v)return;const O=t.get(v.id);if(!O)return;const T=typeof window<"u"?window.setTimeout(()=>{O.scrollIntoView({block:"nearest",behavior:"smooth"})},120):null;Ne(()=>{T!==null&&typeof window<"u"&&window.clearTimeout(T)})}),J(()=>{const y=u();if(!y||typeof window>"u")return;const v=()=>{const T=y.getBoundingClientRect();d({width:T.width,height:T.height})};if(v(),typeof ResizeObserver>"u")return;const O=new ResizeObserver(()=>v());O.observe(y),Ne(()=>O.disconnect())});const b=F(()=>{const y=r();return!y||!n().getMessage(y.messageId)?null:{messageId:y.messageId}});return(()=>{var y=MZ();return C(y,S(_t,{get each(){return e.segments},children:v=>{Ne(()=>t.delete(v.id));const O=()=>e.activeMessageId===v.messageId,T=()=>{if(v.type!=="tool")return!1;const A=v.toolPartIds??[];if(A.length===0)return!1;for(const V of A){const B=n().getPermissionState(v.messageId,V);if(B!=null&&B.active)return!0}return!1},I=()=>v.type==="tool"&&!(g()||O()||T()),k=()=>v.type==="tool"?T()?S(__,{class:"message-timeline-icon","aria-hidden":"true"}):v.shortLabel??Gc("tool"):v.type==="compaction"?S(tT,{class:"message-timeline-icon","aria-hidden":"true"}):v.type==="user"?S(sT,{class:"message-timeline-icon","aria-hidden":"true"}):S(eT,{class:"message-timeline-icon","aria-hidden":"true"});return(()=>{var A=PZ(),V=A.firstChild,B=V.nextSibling;return A.addEventListener("mouseleave",f),A.addEventListener("mouseenter",$=>h(v,$)),A.$$click=()=>{var $;return($=e.onSegmentClick)==null?void 0:$.call(e,v)},wt($=>p(v.id,$),A),C(V,()=>v.label),C(B,k),ne($=>{var M=v.variant,L=`message-timeline-segment message-timeline-${v.type} ${T()?"message-timeline-segment-permission":""} ${v.type==="compaction"?`message-timeline-compaction-${v.variant??"manual"}`:""} ${O()?"message-timeline-segment-active":""} ${I()?"message-timeline-segment-hidden":""}`,R=O()?"true":void 0,D=I()?"true":void 0;return M!==$.e&&Fe(A,"data-variant",$.e=M),L!==$.t&&rt(A,$.t=L),R!==$.a&&Fe(A,"aria-current",$.a=R),D!==$.o&&Fe(A,"aria-hidden",$.o=D),$},{e:void 0,t:void 0,a:void 0,o:void 0}),A})()}}),null),C(y,S(W,{get when(){return b()},children:v=>(Ne(()=>_(null)),(()=>{var O=$Z();return wt(T=>_(T),O),C(O,S(kZ,{get messageId(){return v().messageId},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},store:n})),ne(T=>{var I=`${s().top}px`,k=`${s().left}px`;return I!==T.e&&Ci(O,"top",T.e=I),k!==T.t&&Ci(O,"left",T.t=k),T},{e:void 0,t:void 0}),O})())}),null),y})()};Ht(["click"]);const YZ=48;function zZ(e){const t=F(()=>({instanceId:ug(e.instanceId),sessionId:ug(e.sessionId),scope:ug(e.scope)})),n=F(()=>{const{instanceId:s}=t();return Ut.getOrCreate(s)});function r(s,o){if(!s)return;const a=t();if(!a.sessionId)return;const l={scrollTop:s.scrollTop,atBottom:WZ(s,(o==null?void 0:o.atBottomOffset)??YZ)};return n().setScrollSnapshot(a.sessionId,a.scope,l),{...l,updatedAt:Date.now()}}function i(s,o){var c,d;const a=t();if(!s||!a.sessionId){(c=o==null?void 0:o.fallback)==null||c.call(o),(d=o==null?void 0:o.onApplied)==null||d.call(o,void 0);return}const l=n().getScrollSnapshot(a.sessionId,a.scope);requestAnimationFrame(()=>{var g,p,E,h;if(!s){(g=o==null?void 0:o.onApplied)==null||g.call(o,l);return}if(!l){(p=o==null?void 0:o.fallback)==null||p.call(o),(E=o==null?void 0:o.onApplied)==null||E.call(o,void 0);return}const u=Math.max(s.scrollHeight-s.clientHeight,0),_=l.atBottom?u:Math.min(l.scrollTop,u),m=(o==null?void 0:o.behavior)??"auto";s.scrollTo({top:_,behavior:m}),(h=o==null?void 0:o.onApplied)==null||h.call(o,l)})}return{persist:r,restore:i}}function WZ(e,t){const{scrollTop:n,scrollHeight:r,clientHeight:i}=e;return r-(n+i)<=t}function ug(e){return typeof e=="function"?e():e}var qZ=x('<div class=empty-state><div class=empty-state-content><div class="flex flex-col items-center gap-3 mb-6"><img alt="CodeNomad logo"class="h-48 w-auto"loading=lazy><h1 class="text-3xl font-semibold text-primary">CodeNomad</h1></div><h3>Start a conversation</h3><p>Type a message below or open the Command Palette:</p><ul><li><span>Command Palette</span></li><li>Ask about your codebase</li><li>Attach files with <code>@',!0,!1,!1),KZ=x("<div class=loading-state><div class=spinner></div><p>Loading messages..."),QZ=x('<button type=button class=message-scroll-button aria-label="Scroll to first message"><span class=message-scroll-icon aria-hidden=true>↑'),jZ=x('<button type=button class=message-scroll-button aria-label="Scroll to latest message"><span class=message-scroll-icon aria-hidden=true>↓'),XZ=x("<div class=message-scroll-button-wrapper>"),ZZ=x("<div class=message-timeline-sidebar>"),JZ=x("<div class=message-stream-container><div><div class=message-stream-shell><div class=message-stream><div aria-hidden=true style=height:1px>"),eJ=x("<div class=message-quote-popover><div class=message-quote-button-group><button type=button class=message-quote-button>Add as quote</button><button type=button class=message-quote-button>Add as code");const tJ="session",Kv=48,nJ=600,rJ=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," ","Spacebar"]),Qv=2e3,iJ=new URL("/assets/CodeNomad-Icon-bmTWNPXy.png",import.meta.url).href;function sJ(e){const{preferences:t}=ro(),n=()=>t().showUsageMetrics??!0,r=()=>t().showTimelineTools??!0,i=F(()=>Ut.getOrCreate(e.instanceId)),s=F(()=>i().getSessionMessageIds(e.sessionId)),o=F(()=>i().getSessionRevision(e.sessionId)),a=F(()=>i().getSessionUsage(e.sessionId)),l=F(()=>Kp(e.instanceId,e.sessionId)??{cost:0,contextWindow:0,isSubscriptionModel:!1,inputTokens:0,outputTokens:0,reasoningTokens:0,actualUsageTokens:0,modelOutputLimit:0,contextAvailableTokens:null});F(()=>{const ye=a(),Ie=l();return{used:(ye==null?void 0:ye.actualUsageTokens)??Ie.actualUsageTokens??0,avail:Ie.contextAvailableTokens}});const c=F(()=>{const ye=t(),Ie=ye.showThinkingBlocks?1:0,Ge=ye.thinkingBlocksExpansion??"expanded",Qe=ye.showUsageMetrics??!0?1:0;return`${Ie}|${Ge}|${Qe}`}),d=ye=>{if(typeof document>"u")return;const Ie=document.getElementById(Gf(ye.messageId));Ie==null||Ie.scrollIntoView({block:"start",behavior:"smooth"})},u=F(()=>{const ye=s(),Ie=i();for(let Ge=ye.length-1;Ge>=0;Ge--){const Qe=Ie.getMessage(ye[Ge]);if((Qe==null?void 0:Qe.role)==="assistant")return Ge}return-1}),[_,m]=U([]),g=()=>_().length>0,p=new Set,E=new Set;function h(ye){return`${ye.messageId}:${ye.id}:${ye.type}`}function f(){p.clear(),E.clear();const ye=Wr(s),Ie=Wr(i),Ge=[];ye.forEach(Qe=>{const ct=Ie.getMessage(Qe);if(!ct)return;p.add(Qe),dg(e.instanceId,ct).forEach(gt=>{const yt=h(gt);E.has(yt)||(E.add(yt),Ge.push(gt))})}),m(Ge)}function b(ye){const Ie=Wr(()=>i().getMessage(ye));if(!Ie)return;const Ge=dg(e.instanceId,Ie);if(Ge.length===0)return;const Qe=[];Ge.forEach(ct=>{const it=h(ct);E.has(it)||(E.add(it),Qe.push(ct))}),Qe.length>0&&m(ct=>[...ct,...Qe])}const[y,v]=U(null),O=F(()=>String(o())),T=F(()=>e.isActive!==!1);zZ({instanceId:()=>e.instanceId,sessionId:()=>e.sessionId,scope:tJ});const[I,k]=U(),[A,V]=U(null),[B,$]=U(null),M=()=>B(),L=ye=>{$(ye),ge()},[R,D]=U(!0),[w,P]=U(!1),[j,le]=U(!1),[me,Ae]=U(!0),[ie,re]=U(!0),[Ee,Se]=U(null);let q,ae,N=null,H=null,te=null,Q=0,z,he=!1,ue=!1,ce=!1,se=null,ke=null,We=!0;function Oe(){Q=(typeof performance<"u"?performance.now():Date.now())+nJ}function je(){return(typeof performance<"u"?performance.now():Date.now())<=Q}function dt(ye){if(z&&(z(),z=void 0),!ye)return;const Ie=()=>Oe(),Ge=Qe=>{rJ.has(Qe.key)&&Oe()};ye.addEventListener("wheel",Ie,{passive:!0}),ye.addEventListener("pointerdown",Ie),ye.addEventListener("touchstart",Ie,{passive:!0}),ye.addEventListener("keydown",Ge),z=()=>{ye.removeEventListener("wheel",Ie),ye.removeEventListener("pointerdown",Ie),ye.removeEventListener("touchstart",Ie),ye.removeEventListener("keydown",Ge)}}function Lt(ye){if(q=ye||void 0,k(q),dt(q),!q){Pe();return}ge()}function be(ye){ae=ye||void 0,ae||Pe()}function ee(){const ye=s().length>0,Ie=ie(),Ge=me();le(ye&&!Ie),P(ye&&!Ge)}function Re(){te===null&&(te=requestAnimationFrame(()=>{te=null}))}function He(ye=!1,Ie){if(!q)return;const Ge=M(),Qe=ye?"auto":"smooth";((Ie==null?void 0:Ie.suppressAutoAnchor)??!ye)&&(ue=!0),Ge==null||Ge.scrollIntoView({block:"end",inline:"nearest",behavior:Qe}),D(!0),Re()}function qe(){se!==null&&(cancelAnimationFrame(se),se=null),ke!==null&&(cancelAnimationFrame(ke),ke=null)}function de(ye=!0){if(!T()){ce=!0;return}if(!q||!M()){ce=!0;return}ce=!1,qe(),se=requestAnimationFrame(()=>{se=null,ke=requestAnimationFrame(()=>{ke=null,He(ye)})})}function ge(){ce&&T()&&de(!0)}function Ce(ye=!1){var Ge;if(!q)return;const Ie=ye?"auto":"smooth";D(!1),(Ge=A())==null||Ge.scrollIntoView({block:"start",inline:"nearest",behavior:Ie}),Re()}function Ke(ye=!1){if(!R())return;if(!T()){ce=!0;return}const Ie=M();if(!Ie){ce=!0;return}H!==null&&(cancelAnimationFrame(H),H=null),H=requestAnimationFrame(()=>{H=null,Ie.scrollIntoView({block:"end",inline:"nearest",behavior:ye?"auto":"smooth"})})}function Pe(){Se(null)}function Be(ye){if(!ye||!q)return!1;const Ie=ye.commonAncestorContainer;return Ie?q.contains(Ie):!1}function nt(){if(!e.onQuoteSelection||typeof window>"u"){Pe();return}const ye=window.getSelection();if(!ye||ye.rangeCount===0||ye.isCollapsed){Pe();return}const Ie=ye.getRangeAt(0);if(!Be(Ie)){Pe();return}const Ge=ae;if(!Ge){Pe();return}const Qe=ye.toString().trim();if(!Qe){Pe();return}const ct=Qe.length>Qv?Qe.slice(0,Qv).trimEnd():Qe;if(!ct){Pe();return}const it=Ie.getClientRects(),gt=it.length>0?it[0]:Ie.getBoundingClientRect(),yt=Ge.getBoundingClientRect(),nn=Math.max(gt.top-yt.top-40,8),Rn=Math.max(Ge.clientWidth-180,8),yr=Math.min(Math.max(gt.left-yt.left,8),Rn);Se({text:ct,top:nn,left:yr})}function pt(){nt()}function at(ye){const Ie=Ee();if(!(!Ie||!e.onQuoteSelection)&&(e.onQuoteSelection(Ie.text,ye),Pe(),typeof window<"u")){const Ge=window.getSelection();Ge==null||Ge.removeAllRanges()}}function mt(){e.loading||Ke()}function bt(){if(!q)return;N!==null&&cancelAnimationFrame(N);const ye=je();N=requestAnimationFrame(()=>{if(N=null,!q)return;const Ie=ie();ye&&(Ie?R()||D(!0):R()&&D(!1)),Pe(),Re()})}J(()=>{e.registerScrollToBottom&&e.registerScrollToBottom(()=>de(!0))});let Ze=!1;J(()=>{const ye=T();ye?(ge(),!Ze&&R()&&de(!0)):R()&&(ce=!0),Ze=ye}),J(()=>{if(!!e.loading){We=!0;return}if(!We)return;const Ie=I(),Ge=M();!Ie||!Ge||s().length===0||(We=!1,de(!0))});let Ve=[],tt=null,ut=0;J(()=>{const ye=!!e.loading,Ie=s();if(ye){Ve=[],tt=null,ut=0,m([]),p.clear(),E.clear();return}if(Ve.length===0&&Ie.length>0){f(),Ve=Ie.slice();return}if(Ie.length<Ve.length){f(),Ve=Ie.slice();return}if(Ie.length===Ve.length){let Qe=-1,ct=0;for(let it=0;it<Ie.length&&!(Ie[it]!==Ve[it]&&(Qe=it,ct+=1,ct>1));it++);if(ct===1&&Qe>=0){const it=Ve[Qe],gt=Ie[Qe];if(p.has(it)&&!p.has(gt)){p.delete(it),p.add(gt),m(yt=>{const nn=yt.map(Rn=>{if(Rn.messageId!==it)return Rn;const yr=Rn.id.replace(it,gt);return{...Rn,messageId:gt,id:yr}});return E.clear(),nn.forEach(Rn=>E.add(h(Rn))),nn}),Ve=Ie.slice();return}}}const Ge=[];Ie.forEach(Qe=>{p.has(Qe)||Ge.push(Qe)}),Ge.length>0&&Ge.forEach(Qe=>{p.add(Qe),b(Qe)}),Ve=Ie.slice()}),J(()=>{if(e.loading)return;const ye=s();if(ye.length===0)return;const Ie=ye[ye.length-1];if(!Ie)return;const Ge=i().getMessage(Ie);if(!Ge)return;const Qe=Ge.partIds.length;if(Ie===tt&&Qe===ut)return;tt=Ie,ut=Qe;const ct=dg(e.instanceId,Ge),it=[];ct.forEach(gt=>{const yt=h(gt);E.has(yt)||(E.add(yt),it.push(gt))}),it.length>0&&m(gt=>[...gt,...it])}),J(()=>{e.onQuoteSelection||Pe()}),J(()=>{if(typeof document>"u")return;const ye=()=>nt(),Ie=Ge=>{ae&&(ae.contains(Ge.target)||Pe())};document.addEventListener("selectionchange",ye),document.addEventListener("pointerdown",Ie),Ne(()=>{document.removeEventListener("selectionchange",ye),document.removeEventListener("pointerdown",Ie)})}),J(()=>{e.loading&&Pe()}),J(()=>{const ye=q,Ie=e.loading;!ye||Ie||he||(he=!0)});let Yt;return J(()=>{const ye=O();if(!(e.loading||!ye||ye===Yt)){if(Yt=ye,ue){ue=!1;return}R()&&Ke(!0)}}),J(()=>{if(c(),!(e.loading||!R())){if(ue){ue=!1;return}Ke(!0)}}),J(()=>{if(s().length===0){P(!1),le(!1),D(!0);return}ee()}),J(()=>{const ye=I(),Ie=A(),Ge=M();if(!ye||!Ie||!Ge)return;const Qe=new IntersectionObserver(ct=>{let it=!1;for(const gt of ct)gt.target===Ie?(Ae(gt.isIntersecting),it=!0):gt.target===Ge&&(re(gt.isIntersecting),it=!0);it&&ee()},{root:ye,threshold:0,rootMargin:`${Kv}px 0px ${Kv}px 0px`});Qe.observe(Ie),Qe.observe(Ge),Ne(()=>Qe.disconnect())}),J(()=>{const ye=I(),Ie=s();if(!ye||Ie.length===0||typeof document>"u")return;const Ge=new IntersectionObserver(Qe=>{let ct=null;for(const it of Qe)it.isIntersecting&&(!ct||it.boundingClientRect.top<ct.boundingClientRect.top)&&(ct=it);if(ct){const it=ct.target.id,gt=it.startsWith("message-anchor-")?it.slice(15):it;v(yt=>yt===gt?yt:gt)}},{root:ye,rootMargin:"-10% 0px -80% 0px",threshold:0});Ie.forEach(Qe=>{const ct=document.getElementById(Gf(Qe));ct&&Ge.observe(ct)}),Ne(()=>Ge.disconnect())}),Ne(()=>{N!==null&&cancelAnimationFrame(N),te!==null&&cancelAnimationFrame(te),H!==null&&cancelAnimationFrame(H),qe(),z&&z(),Pe()}),(()=>{var ye=JZ(),Ie=ye.firstChild,Ge=Ie.firstChild,Qe=Ge.firstChild,ct=Qe.firstChild,it=be;typeof it=="function"?wt(it,Ge):be=Ge,Qe.$$mouseup=pt,Qe.addEventListener("scroll",bt);var gt=Lt;return typeof gt=="function"?wt(gt,Qe):Lt=Qe,wt(V,ct),C(Qe,S(W,{get when(){return we(()=>!e.loading)()&&s().length===0},get children(){var yt=qZ(),nn=yt.firstChild,Rn=nn.firstChild,yr=Rn.firstChild,Rs=Rn.nextSibling,Lr=Rs.nextSibling,ar=Lr.nextSibling,mi=ar.firstChild;return mi.firstChild,Fe(yr,"src",iJ),C(mi,S(ir,{shortcut:"cmd+shift+p",class:"ml-2"}),null),yt}}),null),C(Qe,S(W,{get when(){return e.loading},get children(){return KZ()}}),null),C(Qe,S(DZ,{get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},store:i,messageIds:s,lastAssistantIndex:u,showThinking:()=>t().showThinkingBlocks,thinkingDefaultExpanded:()=>(t().thinkingBlocksExpansion??"expanded")==="expanded",showUsageMetrics:n,scrollContainer:I,get loading(){return e.loading},get onRevert(){return e.onRevert},get onFork(){return e.onFork},onContentRendered:mt,setBottomSentinel:L,suspendMeasurements:()=>!T()}),null),C(Ge,S(W,{get when(){return w()||j()},get children(){var yt=XZ();return C(yt,S(W,{get when(){return w()},get children(){var nn=QZ();return nn.$$click=()=>Ce(),nn}}),null),C(yt,S(W,{get when(){return j()},get children(){var nn=jZ();return nn.$$click=()=>He(!1,{suppressAutoAnchor:!1}),nn}}),null),yt}}),null),C(Ge,S(W,{get when(){return Ee()},children:yt=>(()=>{var nn=eJ(),Rn=nn.firstChild,yr=Rn.firstChild,Rs=yr.nextSibling;return yr.$$click=()=>at("quote"),Rs.$$click=()=>at("code"),ne(Lr=>{var ar=`${yt().top}px`,mi=`${yt().left}px`;return ar!==Lr.e&&Ci(nn,"top",Lr.e=ar),mi!==Lr.t&&Ci(nn,"left",Lr.t=mi),Lr},{e:void 0,t:void 0}),nn})()}),null),C(Ie,S(W,{get when(){return g()},get children(){var yt=ZZ();return C(yt,S(HZ,{get segments(){return _()},onSegmentClick:d,get activeMessageId(){return y()},get instanceId(){return e.instanceId},get sessionId(){return e.sessionId},get showToolSegments(){return r()}})),yt}}),null),ne(()=>rt(Ie,`message-layout${g()?" message-layout--with-timeline":""}`)),ye})()}Ht(["mouseup","click"]);var oJ=x("<span class=ml-2>"),aJ=x("<div class=dropdown-empty>No results found"),lJ=x("<div class=dropdown-section-header>COMMANDS"),cJ=x("<div class=dropdown-section-header>AGENTS"),dJ=x("<div class=dropdown-section-header>FILES"),uJ=x('<div class="dropdown-surface bottom-full left-0 mb-1 max-w-md"><div class=dropdown-header><div class=dropdown-header-title></div></div><div class="dropdown-content max-h-60"></div><div class=dropdown-footer><div><span class=font-medium>↑↓</span> navigate • <span class=font-medium>Tab/Enter</span> select • <span class=font-medium>Esc</span> close'),jv=x('<div class="mt-0.5 text-xs"style=color:var(--text-muted)>'),_J=x('<div><div class="flex items-start gap-2"><svg class="dropdown-icon-accent h-4 w-4 mt-0.5"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M4 6h16M4 12h16M4 18h16"></path></svg><div class=flex-1><div class="text-sm font-medium">/'),mJ=x("<span class=dropdown-badge>subagent"),gJ=x('<div><div class="flex items-start gap-2"><svg class="dropdown-icon-accent h-4 w-4 mt-0.5"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path></svg><div class=flex-1><div class="flex items-center gap-2"><span class="text-sm font-medium">'),fJ=x('<svg class="dropdown-icon-accent h-4 w-4"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z">'),pJ=x('<div><div class="flex items-center gap-2 text-sm"><span class=truncate>'),hJ=x('<svg class="dropdown-icon h-4 w-4"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z">');const Xv=vt("actions"),EJ=100,SJ=200;function bJ(e,t){if(!t)return e;const n=e.replace(/\/+$/,"");return n.length>0?`${n}/`:"./"}function vJ(e){return e==="."||e==="./"||e==="/"}function yJ(e,t){if(vJ(e))return".";const n=e.replace(/^\.\/+/,"");return t?n.replace(/\/+$/,"")||".":n}function _g(e){const t=e.trim();return!t||t==="."||t==="./"?"":t.replace(/^(\.\/)+/,"").replace(/^\/+/,"")}function Zv(e){return e.map(t=>{const n=t.type==="directory";return{path:bJ(t.path,n),relativePath:yJ(t.path,n),isDirectory:n,isGitFile:!1}})}const TJ=e=>{const t=()=>e.mode??"mention",[n,r]=U([]),[i,s]=U([]),[o,a]=U(0),[l,c]=U("idle"),[d,u]=U([]),[_,m]=U(!1),[g,p]=U(null);let E,h,f=null,b="",y=null,v=null,O=0,T=null;function I(){setTimeout(()=>{h&&(h.scrollTop=0)},0)}function k(q){r(q),a(0),I()}async function A(q){return y===q&&v||(y=q,v=vn.listWorkspaceFiles(q).then(ae=>Zv(ae)).then(ae=>(u(ae),p(q),ae)).catch(ae=>{throw Xv.error("[UnifiedPicker] Failed to load workspace files:",ae),u([]),p(null),ae}).finally(()=>{y===q&&(y=null,v=null)})),v}async function V(q){return g()===q&&d().length>0?d():A(q)}async function B(q,ae){const N=_g(q),H=++O,te=!N&&g()===ae&&d().length>0,Q=N?"search":te?"idle":"listing";c(Q!=="idle"?Q:"idle");try{if(!N){const he=await V(ae);if(!L(H,ae))return;k(he);return}const z=await vn.searchWorkspaceFiles(ae,N,{limit:EJ});if(!L(H,ae))return;k(Zv(z))}catch(z){ae===e.workspaceId&&(Xv.error("[UnifiedPicker] Failed to fetch files:",z),L(H,ae)&&k([]))}finally{R(H,ae)&&c("idle")}}function $(){T&&(clearTimeout(T),T=null)}function M(q,ae,N=!1){$();const H=_g(q);if(!N&&H.length>0){T=setTimeout(()=>{T=null,B(q,ae)},SJ);return}B(q,ae)}function L(q,ae){return e.open&&ae===e.workspaceId&&q===O}function R(q,ae){return ae===e.workspaceId&&q===O}function D(){$(),r([]),u([]),p(null),m(!1),a(0),c("idle"),f=null,b="",O=0}Ne(()=>{$()}),J(()=>{if(!e.open){D();return}if(t()!=="mention")return;const q=f!==e.workspaceId,ae=b!==e.searchQuery;if(!_()||q||ae){m(!0),f=e.workspaceId,b=e.searchQuery;const N=q||_g(e.searchQuery).length===0;M(e.searchQuery,e.workspaceId,N)}}),J(()=>{if(!e.open||t()!=="mention")return;const q=e.searchQuery.toLowerCase(),ae=q?e.agents.filter(N=>N.name.toLowerCase().includes(q)||N.description&&N.description.toLowerCase().includes(q)):e.agents;s(ae)});const w=F(()=>{if(t()!=="command")return[];const q=e.searchQuery.trim().toLowerCase(),ae=e.commands??[];return q?ae.filter(N=>{const H=N.name.toLowerCase().includes(q),te=(N.description??"").toLowerCase().includes(q);return H||te}):ae}),P=()=>{const q=[];return t()==="command"?(w().forEach(ae=>q.push({type:"command",command:ae})),q):(i().forEach(ae=>q.push({type:"agent",agent:ae})),n().forEach(ae=>q.push({type:"file",file:ae})),q)};function j(){setTimeout(()=>{const q=E==null?void 0:E.querySelector('[data-picker-selected="true"]');q&&q.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}function le(q){e.onSelect(q)}function me(q){if(!e.open)return;const ae=P();if(q.key==="ArrowDown")q.preventDefault(),a(N=>Math.min(N+1,ae.length-1)),j();else if(q.key==="ArrowUp")q.preventDefault(),a(N=>Math.max(N-1,0)),j();else if(q.key==="Enter"||q.key==="Tab"){q.preventDefault();const N=ae[o()];N&&le(N)}else q.key==="Escape"&&(q.preventDefault(),e.onClose())}J(()=>{e.open&&(document.addEventListener("keydown",me),Ne(()=>{document.removeEventListener("keydown",me)}))});const Ae=()=>w().length,ie=()=>i().length,re=()=>n().length,Ee=()=>t()==="mention"&&l()!=="idle",Se=()=>l()==="search"?"Searching...":l()==="listing"?"Loading workspace...":"";return S(W,{get when(){return e.open},get children(){var q=uJ(),ae=q.firstChild,N=ae.firstChild,H=ae.nextSibling,te=E;typeof te=="function"?wt(te,q):E=q,C(N,S(W,{get when(){return t()==="command"},fallback:"Select Agent or File",children:"Select Command"}),null),C(N,S(W,{get when(){return Ee()},get children(){var z=oJ();return C(z,Se),z}}),null);var Q=h;return typeof Q=="function"?wt(Q,H):h=H,C(H,S(W,{get when(){return we(()=>t()==="command")()?Ae()===0:we(()=>ie()===0)()&&re()===0},get children(){return aJ()}}),null),C(H,S(W,{get when(){return we(()=>t()==="command")()&&Ae()>0},get children(){return[lJ(),S(_t,{get each(){return w()},children:z=>{const he=P().findIndex(ue=>ue.type==="command"&&ue.command.name===z.name);return(()=>{var ue=_J(),ce=ue.firstChild,se=ce.firstChild,ke=se.nextSibling,We=ke.firstChild;return We.firstChild,ue.$$click=()=>le({type:"command",command:z}),C(We,()=>z.name,null),C(ke,S(W,{get when(){return z.description},get children(){var Oe=jv();return C(Oe,(()=>{var je=we(()=>(z.description??"").length>80);return()=>je()?(z.description??"").slice(0,80)+"...":z.description})()),Oe}}),null),ne(Oe=>{var je=`dropdown-item ${he===o()?"dropdown-item-highlight":""}`,dt=he===o();return je!==Oe.e&&rt(ue,Oe.e=je),dt!==Oe.t&&Fe(ue,"data-picker-selected",Oe.t=dt),Oe},{e:void 0,t:void 0}),ue})()}})]}}),null),C(H,S(W,{get when(){return we(()=>t()==="mention")()&&ie()>0},get children(){return[cJ(),S(_t,{get each(){return i()},children:z=>{const he=P().findIndex(ue=>ue.type==="agent"&&ue.agent.name===z.name);return(()=>{var ue=gJ(),ce=ue.firstChild,se=ce.firstChild,ke=se.nextSibling,We=ke.firstChild,Oe=We.firstChild;return ue.$$click=()=>le({type:"agent",agent:z}),C(Oe,()=>z.name),C(We,S(W,{get when(){return z.mode==="subagent"},get children(){return mJ()}}),null),C(ke,S(W,{get when(){return z.description},get children(){var je=jv();return C(je,(()=>{var dt=we(()=>!!(z.description&&z.description.length>80));return()=>dt()?z.description.slice(0,80)+"...":z.description})()),je}}),null),ne(je=>{var dt=`dropdown-item ${he===o()?"dropdown-item-highlight":""}`,Lt=he===o();return dt!==je.e&&rt(ue,je.e=dt),Lt!==je.t&&Fe(ue,"data-picker-selected",je.t=Lt),je},{e:void 0,t:void 0}),ue})()}})]}}),null),C(H,S(W,{get when(){return we(()=>t()==="mention")()&&re()>0},get children(){return[dJ(),S(_t,{get each(){return n()},children:z=>{const he=P().findIndex(ce=>ce.type==="file"&&ce.file.relativePath===z.relativePath),ue=z.isDirectory;return(()=>{var ce=pJ(),se=ce.firstChild,ke=se.firstChild;return ce.$$click=()=>le({type:"file",file:z}),C(se,S(W,{when:ue,get fallback(){return hJ()},get children(){return fJ()}}),ke),C(ke,()=>z.path),ne(We=>{var Oe=`dropdown-item py-1.5 ${he===o()?"dropdown-item-highlight":""}`,je=he===o();return Oe!==We.e&&rt(ce,We.e=Oe),je!==We.t&&Fe(ce,"data-picker-selected",We.t=je),We},{e:void 0,t:void 0}),ce})()}})]}}),null),q}})};Ht(["click"]);var CJ=x('<button type=button class=prompt-expand-button aria-label="Toggle chat input height">');function RJ(e){function t(){const n=e.expandState();e.onToggleExpand(n==="normal"?"expanded":"normal")}return(()=>{var n=CJ();return n.$$click=t,C(n,S(W,{get when(){return e.expandState()==="normal"},get fallback(){return S(i0,{class:"h-4 w-4","aria-hidden":"true"})},get children(){return S(n0,{class:"h-4 w-4","aria-hidden":"true"})}})),n})()}Ht(["click"]);const Jv=100;async function IJ(e,t){!e||!t||(await Bo(e),await up(e,n=>{const r=[t,...n.messageHistory??[]];r.length>Jv&&(r.length=Jv),n.messageHistory=r}))}async function OJ(e){return e?(await Bo(e),[..._p(e).messageHistory??[]]):[]}const[NJ,sE]=U(new Map);function tm(e,t){return`${e}:${t}`}function Vf(e,t){const n=tm(e,t);return NJ().get(n)||[]}function Pl(e,t,n){const r=tm(e,t);sE(i=>{const s=new Map(i),o=s.get(r)||[];return s.set(r,[...o,n]),s})}function Ec(e,t,n){const r=tm(e,t);sE(i=>{const s=new Map(i),o=s.get(r)||[];return s.set(r,o.filter(a=>a.id!==n)),s})}function AJ(e,t){const n=tm(e,t);sE(r=>{const i=new Map(r);return i.delete(n),i})}function oE(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function mg(e,t,n="text/plain",r,i){let s=e;return i&&!e.startsWith("file://")?s=`file://${e.startsWith("/")?e:`${i}/${e}`}`:!e.startsWith("file://")&&e.startsWith("/")&&(s=`file://${e}`),{id:oE(),type:"file",display:`@${t}`,url:s,filename:t,mediaType:n,source:{type:"file",path:e,mime:n,data:r}}}function wJ(e,t,n){const r=xJ(e);return{id:oE(),type:"text",display:t,url:`data:text/plain;base64,${r}`,filename:n,mediaType:"text/plain",source:{type:"text",value:e}}}function xJ(e){if(typeof TextEncoder<"u"){const n=new TextEncoder().encode(e);let r="";const i=32768;for(let s=0;s<n.length;s+=i){const o=n.subarray(s,Math.min(s+i,n.length));r+=String.fromCharCode(...o)}return btoa(r)}return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(Number.parseInt(n,16))))}function DJ(e){return{id:oE(),type:"agent",display:`@${e}`,url:"",filename:e,mediaType:"text/plain",source:{type:"agent",name:e}}}var LJ=x('<button type=button class=prompt-history-button aria-label="Previous prompt">'),kJ=x('<button type=button class=prompt-history-button aria-label="Next prompt">'),MJ=x('<span class="prompt-overlay-text prompt-overlay-warning">Press <!> again to abort session'),ey=x("<span class=prompt-overlay-shell-active>Shell mode active"),PJ=x("<div>"),$J=x('<svg class=shell-icon viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><path stroke-linecap=round stroke-linejoin=round d="M5 8l5 4-5 4"></path><path stroke-linecap=round stroke-linejoin=round d="M13 16h6">'),FJ=x('<div class=prompt-input-container><div><div class="flex flex-1 flex-col"><div><div><textarea autocorrect=off autocapitalize=off autocomplete=off></textarea><div class=prompt-nav-buttons></div></div></div></div><div class=prompt-input-actions><button type=button class=stop-button aria-label="Stop session"title="Stop session"><svg class=stop-icon viewBox="0 0 20 20"fill=currentColor aria-hidden=true><rect x=4 y=4 width=12 height=12 rx=2></rect></svg></button><button type=button aria-label="Send message">'),BJ=x("<span class=prompt-overlay-text> New line • <!> Send • <!> Files/agents • <!> History"),UJ=x('<span class="prompt-overlay-text prompt-overlay-muted">• <!> file(s) attached'),ty=x("<span class=prompt-overlay-text>• <!> "),GJ=x("<span class=send-icon>▶");const ny=vt("actions");function VJ(e){const[t,n]=U(""),[r,i]=U([]),s=100,[o,a]=U(-1),[l,c]=U(null),[,d]=U(!1),[u,_]=U(!1),[m,g]=U("mention"),[p,E]=U(""),[h,f]=U(null),[b,y]=U(!1),[v,O]=U(new Set),[T,I]=U(0),[k,A]=U(0),[V,B]=U("normal"),[$,M]=U("normal"),L=2e3;let R;const D=()=>V()==="shell"?"Run a shell command (Esc to exit)...":"Type your message, @file, @agent, or paste images and text...",w=()=>Vf(e.instanceId,e.sessionId),P=()=>A_().get(e.instanceId)||[];J(()=>{if(!e.registerQuoteHandler)return;const de=e.registerQuoteHandler((ge,Ce)=>{Ce==="code"?We(ge):ke(ge)});Ne(()=>{typeof de=="function"&&de()})});const j=de=>{n(de),wm(e.instanceId,e.sessionId,de)},le=()=>{NR(e.instanceId,e.sessionId),n(""),c(null),B("normal")};function me(de,ge){let Ce=0,Ke=0;for(const Pe of de.matchAll(/\[pasted #(\d+)\]/g)){const Be=Number.parseInt(Pe[1],10);Number.isNaN(Be)||(Ce=Math.max(Ce,Be))}for(const Pe of ge){if(Pe.source.type==="text"){const Be=Pe.display.match(/pasted #(\d+)/);if(Be){const nt=Number.parseInt(Be[1],10);Number.isNaN(nt)||(Ce=Math.max(Ce,nt))}}if(Pe.source.type==="file"&&Pe.mediaType.startsWith("image/")){const Be=Pe.display.match(/Image #(\d+)/);if(Be){const nt=Number.parseInt(Be[1],10);Number.isNaN(nt)||(Ke=Math.max(Ke,nt))}}}for(const Pe of de.matchAll(/\[Image #(\d+)\]/g)){const Be=Number.parseInt(Pe[1],10);Number.isNaN(Be)||(Ke=Math.max(Ke,Be))}I(Ce),A(Ke)}J(qr(()=>`${e.instanceId}:${e.sessionId}`,()=>{const de=e.instanceId,ge=e.sessionId;Ne(()=>{wm(de,ge,t())});const Ce=LU(de,ge),Ke=Wr(()=>Vf(de,ge));n(Ce),wm(de,ge,Ce),a(-1),c(null),O(new Set),_(!1),f(null),E(""),me(Ce,Ke)}));async function Ae(de){var nt,pt;const ge=(nt=de.clipboardData)==null?void 0:nt.items;if(!ge)return;for(let at=0;at<ge.length;at++){const mt=ge[at];if(mt.type.startsWith("image/")){de.preventDefault();const bt=mt.getAsFile();if(!bt)continue;const Ze=k()+1;A(Ze);const Ve=new FileReader;Ve.onload=()=>{const tt=Ve.result.split(",")[1],ut=`[Image #${Ze}]`,Yt=`image-${Ze}.png`,ye=mg(Yt,Yt,"image/png",new TextEncoder().encode(tt),e.instanceFolder);ye.url=`data:image/png;base64,${tt}`,ye.display=ut,Pl(e.instanceId,e.sessionId,ye);const Ie=R;if(Ie){const Ge=Ie.selectionStart,Qe=Ie.selectionEnd,ct=t(),it=`[Image #${Ze}]`,gt=ct.substring(0,Ge)+it+ct.substring(Qe);j(gt),setTimeout(()=>{const yt=Ge+it.length;Ie.setSelectionRange(yt,yt),Ie.focus()},0)}},Ve.readAsDataURL(bt);return}}const Ce=(pt=de.clipboardData)==null?void 0:pt.getData("text/plain");if(!Ce)return;const Ke=Ce.split(`
169
+ `).length,Pe=Ce.length;if(Pe>150||Ke>3){de.preventDefault();const at=T()+1;I(at);const mt=Ke>1?`${Ke} lines`:`${Pe} chars`,bt=`pasted #${at} (${mt})`,Ze=`paste-${at}.txt`,Ve=wJ(Ce,bt,Ze);Pl(e.instanceId,e.sessionId,Ve);const tt=R;if(tt){const ut=tt.selectionStart,Yt=tt.selectionEnd,ye=t(),Ie=`[pasted #${at}]`,Ge=ye.substring(0,ut)+Ie+ye.substring(Yt);j(Ge),setTimeout(()=>{const Qe=ut+Ie.length;tt.setSelectionRange(Qe,Qe),tt.focus()},0)}}}Tn(()=>{const de=ge=>{const Ce=document.activeElement;(Ce==null?void 0:Ce.tagName)==="INPUT"||(Ce==null?void 0:Ce.tagName)==="TEXTAREA"||(Ce==null?void 0:Ce.tagName)==="SELECT"||Ce!=null&&Ce.isContentEditable||ge.ctrlKey||ge.metaKey||ge.altKey||ge.key==="Tab"||ge.key==="Enter"||ge.key.startsWith("Arrow")||ge.key==="Backspace"||ge.key==="Delete"||ge.key.length===1&&R&&!e.disabled&&R.focus()};document.addEventListener("keydown",de),Ne(()=>{document.removeEventListener("keydown",de)}),(async()=>{const ge=await OJ(e.instanceFolder);i(ge)})()});function ie(de){const ge=R;if(!ge)return;const Ce=t(),Ke=ge.selectionStart===0&&ge.selectionEnd===0,Pe=V()==="shell";if(!Pe&&de.key==="!"&&Ke&&Ce.length===0&&!e.disabled){de.preventDefault(),B("shell");return}if(u()&&de.key==="Escape"){de.preventDefault(),de.stopPropagation(),z();return}if(Pe){if(de.key==="Escape"){de.preventDefault(),de.stopPropagation(),B("normal");return}if(de.key==="Backspace"&&Ke&&Ce.length===0){de.preventDefault(),B("normal");return}}if(de.key==="Backspace"||de.key==="Delete"){const Be=ge.selectionStart,nt=Ce,pt=/\[pasted #(\d+)\]/g;let at;for(;(at=pt.exec(nt))!==null;){const tt=at.index,ut=at.index+at[0].length,Yt=at[1],ye=de.key==="Backspace"&&Be===ut,Ie=de.key==="Delete"&&Be===tt,Ge=ge.selectionStart<=tt&&ge.selectionEnd>=ut&&ge.selectionStart!==ge.selectionEnd;if(ye||Ie||Ge){de.preventDefault();const ct=w().find(gt=>gt.source.type==="text"&&gt.display.includes(`pasted #${Yt}`));ct&&Ec(e.instanceId,e.sessionId,ct.id);const it=nt.substring(0,tt)+nt.substring(ut);j(it),setTimeout(()=>{ge.setSelectionRange(tt,tt)},0);return}}const mt=/\[Image #(\d+)\]/g;let bt;for(;(bt=mt.exec(nt))!==null;){const tt=bt.index,ut=bt.index+bt[0].length,Yt=bt[1],ye=de.key==="Backspace"&&Be===ut,Ie=de.key==="Delete"&&Be===tt,Ge=ge.selectionStart<=tt&&ge.selectionEnd>=ut&&ge.selectionStart!==ge.selectionEnd;if(ye||Ie||Ge){de.preventDefault();const ct=w().find(gt=>gt.source.type==="file"&&gt.mediaType.startsWith("image/")&&gt.display.includes(`Image #${Yt}`));ct&&Ec(e.instanceId,e.sessionId,ct.id);const it=nt.substring(0,tt)+nt.substring(ut);j(it),setTimeout(()=>{ge.setSelectionRange(tt,tt)},0);return}}const Ze=/@(\S+)/g;let Ve;for(;(Ve=Ze.exec(nt))!==null;){const tt=Ve.index,ut=Ve.index+Ve[0].length,Yt=Ve[1],ye=de.key==="Backspace"&&Be===ut,Ie=de.key==="Delete"&&Be===tt,Ge=ge.selectionStart<=tt&&ge.selectionEnd>=ut&&ge.selectionStart!==ge.selectionEnd;if(ye||Ie||Ge){const ct=w().find(it=>(it.source.type==="file"||it.source.type==="agent")&&it.filename===Yt);if(ct){de.preventDefault(),Ec(e.instanceId,e.sessionId,ct.id),O(gt=>{const yt=new Set(gt);return yt.delete(tt),yt});const it=nt.substring(0,tt)+nt.substring(ut);j(it),setTimeout(()=>{ge.setSelectionRange(tt,tt)},0);return}}}}if(de.key==="Enter"&&(de.metaKey||de.ctrlKey)){de.preventDefault(),u()&&z(),re();return}if(de.key==="ArrowUp"&&q()){de.preventDefault();return}if(de.key==="ArrowDown"&&ae()){de.preventDefault();return}}async function re(){const de=t().trim(),ge=w();if(e.disabled||!de&&ge.length===0)return;const Ce=V()==="shell",Ke=!Ce&&de.startsWith("/"),Pe=Ke?de.indexOf(" "):-1,Be=Ke?Pe===-1?de:de.slice(0,Pe):"",nt=Ke?Be.slice(1):"",pt=Ke?Pe===-1?"":de.slice(Pe+1).trimStart():"",at=Ke&&nt.length>0&&YS(e.instanceId).some(Ve=>Ve.name===nt),mt=at?de:PT(de,ge),bt=mt,Ze=async()=>{try{await IJ(e.instanceFolder,bt),i(Ve=>{const tt=[bt,...Ve];return tt.length>s&&(tt.length=s),tt}),a(-1)}catch(Ve){ny.error("Failed to update prompt history:",Ve)}};M("normal"),le(),at?(me("",ge),O(new Set)):(AJ(e.instanceId,e.sessionId),I(0),A(0),O(new Set)),c(null),at&&Ze();try{Ce?e.onRunShell?await e.onRunShell(mt):await e.onSend(mt,[]):at?await JM(e.instanceId,e.sessionId,nt,pt):await e.onSend(mt,ge),at||Ze()}catch(Ve){ny.error("Failed to send message:",Ve),Gs("Failed to send message",{title:"Send failed",detail:Ve instanceof Error?Ve.message:String(Ve),variant:"error"})}finally{R==null||R.focus()}}function Ee(){R&&setTimeout(()=>{if(!R)return;const de=R.value.length;R.setSelectionRange(de,de),R.focus()},0)}function Se(de=!1){if(de)return!0;if(u())return!1;const ge=R;return ge?ge.selectionStart===0&&ge.selectionEnd===0:!1}function q(de=!1){const ge=r();if(ge.length===0||!Se(de))return!1;o()===-1&&c(t());const Ce=o()===-1?0:Math.min(o()+1,ge.length-1);return a(Ce),j(ge[Ce]),Ee(),!0}function ae(de=!1){const ge=r();if(ge.length===0||!Se(de)||o()===-1)return!1;const Ce=o()-1;if(Ce>=0)a(Ce),j(ge[Ce]);else{a(-1);const Ke=l();j(Ke??""),c(null)}return Ee(),!0}function N(){!e.onAbortSession||!e.isSessionBusy||e.onAbortSession()}function H(de){M(de),R==null||R.focus()}function te(de){const ge=de.target,Ce=ge.value;j(Ce),a(-1),c(null);const Ke=ge.selectionStart;if(Ce.startsWith("/")&&Ke>=1){const pt=Ce.slice(1).search(/\s/),at=pt===-1?Ce.length:pt+1;if(Ke<=at){g("command"),f(0),E(Ce.substring(1,Ke)),_(!0);return}}const Be=Ce.substring(0,Ke).lastIndexOf("@"),nt=h();if(Be===-1?O(new Set):nt!==null&&Be!==nt&&O(pt=>{const at=new Set(pt);return at.delete(nt),at}),Be!==-1){const pt=Ce.substring(Be+1,Ke);if(!(pt.includes(" ")||pt.includes(`
170
+ `))&&Ke===Be+pt.length+1){v().has(Be)||(g("mention"),f(Be),E(pt),_(!0));return}}_(!1),f(null)}function Q(de){if(de.type==="command"){const ge=de.command.name,Ce=t(),Pe=Ce.slice(1).search(/\s/),Be=Pe===-1?Ce.length:Pe+1,nt="",pt=Ce.substring(Be),at=nt+`/${ge} `+pt;j(at),setTimeout(()=>{if(R){const mt=`/${ge} `.length;R.setSelectionRange(mt,mt),R.focus()}},0)}else if(de.type==="agent"){const ge=de.agent.name;if(!w().some(pt=>pt.source.type==="agent"&&pt.source.name===ge)){const pt=DJ(ge);Pl(e.instanceId,e.sessionId,pt)}const Pe=t(),Be=h(),nt=(R==null?void 0:R.selectionStart)||0;if(Be!==null){const pt=Pe.substring(0,Be),at=Pe.substring(nt),mt=`@${ge}`,bt=pt+mt+" "+at;j(bt),setTimeout(()=>{if(R){const Ze=Be+mt.length+1;R.setSelectionRange(Ze,Ze)}},0)}}else if(de.type==="file"){const ge=de.file.path,Ce=de.file.relativePath??ge;if(de.file.isDirectory??ge.endsWith("/")){const Ve=t(),tt=h(),ut=(R==null?void 0:R.selectionStart)||0,Yt=Ce==="."||Ce===""?"/":Ce.replace(/\/+$/,"")+"/";if(tt!==null){const ye=Ve.substring(0,tt+1),Ie=Ve.substring(ut),Ge=ye+Yt+Ie;j(Ge),E(Yt),setTimeout(()=>{if(R){const Qe=tt+1+Yt.length;R.setSelectionRange(Qe,Qe)}},0)}return}const Pe=Ce.replace(/\/+$/,"")||Ce,Be=Pe.split("/"),nt=(()=>{const Ve=Be[Be.length-1]||Pe;return Ve==="."?"/":Ve})();if(!w().some(Ve=>Ve.source.type==="file"&&Ve.source.path===Pe)){const Ve=mg(Pe,nt,"text/plain",void 0,e.instanceFolder);Pl(e.instanceId,e.sessionId,Ve)}const mt=t(),bt=h(),Ze=(R==null?void 0:R.selectionStart)||0;if(bt!==null){const Ve=mt.substring(0,bt),tt=mt.substring(Ze),ut=`@${Pe}`,Yt=Ve+ut+" "+tt;j(Yt),setTimeout(()=>{if(R){const ye=bt+ut.length+1;R.setSelectionRange(ye,ye)}},0)}}_(!1),f(null),E(""),R==null||R.focus()}function z(){const de=h();m()==="mention"&&de!==null&&O(ge=>new Set(ge).add(de)),_(!1),f(null),E(""),setTimeout(()=>R==null?void 0:R.focus(),0)}function he(de){de.preventDefault(),de.stopPropagation(),y(!0)}function ue(de){de.preventDefault(),de.stopPropagation(),y(!1)}function ce(de){var Ce;de.preventDefault(),de.stopPropagation(),y(!1);const ge=(Ce=de.dataTransfer)==null?void 0:Ce.files;if(!(!ge||ge.length===0)){for(let Ke=0;Ke<ge.length;Ke++){const Pe=ge[Ke],Be=Pe.path||Pe.name,nt=Pe.name,pt=Pe.type||"text/plain",at=mt=>{const bt=mg(Be,nt,pt,void 0,e.instanceFolder);mt&&(pt.startsWith("image/")||pt.startsWith("text/"))&&(bt.url=mt),Pl(e.instanceId,e.sessionId,bt)};if(pt.startsWith("image/")&&typeof FileReader<"u"){const mt=new FileReader;mt.onload=()=>{const bt=typeof mt.result=="string"?mt.result:void 0;at(bt)},mt.readAsDataURL(Pe)}else if(pt.startsWith("text/")&&typeof FileReader<"u"){const mt=new FileReader;mt.onload=()=>{const bt=typeof mt.result=="string"?mt.result:void 0;at(bt)},mt.readAsDataURL(Pe)}else at()}R==null||R.focus()}}function se(de){const ge=R,Ce=t(),Ke=ge?ge.selectionStart:Ce.length,Pe=ge?ge.selectionEnd:Ce.length,Be=Ce.substring(0,Ke),nt=Ce.substring(Pe),at=`${Be.length>0&&!Be.endsWith(`
171
171
  `)?`
172
- `:""}${de}`,mt=Be+at+tt;j(mt),a(-1),c(null),_(!1),f(null),ge&&setTimeout(()=>{const bt=Be.length+at.length;ge.focus(),ge.setSelectionRange(bt,bt)},0)}function ke(de){const ge=(de??"").replace(/\r/g,"").trim();if(!ge)return;const Ke=(ge.length>L?ge.slice(0,L).trimEnd():ge).split(/\n/).map(Be=>Be.trim()).filter(Be=>Be.length>0);if(Ke.length===0)return;const $e=Ke.map(Be=>`> ${Be}`).join(`
173
- `);$e&&se(`${$e}
172
+ `:""}${de}`,mt=Be+at+nt;j(mt),a(-1),c(null),_(!1),f(null),ge&&setTimeout(()=>{const bt=Be.length+at.length;ge.focus(),ge.setSelectionRange(bt,bt)},0)}function ke(de){const ge=(de??"").replace(/\r/g,"").trim();if(!ge)return;const Ke=(ge.length>L?ge.slice(0,L).trimEnd():ge).split(/\n/).map(Be=>Be.trim()).filter(Be=>Be.length>0);if(Ke.length===0)return;const Pe=Ke.map(Be=>`> ${Be}`).join(`
173
+ `);Pe&&se(`${Pe}
174
174
 
175
- `)}function We(de){const ge=(de??"").replace(/\r/g,""),Ke=(ge.length>L?ge.slice(0,L):ge).replace(/^\n+/,"").replace(/\n+$/,"");if(!Ke)return;const $e="```\n"+Ke+"\n```\n\n";se($e)}const Oe=()=>!!(e.isSessionBusy&&e.onAbortSession),je=()=>r().length>0,dt=()=>je()&&(o()===-1||o()<r().length-1),Lt=()=>o()>=0,be=()=>{if(e.disabled)return!1;const de=t().trim().length>0;return V()==="shell"?de:de||w().length>0},ee=()=>V()==="shell"?{key:"Esc",text:"to exit shell mode"}:{key:"!",text:"Shell mode"},Re=()=>({key:"/",text:"Commands"}),He=()=>t().length===0,qe=()=>hR();return(()=>{var de=FJ(),ge=de.firstChild,Ce=ge.firstChild,Ke=Ce.firstChild,$e=Ke.firstChild,Be=$e.firstChild,tt=Be.nextSibling,pt=Ce.nextSibling,at=pt.firstChild,mt=at.nextSibling;ge.addEventListener("drop",ce),ge.addEventListener("dragleave",ue),ge.addEventListener("dragover",he),C(ge,S(W,{get when(){return we(()=>!!u())()&&qe()},get children(){return S(TJ,{get open(){return u()},get mode(){return m()},onClose:z,onSelect:Q,get agents(){return P()},get commands(){return YS(e.instanceId)},get instanceClient(){return qe().client},get searchQuery(){return p()},textareaRef:R,get workspaceId(){return e.instanceId}})}}),Ce),Be.addEventListener("blur",()=>d(!1)),Be.addEventListener("focus",()=>d(!0)),Be.addEventListener("paste",Ae),Be.$$keydown=ie,Be.$$input=te;var bt=R;return typeof bt=="function"?wt(bt,Be):R=Be,Fe(Be,"spellcheck",!1),C(tt,S(RJ,{expandState:$,onToggleExpand:H}),null),C(tt,S(W,{get when(){return je()},get children(){return[(()=>{var Ze=LJ();return Ze.$$click=()=>q(!0),C(Ze,S(ID,{class:"h-5 w-5","aria-hidden":"true"})),ne(()=>Ze.disabled=!dt()),Ze})(),(()=>{var Ze=kJ();return Ze.$$click=()=>ae(!0),C(Ze,S(CD,{class:"h-5 w-5","aria-hidden":"true"})),ne(()=>Ze.disabled=!Lt()),Ze})()]}}),null),C($e,S(W,{get when(){return He()},get children(){var Ze=PJ();return C(Ze,S(W,{get when(){return e.escapeInDebounce},get fallback(){return[(()=>{var Ve=BJ(),nt=Ve.firstChild,ut=nt.nextSibling,Yt=ut.nextSibling,ye=Yt.nextSibling,Ie=ye.nextSibling,Ge=Ie.nextSibling;return Ge.nextSibling,C(Ve,S(ir,{children:"Enter"}),nt),C(Ve,S(ir,{shortcut:"cmd+enter"}),ut),C(Ve,S(ir,{children:"@"}),ye),C(Ve,S(ir,{children:"↑↓"}),Ge),Ve})(),S(W,{get when(){return w().length>0},get children(){var Ve=UJ(),nt=Ve.firstChild,ut=nt.nextSibling;return ut.nextSibling,C(Ve,()=>w().length,ut),Ve}}),(()=>{var Ve=ty(),nt=Ve.firstChild,ut=nt.nextSibling;return ut.nextSibling,C(Ve,S(ir,{get children(){return ee().key}}),ut),C(Ve,()=>ee().text,null),Ve})(),S(W,{get when(){return V()!=="shell"},get children(){var Ve=ty(),nt=Ve.firstChild,ut=nt.nextSibling;return ut.nextSibling,C(Ve,S(ir,{get children(){return Re().key}}),ut),C(Ve,()=>Re().text,null),Ve}}),S(W,{get when(){return V()==="shell"},get children(){return ey()}})]},get children(){return[(()=>{var Ve=MJ(),nt=Ve.firstChild,ut=nt.nextSibling;return ut.nextSibling,C(Ve,S(ir,{children:"Esc"}),ut),Ve})(),S(W,{get when(){return V()==="shell"},get children(){return ey()}})]}})),ne(()=>rt(Ze,`prompt-input-overlay ${V()==="shell"?"shell-mode":""}`)),Ze}}),null),at.$$click=N,mt.$$click=re,C(mt,S(W,{get when(){return V()==="shell"},get fallback(){return GJ()},get children(){return $J()}})),ne(Ze=>{var Ve=`prompt-input-wrapper relative ${b()?"border-2":""}`,nt=b()?"border-color: var(--accent-primary); background-color: rgba(0, 102, 255, 0.05);":"",ut=`prompt-input-field-container ${$()==="expanded"?"is-expanded":""}`,Yt=`prompt-input-field ${$()==="expanded"?"is-expanded":""}`,ye=`prompt-input ${V()==="shell"?"shell-mode":""} ${$()==="expanded"?"is-expanded":""}`,Ie=D(),Ge=e.disabled,Qe=$()==="expanded"?15:4,ct=!Oe(),it=`send-button ${V()==="shell"?"shell-mode":""}`,gt=!be();return Ve!==Ze.e&&rt(ge,Ze.e=Ve),Ze.t=ri(ge,nt,Ze.t),ut!==Ze.a&&rt(Ke,Ze.a=ut),Yt!==Ze.o&&rt($e,Ze.o=Yt),ye!==Ze.i&&rt(Be,Ze.i=ye),Ie!==Ze.n&&Fe(Be,"placeholder",Ze.n=Ie),Ge!==Ze.s&&(Be.disabled=Ze.s=Ge),Qe!==Ze.h&&Fe(Be,"rows",Ze.h=Qe),ct!==Ze.r&&(at.disabled=Ze.r=ct),it!==Ze.d&&rt(mt,Ze.d=it),gt!==Ze.l&&(mt.disabled=Ze.l=gt),Ze},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0}),ne(()=>Be.value=t()),de})()}Ht(["input","keydown","click"]);var HJ=x('<div class="flex items-center justify-center h-full"><div class="text-center text-gray-500">Session not found'),YJ=x('<div class="flex flex-wrap items-center gap-1.5 border-t px-3 py-2"style=border-color:var(--border-base)>'),zJ=x("<div class=session-view>"),WJ=x('<button type=button class=attachment-expand aria-label="Expand pasted text"title="Insert pasted text">'),qJ=x('<div class=attachment-chip><span class=font-mono></span><button type=button class=attachment-remove aria-label="Remove attachment">×');const lo=vt("session");function KJ(e){return(e==null?void 0:e.type)==="text"&&typeof e.text=="string"}const QJ=e=>{const t=()=>e.activeSessions.get(e.sessionId),n=F(()=>HU(e.instanceId,e.sessionId)),r=F(()=>Ut.getOrCreate(e.instanceId)),i=F(()=>{const y=t();return y?qU(e.instanceId,y.id):!1}),s=F(()=>{const y=t();return y?!!(y.pendingPermission||y.pendingQuestion):!1}),o=F(()=>Vf(e.instanceId,e.sessionId));function a(y){if(y.source.type!=="text")return;const v=c==null?void 0:c.querySelector(".prompt-input"),O=y.source.value,T=y.display.match(/pasted #(\d+)/),I=T?`[pasted #${T[1]}]`:null,k=(v==null?void 0:v.value)??"";let A=k,V=null;if(I){const B=k.indexOf(I);B!==-1&&(A=k.substring(0,B)+O+k.substring(B+I.length),V=B+O.length)}if(A===k)if(v){const B=v.selectionStart,$=v.selectionEnd;A=k.substring(0,B)+O+k.substring($),V=B+O.length}else A=k+O;v&&(v.value=A,v.dispatchEvent(new Event("input",{bubbles:!0})),v.focus(),V!==null&&v.setSelectionRange(V,V)),Ec(e.instanceId,e.sessionId,y.id)}let l,c;function d(){l&&requestAnimationFrame(()=>{requestAnimationFrame(()=>l==null?void 0:l())})}J(()=>{e.isActive&&d()});let u=null;J(()=>{const y=t();y&&Pu(e.instanceId,y.id).catch(v=>lo.error("Failed to load messages",v))});function _(y){return u=y,()=>{u===y&&(u=null)}}function m(y,v){u&&u(y,v)}async function g(y,v){d(),await ZM(e.instanceId,e.sessionId,y,v)}async function p(y){await eP(e.instanceId,e.sessionId,y)}async function E(){const y=t();if(y)try{await zT(e.instanceId,y.id),lo.info("Abort requested",{instanceId:e.instanceId,sessionId:y.id})}catch(v){lo.error("Failed to abort session",v),Gs("Failed to stop session",{title:"Stop failed",detail:v instanceof Error?v.message:String(v),variant:"error"})}}function h(y){const v=r().getMessage(y);if(v&&v.role==="user"){const T=v.partIds.map(I=>{var k;return(k=v.parts[I])==null?void 0:k.data}).filter(I=>!!I).filter(KJ);if(T.length>0)return T.map(I=>I.text).join(`
176
- `)}return null}async function f(y){const v=Et().get(e.instanceId);if(!(!v||!v.client))try{await An(v.client.session.revert({sessionID:e.sessionId,messageID:y}),"session.revert");const O=h(y);if(O){const T=c==null?void 0:c.querySelector(".prompt-input");T&&(T.value=O,T.dispatchEvent(new Event("input",{bubbles:!0})),T.focus())}}catch(O){lo.error("Failed to revert message",O),Gs("Failed to revert to message",{title:"Revert failed",variant:"error"})}}async function b(y){if(!y){lo.warn("Fork requires a user message id");return}const v=h(y);try{const O=await TU(e.instanceId,e.sessionId,{messageId:y}),T=O.parentId??O.id;if(Ss(e.instanceId,T),O.parentId&&Es(e.instanceId,O.id),await Pu(e.instanceId,O.id).catch(I=>lo.error("Failed to load forked session messages",I)),v){const I=c==null?void 0:c.querySelector(".prompt-input");I&&(I.value=v,I.dispatchEvent(new Event("input",{bubbles:!0})),I.focus())}}catch(O){lo.error("Failed to fork session",O),Gs("Failed to fork session",{title:"Fork failed",variant:"error"})}}return S(W,{get when(){return t()},get fallback(){return HJ()},children:y=>{const v=y();return v?(()=>{var O=zJ(),T=c;return typeof T=="function"?wt(T,O):c=O,C(O,S(sJ,{get instanceId(){return e.instanceId},get sessionId(){return v.id},get loading(){return n()},onRevert:f,onFork:b,get isActive(){return e.isActive},registerScrollToBottom:I=>{l=I,e.isActive&&d()},get showSidebarToggle(){return e.showSidebarToggle},get onSidebarToggle(){return e.onSidebarToggle},get forceCompactStatusLayout(){return e.forceCompactStatusLayout},onQuoteSelection:m}),null),C(O,S(W,{get when(){return o().length>0},get children(){var I=YJ();return C(I,S(_t,{get each(){return o()},children:k=>{const A=k.source.type==="text";return(()=>{var V=qJ(),B=V.firstChild,$=B.nextSibling;return C(B,()=>k.display),C(V,S(W,{when:A,get children(){var M=WJ();return M.$$click=()=>a(k),C(M,S(BD,{class:"h-3 w-3","aria-hidden":"true"})),M}}),$),$.$$click=()=>Ec(e.instanceId,e.sessionId,k.id),ne(()=>Fe(V,"title",k.source.type==="file"?k.source.path:void 0)),V})()}})),I}}),null),C(O,S(VJ,{get instanceId(){return e.instanceId},get instanceFolder(){return e.instanceFolder},get sessionId(){return v.id},onSend:g,onRunShell:p,get escapeInDebounce(){return e.escapeInDebounce},get isSessionBusy(){return i()},get disabled(){return s()},onAbortSession:E,registerQuoteHandler:_}),null),O})():null}})};Ht(["click"]);const[jJ,aE]=U(new Map);function XJ(e,t){aE(n=>{const r=new Map(n);return r.set(e,t),r})}function ZJ(e,t){aE(n=>{const r=new Map(n),i=r.get(e)??[],s=i.findIndex(a=>a.id===t.id),o=s>=0?[...i.slice(0,s),t,...i.slice(s+1)]:[...i,t];return r.set(e,o),r})}function JJ(e,t){aE(n=>{const r=new Map(n),i=r.get(e)??[];return r.set(e,i.filter(s=>s.id!==t)),r})}async function eee(e){const t=await vn.listBackgroundProcesses(e);XJ(e,t.processes)}function tee(e){return jJ().get(e)??[]}wn.onBackgroundProcessUpdated=(e,t)=>{var r;const n=(r=t.properties)==null?void 0:r.process;n&&ZJ(e,n)};wn.onBackgroundProcessRemoved=(e,t)=>{var r;const n=(r=t.properties)==null?void 0:r.processId;n&&JJ(e,n)};var nee=x('<span class="text-xs text-secondary block"> · '),ree=x('<span class="text-xs text-secondary mt-1 block truncate">'),iee=x('<div class="flex items-start justify-between px-6 py-4 border-b border-base gap-4"><div class="flex-1 min-w-0"></div><button type=button class="button-tertiary flex-shrink-0">Close'),see=x('<p class="text-xs text-secondary">Loading output...'),oee=x('<p class="text-xs text-secondary mb-2">Output truncated for display.'),ry=x('<pre class="text-xs whitespace-pre-wrap break-all text-primary bg-surface-secondary border border-base rounded-md p-4 font-mono">'),aee=x('<div class="flex-1 overflow-auto p-6">'),lee=x('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">');function cee(e){const[t,n]=U(""),[r,i]=U(""),[s,o]=U(!1),[a,l]=U(!1),[c,d]=U(!1);let u=$A();return J(()=>{const _=e.process;if(!e.open||!_)return;let m=null,g=!0,p="";const E=f=>{p=f,n(f)},h=f=>{p+=f,n(p)};o(!1),i(""),E(""),u.reset(),d(!0),vn.fetchBackgroundProcessOutput(e.instanceId,_.id,{method:"full",maxBytes:void 0}).then(f=>{if(!g)return;E(f.content),l(f.truncated),hc(f.content)?(o(!0),u.reset(),i(u.render(f.content))):(o(!1),i(""),u.reset())}).catch(()=>{g&&(E("Failed to load output."),o(!1),i(""))}).finally(()=>{g&&d(!1)}),m=new EventSource(A0(e.instanceId,_.id),{withCredentials:!0}),m.onmessage=f=>{try{const b=JSON.parse(f.data);if((b==null?void 0:b.type)!=="chunk"||typeof b.content!="string")return;const y=b.content;if(!s()){h(y),hc(y)&&(o(!0),u.reset(),i(u.render(p)));return}h(y);const O=u.render(y);i(T=>`${T}${O}`)}catch{}},Ne(()=>{g=!1,m==null||m.close()})}),S(ft,{get open(){return e.open},onOpenChange:_=>!_&&e.onClose(),modal:!0,get children(){return S(ft.Portal,{get children(){return[S(ft.Overlay,{class:"modal-overlay"}),(()=>{var _=lee();return C(_,S(ft.Content,{class:"modal-surface w-full max-w-5xl max-h-[90vh] flex flex-col overflow-hidden",get children(){return[(()=>{var m=iee(),g=m.firstChild,p=g.nextSibling;return C(g,S(ft.Title,{class:"text-lg font-semibold text-primary",children:"Background Output"}),null),C(g,S(W,{get when(){return e.process},get children(){return[(()=>{var E=nee(),h=E.firstChild;return C(E,()=>{var f;return(f=e.process)==null?void 0:f.title},h),C(E,()=>{var f;return(f=e.process)==null?void 0:f.id},null),E})(),(()=>{var E=ree();return C(E,()=>{var h;return(h=e.process)==null?void 0:h.command}),ne(()=>{var h;return Fe(E,"title",(h=e.process)==null?void 0:h.command)}),E})()]}}),null),Fn(p,"click",e.onClose,!0),m})(),(()=>{var m=aee();return C(m,S(W,{get when(){return c()},get children(){return see()}}),null),C(m,S(W,{get when(){return!c()},get children(){return[S(W,{get when(){return a()},get children(){return oee()}}),S(W,{get when(){return s()},get fallback(){return(()=>{var g=ry();return C(g,t),g})()},get children(){var g=ry();return ne(()=>g.innerHTML=r()),g}})]}}),null),m})()]}})),_})()]}})}})}Ht(["click"]);const Hf="opencode:session-sidebar-request";function ya(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(Hf,{detail:e}))}var dee=x('<div class="flex flex-col h-full min-h-0"><div class="flex items-start justify-between gap-2 px-4 py-3 border-b border-base"><div class="flex flex-col gap-1"><span class="session-sidebar-title text-sm font-semibold uppercase text-primary">Sessions</span><div class=session-sidebar-shortcuts></div></div><div class="flex items-center gap-2"></div></div><div class="session-sidebar flex flex-col flex-1 min-h-0">'),uee=x('<div class="session-sidebar-controls px-4 py-4 border-t border-base flex flex-col gap-3"><div class=sidebar-selector-hints aria-hidden=true><span class="hint sidebar-selector-hint sidebar-selector-hint--left"></span><span class="hint sidebar-selector-hint sidebar-selector-hint--right">'),_ee=x('<p class="text-xs text-secondary">Select a session to view plan.'),mee=x('<p class="text-xs text-secondary">Nothing planned yet.'),gee=x('<p class="text-xs text-secondary">No background processes.'),fee=x('<div class="flex flex-col gap-2">'),pee=x("<span>Output: <!>KB"),hee=x('<div class="rounded-md border border-base bg-surface-secondary p-2 flex flex-col gap-2"><div class="flex flex-col gap-1"><span class="text-xs font-semibold text-primary"></span><div class="flex flex-wrap gap-2 text-[11px] text-secondary"><span>Status: </span></div></div><div class="grid grid-cols-3 gap-2"><button type=button class="button-tertiary w-full p-1 inline-flex items-center justify-center"aria-label=Output title=Output></button><button type=button class="button-tertiary w-full p-1 inline-flex items-center justify-center"aria-label=Stop title=Stop></button><button type=button class="button-tertiary w-full p-1 inline-flex items-center justify-center"aria-label=Terminate title=Terminate>'),Eee=x('<div class="flex flex-col h-full"><div class="flex items-center justify-between px-4 py-2 border-b border-base"><div class="flex items-center gap-2"></div></div><div class="flex-1 overflow-y-auto">'),See=x("<span>"),bee=x('<div class="session-resize-handle session-resize-handle--left"role=presentation aria-hidden=true>'),vee=x('<div class="session-resize-handle session-resize-handle--right"role=presentation aria-hidden=true>'),yee=x('<div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Used</span><span class="font-semibold text-primary">'),Tee=x('<div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Avail</span><span class="font-semibold text-primary">'),Cee=x('<div class="session-toolbar-left flex items-center gap-3 min-w-0">'),Ree=x('<div class="session-toolbar-center flex-1 flex items-center justify-center gap-2 min-w-[160px]"><button type=button class="connection-status-button px-2 py-0.5 text-xs"aria-label="Open command palette"style="flex:0 0 auto;width:auto">Command Palette</button><span class=connection-status-shortcut-hint>'),Iee=x('<span class="status-indicator connected"><span class=status-dot></span><span class=status-text>Connected'),Oee=x('<span class="status-indicator connecting"><span class=status-dot></span><span class=status-text>Connecting...'),Nee=x('<span class="status-indicator disconnected"><span class=status-dot></span><span class=status-text>Disconnected'),Aee=x('<div class="session-toolbar-right flex items-center gap-3"><div class="connection-status-meta flex items-center gap-3">'),wee=x('<div class="info-view-pane flex flex-col flex-1 min-h-0 overflow-y-auto">'),xee=x('<div class="session-shell-panels flex flex-col flex-1 min-h-0 overflow-x-hidden">'),Dee=x('<div class="flex flex-col w-full gap-1.5"><div class="flex flex-wrap items-center justify-between gap-2 w-full"><div class="flex flex-wrap items-center gap-1 justify-center"><button type=button class="connection-status-button px-2 py-0.5 text-xs"aria-label="Open command palette"style="flex:0 0 auto;width:auto">Command Palette</button><span class=connection-status-shortcut-hint></span><span><span class=status-dot></span></span></div></div><div class="flex flex-wrap items-center justify-center gap-2 pb-1"><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Used</span><span class="font-semibold text-primary"></span></div><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Avail</span><span class="font-semibold text-primary">'),Lee=x('<div class="flex items-center justify-center h-full"><div class="text-center text-gray-500 dark:text-gray-400"><p class=mb-2>No session selected</p><p class=text-sm>Select a session to view messages'),kee=x('<div class="session-cache-pane flex flex-col flex-1 min-h-0">'),Mee=x('<div class="instance-shell2 flex flex-col flex-1 min-h-0">');const $l=vt("session"),Pee=280,$ee=220,Fee=360,Bee=260,Uee=200,Gee=380,iy=5,sy=56,oy="opencode-session-sidebar-width-v8",ay="opencode-session-right-drawer-width-v1",Vee="opencode-session-left-drawer-pinned-v1",Hee="opencode-session-right-drawer-pinned-v1",Wd=e=>Math.min(Fee,Math.max($ee,e)),ly=e=>Math.min(Gee,Math.max(Uee,e)),XA=e=>e==="left"?Vee:Hee;function gg(e,t){if(typeof window>"u")return t;const n=window.localStorage.getItem(XA(e));return n==="true"?!0:n==="false"?!1:t}function Yee(e,t){typeof window>"u"||window.localStorage.setItem(XA(e),t?"true":"false")}const zee=e=>{const[t,n]=U(Pee),[r,i]=U(Bee),[s,o]=U(!0),[a,l]=U(!0),[c,d]=U(!0),[u,_]=U(!0),[m,g]=U([]),[p,E]=U([]),[h,f]=U(null),[b,y]=U(0),[v,O]=U(0),[T,I]=U(null),[k,A]=U(null),[V,B]=U(null),[$,M]=U(null),[L,R]=U(null),[D,w]=U(0),[P,j]=U(0),[le,me]=U(["plan","background-processes","mcp","lsp","plugins"]),[Ae,ie]=U(null),[re,Ee]=U(!1),[Se,q]=U(!1),ae=F(()=>Ut.getOrCreate(e.instance.id)),N=xb("(min-width: 1280px)"),H=xb("(min-width: 768px)"),te=F(()=>N()?"desktop":H()?"tablet":"phone"),Q=F(()=>te()==="phone"),z=F(()=>te()==="desktop"),he=F(()=>te()!=="phone"),ue=(Z,fe)=>{Z==="left"&&!z()||Z==="right"&&!he()||Yee(Z,fe)};J(()=>{const Z=e.instance.id;eee(Z).catch(fe=>{$l.warn("Failed to load background processes",fe)})}),J(()=>{switch(te()){case"desktop":{const Z=gg("left",!0),fe=gg("right",!0);o(Z),l(Z),d(fe),_(fe);break}case"tablet":{const Z=gg("right",!0);o(!1),l(!1),d(Z),_(Z);break}default:o(!1),l(!1),d(!1),_(!1);break}});const ce=()=>{if(typeof window>"u")return;const Z=h();if(!Z)return;const fe=Z.getBoundingClientRect(),Ue=Z.querySelector(".session-toolbar"),st=(Ue==null?void 0:Ue.offsetHeight)??sy;y(fe.top+st),O(Math.max(0,fe.height-st))};Tn(()=>{if(typeof window>"u")return;const Z=window.localStorage.getItem(oy);if(Z){const st=Number.parseInt(Z,10);Number.isFinite(st)&&n(Wd(st))}const fe=window.localStorage.getItem(ay);if(fe){const st=Number.parseInt(fe,10);Number.isFinite(st)&&i(ly(st))}const Ue=()=>{const st=Wd(window.innerWidth*.3);n(At=>Wd(At||st)),ce()};Ue(),window.addEventListener("resize",Ue),Ne(()=>window.removeEventListener("resize",Ue))}),Tn(()=>{if(typeof window>"u")return;const Z=fe=>{const Ue=fe.detail;!Ue||Ue.instanceId!==e.instance.id||Yt(Ue.action)};window.addEventListener(Hf,Z),Ne(()=>window.removeEventListener(Hf,Z))}),J(()=>{typeof window>"u"||window.localStorage.setItem(oy,t().toString())}),J(()=>{typeof window>"u"||window.localStorage.setItem(ay,r().toString())}),J(()=>{e.tabBarOffset,requestAnimationFrame(()=>ce())});const se=F(()=>Ft().get(e.instance.id)??new Map),ke=F(()=>AR(e.instance.id)),We=F(()=>{const Z=Qg().get(e.instance.id);if(!Z)return new Map;const fe=FU(e.instance.id,Z);return new Map(fe.map(Ue=>[Ue.id,Ue]))}),Oe=F(()=>qa().get(e.instance.id)||null);F(()=>Qg().get(e.instance.id)||null);const je=F(()=>{const Z=Oe();return!Z||Z==="info"?null:We().get(Z)??null}),dt=F(()=>{const Z=Oe();if(!Z)return null;const fe=ae();return(fe==null?void 0:fe.getSessionUsage(Z))??null}),Lt=F(()=>{const Z=Oe();return Z?Kp(e.instance.id,Z)??null:null}),be=F(()=>{const Z=dt(),fe=Lt();return{used:(Z==null?void 0:Z.actualUsageTokens)??(fe==null?void 0:fe.actualUsageTokens)??0,avail:(fe==null?void 0:fe.contextAvailableTokens)??null}}),ee=F(()=>{const Z=Oe();if(!Z||Z==="info")return null;const fe=ae();return fe?fe.state.latestTodos[Z]??null:null}),Re=F(()=>{var xt;const Z=ee();if(!Z)return null;const fe=ae();if(!fe)return null;const Ue=fe.getMessage(Z.messageId);if(!Ue)return null;const st=(xt=Ue.parts)==null?void 0:xt[Z.partId],At=st==null?void 0:st.data;if(!At||At.type!=="tool"||At.tool!=="todowrite")return null;const Ct=At.state;return!Ct||Ct.status!=="completed"?null:Ct}),He=F(()=>tee(e.instance.id)),qe=()=>wn.getStatus(e.instance.id),de=()=>{const Z=qe();return Z==="connecting"?"connecting":Z==="connected"?"connected":"disconnected"},ge=()=>{YA(e.instance.id)},Ce=Z=>{ie(Z),Ee(!0)},Ke=()=>{Ee(!1),ie(null)},$e=async Z=>{try{await vn.stopBackgroundProcess(e.instance.id,Z)}catch(fe){$l.warn("Failed to stop background process",fe)}},Be=async Z=>{try{await vn.terminateBackgroundProcess(e.instance.id,Z)}catch(fe){$l.warn("Failed to terminate background process",fe)}},tt=F(()=>e.paletteCommands()),pt=F(()=>pj(e.instance.id)),at=F(()=>[Hn.get("session-prev"),Hn.get("session-next")].filter(Z=>!!Z));let mt=0;const[bt,Ze]=U(null),Ve=(Z,fe)=>{Z.dispatchEvent(new KeyboardEvent("keydown",{key:fe.key,code:fe.code,keyCode:fe.keyCode,which:fe.keyCode,bubbles:!0,cancelable:!0}))},nt=()=>{var fe;const Z=(fe=T())==null?void 0:fe.querySelector("[data-agent-selector]");return Z?(Z.focus(),setTimeout(()=>Ve(Z,{key:"Enter",code:"Enter",keyCode:13}),10),!0):!1},ut=()=>{var fe;const Z=(fe=T())==null?void 0:fe.querySelector("[data-model-selector]");return Z?(Z.focus(),setTimeout(()=>Ve(Z,{key:"ArrowDown",code:"ArrowDown",keyCode:40}),10),!0):!1};J(()=>{const Z=bt();if(!Z)return;const fe=Z.action;if(!!!T())return;if(fe==="show-session-list"){Ze(null);return}(fe==="focus-agent-selector"?nt():ut())&&Ze(null)});const Yt=Z=>{Ze({action:Z,id:mt++}),!s()&&!a()&&(l(!0),ce())},ye=()=>{let Z=!1;return!s()&&a()&&(l(!1),Ln(T()),er(V()),Z=!0),!c()&&u()&&(_(!1),Ln(k()),er($()),Z=!0),Z};Tn(()=>{if(typeof window>"u")return;const Z=fe=>{fe.key==="Escape"&&ye()&&(fe.preventDefault(),fe.stopPropagation())};window.addEventListener("keydown",Z,!0),Ne(()=>window.removeEventListener("keydown",Z,!0))});const Ie=Z=>{if(Z==="info"){Es(e.instance.id,Z);return}const fe=se().get(Z);if(!fe)return;if(fe.parentId===null){Ss(e.instance.id,Z);return}const Ue=fe.parentId;Ue&&ur(()=>{Ss(e.instance.id,Ue),Es(e.instance.id,Z)})},Ge=Z=>{if(!Z)return;$l.info("Evicting cached session",{instanceId:e.instance.id,sessionId:Z});const fe=Ut.getInstance(e.instance.id);fe==null||fe.clearSession(Z),cj(e.instance.id,Z)},Qe=Z=>{Z.length&&E(fe=>{const Ue=new Set(fe),st=[...fe];return Z.forEach(At=>{Ue.has(At)||(st.push(At),Ue.add(At))}),st})};J(()=>{const Z=p();if(!Z.length)return;const fe=new Set(m()),Ue=[];Z.forEach(st=>{fe.has(st)?Ue.push(st):Ge(st)}),Ue.length!==Z.length&&E(Ue)}),J(()=>{const Z=se(),fe=Oe();g(Ue=>{const st=Ue.filter(Vt=>Vt!=="info"&&Z.has(Vt));(Vt=>{if(!Vt||Vt==="info"||!Z.has(Vt))return;const On=st.indexOf(Vt);On!==-1&&st.splice(On,1),st.unshift(Vt)})(fe);const Ct=st.length>iy?st.slice(0,iy):st,xt=new Set(Ct),Pt=Ue.filter(Vt=>!xt.has(Vt));return Pt.length&&Qe(Pt),Ct})});const ct=F(()=>!s()&&!a()),it=()=>{const Z=h();if(Z)return Z;if(typeof document<"u")return document.body},gt=()=>sy+e.tabBarOffset,yt=()=>{const Z=b();return Z>0?Z:gt()},nn=()=>`${yt()}px`,Rn=()=>{const Z=v();return Z>0?`${Z}px`:`calc(100% - ${yt()}px)`},yr=()=>{if(typeof window>"u"){ce();return}requestAnimationFrame(()=>ce())},Rs=(Z,fe)=>{Z==="left"?n(fe):i(fe),yr()},Lr=Z=>{const fe=L();if(!fe)return;const Ue=P(),st=fe==="left"?Wd:ly,At=fe==="left"?Z-D():D()-Z,Ct=st(Ue+At);Rs(fe,Ct)};function ar(){R(null),document.removeEventListener("mousemove",mi),document.removeEventListener("mouseup",yl),document.removeEventListener("touchmove",Tl),document.removeEventListener("touchend",Cl)}function mi(Z){Z.preventDefault(),Lr(Z.clientX)}function yl(){ar()}function Tl(Z){const fe=Z.touches[0];fe&&(Z.preventDefault(),Lr(fe.clientX))}function Cl(){ar()}const K=(Z,fe)=>{R(Z),w(fe),j(Z==="left"?t():r()),document.addEventListener("mousemove",mi),document.addEventListener("mouseup",yl),document.addEventListener("touchmove",Tl,{passive:!1}),document.addEventListener("touchend",Cl)},_e=Z=>fe=>{fe.preventDefault(),K(Z,fe.clientX)},Ye=Z=>fe=>{const Ue=fe.touches[0];Ue&&(fe.preventDefault(),K(Z,Ue.clientX))};Ne(()=>{ar()});const Xe=F(()=>s()?"pinned":a()?"floating-open":"floating-closed"),ot=F(()=>c()?"pinned":u()?"floating-open":"floating-closed"),kt=()=>{const Z=Xe();return Z==="pinned"?"Left drawer pinned":Z==="floating-closed"?"Open left drawer":"Close left drawer"},Nt=()=>{const Z=ot();return Z==="pinned"?"Right drawer pinned":Z==="floating-closed"?"Open right drawer":"Close right drawer"},zt=()=>Xe()==="floating-closed"?S(Db,{fontSize:"small"}):S(Lb,{fontSize:"small"}),Rt=()=>ot()==="floating-closed"?S(Db,{fontSize:"small",sx:{transform:"scaleX(-1)"}}):S(Lb,{fontSize:"small",sx:{transform:"scaleX(-1)"}}),xn=()=>{Ln(T()),ur(()=>{o(!0),l(!0)}),ue("left",!0),ce()},Ot=()=>{Ln(T()),ur(()=>{o(!1),l(!0)}),ue("left",!1),ce()},Dn=()=>{Ln(k()),ur(()=>{d(!0),_(!0)}),ue("right",!0),ce()},gi=()=>{Ln(k()),ur(()=>{d(!1),_(!0)}),ue("right",!1),ce()},jt=()=>{const Z=Xe();if(Z!=="pinned"){if(Z==="floating-closed"){l(!0),ce();return}Ln(T()),l(!1),er(V()),ce()}},jr=()=>{const Z=ot();if(Z!=="pinned"){if(Z==="floating-closed"){_(!0),ce();return}Ln(k()),_(!1),er($()),ce()}},er=Z=>{Z&&requestAnimationFrame(()=>{Z.focus()})},Ln=Z=>{if(typeof document>"u"||!Z)return;const fe=document.activeElement;fe&&Z.contains(fe)&&fe.blur()},kr=()=>{Xe()!=="pinned"&&(Ln(T()),l(!1),er(V()))},tr=()=>{ot()!=="pinned"&&(Ln(k()),_(!1),er($()))},Mt=()=>yi(be().used),gn=()=>{const Z=be().avail;return typeof Z=="number"?yi(Z):"--"},rn=()=>(()=>{var Z=dee(),fe=Z.firstChild,Ue=fe.firstChild,st=Ue.firstChild,At=st.nextSibling,Ct=Ue.nextSibling,xt=fe.nextSibling;return wt(I,Z),C(At,S(W,{get when(){return at().length},get children(){return S(Qp,{get shortcuts(){return at()},separator:" ",showDescription:!1})}})),C(Ct,S(so,{size:"small",color:"inherit","aria-label":"Instance Info",title:"Instance Info",onClick:()=>Ie("info"),get children(){return S(bz,{fontSize:"small"})}}),null),C(Ct,S(W,{get when(){return!Q()},get children(){return S(so,{size:"small",color:"inherit",get"aria-label"(){return s()?"Unpin left drawer":"Pin left drawer"},onClick:()=>s()?Ot():xn(),get children(){return we(()=>!!s())()?S(kb,{fontSize:"small"}):S(Mb,{fontSize:"small"})}})}}),null),C(xt,S(Dj,{get instanceId(){return e.instance.id},get threads(){return ke()},get activeSessionId(){return Oe()},onSelect:Ie,onNew:()=>{const Pt=e.onNewSession();Pt instanceof Promise&&Pt.catch(Vt=>$l.error("Failed to create session:",Vt))},showHeader:!1,showFooter:!1}),null),C(xt,S(oY,{}),null),C(xt,S(W,{get when(){return je()},children:Pt=>[S(SZ,{get instanceId(){return e.instance.id},get sessionId(){return Pt().id}}),(()=>{var Vt=uee(),On=Vt.firstChild,fr=On.firstChild,xi=fr.nextSibling;return C(Vt,S(VX,{get instanceId(){return e.instance.id},get sessionId(){return Pt().id},get currentAgent(){return Pt().agent},onAgentChange:Mr=>e.handleSidebarAgentChange(Pt().id,Mr)}),On),C(fr,S(ir,{shortcut:"cmd+shift+a"})),C(xi,S(ir,{shortcut:"cmd+shift+m"})),C(Vt,S(jX,{get instanceId(){return e.instance.id},get sessionId(){return Pt().id},get currentModel(){return Pt().model},onModelChange:Mr=>e.handleSidebarModelChange(Pt().id,Mr)}),null),Vt})()]}),null),Z})(),Xr=()=>{const Ue=[{id:"plan",label:"Plan",render:()=>{const Ct=Oe();if(!Ct||Ct==="info")return _ee();const xt=Re();return xt?S(LA,{state:xt,emptyLabel:"Nothing planned yet.",showStatusLabel:!1}):mee()}},{id:"background-processes",label:"Background Shells",render:()=>{const Ct=He();return Ct.length===0?gee():(()=>{var xt=fee();return C(xt,S(_t,{each:Ct,children:Pt=>(()=>{var Vt=hee(),On=Vt.firstChild,fr=On.firstChild,xi=fr.nextSibling,Mr=xi.firstChild;Mr.firstChild;var ji=On.nextSibling,fn=ji.firstChild,Wn=fn.nextSibling,rr=Wn.nextSibling;return C(fr,()=>Pt.title),C(Mr,()=>Pt.status,null),C(xi,S(W,{get when(){return typeof Pt.outputSizeBytes=="number"},get children(){var sn=pee(),Xi=sn.firstChild,Zi=Xi.nextSibling;return Zi.nextSibling,C(sn,()=>Math.round((Pt.outputSizeBytes??0)/1024),Zi),sn}}),null),fn.$$click=()=>Ce(Pt),C(fn,S(h0,{class:"h-4 w-4"})),Wn.$$click=()=>$e(Pt.id),C(Wn,S(T0,{class:"h-4 w-4"})),rr.$$click=()=>Be(Pt.id),C(rr,S(al,{class:"h-4 w-4"})),ne(()=>Wn.disabled=Pt.status!=="running"),Vt})()})),xt})()}},{id:"mcp",label:"MCP Servers",render:()=>S(_u,{get initialInstance(){return e.instance},sections:["mcp"],showSectionHeadings:!1,class:"space-y-2"})},{id:"lsp",label:"LSP Servers",render:()=>S(_u,{get initialInstance(){return e.instance},sections:["lsp"],showSectionHeadings:!1,class:"space-y-2"})},{id:"plugins",label:"Plugins",render:()=>S(_u,{get initialInstance(){return e.instance},sections:["plugins"],showSectionHeadings:!1,class:"space-y-2"})}];J(()=>{const Ct=new Set(le());Ue.every(xt=>Ct.has(xt.id))||me(Ue.map(xt=>xt.id))});const st=Ct=>{me(Ct)},At=Ct=>le().includes(Ct);return(()=>{var Ct=Eee(),xt=Ct.firstChild,Pt=xt.firstChild,Vt=xt.nextSibling;return wt(A,Ct),C(xt,S(az,{variant:"subtitle2",class:"uppercase tracking-wide text-xs font-semibold",children:"Status Panel"}),Pt),C(Pt,S(W,{get when(){return!Q()},get children(){return S(so,{size:"small",color:"inherit",get"aria-label"(){return c()?"Unpin right drawer":"Pin right drawer"},onClick:()=>c()?gi():Dn(),get children(){return we(()=>!!c())()?S(kb,{fontSize:"small"}):S(Mb,{fontSize:"small"})}})}})),C(Vt,S(ia.Root,{class:"flex flex-col",collapsible:!0,multiple:!0,get value(){return le()},onChange:st,get children(){return S(_t,{each:Ue,children:On=>S(ia.Item,{get value(){return On.id},class:"w-full border border-base bg-surface-secondary text-primary",get children(){return[S(ia.Header,{get children(){return S(ia.Trigger,{class:"w-full flex items-center justify-between gap-3 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide",get children(){return[(()=>{var fr=See();return C(fr,()=>On.label),fr})(),S(Qc,{get class(){return`h-4 w-4 transition-transform duration-150 ${At(On.id)?"rotate-180":""}`}})]}})}}),S(ia.Content,{class:"w-full px-3 pb-3 text-sm text-primary",get children(){return On.render()}})]}})})}})),Ct})()},nr=()=>{if(s())return S(Kl,{class:"session-sidebar-container",get sx(){return{width:`${t()}px`,flexShrink:0,borderRight:"1px solid var(--border-base)",backgroundColor:"var(--surface-secondary)",height:"100%",minHeight:0,position:"relative"}},get children(){return[(()=>{var Ue=bee();return Fn(Ue,"touchstart",Ye("left"),!0),Fn(Ue,"mousedown",_e("left"),!0),Ue})(),S(rn,{})]}});const Z=it();return S(Nb,{anchor:"left",variant:"temporary",get open(){return a()},onClose:kr,ModalProps:Z?{container:Z}:void 0,get sx(){return{"& .MuiDrawer-paper":{width:Q()?"100vw":`${t()}px`,boxSizing:"border-box",borderRight:Q()?"none":"1px solid var(--border-base)",backgroundColor:"var(--surface-secondary)",backgroundImage:"none",color:"var(--text-primary)",boxShadow:"none",borderRadius:0,top:nn(),height:Rn()},"& .MuiBackdrop-root":{backgroundColor:"transparent"}}},get children(){return S(rn,{})}})},Is=()=>{if(c())return S(Kl,{class:"session-right-panel",get sx(){return{width:`${r()}px`,flexShrink:0,borderLeft:"1px solid var(--border-base)",backgroundColor:"var(--surface-secondary)",height:"100%",minHeight:0,position:"relative"}},get children(){return[(()=>{var Ue=vee();return Fn(Ue,"touchstart",Ye("right"),!0),Fn(Ue,"mousedown",_e("right"),!0),Ue})(),S(Xr,{})]}});const Z=it();return S(Nb,{anchor:"right",variant:"temporary",get open(){return u()},onClose:tr,ModalProps:Z?{container:Z}:void 0,get sx(){return{"& .MuiDrawer-paper":{width:Q()?"100vw":`${r()}px`,boxSizing:"border-box",borderLeft:Q()?"none":"1px solid var(--border-base)",backgroundColor:"var(--surface-secondary)",backgroundImage:"none",color:"var(--text-primary)",boxShadow:"none",borderRadius:0,top:nn(),height:Rn()},"& .MuiBackdrop-root":{backgroundColor:"transparent"}}},get children(){return S(Xr,{})}})},In=F(()=>We().size>0),Os=F(()=>Oe()==="info"),gr=(()=>{var Z=xee();return wt(fe=>{f(fe),ce()},Z),C(Z,S(XH,{position:"sticky",color:"default",elevation:0,class:"border-b border-base",get children(){return S(nz,{variant:"dense",class:"session-toolbar flex flex-wrap items-center gap-2 py-0 min-h-[40px]",get children(){return S(W,{get when(){return!Q()},get fallback(){return(()=>{var fe=Dee(),Ue=fe.firstChild,st=Ue.firstChild,At=st.firstChild,Ct=At.nextSibling,xt=Ct.nextSibling,Pt=Ue.nextSibling,Vt=Pt.firstChild,On=Vt.firstChild,fr=On.nextSibling,xi=Vt.nextSibling,Mr=xi.firstChild,ji=Mr.nextSibling;return C(Ue,S(so,{ref:B,color:"inherit",onClick:jt,get"aria-label"(){return kt()},size:"small",get"aria-expanded"(){return Xe()!=="floating-closed"},get disabled(){return Xe()==="pinned"},get children(){return zt()}}),st),C(st,S(Hv,{get instanceId(){return e.instance.id},onClick:()=>q(!0)}),At),At.$$click=ge,C(Ct,S(ir,{shortcut:"cmd+shift+p"})),C(Ue,S(so,{ref:M,color:"inherit",onClick:jr,get"aria-label"(){return Nt()},size:"small",get"aria-expanded"(){return ot()!=="floating-closed"},get disabled(){return ot()==="pinned"},get children(){return Rt()}}),null),C(fr,Mt),C(ji,gn),ne(fn=>{var Wn=`status-indicator ${de()}`,rr=`Connection ${qe()}`;return Wn!==fn.e&&rt(xt,fn.e=Wn),rr!==fn.t&&Fe(xt,"aria-label",fn.t=rr),fn},{e:void 0,t:void 0}),fe})()},get children(){return[(()=>{var fe=Cee();return C(fe,S(so,{ref:B,color:"inherit",onClick:jt,get"aria-label"(){return kt()},size:"small",get"aria-expanded"(){return Xe()!=="floating-closed"},get disabled(){return Xe()==="pinned"},get children(){return zt()}}),null),C(fe,S(W,{get when(){return!Os()},get children(){return[(()=>{var Ue=yee(),st=Ue.firstChild,At=st.nextSibling;return C(At,Mt),Ue})(),(()=>{var Ue=Tee(),st=Ue.firstChild,At=st.nextSibling;return C(At,gn),Ue})()]}}),null),fe})(),(()=>{var fe=Ree(),Ue=fe.firstChild,st=Ue.nextSibling;return C(fe,S(Hv,{get instanceId(){return e.instance.id},onClick:()=>q(!0)}),Ue),Ue.$$click=ge,C(st,S(ir,{shortcut:"cmd+shift+p"})),fe})(),(()=>{var fe=Aee(),Ue=fe.firstChild;return C(Ue,S(W,{get when(){return qe()==="connected"},get children(){return Iee()}}),null),C(Ue,S(W,{get when(){return qe()==="connecting"},get children(){return Oee()}}),null),C(Ue,S(W,{get when(){return qe()==="error"||qe()==="disconnected"},get children(){return Nee()}}),null),C(fe,S(so,{ref:M,color:"inherit",onClick:jr,get"aria-label"(){return Nt()},size:"small",get"aria-expanded"(){return ot()!=="floating-closed"},get disabled(){return ot()==="pinned"},get children(){return Rt()}}),null),fe})()]}})}})}}),null),C(Z,S(Kl,{sx:{display:"flex",flex:1,minHeight:0,overflowX:"hidden"},get children(){return[we(()=>nr()),S(Kl,{component:"main",sx:{flexGrow:1,minHeight:0,display:"flex",flexDirection:"column",overflowX:"hidden"},class:"content-area",get children(){return S(W,{get when(){return Os()},get fallback(){return S(W,{get when(){return we(()=>m().length>0)()&&Oe()},get fallback(){return Lee()},get children(){return S(_t,{get each(){return m()},children:fe=>{const Ue=()=>Oe()===fe;return(()=>{var st=kee();return Fe(st,"data-session-id",fe),C(st,S(QJ,{sessionId:fe,get activeSessions(){return We()},get instanceId(){return e.instance.id},get instanceFolder(){return e.instance.folder},get escapeInDebounce(){return e.escapeInDebounce},get showSidebarToggle(){return ct()},onSidebarToggle:()=>l(!0),get forceCompactStatusLayout(){return ct()},get isActive(){return Ue()}})),ne(At=>{var Ct=Ue()?"flex":"none",xt=!Ue();return Ct!==At.e&&Ci(st,"display",At.e=Ct),xt!==At.t&&Fe(st,"aria-hidden",At.t=xt),At},{e:void 0,t:void 0}),st})()}})}})},get children(){var fe=wee();return C(fe,S(MX,{get instanceId(){return e.instance.id}})),fe}})}}),we(()=>Is())]}}),null),Z})();return[(()=>{var Z=Mee();return C(Z,S(W,{get when(){return In()},get fallback(){return S(OX,{get instance(){return e.instance}})},children:gr})),Z})(),S(sZ,{get open(){return pt()},onClose:()=>zA(e.instance.id),get commands(){return tt()},get onExecute(){return e.onExecuteCommand}}),S(cee,{get open(){return re()},get instanceId(){return e.instance.id},get process(){return Ae()},onClose:Ke}),S(hZ,{get instanceId(){return e.instance.id},get isOpen(){return Se()},onClose:()=>q(!1)})]};Ht(["click","mousedown","touchstart"]);var Wee=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},ZA={},Qr={};let lE;const qee=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];Qr.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};Qr.getSymbolTotalCodewords=function(t){return qee[t]};Qr.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};Qr.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');lE=t};Qr.isKanjiModeEnabled=function(){return typeof lE<"u"};Qr.toSJIS=function(t){return lE(t)};var nm={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,i){if(e.isValid(r))return r;try{return t(r)}catch{return i}}})(nm);function JA(){this.buffer=[],this.length=0}JA.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var Kee=JA;function _d(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}_d.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};_d.prototype.get=function(e,t){return this.data[e*this.size+t]};_d.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};_d.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var Qee=_d,ew={};(function(e){const t=Qr.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,s=t(r),o=s===145?26:Math.ceil((s-13)/(2*i-2))*2,a=[s-7];for(let l=1;l<i-1;l++)a[l]=a[l-1]-o;return a.push(6),a.reverse()},e.getPositions=function(r){const i=[],s=e.getRowColCoords(r),o=s.length;for(let a=0;a<o;a++)for(let l=0;l<o;l++)a===0&&l===0||a===0&&l===o-1||a===o-1&&l===0||i.push([s[a],s[l]]);return i}})(ew);var tw={};const jee=Qr.getSymbolSize,cy=7;tw.getPositions=function(t){const n=jee(t);return[[0,0],[n-cy,0],[0,n-cy]]};var nw={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const s=i.size;let o=0,a=0,l=0,c=null,d=null;for(let u=0;u<s;u++){a=l=0,c=d=null;for(let _=0;_<s;_++){let m=i.get(u,_);m===c?a++:(a>=5&&(o+=t.N1+(a-5)),c=m,a=1),m=i.get(_,u),m===d?l++:(l>=5&&(o+=t.N1+(l-5)),d=m,l=1)}a>=5&&(o+=t.N1+(a-5)),l>=5&&(o+=t.N1+(l-5))}return o},e.getPenaltyN2=function(i){const s=i.size;let o=0;for(let a=0;a<s-1;a++)for(let l=0;l<s-1;l++){const c=i.get(a,l)+i.get(a,l+1)+i.get(a+1,l)+i.get(a+1,l+1);(c===4||c===0)&&o++}return o*t.N2},e.getPenaltyN3=function(i){const s=i.size;let o=0,a=0,l=0;for(let c=0;c<s;c++){a=l=0;for(let d=0;d<s;d++)a=a<<1&2047|i.get(c,d),d>=10&&(a===1488||a===93)&&o++,l=l<<1&2047|i.get(d,c),d>=10&&(l===1488||l===93)&&o++}return o*t.N3},e.getPenaltyN4=function(i){let s=0;const o=i.data.length;for(let l=0;l<o;l++)s+=i.data[l];return Math.abs(Math.ceil(s*100/o/5)-10)*t.N4};function n(r,i,s){switch(r){case e.Patterns.PATTERN000:return(i+s)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return s%3===0;case e.Patterns.PATTERN011:return(i+s)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(s/3))%2===0;case e.Patterns.PATTERN101:return i*s%2+i*s%3===0;case e.Patterns.PATTERN110:return(i*s%2+i*s%3)%2===0;case e.Patterns.PATTERN111:return(i*s%3+(i+s)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,s){const o=s.size;for(let a=0;a<o;a++)for(let l=0;l<o;l++)s.isReserved(l,a)||s.xor(l,a,n(i,l,a))},e.getBestMask=function(i,s){const o=Object.keys(e.Patterns).length;let a=0,l=1/0;for(let c=0;c<o;c++){s(c),e.applyMask(c,i);const d=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(c,i),d<l&&(l=d,a=c)}return a}})(nw);var rm={};const Us=nm,qd=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Kd=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];rm.getBlocksCount=function(t,n){switch(n){case Us.L:return qd[(t-1)*4+0];case Us.M:return qd[(t-1)*4+1];case Us.Q:return qd[(t-1)*4+2];case Us.H:return qd[(t-1)*4+3];default:return}};rm.getTotalCodewordsCount=function(t,n){switch(n){case Us.L:return Kd[(t-1)*4+0];case Us.M:return Kd[(t-1)*4+1];case Us.Q:return Kd[(t-1)*4+2];case Us.H:return Kd[(t-1)*4+3];default:return}};var rw={},im={};const Sc=new Uint8Array(512),s_=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)Sc[n]=t,s_[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Sc[n]=Sc[n-255]})();im.log=function(t){if(t<1)throw new Error("log("+t+")");return s_[t]};im.exp=function(t){return Sc[t]};im.mul=function(t,n){return t===0||n===0?0:Sc[s_[t]+s_[n]]};(function(e){const t=im;e.mul=function(r,i){const s=new Uint8Array(r.length+i.length-1);for(let o=0;o<r.length;o++)for(let a=0;a<i.length;a++)s[o+a]^=t.mul(r[o],i[a]);return s},e.mod=function(r,i){let s=new Uint8Array(r);for(;s.length-i.length>=0;){const o=s[0];for(let l=0;l<i.length;l++)s[l]^=t.mul(i[l],o);let a=0;for(;a<s.length&&s[a]===0;)a++;s=s.slice(a)}return s},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let s=0;s<r;s++)i=e.mul(i,new Uint8Array([1,t.exp(s)]));return i}})(rw);const iw=rw;function cE(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}cE.prototype.initialize=function(t){this.degree=t,this.genPoly=iw.generateECPolynomial(this.degree)};cE.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=iw.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const s=new Uint8Array(this.degree);return s.set(r,i),s}return r};var Xee=cE,sw={},io={},dE={};dE.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var Qi={};const ow="[0-9]+",Zee="[A-Z $%*+\\-./:]+";let Yc="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Yc=Yc.replace(/u/g,"\\u");const Jee="(?:(?![A-Z0-9 $%*+\\-./:]|"+Yc+`)(?:.|[\r
175
+ `)}function We(de){const ge=(de??"").replace(/\r/g,""),Ke=(ge.length>L?ge.slice(0,L):ge).replace(/^\n+/,"").replace(/\n+$/,"");if(!Ke)return;const Pe="```\n"+Ke+"\n```\n\n";se(Pe)}const Oe=()=>!!(e.isSessionBusy&&e.onAbortSession),je=()=>r().length>0,dt=()=>je()&&(o()===-1||o()<r().length-1),Lt=()=>o()>=0,be=()=>{if(e.disabled)return!1;const de=t().trim().length>0;return V()==="shell"?de:de||w().length>0},ee=()=>V()==="shell"?{key:"Esc",text:"to exit shell mode"}:{key:"!",text:"Shell mode"},Re=()=>({key:"/",text:"Commands"}),He=()=>t().length===0,qe=()=>hR();return(()=>{var de=FJ(),ge=de.firstChild,Ce=ge.firstChild,Ke=Ce.firstChild,Pe=Ke.firstChild,Be=Pe.firstChild,nt=Be.nextSibling,pt=Ce.nextSibling,at=pt.firstChild,mt=at.nextSibling;ge.addEventListener("drop",ce),ge.addEventListener("dragleave",ue),ge.addEventListener("dragover",he),C(ge,S(W,{get when(){return we(()=>!!u())()&&qe()},get children(){return S(TJ,{get open(){return u()},get mode(){return m()},onClose:z,onSelect:Q,get agents(){return P()},get commands(){return YS(e.instanceId)},get instanceClient(){return qe().client},get searchQuery(){return p()},textareaRef:R,get workspaceId(){return e.instanceId}})}}),Ce),Be.addEventListener("blur",()=>d(!1)),Be.addEventListener("focus",()=>d(!0)),Be.addEventListener("paste",Ae),Be.$$keydown=ie,Be.$$input=te;var bt=R;return typeof bt=="function"?wt(bt,Be):R=Be,Fe(Be,"spellcheck",!1),C(nt,S(RJ,{expandState:$,onToggleExpand:H}),null),C(nt,S(W,{get when(){return je()},get children(){return[(()=>{var Ze=LJ();return Ze.$$click=()=>q(!0),C(Ze,S(ID,{class:"h-5 w-5","aria-hidden":"true"})),ne(()=>Ze.disabled=!dt()),Ze})(),(()=>{var Ze=kJ();return Ze.$$click=()=>ae(!0),C(Ze,S(CD,{class:"h-5 w-5","aria-hidden":"true"})),ne(()=>Ze.disabled=!Lt()),Ze})()]}}),null),C(Pe,S(W,{get when(){return He()},get children(){var Ze=PJ();return C(Ze,S(W,{get when(){return e.escapeInDebounce},get fallback(){return[(()=>{var Ve=BJ(),tt=Ve.firstChild,ut=tt.nextSibling,Yt=ut.nextSibling,ye=Yt.nextSibling,Ie=ye.nextSibling,Ge=Ie.nextSibling;return Ge.nextSibling,C(Ve,S(ir,{children:"Enter"}),tt),C(Ve,S(ir,{shortcut:"cmd+enter"}),ut),C(Ve,S(ir,{children:"@"}),ye),C(Ve,S(ir,{children:"↑↓"}),Ge),Ve})(),S(W,{get when(){return w().length>0},get children(){var Ve=UJ(),tt=Ve.firstChild,ut=tt.nextSibling;return ut.nextSibling,C(Ve,()=>w().length,ut),Ve}}),(()=>{var Ve=ty(),tt=Ve.firstChild,ut=tt.nextSibling;return ut.nextSibling,C(Ve,S(ir,{get children(){return ee().key}}),ut),C(Ve,()=>ee().text,null),Ve})(),S(W,{get when(){return V()!=="shell"},get children(){var Ve=ty(),tt=Ve.firstChild,ut=tt.nextSibling;return ut.nextSibling,C(Ve,S(ir,{get children(){return Re().key}}),ut),C(Ve,()=>Re().text,null),Ve}}),S(W,{get when(){return V()==="shell"},get children(){return ey()}})]},get children(){return[(()=>{var Ve=MJ(),tt=Ve.firstChild,ut=tt.nextSibling;return ut.nextSibling,C(Ve,S(ir,{children:"Esc"}),ut),Ve})(),S(W,{get when(){return V()==="shell"},get children(){return ey()}})]}})),ne(()=>rt(Ze,`prompt-input-overlay ${V()==="shell"?"shell-mode":""}`)),Ze}}),null),at.$$click=N,mt.$$click=re,C(mt,S(W,{get when(){return V()==="shell"},get fallback(){return GJ()},get children(){return $J()}})),ne(Ze=>{var Ve=`prompt-input-wrapper relative ${b()?"border-2":""}`,tt=b()?"border-color: var(--accent-primary); background-color: rgba(0, 102, 255, 0.05);":"",ut=`prompt-input-field-container ${$()==="expanded"?"is-expanded":""}`,Yt=`prompt-input-field ${$()==="expanded"?"is-expanded":""}`,ye=`prompt-input ${V()==="shell"?"shell-mode":""} ${$()==="expanded"?"is-expanded":""}`,Ie=D(),Ge=e.disabled,Qe=$()==="expanded"?15:4,ct=!Oe(),it=`send-button ${V()==="shell"?"shell-mode":""}`,gt=!be();return Ve!==Ze.e&&rt(ge,Ze.e=Ve),Ze.t=ri(ge,tt,Ze.t),ut!==Ze.a&&rt(Ke,Ze.a=ut),Yt!==Ze.o&&rt(Pe,Ze.o=Yt),ye!==Ze.i&&rt(Be,Ze.i=ye),Ie!==Ze.n&&Fe(Be,"placeholder",Ze.n=Ie),Ge!==Ze.s&&(Be.disabled=Ze.s=Ge),Qe!==Ze.h&&Fe(Be,"rows",Ze.h=Qe),ct!==Ze.r&&(at.disabled=Ze.r=ct),it!==Ze.d&&rt(mt,Ze.d=it),gt!==Ze.l&&(mt.disabled=Ze.l=gt),Ze},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0}),ne(()=>Be.value=t()),de})()}Ht(["input","keydown","click"]);var HJ=x('<div class="flex items-center justify-center h-full"><div class="text-center text-gray-500">Session not found'),YJ=x('<div class="flex flex-wrap items-center gap-1.5 border-t px-3 py-2"style=border-color:var(--border-base)>'),zJ=x("<div class=session-view>"),WJ=x('<button type=button class=attachment-expand aria-label="Expand pasted text"title="Insert pasted text">'),qJ=x('<div class=attachment-chip><span class=font-mono></span><button type=button class=attachment-remove aria-label="Remove attachment">×');const lo=vt("session");function KJ(e){return(e==null?void 0:e.type)==="text"&&typeof e.text=="string"}const QJ=e=>{const t=()=>e.activeSessions.get(e.sessionId),n=F(()=>HU(e.instanceId,e.sessionId)),r=F(()=>Ut.getOrCreate(e.instanceId)),i=F(()=>{const y=t();return y?qU(e.instanceId,y.id):!1}),s=F(()=>{const y=t();return y?!!(y.pendingPermission||y.pendingQuestion):!1}),o=F(()=>Vf(e.instanceId,e.sessionId));function a(y){if(y.source.type!=="text")return;const v=c==null?void 0:c.querySelector(".prompt-input"),O=y.source.value,T=y.display.match(/pasted #(\d+)/),I=T?`[pasted #${T[1]}]`:null,k=(v==null?void 0:v.value)??"";let A=k,V=null;if(I){const B=k.indexOf(I);B!==-1&&(A=k.substring(0,B)+O+k.substring(B+I.length),V=B+O.length)}if(A===k)if(v){const B=v.selectionStart,$=v.selectionEnd;A=k.substring(0,B)+O+k.substring($),V=B+O.length}else A=k+O;v&&(v.value=A,v.dispatchEvent(new Event("input",{bubbles:!0})),v.focus(),V!==null&&v.setSelectionRange(V,V)),Ec(e.instanceId,e.sessionId,y.id)}let l,c;function d(){l&&requestAnimationFrame(()=>{requestAnimationFrame(()=>l==null?void 0:l())})}J(()=>{e.isActive&&d()});let u=null;J(()=>{const y=t();y&&Pu(e.instanceId,y.id).catch(v=>lo.error("Failed to load messages",v))});function _(y){return u=y,()=>{u===y&&(u=null)}}function m(y,v){u&&u(y,v)}async function g(y,v){d(),await ZM(e.instanceId,e.sessionId,y,v)}async function p(y){await eP(e.instanceId,e.sessionId,y)}async function E(){const y=t();if(y)try{await zT(e.instanceId,y.id),lo.info("Abort requested",{instanceId:e.instanceId,sessionId:y.id})}catch(v){lo.error("Failed to abort session",v),Gs("Failed to stop session",{title:"Stop failed",detail:v instanceof Error?v.message:String(v),variant:"error"})}}function h(y){const v=r().getMessage(y);if(v&&v.role==="user"){const T=v.partIds.map(I=>{var k;return(k=v.parts[I])==null?void 0:k.data}).filter(I=>!!I).filter(KJ);if(T.length>0)return T.map(I=>I.text).join(`
176
+ `)}return null}async function f(y){const v=Et().get(e.instanceId);if(!(!v||!v.client))try{await An(v.client.session.revert({sessionID:e.sessionId,messageID:y}),"session.revert");const O=h(y);if(O){const T=c==null?void 0:c.querySelector(".prompt-input");T&&(T.value=O,T.dispatchEvent(new Event("input",{bubbles:!0})),T.focus())}}catch(O){lo.error("Failed to revert message",O),Gs("Failed to revert to message",{title:"Revert failed",variant:"error"})}}async function b(y){if(!y){lo.warn("Fork requires a user message id");return}const v=h(y);try{const O=await TU(e.instanceId,e.sessionId,{messageId:y}),T=O.parentId??O.id;if(Ss(e.instanceId,T),O.parentId&&Es(e.instanceId,O.id),await Pu(e.instanceId,O.id).catch(I=>lo.error("Failed to load forked session messages",I)),v){const I=c==null?void 0:c.querySelector(".prompt-input");I&&(I.value=v,I.dispatchEvent(new Event("input",{bubbles:!0})),I.focus())}}catch(O){lo.error("Failed to fork session",O),Gs("Failed to fork session",{title:"Fork failed",variant:"error"})}}return S(W,{get when(){return t()},get fallback(){return HJ()},children:y=>{const v=y();return v?(()=>{var O=zJ(),T=c;return typeof T=="function"?wt(T,O):c=O,C(O,S(sJ,{get instanceId(){return e.instanceId},get sessionId(){return v.id},get loading(){return n()},onRevert:f,onFork:b,get isActive(){return e.isActive},registerScrollToBottom:I=>{l=I,e.isActive&&d()},get showSidebarToggle(){return e.showSidebarToggle},get onSidebarToggle(){return e.onSidebarToggle},get forceCompactStatusLayout(){return e.forceCompactStatusLayout},onQuoteSelection:m}),null),C(O,S(W,{get when(){return o().length>0},get children(){var I=YJ();return C(I,S(_t,{get each(){return o()},children:k=>{const A=k.source.type==="text";return(()=>{var V=qJ(),B=V.firstChild,$=B.nextSibling;return C(B,()=>k.display),C(V,S(W,{when:A,get children(){var M=WJ();return M.$$click=()=>a(k),C(M,S(BD,{class:"h-3 w-3","aria-hidden":"true"})),M}}),$),$.$$click=()=>Ec(e.instanceId,e.sessionId,k.id),ne(()=>Fe(V,"title",k.source.type==="file"?k.source.path:void 0)),V})()}})),I}}),null),C(O,S(VJ,{get instanceId(){return e.instanceId},get instanceFolder(){return e.instanceFolder},get sessionId(){return v.id},onSend:g,onRunShell:p,get escapeInDebounce(){return e.escapeInDebounce},get isSessionBusy(){return i()},get disabled(){return s()},onAbortSession:E,registerQuoteHandler:_}),null),O})():null}})};Ht(["click"]);const[jJ,aE]=U(new Map);function XJ(e,t){aE(n=>{const r=new Map(n);return r.set(e,t),r})}function ZJ(e,t){aE(n=>{const r=new Map(n),i=r.get(e)??[],s=i.findIndex(a=>a.id===t.id),o=s>=0?[...i.slice(0,s),t,...i.slice(s+1)]:[...i,t];return r.set(e,o),r})}function JJ(e,t){aE(n=>{const r=new Map(n),i=r.get(e)??[];return r.set(e,i.filter(s=>s.id!==t)),r})}async function eee(e){const t=await vn.listBackgroundProcesses(e);XJ(e,t.processes)}function tee(e){return jJ().get(e)??[]}wn.onBackgroundProcessUpdated=(e,t)=>{var r;const n=(r=t.properties)==null?void 0:r.process;n&&ZJ(e,n)};wn.onBackgroundProcessRemoved=(e,t)=>{var r;const n=(r=t.properties)==null?void 0:r.processId;n&&JJ(e,n)};var nee=x('<span class="text-xs text-secondary block"> · '),ree=x('<span class="text-xs text-secondary mt-1 block truncate">'),iee=x('<div class="flex items-start justify-between px-6 py-4 border-b border-base gap-4"><div class="flex-1 min-w-0"></div><button type=button class="button-tertiary flex-shrink-0">Close'),see=x('<p class="text-xs text-secondary">Loading output...'),oee=x('<p class="text-xs text-secondary mb-2">Output truncated for display.'),ry=x('<pre class="text-xs whitespace-pre-wrap break-all text-primary bg-surface-secondary border border-base rounded-md p-4 font-mono">'),aee=x('<div class="flex-1 overflow-auto p-6">'),lee=x('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">');function cee(e){const[t,n]=U(""),[r,i]=U(""),[s,o]=U(!1),[a,l]=U(!1),[c,d]=U(!1);let u=$A();return J(()=>{const _=e.process;if(!e.open||!_)return;let m=null,g=!0,p="";const E=f=>{p=f,n(f)},h=f=>{p+=f,n(p)};o(!1),i(""),E(""),u.reset(),d(!0),vn.fetchBackgroundProcessOutput(e.instanceId,_.id,{method:"full",maxBytes:void 0}).then(f=>{if(!g)return;E(f.content),l(f.truncated),hc(f.content)?(o(!0),u.reset(),i(u.render(f.content))):(o(!1),i(""),u.reset())}).catch(()=>{g&&(E("Failed to load output."),o(!1),i(""))}).finally(()=>{g&&d(!1)}),m=new EventSource(A0(e.instanceId,_.id),{withCredentials:!0}),m.onmessage=f=>{try{const b=JSON.parse(f.data);if((b==null?void 0:b.type)!=="chunk"||typeof b.content!="string")return;const y=b.content;if(!s()){h(y),hc(y)&&(o(!0),u.reset(),i(u.render(p)));return}h(y);const O=u.render(y);i(T=>`${T}${O}`)}catch{}},Ne(()=>{g=!1,m==null||m.close()})}),S(ft,{get open(){return e.open},onOpenChange:_=>!_&&e.onClose(),modal:!0,get children(){return S(ft.Portal,{get children(){return[S(ft.Overlay,{class:"modal-overlay"}),(()=>{var _=lee();return C(_,S(ft.Content,{class:"modal-surface w-full max-w-5xl max-h-[90vh] flex flex-col overflow-hidden",get children(){return[(()=>{var m=iee(),g=m.firstChild,p=g.nextSibling;return C(g,S(ft.Title,{class:"text-lg font-semibold text-primary",children:"Background Output"}),null),C(g,S(W,{get when(){return e.process},get children(){return[(()=>{var E=nee(),h=E.firstChild;return C(E,()=>{var f;return(f=e.process)==null?void 0:f.title},h),C(E,()=>{var f;return(f=e.process)==null?void 0:f.id},null),E})(),(()=>{var E=ree();return C(E,()=>{var h;return(h=e.process)==null?void 0:h.command}),ne(()=>{var h;return Fe(E,"title",(h=e.process)==null?void 0:h.command)}),E})()]}}),null),Fn(p,"click",e.onClose,!0),m})(),(()=>{var m=aee();return C(m,S(W,{get when(){return c()},get children(){return see()}}),null),C(m,S(W,{get when(){return!c()},get children(){return[S(W,{get when(){return a()},get children(){return oee()}}),S(W,{get when(){return s()},get fallback(){return(()=>{var g=ry();return C(g,t),g})()},get children(){var g=ry();return ne(()=>g.innerHTML=r()),g}})]}}),null),m})()]}})),_})()]}})}})}Ht(["click"]);const Hf="opencode:session-sidebar-request";function ya(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(Hf,{detail:e}))}var dee=x('<div class="flex flex-col h-full min-h-0"><div class="flex items-start justify-between gap-2 px-4 py-3 border-b border-base"><div class="flex flex-col gap-1"><span class="session-sidebar-title text-sm font-semibold uppercase text-primary">Sessions</span><div class=session-sidebar-shortcuts></div></div><div class="flex items-center gap-2"></div></div><div class="session-sidebar flex flex-col flex-1 min-h-0">'),uee=x('<div class="session-sidebar-controls px-4 py-4 border-t border-base flex flex-col gap-3"><div class=sidebar-selector-hints aria-hidden=true><span class="hint sidebar-selector-hint sidebar-selector-hint--left"></span><span class="hint sidebar-selector-hint sidebar-selector-hint--right">'),_ee=x('<p class="text-xs text-secondary">Select a session to view plan.'),mee=x('<p class="text-xs text-secondary">Nothing planned yet.'),gee=x('<p class="text-xs text-secondary">No background processes.'),fee=x('<div class="flex flex-col gap-2">'),pee=x("<span>Output: <!>KB"),hee=x('<div class="rounded-md border border-base bg-surface-secondary p-2 flex flex-col gap-2"><div class="flex flex-col gap-1"><span class="text-xs font-semibold text-primary"></span><div class="flex flex-wrap gap-2 text-[11px] text-secondary"><span>Status: </span></div></div><div class="grid grid-cols-3 gap-2"><button type=button class="button-tertiary w-full p-1 inline-flex items-center justify-center"aria-label=Output title=Output></button><button type=button class="button-tertiary w-full p-1 inline-flex items-center justify-center"aria-label=Stop title=Stop></button><button type=button class="button-tertiary w-full p-1 inline-flex items-center justify-center"aria-label=Terminate title=Terminate>'),Eee=x('<div class="flex flex-col h-full"><div class="flex items-center justify-between px-4 py-2 border-b border-base"><div class="flex items-center gap-2"></div></div><div class="flex-1 overflow-y-auto">'),See=x("<span>"),bee=x('<div class="session-resize-handle session-resize-handle--left"role=presentation aria-hidden=true>'),vee=x('<div class="session-resize-handle session-resize-handle--right"role=presentation aria-hidden=true>'),yee=x('<div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Used</span><span class="font-semibold text-primary">'),Tee=x('<div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Avail</span><span class="font-semibold text-primary">'),Cee=x('<div class="session-toolbar-left flex items-center gap-3 min-w-0">'),Ree=x('<div class="session-toolbar-center flex-1 flex items-center justify-center gap-2 min-w-[160px]"><button type=button class="connection-status-button px-2 py-0.5 text-xs"aria-label="Open command palette"style="flex:0 0 auto;width:auto">Command Palette</button><span class=connection-status-shortcut-hint>'),Iee=x('<span class="status-indicator connected"><span class=status-dot></span><span class=status-text>Connected'),Oee=x('<span class="status-indicator connecting"><span class=status-dot></span><span class=status-text>Connecting...'),Nee=x('<span class="status-indicator disconnected"><span class=status-dot></span><span class=status-text>Disconnected'),Aee=x('<div class="session-toolbar-right flex items-center gap-3"><div class="connection-status-meta flex items-center gap-3">'),wee=x('<div class="info-view-pane flex flex-col flex-1 min-h-0 overflow-y-auto">'),xee=x('<div class="session-shell-panels flex flex-col flex-1 min-h-0 overflow-x-hidden">'),Dee=x('<div class="flex flex-col w-full gap-1.5"><div class="flex flex-wrap items-center justify-between gap-2 w-full"><div class="flex flex-wrap items-center gap-1 justify-center"><button type=button class="connection-status-button px-2 py-0.5 text-xs"aria-label="Open command palette"style="flex:0 0 auto;width:auto">Command Palette</button><span class=connection-status-shortcut-hint></span><span><span class=status-dot></span></span></div></div><div class="flex flex-wrap items-center justify-center gap-2 pb-1"><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Used</span><span class="font-semibold text-primary"></span></div><div class="inline-flex items-center gap-1 rounded-full border border-base px-2 py-0.5 text-xs text-primary"><span class="uppercase text-[10px] tracking-wide text-primary/70">Avail</span><span class="font-semibold text-primary">'),Lee=x('<div class="flex items-center justify-center h-full"><div class="text-center text-gray-500 dark:text-gray-400"><p class=mb-2>No session selected</p><p class=text-sm>Select a session to view messages'),kee=x('<div class="session-cache-pane flex flex-col flex-1 min-h-0">'),Mee=x('<div class="instance-shell2 flex flex-col flex-1 min-h-0">');const $l=vt("session"),Pee=280,$ee=220,Fee=360,Bee=260,Uee=200,Gee=380,iy=5,sy=56,oy="opencode-session-sidebar-width-v8",ay="opencode-session-right-drawer-width-v1",Vee="opencode-session-left-drawer-pinned-v1",Hee="opencode-session-right-drawer-pinned-v1",Wd=e=>Math.min(Fee,Math.max($ee,e)),ly=e=>Math.min(Gee,Math.max(Uee,e)),XA=e=>e==="left"?Vee:Hee;function gg(e,t){if(typeof window>"u")return t;const n=window.localStorage.getItem(XA(e));return n==="true"?!0:n==="false"?!1:t}function Yee(e,t){typeof window>"u"||window.localStorage.setItem(XA(e),t?"true":"false")}const zee=e=>{const[t,n]=U(Pee),[r,i]=U(Bee),[s,o]=U(!0),[a,l]=U(!0),[c,d]=U(!0),[u,_]=U(!0),[m,g]=U([]),[p,E]=U([]),[h,f]=U(null),[b,y]=U(0),[v,O]=U(0),[T,I]=U(null),[k,A]=U(null),[V,B]=U(null),[$,M]=U(null),[L,R]=U(null),[D,w]=U(0),[P,j]=U(0),[le,me]=U(["plan","background-processes","mcp","lsp","plugins"]),[Ae,ie]=U(null),[re,Ee]=U(!1),[Se,q]=U(!1),ae=F(()=>Ut.getOrCreate(e.instance.id)),N=xb("(min-width: 1280px)"),H=xb("(min-width: 768px)"),te=F(()=>N()?"desktop":H()?"tablet":"phone"),Q=F(()=>te()==="phone"),z=F(()=>te()==="desktop"),he=F(()=>te()!=="phone"),ue=(Z,fe)=>{Z==="left"&&!z()||Z==="right"&&!he()||Yee(Z,fe)};J(()=>{const Z=e.instance.id;eee(Z).catch(fe=>{$l.warn("Failed to load background processes",fe)})}),J(()=>{switch(te()){case"desktop":{const Z=gg("left",!0),fe=gg("right",!0);o(Z),l(Z),d(fe),_(fe);break}case"tablet":{const Z=gg("right",!0);o(!1),l(!1),d(Z),_(Z);break}default:o(!1),l(!1),d(!1),_(!1);break}});const ce=()=>{if(typeof window>"u")return;const Z=h();if(!Z)return;const fe=Z.getBoundingClientRect(),Ue=Z.querySelector(".session-toolbar"),st=(Ue==null?void 0:Ue.offsetHeight)??sy;y(fe.top+st),O(Math.max(0,fe.height-st))};Tn(()=>{if(typeof window>"u")return;const Z=window.localStorage.getItem(oy);if(Z){const st=Number.parseInt(Z,10);Number.isFinite(st)&&n(Wd(st))}const fe=window.localStorage.getItem(ay);if(fe){const st=Number.parseInt(fe,10);Number.isFinite(st)&&i(ly(st))}const Ue=()=>{const st=Wd(window.innerWidth*.3);n(At=>Wd(At||st)),ce()};Ue(),window.addEventListener("resize",Ue),Ne(()=>window.removeEventListener("resize",Ue))}),Tn(()=>{if(typeof window>"u")return;const Z=fe=>{const Ue=fe.detail;!Ue||Ue.instanceId!==e.instance.id||Yt(Ue.action)};window.addEventListener(Hf,Z),Ne(()=>window.removeEventListener(Hf,Z))}),J(()=>{typeof window>"u"||window.localStorage.setItem(oy,t().toString())}),J(()=>{typeof window>"u"||window.localStorage.setItem(ay,r().toString())}),J(()=>{e.tabBarOffset,requestAnimationFrame(()=>ce())});const se=F(()=>Ft().get(e.instance.id)??new Map),ke=F(()=>AR(e.instance.id)),We=F(()=>{const Z=Qg().get(e.instance.id);if(!Z)return new Map;const fe=FU(e.instance.id,Z);return new Map(fe.map(Ue=>[Ue.id,Ue]))}),Oe=F(()=>qa().get(e.instance.id)||null);F(()=>Qg().get(e.instance.id)||null);const je=F(()=>{const Z=Oe();return!Z||Z==="info"?null:We().get(Z)??null}),dt=F(()=>{const Z=Oe();if(!Z)return null;const fe=ae();return(fe==null?void 0:fe.getSessionUsage(Z))??null}),Lt=F(()=>{const Z=Oe();return Z?Kp(e.instance.id,Z)??null:null}),be=F(()=>{const Z=dt(),fe=Lt();return{used:(Z==null?void 0:Z.actualUsageTokens)??(fe==null?void 0:fe.actualUsageTokens)??0,avail:(fe==null?void 0:fe.contextAvailableTokens)??null}}),ee=F(()=>{const Z=Oe();if(!Z||Z==="info")return null;const fe=ae();return fe?fe.state.latestTodos[Z]??null:null}),Re=F(()=>{var xt;const Z=ee();if(!Z)return null;const fe=ae();if(!fe)return null;const Ue=fe.getMessage(Z.messageId);if(!Ue)return null;const st=(xt=Ue.parts)==null?void 0:xt[Z.partId],At=st==null?void 0:st.data;if(!At||At.type!=="tool"||At.tool!=="todowrite")return null;const Ct=At.state;return!Ct||Ct.status!=="completed"?null:Ct}),He=F(()=>tee(e.instance.id)),qe=()=>wn.getStatus(e.instance.id),de=()=>{const Z=qe();return Z==="connecting"?"connecting":Z==="connected"?"connected":"disconnected"},ge=()=>{YA(e.instance.id)},Ce=Z=>{ie(Z),Ee(!0)},Ke=()=>{Ee(!1),ie(null)},Pe=async Z=>{try{await vn.stopBackgroundProcess(e.instance.id,Z)}catch(fe){$l.warn("Failed to stop background process",fe)}},Be=async Z=>{try{await vn.terminateBackgroundProcess(e.instance.id,Z)}catch(fe){$l.warn("Failed to terminate background process",fe)}},nt=F(()=>e.paletteCommands()),pt=F(()=>pj(e.instance.id)),at=F(()=>[Hn.get("session-prev"),Hn.get("session-next")].filter(Z=>!!Z));let mt=0;const[bt,Ze]=U(null),Ve=(Z,fe)=>{Z.dispatchEvent(new KeyboardEvent("keydown",{key:fe.key,code:fe.code,keyCode:fe.keyCode,which:fe.keyCode,bubbles:!0,cancelable:!0}))},tt=()=>{var fe;const Z=(fe=T())==null?void 0:fe.querySelector("[data-agent-selector]");return Z?(Z.focus(),setTimeout(()=>Ve(Z,{key:"Enter",code:"Enter",keyCode:13}),10),!0):!1},ut=()=>{var fe;const Z=(fe=T())==null?void 0:fe.querySelector("[data-model-selector]");return Z?(Z.focus(),setTimeout(()=>Ve(Z,{key:"ArrowDown",code:"ArrowDown",keyCode:40}),10),!0):!1};J(()=>{const Z=bt();if(!Z)return;const fe=Z.action;if(!!!T())return;if(fe==="show-session-list"){Ze(null);return}(fe==="focus-agent-selector"?tt():ut())&&Ze(null)});const Yt=Z=>{Ze({action:Z,id:mt++}),!s()&&!a()&&(l(!0),ce())},ye=()=>{let Z=!1;return!s()&&a()&&(l(!1),Ln(T()),er(V()),Z=!0),!c()&&u()&&(_(!1),Ln(k()),er($()),Z=!0),Z};Tn(()=>{if(typeof window>"u")return;const Z=fe=>{fe.key==="Escape"&&ye()&&(fe.preventDefault(),fe.stopPropagation())};window.addEventListener("keydown",Z,!0),Ne(()=>window.removeEventListener("keydown",Z,!0))});const Ie=Z=>{if(Z==="info"){Es(e.instance.id,Z);return}const fe=se().get(Z);if(!fe)return;if(fe.parentId===null){Ss(e.instance.id,Z);return}const Ue=fe.parentId;Ue&&ur(()=>{Ss(e.instance.id,Ue),Es(e.instance.id,Z)})},Ge=Z=>{if(!Z)return;$l.info("Evicting cached session",{instanceId:e.instance.id,sessionId:Z});const fe=Ut.getInstance(e.instance.id);fe==null||fe.clearSession(Z),cj(e.instance.id,Z)},Qe=Z=>{Z.length&&E(fe=>{const Ue=new Set(fe),st=[...fe];return Z.forEach(At=>{Ue.has(At)||(st.push(At),Ue.add(At))}),st})};J(()=>{const Z=p();if(!Z.length)return;const fe=new Set(m()),Ue=[];Z.forEach(st=>{fe.has(st)?Ue.push(st):Ge(st)}),Ue.length!==Z.length&&E(Ue)}),J(()=>{const Z=se(),fe=Oe();g(Ue=>{const st=Ue.filter(Vt=>Vt!=="info"&&Z.has(Vt));(Vt=>{if(!Vt||Vt==="info"||!Z.has(Vt))return;const On=st.indexOf(Vt);On!==-1&&st.splice(On,1),st.unshift(Vt)})(fe);const Ct=st.length>iy?st.slice(0,iy):st,xt=new Set(Ct),Pt=Ue.filter(Vt=>!xt.has(Vt));return Pt.length&&Qe(Pt),Ct})});const ct=F(()=>!s()&&!a()),it=()=>{const Z=h();if(Z)return Z;if(typeof document<"u")return document.body},gt=()=>sy+e.tabBarOffset,yt=()=>{const Z=b();return Z>0?Z:gt()},nn=()=>`${yt()}px`,Rn=()=>{const Z=v();return Z>0?`${Z}px`:`calc(100% - ${yt()}px)`},yr=()=>{if(typeof window>"u"){ce();return}requestAnimationFrame(()=>ce())},Rs=(Z,fe)=>{Z==="left"?n(fe):i(fe),yr()},Lr=Z=>{const fe=L();if(!fe)return;const Ue=P(),st=fe==="left"?Wd:ly,At=fe==="left"?Z-D():D()-Z,Ct=st(Ue+At);Rs(fe,Ct)};function ar(){R(null),document.removeEventListener("mousemove",mi),document.removeEventListener("mouseup",yl),document.removeEventListener("touchmove",Tl),document.removeEventListener("touchend",Cl)}function mi(Z){Z.preventDefault(),Lr(Z.clientX)}function yl(){ar()}function Tl(Z){const fe=Z.touches[0];fe&&(Z.preventDefault(),Lr(fe.clientX))}function Cl(){ar()}const K=(Z,fe)=>{R(Z),w(fe),j(Z==="left"?t():r()),document.addEventListener("mousemove",mi),document.addEventListener("mouseup",yl),document.addEventListener("touchmove",Tl,{passive:!1}),document.addEventListener("touchend",Cl)},_e=Z=>fe=>{fe.preventDefault(),K(Z,fe.clientX)},Ye=Z=>fe=>{const Ue=fe.touches[0];Ue&&(fe.preventDefault(),K(Z,Ue.clientX))};Ne(()=>{ar()});const Xe=F(()=>s()?"pinned":a()?"floating-open":"floating-closed"),ot=F(()=>c()?"pinned":u()?"floating-open":"floating-closed"),kt=()=>{const Z=Xe();return Z==="pinned"?"Left drawer pinned":Z==="floating-closed"?"Open left drawer":"Close left drawer"},Nt=()=>{const Z=ot();return Z==="pinned"?"Right drawer pinned":Z==="floating-closed"?"Open right drawer":"Close right drawer"},zt=()=>Xe()==="floating-closed"?S(Db,{fontSize:"small"}):S(Lb,{fontSize:"small"}),Rt=()=>ot()==="floating-closed"?S(Db,{fontSize:"small",sx:{transform:"scaleX(-1)"}}):S(Lb,{fontSize:"small",sx:{transform:"scaleX(-1)"}}),xn=()=>{Ln(T()),ur(()=>{o(!0),l(!0)}),ue("left",!0),ce()},Ot=()=>{Ln(T()),ur(()=>{o(!1),l(!0)}),ue("left",!1),ce()},Dn=()=>{Ln(k()),ur(()=>{d(!0),_(!0)}),ue("right",!0),ce()},gi=()=>{Ln(k()),ur(()=>{d(!1),_(!0)}),ue("right",!1),ce()},jt=()=>{const Z=Xe();if(Z!=="pinned"){if(Z==="floating-closed"){l(!0),ce();return}Ln(T()),l(!1),er(V()),ce()}},jr=()=>{const Z=ot();if(Z!=="pinned"){if(Z==="floating-closed"){_(!0),ce();return}Ln(k()),_(!1),er($()),ce()}},er=Z=>{Z&&requestAnimationFrame(()=>{Z.focus()})},Ln=Z=>{if(typeof document>"u"||!Z)return;const fe=document.activeElement;fe&&Z.contains(fe)&&fe.blur()},kr=()=>{Xe()!=="pinned"&&(Ln(T()),l(!1),er(V()))},tr=()=>{ot()!=="pinned"&&(Ln(k()),_(!1),er($()))},Mt=()=>yi(be().used),gn=()=>{const Z=be().avail;return typeof Z=="number"?yi(Z):"--"},rn=()=>(()=>{var Z=dee(),fe=Z.firstChild,Ue=fe.firstChild,st=Ue.firstChild,At=st.nextSibling,Ct=Ue.nextSibling,xt=fe.nextSibling;return wt(I,Z),C(At,S(W,{get when(){return at().length},get children(){return S(Qp,{get shortcuts(){return at()},separator:" ",showDescription:!1})}})),C(Ct,S(so,{size:"small",color:"inherit","aria-label":"Instance Info",title:"Instance Info",onClick:()=>Ie("info"),get children(){return S(bz,{fontSize:"small"})}}),null),C(Ct,S(W,{get when(){return!Q()},get children(){return S(so,{size:"small",color:"inherit",get"aria-label"(){return s()?"Unpin left drawer":"Pin left drawer"},onClick:()=>s()?Ot():xn(),get children(){return we(()=>!!s())()?S(kb,{fontSize:"small"}):S(Mb,{fontSize:"small"})}})}}),null),C(xt,S(Dj,{get instanceId(){return e.instance.id},get threads(){return ke()},get activeSessionId(){return Oe()},onSelect:Ie,onNew:()=>{const Pt=e.onNewSession();Pt instanceof Promise&&Pt.catch(Vt=>$l.error("Failed to create session:",Vt))},showHeader:!1,showFooter:!1}),null),C(xt,S(oY,{}),null),C(xt,S(W,{get when(){return je()},children:Pt=>[S(SZ,{get instanceId(){return e.instance.id},get sessionId(){return Pt().id}}),(()=>{var Vt=uee(),On=Vt.firstChild,fr=On.firstChild,xi=fr.nextSibling;return C(Vt,S(VX,{get instanceId(){return e.instance.id},get sessionId(){return Pt().id},get currentAgent(){return Pt().agent},onAgentChange:Mr=>e.handleSidebarAgentChange(Pt().id,Mr)}),On),C(fr,S(ir,{shortcut:"cmd+shift+a"})),C(xi,S(ir,{shortcut:"cmd+shift+m"})),C(Vt,S(jX,{get instanceId(){return e.instance.id},get sessionId(){return Pt().id},get currentModel(){return Pt().model},onModelChange:Mr=>e.handleSidebarModelChange(Pt().id,Mr)}),null),Vt})()]}),null),Z})(),Xr=()=>{const Ue=[{id:"plan",label:"Plan",render:()=>{const Ct=Oe();if(!Ct||Ct==="info")return _ee();const xt=Re();return xt?S(LA,{state:xt,emptyLabel:"Nothing planned yet.",showStatusLabel:!1}):mee()}},{id:"background-processes",label:"Background Shells",render:()=>{const Ct=He();return Ct.length===0?gee():(()=>{var xt=fee();return C(xt,S(_t,{each:Ct,children:Pt=>(()=>{var Vt=hee(),On=Vt.firstChild,fr=On.firstChild,xi=fr.nextSibling,Mr=xi.firstChild;Mr.firstChild;var ji=On.nextSibling,fn=ji.firstChild,Wn=fn.nextSibling,rr=Wn.nextSibling;return C(fr,()=>Pt.title),C(Mr,()=>Pt.status,null),C(xi,S(W,{get when(){return typeof Pt.outputSizeBytes=="number"},get children(){var sn=pee(),Xi=sn.firstChild,Zi=Xi.nextSibling;return Zi.nextSibling,C(sn,()=>Math.round((Pt.outputSizeBytes??0)/1024),Zi),sn}}),null),fn.$$click=()=>Ce(Pt),C(fn,S(h0,{class:"h-4 w-4"})),Wn.$$click=()=>Pe(Pt.id),C(Wn,S(T0,{class:"h-4 w-4"})),rr.$$click=()=>Be(Pt.id),C(rr,S(al,{class:"h-4 w-4"})),ne(()=>Wn.disabled=Pt.status!=="running"),Vt})()})),xt})()}},{id:"mcp",label:"MCP Servers",render:()=>S(_u,{get initialInstance(){return e.instance},sections:["mcp"],showSectionHeadings:!1,class:"space-y-2"})},{id:"lsp",label:"LSP Servers",render:()=>S(_u,{get initialInstance(){return e.instance},sections:["lsp"],showSectionHeadings:!1,class:"space-y-2"})},{id:"plugins",label:"Plugins",render:()=>S(_u,{get initialInstance(){return e.instance},sections:["plugins"],showSectionHeadings:!1,class:"space-y-2"})}];J(()=>{const Ct=new Set(le());Ue.every(xt=>Ct.has(xt.id))||me(Ue.map(xt=>xt.id))});const st=Ct=>{me(Ct)},At=Ct=>le().includes(Ct);return(()=>{var Ct=Eee(),xt=Ct.firstChild,Pt=xt.firstChild,Vt=xt.nextSibling;return wt(A,Ct),C(xt,S(az,{variant:"subtitle2",class:"uppercase tracking-wide text-xs font-semibold",children:"Status Panel"}),Pt),C(Pt,S(W,{get when(){return!Q()},get children(){return S(so,{size:"small",color:"inherit",get"aria-label"(){return c()?"Unpin right drawer":"Pin right drawer"},onClick:()=>c()?gi():Dn(),get children(){return we(()=>!!c())()?S(kb,{fontSize:"small"}):S(Mb,{fontSize:"small"})}})}})),C(Vt,S(ia.Root,{class:"flex flex-col",collapsible:!0,multiple:!0,get value(){return le()},onChange:st,get children(){return S(_t,{each:Ue,children:On=>S(ia.Item,{get value(){return On.id},class:"w-full border border-base bg-surface-secondary text-primary",get children(){return[S(ia.Header,{get children(){return S(ia.Trigger,{class:"w-full flex items-center justify-between gap-3 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide",get children(){return[(()=>{var fr=See();return C(fr,()=>On.label),fr})(),S(Qc,{get class(){return`h-4 w-4 transition-transform duration-150 ${At(On.id)?"rotate-180":""}`}})]}})}}),S(ia.Content,{class:"w-full px-3 pb-3 text-sm text-primary",get children(){return On.render()}})]}})})}})),Ct})()},nr=()=>{if(s())return S(Kl,{class:"session-sidebar-container",get sx(){return{width:`${t()}px`,flexShrink:0,borderRight:"1px solid var(--border-base)",backgroundColor:"var(--surface-secondary)",height:"100%",minHeight:0,position:"relative"}},get children(){return[(()=>{var Ue=bee();return Fn(Ue,"touchstart",Ye("left"),!0),Fn(Ue,"mousedown",_e("left"),!0),Ue})(),S(rn,{})]}});const Z=it();return S(Nb,{anchor:"left",variant:"temporary",get open(){return a()},onClose:kr,ModalProps:Z?{container:Z}:void 0,get sx(){return{"& .MuiDrawer-paper":{width:Q()?"100vw":`${t()}px`,boxSizing:"border-box",borderRight:Q()?"none":"1px solid var(--border-base)",backgroundColor:"var(--surface-secondary)",backgroundImage:"none",color:"var(--text-primary)",boxShadow:"none",borderRadius:0,top:nn(),height:Rn()},"& .MuiBackdrop-root":{backgroundColor:"transparent"}}},get children(){return S(rn,{})}})},Is=()=>{if(c())return S(Kl,{class:"session-right-panel",get sx(){return{width:`${r()}px`,flexShrink:0,borderLeft:"1px solid var(--border-base)",backgroundColor:"var(--surface-secondary)",height:"100%",minHeight:0,position:"relative"}},get children(){return[(()=>{var Ue=vee();return Fn(Ue,"touchstart",Ye("right"),!0),Fn(Ue,"mousedown",_e("right"),!0),Ue})(),S(Xr,{})]}});const Z=it();return S(Nb,{anchor:"right",variant:"temporary",get open(){return u()},onClose:tr,ModalProps:Z?{container:Z}:void 0,get sx(){return{"& .MuiDrawer-paper":{width:Q()?"100vw":`${r()}px`,boxSizing:"border-box",borderLeft:Q()?"none":"1px solid var(--border-base)",backgroundColor:"var(--surface-secondary)",backgroundImage:"none",color:"var(--text-primary)",boxShadow:"none",borderRadius:0,top:nn(),height:Rn()},"& .MuiBackdrop-root":{backgroundColor:"transparent"}}},get children(){return S(Xr,{})}})},In=F(()=>We().size>0),Os=F(()=>Oe()==="info"),gr=(()=>{var Z=xee();return wt(fe=>{f(fe),ce()},Z),C(Z,S(XH,{position:"sticky",color:"default",elevation:0,class:"border-b border-base",get children(){return S(nz,{variant:"dense",class:"session-toolbar flex flex-wrap items-center gap-2 py-0 min-h-[40px]",get children(){return S(W,{get when(){return!Q()},get fallback(){return(()=>{var fe=Dee(),Ue=fe.firstChild,st=Ue.firstChild,At=st.firstChild,Ct=At.nextSibling,xt=Ct.nextSibling,Pt=Ue.nextSibling,Vt=Pt.firstChild,On=Vt.firstChild,fr=On.nextSibling,xi=Vt.nextSibling,Mr=xi.firstChild,ji=Mr.nextSibling;return C(Ue,S(so,{ref:B,color:"inherit",onClick:jt,get"aria-label"(){return kt()},size:"small",get"aria-expanded"(){return Xe()!=="floating-closed"},get disabled(){return Xe()==="pinned"},get children(){return zt()}}),st),C(st,S(Hv,{get instanceId(){return e.instance.id},onClick:()=>q(!0)}),At),At.$$click=ge,C(Ct,S(ir,{shortcut:"cmd+shift+p"})),C(Ue,S(so,{ref:M,color:"inherit",onClick:jr,get"aria-label"(){return Nt()},size:"small",get"aria-expanded"(){return ot()!=="floating-closed"},get disabled(){return ot()==="pinned"},get children(){return Rt()}}),null),C(fr,Mt),C(ji,gn),ne(fn=>{var Wn=`status-indicator ${de()}`,rr=`Connection ${qe()}`;return Wn!==fn.e&&rt(xt,fn.e=Wn),rr!==fn.t&&Fe(xt,"aria-label",fn.t=rr),fn},{e:void 0,t:void 0}),fe})()},get children(){return[(()=>{var fe=Cee();return C(fe,S(so,{ref:B,color:"inherit",onClick:jt,get"aria-label"(){return kt()},size:"small",get"aria-expanded"(){return Xe()!=="floating-closed"},get disabled(){return Xe()==="pinned"},get children(){return zt()}}),null),C(fe,S(W,{get when(){return!Os()},get children(){return[(()=>{var Ue=yee(),st=Ue.firstChild,At=st.nextSibling;return C(At,Mt),Ue})(),(()=>{var Ue=Tee(),st=Ue.firstChild,At=st.nextSibling;return C(At,gn),Ue})()]}}),null),fe})(),(()=>{var fe=Ree(),Ue=fe.firstChild,st=Ue.nextSibling;return C(fe,S(Hv,{get instanceId(){return e.instance.id},onClick:()=>q(!0)}),Ue),Ue.$$click=ge,C(st,S(ir,{shortcut:"cmd+shift+p"})),fe})(),(()=>{var fe=Aee(),Ue=fe.firstChild;return C(Ue,S(W,{get when(){return qe()==="connected"},get children(){return Iee()}}),null),C(Ue,S(W,{get when(){return qe()==="connecting"},get children(){return Oee()}}),null),C(Ue,S(W,{get when(){return qe()==="error"||qe()==="disconnected"},get children(){return Nee()}}),null),C(fe,S(so,{ref:M,color:"inherit",onClick:jr,get"aria-label"(){return Nt()},size:"small",get"aria-expanded"(){return ot()!=="floating-closed"},get disabled(){return ot()==="pinned"},get children(){return Rt()}}),null),fe})()]}})}})}}),null),C(Z,S(Kl,{sx:{display:"flex",flex:1,minHeight:0,overflowX:"hidden"},get children(){return[we(()=>nr()),S(Kl,{component:"main",sx:{flexGrow:1,minHeight:0,display:"flex",flexDirection:"column",overflowX:"hidden"},class:"content-area",get children(){return S(W,{get when(){return Os()},get fallback(){return S(W,{get when(){return we(()=>m().length>0)()&&Oe()},get fallback(){return Lee()},get children(){return S(_t,{get each(){return m()},children:fe=>{const Ue=()=>Oe()===fe;return(()=>{var st=kee();return Fe(st,"data-session-id",fe),C(st,S(QJ,{sessionId:fe,get activeSessions(){return We()},get instanceId(){return e.instance.id},get instanceFolder(){return e.instance.folder},get escapeInDebounce(){return e.escapeInDebounce},get showSidebarToggle(){return ct()},onSidebarToggle:()=>l(!0),get forceCompactStatusLayout(){return ct()},get isActive(){return Ue()}})),ne(At=>{var Ct=Ue()?"flex":"none",xt=!Ue();return Ct!==At.e&&Ci(st,"display",At.e=Ct),xt!==At.t&&Fe(st,"aria-hidden",At.t=xt),At},{e:void 0,t:void 0}),st})()}})}})},get children(){var fe=wee();return C(fe,S(MX,{get instanceId(){return e.instance.id}})),fe}})}}),we(()=>Is())]}}),null),Z})();return[(()=>{var Z=Mee();return C(Z,S(W,{get when(){return In()},get fallback(){return S(OX,{get instance(){return e.instance}})},children:gr})),Z})(),S(sZ,{get open(){return pt()},onClose:()=>zA(e.instance.id),get commands(){return nt()},get onExecute(){return e.onExecuteCommand}}),S(cee,{get open(){return re()},get instanceId(){return e.instance.id},get process(){return Ae()},onClose:Ke}),S(hZ,{get instanceId(){return e.instance.id},get isOpen(){return Se()},onClose:()=>q(!1)})]};Ht(["click","mousedown","touchstart"]);var Wee=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},ZA={},Qr={};let lE;const qee=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];Qr.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};Qr.getSymbolTotalCodewords=function(t){return qee[t]};Qr.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};Qr.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');lE=t};Qr.isKanjiModeEnabled=function(){return typeof lE<"u"};Qr.toSJIS=function(t){return lE(t)};var nm={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,i){if(e.isValid(r))return r;try{return t(r)}catch{return i}}})(nm);function JA(){this.buffer=[],this.length=0}JA.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var Kee=JA;function _d(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}_d.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};_d.prototype.get=function(e,t){return this.data[e*this.size+t]};_d.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};_d.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var Qee=_d,ew={};(function(e){const t=Qr.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,s=t(r),o=s===145?26:Math.ceil((s-13)/(2*i-2))*2,a=[s-7];for(let l=1;l<i-1;l++)a[l]=a[l-1]-o;return a.push(6),a.reverse()},e.getPositions=function(r){const i=[],s=e.getRowColCoords(r),o=s.length;for(let a=0;a<o;a++)for(let l=0;l<o;l++)a===0&&l===0||a===0&&l===o-1||a===o-1&&l===0||i.push([s[a],s[l]]);return i}})(ew);var tw={};const jee=Qr.getSymbolSize,cy=7;tw.getPositions=function(t){const n=jee(t);return[[0,0],[n-cy,0],[0,n-cy]]};var nw={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const s=i.size;let o=0,a=0,l=0,c=null,d=null;for(let u=0;u<s;u++){a=l=0,c=d=null;for(let _=0;_<s;_++){let m=i.get(u,_);m===c?a++:(a>=5&&(o+=t.N1+(a-5)),c=m,a=1),m=i.get(_,u),m===d?l++:(l>=5&&(o+=t.N1+(l-5)),d=m,l=1)}a>=5&&(o+=t.N1+(a-5)),l>=5&&(o+=t.N1+(l-5))}return o},e.getPenaltyN2=function(i){const s=i.size;let o=0;for(let a=0;a<s-1;a++)for(let l=0;l<s-1;l++){const c=i.get(a,l)+i.get(a,l+1)+i.get(a+1,l)+i.get(a+1,l+1);(c===4||c===0)&&o++}return o*t.N2},e.getPenaltyN3=function(i){const s=i.size;let o=0,a=0,l=0;for(let c=0;c<s;c++){a=l=0;for(let d=0;d<s;d++)a=a<<1&2047|i.get(c,d),d>=10&&(a===1488||a===93)&&o++,l=l<<1&2047|i.get(d,c),d>=10&&(l===1488||l===93)&&o++}return o*t.N3},e.getPenaltyN4=function(i){let s=0;const o=i.data.length;for(let l=0;l<o;l++)s+=i.data[l];return Math.abs(Math.ceil(s*100/o/5)-10)*t.N4};function n(r,i,s){switch(r){case e.Patterns.PATTERN000:return(i+s)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return s%3===0;case e.Patterns.PATTERN011:return(i+s)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(s/3))%2===0;case e.Patterns.PATTERN101:return i*s%2+i*s%3===0;case e.Patterns.PATTERN110:return(i*s%2+i*s%3)%2===0;case e.Patterns.PATTERN111:return(i*s%3+(i+s)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,s){const o=s.size;for(let a=0;a<o;a++)for(let l=0;l<o;l++)s.isReserved(l,a)||s.xor(l,a,n(i,l,a))},e.getBestMask=function(i,s){const o=Object.keys(e.Patterns).length;let a=0,l=1/0;for(let c=0;c<o;c++){s(c),e.applyMask(c,i);const d=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(c,i),d<l&&(l=d,a=c)}return a}})(nw);var rm={};const Us=nm,qd=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Kd=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];rm.getBlocksCount=function(t,n){switch(n){case Us.L:return qd[(t-1)*4+0];case Us.M:return qd[(t-1)*4+1];case Us.Q:return qd[(t-1)*4+2];case Us.H:return qd[(t-1)*4+3];default:return}};rm.getTotalCodewordsCount=function(t,n){switch(n){case Us.L:return Kd[(t-1)*4+0];case Us.M:return Kd[(t-1)*4+1];case Us.Q:return Kd[(t-1)*4+2];case Us.H:return Kd[(t-1)*4+3];default:return}};var rw={},im={};const Sc=new Uint8Array(512),s_=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)Sc[n]=t,s_[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Sc[n]=Sc[n-255]})();im.log=function(t){if(t<1)throw new Error("log("+t+")");return s_[t]};im.exp=function(t){return Sc[t]};im.mul=function(t,n){return t===0||n===0?0:Sc[s_[t]+s_[n]]};(function(e){const t=im;e.mul=function(r,i){const s=new Uint8Array(r.length+i.length-1);for(let o=0;o<r.length;o++)for(let a=0;a<i.length;a++)s[o+a]^=t.mul(r[o],i[a]);return s},e.mod=function(r,i){let s=new Uint8Array(r);for(;s.length-i.length>=0;){const o=s[0];for(let l=0;l<i.length;l++)s[l]^=t.mul(i[l],o);let a=0;for(;a<s.length&&s[a]===0;)a++;s=s.slice(a)}return s},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let s=0;s<r;s++)i=e.mul(i,new Uint8Array([1,t.exp(s)]));return i}})(rw);const iw=rw;function cE(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}cE.prototype.initialize=function(t){this.degree=t,this.genPoly=iw.generateECPolynomial(this.degree)};cE.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=iw.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const s=new Uint8Array(this.degree);return s.set(r,i),s}return r};var Xee=cE,sw={},io={},dE={};dE.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var Qi={};const ow="[0-9]+",Zee="[A-Z $%*+\\-./:]+";let Yc="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Yc=Yc.replace(/u/g,"\\u");const Jee="(?:(?![A-Z0-9 $%*+\\-./:]|"+Yc+`)(?:.|[\r
177
177
  ]))+`;Qi.KANJI=new RegExp(Yc,"g");Qi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Qi.BYTE=new RegExp(Jee,"g");Qi.NUMERIC=new RegExp(ow,"g");Qi.ALPHANUMERIC=new RegExp(Zee,"g");const ete=new RegExp("^"+Yc+"$"),tte=new RegExp("^"+ow+"$"),nte=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Qi.testKanji=function(t){return ete.test(t)};Qi.testNumeric=function(t){return tte.test(t)};Qi.testAlphanumeric=function(t){return nte.test(t)};(function(e){const t=dE,n=Qi;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(s,o){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!t.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?s.ccBits[0]:o<27?s.ccBits[1]:s.ccBits[2]},e.getBestModeForData=function(s){return n.testNumeric(s)?e.NUMERIC:n.testAlphanumeric(s)?e.ALPHANUMERIC:n.testKanji(s)?e.KANJI:e.BYTE},e.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},e.isValid=function(s){return s&&s.bit&&s.ccBits};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+i)}}e.from=function(s,o){if(e.isValid(s))return s;try{return r(s)}catch{return o}}})(io);(function(e){const t=Qr,n=rm,r=nm,i=io,s=dE,o=7973,a=t.getBCHDigit(o);function l(_,m,g){for(let p=1;p<=40;p++)if(m<=e.getCapacity(p,g,_))return p}function c(_,m){return i.getCharCountIndicator(_,m)+4}function d(_,m){let g=0;return _.forEach(function(p){const E=c(p.mode,m);g+=E+p.getBitsLength()}),g}function u(_,m){for(let g=1;g<=40;g++)if(d(_,g)<=e.getCapacity(g,m,i.MIXED))return g}e.from=function(m,g){return s.isValid(m)?parseInt(m,10):g},e.getCapacity=function(m,g,p){if(!s.isValid(m))throw new Error("Invalid QR Code version");typeof p>"u"&&(p=i.BYTE);const E=t.getSymbolTotalCodewords(m),h=n.getTotalCodewordsCount(m,g),f=(E-h)*8;if(p===i.MIXED)return f;const b=f-c(p,m);switch(p){case i.NUMERIC:return Math.floor(b/10*3);case i.ALPHANUMERIC:return Math.floor(b/11*2);case i.KANJI:return Math.floor(b/13);case i.BYTE:default:return Math.floor(b/8)}},e.getBestVersionForData=function(m,g){let p;const E=r.from(g,r.M);if(Array.isArray(m)){if(m.length>1)return u(m,E);if(m.length===0)return 1;p=m[0]}else p=m;return l(p.mode,p.getLength(),E)},e.getEncodedBits=function(m){if(!s.isValid(m)||m<7)throw new Error("Invalid QR Code version");let g=m<<12;for(;t.getBCHDigit(g)-a>=0;)g^=o<<t.getBCHDigit(g)-a;return m<<12|g}})(sw);var aw={};const Yf=Qr,lw=1335,rte=21522,dy=Yf.getBCHDigit(lw);aw.getEncodedBits=function(t,n){const r=t.bit<<3|n;let i=r<<10;for(;Yf.getBCHDigit(i)-dy>=0;)i^=lw<<Yf.getBCHDigit(i)-dy;return(r<<10|i)^rte};var cw={};const ite=io;function rl(e){this.mode=ite.NUMERIC,this.data=e.toString()}rl.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};rl.prototype.getLength=function(){return this.data.length};rl.prototype.getBitsLength=function(){return rl.getBitsLength(this.data.length)};rl.prototype.write=function(t){let n,r,i;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),i=parseInt(r,10),t.put(i,10);const s=this.data.length-n;s>0&&(r=this.data.substr(n),i=parseInt(r,10),t.put(i,s*3+1))};var ste=rl;const ote=io,fg=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function il(e){this.mode=ote.ALPHANUMERIC,this.data=e}il.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};il.prototype.getLength=function(){return this.data.length};il.prototype.getBitsLength=function(){return il.getBitsLength(this.data.length)};il.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let r=fg.indexOf(this.data[n])*45;r+=fg.indexOf(this.data[n+1]),t.put(r,11)}this.data.length%2&&t.put(fg.indexOf(this.data[n]),6)};var ate=il;const lte=io;function sl(e){this.mode=lte.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}sl.getBitsLength=function(t){return t*8};sl.prototype.getLength=function(){return this.data.length};sl.prototype.getBitsLength=function(){return sl.getBitsLength(this.data.length)};sl.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var cte=sl;const dte=io,ute=Qr;function ol(e){this.mode=dte.KANJI,this.data=e}ol.getBitsLength=function(t){return t*13};ol.prototype.getLength=function(){return this.data.length};ol.prototype.getBitsLength=function(){return ol.getBitsLength(this.data.length)};ol.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=ute.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
178
178
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var _te=ol,dw={exports:{}};(function(e){var t={single_source_shortest_paths:function(n,r,i){var s={},o={};o[r]=0;var a=t.PriorityQueue.make();a.push(r,0);for(var l,c,d,u,_,m,g,p,E;!a.empty();){l=a.pop(),c=l.value,u=l.cost,_=n[c]||{};for(d in _)_.hasOwnProperty(d)&&(m=_[d],g=u+m,p=o[d],E=typeof o[d]>"u",(E||p>g)&&(o[d]=g,a.push(d,g),s[d]=c))}if(typeof i<"u"&&typeof o[i]>"u"){var h=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(h)}return s},extract_shortest_path_from_predecessor_list:function(n,r){for(var i=[],s=r;s;)i.push(s),n[s],s=n[s];return i.reverse(),i},find_path:function(n,r,i){var s=t.single_source_shortest_paths(n,r,i);return t.extract_shortest_path_from_predecessor_list(s,i)},PriorityQueue:{make:function(n){var r=t.PriorityQueue,i={},s;n=n||{};for(s in r)r.hasOwnProperty(s)&&(i[s]=r[s]);return i.queue=[],i.sorter=n.sorter||r.default_sorter,i},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var i={value:n,cost:r};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(dw);var mte=dw.exports;(function(e){const t=io,n=ste,r=ate,i=cte,s=_te,o=Qi,a=Qr,l=mte;function c(h){return unescape(encodeURIComponent(h)).length}function d(h,f,b){const y=[];let v;for(;(v=h.exec(b))!==null;)y.push({data:v[0],index:v.index,mode:f,length:v[0].length});return y}function u(h){const f=d(o.NUMERIC,t.NUMERIC,h),b=d(o.ALPHANUMERIC,t.ALPHANUMERIC,h);let y,v;return a.isKanjiModeEnabled()?(y=d(o.BYTE,t.BYTE,h),v=d(o.KANJI,t.KANJI,h)):(y=d(o.BYTE_KANJI,t.BYTE,h),v=[]),f.concat(b,y,v).sort(function(T,I){return T.index-I.index}).map(function(T){return{data:T.data,mode:T.mode,length:T.length}})}function _(h,f){switch(f){case t.NUMERIC:return n.getBitsLength(h);case t.ALPHANUMERIC:return r.getBitsLength(h);case t.KANJI:return s.getBitsLength(h);case t.BYTE:return i.getBitsLength(h)}}function m(h){return h.reduce(function(f,b){const y=f.length-1>=0?f[f.length-1]:null;return y&&y.mode===b.mode?(f[f.length-1].data+=b.data,f):(f.push(b),f)},[])}function g(h){const f=[];for(let b=0;b<h.length;b++){const y=h[b];switch(y.mode){case t.NUMERIC:f.push([y,{data:y.data,mode:t.ALPHANUMERIC,length:y.length},{data:y.data,mode:t.BYTE,length:y.length}]);break;case t.ALPHANUMERIC:f.push([y,{data:y.data,mode:t.BYTE,length:y.length}]);break;case t.KANJI:f.push([y,{data:y.data,mode:t.BYTE,length:c(y.data)}]);break;case t.BYTE:f.push([{data:y.data,mode:t.BYTE,length:c(y.data)}])}}return f}function p(h,f){const b={},y={start:{}};let v=["start"];for(let O=0;O<h.length;O++){const T=h[O],I=[];for(let k=0;k<T.length;k++){const A=T[k],V=""+O+k;I.push(V),b[V]={node:A,lastCount:0},y[V]={};for(let B=0;B<v.length;B++){const $=v[B];b[$]&&b[$].node.mode===A.mode?(y[$][V]=_(b[$].lastCount+A.length,A.mode)-_(b[$].lastCount,A.mode),b[$].lastCount+=A.length):(b[$]&&(b[$].lastCount=A.length),y[$][V]=_(A.length,A.mode)+4+t.getCharCountIndicator(A.mode,f))}}v=I}for(let O=0;O<v.length;O++)y[v[O]].end=0;return{map:y,table:b}}function E(h,f){let b;const y=t.getBestModeForData(h);if(b=t.from(f,y),b!==t.BYTE&&b.bit<y.bit)throw new Error('"'+h+'" cannot be encoded with mode '+t.toString(b)+`.
179
179
  Suggested mode is: `+t.toString(y));switch(b===t.KANJI&&!a.isKanjiModeEnabled()&&(b=t.BYTE),b){case t.NUMERIC:return new n(h);case t.ALPHANUMERIC:return new r(h);case t.KANJI:return new s(h);case t.BYTE:return new i(h)}}e.fromArray=function(f){return f.reduce(function(b,y){return typeof y=="string"?b.push(E(y,null)):y.data&&b.push(E(y.data,y.mode)),b},[])},e.fromString=function(f,b){const y=u(f,a.isKanjiModeEnabled()),v=g(y),O=p(v,b),T=l.find_path(O.map,"start","end"),I=[];for(let k=1;k<T.length-1;k++)I.push(O.table[T[k]].node);return e.fromArray(m(I))},e.rawSplit=function(f){return e.fromArray(u(f,a.isKanjiModeEnabled()))}})(cw);const sm=Qr,pg=nm,gte=Kee,fte=Qee,pte=ew,hte=tw,zf=nw,Wf=rm,Ete=Xee,o_=sw,Ste=aw,bte=io,hg=cw;function vte(e,t){const n=e.size,r=hte.getPositions(t);for(let i=0;i<r.length;i++){const s=r[i][0],o=r[i][1];for(let a=-1;a<=7;a++)if(!(s+a<=-1||n<=s+a))for(let l=-1;l<=7;l++)o+l<=-1||n<=o+l||(a>=0&&a<=6&&(l===0||l===6)||l>=0&&l<=6&&(a===0||a===6)||a>=2&&a<=4&&l>=2&&l<=4?e.set(s+a,o+l,!0,!0):e.set(s+a,o+l,!1,!0))}}function yte(e){const t=e.size;for(let n=8;n<t-8;n++){const r=n%2===0;e.set(n,6,r,!0),e.set(6,n,r,!0)}}function Tte(e,t){const n=pte.getPositions(t);for(let r=0;r<n.length;r++){const i=n[r][0],s=n[r][1];for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)o===-2||o===2||a===-2||a===2||o===0&&a===0?e.set(i+o,s+a,!0,!0):e.set(i+o,s+a,!1,!0)}}function Cte(e,t){const n=e.size,r=o_.getEncodedBits(t);let i,s,o;for(let a=0;a<18;a++)i=Math.floor(a/3),s=a%3+n-8-3,o=(r>>a&1)===1,e.set(i,s,o,!0),e.set(s,i,o,!0)}function Eg(e,t,n){const r=e.size,i=Ste.getEncodedBits(t,n);let s,o;for(s=0;s<15;s++)o=(i>>s&1)===1,s<6?e.set(s,8,o,!0):s<8?e.set(s+1,8,o,!0):e.set(r-15+s,8,o,!0),s<8?e.set(8,r-s-1,o,!0):s<9?e.set(8,15-s-1+1,o,!0):e.set(8,15-s-1,o,!0);e.set(r-8,8,1,!0)}function Rte(e,t){const n=e.size;let r=-1,i=n-1,s=7,o=0;for(let a=n-1;a>0;a-=2)for(a===6&&a--;;){for(let l=0;l<2;l++)if(!e.isReserved(i,a-l)){let c=!1;o<t.length&&(c=(t[o]>>>s&1)===1),e.set(i,a-l,c),s--,s===-1&&(o++,s=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function Ite(e,t,n){const r=new gte;n.forEach(function(l){r.put(l.mode.bit,4),r.put(l.getLength(),bte.getCharCountIndicator(l.mode,e)),l.write(r)});const i=sm.getSymbolTotalCodewords(e),s=Wf.getTotalCodewordsCount(e,t),o=(i-s)*8;for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const a=(o-r.getLengthInBits())/8;for(let l=0;l<a;l++)r.put(l%2?17:236,8);return Ote(r,e,t)}function Ote(e,t,n){const r=sm.getSymbolTotalCodewords(t),i=Wf.getTotalCodewordsCount(t,n),s=r-i,o=Wf.getBlocksCount(t,n),a=r%o,l=o-a,c=Math.floor(r/o),d=Math.floor(s/o),u=d+1,_=c-d,m=new Ete(_);let g=0;const p=new Array(o),E=new Array(o);let h=0;const f=new Uint8Array(e.buffer);for(let T=0;T<o;T++){const I=T<l?d:u;p[T]=f.slice(g,g+I),E[T]=m.encode(p[T]),g+=I,h=Math.max(h,I)}const b=new Uint8Array(r);let y=0,v,O;for(v=0;v<h;v++)for(O=0;O<o;O++)v<p[O].length&&(b[y++]=p[O][v]);for(v=0;v<_;v++)for(O=0;O<o;O++)b[y++]=E[O][v];return b}function Nte(e,t,n,r){let i;if(Array.isArray(e))i=hg.fromArray(e);else if(typeof e=="string"){let c=t;if(!c){const d=hg.rawSplit(e);c=o_.getBestVersionForData(d,n)}i=hg.fromString(e,c||40)}else throw new Error("Invalid data");const s=o_.getBestVersionForData(i,n);if(!s)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=s;else if(t<s)throw new Error(`