@neuralnomads/codenomad 0.2.5-dev → 0.2.6-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/assets/{index-CNQYgIVc.css → index-xIuBSisM.css} +1 -1
- package/public/assets/{loading--BigFJiI.js → loading-CA8y-NQU.js} +1 -1
- package/public/assets/{main-evQM-q4k.js → main-CjXO1IoI.js} +2 -2
- package/public/index.html +3 -3
- package/public/loading.html +3 -3
- /package/public/assets/{index-DX72pXhS.js → index-ysIEPg5i.js} +0 -0
|
@@ -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 Cv=Object.defineProperty;var Am=e=>{throw TypeError(e)};var Rv=(e,t,n)=>t in e?Cv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var X=(e,t,n)=>Rv(e,typeof t!="symbol"?t+"":t,n),Iv=(e,t,n)=>t.has(e)||Am("Cannot "+n);var xm=(e,t,n)=>t.has(e)?Am("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var So=(e,t,n)=>(Iv(e,t,"access private method"),n);import{o as xe,c as fe,a as ue,b as V,$ as yd,u as Fa,d as Cd,e as Q,m as Ne,s as Qe,f as T,D as Lf,g as dn,h as si,i as un,j as Cn,k as ke,l as Fr,P as wu,S as ee,n as Or,p as Mf,q as Rd,t as G,r as I,F as We,v as wn,w as He,M as bn,x as ic,y as li,z as Nt,A as Fe,B as At,C as bs,E as cr,G as Id,H as Ov,I as kf,J as Nv,K as Av}from"./index-DX72pXhS.js";function xv(e){return(...t)=>{for(const n of e)n&&n(...t)}}const ce=e=>typeof e=="function"&&!e.length?e():e,wm=e=>Array.isArray(e)?e:e?[e]:[];function wv(e,...t){return typeof e=="function"?e(...t):e}const Dv=xe;function Lv(e,t,n,i){return e.addEventListener(t,n,i),Dv(e.removeEventListener.bind(e,t,n,i))}function Mv(e,t,n,i){const r=()=>{wm(ce(e)).forEach(a=>{a&&wm(ce(t)).forEach(s=>Lv(a,s,n,i))})};typeof e=="function"?fe(r):ue(r)}const Pc=Symbol("fallback");function Dm(e){for(const t of e)t.dispose()}function kv(e,t,n,i={}){const r=new Map;return xe(()=>Dm(r.values())),()=>{const s=e()||[];return s[yd],Fa(()=>{var d,u;if(!s.length)return Dm(r.values()),r.clear(),i.fallback?[Cd(m=>(r.set(Pc,{dispose:m}),i.fallback()))]:[];const o=new Array(s.length),l=r.get(Pc);if(!r.size||l){l==null||l.dispose(),r.delete(Pc);for(let _=0;_<s.length;_++){const m=s[_],p=t(m,_);a(o,m,_,p)}return o}const c=new Set(r.keys());for(let _=0;_<s.length;_++){const m=s[_],p=t(m,_);c.delete(p);const g=r.get(p);g?(o[_]=g.mapped,(d=g.setIndex)==null||d.call(g,_),g.setItem(()=>m)):a(o,m,_,p)}for(const _ of c)(u=r.get(_))==null||u.dispose(),r.delete(_);return o})};function a(s,o,l,c){Cd(d=>{const[u,_]=Q(o),m={setItem:_,dispose:d};if(n.length>1){const[p,g]=Q(l);m.setIndex=g,m.mapped=n(u,p)}else m.mapped=n(u);r.set(c,m),s[l]=m.mapped})}}function Pv(e){const{by:t}=e;return V(kv(()=>e.each,typeof t=="function"?t:n=>n[t],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}const Fv=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Lm(e){const t={};let n;for(;n=Fv.exec(e);)t[n[1]]=n[2];return t}function ao(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=Lm(e)}else typeof t=="string"&&(t=Lm(t));return{...e,...t}}function Pt(...e){return xv(e)}function Mm(e,t){const n=[...e],i=n.indexOf(t);return i!==-1&&n.splice(i,1),n}function Uv(e){return typeof e=="number"}function Xr(e){return Object.prototype.toString.call(e)==="[object String]"}function zi(e){return typeof e=="function"}function Ua(e){return t=>`${e()}-${t}`}function zn(e,t){return e?e===t||e.contains(t):!1}function ds(e,t=!1){const{activeElement:n}=Ai(e);if(!(n!=null&&n.nodeName))return null;if(Pf(n)&&n.contentDocument)return ds(n.contentDocument.body,t);if(t){const i=n.getAttribute("aria-activedescendant");if(i){const r=Ai(n).getElementById(i);if(r)return r}}return n}function Bv(e){return Ai(e).defaultView||window}function Ai(e){return e?e.ownerDocument||e:document}function Pf(e){return e.tagName==="IFRAME"}var Ff=(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))(Ff||{});function Uf(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 Du(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 so(){return Du(/^Mac/i)}function $v(){return Du(/^iPhone/i)}function Gv(){return Du(/^iPad/i)||so()&&navigator.maxTouchPoints>1}function Yv(){return $v()||Gv()}function Zo(){return so()||Yv()}function Vv(){return Uf(/AppleWebKit/i)&&!Hv()}function Hv(){return Uf(/Chrome/i)}function _t(e,t){return t&&(zi(t)?t(e):t[0](t[1],e)),e==null?void 0:e.defaultPrevented}function Dn(e){return t=>{for(const n of e)_t(t,n)}}function Wv(e){return so()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Gt(e){if(e)if(zv())e.focus({preventScroll:!0});else{const t=Kv(e);e.focus(),qv(t)}}var bo=null;function zv(){if(bo==null){bo=!1;try{document.createElement("div").focus({get preventScroll(){return bo=!0,!0}})}catch{}}return bo}function Kv(e){let t=e.parentNode;const n=[],i=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==i;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return i instanceof HTMLElement&&n.push({element:i,scrollTop:i.scrollTop,scrollLeft:i.scrollLeft}),n}function qv(e){for(const{element:t,scrollTop:n,scrollLeft:i}of e)t.scrollTop=n,t.scrollLeft=i}var Bf=["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'])"],Qv=[...Bf,'[tabindex]:not([tabindex="-1"]):not([disabled])'],Lu=`${Bf.join(":not([hidden]),")},[tabindex]:not([disabled]):not([hidden])`,Xv=Qv.join(':not([hidden]):not([tabindex="-1"]),');function $f(e,t){const i=Array.from(e.querySelectorAll(Lu)).filter(km);return t&&km(e)&&i.unshift(e),i.forEach((r,a)=>{if(Pf(r)&&r.contentDocument){const s=r.contentDocument.body,o=$f(s,!1);i.splice(a,1,...o)}}),i}function km(e){return Gf(e)&&!jv(e)}function Gf(e){return e.matches(Lu)&&Mu(e)}function jv(e){return Number.parseInt(e.getAttribute("tabindex")||"0",10)<0}function Mu(e,t){return e.nodeName!=="#comment"&&Zv(e)&&Jv(e,t)&&(!e.parentElement||Mu(e.parentElement,e))}function Zv(e){if(!(e instanceof HTMLElement)&&!(e instanceof SVGElement))return!1;const{display:t,visibility:n}=e.style;let i=t!=="none"&&n!=="hidden"&&n!=="collapse";if(i){if(!e.ownerDocument.defaultView)return i;const{getComputedStyle:r}=e.ownerDocument.defaultView,{display:a,visibility:s}=r(e);i=a!=="none"&&s!=="hidden"&&s!=="collapse"}return i}function Jv(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function ey(e,t,n){const i=t!=null&&t.tabbable?Xv:Lu,r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(a){var s;return(s=t==null?void 0:t.from)!=null&&s.contains(a)?NodeFilter.FILTER_REJECT:a.matches(i)&&Mu(a)&&(!(t!=null&&t.accept)||t.accept(a))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(r.currentNode=t.from),r}function ty(){}function rt(e,t){return Ne(e,t)}var Ja=new Map,Pm=new Set;function Fm(){if(typeof window>"u")return;const e=n=>{if(!n.target)return;let i=Ja.get(n.target);i||(i=new Set,Ja.set(n.target,i),n.target.addEventListener("transitioncancel",t)),i.add(n.propertyName)},t=n=>{if(!n.target)return;const i=Ja.get(n.target);if(i&&(i.delete(n.propertyName),i.size===0&&(n.target.removeEventListener("transitioncancel",t),Ja.delete(n.target)),Ja.size===0)){for(const r of Pm)r();Pm.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?Fm():document.addEventListener("DOMContentLoaded",Fm));function Um(e,t){const n=Bm(e,t,"left"),i=Bm(e,t,"top"),r=t.offsetWidth,a=t.offsetHeight;let s=e.scrollLeft,o=e.scrollTop;const l=s+e.offsetWidth,c=o+e.offsetHeight;n<=s?s=n:n+r>l&&(s+=n+r-l),i<=o?o=i:i+a>c&&(o+=i+a-c),e.scrollLeft=s,e.scrollTop=o}function Bm(e,t,n){const i=n==="left"?"offsetLeft":"offsetTop";let r=0;for(;t.offsetParent&&(r+=t[i],t.offsetParent!==e);){if(t.offsetParent.contains(e)){r-=e[i];break}t=t.offsetParent}return r}var ku={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"},ul="data-kb-top-layer",Yf,Od=!1,xi=[];function Ps(e){return xi.findIndex(t=>t.node===e)}function ny(e){return xi[Ps(e)]}function iy(e){return xi[xi.length-1].node===e}function Vf(){return xi.filter(e=>e.isPointerBlocking)}function ry(){return[...Vf()].slice(-1)[0]}function Pu(){return Vf().length>0}function Hf(e){var n;const t=Ps((n=ry())==null?void 0:n.node);return Ps(e)<t}function ay(e){xi.push(e)}function sy(e){const t=Ps(e);t<0||xi.splice(t,1)}function oy(){for(const{node:e}of xi)e.style.pointerEvents=Hf(e)?"none":"auto"}function ly(e){if(Pu()&&!Od){const t=Ai(e);Yf=document.body.style.pointerEvents,t.body.style.pointerEvents="none",Od=!0}}function cy(e){if(Pu())return;const t=Ai(e);t.body.style.pointerEvents=Yf,t.body.style.length===0&&t.body.removeAttribute("style"),Od=!1}var mn={layers:xi,isTopMostLayer:iy,hasPointerBlockingLayer:Pu,isBelowPointerBlockingLayer:Hf,addLayer:ay,removeLayer:sy,indexOf:Ps,find:ny,assignPointerEventToLayers:oy,disableBodyPointerEvents:ly,restoreBodyPointerEvents:cy},Fc="focusScope.autoFocusOnMount",Uc="focusScope.autoFocusOnUnmount",$m={bubbles:!1,cancelable:!0},Gm={stack:[],active(){return this.stack[0]},add(e){var t;e!==this.active()&&((t=this.active())==null||t.pause()),this.stack=Mm(this.stack,e),this.stack.unshift(e)},remove(e){var t;this.stack=Mm(this.stack,e),(t=this.active())==null||t.resume()}};function Fu(e,t){const[n,i]=Q(!1),r={pause(){i(!0)},resume(){i(!1)}};let a=null;const s=p=>{var g;return(g=e.onMountAutoFocus)==null?void 0:g.call(e,p)},o=p=>{var g;return(g=e.onUnmountAutoFocus)==null?void 0:g.call(e,p)},l=()=>Ai(t()),c=()=>{const p=l().createElement("span");return p.setAttribute("data-focus-trap",""),p.tabIndex=0,Object.assign(p.style,ku),p},d=()=>{const p=t();return p?$f(p,!0).filter(g=>!g.hasAttribute("data-focus-trap")):[]},u=()=>{const p=d();return p.length>0?p[0]:null},_=()=>{const p=d();return p.length>0?p[p.length-1]:null},m=()=>{const p=t();if(!p)return!1;const g=ds(p);return!g||zn(p,g)?!1:Gf(g)};fe(()=>{const p=t();if(!p)return;Gm.add(r);const g=ds(p);if(!zn(p,g)){const h=new CustomEvent(Fc,$m);p.addEventListener(Fc,s),p.dispatchEvent(h),h.defaultPrevented||setTimeout(()=>{Gt(u()),ds(p)===g&&Gt(p)},0)}xe(()=>{p.removeEventListener(Fc,s),setTimeout(()=>{const h=new CustomEvent(Uc,$m);m()&&h.preventDefault(),p.addEventListener(Uc,o),p.dispatchEvent(h),h.defaultPrevented||Gt(g??l().body),p.removeEventListener(Uc,o),Gm.remove(r)},0)})}),fe(()=>{const p=t();if(!p||!ce(e.trapFocus)||n())return;const g=h=>{const f=h.target;f!=null&&f.closest(`[${ul}]`)||(zn(p,f)?a=f:Gt(a))},E=h=>{const S=h.relatedTarget??ds(p);S!=null&&S.closest(`[${ul}]`)||zn(p,S)||Gt(a)};l().addEventListener("focusin",g),l().addEventListener("focusout",E),xe(()=>{l().removeEventListener("focusin",g),l().removeEventListener("focusout",E)})}),fe(()=>{const p=t();if(!p||!ce(e.trapFocus)||n())return;const g=c();p.insertAdjacentElement("afterbegin",g);const E=c();p.insertAdjacentElement("beforeend",E);function h(S){const v=u(),b=_();S.relatedTarget===v?Gt(b):Gt(v)}g.addEventListener("focusin",h),E.addEventListener("focusin",h);const f=new MutationObserver(S=>{for(const v of S)v.previousSibling===E&&(E.remove(),p.insertAdjacentElement("beforeend",E)),v.nextSibling===g&&(g.remove(),p.insertAdjacentElement("afterbegin",g))});f.observe(p,{childList:!0,subtree:!1}),xe(()=>{g.removeEventListener("focusin",h),E.removeEventListener("focusin",h),g.remove(),E.remove(),f.disconnect()})})}var Wf=7e3,Bc=null,dy="data-live-announcer";function $c(e,t="assertive",n=Wf){Bc||(Bc=new uy),Bc.announce(e,t,n)}var uy=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,ku),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=Wf){if(!this.node)return;const i=document.createElement("div");i.textContent=e,t==="assertive"?this.assertiveLog.appendChild(i):this.politeLog.appendChild(i),e!==""&&setTimeout(()=>{i.remove()},n)}clear(e){this.node&&((!e||e==="assertive")&&(this.assertiveLog.innerHTML=""),(!e||e==="polite")&&(this.politeLog.innerHTML=""))}};function Uu(e){fe(()=>{ce(e.isDisabled)||xe(_y(ce(e.targets),ce(e.root)))})}var es=new WeakMap,Nn=[];function _y(e,t=document.body){const n=new Set(e),i=new Set,r=l=>{for(const _ of l.querySelectorAll(`[${dy}], [${ul}]`))n.add(_);const c=_=>{if(n.has(_)||_.parentElement&&i.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&&a(l),u!==NodeFilter.FILTER_REJECT){let _=d.nextNode();for(;_!=null;)a(_),_=d.nextNode()}},a=l=>{const c=es.get(l)??0;l.getAttribute("aria-hidden")==="true"&&c===0||(c===0&&l.setAttribute("aria-hidden","true"),i.add(l),es.set(l,c+1))};Nn.length&&Nn[Nn.length-1].disconnect(),r(t);const s=new MutationObserver(l=>{for(const c of l)if(!(c.type!=="childList"||c.addedNodes.length===0)&&![...n,...i].some(d=>d.contains(c.target))){for(const d of c.removedNodes)d instanceof Element&&(n.delete(d),i.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&&r(d)}});s.observe(t,{childList:!0,subtree:!0});const o={observe(){s.observe(t,{childList:!0,subtree:!0})},disconnect(){s.disconnect()}};return Nn.push(o),()=>{s.disconnect();for(const l of i){const c=es.get(l);if(c==null)return;c===1?(l.removeAttribute("aria-hidden"),es.delete(l)):es.set(l,c-1)}o===Nn[Nn.length-1]?(Nn.pop(),Nn.length&&Nn[Nn.length-1].observe()):Nn.splice(Nn.indexOf(o),1)}}var Ym="interactOutside.pointerDownOutside",Vm="interactOutside.focusOutside";function my(e,t){let n,i=ty;const r=()=>Ai(t()),a=u=>{var _;return(_=e.onPointerDownOutside)==null?void 0:_.call(e,u)},s=u=>{var _;return(_=e.onFocusOutside)==null?void 0:_.call(e,u)},o=u=>{var _;return(_=e.onInteractOutside)==null?void 0:_.call(e,u)},l=u=>{var m;const _=u.target;return!(_ instanceof Element)||_.closest(`[${ul}]`)||!zn(r(),_)||zn(t(),_)?!1:!((m=e.shouldExcludeElement)!=null&&m.call(e,_))},c=u=>{function _(){const m=t(),p=u.target;if(!m||!p||!l(u))return;const g=Dn([a,o]);p.addEventListener(Ym,g,{once:!0});const E=new CustomEvent(Ym,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:u.button===2||Wv(u)&&u.button===0}});p.dispatchEvent(E)}u.pointerType==="touch"?(r().removeEventListener("click",_),i=_,r().addEventListener("click",_,{once:!0})):_()},d=u=>{const _=t(),m=u.target;if(!_||!m||!l(u))return;const p=Dn([s,o]);m.addEventListener(Vm,p,{once:!0});const g=new CustomEvent(Vm,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:!1}});m.dispatchEvent(g)};fe(()=>{ce(e.isDisabled)||(n=window.setTimeout(()=>{r().addEventListener("pointerdown",c,!0)},0),r().addEventListener("focusin",d,!0),xe(()=>{window.clearTimeout(n),r().removeEventListener("click",i),r().removeEventListener("pointerdown",c,!0),r().removeEventListener("focusin",d,!0)}))})}function py(e){const t=n=>{var i;n.key===Ff.Escape&&((i=e.onEscapeKeyDown)==null||i.call(e,n))};fe(()=>{var i;if(ce(e.isDisabled))return;const n=((i=e.ownerDocument)==null?void 0:i.call(e))??Ai();n.addEventListener("keydown",t),xe(()=>{n.removeEventListener("keydown",t)})})}function ft(e){const[t,n]=Qe(e,["as"]);if(!t.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return T(Lf,Ne(n,{get component(){return t.as}}))}var zf=un();function gy(){return Cn(zf)}function Bu(e){let t;const n=gy(),[i,r]=Qe(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),a=new Set([]),s=u=>{a.add(u);const _=n==null?void 0:n.registerNestedLayer(u);return()=>{a.delete(u),_==null||_()}};my({shouldExcludeElement:u=>{var _;return t?((_=i.excludedElements)==null?void 0:_.some(m=>zn(m(),u)))||[...a].some(m=>zn(m,u)):!1},onPointerDownOutside:u=>{var _,m,p;!t||mn.isBelowPointerBlockingLayer(t)||!i.bypassTopMostLayerCheck&&!mn.isTopMostLayer(t)||((_=i.onPointerDownOutside)==null||_.call(i,u),(m=i.onInteractOutside)==null||m.call(i,u),u.defaultPrevented||(p=i.onDismiss)==null||p.call(i))},onFocusOutside:u=>{var _,m,p;(_=i.onFocusOutside)==null||_.call(i,u),(m=i.onInteractOutside)==null||m.call(i,u),u.defaultPrevented||(p=i.onDismiss)==null||p.call(i)}},()=>t),py({ownerDocument:()=>Ai(t),onEscapeKeyDown:u=>{var _;!t||!mn.isTopMostLayer(t)||((_=i.onEscapeKeyDown)==null||_.call(i,u),!u.defaultPrevented&&i.onDismiss&&(u.preventDefault(),i.onDismiss()))}}),dn(()=>{if(!t)return;mn.addLayer({node:t,isPointerBlocking:i.disableOutsidePointerEvents,dismiss:i.onDismiss});const u=n==null?void 0:n.registerNestedLayer(t);mn.assignPointerEventToLayers(),mn.disableBodyPointerEvents(t),xe(()=>{t&&(mn.removeLayer(t),u==null||u(),mn.assignPointerEventToLayers(),mn.restoreBodyPointerEvents(t))})}),fe(si([()=>t,()=>i.disableOutsidePointerEvents],([u,_])=>{if(!u)return;const m=mn.find(u);m&&m.isPointerBlocking!==_&&(m.isPointerBlocking=_,mn.assignPointerEventToLayers()),_&&mn.disableBodyPointerEvents(u),xe(()=>{mn.restoreBodyPointerEvents(u)})},{defer:!0}));const d={registerNestedLayer:s};return T(zf.Provider,{value:d,get children(){return T(ft,Ne({as:"div",ref(u){var _=Pt(m=>t=m,i.ref);typeof _=="function"&&_(u)}},r))}})}function $u(e){var s;const[t,n]=Q((s=e.defaultValue)==null?void 0:s.call(e)),i=V(()=>{var o;return((o=e.value)==null?void 0:o.call(e))!==void 0}),r=V(()=>{var o;return i()?(o=e.value)==null?void 0:o.call(e):t()});return[r,o=>{Fa(()=>{var c;const l=wv(o,r());return Object.is(l,r())||(i()||n(l),(c=e.onChange)==null||c.call(e,l)),l})}]}function fy(e){const[t,n]=$u(e);return[()=>t()??!1,n]}function Gu(e={}){const[t,n]=fy({value:()=>ce(e.open),defaultValue:()=>!!ce(e.defaultOpen),onChange:s=>{var o;return(o=e.onOpenChange)==null?void 0:o.call(e,s)}}),i=()=>{n(!0)},r=()=>{n(!1)};return{isOpen:t,setIsOpen:n,open:i,close:r,toggle:()=>{t()?r():i()}}}function Kf(e,t){const[n,i]=Q(Hm(t==null?void 0:t()));return fe(()=>{var r;i(((r=e())==null?void 0:r.tagName.toLowerCase())||Hm(t==null?void 0:t()))}),n}function Hm(e){return Xr(e)?e:void 0}var Ey=Object.defineProperty,oo=(e,t)=>{for(var n in t)Ey(e,n,{get:t[n],enumerable:!0})},hy={};oo(hy,{Button:()=>Ty,Root:()=>Ba});var Sy=["button","color","file","image","reset","submit"];function by(e){const t=e.tagName.toLowerCase();return t==="button"?!0:t==="input"&&e.type?Sy.indexOf(e.type)!==-1:!1}function Ba(e){let t;const n=rt({type:"button"},e),[i,r]=Qe(n,["ref","type","disabled"]),a=Kf(()=>t,()=>"button"),s=V(()=>{const c=a();return c==null?!1:by({tagName:c,type:i.type})}),o=V(()=>a()==="input"),l=V(()=>a()==="a"&&(t==null?void 0:t.getAttribute("href"))!=null);return T(ft,Ne({as:"button",ref(c){var d=Pt(u=>t=u,i.ref);typeof d=="function"&&d(c)},get type(){return ke(()=>!!(s()||o()))()?i.type:void 0},get role(){return!s()&&!l()?"button":void 0},get tabIndex(){return!s()&&!l()&&!i.disabled?0:void 0},get disabled(){return ke(()=>!!(s()||o()))()?i.disabled:void 0},get"aria-disabled"(){return!s()&&!o()&&i.disabled?!0:void 0},get"data-disabled"(){return i.disabled?"":void 0}},r))}var Ty=Ba;function Tn(e){return t=>(e(t),()=>e(void 0))}var Kt=e=>typeof e=="function"?e():e,Nd=(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},To=new Map,vy=e=>{fe(()=>{const t=Kt(e.style)??{},n=Kt(e.properties)??[],i={};for(const a in t)i[a]=e.element.style[a];const r=To.get(e.key);r?r.activeCount++:To.set(e.key,{activeCount:1,originalStyles:i,properties:n.map(a=>a.key)}),Object.assign(e.element.style,e.style);for(const a of n)e.element.style.setProperty(a.key,a.value);xe(()=>{var s;const a=To.get(e.key);if(a){if(a.activeCount!==1){a.activeCount--;return}To.delete(e.key);for(const[o,l]of Object.entries(a.originalStyles))e.element.style[o]=l;for(const o of a.properties)e.element.style.removeProperty(o);e.element.style.length===0&&e.element.removeAttribute("style"),(s=e.cleanup)==null||s.call(e)}})})},Wm=vy,yy=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},Cy=(e,t)=>{const n=getComputedStyle(e),i=t==="x"?n.overflowX:n.overflowY;return i==="auto"||i==="scroll"||e.tagName==="HTML"&&i==="visible"},Ry=(e,t,n)=>{const i=t==="x"&&window.getComputedStyle(e).direction==="rtl"?-1:1;let r=e,a=0,s=0,o=!1;do{const[l,c,d]=yy(r,t),u=d-l-i*c;(c!==0||u!==0)&&Cy(r,t)&&(a+=u,s+=c),r===(n??document.documentElement)?o=!0:r=r._$host??r.parentElement}while(r&&!o);return[a,s]},[zm,Km]=Q([]),Iy=e=>zm().indexOf(e)===zm().length-1,Oy=e=>{const t=Ne({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=Fr();let i=[0,0],r=null,a=null;fe(()=>{Kt(t.enabled)&&(Km(c=>[...c,n]),xe(()=>{Km(c=>c.filter(d=>d!==n))}))}),fe(()=>{if(!Kt(t.enabled)||!Kt(t.hideScrollbar))return;const{body:c}=document,d=window.innerWidth-c.offsetWidth;if(Kt(t.preventScrollbarShift)){const u={overflow:"hidden"},_=[];d>0&&(Kt(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,p=window.scrollX;Wm({key:"prevent-scroll",element:c,style:u,properties:_,cleanup:()=>{Kt(t.restoreScrollPosition)&&d>0&&window.scrollTo(p,m)}})}else Wm({key:"prevent-scroll",element:c,style:{overflow:"hidden"}})}),fe(()=>{!Iy(n)||!Kt(t.enabled)||(document.addEventListener("wheel",o,{passive:!1}),document.addEventListener("touchstart",s,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),xe(()=>{document.removeEventListener("wheel",o),document.removeEventListener("touchstart",s),document.removeEventListener("touchmove",l)}))});const s=c=>{i=qm(c),r=null,a=null},o=c=>{const d=c.target,u=Kt(t.element),_=Ny(c),m=Math.abs(_[0])>Math.abs(_[1])?"x":"y",p=m==="x"?_[0]:_[1],g=Qm(d,m,p,u);let E;u&&Nd(u,d)?E=!g:E=!0,E&&c.cancelable&&c.preventDefault()},l=c=>{const d=Kt(t.element),u=c.target;let _;if(c.touches.length===2)_=!Kt(t.allowPinchZoom);else{if(r==null||a===null){const m=qm(c).map((g,E)=>i[E]-g),p=Math.abs(m[0])>Math.abs(m[1])?"x":"y";r=p,a=p==="x"?m[0]:m[1]}if(u.type==="range")_=!1;else{const m=Qm(u,r,a,d);d&&Nd(d,u)?_=!m:_=!0}}_&&c.cancelable&&c.preventDefault()}},Ny=e=>[e.deltaX,e.deltaY],qm=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],Qm=(e,t,n,i)=>{const r=i!==null&&Nd(i,e),[a,s]=Ry(e,t,r?i:void 0);return!(n>0&&Math.abs(a)<=1||n<0&&Math.abs(s)<1)},Ay=Oy,Yu=Ay,xy=e=>{const t=V(()=>{const s=Kt(e.element);if(s)return getComputedStyle(s)}),n=()=>{var s;return((s=t())==null?void 0:s.animationName)??"none"},[i,r]=Q(Kt(e.show)?"present":"hidden");let a="none";return fe(s=>{const o=Kt(e.show);return Fa(()=>{var d;if(s===o)return o;const l=a,c=n();o?r("present"):c==="none"||((d=t())==null?void 0:d.display)==="none"?r("hidden"):r(s===!0&&l!==c?"hiding":"hidden")}),o}),fe(()=>{const s=Kt(e.element);if(!s)return;const o=c=>{c.target===s&&(a=n())},l=c=>{const u=n().includes(c.animationName);c.target===s&&u&&i()==="hiding"&&r("hidden")};s.addEventListener("animationstart",o),s.addEventListener("animationcancel",l),s.addEventListener("animationend",l),xe(()=>{s.removeEventListener("animationstart",o),s.removeEventListener("animationcancel",l),s.removeEventListener("animationend",l)})}),{present:()=>i()==="present"||i()==="hiding",state:i,setState:r}},wy=xy,_l=wy,Dy={};oo(Dy,{CloseButton:()=>Qf,Content:()=>Xf,Description:()=>jf,Dialog:()=>Ze,Overlay:()=>Zf,Portal:()=>Jf,Root:()=>eE,Title:()=>tE,Trigger:()=>nE,useDialogContext:()=>dr});var qf=un();function dr(){const e=Cn(qf);if(e===void 0)throw new Error("[kobalte]: `useDialogContext` must be used within a `Dialog` component");return e}function Qf(e){const t=dr(),[n,i]=Qe(e,["aria-label","onClick"]);return T(Ba,Ne({get"aria-label"(){return n["aria-label"]||t.translations().dismiss},onClick:a=>{_t(a,n.onClick),t.close()}},i))}function Xf(e){let t;const n=dr(),i=rt({id:n.generateId("content")},e),[r,a]=Qe(i,["ref","onOpenAutoFocus","onCloseAutoFocus","onPointerDownOutside","onFocusOutside","onInteractOutside"]);let s=!1,o=!1;const l=_=>{var m;(m=r.onPointerDownOutside)==null||m.call(r,_),n.modal()&&_.detail.isContextMenu&&_.preventDefault()},c=_=>{var m;(m=r.onFocusOutside)==null||m.call(r,_),n.modal()&&_.preventDefault()},d=_=>{var m;(m=r.onInteractOutside)==null||m.call(r,_),!n.modal()&&(_.defaultPrevented||(s=!0,_.detail.originalEvent.type==="pointerdown"&&(o=!0)),zn(n.triggerRef(),_.target)&&_.preventDefault(),_.detail.originalEvent.type==="focusin"&&o&&_.preventDefault())},u=_=>{var m;(m=r.onCloseAutoFocus)==null||m.call(r,_),n.modal()?(_.preventDefault(),Gt(n.triggerRef())):(_.defaultPrevented||(s||Gt(n.triggerRef()),_.preventDefault()),s=!1,o=!1)};return Uu({isDisabled:()=>!(n.isOpen()&&n.modal()),targets:()=>t?[t]:[]}),Yu({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),Fu({trapFocus:()=>n.isOpen()&&n.modal(),onMountAutoFocus:r.onOpenAutoFocus,onUnmountAutoFocus:u},()=>t),fe(()=>xe(n.registerContentId(a.id))),T(ee,{get when(){return n.contentPresent()},get children(){return T(Bu,Ne({ref(_){var m=Pt(p=>{n.setContentRef(p),t=p},r.ref);typeof m=="function"&&m(_)},role:"dialog",tabIndex:-1,get disableOutsidePointerEvents(){return ke(()=>!!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}},a))}})}function jf(e){const t=dr(),n=rt({id:t.generateId("description")},e),[i,r]=Qe(n,["id"]);return fe(()=>xe(t.registerDescriptionId(i.id))),T(ft,Ne({as:"p",get id(){return i.id}},r))}function Zf(e){const t=dr(),[n,i]=Qe(e,["ref","style","onPointerDown"]),r=a=>{_t(a,n.onPointerDown),a.target===a.currentTarget&&a.preventDefault()};return T(ee,{get when(){return t.overlayPresent()},get children(){return T(ft,Ne({as:"div",ref(a){var s=Pt(t.setOverlayRef,n.ref);typeof s=="function"&&s(a)},get style(){return ao({"pointer-events":"auto"},n.style)},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onPointerDown:r},i))}})}function Jf(e){const t=dr();return T(ee,{get when(){return t.contentPresent()||t.overlayPresent()},get children(){return T(wu,e)}})}var Xm={dismiss:"Dismiss"};function eE(e){const t=`dialog-${Fr()}`,n=rt({id:t,modal:!0,translations:Xm},e),[i,r]=Q(),[a,s]=Q(),[o,l]=Q(),[c,d]=Q(),[u,_]=Q(),[m,p]=Q(),g=Gu({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:v=>{var b;return(b=n.onOpenChange)==null?void 0:b.call(n,v)}}),E=()=>n.forceMount||g.isOpen(),{present:h}=_l({show:E,element:()=>c()??null}),{present:f}=_l({show:E,element:()=>u()??null}),S={translations:()=>n.translations??Xm,isOpen:g.isOpen,modal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??S.modal(),contentId:i,titleId:a,descriptionId:o,triggerRef:m,overlayRef:c,setOverlayRef:d,contentRef:u,setContentRef:_,overlayPresent:h,contentPresent:f,close:g.close,toggle:g.toggle,setTriggerRef:p,generateId:Ua(()=>n.id),registerContentId:Tn(r),registerTitleId:Tn(s),registerDescriptionId:Tn(l)};return T(qf.Provider,{value:S,get children(){return n.children}})}function tE(e){const t=dr(),n=rt({id:t.generateId("title")},e),[i,r]=Qe(n,["id"]);return fe(()=>xe(t.registerTitleId(i.id))),T(ft,Ne({as:"h2",get id(){return i.id}},r))}function nE(e){const t=dr(),[n,i]=Qe(e,["ref","onClick"]);return T(Ba,Ne({ref(a){var s=Pt(t.setTriggerRef,n.ref);typeof s=="function"&&s(a)},"aria-haspopup":"dialog",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return ke(()=>!!t.isOpen())()?t.contentId():void 0},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onClick:a=>{_t(a,n.onClick),t.toggle()}},i))}var Ze=Object.assign(eE,{CloseButton:Qf,Content:Xf,Description:jf,Overlay:Zf,Portal:Jf,Title:tE,Trigger:nE});const Ly=e=>typeof e=="function",ml=(e,t)=>Ly(e)?e(t):e;var Rt;(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"})(Rt||(Rt={}));const pl=Symbol("store-raw"),fa=Symbol("store-node"),Si=Symbol("store-has"),iE=Symbol("store-self");function rE(e){let t=e[Or];if(!t&&(Object.defineProperty(e,Or,{value:t=new Proxy(e,Py)}),!Array.isArray(e))){const n=Object.keys(e),i=Object.getOwnPropertyDescriptors(e);for(let r=0,a=n.length;r<a;r++){const s=n[r];i[s].get&&Object.defineProperty(e,s,{enumerable:i[s].enumerable,get:i[s].get.bind(t)})}}return t}function ci(e){let t;return e!=null&&typeof e=="object"&&(e[Or]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function Nr(e,t=new Set){let n,i,r,a;if(n=e!=null&&e[pl])return n;if(!ci(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let s=0,o=e.length;s<o;s++)r=e[s],(i=Nr(r,t))!==r&&(e[s]=i)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);const s=Object.keys(e),o=Object.getOwnPropertyDescriptors(e);for(let l=0,c=s.length;l<c;l++)a=s[l],!o[a].get&&(r=e[a],(i=Nr(r,t))!==r&&(e[a]=i))}return e}function gl(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Fs(e,t,n){if(e[t])return e[t];const[i,r]=Q(n,{equals:!1,internal:!0});return i.$=r,e[t]=i}function My(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===Or||t===fa||(delete n.value,delete n.writable,n.get=()=>e[Or][t]),n}function aE(e){Rd()&&Fs(gl(e,fa),iE)()}function ky(e){return aE(e),Reflect.ownKeys(e)}const Py={get(e,t,n){if(t===pl)return e;if(t===Or)return n;if(t===yd)return aE(e),n;const i=gl(e,fa),r=i[t];let a=r?r():e[t];if(t===fa||t===Si||t==="__proto__")return a;if(!r){const s=Object.getOwnPropertyDescriptor(e,t);Rd()&&(typeof a!="function"||e.hasOwnProperty(t))&&!(s&&s.get)&&(a=Fs(i,t,a)())}return ci(a)?rE(a):a},has(e,t){return t===pl||t===Or||t===yd||t===fa||t===Si||t==="__proto__"?!0:(Rd()&&Fs(gl(e,Si),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:ky,getOwnPropertyDescriptor:My};function sn(e,t,n,i=!1){if(!i&&e[t]===n)return;const r=e[t],a=e.length;n===void 0?(delete e[t],e[Si]&&e[Si][t]&&r!==void 0&&e[Si][t].$()):(e[t]=n,e[Si]&&e[Si][t]&&r===void 0&&e[Si][t].$());let s=gl(e,fa),o;if((o=Fs(s,t,r))&&o.$(()=>n),Array.isArray(e)&&e.length!==a){for(let l=e.length;l<a;l++)(o=s[l])&&o.$();(o=Fs(s,"length",a))&&o.$(e.length)}(o=s[iE])&&o.$()}function sE(e,t){const n=Object.keys(t);for(let i=0;i<n.length;i+=1){const r=n[i];sn(e,r,t[r])}}function Fy(e,t){if(typeof t=="function"&&(t=t(e)),t=Nr(t),Array.isArray(t)){if(e===t)return;let n=0,i=t.length;for(;n<i;n++){const r=t[n];e[n]!==r&&sn(e,n,r)}sn(e,"length",i)}else sE(e,t)}function us(e,t,n=[]){let i,r=e;if(t.length>1){i=t.shift();const s=typeof i,o=Array.isArray(e);if(Array.isArray(i)){for(let l=0;l<i.length;l++)us(e,[i[l]].concat(t),n);return}else if(o&&s==="function"){for(let l=0;l<e.length;l++)i(e[l],l)&&us(e,[l].concat(t),n);return}else if(o&&s==="object"){const{from:l=0,to:c=e.length-1,by:d=1}=i;for(let u=l;u<=c;u+=d)us(e,[u].concat(t),n);return}else if(t.length>1){us(e[i],t,[i].concat(n));return}r=e[i],n=[i].concat(n)}let a=t[0];typeof a=="function"&&(a=a(r,n),a===r)||i===void 0&&a==null||(a=Nr(a),i===void 0||ci(r)&&ci(a)&&!Array.isArray(a)?sE(r,a):sn(e,i,a))}function oE(...[e,t]){const n=Nr(e||{}),i=Array.isArray(n),r=rE(n);function a(...s){Mf(()=>{i&&s.length===1?Fy(n,s[0]):us(n,s)})}return[r,a]}const Ad=Symbol("store-root");function jr(e,t,n,i,r){const a=t[n];if(e===a)return;const s=Array.isArray(e);if(n!==Ad&&(!ci(e)||!ci(a)||s!==Array.isArray(a)||r&&e[r]!==a[r])){sn(t,n,e);return}if(s){if(e.length&&a.length&&(!i||r&&e[0]&&e[0][r]!=null)){let c,d,u,_,m,p,g,E;for(u=0,_=Math.min(a.length,e.length);u<_&&(a[u]===e[u]||r&&a[u]&&e[u]&&a[u][r]&&a[u][r]===e[u][r]);u++)jr(e[u],a,u,i,r);const h=new Array(e.length),f=new Map;for(_=a.length-1,m=e.length-1;_>=u&&m>=u&&(a[_]===e[m]||r&&a[_]&&e[m]&&a[_][r]&&a[_][r]===e[m][r]);_--,m--)h[m]=a[_];if(u>m||u>_){for(d=u;d<=m;d++)sn(a,d,e[d]);for(;d<e.length;d++)sn(a,d,h[d]),jr(e[d],a,d,i,r);a.length>e.length&&sn(a,"length",e.length);return}for(g=new Array(m+1),d=m;d>=u;d--)p=e[d],E=r&&p?p[r]:p,c=f.get(E),g[d]=c===void 0?-1:c,f.set(E,d);for(c=u;c<=_;c++)p=a[c],E=r&&p?p[r]:p,d=f.get(E),d!==void 0&&d!==-1&&(h[d]=a[c],d=g[d],f.set(E,d));for(d=u;d<e.length;d++)d in h?(sn(a,d,h[d]),jr(e[d],a,d,i,r)):sn(a,d,e[d])}else for(let c=0,d=e.length;c<d;c++)jr(e[c],a,c,i,r);a.length>e.length&&sn(a,"length",e.length);return}const o=Object.keys(e);for(let c=0,d=o.length;c<d;c++)jr(e[o[c]],a,o[c],i,r);const l=Object.keys(a);for(let c=0,d=l.length;c<d;c++)e[l[c]]===void 0&&sn(a,l[c],void 0)}function Uy(e,t={}){const{merge:n,key:i="id"}=t,r=Nr(e);return a=>{if(!ci(a)||!ci(r))return r;const s=jr(r,{[Ad]:a},Ad,n,i);return s===void 0?a:s}}const fl=new WeakMap,lE={get(e,t){if(t===pl)return e;const n=e[t];let i;return ci(n)?fl.get(n)||(fl.set(n,i=new Proxy(n,lE)),i):n},set(e,t,n){return sn(e,t,Nr(n)),!0},deleteProperty(e,t){return sn(e,t,void 0,!0),!0}};function Ki(e){return t=>{if(ci(t)){let n;(n=fl.get(t))||fl.set(t,n=new Proxy(t,lE)),e(n)}return t}}const[Cr,Bi]=oE({toasts:[],pausedAt:void 0}),By=()=>{const{pausedAt:e,toasts:t}=Cr;if(e)return;const n=Date.now();return t.map(r=>{if(r.duration===1/0)return;const a=(r.duration||0)+r.pauseDuration-(n-r.createdAt);if(a<=0){r.visible&&Xn({type:Rt.DISMISS_TOAST,toastId:r.id});return}return setTimeout(()=>{Xn({type:Rt.DISMISS_TOAST,toastId:r.id})},a)})},Ts=new Map,jm=(e,t)=>{if(Ts.has(e))return;const n=setTimeout(()=>{Ts.delete(e),Xn({type:Rt.REMOVE_TOAST,toastId:e})},t);Ts.set(e,n)},$y=e=>{const t=Ts.get(e);Ts.delete(e),t&&clearTimeout(t)},Xn=e=>{switch(e.type){case Rt.ADD_TOAST:Bi("toasts",r=>{const a=r;return[e.toast,...a]});break;case Rt.DISMISS_TOAST:const{toastId:t}=e,n=Cr.toasts;if(t){const r=n.find(a=>a.id===t);r&&jm(t,r.unmountDelay),Bi("toasts",a=>a.id===t,Ki(a=>a.visible=!1))}else n.forEach(r=>{jm(r.id,r.unmountDelay)}),Bi("toasts",r=>r.id!==void 0,Ki(r=>r.visible=!1));break;case Rt.REMOVE_TOAST:if(!e.toastId){Bi("toasts",[]);break}Bi("toasts",r=>r.filter(s=>s.id!==e.toastId));break;case Rt.UPDATE_TOAST:e.toast.id&&$y(e.toast.id),Bi("toasts",r=>r.id===e.toast.id,r=>({...r,...e.toast}));break;case Rt.UPSERT_TOAST:Cr.toasts.find(r=>r.id===e.toast.id)?Xn({type:Rt.UPDATE_TOAST,toast:e.toast}):Xn({type:Rt.ADD_TOAST,toast:e.toast});break;case Rt.START_PAUSE:Bi(Ki(r=>{r.pausedAt=Date.now(),r.toasts.forEach(a=>{a.paused=!0})}));break;case Rt.END_PAUSE:const i=e.time-(Cr.pausedAt||0);Bi(Ki(r=>{r.pausedAt=void 0,r.toasts.forEach(a=>{a.pauseDuration+=i,a.paused=!1})}));break}},Gy={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Ea={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},cE={position:"top-right",toastOptions:Ea,gutter:8,containerStyle:{},containerClassName:""},vo="16px",Yy={position:"fixed","z-index":9999,top:vo,bottom:vo,left:vo,right:vo,"pointer-events":"none"},Vy=(()=>{let e=0;return()=>String(++e)})(),Hy=e=>{jy(t=>({containerClassName:e.containerClassName??t.containerClassName,containerStyle:e.containerStyle??t.containerStyle,gutter:e.gutter??t.gutter,position:e.position??t.position,toastOptions:{...e.toastOptions}}))},Wy=(e,t)=>{const i=e.includes("top")?{top:0,"margin-top":`${t}px`}:{bottom:0,"margin-bottom":`${t}px`},r=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)",...i,...r}},zy=(e,t)=>{const n=e.getBoundingClientRect();n.height!==t.height&&Xn({type:Rt.UPDATE_TOAST,toast:{id:t.id,height:n.height}})},Ky=(e,t)=>{const{toasts:n}=Cr,i=Zr().gutter||cE.gutter||8,r=n.filter(l=>(l.position||t)===t&&l.height),a=r.findIndex(l=>l.id===e.id),s=r.filter((l,c)=>c<a&&l.visible).length;return r.slice(0,s).reduce((l,c)=>l+i+(c.height||0),0)},qy=(e,t)=>(e.position||t).includes("top")?1:-1,Qy={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"},Xy={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},yo={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},El=e=>({calcMode:"spline",keyTimes:"0; 1",keySplines:e}),[Zr,jy]=Q(cE),Zy=(e,t="blank",n)=>{var i,r,a;return{...Ea,...Zr().toastOptions,...n,type:t,message:e,pauseDuration:0,createdAt:Date.now(),visible:!0,id:n.id||Vy(),paused:!1,style:{...Ea.style,...(i=Zr().toastOptions)==null?void 0:i.style,...n.style},duration:n.duration||((r=Zr().toastOptions)==null?void 0:r.duration)||Gy[t],position:n.position||((a=Zr().toastOptions)==null?void 0:a.position)||Zr().position||Ea.position}},lo=e=>(t,n={})=>Cd(()=>{const i=Cr.toasts.find(a=>a.id===n.id),r=Zy(t,e,{...i,duration:void 0,...n});return Xn({type:Rt.UPSERT_TOAST,toast:r}),r.id}),Mn=(e,t)=>lo("blank")(e,t);Fa(()=>Mn);Mn.error=lo("error");Mn.success=lo("success");Mn.loading=lo("loading");Mn.custom=lo("custom");Mn.dismiss=e=>{Xn({type:Rt.DISMISS_TOAST,toastId:e})};Mn.promise=(e,t,n)=>{const i=Mn.loading(t.loading,{...n});return e.then(r=>(Mn.success(ml(t.success,r),{id:i,...n}),r)).catch(r=>{Mn.error(ml(t.error,r),{id:i,...n})}),e};Mn.remove=e=>{Xn({type:Rt.REMOVE_TOAST,toastId:e})};var Jy=G("<div><style>.sldt-active{z-index:9999;}.sldt-active>*{pointer-events:auto;}");const eC=e=>(fe(()=>{Hy(e)}),fe(()=>{const t=By();xe(()=>{t&&t.forEach(n=>n&&clearTimeout(n))})}),(()=>{var t=Jy();return t.firstChild,I(t,T(We,{get each(){return Cr.toasts},children:n=>T(rC,{toast:n})}),null),ue(n=>{var i={...Yy,...e.containerStyle},r=e.containerClassName;return n.e=wn(t,i,n.e),r!==n.t&&He(t,n.t=r),n},{e:void 0,t:void 0}),t})());var Co=G("<div>"),tC=G("<div><div>");const nC=e=>{let t;return fe(()=>{if(!t)return;const n=qy(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=tC(),i=n.firstChild,r=t;return typeof r=="function"?Nt(r,n):t=n,I(n,T(ic,{get children(){return[T(bn,{get when(){return e.toast.icon},get children(){var a=Co();return I(a,()=>e.toast.icon),ue(s=>wn(a,yo,s)),a}}),T(bn,{get when(){return e.toast.type==="loading"},get children(){var a=Co();return I(a,T(_C,Ne(()=>e.toast.iconTheme))),ue(s=>wn(a,yo,s)),a}}),T(bn,{get when(){return e.toast.type==="success"},get children(){var a=Co();return I(a,T(lC,Ne(()=>e.toast.iconTheme))),ue(s=>wn(a,yo,s)),a}}),T(bn,{get when(){return e.toast.type==="error"},get children(){var a=Co();return I(a,T(dC,Ne(()=>e.toast.iconTheme))),ue(s=>wn(a,yo,s)),a}})]}}),i),li(i,Ne(()=>e.toast.ariaProps),!1,!0),I(i,()=>ml(e.toast.message,e.toast)),ue(a=>{var s=e.toast.className,o={...Qy,...e.toast.style},l=Xy;return s!==a.e&&He(n,a.e=s),a.t=wn(n,o,a.t),a.a=wn(i,l,a.a),a},{e:void 0,t:void 0,a:void 0}),n})()};var iC=G("<div>");const rC=e=>{const t=()=>{const r=e.toast.position||Ea.position,a=Ky(e.toast,r);return Wy(r,a)},n=V(()=>t());let i;return dn(()=>{i&&zy(i,e.toast)}),(()=>{var r=iC();r.addEventListener("mouseleave",()=>Xn({type:Rt.END_PAUSE,time:Date.now()})),r.addEventListener("mouseenter",()=>Xn({type:Rt.START_PAUSE,time:Date.now()}));var a=i;return typeof a=="function"?Nt(a,r):i=r,I(r,(()=>{var s=ke(()=>e.toast.type==="custom");return()=>s()?ml(e.toast.message,e.toast):T(nC,{get toast(){return e.toast},get position(){return e.toast.position||Ea.position}})})()),ue(s=>{var o=n(),l=e.toast.visible?"sldt-active":"";return s.e=wn(r,o,s.e),l!==s.t&&He(r,s.t=l),s},{e:void 0,t:void 0}),r})()};var aC=G('<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),sC=G('<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 dE=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=aC(),i=n.firstChild,r=i.nextSibling;return li(i,t,!0,!1),li(r,t,!0,!1),ue(()=>Fe(n,"fill",e.fill)),n})()},uE=e=>{const t={dur:"1s",begin:e.begin||"320ms",fill:"freeze",...El("0.0 0.0 0.2 1")};return(()=>{var n=sC(),i=n.firstChild,r=i.nextSibling;return li(i,t,!0,!1),li(r,t,!0,!1),ue(()=>Fe(n,"fill",e.fill)),n})()};var oC=G('<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 lC=e=>{const t=e.primary||"#34C759";return(()=>{var n=oC(),i=n.firstChild,r=i.firstChild;return I(n,T(dE,{fill:t}),i),I(n,T(uE,{fill:t,begin:"350ms"}),i),li(r,Ne(()=>El("0.0, 0.0, 0.58, 1.0")),!0,!1),ue(()=>Fe(i,"stroke",e.secondary||"#FCFCFC")),n})()};var cC=G('<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 dC=e=>{const t=e.primary||"#FF3B30";return(()=>{var n=cC(),i=n.firstChild,r=i.firstChild,a=i.nextSibling,s=a.firstChild;return I(n,T(dE,{fill:t}),i),I(n,T(uE,{fill:t}),i),li(r,Ne(()=>El("0.0, 0.0, 0.58, 1.0")),!0,!1),li(s,Ne(()=>El("0.0, 0.0, 0.58, 1.0")),!0,!1),ue(o=>{var l=e.secondary||"#FFFFFF",c=e.secondary||"#FFFFFF";return l!==o.e&&Fe(i,"stroke",o.e=l),c!==o.t&&Fe(a,"fill",o.t=c),o},{e:void 0,t:void 0}),n})()};var uC=G('<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 _C=e=>(()=>{var t=uC(),n=t.firstChild,i=n.nextSibling;return ue(r=>{var a=e.primary||"#E5E7EB",s=e.secondary||"#4b5563";return a!==r.e&&Fe(n,"stroke",r.e=a),s!==r.t&&Fe(i,"stroke",r.t=s),r},{e:void 0,t:void 0}),t})(),[xd,Vu]=Q(null);function vi(e,t){Vu({type:"alert",message:e,...t})}function mC(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(i=>{Vu({type:"confirm",message:e,...t,resolve:i})})}function pC(){Vu(null)}var gC=G('<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>'),fC=G('<div class="mt-6 flex justify-end gap-3"><button type=button class=button-primary>'),EC=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),hC=G('<p class="mt-2 text-secondary">'),SC=G("<button type=button class=button-secondary>");const bC={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 Gc(e,t){var i,r,a,s;const n=t??xd();(n==null?void 0:n.type)==="confirm"?(e?(i=n.onConfirm)==null||i.call(n):(r=n.onCancel)==null||r.call(n),(a=n.resolve)==null||a.call(n,e)):e&&((s=n==null?void 0:n.onConfirm)==null||s.call(n)),pC()}const TC=()=>{let e;return fe(()=>{xd()&&queueMicrotask(()=>{e==null||e.focus()})}),T(ee,{get when(){return xd()},keyed:!0,children:t=>{const n=t.variant??"info",i=bC[n],r=t.title||i.fallbackTitle,a=t.type==="confirm",s=t.confirmLabel||(a?"Confirm":"OK"),o=t.cancelLabel||"Cancel";return T(Ze,{open:!0,modal:!0,onOpenChange:l=>{l||Gc(!1,t)},get children(){return T(Ze.Portal,{get children(){return[T(Ze.Overlay,{class:"modal-overlay"}),(()=>{var l=EC();return I(l,T(Ze.Content,{class:"modal-surface w-full max-w-sm p-6 border border-base shadow-2xl",tabIndex:-1,get children(){return[(()=>{var c=gC(),d=c.firstChild,u=d.nextSibling;return I(d,()=>i.symbol),I(u,T(Ze.Title,{class:"text-lg font-semibold text-primary",children:r}),null),I(u,T(Ze.Description,{class:"text-sm text-secondary mt-1 whitespace-pre-line",get children(){return[ke(()=>t.message),ke(()=>ke(()=>!!t.detail)()&&(()=>{var _=hC();return I(_,()=>t.detail),_})())]}}),null),ue(_=>{var m=i.badgeBg,p=i.badgeBorder,g=i.badgeText;return m!==_.e&&bs(d,"background-color",_.e=m),p!==_.t&&bs(d,"border-color",_.t=p),g!==_.a&&bs(d,"color",_.a=g),_},{e:void 0,t:void 0,a:void 0}),c})(),(()=>{var c=fC(),d=c.firstChild;return I(c,a&&(()=>{var u=SC();return u.$$click=()=>Gc(!1,t),I(u,o),u})(),d),d.$$click=()=>Gc(!0,t),Nt(u=>{e=u},d),I(d,s),c})()]}})),l})()]}})}})}})};At(["click"]);const Wr={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 vC=G("<svg>");const yC=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Tt=e=>{const[t,n]=Qe(e,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var i=vC();return li(i,Ne(Wr,{get width(){return t.size??Wr.width},get height(){return t.size??Wr.height},get stroke(){return t.color??Wr.stroke},get"stroke-width"(){return ke(()=>!!t.absoluteStrokeWidth)()?Number(t.strokeWidth??Wr["stroke-width"])*24/Number(t.size):Number(t.strokeWidth??Wr["stroke-width"])},get class(){return`lucide lucide-${yC((t==null?void 0:t.name)??"icon")} ${t.class!=null?t.class:""}`}},n),!0,!0),I(i,T(We,{get each(){return t.iconNode},children:([r,a])=>T(Lf,Ne({component:r},a))})),i})()},CC=[["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"}]],RC=e=>T(Tt,Ne(e,{name:"AlertCircle",iconNode:CC})),IC=[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]],_E=e=>T(Tt,Ne(e,{name:"ArrowUpLeft",iconNode:IC})),OC=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],NC=e=>T(Tt,Ne(e,{name:"Check",iconNode:OC})),AC=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Hu=e=>T(Tt,Ne(e,{name:"ChevronDown",iconNode:AC})),xC=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],wC=e=>T(Tt,Ne(e,{name:"ChevronRight",iconNode:xC})),DC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],LC=e=>T(Tt,Ne(e,{name:"Clock",iconNode:DC})),MC=[["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"}]],kC=e=>T(Tt,Ne(e,{name:"Copy",iconNode:MC})),PC=[["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"}]],FC=e=>T(Tt,Ne(e,{name:"File",iconNode:PC})),UC=[["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"}]],mE=e=>T(Tt,Ne(e,{name:"FolderOpen",iconNode:UC})),BC=[["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"}]],$C=e=>T(Tt,Ne(e,{name:"FolderPlus",iconNode:BC})),GC=[["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"}]],Wu=e=>T(Tt,Ne(e,{name:"Folder",iconNode:GC})),YC=[["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"}]],VC=e=>T(Tt,Ne(e,{name:"Globe",iconNode:YC})),HC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],WC=e=>T(Tt,Ne(e,{name:"Info",iconNode:HC})),zC=[["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"}]],Zm=e=>T(Tt,Ne(e,{name:"Key",iconNode:zC})),KC=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Us=e=>T(Tt,Ne(e,{name:"Loader2",iconNode:KC})),qC=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]],QC=e=>T(Tt,Ne(e,{name:"MessageSquare",iconNode:qC})),XC=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],zu=e=>T(Tt,Ne(e,{name:"Plus",iconNode:XC})),jC=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],ZC=e=>T(Tt,Ne(e,{name:"Search",iconNode:jC})),JC=[["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"}]],eR=e=>T(Tt,Ne(e,{name:"Settings",iconNode:JC})),tR=[["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"}]],Ku=e=>T(Tt,Ne(e,{name:"Trash2",iconNode:tR})),nR=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],rc=e=>T(Tt,Ne(e,{name:"X",iconNode:nR})),Jm="http://127.0.0.1:9898";var Df;const iR=typeof window<"u"?(Df=window.location)==null?void 0:Df.origin:void 0,rR=typeof window<"u"?window.__CODENOMAD_API_BASE__??iR??Jm:Jm,aR=typeof window<"u"?window.__CODENOMAD_EVENTS_URL__??"/api/events":"/api/events",hl=rR,ep=oR(hl,aR),sR=hl;function oR(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(e){const n=t.startsWith("/")?t:`/${t}`;return`${e}${n}`}return t}const tp="[HTTP]";function Ro(e,t){if(t){console.log(`${tp} ${e}`,t);return}console.log(`${tp} ${e}`)}async function Ut(e,t){const n=hl?new URL(e,hl).toString():e,i={"Content-Type":"application/json",...(t==null?void 0:t.headers)??{}},r=((t==null?void 0:t.method)??"GET").toUpperCase(),a=Date.now();Ro(`${r} ${e}`);try{const s=await fetch(n,{...t,headers:i});if(!s.ok){const l=await s.text();throw Ro(`${r} ${e} -> ${s.status}`,{durationMs:Date.now()-a,error:l}),new Error(l||`Request failed with ${s.status}`)}const o=Date.now()-a;return Ro(`${r} ${e} -> ${s.status}`,{durationMs:o}),s.status===204?void 0:await s.json()}catch(s){throw Ro(`${r} ${e} failed`,{durationMs:Date.now()-a,error:s}),s}}const cn={fetchWorkspaces(){return Ut("/api/workspaces")},createWorkspace(e){return Ut("/api/workspaces",{method:"POST",body:JSON.stringify(e)})},fetchServerMeta(){return Ut("/api/meta")},deleteWorkspace(e){return Ut(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})},listWorkspaceFiles(e,t="."){const n=new URLSearchParams({path:t});return Ut(`/api/workspaces/${encodeURIComponent(e)}/files?${n.toString()}`)},searchWorkspaceFiles(e,t,n){const i=t.trim();if(!i)return Promise.resolve([]);const r=new URLSearchParams({q:i});return n!=null&&n.limit&&r.set("limit",String(n.limit)),n!=null&&n.type&&r.set("type",n.type),Ut(`/api/workspaces/${encodeURIComponent(e)}/files/search?${r.toString()}`)},readWorkspaceFile(e,t){const n=new URLSearchParams({path:t});return Ut(`/api/workspaces/${encodeURIComponent(e)}/files/content?${n.toString()}`)},fetchConfig(){return Ut("/api/config/app")},updateConfig(e){return Ut("/api/config/app",{method:"PUT",body:JSON.stringify(e)})},listBinaries(){return Ut("/api/config/binaries")},createBinary(e){return Ut("/api/config/binaries",{method:"POST",body:JSON.stringify(e)})},updateBinary(e,t){return Ut(`/api/config/binaries/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})},deleteBinary(e){return Ut(`/api/config/binaries/${encodeURIComponent(e)}`,{method:"DELETE"})},validateBinary(e){return Ut("/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 i=n.toString();return Ut(i?`/api/filesystem?${i}`:"/api/filesystem")},readInstanceData(e){return Ut(`/api/storage/instances/${encodeURIComponent(e)}`)},writeInstanceData(e,t){return Ut(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})},deleteInstanceData(e){return Ut(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"DELETE"})},connectEvents(e,t){console.log(`[SSE] Connecting to ${ep}`);const n=new EventSource(ep);return n.onmessage=i=>{try{const r=JSON.parse(i.data);e(r)}catch(r){console.error("[SSE] Failed to parse event",r)}},n.onerror=()=>{console.warn("[SSE] EventSource error, closing stream"),t==null||t()},n}},np=1e3,lR=1e4,ip="[SSE]";function Io(e,t){if(t){console.log(`${ip} ${e}`,t);return}console.log(`${ip} ${e}`)}class cR{constructor(){this.handlers=new Map,this.source=null,this.retryDelay=np,this.connect()}connect(){this.source&&this.source.close(),Io("Connecting to backend events stream"),this.source=cn.connectEvents(t=>this.dispatch(t),()=>this.scheduleReconnect()),this.source.onopen=()=>{Io("Events stream connected"),this.retryDelay=np}}scheduleReconnect(){this.source&&(this.source.close(),this.source=null),Io("Events stream disconnected, scheduling reconnect",{delayMs:this.retryDelay}),setTimeout(()=>{this.retryDelay=Math.min(this.retryDelay*2,lR),this.connect()},this.retryDelay)}dispatch(t){var n,i;Io(`event ${t.type}`),(n=this.handlers.get("*"))==null||n.forEach(r=>r(t)),(i=this.handlers.get(t.type))==null||i.forEach(r=>r(t))}on(t,n){this.handlers.has(t)||this.handlers.set(t,new Set);const i=this.handlers.get(t);return i.add(n),()=>i.delete(n)}}const Bs=new cR,rp={messageHistory:[],agentModelSelections:{}};function ap(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){console.warn("Failed to compare config objects",n)}return!1}class dR{constructor(){this.configChangeListeners=new Set,this.configCache=null,this.loadPromise=null,this.instanceDataCache=new Map,this.instanceDataListeners=new Map,this.instanceLoadPromises=new Map,Bs.on("config.appChanged",t=>{t.type==="config.appChanged"&&this.setConfigCache(t.config)}),Bs.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=cn.fetchConfig().then(t=>(this.setConfigCache(t),t)).finally(()=>{this.loadPromise=null})),this.loadPromise)}async updateConfig(t){const n=await cn.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 i=cn.readInstanceData(t).then(r=>{const a=this.normalizeInstanceData(r);return this.setInstanceDataCache(t,a),a}).finally(()=>{this.instanceLoadPromises.delete(t)});this.instanceLoadPromises.set(t,i)}return this.instanceLoadPromises.get(t)}async saveInstanceData(t,n){const i=this.normalizeInstanceData(n);await cn.writeInstanceData(t,i),this.setInstanceDataCache(t,i)}async deleteInstanceData(t){await cn.deleteInstanceData(t),this.setInstanceDataCache(t,rp)}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 i=this.instanceDataListeners.get(t);i.add(n);const r=this.instanceDataCache.get(t);return r&&n(r),()=>{i.delete(n),i.size===0&&this.instanceDataListeners.delete(t)}}setConfigCache(t){if(this.configCache&&ap(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??rp,i=Array.isArray(n.messageHistory)?[...n.messageHistory]:[],r={...n.agentModelSelections??{}};return{...n,messageHistory:i,agentModelSelections:r}}setInstanceDataCache(t,n){const i=this.normalizeInstanceData(n),r=this.instanceDataCache.get(t);if(r&&ap(r,i)){this.instanceDataCache.set(t,i);return}this.instanceDataCache.set(t,i),this.notifyInstanceDataChanged(t,i)}notifyInstanceDataChanged(t,n){const i=this.instanceDataListeners.get(t);if(i)for(const r of i)r(n)}}const Ar=new dR,ac={messageHistory:[],agentModelSelections:{}},[qu,pE]=Q(new Map),Oo=new Map,Ra=new Map;function gE(e){const t=e??ac;return{...t,messageHistory:Array.isArray(t.messageHistory)?[...t.messageHistory]:[],agentModelSelections:{...t.agentModelSelections??{}}}}function sp(e){if(Ra.has(e))return;const t=Ar.onInstanceDataChanged(e,n=>{Sl(e,n)});Ra.set(e,t)}function uR(e){const t=Ra.get(e);t&&(t(),Ra.delete(e))}function Sl(e,t){pE(n=>{const i=new Map(n);return i.set(e,gE(t)),i})}async function Ur(e){if(!e||qu().has(e))return;if(Oo.has(e)){await Oo.get(e);return}const t=Ar.loadInstanceData(e).then(n=>{Sl(e,n),sp(e)}).catch(n=>{console.warn("Failed to load instance data:",n),Sl(e,ac),sp(e)}).finally(()=>{Oo.delete(e)});Oo.set(e,t),await t}async function Qu(e,t){if(!e)return;await Ur(e);const n=qu().get(e)??ac,i=gE(n);t(i);try{await Ar.saveInstanceData(e,i)}catch(r){console.warn("Failed to persist instance data:",r)}Sl(e,i)}function Xu(e){return qu().get(e)??ac}function _R(e){pE(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),uR(e)}const mR=un(),pR={getInstanceConfig:Xu,ensureInstanceConfig:Ur,updateInstanceConfig:Qu,clearInstanceConfig:_R},gR=e=>(xe(()=>{for(const t of Ra.values())t();Ra.clear()}),T(mR.Provider,{value:pR,get children(){return e.children}})),fR=20,ER=5,pi={showThinkingBlocks:!1,thinkingBlocksExpansion:"expanded",environmentVariables:{},modelRecents:[],diffViewMode:"split",toolOutputExpansion:"expanded",diagnosticsExpansion:"expanded",showUsageMetrics:!0};function fE(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){console.warn("Failed to compare preference values",n)}return!1}function sc(e){const t=e??{},n={...pi.environmentVariables,...t.environmentVariables??{}},r=(t.modelRecents??pi.modelRecents).map(a=>({...a}));return{showThinkingBlocks:t.showThinkingBlocks??pi.showThinkingBlocks,thinkingBlocksExpansion:t.thinkingBlocksExpansion??pi.thinkingBlocksExpansion,lastUsedBinary:t.lastUsedBinary??pi.lastUsedBinary,environmentVariables:n,modelRecents:r,diffViewMode:t.diffViewMode??pi.diffViewMode,toolOutputExpansion:t.toolOutputExpansion??pi.toolOutputExpansion,diagnosticsExpansion:t.diagnosticsExpansion??pi.diagnosticsExpansion,showUsageMetrics:t.showUsageMetrics??pi.showUsageMetrics}}const[ur,hR]=Q(SE()),SR=V(()=>ur()),[EE,bR]=Q(!1),Rn=V(()=>ur().preferences),TR=V(()=>ur().recentFolders??[]),vR=V(()=>ur().opencodeBinaries??[]),hE=V(()=>ur().theme??"dark");let No=null;function oc(e){return{preferences:sc(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 SE(){return oc()}function yR(e){var i;const t=!!((i=e==null?void 0:e.preferences)!=null&&i.agentModelSelections);return{cleaned:oc(e),migrated:t}}async function ju(e){try{const t=e??await Ar.loadConfig(),{cleaned:n,migrated:i}=yR(t);wd(n),i&&Ar.updateConfig(n).catch(r=>{console.error("Failed to persist legacy config cleanup:",r)})}catch(t){console.error("Failed to load config:",t),wd(SE())}}function wd(e){hR(oc(e)),bR(!0)}function CR(){return oc(ur())}function RR(e,t){if(fE(e,t))return;const n=bE(e,t);n.length>0&&console.debug("[Config] Changes",n)}function bE(e,t,n=[]){if(e===t)return[];if(typeof e!="object"||e===null||typeof t!="object"||t===null)return[n.join(".")];const i=Object.keys(e),r=Object.keys(t),a=new Set([...i,...r]),s=[];for(const o of a){const l=[...n,o],c=e[o],d=t[o];s.push(...bE(c,d,l))}return s}function Mi(e){const t=ur(),n=CR();e(n),RR(t,n),wd(n),IR(n)}async function IR(e){try{await Zu(),await Ar.updateConfig(e)}catch(t){console.error("Failed to save config:",t),ju().catch(n=>{console.error("Failed to refresh config:",n)})}}function OR(e){hE()!==e&&Mi(t=>{t.theme=e})}async function Zu(){EE()||(No||(No=ju().finally(()=>{No=null})),await No)}function TE(e,t){const n=t.filter(i=>i.path!==e);return n.unshift({path:e,lastAccessed:Date.now()}),n.slice(0,fR)}function Ju(e,t,n){const i=Date.now(),r=n.find(s=>s.path===e);if(r){const s={...r,lastUsed:i},o=n.filter(l=>l.path!==e);return[s,...o]}return[t?{path:e,version:t,lastUsed:i}:{path:e,lastUsed:i},...n].slice(0,10)}function ki(e){const t=ur().preferences,n=sc({...t,...e});fE(t,n)||Mi(i=>{i.preferences=n})}function NR(e){Rn().diffViewMode!==e&&ki({diffViewMode:e})}function AR(e){Rn().toolOutputExpansion!==e&&ki({toolOutputExpansion:e})}function xR(e){Rn().diagnosticsExpansion!==e&&ki({diagnosticsExpansion:e})}function wR(e){Rn().thinkingBlocksExpansion!==e&&ki({thinkingBlocksExpansion:e})}function DR(){ki({showThinkingBlocks:!Rn().showThinkingBlocks})}function LR(){ki({showUsageMetrics:!Rn().showUsageMetrics})}function MR(e){Mi(t=>{t.recentFolders=TE(e,t.recentFolders)})}function kR(e){Mi(t=>{t.recentFolders=t.recentFolders.filter(n=>n.path!==e)})}function PR(e,t){Mi(n=>{n.opencodeBinaries=Ju(e,t,n.opencodeBinaries)})}function FR(e){Mi(t=>{t.opencodeBinaries=t.opencodeBinaries.filter(n=>n.path!==e)})}function UR(e){const t=e||Rn().lastUsedBinary||"opencode";Mi(n=>{n.preferences=sc({...n.preferences,lastUsedBinary:t}),n.opencodeBinaries=Ju(t,void 0,n.opencodeBinaries)})}function BR(e,t){Mi(n=>{const i=t&&t.trim().length>0?t:n.preferences.lastUsedBinary||"opencode";n.recentFolders=TE(e,n.recentFolders),n.preferences=sc({...n.preferences,lastUsedBinary:i}),n.opencodeBinaries=Ju(i,void 0,n.opencodeBinaries)})}function e_(e){ki({environmentVariables:e})}function $R(e,t){const i={...Rn().environmentVariables||{},[e]:t};e_(i)}function GR(e){const t=Rn().environmentVariables||{},{[e]:n,...i}=t;e_(i)}function vE(e){if(!e.providerId||!e.modelId)return;const n=(Rn().modelRecents??[]).filter(r=>r.providerId!==e.providerId||r.modelId!==e.modelId),i=[e,...n].slice(0,ER);ki({modelRecents:i})}async function lc(e,t,n){!e||!t||!n.providerId||!n.modelId||(await Ur(e),await Qu(e,i=>{const r={...i.agentModelSelections??{}},a=r[t];a&&a.providerId===n.providerId&&a.modelId===n.modelId||(r[t]=n,i.agentModelSelections=r)}))}async function yE(e,t){return!e||!t?void 0:(await Ur(e),(Xu(e).agentModelSelections??{})[t])}Zu().catch(e=>{console.error("Failed to initialize config:",e)});const CE=un(),YR={isLoaded:EE,config:SR,preferences:Rn,recentFolders:TR,opencodeBinaries:vR,themePreference:hE,setThemePreference:OR,updateConfig:Mi,toggleShowThinkingBlocks:DR,toggleUsageMetrics:LR,setDiffViewMode:NR,setToolOutputExpansion:AR,setDiagnosticsExpansion:xR,setThinkingBlocksExpansion:wR,addRecentFolder:MR,removeRecentFolder:kR,addOpenCodeBinary:PR,removeOpenCodeBinary:FR,updateLastUsedBinary:UR,recordWorkspaceLaunch:BR,updatePreferences:ki,updateEnvironmentVariables:e_,addEnvironmentVariable:$R,removeEnvironmentVariable:GR,addRecentModelPreference:vE,setAgentModelPreference:lc,getAgentModelPreference:yE},VR=e=>(dn(()=>{Zu().catch(n=>{console.error("Failed to initialize config:",n)});const t=Ar.onConfigChanged(n=>{ju(n).catch(i=>{console.error("Failed to refresh config:",i)})});return()=>{t()}}),T(CE.Provider,{value:YR,get children(){return e.children}}));function _r(){const e=Cn(CE);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e}var HR=G('<p class="text-xs text-muted mt-1 font-mono break-all">Root: '),WR=G('<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'),zR=G('<div class="flex items-center gap-2 px-4 py-2 text-xs text-secondary"><span>Loading <!>…'),KR=G('<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'),qR=G('<div class="flex items-center gap-2"><span>Loading <!>…'),QR=G('<div class="flex items-center justify-center py-6 text-sm text-secondary">'),XR=G("<span class=text-red-500>"),jR=G('<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'),ZR=G('<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'),JR=G('<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 eI=200;function Yc(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 ts(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;const n=e.includes("\\")?"\\":"/",i=e.endsWith(n)?e:`${e}${n}`,r=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${i}${r}`}const tI=e=>{const[t,n]=Q(""),[i,r]=Q([]),[a,s]=Q(null),[o,l]=Q(null),[c,d]=Q(null),[u,_]=Q(""),[m,p]=Q(0);let g;const E=new Map,h=new Map,f=new Map;function S(){E.clear(),h.clear(),f.clear(),r([]),s(null),l(null)}async function v(D,O=!1){const y=Yc(D);if(E.has(y)&&h.has(y))return O&&(s(h.get(y)??null),r(E.get(y)??[])),h.get(y);if(f.has(y)){const P=await f.get(y);return O&&(s(P),r(E.get(y)??[])),P}const N=(async()=>{l(y);const P=await cn.listFileSystem(y==="."?".":y,{includeFiles:e.mode==="files"});return E.set(y,P.entries),h.set(y,P.metadata),t()||n(P.metadata.rootPath),o()===y&&l(null),P.metadata})().catch(P=>{throw o()===y&&l(null),P});f.set(y,N);try{const P=await N;if(O){const H=Yc(P.currentPath);s(P),r(E.get(H)??E.get(y)??[])}return P}finally{f.delete(y)}}async function b(){d(null),S();try{const D=await v(".",!0);n(D.rootPath),r(E.get(Yc(D.currentPath))??[])}catch(D){const O=D instanceof Error?D.message:"Unable to load filesystem";d(O)}}function C(){const D=o();return D?D==="."?t()||"workspace root":ts(t(),D):"filesystem"}function R(){const D=a();return D?D.pathKind==="relative"?ts(t(),D.currentPath):D.displayPath:t()}function A(D){D.target===D.currentTarget&&e.onClose()}function U(D){const O=ts(t(),D.path);e.onSelect(O)}function w(D){v(D,!0).catch(O=>{console.error("Failed to open directory",O),d(O instanceof Error?O.message:"Unable to open directory")})}function M(){var O;const D=(O=a())==null?void 0:O.parentPath;D&&w(D)}const Y=V(()=>{const D=u().trim().toLowerCase(),O=i().filter(y=>e.mode==="directories"?y.type==="directory":!0);return D?O.filter(y=>ts(t(),y.path).toLowerCase().includes(D)||y.name.toLowerCase().includes(D)):O}),$=V(()=>Y().slice(0,eI)),k=V(()=>{const D=[],O=a();O!=null&&O.parentPath&&D.push({type:"up",path:O.parentPath});for(const y of $())D.push({type:"entry",entry:y});return D});return fe(()=>{const D=$();if(D.length===0){p(0);return}m()>=D.length&&p(D.length-1)}),fe(()=>{if(!e.open)return;_(""),p(0),b(),setTimeout(()=>g==null?void 0:g.focus(),50);const D=O=>{if(!e.open)return;const y=$();if(O.key==="Escape"){O.preventDefault(),e.onClose();return}if(y.length!==0){if(O.key==="ArrowDown")O.preventDefault(),p(N=>Math.min(N+1,y.length-1));else if(O.key==="ArrowUp")O.preventDefault(),p(N=>Math.max(N-1,0));else if(O.key==="Enter"){O.preventDefault();const N=y[m()];N&&U(N)}}};window.addEventListener("keydown",D),xe(()=>{window.removeEventListener("keydown",D),S(),n(""),d(null)})}),T(ee,{get when(){return e.open},get children(){var D=KR(),O=D.firstChild,y=O.firstChild,N=y.firstChild,P=N.firstChild,H=P.firstChild,Z=H.nextSibling,ae=P.nextSibling,Se=ae.firstChild,ne=N.nextSibling,ie=ne.firstChild,Te=ie.nextSibling,Ee=Te.firstChild,le=Ee.nextSibling,Me=ne.nextSibling;return D.$$click=A,I(H,()=>e.title),I(Z,()=>e.description||"Search for a path under the configured workspace root."),I(P,T(ee,{get when(){return t()},get children(){var Re=HR();return Re.firstChild,I(Re,t,null),Re}}),null),cr(ae,"click",e.onClose,!0),I(ae,T(rc,{class:"w-4 h-4"}),Se),I(Ee,T(ZC,{class:"w-4 h-4"})),le.$$input=Re=>_(Re.currentTarget.value),Nt(Re=>{g=Re},le),I(y,T(ee,{get when(){return e.mode==="directories"},get children(){var Re=WR(),he=Re.firstChild,z=he.firstChild,K=z.firstChild,J=K.nextSibling,me=z.nextSibling;return I(J,R),me.$$click=()=>e.onSelect(R()),Re}}),Me),I(Me,T(ee,{get when(){return i().length>0},get fallback(){return(()=>{var Re=QR();return I(Re,T(ee,{get when(){return o()!==null},get fallback(){return(()=>{var he=XR();return I(he,c),he})()},get children(){var he=qR(),z=he.firstChild,K=z.firstChild,J=K.nextSibling;return J.nextSibling,I(he,T(Us,{class:"w-4 h-4 animate-spin"}),z),I(z,C,J),he}})),Re})()},get children(){return[T(ee,{get when(){return o()},get children(){var Re=zR(),he=Re.firstChild,z=he.firstChild,K=z.nextSibling;return K.nextSibling,I(Re,T(Us,{class:"w-3.5 h-3.5 animate-spin"}),he),I(he,C,K),Re}}),T(ee,{get when(){return k().length>0},get fallback(){return(()=>{var Re=jR(),he=Re.firstChild,z=he.nextSibling;return z.$$click=b,Re})()},get children(){return T(We,{get each(){return k()},children:Re=>{if(Re.type==="up")return(()=>{var J=ZR(),me=J.firstChild,te=me.firstChild,se=te.firstChild;return te.$$click=M,I(se,T(_E,{class:"w-4 h-4"})),J})();const he=Re.entry,z=()=>U(he),K=()=>{he.type==="directory"?w(he.path):z()};return(()=>{var J=JR(),me=J.firstChild,te=me.firstChild,se=te.firstChild,oe=se.nextSibling,Ie=oe.firstChild,be=Ie.nextSibling,ge=te.nextSibling;return te.$$click=K,I(se,T(ee,{get when(){return he.type==="directory"},get fallback(){return T(FC,{class:"w-4 h-4"})},get children(){return T(Wu,{class:"w-4 h-4"})}})),I(Ie,()=>he.name||he.path),I(be,()=>ts(t(),he.path)),ge.$$click=De=>{De.stopPropagation(),z()},J})()}})}})]}})),ue(()=>Fe(le,"placeholder",e.mode==="directories"?"Search for folders":"Search for files")),ue(()=>le.value=u()),D}})};At(["click","input"]);function nI(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 iI(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 nI(n)}catch(n){return console.error("[native] electron dialog failed",n),null}}async function rI(e){var i;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 r=await n.open({title:e.title,defaultPath:e.defaultPath,directory:e.mode==="directory",multiple:!1,filters:(i=e.filters)==null?void 0:i.map(a=>({name:a.name,extensions:a.extensions}))});return r?Array.isArray(r)?r[0]??null:r:null}catch(r){return console.error("[native] tauri dialog failed",r),null}}function RE(){switch(Id.host){case"electron":return iI;case"tauri":return rI;default:return null}}function IE(){return RE()!==null}async function OE(e){const t=RE();return t?t(e):null}async function aI(e){return OE({mode:"directory",...e??{}})}async function sI(e){return OE({mode:"file",...e??{}})}var oI=G('<div class="selector-loading text-xs"><span>Checking versions…'),lI=G("<div class=selector-validation-error><div class=selector-validation-error-content><span class=selector-validation-error-text>"),cI=G('<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">'),dI=G('<div class="text-xs font-mono truncate pl-6 text-muted">'),uI=G("<span class=selector-badge-version>v"),_I=G("<span class=selector-badge-time>Checking…"),mI=G("<span class=selector-badge-time>"),pI=G("<span class=selector-badge-time>Use binary from system PATH"),gI=G('<button type=button class="p-2 text-muted hover:text-primary"title="Remove binary">'),fI=G('<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 EI=e=>{const{opencodeBinaries:t,addOpenCodeBinary:n,removeOpenCodeBinary:i,preferences:r,updatePreferences:a}=_r(),[s,o]=Q(""),[l,c]=Q(!1),[d,u]=Q(null),[_,m]=Q(new Map),[p,g]=Q(new Set),[E,h]=Q(!1),f=IE(),S=()=>t(),v=()=>r().lastUsedBinary,b=V(()=>S().filter(N=>N.path!=="opencode")),C=V(()=>[{path:"opencode",isDefault:!0},...b()]),R=()=>e.selectedBinary||"opencode";fe(()=>{if(!e.selectedBinary&&v())e.onBinaryChange(v());else if(!e.selectedBinary){const N=S()[0];N&&e.onBinaryChange(N.path)}}),fe(()=>{const N=new Map(_());let P=!1;S().forEach(H=>{H.version&&!N.has(H.path)&&(N.set(H.path,H.version),P=!0)}),P&&m(N)}),fe(()=>{if(!e.isVisible)return;const N=_(),P=["opencode",...b().map(H=>H.path)].filter(H=>!N.has(H));P.length!==0&&setTimeout(()=>{P.forEach(H=>{A(H).catch(console.error)})},0)}),xe(()=>{g(new Set),c(!1)});async function A(N){if(_().has(N)){const P=_().get(N);return P?{valid:!0,version:P}:{valid:!0}}if(p().has(N))return{valid:!1,error:"Already validating"};try{g(H=>new Set(H).add(N)),c(!0),u(null);const P=await cn.validateBinary(N);if(P.valid&&P.version){const H=new Map(_());H.set(N,P.version),m(H)}return P}catch(P){return{valid:!1,error:P instanceof Error?P.message:String(P)}}finally{g(P=>{const H=new Set(P);return H.delete(N),H.size===0&&c(!1),H})}}async function U(){if(!e.disabled){if(u(null),f){const N=await sI({title:"Select OpenCode Binary"});N&&(o(N),w(N));return}h(!0)}}async function w(N){const P=await A(N);P.valid?(n(N,P.version),e.onBinaryChange(N),a({lastUsedBinary:N}),o(""),u(null)):u(P.error||"Invalid OpenCode binary")}function M(N){h(!1),o(N),w(N)}async function Y(){const N=s().trim();N&&await w(N)}function $(N){e.disabled||N!==e.selectedBinary&&(e.onBinaryChange(N),a({lastUsedBinary:N}))}function k(N,P){P.stopPropagation(),!e.disabled&&(i(N),e.selectedBinary===N&&(e.onBinaryChange("opencode"),a({lastUsedBinary:"opencode"})))}function D(N){if(!N)return"";const P=Math.floor((Date.now()-N)/1e3),H=Math.floor(P/60),Z=Math.floor(H/60),ae=Math.floor(Z/24);return ae>0?`${ae}d ago`:Z>0?`${Z}h ago`:H>0?`${H}m ago`:"just now"}function O(N){if(N==="opencode")return"opencode (system PATH)";const P=N.split(/[/\\]/);return P[P.length-1]??N}const y=N=>p().has(N);return[(()=>{var N=cI(),P=N.firstChild;P.firstChild;var H=P.nextSibling,Z=H.firstChild,ae=Z.firstChild,Se=ae.nextSibling,ne=Se.firstChild,ie=Z.nextSibling,Te=ie.firstChild,Ee=H.nextSibling;return I(P,T(ee,{get when(){return l()},get children(){var le=oI(),Me=le.firstChild;return I(le,T(Us,{class:"selector-loading-spinner"}),Me),le}}),null),ae.$$keydown=le=>{le.key==="Enter"&&(le.preventDefault(),Y())},ae.$$input=le=>o(le.currentTarget.value),Se.$$click=Y,I(Se,T(zu,{class:"w-4 h-4"}),ne),ie.$$click=()=>void U(),I(ie,T(mE,{class:"w-4 h-4"}),Te),I(H,T(ee,{get when(){return d()},get children(){var le=lI(),Me=le.firstChild,Re=Me.firstChild;return I(Me,T(RC,{class:"selector-validation-error-icon"}),Re),I(Re,d),le}}),null),I(Ee,T(We,{get each(){return C()},children:le=>{const Me=le.isDefault,Re=()=>_().get(le.path)??le.version;return(()=>{var he=fI(),z=he.firstChild,K=z.firstChild,J=K.firstChild,me=J.firstChild,te=J.nextSibling;return z.$$click=()=>$(le.path),I(J,T(NC,{get class(){return`w-4 h-4 transition-opacity ${R()===le.path?"opacity-100":"opacity-0"}`}}),me),I(me,()=>O(le.path)),I(K,T(ee,{when:!Me,get children(){var se=dI();return I(se,()=>le.path),se}}),te),I(te,T(ee,{get when(){return Re()},get children(){var se=uI();return se.firstChild,I(se,Re,null),se}}),null),I(te,T(ee,{get when(){return y(le.path)},get children(){return _I()}}),null),I(te,T(ee,{get when(){return!Me&&le.lastUsed},get children(){var se=mI();return I(se,()=>D(le.lastUsed)),se}}),null),I(te,T(ee,{when:Me,get children(){return pI()}}),null),I(he,T(ee,{when:!Me,get children(){var se=gI();return se.$$click=oe=>k(le.path,oe),I(se,T(Ku,{class:"w-3.5 h-3.5"})),ue(()=>se.disabled=e.disabled),se}}),null),ue(se=>{var oe=R()===le.path,Ie=e.disabled;return oe!==se.e&&he.classList.toggle("panel-list-item-highlight",se.e=oe),Ie!==se.t&&(z.disabled=se.t=Ie),se},{e:void 0,t:void 0}),he})()}})),ue(le=>{var Me=e.disabled,Re=e.disabled||!s().trim(),he=e.disabled;return Me!==le.e&&(ae.disabled=le.e=Me),Re!==le.t&&(Se.disabled=le.t=Re),he!==le.a&&(ie.disabled=le.a=he),le},{e:void 0,t:void 0,a:void 0}),ue(()=>ae.value=s()),N})(),T(tI,{get open(){return E()},mode:"files",title:"Select OpenCode Binary",description:"Browse files exposed by the CLI server.",onClose:()=>h(!1),onSelect:M})]};At(["input","keydown","click"]);var hI=G("<div class=space-y-2>"),SI=G('<div class="text-xs text-muted text-center py-2">No environment variables configured. Add variables above to customize the OpenCode environment.'),bI=G('<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.'),TI=G('<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 vI=e=>{const{preferences:t,addEnvironmentVariable:n,removeEnvironmentVariable:i,updateEnvironmentVariables:r}=_r(),[a,s]=Q(t().environmentVariables||{}),[o,l]=Q(""),[c,d]=Q(""),u=()=>Object.entries(a());function _(){const E=o().trim(),h=c().trim();E&&(n(E,h),s({...a(),[E]:h}),l(""),d(""))}function m(E){i(E);const{[E]:h,...f}=a();s(f)}function p(E,h){const f={...a(),[E]:h};s(f),r(f)}function g(E){E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),_())}return(()=>{var E=bI(),h=E.firstChild,f=h.firstChild,S=f.nextSibling,v=S.firstChild,b=v.nextSibling,C=b.nextSibling,R=C.nextSibling;R.nextSibling;var A=h.nextSibling,U=A.firstChild,w=U.firstChild,M=w.nextSibling,Y=U.nextSibling,$=A.nextSibling;return I(h,T(VC,{class:"w-4 h-4 icon-muted"}),f),I(S,()=>u().length,b),I(S,()=>u().length!==1?"s":"",R),I(E,T(ee,{get when(){return u().length>0},get children(){var k=hI();return I(k,T(We,{get each(){return u()},children:([D,O])=>(()=>{var y=TI(),N=y.firstChild,P=N.firstChild,H=P.nextSibling,Z=N.nextSibling;return I(N,T(Zm,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),P),P.value=D,H.$$input=ae=>p(D,ae.currentTarget.value),H.value=O,Z.$$click=()=>m(D),I(Z,T(Ku,{class:"w-3.5 h-3.5"})),ue(ae=>{var Se=e.disabled,ne=e.disabled,ie=e.disabled;return Se!==ae.e&&(P.disabled=ae.e=Se),ne!==ae.t&&(H.disabled=ae.t=ne),ie!==ae.a&&(Z.disabled=ae.a=ie),ae},{e:void 0,t:void 0,a:void 0}),y})()})),k}}),A),I(U,T(Zm,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),w),w.addEventListener("keypress",g),w.$$input=k=>l(k.currentTarget.value),M.addEventListener("keypress",g),M.$$input=k=>d(k.currentTarget.value),Y.$$click=_,I(Y,T(zu,{class:"w-3.5 h-3.5"})),I(E,T(ee,{get when(){return u().length===0},get children(){return SI()}}),$),ue(k=>{var D=e.disabled,O=e.disabled,y=e.disabled||!o().trim();return D!==k.e&&(w.disabled=k.e=D),O!==k.t&&(M.disabled=k.t=O),y!==k.a&&(Y.disabled=k.a=y),k},{e:void 0,t:void 0,a:void 0}),ue(()=>w.value=o()),ue(()=>M.value=c()),E})()};At(["input","click"]);var yI=G('<header class="px-6 py-4 border-b"style=border-color:var(--border-base)>'),CI=G('<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>'),RI=G('<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'),II=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">');const OI=e=>T(Ze,{get open(){return e.open},onOpenChange:t=>!t&&e.onClose(),get children(){return T(Ze.Portal,{get children(){return[T(Ze.Overlay,{class:"modal-overlay"}),(()=>{var t=II();return I(t,T(Ze.Content,{class:"modal-surface w-full max-w-5xl max-h-[90vh] flex flex-col overflow-hidden",get children(){return[(()=>{var n=yI();return I(n,T(Ze.Title,{class:"text-xl font-semibold text-primary",children:"Advanced Settings"})),n})(),(()=>{var n=CI(),i=n.firstChild,r=i.firstChild,a=r.nextSibling;return I(n,T(EI,{get selectedBinary(){return e.selectedBinary},get onBinaryChange(){return e.onBinaryChange},get disabled(){return!!e.isLoading},get isVisible(){return e.open}}),i),I(a,T(vI,{get disabled(){return!!e.isLoading}})),n})(),(()=>{var n=RI(),i=n.firstChild;return cr(i,"click",e.onClose,!0),n})()]}})),t})()]}})}});At(["click"]);const op="__drives__";var NI=G('<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'),AI=G('<div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto directory-browser-list"role=listbox>'),xI=G('<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">'),wI=G("<div class=directory-browser-loading><span>Loading folders…"),DI=G('<div class="panel-empty-state flex-1">'),LI=G("<span class=text-red-500>"),MI=G('<div class="panel-empty-state flex-1">No folders available.'),kI=G('<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>'),PI=G('<button type=button class="selector-button selector-button-secondary directory-browser-select">Select');function Ao(e){if(!e||e==="."||e==="./")return".";if(e===op)return op;let t=e.replace(/\\/g,"/");if(/^[a-zA-Z]:/.test(t)){const[n,i=""]=t.split(":"),r=i.startsWith("/")?i:i?`/${i}`:"/";return`${n.toUpperCase()}:${r.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 NE(e){return e.startsWith("/")||/^[a-zA-Z]:/.test(e)||e.startsWith("\\\\")}function lp(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;if(NE(t))return t;const n=e.includes("\\")?"\\":"/",i=e.endsWith(n)?e:`${e}${n}`,r=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${i}${r}`}const FI=e=>{const[t,n]=Q(""),[i,r]=Q(!1),[a,s]=Q(null),[o,l]=Q(new Map),[c,d]=Q(new Set),[u,_]=Q(null),[m,p]=Q(null),g=new Map,E=new Map;function h(){l(new Map),d(new Set),_(null),p(null),g.clear(),E.clear(),s(null)}fe(()=>{if(!e.open)return;h(),f();const k=D=>{D.key==="Escape"&&(D.preventDefault(),e.onClose())};window.addEventListener("keydown",k),xe(()=>{window.removeEventListener("keydown",k)})});async function f(){r(!0);try{const k=await v();S(k)}catch(k){const D=k instanceof Error?k.message:"Unable to load filesystem";s(D)}finally{r(!1)}}function S(k){const D=Ao(k.currentPath);_(D),p(k),n(k.rootPath)}async function v(k){const D=k?Ao(k):void 0;if(D){const y=g.get(D);if(y)return y;const N=E.get(D);if(N)return N}const O=(async()=>{D&&d(H=>{const Z=new Set(H);return Z.add(D),Z});const y=await cn.listFileSystem(k,{includeFiles:!1}),N=Ao(y.metadata.currentPath),P=y.entries.filter(H=>H.type==="directory").sort((H,Z)=>H.name.localeCompare(Z.name));return l(H=>{const Z=new Map(H);return Z.set(N,P),Z}),g.set(N,y.metadata),d(H=>{const Z=new Set(H);return D&&Z.delete(D),Z.delete(N),Z}),y.metadata})().catch(y=>{throw D&&d(N=>{const P=new Set(N);return P.delete(D),P}),y}).finally(()=>{D&&E.delete(D)});return D&&E.set(D,O),O}async function b(k){s(null);try{const D=await v(k);S(D)}catch(D){const O=D instanceof Error?D.message:"Unable to load filesystem";s(O)}}const C=V(()=>{const k=[],D=m();D!=null&&D.parentPath&&k.push({type:"up",path:D.parentPath});const O=u();if(!O)return k;const y=o().get(O)??[];for(const N of y)k.push({type:"folder",entry:N});return k});function R(k){b(k)}function A(){var D;const k=(D=m())==null?void 0:D.parentPath;k&&b(k)}const U=V(()=>{const k=m();return!k||k.pathKind==="drives"?"":k.pathKind==="relative"?lp(k.rootPath,k.currentPath):k.displayPath}),w=V(()=>!!U());function M(k){const D=k.absolutePath?k.absolutePath:NE(k.path)?k.path:lp(t(),k.path);e.onSelect(D)}function Y(k){return c().has(Ao(k))}function $(k){k.target===k.currentTarget&&e.onClose()}return T(ee,{get when(){return e.open},get children(){var k=xI(),D=k.firstChild,O=D.firstChild,y=O.firstChild,N=y.firstChild,P=N.firstChild,H=P.nextSibling,Z=N.nextSibling,ae=y.nextSibling;return k.$$click=$,I(P,()=>e.title),I(H,()=>e.description||"Browse folders under the configured workspace root."),cr(Z,"click",e.onClose,!0),I(Z,T(rc,{class:"w-5 h-5"})),I(ae,T(ee,{get when(){return t()},get children(){var Se=NI(),ne=Se.firstChild,ie=ne.firstChild,Te=ie.nextSibling,Ee=ne.nextSibling;return I(Te,U),Ee.$$click=()=>{const le=U();le&&e.onSelect(le)},ue(()=>Ee.disabled=!w()),Se}}),null),I(ae,T(ee,{get when(){return ke(()=>!i())()&&!a()},get fallback(){return(()=>{var Se=DI();return I(Se,T(ee,{get when(){return i()},get fallback(){return(()=>{var ne=LI();return I(ne,a),ne})()},get children(){var ne=wI(),ie=ne.firstChild;return I(ne,T(Us,{class:"w-5 h-5 animate-spin"}),ie),ne}})),Se})()},get children(){return T(ee,{get when(){return C().length>0},get fallback(){return MI()},get children(){var Se=AI();return I(Se,T(We,{get each(){return C()},children:ne=>{const ie=ne.type==="folder",Te=ie?ne.entry.name||ne.entry.path:"Up one level",Ee=()=>ie?R(ne.entry.path):A();return(()=>{var le=kI(),Me=le.firstChild,Re=Me.firstChild,he=Re.firstChild,z=he.nextSibling,K=z.firstChild;return Re.$$click=Ee,I(he,T(ee,{when:!ie,get fallback(){return T(Wu,{class:"w-4 h-4"})},get children(){return T(_E,{class:"w-4 h-4"})}})),I(K,Te),I(Re,T(ee,{get when(){return ie&&Y(ne.entry.path)},get children(){return T(Us,{class:"directory-browser-row-spinner animate-spin"})}}),null),I(Me,ie?(()=>{var J=PI();return J.$$click=me=>{me.stopPropagation(),M(ne.entry)},J})():null,null),le})()}})),Se}})}}),null),k}})};At(["click"]);const yi=()=>navigator.platform.toLowerCase().includes("mac"),UI=e=>{const t=[];return(e.modifiers.ctrl||e.modifiers.meta)&&t.push(yi()?"Cmd":"Ctrl"),e.modifiers.shift&&t.push("Shift"),e.modifiers.alt&&t.push(yi()?"Option":"Alt"),t.push(e.key.toUpperCase()),t.join("+")};var BI=G("<kbd>"),$I=G("<span>"),GI=G("<span class=kbd-separator>+");const YI={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:"→"},qt=e=>{const t=()=>{if(e.children)return[{text:e.children,isModifier:!1}];if(!e.shortcut)return[];const n=[];return e.shortcut.toLowerCase().split("+").forEach(a=>{const s=a.trim(),o=s.toLowerCase();if(o==="cmd"||o==="command")n.push({text:yi()?"Cmd":"Ctrl",isModifier:!1});else if(o==="shift")n.push({text:"Shift",isModifier:!1});else if(o==="alt"||o==="option")n.push({text:yi()?"Option":"Alt",isModifier:!1});else if(o==="ctrl"||o==="control")n.push({text:"Ctrl",isModifier:!1});else{const l=YI[o];l?n.push({text:l,isModifier:!1}):s.length===1?n.push({text:s.toUpperCase(),isModifier:!1}):n.push({text:s.charAt(0).toUpperCase()+s.slice(1),isModifier:!1})}}),n};return(()=>{var n=BI();return I(n,T(We,{get each(){return t()},children:(i,r)=>[ke(()=>ke(()=>r()>0)()&&GI()),(()=>{var a=$I();return I(a,()=>i.text),a})()]})),ue(()=>He(n,`kbd ${e.class||""}`)),n})()};var VI=G('<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">'),HI=G('<div class="flex items-center gap-1.5"><kbd class=kbd>↑</kbd><kbd class=kbd>↓</kbd><span>Navigate'),WI=G('<div class="flex items-center gap-1.5"><kbd class=kbd>Enter</kbd><span>Select'),zI=G('<div class="flex items-center gap-1.5"><kbd class=kbd>Del</kbd><span>Remove'),KI=G("<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."),qI=G('<div class="flex h-screen w-full items-start justify-center overflow-hidden py-6 relative"style=background-color:var(--surface-secondary)><div class="w-full max-w-3xl h-full 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),QI=G('<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'),XI=G("<kbd class=kbd>↵"),jI=G('<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 ZI=new URL("/assets/CodeNomad-Icon-bmTWNPXy.png",import.meta.url).href,cp=e=>{const{recentFolders:t,removeRecentFolder:n,preferences:i}=_r(),[r,a]=Q(0),[s,o]=Q("recent"),[l,c]=Q(i().lastUsedBinary||"opencode"),[d,u]=Q(!1),_=IE();let m;const p=()=>t(),g=()=>!!e.isLoading;fe(()=>{const w=i().lastUsedBinary;w&&c(M=>M===w?M:w)});function E(w){const M=m;if(!M)return;const Y=M.querySelector(`[data-folder-index="${w}"]`);if(!Y)return;const $=M.getBoundingClientRect(),k=Y.getBoundingClientRect();k.top<$.top?M.scrollTop-=$.top-k.top:k.bottom>$.bottom&&(M.scrollTop+=k.bottom-$.bottom)}function h(w){const M=w.key.toLowerCase(),Y=(w.metaKey||w.ctrlKey)&&!w.shiftKey&&M==="n",$=["ArrowDown","ArrowUp","PageDown","PageUp","Home","End","Enter","Backspace","Delete"];if(g()){(Y||$.includes(w.key))&&w.preventDefault();return}const k=p();if(Y){w.preventDefault(),b();return}if(k.length!==0){if(w.key==="ArrowDown"){w.preventDefault();const D=Math.min(r()+1,k.length-1);a(D),o("recent"),E(D)}else if(w.key==="ArrowUp"){w.preventDefault();const D=Math.max(r()-1,0);a(D),o("recent"),E(D)}else if(w.key==="PageDown"){w.preventDefault();const O=Math.min(r()+5,k.length-1);a(O),o("recent"),E(O)}else if(w.key==="PageUp"){w.preventDefault();const O=Math.max(r()-5,0);a(O),o("recent"),E(O)}else if(w.key==="Home")w.preventDefault(),a(0),o("recent"),E(0);else if(w.key==="End"){w.preventDefault();const D=k.length-1;a(D),o("recent"),E(D)}else if(w.key==="Enter")w.preventDefault(),f();else if((w.key==="Backspace"||w.key==="Delete")&&(w.preventDefault(),k.length>0&&s()==="recent")){const D=k[r()];D&&A(D.path)}}}function f(){if(g())return;const w=p(),M=r(),Y=w[M];Y&&v(Y.path)}dn(()=>{window.addEventListener("keydown",h),xe(()=>{window.removeEventListener("keydown",h)})});function S(w){const M=Math.floor((Date.now()-w)/1e3),Y=Math.floor(M/60),$=Math.floor(Y/60),k=Math.floor($/24);return k>0?`${k}d ago`:$>0?`${$}h ago`:Y>0?`${Y}m ago`:"just now"}function v(w){g()||e.onSelectFolder(w,l())}async function b(){var w;if(!g()){if(o("new"),_){const M=(w=p()[0])==null?void 0:w.path,Y=await aI({title:"Select Workspace",defaultPath:M});Y&&v(Y);return}u(!0)}}function C(w){u(!1),v(w)}function R(w){c(w)}function A(w,M){if(g())return;M==null||M.stopPropagation(),n(w);const Y=p();r()>=Y.length&&Y.length>0&&a(Y.length-1)}function U(w){return w.startsWith("/Users/")?w.replace(/^\/Users\/[^/]+/,"~"):w}return[(()=>{var w=qI(),M=w.firstChild,Y=M.firstChild,$=Y.firstChild,k=$.firstChild,D=Y.nextSibling,O=D.firstChild,y=O.firstChild,N=y.nextSibling,P=N.firstChild,H=P.firstChild,Z=H.firstChild,ae=N.nextSibling,Se=ae.firstChild,ne=Se.firstChild,ie=ne.firstChild,Te=D.nextSibling,Ee=Te.firstChild,le=Ee.firstChild,Me=le.firstChild;return Fe(k,"src",ZI),I(D,T(ee,{get when(){return p().length>0},get fallback(){return(()=>{var Re=QI(),he=Re.firstChild;return I(he,T(LC,{class:"w-12 h-12 mx-auto"})),Re})()},get children(){var Re=VI(),he=Re.firstChild,z=he.firstChild,K=z.nextSibling,J=K.firstChild,me=J.nextSibling;me.nextSibling;var te=he.nextSibling;return I(K,()=>p().length,J),I(K,()=>p().length===1?"folder":"folders",me),Nt(se=>m=se,te),I(te,T(We,{get each(){return p()},children:(se,oe)=>(()=>{var Ie=jI(),be=Ie.firstChild,ge=be.firstChild,De=ge.firstChild,Pe=De.firstChild,q=Pe.firstChild,F=q.firstChild,x=q.nextSibling,W=x.nextSibling,j=ge.nextSibling;return ge.addEventListener("mouseenter",()=>{g()||(o("recent"),a(oe()))}),ge.$$click=()=>v(se.path),I(q,T(Wu,{class:"w-4 h-4 flex-shrink-0 icon-muted"}),F),I(F,()=>se.path.split("/").pop()),I(x,()=>U(se.path)),I(W,()=>S(se.lastAccessed)),I(De,T(ee,{get when(){return ke(()=>s()==="recent")()&&r()===oe()},get children(){return XI()}}),null),j.$$click=re=>A(se.path,re),I(j,T(Ku,{class:"w-3.5 h-3.5 transition-colors icon-muted hover:text-red-600 dark:hover:text-red-400"})),ue(re=>{var de=s()==="recent"&&r()===oe(),Ae=!!g(),Ue=oe(),Ye=g(),Ve=g();return de!==re.e&&Ie.classList.toggle("panel-list-item-highlight",re.e=de),Ae!==re.t&&Ie.classList.toggle("panel-list-item-disabled",re.t=Ae),Ue!==re.a&&Fe(ge,"data-folder-index",re.a=Ue),Ye!==re.o&&(ge.disabled=re.o=Ye),Ve!==re.i&&(j.disabled=re.i=Ve),re},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),Ie})()})),Re}}),O),P.addEventListener("mouseenter",()=>o("new")),P.$$click=()=>void b(),I(H,T($C,{class:"w-4 h-4"}),Z),I(Z,()=>e.isLoading?"Opening...":"Browse Folders"),I(P,T(qt,{shortcut:"cmd+n",class:"ml-2"}),null),Se.$$click=()=>{var Re;return(Re=e.onAdvancedSettingsOpen)==null?void 0:Re.call(e)},I(ne,T(eR,{class:"w-4 h-4 icon-muted"}),ie),I(Se,T(wC,{class:"w-4 h-4 icon-muted"}),null),I(Ee,T(ee,{get when(){return p().length>0},get children(){return[HI(),WI(),zI()]}}),le),I(le,T(qt,{shortcut:"cmd+n"}),Me),I(w,T(ee,{get when(){return g()},get children(){return KI()}}),null),ue(Re=>{var he=g()?"true":"false",z=e.isLoading;return he!==Re.e&&Fe(M,"aria-busy",Re.e=he),z!==Re.t&&(P.disabled=Re.t=z),Re},{e:void 0,t:void 0}),w})(),T(OI,{get open(){return!!e.advancedSettingsOpen},onClose:()=>{var w;return(w=e.onAdvancedSettingsClose)==null?void 0:w.call(e)},get selectedBinary(){return l()},onBinaryChange:R,get isLoading(){return e.isLoading}}),T(FI,{get open(){return d()},title:"Select Workspace",description:"Select workspace to start coding.",onClose:()=>u(!1),onSelect:C})]};At(["click"]);var JI=G('<div class=group><button role=tab><span class=tab-label></span><span class="tab-close ml-auto"role=button tabindex=0 aria-label="Close instance">');const eO=e=>(()=>{var t=JI(),n=t.firstChild,i=n.firstChild,r=i.nextSibling;return cr(n,"click",e.onSelect,!0),I(n,T(mE,{class:"w-4 h-4 flex-shrink-0"}),i),I(i,()=>e.instance.folder.split("/").pop()||e.instance.folder),r.$$click=a=>{a.stopPropagation(),e.onClose()},I(r,T(rc,{class:"w-3 h-3"})),ue(a=>{var s=`tab-base ${e.active?"tab-active":"tab-inactive"}`,o=e.instance.folder,l=e.active;return s!==a.e&&He(n,a.e=s),o!==a.t&&Fe(n,"title",a.t=o),l!==a.a&&Fe(n,"aria-selected",a.a=l),a},{e:void 0,t:void 0,a:void 0}),t})();At(["click"]);var tO=G("<span>");const nO=e=>(()=>{var t=tO();return I(t,()=>e.children),ue(()=>He(t,`text-xs text-muted ${e.class||""}`)),t})();var iO=G("<span class=mx-1>"),rO=G("<span class=mr-1>");const cc=e=>{function t(n){const i=[];return(n.modifiers.ctrl||n.modifiers.meta)&&i.push("cmd"),n.modifiers.shift&&i.push("shift"),n.modifiers.alt&&i.push("alt"),i.push(n.key),i.join("+")}return T(nO,{get children(){return T(We,{get each(){return e.shortcuts},children:(n,i)=>[ke(()=>ke(()=>i()>0)()&&(()=>{var r=iO();return I(r,()=>e.separator||"•"),r})()),ke(()=>ke(()=>e.showDescription!==!1)()&&(()=>{var r=rO();return I(r,()=>n.description),r})()),T(qt,{get shortcut(){return t(n)}})]})}})};class aO{constructor(){this.shortcuts=new Map}register(t){this.shortcuts.set(t.id,t)}unregister(t){this.shortcuts.delete(t)}get(t){return this.shortcuts.get(t)}findMatch(t){for(const n of this.shortcuts.values())if(this.matches(t,n)){if(n.context==="input"&&!this.isInputFocused()||n.context==="messages"&&this.isInputFocused()||n.condition&&!n.condition())continue;return n}return null}matches(t,n){const i=n.key.toLowerCase(),r=t.key?t.key.toLowerCase():"",a=t.code?t.code.toLowerCase():"",s=r===i||a===i,o=t.ctrlKey===(n.modifiers.ctrl??!1),l=t.metaKey===(n.modifiers.meta??!1),c=t.shiftKey===(n.modifiers.shift??!1),d=t.altKey===(n.modifiers.alt??!1);return s&&o&&l&&c&&d}isInputFocused(){const t=document.activeElement;return(t==null?void 0:t.tagName)==="TEXTAREA"||(t==null?void 0:t.tagName)==="INPUT"||((t==null?void 0:t.hasAttribute("contenteditable"))??!1)}getByContext(t){return Array.from(this.shortcuts.values()).filter(n=>!n.context||n.context===t)}}const Ot=new aO;var sO=G('<div class="flex-shrink-0 ml-4">'),oO=G('<div class="tab-bar tab-bar-instance"><div class=tab-container role=tablist><div class="flex items-center gap-1 overflow-x-auto"><button class=new-tab-button title="New instance (Cmd/Ctrl+N)"aria-label="New instance">');const lO=e=>(()=>{var t=oO(),n=t.firstChild,i=n.firstChild,r=i.firstChild;return I(i,T(We,{get each(){return Array.from(e.instances.entries())},children:([a,s])=>T(eO,{instance:s,get active(){return a===e.activeInstanceId},onSelect:()=>e.onSelect(a),onClose:()=>e.onClose(a)})}),r),cr(r,"click",e.onNew,!0),I(r,T(zu,{class:"w-4 h-4"})),I(n,T(ee,{get when(){return Array.from(e.instances.entries()).length>1},get children(){var a=sO();return I(a,T(cc,{get shortcuts(){return[Ot.get("instance-prev"),Ot.get("instance-next")].filter(Boolean)}})),a}}),null),t})();At(["click"]);var cO=G("<div>"),dO=G('<div class="rounded-lg border border-base bg-surface-secondary p-4 text-sm text-secondary"><p class="font-medium text-primary">Details</p><p class="mt-2 text-secondary">'),uO=G('<div class="flex justify-end"><button type=button class="selector-button selector-button-primary">Close Instance'),_O=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),mO=G('<p class="mt-2 text-secondary">Folder: <span class="font-mono text-primary break-all">');function pO(e){const t=e.folder||"this workspace",n=e.reason||"The server stopped responding";return T(Ze,{get open(){return e.open},modal:!0,get children(){return T(Ze.Portal,{get children(){return[T(Ze.Overlay,{class:"modal-overlay"}),(()=>{var i=_O();return I(i,T(Ze.Content,{class:"modal-surface w-full max-w-md p-6 flex flex-col gap-6",get children(){return[(()=>{var r=cO();return I(r,T(Ze.Title,{class:"text-xl font-semibold text-primary",children:"Instance Disconnected"}),null),I(r,T(Ze.Description,{class:"text-sm text-secondary mt-2",get children(){return[t," can no longer be reached. Close the tab to continue working."]}}),null),r})(),(()=>{var r=dO(),a=r.firstChild,s=a.nextSibling;return I(s,n),I(r,(()=>{var o=ke(()=>!!e.folder);return()=>o()&&(()=>{var l=mO(),c=l.firstChild,d=c.nextSibling;return I(d,()=>e.folder),l})()})(),null),r})(),(()=>{var r=uO(),a=r.firstChild;return cr(a,"click",e.onClose,!0),r})()]}})),i})()]}})}})}At(["click"]);const[dp,gO]=Q(new Map);class fO{constructor(){Bs.on("instance.eventStatus",t=>{var i;const n=t;if(this.updateConnectionStatus(n.instanceId,n.status),n.status==="disconnected"){if(n.reason==="workspace stopped")return;const r=n.reason??"Instance disconnected";(i=this.onConnectionLost)==null||i.call(this,n.instanceId,r)}}),Bs.on("instance.event",t=>{const n=t;this.updateConnectionStatus(n.instanceId,"connected"),this.handleEvent(n.instanceId,n.event)})}seedStatus(t,n){this.updateConnectionStatus(t,n)}handleEvent(t,n){var i,r,a,s,o,l,c,d,u,_,m,p;if(!n||typeof n!="object"||typeof n.type!="string"){console.warn("[SSE] Dropping malformed event",n);return}switch(console.log("[SSE] Received event:",n.type,n),n.type){case"message.updated":(i=this.onMessageUpdate)==null||i.call(this,t,n);break;case"message.part.updated":(r=this.onMessagePartUpdated)==null||r.call(this,t,n);break;case"message.removed":(a=this.onMessageRemoved)==null||a.call(this,t,n);break;case"message.part.removed":(s=this.onMessagePartRemoved)==null||s.call(this,t,n);break;case"session.updated":(o=this.onSessionUpdate)==null||o.call(this,t,n);break;case"session.compacted":(l=this.onSessionCompacted)==null||l.call(this,t,n);break;case"session.error":(c=this.onSessionError)==null||c.call(this,t,n);break;case"tui.toast.show":(d=this.onTuiToast)==null||d.call(this,t,n);break;case"session.idle":(u=this.onSessionIdle)==null||u.call(this,t,n);break;case"permission.updated":(_=this.onPermissionUpdated)==null||_.call(this,t,n);break;case"permission.replied":(m=this.onPermissionReplied)==null||m.call(this,t,n);break;case"lsp.updated":(p=this.onLspUpdated)==null||p.call(this,t,n);break;default:console.warn("[SSE] Unknown event type:",n.type)}}updateConnectionStatus(t,n){gO(i=>{const r=new Map(i);return r.set(t,n),r})}getStatus(t){return dp().get(t)??null}getStatuses(){return dp()}}const Xt=new fO,[kt,xr]=Q(new Map),[nr,AE]=Q(new Map),[$s,xE]=Q(new Map),[dc,EO]=Q(new Map),[$a,hO]=Q(new Map),[SO,uc]=Q(new Map),[wE,Ia]=Q({fetchingSessions:new Map,creatingSession:new Map,deletingSession:new Map,loadingMessages:new Map}),[bO,Dd]=Q(new Map),[DE,t_]=Q(new Map);function n_(e,t){return`${e}:${t}`}function TO(e,t){if(!e||!t)return"";const n=n_(e,t);return SO().get(n)??""}function Vc(e,t,n){const i=n_(e,t);uc(r=>{const a=new Map(r);return n?a.set(i,n):a.delete(i),a})}function vO(e,t){const n=n_(e,t);uc(i=>{if(!i.has(n))return i;const r=new Map(i);return r.delete(n),r})}function yO(e){e&&uc(t=>{let n=!1;const i=new Map(t),r=`${e}:`;for(const a of Array.from(i.keys()))a.startsWith(r)&&(i.delete(a),n=!0);return n?i:t})}function CO(e,t){uc(n=>{let i=!1;const r=new Map(n),a=`${e}:`;for(const s of Array.from(r.keys()))if(s.startsWith(a)){const o=s.slice(a.length);t.has(o)||(r.delete(s),i=!0)}return i?r:n})}function co(e,t,n){const i=kt().get(e);if(!i)return;const r=i.get(t);if(!r)return;n(r);const a={...r};xr(s=>{const o=new Map(s),l=new Map(i);return l.set(t,a),o.set(e,l),o})}function Gs(e,t,n){co(e,t,i=>{i.pendingPermission!==n&&(i.pendingPermission=n)})}function Kn(e,t){AE(n=>{const i=new Map(n);return i.set(e,t),i})}function Ys(e,t){xE(n=>{const i=new Map(n);return i.set(e,t),i}),Kn(e,t)}function RO(e){xE(t=>{const n=new Map(t);return n.delete(e),n}),AE(t=>{const n=new Map(t);return n.delete(e),n})}function wr(e){const t=kt().get(e);return t?Array.from(t.values()):[]}function IO(e){return wr(e).filter(n=>n.parentId===null)}function OO(e,t){return wr(e).filter(i=>i.parentId===t)}function bl(e,t){var r;const n=(r=kt().get(e))==null?void 0:r.get(t);if(!n)return[];const i=OO(e,t);return[n,...i]}function NO(e,t){const n=kt().get(e);return!(!n||!n.has(t))}function AO(e,t){var n;return!!((n=wE().loadingMessages.get(e))!=null&&n.has(t))}function LE(e,t){var n;return(n=DE().get(e))==null?void 0:n.get(t)}const la=32e3;function Oa(e,t){if(!(t!=null&&t.providerId)||!t.modelId)return!1;const i=($a().get(e)||[]).find(r=>r.id===t.providerId);return i?i.models.some(r=>r.id===t.modelId):!1}function xO(e){const t=Rn().modelRecents??[];for(const n of t)if(Oa(e,n))return n}async function i_(e,t){const n=$a().get(e)||[],i=dc().get(e)||[];if(t){const a=i.find(o=>o.name===t);if(a&&a.model&&Oa(e,a.model))return{providerId:a.model.providerId,modelId:a.model.modelId};const s=await yE(e,t);if(Oa(e,s))return s}const r=xO(e);if(r)return r;for(const a of n)if(a.defaultModelId){const s=a.models.find(o=>o.id===a.defaultModelId);if(s)return{providerId:a.id,modelId:s.id}}if(n.length>0){const a=n[0],s=a.models[0];if(s)return{providerId:a.id,modelId:s.id}}return{providerId:"",modelId:""}}const wO=({onSseError:e,onSseEvent:t,responseTransformer:n,responseValidator:i,sseDefaultRetryDelay:r,sseMaxRetryAttempts:a,sseMaxRetryDelay:s,sseSleepFn:o,url:l,...c})=>{let d;const u=o??(p=>new Promise(g=>setTimeout(g,p)));return{stream:async function*(){let p=r??3e3,g=0;const E=c.signal??new AbortController().signal;for(;!E.aborted;){g++;const h=c.headers instanceof Headers?c.headers:new Headers(c.headers);d!==void 0&&h.set("Last-Event-ID",d);try{const f=await fetch(l,{...c,headers:h,signal:E});if(!f.ok)throw new Error(`SSE failed: ${f.status} ${f.statusText}`);if(!f.body)throw new Error("No body in SSE response");const S=f.body.pipeThrough(new TextDecoderStream).getReader();let v="";const b=()=>{try{S.cancel()}catch{}};E.addEventListener("abort",b);try{for(;;){const{done:C,value:R}=await S.read();if(C)break;v+=R;const A=v.split(`
|
|
2
|
+
var Cv=Object.defineProperty;var Am=e=>{throw TypeError(e)};var Rv=(e,t,n)=>t in e?Cv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var X=(e,t,n)=>Rv(e,typeof t!="symbol"?t+"":t,n),Iv=(e,t,n)=>t.has(e)||Am("Cannot "+n);var xm=(e,t,n)=>t.has(e)?Am("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var So=(e,t,n)=>(Iv(e,t,"access private method"),n);import{o as xe,c as fe,a as ue,b as V,$ as yd,u as Fa,d as Cd,e as Q,m as Ne,s as Qe,f as T,D as Lf,g as dn,h as si,i as un,j as Cn,k as ke,l as Fr,P as wu,S as ee,n as Or,p as Mf,q as Rd,t as G,r as I,F as We,v as wn,w as He,M as bn,x as ic,y as li,z as Nt,A as Fe,B as At,C as bs,E as cr,G as Id,H as Ov,I as kf,J as Nv,K as Av}from"./index-ysIEPg5i.js";function xv(e){return(...t)=>{for(const n of e)n&&n(...t)}}const ce=e=>typeof e=="function"&&!e.length?e():e,wm=e=>Array.isArray(e)?e:e?[e]:[];function wv(e,...t){return typeof e=="function"?e(...t):e}const Dv=xe;function Lv(e,t,n,i){return e.addEventListener(t,n,i),Dv(e.removeEventListener.bind(e,t,n,i))}function Mv(e,t,n,i){const r=()=>{wm(ce(e)).forEach(a=>{a&&wm(ce(t)).forEach(s=>Lv(a,s,n,i))})};typeof e=="function"?fe(r):ue(r)}const Pc=Symbol("fallback");function Dm(e){for(const t of e)t.dispose()}function kv(e,t,n,i={}){const r=new Map;return xe(()=>Dm(r.values())),()=>{const s=e()||[];return s[yd],Fa(()=>{var d,u;if(!s.length)return Dm(r.values()),r.clear(),i.fallback?[Cd(m=>(r.set(Pc,{dispose:m}),i.fallback()))]:[];const o=new Array(s.length),l=r.get(Pc);if(!r.size||l){l==null||l.dispose(),r.delete(Pc);for(let _=0;_<s.length;_++){const m=s[_],p=t(m,_);a(o,m,_,p)}return o}const c=new Set(r.keys());for(let _=0;_<s.length;_++){const m=s[_],p=t(m,_);c.delete(p);const g=r.get(p);g?(o[_]=g.mapped,(d=g.setIndex)==null||d.call(g,_),g.setItem(()=>m)):a(o,m,_,p)}for(const _ of c)(u=r.get(_))==null||u.dispose(),r.delete(_);return o})};function a(s,o,l,c){Cd(d=>{const[u,_]=Q(o),m={setItem:_,dispose:d};if(n.length>1){const[p,g]=Q(l);m.setIndex=g,m.mapped=n(u,p)}else m.mapped=n(u);r.set(c,m),s[l]=m.mapped})}}function Pv(e){const{by:t}=e;return V(kv(()=>e.each,typeof t=="function"?t:n=>n[t],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}const Fv=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Lm(e){const t={};let n;for(;n=Fv.exec(e);)t[n[1]]=n[2];return t}function ao(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=Lm(e)}else typeof t=="string"&&(t=Lm(t));return{...e,...t}}function Pt(...e){return xv(e)}function Mm(e,t){const n=[...e],i=n.indexOf(t);return i!==-1&&n.splice(i,1),n}function Uv(e){return typeof e=="number"}function Xr(e){return Object.prototype.toString.call(e)==="[object String]"}function zi(e){return typeof e=="function"}function Ua(e){return t=>`${e()}-${t}`}function zn(e,t){return e?e===t||e.contains(t):!1}function ds(e,t=!1){const{activeElement:n}=Ai(e);if(!(n!=null&&n.nodeName))return null;if(Pf(n)&&n.contentDocument)return ds(n.contentDocument.body,t);if(t){const i=n.getAttribute("aria-activedescendant");if(i){const r=Ai(n).getElementById(i);if(r)return r}}return n}function Bv(e){return Ai(e).defaultView||window}function Ai(e){return e?e.ownerDocument||e:document}function Pf(e){return e.tagName==="IFRAME"}var Ff=(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))(Ff||{});function Uf(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 Du(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 so(){return Du(/^Mac/i)}function $v(){return Du(/^iPhone/i)}function Gv(){return Du(/^iPad/i)||so()&&navigator.maxTouchPoints>1}function Yv(){return $v()||Gv()}function Zo(){return so()||Yv()}function Vv(){return Uf(/AppleWebKit/i)&&!Hv()}function Hv(){return Uf(/Chrome/i)}function _t(e,t){return t&&(zi(t)?t(e):t[0](t[1],e)),e==null?void 0:e.defaultPrevented}function Dn(e){return t=>{for(const n of e)_t(t,n)}}function Wv(e){return so()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Gt(e){if(e)if(zv())e.focus({preventScroll:!0});else{const t=Kv(e);e.focus(),qv(t)}}var bo=null;function zv(){if(bo==null){bo=!1;try{document.createElement("div").focus({get preventScroll(){return bo=!0,!0}})}catch{}}return bo}function Kv(e){let t=e.parentNode;const n=[],i=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==i;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return i instanceof HTMLElement&&n.push({element:i,scrollTop:i.scrollTop,scrollLeft:i.scrollLeft}),n}function qv(e){for(const{element:t,scrollTop:n,scrollLeft:i}of e)t.scrollTop=n,t.scrollLeft=i}var Bf=["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'])"],Qv=[...Bf,'[tabindex]:not([tabindex="-1"]):not([disabled])'],Lu=`${Bf.join(":not([hidden]),")},[tabindex]:not([disabled]):not([hidden])`,Xv=Qv.join(':not([hidden]):not([tabindex="-1"]),');function $f(e,t){const i=Array.from(e.querySelectorAll(Lu)).filter(km);return t&&km(e)&&i.unshift(e),i.forEach((r,a)=>{if(Pf(r)&&r.contentDocument){const s=r.contentDocument.body,o=$f(s,!1);i.splice(a,1,...o)}}),i}function km(e){return Gf(e)&&!jv(e)}function Gf(e){return e.matches(Lu)&&Mu(e)}function jv(e){return Number.parseInt(e.getAttribute("tabindex")||"0",10)<0}function Mu(e,t){return e.nodeName!=="#comment"&&Zv(e)&&Jv(e,t)&&(!e.parentElement||Mu(e.parentElement,e))}function Zv(e){if(!(e instanceof HTMLElement)&&!(e instanceof SVGElement))return!1;const{display:t,visibility:n}=e.style;let i=t!=="none"&&n!=="hidden"&&n!=="collapse";if(i){if(!e.ownerDocument.defaultView)return i;const{getComputedStyle:r}=e.ownerDocument.defaultView,{display:a,visibility:s}=r(e);i=a!=="none"&&s!=="hidden"&&s!=="collapse"}return i}function Jv(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function ey(e,t,n){const i=t!=null&&t.tabbable?Xv:Lu,r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(a){var s;return(s=t==null?void 0:t.from)!=null&&s.contains(a)?NodeFilter.FILTER_REJECT:a.matches(i)&&Mu(a)&&(!(t!=null&&t.accept)||t.accept(a))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(r.currentNode=t.from),r}function ty(){}function rt(e,t){return Ne(e,t)}var Ja=new Map,Pm=new Set;function Fm(){if(typeof window>"u")return;const e=n=>{if(!n.target)return;let i=Ja.get(n.target);i||(i=new Set,Ja.set(n.target,i),n.target.addEventListener("transitioncancel",t)),i.add(n.propertyName)},t=n=>{if(!n.target)return;const i=Ja.get(n.target);if(i&&(i.delete(n.propertyName),i.size===0&&(n.target.removeEventListener("transitioncancel",t),Ja.delete(n.target)),Ja.size===0)){for(const r of Pm)r();Pm.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?Fm():document.addEventListener("DOMContentLoaded",Fm));function Um(e,t){const n=Bm(e,t,"left"),i=Bm(e,t,"top"),r=t.offsetWidth,a=t.offsetHeight;let s=e.scrollLeft,o=e.scrollTop;const l=s+e.offsetWidth,c=o+e.offsetHeight;n<=s?s=n:n+r>l&&(s+=n+r-l),i<=o?o=i:i+a>c&&(o+=i+a-c),e.scrollLeft=s,e.scrollTop=o}function Bm(e,t,n){const i=n==="left"?"offsetLeft":"offsetTop";let r=0;for(;t.offsetParent&&(r+=t[i],t.offsetParent!==e);){if(t.offsetParent.contains(e)){r-=e[i];break}t=t.offsetParent}return r}var ku={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"},ul="data-kb-top-layer",Yf,Od=!1,xi=[];function Ps(e){return xi.findIndex(t=>t.node===e)}function ny(e){return xi[Ps(e)]}function iy(e){return xi[xi.length-1].node===e}function Vf(){return xi.filter(e=>e.isPointerBlocking)}function ry(){return[...Vf()].slice(-1)[0]}function Pu(){return Vf().length>0}function Hf(e){var n;const t=Ps((n=ry())==null?void 0:n.node);return Ps(e)<t}function ay(e){xi.push(e)}function sy(e){const t=Ps(e);t<0||xi.splice(t,1)}function oy(){for(const{node:e}of xi)e.style.pointerEvents=Hf(e)?"none":"auto"}function ly(e){if(Pu()&&!Od){const t=Ai(e);Yf=document.body.style.pointerEvents,t.body.style.pointerEvents="none",Od=!0}}function cy(e){if(Pu())return;const t=Ai(e);t.body.style.pointerEvents=Yf,t.body.style.length===0&&t.body.removeAttribute("style"),Od=!1}var mn={layers:xi,isTopMostLayer:iy,hasPointerBlockingLayer:Pu,isBelowPointerBlockingLayer:Hf,addLayer:ay,removeLayer:sy,indexOf:Ps,find:ny,assignPointerEventToLayers:oy,disableBodyPointerEvents:ly,restoreBodyPointerEvents:cy},Fc="focusScope.autoFocusOnMount",Uc="focusScope.autoFocusOnUnmount",$m={bubbles:!1,cancelable:!0},Gm={stack:[],active(){return this.stack[0]},add(e){var t;e!==this.active()&&((t=this.active())==null||t.pause()),this.stack=Mm(this.stack,e),this.stack.unshift(e)},remove(e){var t;this.stack=Mm(this.stack,e),(t=this.active())==null||t.resume()}};function Fu(e,t){const[n,i]=Q(!1),r={pause(){i(!0)},resume(){i(!1)}};let a=null;const s=p=>{var g;return(g=e.onMountAutoFocus)==null?void 0:g.call(e,p)},o=p=>{var g;return(g=e.onUnmountAutoFocus)==null?void 0:g.call(e,p)},l=()=>Ai(t()),c=()=>{const p=l().createElement("span");return p.setAttribute("data-focus-trap",""),p.tabIndex=0,Object.assign(p.style,ku),p},d=()=>{const p=t();return p?$f(p,!0).filter(g=>!g.hasAttribute("data-focus-trap")):[]},u=()=>{const p=d();return p.length>0?p[0]:null},_=()=>{const p=d();return p.length>0?p[p.length-1]:null},m=()=>{const p=t();if(!p)return!1;const g=ds(p);return!g||zn(p,g)?!1:Gf(g)};fe(()=>{const p=t();if(!p)return;Gm.add(r);const g=ds(p);if(!zn(p,g)){const h=new CustomEvent(Fc,$m);p.addEventListener(Fc,s),p.dispatchEvent(h),h.defaultPrevented||setTimeout(()=>{Gt(u()),ds(p)===g&&Gt(p)},0)}xe(()=>{p.removeEventListener(Fc,s),setTimeout(()=>{const h=new CustomEvent(Uc,$m);m()&&h.preventDefault(),p.addEventListener(Uc,o),p.dispatchEvent(h),h.defaultPrevented||Gt(g??l().body),p.removeEventListener(Uc,o),Gm.remove(r)},0)})}),fe(()=>{const p=t();if(!p||!ce(e.trapFocus)||n())return;const g=h=>{const f=h.target;f!=null&&f.closest(`[${ul}]`)||(zn(p,f)?a=f:Gt(a))},E=h=>{const S=h.relatedTarget??ds(p);S!=null&&S.closest(`[${ul}]`)||zn(p,S)||Gt(a)};l().addEventListener("focusin",g),l().addEventListener("focusout",E),xe(()=>{l().removeEventListener("focusin",g),l().removeEventListener("focusout",E)})}),fe(()=>{const p=t();if(!p||!ce(e.trapFocus)||n())return;const g=c();p.insertAdjacentElement("afterbegin",g);const E=c();p.insertAdjacentElement("beforeend",E);function h(S){const v=u(),b=_();S.relatedTarget===v?Gt(b):Gt(v)}g.addEventListener("focusin",h),E.addEventListener("focusin",h);const f=new MutationObserver(S=>{for(const v of S)v.previousSibling===E&&(E.remove(),p.insertAdjacentElement("beforeend",E)),v.nextSibling===g&&(g.remove(),p.insertAdjacentElement("afterbegin",g))});f.observe(p,{childList:!0,subtree:!1}),xe(()=>{g.removeEventListener("focusin",h),E.removeEventListener("focusin",h),g.remove(),E.remove(),f.disconnect()})})}var Wf=7e3,Bc=null,dy="data-live-announcer";function $c(e,t="assertive",n=Wf){Bc||(Bc=new uy),Bc.announce(e,t,n)}var uy=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,ku),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=Wf){if(!this.node)return;const i=document.createElement("div");i.textContent=e,t==="assertive"?this.assertiveLog.appendChild(i):this.politeLog.appendChild(i),e!==""&&setTimeout(()=>{i.remove()},n)}clear(e){this.node&&((!e||e==="assertive")&&(this.assertiveLog.innerHTML=""),(!e||e==="polite")&&(this.politeLog.innerHTML=""))}};function Uu(e){fe(()=>{ce(e.isDisabled)||xe(_y(ce(e.targets),ce(e.root)))})}var es=new WeakMap,Nn=[];function _y(e,t=document.body){const n=new Set(e),i=new Set,r=l=>{for(const _ of l.querySelectorAll(`[${dy}], [${ul}]`))n.add(_);const c=_=>{if(n.has(_)||_.parentElement&&i.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&&a(l),u!==NodeFilter.FILTER_REJECT){let _=d.nextNode();for(;_!=null;)a(_),_=d.nextNode()}},a=l=>{const c=es.get(l)??0;l.getAttribute("aria-hidden")==="true"&&c===0||(c===0&&l.setAttribute("aria-hidden","true"),i.add(l),es.set(l,c+1))};Nn.length&&Nn[Nn.length-1].disconnect(),r(t);const s=new MutationObserver(l=>{for(const c of l)if(!(c.type!=="childList"||c.addedNodes.length===0)&&![...n,...i].some(d=>d.contains(c.target))){for(const d of c.removedNodes)d instanceof Element&&(n.delete(d),i.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&&r(d)}});s.observe(t,{childList:!0,subtree:!0});const o={observe(){s.observe(t,{childList:!0,subtree:!0})},disconnect(){s.disconnect()}};return Nn.push(o),()=>{s.disconnect();for(const l of i){const c=es.get(l);if(c==null)return;c===1?(l.removeAttribute("aria-hidden"),es.delete(l)):es.set(l,c-1)}o===Nn[Nn.length-1]?(Nn.pop(),Nn.length&&Nn[Nn.length-1].observe()):Nn.splice(Nn.indexOf(o),1)}}var Ym="interactOutside.pointerDownOutside",Vm="interactOutside.focusOutside";function my(e,t){let n,i=ty;const r=()=>Ai(t()),a=u=>{var _;return(_=e.onPointerDownOutside)==null?void 0:_.call(e,u)},s=u=>{var _;return(_=e.onFocusOutside)==null?void 0:_.call(e,u)},o=u=>{var _;return(_=e.onInteractOutside)==null?void 0:_.call(e,u)},l=u=>{var m;const _=u.target;return!(_ instanceof Element)||_.closest(`[${ul}]`)||!zn(r(),_)||zn(t(),_)?!1:!((m=e.shouldExcludeElement)!=null&&m.call(e,_))},c=u=>{function _(){const m=t(),p=u.target;if(!m||!p||!l(u))return;const g=Dn([a,o]);p.addEventListener(Ym,g,{once:!0});const E=new CustomEvent(Ym,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:u.button===2||Wv(u)&&u.button===0}});p.dispatchEvent(E)}u.pointerType==="touch"?(r().removeEventListener("click",_),i=_,r().addEventListener("click",_,{once:!0})):_()},d=u=>{const _=t(),m=u.target;if(!_||!m||!l(u))return;const p=Dn([s,o]);m.addEventListener(Vm,p,{once:!0});const g=new CustomEvent(Vm,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:!1}});m.dispatchEvent(g)};fe(()=>{ce(e.isDisabled)||(n=window.setTimeout(()=>{r().addEventListener("pointerdown",c,!0)},0),r().addEventListener("focusin",d,!0),xe(()=>{window.clearTimeout(n),r().removeEventListener("click",i),r().removeEventListener("pointerdown",c,!0),r().removeEventListener("focusin",d,!0)}))})}function py(e){const t=n=>{var i;n.key===Ff.Escape&&((i=e.onEscapeKeyDown)==null||i.call(e,n))};fe(()=>{var i;if(ce(e.isDisabled))return;const n=((i=e.ownerDocument)==null?void 0:i.call(e))??Ai();n.addEventListener("keydown",t),xe(()=>{n.removeEventListener("keydown",t)})})}function ft(e){const[t,n]=Qe(e,["as"]);if(!t.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return T(Lf,Ne(n,{get component(){return t.as}}))}var zf=un();function gy(){return Cn(zf)}function Bu(e){let t;const n=gy(),[i,r]=Qe(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),a=new Set([]),s=u=>{a.add(u);const _=n==null?void 0:n.registerNestedLayer(u);return()=>{a.delete(u),_==null||_()}};my({shouldExcludeElement:u=>{var _;return t?((_=i.excludedElements)==null?void 0:_.some(m=>zn(m(),u)))||[...a].some(m=>zn(m,u)):!1},onPointerDownOutside:u=>{var _,m,p;!t||mn.isBelowPointerBlockingLayer(t)||!i.bypassTopMostLayerCheck&&!mn.isTopMostLayer(t)||((_=i.onPointerDownOutside)==null||_.call(i,u),(m=i.onInteractOutside)==null||m.call(i,u),u.defaultPrevented||(p=i.onDismiss)==null||p.call(i))},onFocusOutside:u=>{var _,m,p;(_=i.onFocusOutside)==null||_.call(i,u),(m=i.onInteractOutside)==null||m.call(i,u),u.defaultPrevented||(p=i.onDismiss)==null||p.call(i)}},()=>t),py({ownerDocument:()=>Ai(t),onEscapeKeyDown:u=>{var _;!t||!mn.isTopMostLayer(t)||((_=i.onEscapeKeyDown)==null||_.call(i,u),!u.defaultPrevented&&i.onDismiss&&(u.preventDefault(),i.onDismiss()))}}),dn(()=>{if(!t)return;mn.addLayer({node:t,isPointerBlocking:i.disableOutsidePointerEvents,dismiss:i.onDismiss});const u=n==null?void 0:n.registerNestedLayer(t);mn.assignPointerEventToLayers(),mn.disableBodyPointerEvents(t),xe(()=>{t&&(mn.removeLayer(t),u==null||u(),mn.assignPointerEventToLayers(),mn.restoreBodyPointerEvents(t))})}),fe(si([()=>t,()=>i.disableOutsidePointerEvents],([u,_])=>{if(!u)return;const m=mn.find(u);m&&m.isPointerBlocking!==_&&(m.isPointerBlocking=_,mn.assignPointerEventToLayers()),_&&mn.disableBodyPointerEvents(u),xe(()=>{mn.restoreBodyPointerEvents(u)})},{defer:!0}));const d={registerNestedLayer:s};return T(zf.Provider,{value:d,get children(){return T(ft,Ne({as:"div",ref(u){var _=Pt(m=>t=m,i.ref);typeof _=="function"&&_(u)}},r))}})}function $u(e){var s;const[t,n]=Q((s=e.defaultValue)==null?void 0:s.call(e)),i=V(()=>{var o;return((o=e.value)==null?void 0:o.call(e))!==void 0}),r=V(()=>{var o;return i()?(o=e.value)==null?void 0:o.call(e):t()});return[r,o=>{Fa(()=>{var c;const l=wv(o,r());return Object.is(l,r())||(i()||n(l),(c=e.onChange)==null||c.call(e,l)),l})}]}function fy(e){const[t,n]=$u(e);return[()=>t()??!1,n]}function Gu(e={}){const[t,n]=fy({value:()=>ce(e.open),defaultValue:()=>!!ce(e.defaultOpen),onChange:s=>{var o;return(o=e.onOpenChange)==null?void 0:o.call(e,s)}}),i=()=>{n(!0)},r=()=>{n(!1)};return{isOpen:t,setIsOpen:n,open:i,close:r,toggle:()=>{t()?r():i()}}}function Kf(e,t){const[n,i]=Q(Hm(t==null?void 0:t()));return fe(()=>{var r;i(((r=e())==null?void 0:r.tagName.toLowerCase())||Hm(t==null?void 0:t()))}),n}function Hm(e){return Xr(e)?e:void 0}var Ey=Object.defineProperty,oo=(e,t)=>{for(var n in t)Ey(e,n,{get:t[n],enumerable:!0})},hy={};oo(hy,{Button:()=>Ty,Root:()=>Ba});var Sy=["button","color","file","image","reset","submit"];function by(e){const t=e.tagName.toLowerCase();return t==="button"?!0:t==="input"&&e.type?Sy.indexOf(e.type)!==-1:!1}function Ba(e){let t;const n=rt({type:"button"},e),[i,r]=Qe(n,["ref","type","disabled"]),a=Kf(()=>t,()=>"button"),s=V(()=>{const c=a();return c==null?!1:by({tagName:c,type:i.type})}),o=V(()=>a()==="input"),l=V(()=>a()==="a"&&(t==null?void 0:t.getAttribute("href"))!=null);return T(ft,Ne({as:"button",ref(c){var d=Pt(u=>t=u,i.ref);typeof d=="function"&&d(c)},get type(){return ke(()=>!!(s()||o()))()?i.type:void 0},get role(){return!s()&&!l()?"button":void 0},get tabIndex(){return!s()&&!l()&&!i.disabled?0:void 0},get disabled(){return ke(()=>!!(s()||o()))()?i.disabled:void 0},get"aria-disabled"(){return!s()&&!o()&&i.disabled?!0:void 0},get"data-disabled"(){return i.disabled?"":void 0}},r))}var Ty=Ba;function Tn(e){return t=>(e(t),()=>e(void 0))}var Kt=e=>typeof e=="function"?e():e,Nd=(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},To=new Map,vy=e=>{fe(()=>{const t=Kt(e.style)??{},n=Kt(e.properties)??[],i={};for(const a in t)i[a]=e.element.style[a];const r=To.get(e.key);r?r.activeCount++:To.set(e.key,{activeCount:1,originalStyles:i,properties:n.map(a=>a.key)}),Object.assign(e.element.style,e.style);for(const a of n)e.element.style.setProperty(a.key,a.value);xe(()=>{var s;const a=To.get(e.key);if(a){if(a.activeCount!==1){a.activeCount--;return}To.delete(e.key);for(const[o,l]of Object.entries(a.originalStyles))e.element.style[o]=l;for(const o of a.properties)e.element.style.removeProperty(o);e.element.style.length===0&&e.element.removeAttribute("style"),(s=e.cleanup)==null||s.call(e)}})})},Wm=vy,yy=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},Cy=(e,t)=>{const n=getComputedStyle(e),i=t==="x"?n.overflowX:n.overflowY;return i==="auto"||i==="scroll"||e.tagName==="HTML"&&i==="visible"},Ry=(e,t,n)=>{const i=t==="x"&&window.getComputedStyle(e).direction==="rtl"?-1:1;let r=e,a=0,s=0,o=!1;do{const[l,c,d]=yy(r,t),u=d-l-i*c;(c!==0||u!==0)&&Cy(r,t)&&(a+=u,s+=c),r===(n??document.documentElement)?o=!0:r=r._$host??r.parentElement}while(r&&!o);return[a,s]},[zm,Km]=Q([]),Iy=e=>zm().indexOf(e)===zm().length-1,Oy=e=>{const t=Ne({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=Fr();let i=[0,0],r=null,a=null;fe(()=>{Kt(t.enabled)&&(Km(c=>[...c,n]),xe(()=>{Km(c=>c.filter(d=>d!==n))}))}),fe(()=>{if(!Kt(t.enabled)||!Kt(t.hideScrollbar))return;const{body:c}=document,d=window.innerWidth-c.offsetWidth;if(Kt(t.preventScrollbarShift)){const u={overflow:"hidden"},_=[];d>0&&(Kt(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,p=window.scrollX;Wm({key:"prevent-scroll",element:c,style:u,properties:_,cleanup:()=>{Kt(t.restoreScrollPosition)&&d>0&&window.scrollTo(p,m)}})}else Wm({key:"prevent-scroll",element:c,style:{overflow:"hidden"}})}),fe(()=>{!Iy(n)||!Kt(t.enabled)||(document.addEventListener("wheel",o,{passive:!1}),document.addEventListener("touchstart",s,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),xe(()=>{document.removeEventListener("wheel",o),document.removeEventListener("touchstart",s),document.removeEventListener("touchmove",l)}))});const s=c=>{i=qm(c),r=null,a=null},o=c=>{const d=c.target,u=Kt(t.element),_=Ny(c),m=Math.abs(_[0])>Math.abs(_[1])?"x":"y",p=m==="x"?_[0]:_[1],g=Qm(d,m,p,u);let E;u&&Nd(u,d)?E=!g:E=!0,E&&c.cancelable&&c.preventDefault()},l=c=>{const d=Kt(t.element),u=c.target;let _;if(c.touches.length===2)_=!Kt(t.allowPinchZoom);else{if(r==null||a===null){const m=qm(c).map((g,E)=>i[E]-g),p=Math.abs(m[0])>Math.abs(m[1])?"x":"y";r=p,a=p==="x"?m[0]:m[1]}if(u.type==="range")_=!1;else{const m=Qm(u,r,a,d);d&&Nd(d,u)?_=!m:_=!0}}_&&c.cancelable&&c.preventDefault()}},Ny=e=>[e.deltaX,e.deltaY],qm=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],Qm=(e,t,n,i)=>{const r=i!==null&&Nd(i,e),[a,s]=Ry(e,t,r?i:void 0);return!(n>0&&Math.abs(a)<=1||n<0&&Math.abs(s)<1)},Ay=Oy,Yu=Ay,xy=e=>{const t=V(()=>{const s=Kt(e.element);if(s)return getComputedStyle(s)}),n=()=>{var s;return((s=t())==null?void 0:s.animationName)??"none"},[i,r]=Q(Kt(e.show)?"present":"hidden");let a="none";return fe(s=>{const o=Kt(e.show);return Fa(()=>{var d;if(s===o)return o;const l=a,c=n();o?r("present"):c==="none"||((d=t())==null?void 0:d.display)==="none"?r("hidden"):r(s===!0&&l!==c?"hiding":"hidden")}),o}),fe(()=>{const s=Kt(e.element);if(!s)return;const o=c=>{c.target===s&&(a=n())},l=c=>{const u=n().includes(c.animationName);c.target===s&&u&&i()==="hiding"&&r("hidden")};s.addEventListener("animationstart",o),s.addEventListener("animationcancel",l),s.addEventListener("animationend",l),xe(()=>{s.removeEventListener("animationstart",o),s.removeEventListener("animationcancel",l),s.removeEventListener("animationend",l)})}),{present:()=>i()==="present"||i()==="hiding",state:i,setState:r}},wy=xy,_l=wy,Dy={};oo(Dy,{CloseButton:()=>Qf,Content:()=>Xf,Description:()=>jf,Dialog:()=>Ze,Overlay:()=>Zf,Portal:()=>Jf,Root:()=>eE,Title:()=>tE,Trigger:()=>nE,useDialogContext:()=>dr});var qf=un();function dr(){const e=Cn(qf);if(e===void 0)throw new Error("[kobalte]: `useDialogContext` must be used within a `Dialog` component");return e}function Qf(e){const t=dr(),[n,i]=Qe(e,["aria-label","onClick"]);return T(Ba,Ne({get"aria-label"(){return n["aria-label"]||t.translations().dismiss},onClick:a=>{_t(a,n.onClick),t.close()}},i))}function Xf(e){let t;const n=dr(),i=rt({id:n.generateId("content")},e),[r,a]=Qe(i,["ref","onOpenAutoFocus","onCloseAutoFocus","onPointerDownOutside","onFocusOutside","onInteractOutside"]);let s=!1,o=!1;const l=_=>{var m;(m=r.onPointerDownOutside)==null||m.call(r,_),n.modal()&&_.detail.isContextMenu&&_.preventDefault()},c=_=>{var m;(m=r.onFocusOutside)==null||m.call(r,_),n.modal()&&_.preventDefault()},d=_=>{var m;(m=r.onInteractOutside)==null||m.call(r,_),!n.modal()&&(_.defaultPrevented||(s=!0,_.detail.originalEvent.type==="pointerdown"&&(o=!0)),zn(n.triggerRef(),_.target)&&_.preventDefault(),_.detail.originalEvent.type==="focusin"&&o&&_.preventDefault())},u=_=>{var m;(m=r.onCloseAutoFocus)==null||m.call(r,_),n.modal()?(_.preventDefault(),Gt(n.triggerRef())):(_.defaultPrevented||(s||Gt(n.triggerRef()),_.preventDefault()),s=!1,o=!1)};return Uu({isDisabled:()=>!(n.isOpen()&&n.modal()),targets:()=>t?[t]:[]}),Yu({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),Fu({trapFocus:()=>n.isOpen()&&n.modal(),onMountAutoFocus:r.onOpenAutoFocus,onUnmountAutoFocus:u},()=>t),fe(()=>xe(n.registerContentId(a.id))),T(ee,{get when(){return n.contentPresent()},get children(){return T(Bu,Ne({ref(_){var m=Pt(p=>{n.setContentRef(p),t=p},r.ref);typeof m=="function"&&m(_)},role:"dialog",tabIndex:-1,get disableOutsidePointerEvents(){return ke(()=>!!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}},a))}})}function jf(e){const t=dr(),n=rt({id:t.generateId("description")},e),[i,r]=Qe(n,["id"]);return fe(()=>xe(t.registerDescriptionId(i.id))),T(ft,Ne({as:"p",get id(){return i.id}},r))}function Zf(e){const t=dr(),[n,i]=Qe(e,["ref","style","onPointerDown"]),r=a=>{_t(a,n.onPointerDown),a.target===a.currentTarget&&a.preventDefault()};return T(ee,{get when(){return t.overlayPresent()},get children(){return T(ft,Ne({as:"div",ref(a){var s=Pt(t.setOverlayRef,n.ref);typeof s=="function"&&s(a)},get style(){return ao({"pointer-events":"auto"},n.style)},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onPointerDown:r},i))}})}function Jf(e){const t=dr();return T(ee,{get when(){return t.contentPresent()||t.overlayPresent()},get children(){return T(wu,e)}})}var Xm={dismiss:"Dismiss"};function eE(e){const t=`dialog-${Fr()}`,n=rt({id:t,modal:!0,translations:Xm},e),[i,r]=Q(),[a,s]=Q(),[o,l]=Q(),[c,d]=Q(),[u,_]=Q(),[m,p]=Q(),g=Gu({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:v=>{var b;return(b=n.onOpenChange)==null?void 0:b.call(n,v)}}),E=()=>n.forceMount||g.isOpen(),{present:h}=_l({show:E,element:()=>c()??null}),{present:f}=_l({show:E,element:()=>u()??null}),S={translations:()=>n.translations??Xm,isOpen:g.isOpen,modal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??S.modal(),contentId:i,titleId:a,descriptionId:o,triggerRef:m,overlayRef:c,setOverlayRef:d,contentRef:u,setContentRef:_,overlayPresent:h,contentPresent:f,close:g.close,toggle:g.toggle,setTriggerRef:p,generateId:Ua(()=>n.id),registerContentId:Tn(r),registerTitleId:Tn(s),registerDescriptionId:Tn(l)};return T(qf.Provider,{value:S,get children(){return n.children}})}function tE(e){const t=dr(),n=rt({id:t.generateId("title")},e),[i,r]=Qe(n,["id"]);return fe(()=>xe(t.registerTitleId(i.id))),T(ft,Ne({as:"h2",get id(){return i.id}},r))}function nE(e){const t=dr(),[n,i]=Qe(e,["ref","onClick"]);return T(Ba,Ne({ref(a){var s=Pt(t.setTriggerRef,n.ref);typeof s=="function"&&s(a)},"aria-haspopup":"dialog",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return ke(()=>!!t.isOpen())()?t.contentId():void 0},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onClick:a=>{_t(a,n.onClick),t.toggle()}},i))}var Ze=Object.assign(eE,{CloseButton:Qf,Content:Xf,Description:jf,Overlay:Zf,Portal:Jf,Title:tE,Trigger:nE});const Ly=e=>typeof e=="function",ml=(e,t)=>Ly(e)?e(t):e;var Rt;(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"})(Rt||(Rt={}));const pl=Symbol("store-raw"),fa=Symbol("store-node"),Si=Symbol("store-has"),iE=Symbol("store-self");function rE(e){let t=e[Or];if(!t&&(Object.defineProperty(e,Or,{value:t=new Proxy(e,Py)}),!Array.isArray(e))){const n=Object.keys(e),i=Object.getOwnPropertyDescriptors(e);for(let r=0,a=n.length;r<a;r++){const s=n[r];i[s].get&&Object.defineProperty(e,s,{enumerable:i[s].enumerable,get:i[s].get.bind(t)})}}return t}function ci(e){let t;return e!=null&&typeof e=="object"&&(e[Or]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function Nr(e,t=new Set){let n,i,r,a;if(n=e!=null&&e[pl])return n;if(!ci(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let s=0,o=e.length;s<o;s++)r=e[s],(i=Nr(r,t))!==r&&(e[s]=i)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);const s=Object.keys(e),o=Object.getOwnPropertyDescriptors(e);for(let l=0,c=s.length;l<c;l++)a=s[l],!o[a].get&&(r=e[a],(i=Nr(r,t))!==r&&(e[a]=i))}return e}function gl(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Fs(e,t,n){if(e[t])return e[t];const[i,r]=Q(n,{equals:!1,internal:!0});return i.$=r,e[t]=i}function My(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===Or||t===fa||(delete n.value,delete n.writable,n.get=()=>e[Or][t]),n}function aE(e){Rd()&&Fs(gl(e,fa),iE)()}function ky(e){return aE(e),Reflect.ownKeys(e)}const Py={get(e,t,n){if(t===pl)return e;if(t===Or)return n;if(t===yd)return aE(e),n;const i=gl(e,fa),r=i[t];let a=r?r():e[t];if(t===fa||t===Si||t==="__proto__")return a;if(!r){const s=Object.getOwnPropertyDescriptor(e,t);Rd()&&(typeof a!="function"||e.hasOwnProperty(t))&&!(s&&s.get)&&(a=Fs(i,t,a)())}return ci(a)?rE(a):a},has(e,t){return t===pl||t===Or||t===yd||t===fa||t===Si||t==="__proto__"?!0:(Rd()&&Fs(gl(e,Si),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:ky,getOwnPropertyDescriptor:My};function sn(e,t,n,i=!1){if(!i&&e[t]===n)return;const r=e[t],a=e.length;n===void 0?(delete e[t],e[Si]&&e[Si][t]&&r!==void 0&&e[Si][t].$()):(e[t]=n,e[Si]&&e[Si][t]&&r===void 0&&e[Si][t].$());let s=gl(e,fa),o;if((o=Fs(s,t,r))&&o.$(()=>n),Array.isArray(e)&&e.length!==a){for(let l=e.length;l<a;l++)(o=s[l])&&o.$();(o=Fs(s,"length",a))&&o.$(e.length)}(o=s[iE])&&o.$()}function sE(e,t){const n=Object.keys(t);for(let i=0;i<n.length;i+=1){const r=n[i];sn(e,r,t[r])}}function Fy(e,t){if(typeof t=="function"&&(t=t(e)),t=Nr(t),Array.isArray(t)){if(e===t)return;let n=0,i=t.length;for(;n<i;n++){const r=t[n];e[n]!==r&&sn(e,n,r)}sn(e,"length",i)}else sE(e,t)}function us(e,t,n=[]){let i,r=e;if(t.length>1){i=t.shift();const s=typeof i,o=Array.isArray(e);if(Array.isArray(i)){for(let l=0;l<i.length;l++)us(e,[i[l]].concat(t),n);return}else if(o&&s==="function"){for(let l=0;l<e.length;l++)i(e[l],l)&&us(e,[l].concat(t),n);return}else if(o&&s==="object"){const{from:l=0,to:c=e.length-1,by:d=1}=i;for(let u=l;u<=c;u+=d)us(e,[u].concat(t),n);return}else if(t.length>1){us(e[i],t,[i].concat(n));return}r=e[i],n=[i].concat(n)}let a=t[0];typeof a=="function"&&(a=a(r,n),a===r)||i===void 0&&a==null||(a=Nr(a),i===void 0||ci(r)&&ci(a)&&!Array.isArray(a)?sE(r,a):sn(e,i,a))}function oE(...[e,t]){const n=Nr(e||{}),i=Array.isArray(n),r=rE(n);function a(...s){Mf(()=>{i&&s.length===1?Fy(n,s[0]):us(n,s)})}return[r,a]}const Ad=Symbol("store-root");function jr(e,t,n,i,r){const a=t[n];if(e===a)return;const s=Array.isArray(e);if(n!==Ad&&(!ci(e)||!ci(a)||s!==Array.isArray(a)||r&&e[r]!==a[r])){sn(t,n,e);return}if(s){if(e.length&&a.length&&(!i||r&&e[0]&&e[0][r]!=null)){let c,d,u,_,m,p,g,E;for(u=0,_=Math.min(a.length,e.length);u<_&&(a[u]===e[u]||r&&a[u]&&e[u]&&a[u][r]&&a[u][r]===e[u][r]);u++)jr(e[u],a,u,i,r);const h=new Array(e.length),f=new Map;for(_=a.length-1,m=e.length-1;_>=u&&m>=u&&(a[_]===e[m]||r&&a[_]&&e[m]&&a[_][r]&&a[_][r]===e[m][r]);_--,m--)h[m]=a[_];if(u>m||u>_){for(d=u;d<=m;d++)sn(a,d,e[d]);for(;d<e.length;d++)sn(a,d,h[d]),jr(e[d],a,d,i,r);a.length>e.length&&sn(a,"length",e.length);return}for(g=new Array(m+1),d=m;d>=u;d--)p=e[d],E=r&&p?p[r]:p,c=f.get(E),g[d]=c===void 0?-1:c,f.set(E,d);for(c=u;c<=_;c++)p=a[c],E=r&&p?p[r]:p,d=f.get(E),d!==void 0&&d!==-1&&(h[d]=a[c],d=g[d],f.set(E,d));for(d=u;d<e.length;d++)d in h?(sn(a,d,h[d]),jr(e[d],a,d,i,r)):sn(a,d,e[d])}else for(let c=0,d=e.length;c<d;c++)jr(e[c],a,c,i,r);a.length>e.length&&sn(a,"length",e.length);return}const o=Object.keys(e);for(let c=0,d=o.length;c<d;c++)jr(e[o[c]],a,o[c],i,r);const l=Object.keys(a);for(let c=0,d=l.length;c<d;c++)e[l[c]]===void 0&&sn(a,l[c],void 0)}function Uy(e,t={}){const{merge:n,key:i="id"}=t,r=Nr(e);return a=>{if(!ci(a)||!ci(r))return r;const s=jr(r,{[Ad]:a},Ad,n,i);return s===void 0?a:s}}const fl=new WeakMap,lE={get(e,t){if(t===pl)return e;const n=e[t];let i;return ci(n)?fl.get(n)||(fl.set(n,i=new Proxy(n,lE)),i):n},set(e,t,n){return sn(e,t,Nr(n)),!0},deleteProperty(e,t){return sn(e,t,void 0,!0),!0}};function Ki(e){return t=>{if(ci(t)){let n;(n=fl.get(t))||fl.set(t,n=new Proxy(t,lE)),e(n)}return t}}const[Cr,Bi]=oE({toasts:[],pausedAt:void 0}),By=()=>{const{pausedAt:e,toasts:t}=Cr;if(e)return;const n=Date.now();return t.map(r=>{if(r.duration===1/0)return;const a=(r.duration||0)+r.pauseDuration-(n-r.createdAt);if(a<=0){r.visible&&Xn({type:Rt.DISMISS_TOAST,toastId:r.id});return}return setTimeout(()=>{Xn({type:Rt.DISMISS_TOAST,toastId:r.id})},a)})},Ts=new Map,jm=(e,t)=>{if(Ts.has(e))return;const n=setTimeout(()=>{Ts.delete(e),Xn({type:Rt.REMOVE_TOAST,toastId:e})},t);Ts.set(e,n)},$y=e=>{const t=Ts.get(e);Ts.delete(e),t&&clearTimeout(t)},Xn=e=>{switch(e.type){case Rt.ADD_TOAST:Bi("toasts",r=>{const a=r;return[e.toast,...a]});break;case Rt.DISMISS_TOAST:const{toastId:t}=e,n=Cr.toasts;if(t){const r=n.find(a=>a.id===t);r&&jm(t,r.unmountDelay),Bi("toasts",a=>a.id===t,Ki(a=>a.visible=!1))}else n.forEach(r=>{jm(r.id,r.unmountDelay)}),Bi("toasts",r=>r.id!==void 0,Ki(r=>r.visible=!1));break;case Rt.REMOVE_TOAST:if(!e.toastId){Bi("toasts",[]);break}Bi("toasts",r=>r.filter(s=>s.id!==e.toastId));break;case Rt.UPDATE_TOAST:e.toast.id&&$y(e.toast.id),Bi("toasts",r=>r.id===e.toast.id,r=>({...r,...e.toast}));break;case Rt.UPSERT_TOAST:Cr.toasts.find(r=>r.id===e.toast.id)?Xn({type:Rt.UPDATE_TOAST,toast:e.toast}):Xn({type:Rt.ADD_TOAST,toast:e.toast});break;case Rt.START_PAUSE:Bi(Ki(r=>{r.pausedAt=Date.now(),r.toasts.forEach(a=>{a.paused=!0})}));break;case Rt.END_PAUSE:const i=e.time-(Cr.pausedAt||0);Bi(Ki(r=>{r.pausedAt=void 0,r.toasts.forEach(a=>{a.pauseDuration+=i,a.paused=!1})}));break}},Gy={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Ea={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},cE={position:"top-right",toastOptions:Ea,gutter:8,containerStyle:{},containerClassName:""},vo="16px",Yy={position:"fixed","z-index":9999,top:vo,bottom:vo,left:vo,right:vo,"pointer-events":"none"},Vy=(()=>{let e=0;return()=>String(++e)})(),Hy=e=>{jy(t=>({containerClassName:e.containerClassName??t.containerClassName,containerStyle:e.containerStyle??t.containerStyle,gutter:e.gutter??t.gutter,position:e.position??t.position,toastOptions:{...e.toastOptions}}))},Wy=(e,t)=>{const i=e.includes("top")?{top:0,"margin-top":`${t}px`}:{bottom:0,"margin-bottom":`${t}px`},r=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)",...i,...r}},zy=(e,t)=>{const n=e.getBoundingClientRect();n.height!==t.height&&Xn({type:Rt.UPDATE_TOAST,toast:{id:t.id,height:n.height}})},Ky=(e,t)=>{const{toasts:n}=Cr,i=Zr().gutter||cE.gutter||8,r=n.filter(l=>(l.position||t)===t&&l.height),a=r.findIndex(l=>l.id===e.id),s=r.filter((l,c)=>c<a&&l.visible).length;return r.slice(0,s).reduce((l,c)=>l+i+(c.height||0),0)},qy=(e,t)=>(e.position||t).includes("top")?1:-1,Qy={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"},Xy={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},yo={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},El=e=>({calcMode:"spline",keyTimes:"0; 1",keySplines:e}),[Zr,jy]=Q(cE),Zy=(e,t="blank",n)=>{var i,r,a;return{...Ea,...Zr().toastOptions,...n,type:t,message:e,pauseDuration:0,createdAt:Date.now(),visible:!0,id:n.id||Vy(),paused:!1,style:{...Ea.style,...(i=Zr().toastOptions)==null?void 0:i.style,...n.style},duration:n.duration||((r=Zr().toastOptions)==null?void 0:r.duration)||Gy[t],position:n.position||((a=Zr().toastOptions)==null?void 0:a.position)||Zr().position||Ea.position}},lo=e=>(t,n={})=>Cd(()=>{const i=Cr.toasts.find(a=>a.id===n.id),r=Zy(t,e,{...i,duration:void 0,...n});return Xn({type:Rt.UPSERT_TOAST,toast:r}),r.id}),Mn=(e,t)=>lo("blank")(e,t);Fa(()=>Mn);Mn.error=lo("error");Mn.success=lo("success");Mn.loading=lo("loading");Mn.custom=lo("custom");Mn.dismiss=e=>{Xn({type:Rt.DISMISS_TOAST,toastId:e})};Mn.promise=(e,t,n)=>{const i=Mn.loading(t.loading,{...n});return e.then(r=>(Mn.success(ml(t.success,r),{id:i,...n}),r)).catch(r=>{Mn.error(ml(t.error,r),{id:i,...n})}),e};Mn.remove=e=>{Xn({type:Rt.REMOVE_TOAST,toastId:e})};var Jy=G("<div><style>.sldt-active{z-index:9999;}.sldt-active>*{pointer-events:auto;}");const eC=e=>(fe(()=>{Hy(e)}),fe(()=>{const t=By();xe(()=>{t&&t.forEach(n=>n&&clearTimeout(n))})}),(()=>{var t=Jy();return t.firstChild,I(t,T(We,{get each(){return Cr.toasts},children:n=>T(rC,{toast:n})}),null),ue(n=>{var i={...Yy,...e.containerStyle},r=e.containerClassName;return n.e=wn(t,i,n.e),r!==n.t&&He(t,n.t=r),n},{e:void 0,t:void 0}),t})());var Co=G("<div>"),tC=G("<div><div>");const nC=e=>{let t;return fe(()=>{if(!t)return;const n=qy(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=tC(),i=n.firstChild,r=t;return typeof r=="function"?Nt(r,n):t=n,I(n,T(ic,{get children(){return[T(bn,{get when(){return e.toast.icon},get children(){var a=Co();return I(a,()=>e.toast.icon),ue(s=>wn(a,yo,s)),a}}),T(bn,{get when(){return e.toast.type==="loading"},get children(){var a=Co();return I(a,T(_C,Ne(()=>e.toast.iconTheme))),ue(s=>wn(a,yo,s)),a}}),T(bn,{get when(){return e.toast.type==="success"},get children(){var a=Co();return I(a,T(lC,Ne(()=>e.toast.iconTheme))),ue(s=>wn(a,yo,s)),a}}),T(bn,{get when(){return e.toast.type==="error"},get children(){var a=Co();return I(a,T(dC,Ne(()=>e.toast.iconTheme))),ue(s=>wn(a,yo,s)),a}})]}}),i),li(i,Ne(()=>e.toast.ariaProps),!1,!0),I(i,()=>ml(e.toast.message,e.toast)),ue(a=>{var s=e.toast.className,o={...Qy,...e.toast.style},l=Xy;return s!==a.e&&He(n,a.e=s),a.t=wn(n,o,a.t),a.a=wn(i,l,a.a),a},{e:void 0,t:void 0,a:void 0}),n})()};var iC=G("<div>");const rC=e=>{const t=()=>{const r=e.toast.position||Ea.position,a=Ky(e.toast,r);return Wy(r,a)},n=V(()=>t());let i;return dn(()=>{i&&zy(i,e.toast)}),(()=>{var r=iC();r.addEventListener("mouseleave",()=>Xn({type:Rt.END_PAUSE,time:Date.now()})),r.addEventListener("mouseenter",()=>Xn({type:Rt.START_PAUSE,time:Date.now()}));var a=i;return typeof a=="function"?Nt(a,r):i=r,I(r,(()=>{var s=ke(()=>e.toast.type==="custom");return()=>s()?ml(e.toast.message,e.toast):T(nC,{get toast(){return e.toast},get position(){return e.toast.position||Ea.position}})})()),ue(s=>{var o=n(),l=e.toast.visible?"sldt-active":"";return s.e=wn(r,o,s.e),l!==s.t&&He(r,s.t=l),s},{e:void 0,t:void 0}),r})()};var aC=G('<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),sC=G('<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 dE=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=aC(),i=n.firstChild,r=i.nextSibling;return li(i,t,!0,!1),li(r,t,!0,!1),ue(()=>Fe(n,"fill",e.fill)),n})()},uE=e=>{const t={dur:"1s",begin:e.begin||"320ms",fill:"freeze",...El("0.0 0.0 0.2 1")};return(()=>{var n=sC(),i=n.firstChild,r=i.nextSibling;return li(i,t,!0,!1),li(r,t,!0,!1),ue(()=>Fe(n,"fill",e.fill)),n})()};var oC=G('<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 lC=e=>{const t=e.primary||"#34C759";return(()=>{var n=oC(),i=n.firstChild,r=i.firstChild;return I(n,T(dE,{fill:t}),i),I(n,T(uE,{fill:t,begin:"350ms"}),i),li(r,Ne(()=>El("0.0, 0.0, 0.58, 1.0")),!0,!1),ue(()=>Fe(i,"stroke",e.secondary||"#FCFCFC")),n})()};var cC=G('<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 dC=e=>{const t=e.primary||"#FF3B30";return(()=>{var n=cC(),i=n.firstChild,r=i.firstChild,a=i.nextSibling,s=a.firstChild;return I(n,T(dE,{fill:t}),i),I(n,T(uE,{fill:t}),i),li(r,Ne(()=>El("0.0, 0.0, 0.58, 1.0")),!0,!1),li(s,Ne(()=>El("0.0, 0.0, 0.58, 1.0")),!0,!1),ue(o=>{var l=e.secondary||"#FFFFFF",c=e.secondary||"#FFFFFF";return l!==o.e&&Fe(i,"stroke",o.e=l),c!==o.t&&Fe(a,"fill",o.t=c),o},{e:void 0,t:void 0}),n})()};var uC=G('<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 _C=e=>(()=>{var t=uC(),n=t.firstChild,i=n.nextSibling;return ue(r=>{var a=e.primary||"#E5E7EB",s=e.secondary||"#4b5563";return a!==r.e&&Fe(n,"stroke",r.e=a),s!==r.t&&Fe(i,"stroke",r.t=s),r},{e:void 0,t:void 0}),t})(),[xd,Vu]=Q(null);function vi(e,t){Vu({type:"alert",message:e,...t})}function mC(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(i=>{Vu({type:"confirm",message:e,...t,resolve:i})})}function pC(){Vu(null)}var gC=G('<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">'),fC=G('<div class="mt-6 flex justify-end gap-3"><button type=button class=button-primary>'),EC=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),hC=G('<p class="mt-2 text-secondary">'),SC=G("<button type=button class=button-secondary>");const bC={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 Gc(e,t){var i,r,a,s;const n=t??xd();(n==null?void 0:n.type)==="confirm"?(e?(i=n.onConfirm)==null||i.call(n):(r=n.onCancel)==null||r.call(n),(a=n.resolve)==null||a.call(n,e)):e&&((s=n==null?void 0:n.onConfirm)==null||s.call(n)),pC()}const TC=()=>{let e;return fe(()=>{xd()&&queueMicrotask(()=>{e==null||e.focus()})}),T(ee,{get when(){return xd()},keyed:!0,children:t=>{const n=t.variant??"info",i=bC[n],r=t.title||i.fallbackTitle,a=t.type==="confirm",s=t.confirmLabel||(a?"Confirm":"OK"),o=t.cancelLabel||"Cancel";return T(Ze,{open:!0,modal:!0,onOpenChange:l=>{l||Gc(!1,t)},get children(){return T(Ze.Portal,{get children(){return[T(Ze.Overlay,{class:"modal-overlay"}),(()=>{var l=EC();return I(l,T(Ze.Content,{class:"modal-surface w-full max-w-sm p-6 border border-base shadow-2xl",tabIndex:-1,get children(){return[(()=>{var c=gC(),d=c.firstChild,u=d.nextSibling;return I(d,()=>i.symbol),I(u,T(Ze.Title,{class:"text-lg font-semibold text-primary",children:r}),null),I(u,T(Ze.Description,{class:"text-sm text-secondary mt-1 whitespace-pre-line break-words",get children(){return[ke(()=>t.message),ke(()=>ke(()=>!!t.detail)()&&(()=>{var _=hC();return I(_,()=>t.detail),_})())]}}),null),ue(_=>{var m=i.badgeBg,p=i.badgeBorder,g=i.badgeText;return m!==_.e&&bs(d,"background-color",_.e=m),p!==_.t&&bs(d,"border-color",_.t=p),g!==_.a&&bs(d,"color",_.a=g),_},{e:void 0,t:void 0,a:void 0}),c})(),(()=>{var c=fC(),d=c.firstChild;return I(c,a&&(()=>{var u=SC();return u.$$click=()=>Gc(!1,t),I(u,o),u})(),d),d.$$click=()=>Gc(!0,t),Nt(u=>{e=u},d),I(d,s),c})()]}})),l})()]}})}})}})};At(["click"]);const Wr={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 vC=G("<svg>");const yC=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Tt=e=>{const[t,n]=Qe(e,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var i=vC();return li(i,Ne(Wr,{get width(){return t.size??Wr.width},get height(){return t.size??Wr.height},get stroke(){return t.color??Wr.stroke},get"stroke-width"(){return ke(()=>!!t.absoluteStrokeWidth)()?Number(t.strokeWidth??Wr["stroke-width"])*24/Number(t.size):Number(t.strokeWidth??Wr["stroke-width"])},get class(){return`lucide lucide-${yC((t==null?void 0:t.name)??"icon")} ${t.class!=null?t.class:""}`}},n),!0,!0),I(i,T(We,{get each(){return t.iconNode},children:([r,a])=>T(Lf,Ne({component:r},a))})),i})()},CC=[["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"}]],RC=e=>T(Tt,Ne(e,{name:"AlertCircle",iconNode:CC})),IC=[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]],_E=e=>T(Tt,Ne(e,{name:"ArrowUpLeft",iconNode:IC})),OC=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],NC=e=>T(Tt,Ne(e,{name:"Check",iconNode:OC})),AC=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Hu=e=>T(Tt,Ne(e,{name:"ChevronDown",iconNode:AC})),xC=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],wC=e=>T(Tt,Ne(e,{name:"ChevronRight",iconNode:xC})),DC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],LC=e=>T(Tt,Ne(e,{name:"Clock",iconNode:DC})),MC=[["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"}]],kC=e=>T(Tt,Ne(e,{name:"Copy",iconNode:MC})),PC=[["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"}]],FC=e=>T(Tt,Ne(e,{name:"File",iconNode:PC})),UC=[["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"}]],mE=e=>T(Tt,Ne(e,{name:"FolderOpen",iconNode:UC})),BC=[["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"}]],$C=e=>T(Tt,Ne(e,{name:"FolderPlus",iconNode:BC})),GC=[["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"}]],Wu=e=>T(Tt,Ne(e,{name:"Folder",iconNode:GC})),YC=[["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"}]],VC=e=>T(Tt,Ne(e,{name:"Globe",iconNode:YC})),HC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],WC=e=>T(Tt,Ne(e,{name:"Info",iconNode:HC})),zC=[["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"}]],Zm=e=>T(Tt,Ne(e,{name:"Key",iconNode:zC})),KC=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Us=e=>T(Tt,Ne(e,{name:"Loader2",iconNode:KC})),qC=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]],QC=e=>T(Tt,Ne(e,{name:"MessageSquare",iconNode:qC})),XC=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],zu=e=>T(Tt,Ne(e,{name:"Plus",iconNode:XC})),jC=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],ZC=e=>T(Tt,Ne(e,{name:"Search",iconNode:jC})),JC=[["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"}]],eR=e=>T(Tt,Ne(e,{name:"Settings",iconNode:JC})),tR=[["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"}]],Ku=e=>T(Tt,Ne(e,{name:"Trash2",iconNode:tR})),nR=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],rc=e=>T(Tt,Ne(e,{name:"X",iconNode:nR})),Jm="http://127.0.0.1:9898";var Df;const iR=typeof window<"u"?(Df=window.location)==null?void 0:Df.origin:void 0,rR=typeof window<"u"?window.__CODENOMAD_API_BASE__??iR??Jm:Jm,aR=typeof window<"u"?window.__CODENOMAD_EVENTS_URL__??"/api/events":"/api/events",hl=rR,ep=oR(hl,aR),sR=hl;function oR(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(e){const n=t.startsWith("/")?t:`/${t}`;return`${e}${n}`}return t}const tp="[HTTP]";function Ro(e,t){if(t){console.log(`${tp} ${e}`,t);return}console.log(`${tp} ${e}`)}async function Ut(e,t){const n=hl?new URL(e,hl).toString():e,i={"Content-Type":"application/json",...(t==null?void 0:t.headers)??{}},r=((t==null?void 0:t.method)??"GET").toUpperCase(),a=Date.now();Ro(`${r} ${e}`);try{const s=await fetch(n,{...t,headers:i});if(!s.ok){const l=await s.text();throw Ro(`${r} ${e} -> ${s.status}`,{durationMs:Date.now()-a,error:l}),new Error(l||`Request failed with ${s.status}`)}const o=Date.now()-a;return Ro(`${r} ${e} -> ${s.status}`,{durationMs:o}),s.status===204?void 0:await s.json()}catch(s){throw Ro(`${r} ${e} failed`,{durationMs:Date.now()-a,error:s}),s}}const cn={fetchWorkspaces(){return Ut("/api/workspaces")},createWorkspace(e){return Ut("/api/workspaces",{method:"POST",body:JSON.stringify(e)})},fetchServerMeta(){return Ut("/api/meta")},deleteWorkspace(e){return Ut(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})},listWorkspaceFiles(e,t="."){const n=new URLSearchParams({path:t});return Ut(`/api/workspaces/${encodeURIComponent(e)}/files?${n.toString()}`)},searchWorkspaceFiles(e,t,n){const i=t.trim();if(!i)return Promise.resolve([]);const r=new URLSearchParams({q:i});return n!=null&&n.limit&&r.set("limit",String(n.limit)),n!=null&&n.type&&r.set("type",n.type),Ut(`/api/workspaces/${encodeURIComponent(e)}/files/search?${r.toString()}`)},readWorkspaceFile(e,t){const n=new URLSearchParams({path:t});return Ut(`/api/workspaces/${encodeURIComponent(e)}/files/content?${n.toString()}`)},fetchConfig(){return Ut("/api/config/app")},updateConfig(e){return Ut("/api/config/app",{method:"PUT",body:JSON.stringify(e)})},listBinaries(){return Ut("/api/config/binaries")},createBinary(e){return Ut("/api/config/binaries",{method:"POST",body:JSON.stringify(e)})},updateBinary(e,t){return Ut(`/api/config/binaries/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})},deleteBinary(e){return Ut(`/api/config/binaries/${encodeURIComponent(e)}`,{method:"DELETE"})},validateBinary(e){return Ut("/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 i=n.toString();return Ut(i?`/api/filesystem?${i}`:"/api/filesystem")},readInstanceData(e){return Ut(`/api/storage/instances/${encodeURIComponent(e)}`)},writeInstanceData(e,t){return Ut(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})},deleteInstanceData(e){return Ut(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"DELETE"})},connectEvents(e,t){console.log(`[SSE] Connecting to ${ep}`);const n=new EventSource(ep);return n.onmessage=i=>{try{const r=JSON.parse(i.data);e(r)}catch(r){console.error("[SSE] Failed to parse event",r)}},n.onerror=()=>{console.warn("[SSE] EventSource error, closing stream"),t==null||t()},n}},np=1e3,lR=1e4,ip="[SSE]";function Io(e,t){if(t){console.log(`${ip} ${e}`,t);return}console.log(`${ip} ${e}`)}class cR{constructor(){this.handlers=new Map,this.source=null,this.retryDelay=np,this.connect()}connect(){this.source&&this.source.close(),Io("Connecting to backend events stream"),this.source=cn.connectEvents(t=>this.dispatch(t),()=>this.scheduleReconnect()),this.source.onopen=()=>{Io("Events stream connected"),this.retryDelay=np}}scheduleReconnect(){this.source&&(this.source.close(),this.source=null),Io("Events stream disconnected, scheduling reconnect",{delayMs:this.retryDelay}),setTimeout(()=>{this.retryDelay=Math.min(this.retryDelay*2,lR),this.connect()},this.retryDelay)}dispatch(t){var n,i;Io(`event ${t.type}`),(n=this.handlers.get("*"))==null||n.forEach(r=>r(t)),(i=this.handlers.get(t.type))==null||i.forEach(r=>r(t))}on(t,n){this.handlers.has(t)||this.handlers.set(t,new Set);const i=this.handlers.get(t);return i.add(n),()=>i.delete(n)}}const Bs=new cR,rp={messageHistory:[],agentModelSelections:{}};function ap(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){console.warn("Failed to compare config objects",n)}return!1}class dR{constructor(){this.configChangeListeners=new Set,this.configCache=null,this.loadPromise=null,this.instanceDataCache=new Map,this.instanceDataListeners=new Map,this.instanceLoadPromises=new Map,Bs.on("config.appChanged",t=>{t.type==="config.appChanged"&&this.setConfigCache(t.config)}),Bs.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=cn.fetchConfig().then(t=>(this.setConfigCache(t),t)).finally(()=>{this.loadPromise=null})),this.loadPromise)}async updateConfig(t){const n=await cn.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 i=cn.readInstanceData(t).then(r=>{const a=this.normalizeInstanceData(r);return this.setInstanceDataCache(t,a),a}).finally(()=>{this.instanceLoadPromises.delete(t)});this.instanceLoadPromises.set(t,i)}return this.instanceLoadPromises.get(t)}async saveInstanceData(t,n){const i=this.normalizeInstanceData(n);await cn.writeInstanceData(t,i),this.setInstanceDataCache(t,i)}async deleteInstanceData(t){await cn.deleteInstanceData(t),this.setInstanceDataCache(t,rp)}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 i=this.instanceDataListeners.get(t);i.add(n);const r=this.instanceDataCache.get(t);return r&&n(r),()=>{i.delete(n),i.size===0&&this.instanceDataListeners.delete(t)}}setConfigCache(t){if(this.configCache&&ap(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??rp,i=Array.isArray(n.messageHistory)?[...n.messageHistory]:[],r={...n.agentModelSelections??{}};return{...n,messageHistory:i,agentModelSelections:r}}setInstanceDataCache(t,n){const i=this.normalizeInstanceData(n),r=this.instanceDataCache.get(t);if(r&&ap(r,i)){this.instanceDataCache.set(t,i);return}this.instanceDataCache.set(t,i),this.notifyInstanceDataChanged(t,i)}notifyInstanceDataChanged(t,n){const i=this.instanceDataListeners.get(t);if(i)for(const r of i)r(n)}}const Ar=new dR,ac={messageHistory:[],agentModelSelections:{}},[qu,pE]=Q(new Map),Oo=new Map,Ra=new Map;function gE(e){const t=e??ac;return{...t,messageHistory:Array.isArray(t.messageHistory)?[...t.messageHistory]:[],agentModelSelections:{...t.agentModelSelections??{}}}}function sp(e){if(Ra.has(e))return;const t=Ar.onInstanceDataChanged(e,n=>{Sl(e,n)});Ra.set(e,t)}function uR(e){const t=Ra.get(e);t&&(t(),Ra.delete(e))}function Sl(e,t){pE(n=>{const i=new Map(n);return i.set(e,gE(t)),i})}async function Ur(e){if(!e||qu().has(e))return;if(Oo.has(e)){await Oo.get(e);return}const t=Ar.loadInstanceData(e).then(n=>{Sl(e,n),sp(e)}).catch(n=>{console.warn("Failed to load instance data:",n),Sl(e,ac),sp(e)}).finally(()=>{Oo.delete(e)});Oo.set(e,t),await t}async function Qu(e,t){if(!e)return;await Ur(e);const n=qu().get(e)??ac,i=gE(n);t(i);try{await Ar.saveInstanceData(e,i)}catch(r){console.warn("Failed to persist instance data:",r)}Sl(e,i)}function Xu(e){return qu().get(e)??ac}function _R(e){pE(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),uR(e)}const mR=un(),pR={getInstanceConfig:Xu,ensureInstanceConfig:Ur,updateInstanceConfig:Qu,clearInstanceConfig:_R},gR=e=>(xe(()=>{for(const t of Ra.values())t();Ra.clear()}),T(mR.Provider,{value:pR,get children(){return e.children}})),fR=20,ER=5,pi={showThinkingBlocks:!1,thinkingBlocksExpansion:"expanded",environmentVariables:{},modelRecents:[],diffViewMode:"split",toolOutputExpansion:"expanded",diagnosticsExpansion:"expanded",showUsageMetrics:!0};function fE(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){console.warn("Failed to compare preference values",n)}return!1}function sc(e){const t=e??{},n={...pi.environmentVariables,...t.environmentVariables??{}},r=(t.modelRecents??pi.modelRecents).map(a=>({...a}));return{showThinkingBlocks:t.showThinkingBlocks??pi.showThinkingBlocks,thinkingBlocksExpansion:t.thinkingBlocksExpansion??pi.thinkingBlocksExpansion,lastUsedBinary:t.lastUsedBinary??pi.lastUsedBinary,environmentVariables:n,modelRecents:r,diffViewMode:t.diffViewMode??pi.diffViewMode,toolOutputExpansion:t.toolOutputExpansion??pi.toolOutputExpansion,diagnosticsExpansion:t.diagnosticsExpansion??pi.diagnosticsExpansion,showUsageMetrics:t.showUsageMetrics??pi.showUsageMetrics}}const[ur,hR]=Q(SE()),SR=V(()=>ur()),[EE,bR]=Q(!1),Rn=V(()=>ur().preferences),TR=V(()=>ur().recentFolders??[]),vR=V(()=>ur().opencodeBinaries??[]),hE=V(()=>ur().theme??"dark");let No=null;function oc(e){return{preferences:sc(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 SE(){return oc()}function yR(e){var i;const t=!!((i=e==null?void 0:e.preferences)!=null&&i.agentModelSelections);return{cleaned:oc(e),migrated:t}}async function ju(e){try{const t=e??await Ar.loadConfig(),{cleaned:n,migrated:i}=yR(t);wd(n),i&&Ar.updateConfig(n).catch(r=>{console.error("Failed to persist legacy config cleanup:",r)})}catch(t){console.error("Failed to load config:",t),wd(SE())}}function wd(e){hR(oc(e)),bR(!0)}function CR(){return oc(ur())}function RR(e,t){if(fE(e,t))return;const n=bE(e,t);n.length>0&&console.debug("[Config] Changes",n)}function bE(e,t,n=[]){if(e===t)return[];if(typeof e!="object"||e===null||typeof t!="object"||t===null)return[n.join(".")];const i=Object.keys(e),r=Object.keys(t),a=new Set([...i,...r]),s=[];for(const o of a){const l=[...n,o],c=e[o],d=t[o];s.push(...bE(c,d,l))}return s}function Mi(e){const t=ur(),n=CR();e(n),RR(t,n),wd(n),IR(n)}async function IR(e){try{await Zu(),await Ar.updateConfig(e)}catch(t){console.error("Failed to save config:",t),ju().catch(n=>{console.error("Failed to refresh config:",n)})}}function OR(e){hE()!==e&&Mi(t=>{t.theme=e})}async function Zu(){EE()||(No||(No=ju().finally(()=>{No=null})),await No)}function TE(e,t){const n=t.filter(i=>i.path!==e);return n.unshift({path:e,lastAccessed:Date.now()}),n.slice(0,fR)}function Ju(e,t,n){const i=Date.now(),r=n.find(s=>s.path===e);if(r){const s={...r,lastUsed:i},o=n.filter(l=>l.path!==e);return[s,...o]}return[t?{path:e,version:t,lastUsed:i}:{path:e,lastUsed:i},...n].slice(0,10)}function ki(e){const t=ur().preferences,n=sc({...t,...e});fE(t,n)||Mi(i=>{i.preferences=n})}function NR(e){Rn().diffViewMode!==e&&ki({diffViewMode:e})}function AR(e){Rn().toolOutputExpansion!==e&&ki({toolOutputExpansion:e})}function xR(e){Rn().diagnosticsExpansion!==e&&ki({diagnosticsExpansion:e})}function wR(e){Rn().thinkingBlocksExpansion!==e&&ki({thinkingBlocksExpansion:e})}function DR(){ki({showThinkingBlocks:!Rn().showThinkingBlocks})}function LR(){ki({showUsageMetrics:!Rn().showUsageMetrics})}function MR(e){Mi(t=>{t.recentFolders=TE(e,t.recentFolders)})}function kR(e){Mi(t=>{t.recentFolders=t.recentFolders.filter(n=>n.path!==e)})}function PR(e,t){Mi(n=>{n.opencodeBinaries=Ju(e,t,n.opencodeBinaries)})}function FR(e){Mi(t=>{t.opencodeBinaries=t.opencodeBinaries.filter(n=>n.path!==e)})}function UR(e){const t=e||Rn().lastUsedBinary||"opencode";Mi(n=>{n.preferences=sc({...n.preferences,lastUsedBinary:t}),n.opencodeBinaries=Ju(t,void 0,n.opencodeBinaries)})}function BR(e,t){Mi(n=>{const i=t&&t.trim().length>0?t:n.preferences.lastUsedBinary||"opencode";n.recentFolders=TE(e,n.recentFolders),n.preferences=sc({...n.preferences,lastUsedBinary:i}),n.opencodeBinaries=Ju(i,void 0,n.opencodeBinaries)})}function e_(e){ki({environmentVariables:e})}function $R(e,t){const i={...Rn().environmentVariables||{},[e]:t};e_(i)}function GR(e){const t=Rn().environmentVariables||{},{[e]:n,...i}=t;e_(i)}function vE(e){if(!e.providerId||!e.modelId)return;const n=(Rn().modelRecents??[]).filter(r=>r.providerId!==e.providerId||r.modelId!==e.modelId),i=[e,...n].slice(0,ER);ki({modelRecents:i})}async function lc(e,t,n){!e||!t||!n.providerId||!n.modelId||(await Ur(e),await Qu(e,i=>{const r={...i.agentModelSelections??{}},a=r[t];a&&a.providerId===n.providerId&&a.modelId===n.modelId||(r[t]=n,i.agentModelSelections=r)}))}async function yE(e,t){return!e||!t?void 0:(await Ur(e),(Xu(e).agentModelSelections??{})[t])}Zu().catch(e=>{console.error("Failed to initialize config:",e)});const CE=un(),YR={isLoaded:EE,config:SR,preferences:Rn,recentFolders:TR,opencodeBinaries:vR,themePreference:hE,setThemePreference:OR,updateConfig:Mi,toggleShowThinkingBlocks:DR,toggleUsageMetrics:LR,setDiffViewMode:NR,setToolOutputExpansion:AR,setDiagnosticsExpansion:xR,setThinkingBlocksExpansion:wR,addRecentFolder:MR,removeRecentFolder:kR,addOpenCodeBinary:PR,removeOpenCodeBinary:FR,updateLastUsedBinary:UR,recordWorkspaceLaunch:BR,updatePreferences:ki,updateEnvironmentVariables:e_,addEnvironmentVariable:$R,removeEnvironmentVariable:GR,addRecentModelPreference:vE,setAgentModelPreference:lc,getAgentModelPreference:yE},VR=e=>(dn(()=>{Zu().catch(n=>{console.error("Failed to initialize config:",n)});const t=Ar.onConfigChanged(n=>{ju(n).catch(i=>{console.error("Failed to refresh config:",i)})});return()=>{t()}}),T(CE.Provider,{value:YR,get children(){return e.children}}));function _r(){const e=Cn(CE);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e}var HR=G('<p class="text-xs text-muted mt-1 font-mono break-all">Root: '),WR=G('<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'),zR=G('<div class="flex items-center gap-2 px-4 py-2 text-xs text-secondary"><span>Loading <!>…'),KR=G('<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'),qR=G('<div class="flex items-center gap-2"><span>Loading <!>…'),QR=G('<div class="flex items-center justify-center py-6 text-sm text-secondary">'),XR=G("<span class=text-red-500>"),jR=G('<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'),ZR=G('<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'),JR=G('<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 eI=200;function Yc(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 ts(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;const n=e.includes("\\")?"\\":"/",i=e.endsWith(n)?e:`${e}${n}`,r=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${i}${r}`}const tI=e=>{const[t,n]=Q(""),[i,r]=Q([]),[a,s]=Q(null),[o,l]=Q(null),[c,d]=Q(null),[u,_]=Q(""),[m,p]=Q(0);let g;const E=new Map,h=new Map,f=new Map;function S(){E.clear(),h.clear(),f.clear(),r([]),s(null),l(null)}async function v(D,O=!1){const y=Yc(D);if(E.has(y)&&h.has(y))return O&&(s(h.get(y)??null),r(E.get(y)??[])),h.get(y);if(f.has(y)){const P=await f.get(y);return O&&(s(P),r(E.get(y)??[])),P}const N=(async()=>{l(y);const P=await cn.listFileSystem(y==="."?".":y,{includeFiles:e.mode==="files"});return E.set(y,P.entries),h.set(y,P.metadata),t()||n(P.metadata.rootPath),o()===y&&l(null),P.metadata})().catch(P=>{throw o()===y&&l(null),P});f.set(y,N);try{const P=await N;if(O){const H=Yc(P.currentPath);s(P),r(E.get(H)??E.get(y)??[])}return P}finally{f.delete(y)}}async function b(){d(null),S();try{const D=await v(".",!0);n(D.rootPath),r(E.get(Yc(D.currentPath))??[])}catch(D){const O=D instanceof Error?D.message:"Unable to load filesystem";d(O)}}function C(){const D=o();return D?D==="."?t()||"workspace root":ts(t(),D):"filesystem"}function R(){const D=a();return D?D.pathKind==="relative"?ts(t(),D.currentPath):D.displayPath:t()}function A(D){D.target===D.currentTarget&&e.onClose()}function U(D){const O=ts(t(),D.path);e.onSelect(O)}function w(D){v(D,!0).catch(O=>{console.error("Failed to open directory",O),d(O instanceof Error?O.message:"Unable to open directory")})}function M(){var O;const D=(O=a())==null?void 0:O.parentPath;D&&w(D)}const Y=V(()=>{const D=u().trim().toLowerCase(),O=i().filter(y=>e.mode==="directories"?y.type==="directory":!0);return D?O.filter(y=>ts(t(),y.path).toLowerCase().includes(D)||y.name.toLowerCase().includes(D)):O}),$=V(()=>Y().slice(0,eI)),k=V(()=>{const D=[],O=a();O!=null&&O.parentPath&&D.push({type:"up",path:O.parentPath});for(const y of $())D.push({type:"entry",entry:y});return D});return fe(()=>{const D=$();if(D.length===0){p(0);return}m()>=D.length&&p(D.length-1)}),fe(()=>{if(!e.open)return;_(""),p(0),b(),setTimeout(()=>g==null?void 0:g.focus(),50);const D=O=>{if(!e.open)return;const y=$();if(O.key==="Escape"){O.preventDefault(),e.onClose();return}if(y.length!==0){if(O.key==="ArrowDown")O.preventDefault(),p(N=>Math.min(N+1,y.length-1));else if(O.key==="ArrowUp")O.preventDefault(),p(N=>Math.max(N-1,0));else if(O.key==="Enter"){O.preventDefault();const N=y[m()];N&&U(N)}}};window.addEventListener("keydown",D),xe(()=>{window.removeEventListener("keydown",D),S(),n(""),d(null)})}),T(ee,{get when(){return e.open},get children(){var D=KR(),O=D.firstChild,y=O.firstChild,N=y.firstChild,P=N.firstChild,H=P.firstChild,Z=H.nextSibling,ae=P.nextSibling,Se=ae.firstChild,ne=N.nextSibling,ie=ne.firstChild,Te=ie.nextSibling,Ee=Te.firstChild,le=Ee.nextSibling,Me=ne.nextSibling;return D.$$click=A,I(H,()=>e.title),I(Z,()=>e.description||"Search for a path under the configured workspace root."),I(P,T(ee,{get when(){return t()},get children(){var Re=HR();return Re.firstChild,I(Re,t,null),Re}}),null),cr(ae,"click",e.onClose,!0),I(ae,T(rc,{class:"w-4 h-4"}),Se),I(Ee,T(ZC,{class:"w-4 h-4"})),le.$$input=Re=>_(Re.currentTarget.value),Nt(Re=>{g=Re},le),I(y,T(ee,{get when(){return e.mode==="directories"},get children(){var Re=WR(),he=Re.firstChild,z=he.firstChild,K=z.firstChild,J=K.nextSibling,me=z.nextSibling;return I(J,R),me.$$click=()=>e.onSelect(R()),Re}}),Me),I(Me,T(ee,{get when(){return i().length>0},get fallback(){return(()=>{var Re=QR();return I(Re,T(ee,{get when(){return o()!==null},get fallback(){return(()=>{var he=XR();return I(he,c),he})()},get children(){var he=qR(),z=he.firstChild,K=z.firstChild,J=K.nextSibling;return J.nextSibling,I(he,T(Us,{class:"w-4 h-4 animate-spin"}),z),I(z,C,J),he}})),Re})()},get children(){return[T(ee,{get when(){return o()},get children(){var Re=zR(),he=Re.firstChild,z=he.firstChild,K=z.nextSibling;return K.nextSibling,I(Re,T(Us,{class:"w-3.5 h-3.5 animate-spin"}),he),I(he,C,K),Re}}),T(ee,{get when(){return k().length>0},get fallback(){return(()=>{var Re=jR(),he=Re.firstChild,z=he.nextSibling;return z.$$click=b,Re})()},get children(){return T(We,{get each(){return k()},children:Re=>{if(Re.type==="up")return(()=>{var J=ZR(),me=J.firstChild,te=me.firstChild,se=te.firstChild;return te.$$click=M,I(se,T(_E,{class:"w-4 h-4"})),J})();const he=Re.entry,z=()=>U(he),K=()=>{he.type==="directory"?w(he.path):z()};return(()=>{var J=JR(),me=J.firstChild,te=me.firstChild,se=te.firstChild,oe=se.nextSibling,Ie=oe.firstChild,be=Ie.nextSibling,ge=te.nextSibling;return te.$$click=K,I(se,T(ee,{get when(){return he.type==="directory"},get fallback(){return T(FC,{class:"w-4 h-4"})},get children(){return T(Wu,{class:"w-4 h-4"})}})),I(Ie,()=>he.name||he.path),I(be,()=>ts(t(),he.path)),ge.$$click=De=>{De.stopPropagation(),z()},J})()}})}})]}})),ue(()=>Fe(le,"placeholder",e.mode==="directories"?"Search for folders":"Search for files")),ue(()=>le.value=u()),D}})};At(["click","input"]);function nI(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 iI(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 nI(n)}catch(n){return console.error("[native] electron dialog failed",n),null}}async function rI(e){var i;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 r=await n.open({title:e.title,defaultPath:e.defaultPath,directory:e.mode==="directory",multiple:!1,filters:(i=e.filters)==null?void 0:i.map(a=>({name:a.name,extensions:a.extensions}))});return r?Array.isArray(r)?r[0]??null:r:null}catch(r){return console.error("[native] tauri dialog failed",r),null}}function RE(){switch(Id.host){case"electron":return iI;case"tauri":return rI;default:return null}}function IE(){return RE()!==null}async function OE(e){const t=RE();return t?t(e):null}async function aI(e){return OE({mode:"directory",...e??{}})}async function sI(e){return OE({mode:"file",...e??{}})}var oI=G('<div class="selector-loading text-xs"><span>Checking versions…'),lI=G("<div class=selector-validation-error><div class=selector-validation-error-content><span class=selector-validation-error-text>"),cI=G('<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">'),dI=G('<div class="text-xs font-mono truncate pl-6 text-muted">'),uI=G("<span class=selector-badge-version>v"),_I=G("<span class=selector-badge-time>Checking…"),mI=G("<span class=selector-badge-time>"),pI=G("<span class=selector-badge-time>Use binary from system PATH"),gI=G('<button type=button class="p-2 text-muted hover:text-primary"title="Remove binary">'),fI=G('<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 EI=e=>{const{opencodeBinaries:t,addOpenCodeBinary:n,removeOpenCodeBinary:i,preferences:r,updatePreferences:a}=_r(),[s,o]=Q(""),[l,c]=Q(!1),[d,u]=Q(null),[_,m]=Q(new Map),[p,g]=Q(new Set),[E,h]=Q(!1),f=IE(),S=()=>t(),v=()=>r().lastUsedBinary,b=V(()=>S().filter(N=>N.path!=="opencode")),C=V(()=>[{path:"opencode",isDefault:!0},...b()]),R=()=>e.selectedBinary||"opencode";fe(()=>{if(!e.selectedBinary&&v())e.onBinaryChange(v());else if(!e.selectedBinary){const N=S()[0];N&&e.onBinaryChange(N.path)}}),fe(()=>{const N=new Map(_());let P=!1;S().forEach(H=>{H.version&&!N.has(H.path)&&(N.set(H.path,H.version),P=!0)}),P&&m(N)}),fe(()=>{if(!e.isVisible)return;const N=_(),P=["opencode",...b().map(H=>H.path)].filter(H=>!N.has(H));P.length!==0&&setTimeout(()=>{P.forEach(H=>{A(H).catch(console.error)})},0)}),xe(()=>{g(new Set),c(!1)});async function A(N){if(_().has(N)){const P=_().get(N);return P?{valid:!0,version:P}:{valid:!0}}if(p().has(N))return{valid:!1,error:"Already validating"};try{g(H=>new Set(H).add(N)),c(!0),u(null);const P=await cn.validateBinary(N);if(P.valid&&P.version){const H=new Map(_());H.set(N,P.version),m(H)}return P}catch(P){return{valid:!1,error:P instanceof Error?P.message:String(P)}}finally{g(P=>{const H=new Set(P);return H.delete(N),H.size===0&&c(!1),H})}}async function U(){if(!e.disabled){if(u(null),f){const N=await sI({title:"Select OpenCode Binary"});N&&(o(N),w(N));return}h(!0)}}async function w(N){const P=await A(N);P.valid?(n(N,P.version),e.onBinaryChange(N),a({lastUsedBinary:N}),o(""),u(null)):u(P.error||"Invalid OpenCode binary")}function M(N){h(!1),o(N),w(N)}async function Y(){const N=s().trim();N&&await w(N)}function $(N){e.disabled||N!==e.selectedBinary&&(e.onBinaryChange(N),a({lastUsedBinary:N}))}function k(N,P){P.stopPropagation(),!e.disabled&&(i(N),e.selectedBinary===N&&(e.onBinaryChange("opencode"),a({lastUsedBinary:"opencode"})))}function D(N){if(!N)return"";const P=Math.floor((Date.now()-N)/1e3),H=Math.floor(P/60),Z=Math.floor(H/60),ae=Math.floor(Z/24);return ae>0?`${ae}d ago`:Z>0?`${Z}h ago`:H>0?`${H}m ago`:"just now"}function O(N){if(N==="opencode")return"opencode (system PATH)";const P=N.split(/[/\\]/);return P[P.length-1]??N}const y=N=>p().has(N);return[(()=>{var N=cI(),P=N.firstChild;P.firstChild;var H=P.nextSibling,Z=H.firstChild,ae=Z.firstChild,Se=ae.nextSibling,ne=Se.firstChild,ie=Z.nextSibling,Te=ie.firstChild,Ee=H.nextSibling;return I(P,T(ee,{get when(){return l()},get children(){var le=oI(),Me=le.firstChild;return I(le,T(Us,{class:"selector-loading-spinner"}),Me),le}}),null),ae.$$keydown=le=>{le.key==="Enter"&&(le.preventDefault(),Y())},ae.$$input=le=>o(le.currentTarget.value),Se.$$click=Y,I(Se,T(zu,{class:"w-4 h-4"}),ne),ie.$$click=()=>void U(),I(ie,T(mE,{class:"w-4 h-4"}),Te),I(H,T(ee,{get when(){return d()},get children(){var le=lI(),Me=le.firstChild,Re=Me.firstChild;return I(Me,T(RC,{class:"selector-validation-error-icon"}),Re),I(Re,d),le}}),null),I(Ee,T(We,{get each(){return C()},children:le=>{const Me=le.isDefault,Re=()=>_().get(le.path)??le.version;return(()=>{var he=fI(),z=he.firstChild,K=z.firstChild,J=K.firstChild,me=J.firstChild,te=J.nextSibling;return z.$$click=()=>$(le.path),I(J,T(NC,{get class(){return`w-4 h-4 transition-opacity ${R()===le.path?"opacity-100":"opacity-0"}`}}),me),I(me,()=>O(le.path)),I(K,T(ee,{when:!Me,get children(){var se=dI();return I(se,()=>le.path),se}}),te),I(te,T(ee,{get when(){return Re()},get children(){var se=uI();return se.firstChild,I(se,Re,null),se}}),null),I(te,T(ee,{get when(){return y(le.path)},get children(){return _I()}}),null),I(te,T(ee,{get when(){return!Me&&le.lastUsed},get children(){var se=mI();return I(se,()=>D(le.lastUsed)),se}}),null),I(te,T(ee,{when:Me,get children(){return pI()}}),null),I(he,T(ee,{when:!Me,get children(){var se=gI();return se.$$click=oe=>k(le.path,oe),I(se,T(Ku,{class:"w-3.5 h-3.5"})),ue(()=>se.disabled=e.disabled),se}}),null),ue(se=>{var oe=R()===le.path,Ie=e.disabled;return oe!==se.e&&he.classList.toggle("panel-list-item-highlight",se.e=oe),Ie!==se.t&&(z.disabled=se.t=Ie),se},{e:void 0,t:void 0}),he})()}})),ue(le=>{var Me=e.disabled,Re=e.disabled||!s().trim(),he=e.disabled;return Me!==le.e&&(ae.disabled=le.e=Me),Re!==le.t&&(Se.disabled=le.t=Re),he!==le.a&&(ie.disabled=le.a=he),le},{e:void 0,t:void 0,a:void 0}),ue(()=>ae.value=s()),N})(),T(tI,{get open(){return E()},mode:"files",title:"Select OpenCode Binary",description:"Browse files exposed by the CLI server.",onClose:()=>h(!1),onSelect:M})]};At(["input","keydown","click"]);var hI=G("<div class=space-y-2>"),SI=G('<div class="text-xs text-muted text-center py-2">No environment variables configured. Add variables above to customize the OpenCode environment.'),bI=G('<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.'),TI=G('<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 vI=e=>{const{preferences:t,addEnvironmentVariable:n,removeEnvironmentVariable:i,updateEnvironmentVariables:r}=_r(),[a,s]=Q(t().environmentVariables||{}),[o,l]=Q(""),[c,d]=Q(""),u=()=>Object.entries(a());function _(){const E=o().trim(),h=c().trim();E&&(n(E,h),s({...a(),[E]:h}),l(""),d(""))}function m(E){i(E);const{[E]:h,...f}=a();s(f)}function p(E,h){const f={...a(),[E]:h};s(f),r(f)}function g(E){E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),_())}return(()=>{var E=bI(),h=E.firstChild,f=h.firstChild,S=f.nextSibling,v=S.firstChild,b=v.nextSibling,C=b.nextSibling,R=C.nextSibling;R.nextSibling;var A=h.nextSibling,U=A.firstChild,w=U.firstChild,M=w.nextSibling,Y=U.nextSibling,$=A.nextSibling;return I(h,T(VC,{class:"w-4 h-4 icon-muted"}),f),I(S,()=>u().length,b),I(S,()=>u().length!==1?"s":"",R),I(E,T(ee,{get when(){return u().length>0},get children(){var k=hI();return I(k,T(We,{get each(){return u()},children:([D,O])=>(()=>{var y=TI(),N=y.firstChild,P=N.firstChild,H=P.nextSibling,Z=N.nextSibling;return I(N,T(Zm,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),P),P.value=D,H.$$input=ae=>p(D,ae.currentTarget.value),H.value=O,Z.$$click=()=>m(D),I(Z,T(Ku,{class:"w-3.5 h-3.5"})),ue(ae=>{var Se=e.disabled,ne=e.disabled,ie=e.disabled;return Se!==ae.e&&(P.disabled=ae.e=Se),ne!==ae.t&&(H.disabled=ae.t=ne),ie!==ae.a&&(Z.disabled=ae.a=ie),ae},{e:void 0,t:void 0,a:void 0}),y})()})),k}}),A),I(U,T(Zm,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),w),w.addEventListener("keypress",g),w.$$input=k=>l(k.currentTarget.value),M.addEventListener("keypress",g),M.$$input=k=>d(k.currentTarget.value),Y.$$click=_,I(Y,T(zu,{class:"w-3.5 h-3.5"})),I(E,T(ee,{get when(){return u().length===0},get children(){return SI()}}),$),ue(k=>{var D=e.disabled,O=e.disabled,y=e.disabled||!o().trim();return D!==k.e&&(w.disabled=k.e=D),O!==k.t&&(M.disabled=k.t=O),y!==k.a&&(Y.disabled=k.a=y),k},{e:void 0,t:void 0,a:void 0}),ue(()=>w.value=o()),ue(()=>M.value=c()),E})()};At(["input","click"]);var yI=G('<header class="px-6 py-4 border-b"style=border-color:var(--border-base)>'),CI=G('<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>'),RI=G('<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'),II=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">');const OI=e=>T(Ze,{get open(){return e.open},onOpenChange:t=>!t&&e.onClose(),get children(){return T(Ze.Portal,{get children(){return[T(Ze.Overlay,{class:"modal-overlay"}),(()=>{var t=II();return I(t,T(Ze.Content,{class:"modal-surface w-full max-w-5xl max-h-[90vh] flex flex-col overflow-hidden",get children(){return[(()=>{var n=yI();return I(n,T(Ze.Title,{class:"text-xl font-semibold text-primary",children:"Advanced Settings"})),n})(),(()=>{var n=CI(),i=n.firstChild,r=i.firstChild,a=r.nextSibling;return I(n,T(EI,{get selectedBinary(){return e.selectedBinary},get onBinaryChange(){return e.onBinaryChange},get disabled(){return!!e.isLoading},get isVisible(){return e.open}}),i),I(a,T(vI,{get disabled(){return!!e.isLoading}})),n})(),(()=>{var n=RI(),i=n.firstChild;return cr(i,"click",e.onClose,!0),n})()]}})),t})()]}})}});At(["click"]);const op="__drives__";var NI=G('<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'),AI=G('<div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto directory-browser-list"role=listbox>'),xI=G('<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">'),wI=G("<div class=directory-browser-loading><span>Loading folders…"),DI=G('<div class="panel-empty-state flex-1">'),LI=G("<span class=text-red-500>"),MI=G('<div class="panel-empty-state flex-1">No folders available.'),kI=G('<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>'),PI=G('<button type=button class="selector-button selector-button-secondary directory-browser-select">Select');function Ao(e){if(!e||e==="."||e==="./")return".";if(e===op)return op;let t=e.replace(/\\/g,"/");if(/^[a-zA-Z]:/.test(t)){const[n,i=""]=t.split(":"),r=i.startsWith("/")?i:i?`/${i}`:"/";return`${n.toUpperCase()}:${r.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 NE(e){return e.startsWith("/")||/^[a-zA-Z]:/.test(e)||e.startsWith("\\\\")}function lp(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;if(NE(t))return t;const n=e.includes("\\")?"\\":"/",i=e.endsWith(n)?e:`${e}${n}`,r=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${i}${r}`}const FI=e=>{const[t,n]=Q(""),[i,r]=Q(!1),[a,s]=Q(null),[o,l]=Q(new Map),[c,d]=Q(new Set),[u,_]=Q(null),[m,p]=Q(null),g=new Map,E=new Map;function h(){l(new Map),d(new Set),_(null),p(null),g.clear(),E.clear(),s(null)}fe(()=>{if(!e.open)return;h(),f();const k=D=>{D.key==="Escape"&&(D.preventDefault(),e.onClose())};window.addEventListener("keydown",k),xe(()=>{window.removeEventListener("keydown",k)})});async function f(){r(!0);try{const k=await v();S(k)}catch(k){const D=k instanceof Error?k.message:"Unable to load filesystem";s(D)}finally{r(!1)}}function S(k){const D=Ao(k.currentPath);_(D),p(k),n(k.rootPath)}async function v(k){const D=k?Ao(k):void 0;if(D){const y=g.get(D);if(y)return y;const N=E.get(D);if(N)return N}const O=(async()=>{D&&d(H=>{const Z=new Set(H);return Z.add(D),Z});const y=await cn.listFileSystem(k,{includeFiles:!1}),N=Ao(y.metadata.currentPath),P=y.entries.filter(H=>H.type==="directory").sort((H,Z)=>H.name.localeCompare(Z.name));return l(H=>{const Z=new Map(H);return Z.set(N,P),Z}),g.set(N,y.metadata),d(H=>{const Z=new Set(H);return D&&Z.delete(D),Z.delete(N),Z}),y.metadata})().catch(y=>{throw D&&d(N=>{const P=new Set(N);return P.delete(D),P}),y}).finally(()=>{D&&E.delete(D)});return D&&E.set(D,O),O}async function b(k){s(null);try{const D=await v(k);S(D)}catch(D){const O=D instanceof Error?D.message:"Unable to load filesystem";s(O)}}const C=V(()=>{const k=[],D=m();D!=null&&D.parentPath&&k.push({type:"up",path:D.parentPath});const O=u();if(!O)return k;const y=o().get(O)??[];for(const N of y)k.push({type:"folder",entry:N});return k});function R(k){b(k)}function A(){var D;const k=(D=m())==null?void 0:D.parentPath;k&&b(k)}const U=V(()=>{const k=m();return!k||k.pathKind==="drives"?"":k.pathKind==="relative"?lp(k.rootPath,k.currentPath):k.displayPath}),w=V(()=>!!U());function M(k){const D=k.absolutePath?k.absolutePath:NE(k.path)?k.path:lp(t(),k.path);e.onSelect(D)}function Y(k){return c().has(Ao(k))}function $(k){k.target===k.currentTarget&&e.onClose()}return T(ee,{get when(){return e.open},get children(){var k=xI(),D=k.firstChild,O=D.firstChild,y=O.firstChild,N=y.firstChild,P=N.firstChild,H=P.nextSibling,Z=N.nextSibling,ae=y.nextSibling;return k.$$click=$,I(P,()=>e.title),I(H,()=>e.description||"Browse folders under the configured workspace root."),cr(Z,"click",e.onClose,!0),I(Z,T(rc,{class:"w-5 h-5"})),I(ae,T(ee,{get when(){return t()},get children(){var Se=NI(),ne=Se.firstChild,ie=ne.firstChild,Te=ie.nextSibling,Ee=ne.nextSibling;return I(Te,U),Ee.$$click=()=>{const le=U();le&&e.onSelect(le)},ue(()=>Ee.disabled=!w()),Se}}),null),I(ae,T(ee,{get when(){return ke(()=>!i())()&&!a()},get fallback(){return(()=>{var Se=DI();return I(Se,T(ee,{get when(){return i()},get fallback(){return(()=>{var ne=LI();return I(ne,a),ne})()},get children(){var ne=wI(),ie=ne.firstChild;return I(ne,T(Us,{class:"w-5 h-5 animate-spin"}),ie),ne}})),Se})()},get children(){return T(ee,{get when(){return C().length>0},get fallback(){return MI()},get children(){var Se=AI();return I(Se,T(We,{get each(){return C()},children:ne=>{const ie=ne.type==="folder",Te=ie?ne.entry.name||ne.entry.path:"Up one level",Ee=()=>ie?R(ne.entry.path):A();return(()=>{var le=kI(),Me=le.firstChild,Re=Me.firstChild,he=Re.firstChild,z=he.nextSibling,K=z.firstChild;return Re.$$click=Ee,I(he,T(ee,{when:!ie,get fallback(){return T(Wu,{class:"w-4 h-4"})},get children(){return T(_E,{class:"w-4 h-4"})}})),I(K,Te),I(Re,T(ee,{get when(){return ie&&Y(ne.entry.path)},get children(){return T(Us,{class:"directory-browser-row-spinner animate-spin"})}}),null),I(Me,ie?(()=>{var J=PI();return J.$$click=me=>{me.stopPropagation(),M(ne.entry)},J})():null,null),le})()}})),Se}})}}),null),k}})};At(["click"]);const yi=()=>navigator.platform.toLowerCase().includes("mac"),UI=e=>{const t=[];return(e.modifiers.ctrl||e.modifiers.meta)&&t.push(yi()?"Cmd":"Ctrl"),e.modifiers.shift&&t.push("Shift"),e.modifiers.alt&&t.push(yi()?"Option":"Alt"),t.push(e.key.toUpperCase()),t.join("+")};var BI=G("<kbd>"),$I=G("<span>"),GI=G("<span class=kbd-separator>+");const YI={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:"→"},qt=e=>{const t=()=>{if(e.children)return[{text:e.children,isModifier:!1}];if(!e.shortcut)return[];const n=[];return e.shortcut.toLowerCase().split("+").forEach(a=>{const s=a.trim(),o=s.toLowerCase();if(o==="cmd"||o==="command")n.push({text:yi()?"Cmd":"Ctrl",isModifier:!1});else if(o==="shift")n.push({text:"Shift",isModifier:!1});else if(o==="alt"||o==="option")n.push({text:yi()?"Option":"Alt",isModifier:!1});else if(o==="ctrl"||o==="control")n.push({text:"Ctrl",isModifier:!1});else{const l=YI[o];l?n.push({text:l,isModifier:!1}):s.length===1?n.push({text:s.toUpperCase(),isModifier:!1}):n.push({text:s.charAt(0).toUpperCase()+s.slice(1),isModifier:!1})}}),n};return(()=>{var n=BI();return I(n,T(We,{get each(){return t()},children:(i,r)=>[ke(()=>ke(()=>r()>0)()&&GI()),(()=>{var a=$I();return I(a,()=>i.text),a})()]})),ue(()=>He(n,`kbd ${e.class||""}`)),n})()};var VI=G('<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">'),HI=G('<div class="flex items-center gap-1.5"><kbd class=kbd>↑</kbd><kbd class=kbd>↓</kbd><span>Navigate'),WI=G('<div class="flex items-center gap-1.5"><kbd class=kbd>Enter</kbd><span>Select'),zI=G('<div class="flex items-center gap-1.5"><kbd class=kbd>Del</kbd><span>Remove'),KI=G("<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."),qI=G('<div class="flex h-screen w-full items-start justify-center overflow-hidden py-6 relative"style=background-color:var(--surface-secondary)><div class="w-full max-w-3xl h-full 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),QI=G('<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'),XI=G("<kbd class=kbd>↵"),jI=G('<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 ZI=new URL("/assets/CodeNomad-Icon-bmTWNPXy.png",import.meta.url).href,cp=e=>{const{recentFolders:t,removeRecentFolder:n,preferences:i}=_r(),[r,a]=Q(0),[s,o]=Q("recent"),[l,c]=Q(i().lastUsedBinary||"opencode"),[d,u]=Q(!1),_=IE();let m;const p=()=>t(),g=()=>!!e.isLoading;fe(()=>{const w=i().lastUsedBinary;w&&c(M=>M===w?M:w)});function E(w){const M=m;if(!M)return;const Y=M.querySelector(`[data-folder-index="${w}"]`);if(!Y)return;const $=M.getBoundingClientRect(),k=Y.getBoundingClientRect();k.top<$.top?M.scrollTop-=$.top-k.top:k.bottom>$.bottom&&(M.scrollTop+=k.bottom-$.bottom)}function h(w){const M=w.key.toLowerCase(),Y=(w.metaKey||w.ctrlKey)&&!w.shiftKey&&M==="n",$=["ArrowDown","ArrowUp","PageDown","PageUp","Home","End","Enter","Backspace","Delete"];if(g()){(Y||$.includes(w.key))&&w.preventDefault();return}const k=p();if(Y){w.preventDefault(),b();return}if(k.length!==0){if(w.key==="ArrowDown"){w.preventDefault();const D=Math.min(r()+1,k.length-1);a(D),o("recent"),E(D)}else if(w.key==="ArrowUp"){w.preventDefault();const D=Math.max(r()-1,0);a(D),o("recent"),E(D)}else if(w.key==="PageDown"){w.preventDefault();const O=Math.min(r()+5,k.length-1);a(O),o("recent"),E(O)}else if(w.key==="PageUp"){w.preventDefault();const O=Math.max(r()-5,0);a(O),o("recent"),E(O)}else if(w.key==="Home")w.preventDefault(),a(0),o("recent"),E(0);else if(w.key==="End"){w.preventDefault();const D=k.length-1;a(D),o("recent"),E(D)}else if(w.key==="Enter")w.preventDefault(),f();else if((w.key==="Backspace"||w.key==="Delete")&&(w.preventDefault(),k.length>0&&s()==="recent")){const D=k[r()];D&&A(D.path)}}}function f(){if(g())return;const w=p(),M=r(),Y=w[M];Y&&v(Y.path)}dn(()=>{window.addEventListener("keydown",h),xe(()=>{window.removeEventListener("keydown",h)})});function S(w){const M=Math.floor((Date.now()-w)/1e3),Y=Math.floor(M/60),$=Math.floor(Y/60),k=Math.floor($/24);return k>0?`${k}d ago`:$>0?`${$}h ago`:Y>0?`${Y}m ago`:"just now"}function v(w){g()||e.onSelectFolder(w,l())}async function b(){var w;if(!g()){if(o("new"),_){const M=(w=p()[0])==null?void 0:w.path,Y=await aI({title:"Select Workspace",defaultPath:M});Y&&v(Y);return}u(!0)}}function C(w){u(!1),v(w)}function R(w){c(w)}function A(w,M){if(g())return;M==null||M.stopPropagation(),n(w);const Y=p();r()>=Y.length&&Y.length>0&&a(Y.length-1)}function U(w){return w.startsWith("/Users/")?w.replace(/^\/Users\/[^/]+/,"~"):w}return[(()=>{var w=qI(),M=w.firstChild,Y=M.firstChild,$=Y.firstChild,k=$.firstChild,D=Y.nextSibling,O=D.firstChild,y=O.firstChild,N=y.nextSibling,P=N.firstChild,H=P.firstChild,Z=H.firstChild,ae=N.nextSibling,Se=ae.firstChild,ne=Se.firstChild,ie=ne.firstChild,Te=D.nextSibling,Ee=Te.firstChild,le=Ee.firstChild,Me=le.firstChild;return Fe(k,"src",ZI),I(D,T(ee,{get when(){return p().length>0},get fallback(){return(()=>{var Re=QI(),he=Re.firstChild;return I(he,T(LC,{class:"w-12 h-12 mx-auto"})),Re})()},get children(){var Re=VI(),he=Re.firstChild,z=he.firstChild,K=z.nextSibling,J=K.firstChild,me=J.nextSibling;me.nextSibling;var te=he.nextSibling;return I(K,()=>p().length,J),I(K,()=>p().length===1?"folder":"folders",me),Nt(se=>m=se,te),I(te,T(We,{get each(){return p()},children:(se,oe)=>(()=>{var Ie=jI(),be=Ie.firstChild,ge=be.firstChild,De=ge.firstChild,Pe=De.firstChild,q=Pe.firstChild,F=q.firstChild,x=q.nextSibling,W=x.nextSibling,j=ge.nextSibling;return ge.addEventListener("mouseenter",()=>{g()||(o("recent"),a(oe()))}),ge.$$click=()=>v(se.path),I(q,T(Wu,{class:"w-4 h-4 flex-shrink-0 icon-muted"}),F),I(F,()=>se.path.split("/").pop()),I(x,()=>U(se.path)),I(W,()=>S(se.lastAccessed)),I(De,T(ee,{get when(){return ke(()=>s()==="recent")()&&r()===oe()},get children(){return XI()}}),null),j.$$click=re=>A(se.path,re),I(j,T(Ku,{class:"w-3.5 h-3.5 transition-colors icon-muted hover:text-red-600 dark:hover:text-red-400"})),ue(re=>{var de=s()==="recent"&&r()===oe(),Ae=!!g(),Ue=oe(),Ye=g(),Ve=g();return de!==re.e&&Ie.classList.toggle("panel-list-item-highlight",re.e=de),Ae!==re.t&&Ie.classList.toggle("panel-list-item-disabled",re.t=Ae),Ue!==re.a&&Fe(ge,"data-folder-index",re.a=Ue),Ye!==re.o&&(ge.disabled=re.o=Ye),Ve!==re.i&&(j.disabled=re.i=Ve),re},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),Ie})()})),Re}}),O),P.addEventListener("mouseenter",()=>o("new")),P.$$click=()=>void b(),I(H,T($C,{class:"w-4 h-4"}),Z),I(Z,()=>e.isLoading?"Opening...":"Browse Folders"),I(P,T(qt,{shortcut:"cmd+n",class:"ml-2"}),null),Se.$$click=()=>{var Re;return(Re=e.onAdvancedSettingsOpen)==null?void 0:Re.call(e)},I(ne,T(eR,{class:"w-4 h-4 icon-muted"}),ie),I(Se,T(wC,{class:"w-4 h-4 icon-muted"}),null),I(Ee,T(ee,{get when(){return p().length>0},get children(){return[HI(),WI(),zI()]}}),le),I(le,T(qt,{shortcut:"cmd+n"}),Me),I(w,T(ee,{get when(){return g()},get children(){return KI()}}),null),ue(Re=>{var he=g()?"true":"false",z=e.isLoading;return he!==Re.e&&Fe(M,"aria-busy",Re.e=he),z!==Re.t&&(P.disabled=Re.t=z),Re},{e:void 0,t:void 0}),w})(),T(OI,{get open(){return!!e.advancedSettingsOpen},onClose:()=>{var w;return(w=e.onAdvancedSettingsClose)==null?void 0:w.call(e)},get selectedBinary(){return l()},onBinaryChange:R,get isLoading(){return e.isLoading}}),T(FI,{get open(){return d()},title:"Select Workspace",description:"Select workspace to start coding.",onClose:()=>u(!1),onSelect:C})]};At(["click"]);var JI=G('<div class=group><button role=tab><span class=tab-label></span><span class="tab-close ml-auto"role=button tabindex=0 aria-label="Close instance">');const eO=e=>(()=>{var t=JI(),n=t.firstChild,i=n.firstChild,r=i.nextSibling;return cr(n,"click",e.onSelect,!0),I(n,T(mE,{class:"w-4 h-4 flex-shrink-0"}),i),I(i,()=>e.instance.folder.split("/").pop()||e.instance.folder),r.$$click=a=>{a.stopPropagation(),e.onClose()},I(r,T(rc,{class:"w-3 h-3"})),ue(a=>{var s=`tab-base ${e.active?"tab-active":"tab-inactive"}`,o=e.instance.folder,l=e.active;return s!==a.e&&He(n,a.e=s),o!==a.t&&Fe(n,"title",a.t=o),l!==a.a&&Fe(n,"aria-selected",a.a=l),a},{e:void 0,t:void 0,a:void 0}),t})();At(["click"]);var tO=G("<span>");const nO=e=>(()=>{var t=tO();return I(t,()=>e.children),ue(()=>He(t,`text-xs text-muted ${e.class||""}`)),t})();var iO=G("<span class=mx-1>"),rO=G("<span class=mr-1>");const cc=e=>{function t(n){const i=[];return(n.modifiers.ctrl||n.modifiers.meta)&&i.push("cmd"),n.modifiers.shift&&i.push("shift"),n.modifiers.alt&&i.push("alt"),i.push(n.key),i.join("+")}return T(nO,{get children(){return T(We,{get each(){return e.shortcuts},children:(n,i)=>[ke(()=>ke(()=>i()>0)()&&(()=>{var r=iO();return I(r,()=>e.separator||"•"),r})()),ke(()=>ke(()=>e.showDescription!==!1)()&&(()=>{var r=rO();return I(r,()=>n.description),r})()),T(qt,{get shortcut(){return t(n)}})]})}})};class aO{constructor(){this.shortcuts=new Map}register(t){this.shortcuts.set(t.id,t)}unregister(t){this.shortcuts.delete(t)}get(t){return this.shortcuts.get(t)}findMatch(t){for(const n of this.shortcuts.values())if(this.matches(t,n)){if(n.context==="input"&&!this.isInputFocused()||n.context==="messages"&&this.isInputFocused()||n.condition&&!n.condition())continue;return n}return null}matches(t,n){const i=n.key.toLowerCase(),r=t.key?t.key.toLowerCase():"",a=t.code?t.code.toLowerCase():"",s=r===i||a===i,o=t.ctrlKey===(n.modifiers.ctrl??!1),l=t.metaKey===(n.modifiers.meta??!1),c=t.shiftKey===(n.modifiers.shift??!1),d=t.altKey===(n.modifiers.alt??!1);return s&&o&&l&&c&&d}isInputFocused(){const t=document.activeElement;return(t==null?void 0:t.tagName)==="TEXTAREA"||(t==null?void 0:t.tagName)==="INPUT"||((t==null?void 0:t.hasAttribute("contenteditable"))??!1)}getByContext(t){return Array.from(this.shortcuts.values()).filter(n=>!n.context||n.context===t)}}const Ot=new aO;var sO=G('<div class="flex-shrink-0 ml-4">'),oO=G('<div class="tab-bar tab-bar-instance"><div class=tab-container role=tablist><div class="flex items-center gap-1 overflow-x-auto"><button class=new-tab-button title="New instance (Cmd/Ctrl+N)"aria-label="New instance">');const lO=e=>(()=>{var t=oO(),n=t.firstChild,i=n.firstChild,r=i.firstChild;return I(i,T(We,{get each(){return Array.from(e.instances.entries())},children:([a,s])=>T(eO,{instance:s,get active(){return a===e.activeInstanceId},onSelect:()=>e.onSelect(a),onClose:()=>e.onClose(a)})}),r),cr(r,"click",e.onNew,!0),I(r,T(zu,{class:"w-4 h-4"})),I(n,T(ee,{get when(){return Array.from(e.instances.entries()).length>1},get children(){var a=sO();return I(a,T(cc,{get shortcuts(){return[Ot.get("instance-prev"),Ot.get("instance-next")].filter(Boolean)}})),a}}),null),t})();At(["click"]);var cO=G("<div>"),dO=G('<div class="rounded-lg border border-base bg-surface-secondary p-4 text-sm text-secondary"><p class="font-medium text-primary">Details</p><p class="mt-2 text-secondary">'),uO=G('<div class="flex justify-end"><button type=button class="selector-button selector-button-primary">Close Instance'),_O=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),mO=G('<p class="mt-2 text-secondary">Folder: <span class="font-mono text-primary break-all">');function pO(e){const t=e.folder||"this workspace",n=e.reason||"The server stopped responding";return T(Ze,{get open(){return e.open},modal:!0,get children(){return T(Ze.Portal,{get children(){return[T(Ze.Overlay,{class:"modal-overlay"}),(()=>{var i=_O();return I(i,T(Ze.Content,{class:"modal-surface w-full max-w-md p-6 flex flex-col gap-6",get children(){return[(()=>{var r=cO();return I(r,T(Ze.Title,{class:"text-xl font-semibold text-primary",children:"Instance Disconnected"}),null),I(r,T(Ze.Description,{class:"text-sm text-secondary mt-2 break-words",get children(){return[t," can no longer be reached. Close the tab to continue working."]}}),null),r})(),(()=>{var r=dO(),a=r.firstChild,s=a.nextSibling;return I(s,n),I(r,(()=>{var o=ke(()=>!!e.folder);return()=>o()&&(()=>{var l=mO(),c=l.firstChild,d=c.nextSibling;return I(d,()=>e.folder),l})()})(),null),r})(),(()=>{var r=uO(),a=r.firstChild;return cr(a,"click",e.onClose,!0),r})()]}})),i})()]}})}})}At(["click"]);const[dp,gO]=Q(new Map);class fO{constructor(){Bs.on("instance.eventStatus",t=>{var i;const n=t;if(this.updateConnectionStatus(n.instanceId,n.status),n.status==="disconnected"){if(n.reason==="workspace stopped")return;const r=n.reason??"Instance disconnected";(i=this.onConnectionLost)==null||i.call(this,n.instanceId,r)}}),Bs.on("instance.event",t=>{const n=t;this.updateConnectionStatus(n.instanceId,"connected"),this.handleEvent(n.instanceId,n.event)})}seedStatus(t,n){this.updateConnectionStatus(t,n)}handleEvent(t,n){var i,r,a,s,o,l,c,d,u,_,m,p;if(!n||typeof n!="object"||typeof n.type!="string"){console.warn("[SSE] Dropping malformed event",n);return}switch(console.log("[SSE] Received event:",n.type,n),n.type){case"message.updated":(i=this.onMessageUpdate)==null||i.call(this,t,n);break;case"message.part.updated":(r=this.onMessagePartUpdated)==null||r.call(this,t,n);break;case"message.removed":(a=this.onMessageRemoved)==null||a.call(this,t,n);break;case"message.part.removed":(s=this.onMessagePartRemoved)==null||s.call(this,t,n);break;case"session.updated":(o=this.onSessionUpdate)==null||o.call(this,t,n);break;case"session.compacted":(l=this.onSessionCompacted)==null||l.call(this,t,n);break;case"session.error":(c=this.onSessionError)==null||c.call(this,t,n);break;case"tui.toast.show":(d=this.onTuiToast)==null||d.call(this,t,n);break;case"session.idle":(u=this.onSessionIdle)==null||u.call(this,t,n);break;case"permission.updated":(_=this.onPermissionUpdated)==null||_.call(this,t,n);break;case"permission.replied":(m=this.onPermissionReplied)==null||m.call(this,t,n);break;case"lsp.updated":(p=this.onLspUpdated)==null||p.call(this,t,n);break;default:console.warn("[SSE] Unknown event type:",n.type)}}updateConnectionStatus(t,n){gO(i=>{const r=new Map(i);return r.set(t,n),r})}getStatus(t){return dp().get(t)??null}getStatuses(){return dp()}}const Xt=new fO,[kt,xr]=Q(new Map),[nr,AE]=Q(new Map),[$s,xE]=Q(new Map),[dc,EO]=Q(new Map),[$a,hO]=Q(new Map),[SO,uc]=Q(new Map),[wE,Ia]=Q({fetchingSessions:new Map,creatingSession:new Map,deletingSession:new Map,loadingMessages:new Map}),[bO,Dd]=Q(new Map),[DE,t_]=Q(new Map);function n_(e,t){return`${e}:${t}`}function TO(e,t){if(!e||!t)return"";const n=n_(e,t);return SO().get(n)??""}function Vc(e,t,n){const i=n_(e,t);uc(r=>{const a=new Map(r);return n?a.set(i,n):a.delete(i),a})}function vO(e,t){const n=n_(e,t);uc(i=>{if(!i.has(n))return i;const r=new Map(i);return r.delete(n),r})}function yO(e){e&&uc(t=>{let n=!1;const i=new Map(t),r=`${e}:`;for(const a of Array.from(i.keys()))a.startsWith(r)&&(i.delete(a),n=!0);return n?i:t})}function CO(e,t){uc(n=>{let i=!1;const r=new Map(n),a=`${e}:`;for(const s of Array.from(r.keys()))if(s.startsWith(a)){const o=s.slice(a.length);t.has(o)||(r.delete(s),i=!0)}return i?r:n})}function co(e,t,n){const i=kt().get(e);if(!i)return;const r=i.get(t);if(!r)return;n(r);const a={...r};xr(s=>{const o=new Map(s),l=new Map(i);return l.set(t,a),o.set(e,l),o})}function Gs(e,t,n){co(e,t,i=>{i.pendingPermission!==n&&(i.pendingPermission=n)})}function Kn(e,t){AE(n=>{const i=new Map(n);return i.set(e,t),i})}function Ys(e,t){xE(n=>{const i=new Map(n);return i.set(e,t),i}),Kn(e,t)}function RO(e){xE(t=>{const n=new Map(t);return n.delete(e),n}),AE(t=>{const n=new Map(t);return n.delete(e),n})}function wr(e){const t=kt().get(e);return t?Array.from(t.values()):[]}function IO(e){return wr(e).filter(n=>n.parentId===null)}function OO(e,t){return wr(e).filter(i=>i.parentId===t)}function bl(e,t){var r;const n=(r=kt().get(e))==null?void 0:r.get(t);if(!n)return[];const i=OO(e,t);return[n,...i]}function NO(e,t){const n=kt().get(e);return!(!n||!n.has(t))}function AO(e,t){var n;return!!((n=wE().loadingMessages.get(e))!=null&&n.has(t))}function LE(e,t){var n;return(n=DE().get(e))==null?void 0:n.get(t)}const la=32e3;function Oa(e,t){if(!(t!=null&&t.providerId)||!t.modelId)return!1;const i=($a().get(e)||[]).find(r=>r.id===t.providerId);return i?i.models.some(r=>r.id===t.modelId):!1}function xO(e){const t=Rn().modelRecents??[];for(const n of t)if(Oa(e,n))return n}async function i_(e,t){const n=$a().get(e)||[],i=dc().get(e)||[];if(t){const a=i.find(o=>o.name===t);if(a&&a.model&&Oa(e,a.model))return{providerId:a.model.providerId,modelId:a.model.modelId};const s=await yE(e,t);if(Oa(e,s))return s}const r=xO(e);if(r)return r;for(const a of n)if(a.defaultModelId){const s=a.models.find(o=>o.id===a.defaultModelId);if(s)return{providerId:a.id,modelId:s.id}}if(n.length>0){const a=n[0],s=a.models[0];if(s)return{providerId:a.id,modelId:s.id}}return{providerId:"",modelId:""}}const wO=({onSseError:e,onSseEvent:t,responseTransformer:n,responseValidator:i,sseDefaultRetryDelay:r,sseMaxRetryAttempts:a,sseMaxRetryDelay:s,sseSleepFn:o,url:l,...c})=>{let d;const u=o??(p=>new Promise(g=>setTimeout(g,p)));return{stream:async function*(){let p=r??3e3,g=0;const E=c.signal??new AbortController().signal;for(;!E.aborted;){g++;const h=c.headers instanceof Headers?c.headers:new Headers(c.headers);d!==void 0&&h.set("Last-Event-ID",d);try{const f=await fetch(l,{...c,headers:h,signal:E});if(!f.ok)throw new Error(`SSE failed: ${f.status} ${f.statusText}`);if(!f.body)throw new Error("No body in SSE response");const S=f.body.pipeThrough(new TextDecoderStream).getReader();let v="";const b=()=>{try{S.cancel()}catch{}};E.addEventListener("abort",b);try{for(;;){const{done:C,value:R}=await S.read();if(C)break;v+=R;const A=v.split(`
|
|
3
3
|
|
|
4
4
|
`);v=A.pop()??"";for(const U of A){const w=U.split(`
|
|
5
5
|
`),M=[];let Y;for(const D of w)if(D.startsWith("data:"))M.push(D.replace(/^data:\s*/,""));else if(D.startsWith("event:"))Y=D.replace(/^event:\s*/,"");else if(D.startsWith("id:"))d=D.replace(/^id:\s*/,"");else if(D.startsWith("retry:")){const O=Number.parseInt(D.replace(/^retry:\s*/,""),10);Number.isNaN(O)||(p=O)}let $,k=!1;if(M.length){const D=M.join(`
|
|
@@ -147,4 +147,4 @@ ${W}
|
|
|
147
147
|
`).length,te=J.length;if(te>150||me>3){z.preventDefault();const be=b()+1;C(be);const ge=me>1?`${me} lines`:`${te} chars`,De=`pasted #${be} (${ge})`,Pe=`paste-${be}.txt`,q=wW(J,De,Pe);cs(e.instanceId,e.sessionId,q);const F=M;if(F){const x=F.selectionStart,W=F.selectionEnd,j=t(),re=`[pasted #${be}]`,de=j.substring(0,x)+re+j.substring(W);D(de),setTimeout(()=>{const Ae=x+re.length;F.setSelectionRange(Ae,Ae),F.focus()},0)}}}dn(()=>{const z=K=>{const J=document.activeElement;(J==null?void 0:J.tagName)==="INPUT"||(J==null?void 0:J.tagName)==="TEXTAREA"||(J==null?void 0:J.tagName)==="SELECT"||J!=null&&J.isContentEditable||K.ctrlKey||K.metaKey||K.altKey||K.key==="Tab"||K.key==="Enter"||K.key.startsWith("Arrow")||K.key==="Backspace"||K.key==="Delete"||K.key.length===1&&M&&!e.disabled&&M.focus()};document.addEventListener("keydown",z),xe(()=>{document.removeEventListener("keydown",z)}),(async()=>{const K=await NW(e.instanceFolder);r(K)})()});function H(z){const K=M;if(!K)return;const J=t(),me=K.selectionStart===0&&K.selectionEnd===0,te=U()==="shell";if(!te&&z.key==="!"&&me&&J.length===0&&!e.disabled){z.preventDefault(),w("shell");return}if(u()&&z.key==="Escape"){z.preventDefault(),z.stopPropagation(),ne();return}if(te){if(z.key==="Escape"){z.preventDefault(),z.stopPropagation(),w("normal");return}if(z.key==="Backspace"&&me&&J.length===0){z.preventDefault(),w("normal");return}}if(z.key==="Backspace"||z.key==="Delete"){const Ie=K.selectionStart,be=J,ge=/\[pasted #(\d+)\]/g;let De;for(;(De=ge.exec(be))!==null;){const W=De.index,j=De.index+De[0].length,re=De[1],de=z.key==="Backspace"&&Ie===j,Ae=z.key==="Delete"&&Ie===W,Ue=K.selectionStart<=W&&K.selectionEnd>=j&&K.selectionStart!==K.selectionEnd;if(de||Ae||Ue){z.preventDefault();const Ve=$().find(Je=>Je.source.type==="text"&&Je.display.includes(`pasted #${re}`));Ve&&Xo(e.instanceId,e.sessionId,Ve.id);const Ke=be.substring(0,W)+be.substring(j);D(Ke),setTimeout(()=>{K.setSelectionRange(W,W)},0);return}}const Pe=/\[Image #(\d+)\]/g;let q;for(;(q=Pe.exec(be))!==null;){const W=q.index,j=q.index+q[0].length,re=q[1],de=z.key==="Backspace"&&Ie===j,Ae=z.key==="Delete"&&Ie===W,Ue=K.selectionStart<=W&&K.selectionEnd>=j&&K.selectionStart!==K.selectionEnd;if(de||Ae||Ue){z.preventDefault();const Ve=$().find(Je=>Je.source.type==="file"&&Je.mediaType.startsWith("image/")&&Je.display.includes(`Image #${re}`));Ve&&Xo(e.instanceId,e.sessionId,Ve.id);const Ke=be.substring(0,W)+be.substring(j);D(Ke),setTimeout(()=>{K.setSelectionRange(W,W)},0);return}}const F=/@(\S+)/g;let x;for(;(x=F.exec(be))!==null;){const W=x.index,j=x.index+x[0].length,re=x[1],de=z.key==="Backspace"&&Ie===j,Ae=z.key==="Delete"&&Ie===W,Ue=K.selectionStart<=W&&K.selectionEnd>=j&&K.selectionStart!==K.selectionEnd;if(de||Ae||Ue){const Ve=$().find(Ke=>(Ke.source.type==="file"||Ke.source.type==="agent")&&Ke.filename===re);if(Ve){z.preventDefault(),Xo(e.instanceId,e.sessionId,Ve.id),v(Je=>{const $e=new Set(Je);return $e.delete(W),$e});const Ke=be.substring(0,W)+be.substring(j);D(Ke),setTimeout(()=>{K.setSelectionRange(W,W)},0);return}}}}if(z.key==="Enter"&&(z.metaKey||z.ctrlKey)){z.preventDefault(),u()&&ne(),Z();return}const se=K.selectionStart===0&&K.selectionEnd===0,oe=i();if(z.key==="ArrowUp"&&!u()&&se&&oe.length>0){z.preventDefault(),s()===-1&&c(t());const Ie=s()===-1?0:Math.min(s()+1,oe.length-1);o(Ie),D(oe[Ie]);return}if(z.key==="ArrowDown"&&!u()&&s()>=0){z.preventDefault();const Ie=s()-1;if(Ie>=0)o(Ie),D(oe[Ie]);else{o(-1);const be=l();D(be??""),c(null)}}}async function Z(){const z=t().trim(),K=$();if(e.disabled||!z&&K.length===0)return;const J=dS(z,K),me=U()==="shell",te=async()=>{try{await OW(e.instanceFolder,J),r(se=>{const oe=[J,...se];return oe.length>a&&(oe.length=a),oe}),o(-1)}catch(se){console.error("Failed to update prompt history:",se)}};O(),xW(e.instanceId,e.sessionId),v(new Set),C(0),A(0),c(null);try{me?e.onRunShell?await e.onRunShell(J):await e.onSend(J,[]):await e.onSend(J,K),te()}catch(se){console.error("Failed to send message:",se),vi("Failed to send message",{title:"Send failed",detail:se instanceof Error?se.message:String(se),variant:"error"})}finally{M==null||M.focus()}}function ae(z){const K=z.target,J=K.value;D(J),o(-1),c(null);const me=K.selectionStart,se=J.substring(0,me).lastIndexOf("@"),oe=g();if(se===-1?v(new Set):oe!==null&&se!==oe&&v(Ie=>{const be=new Set(Ie);return be.delete(oe),be}),se!==-1){const Ie=J.substring(se+1,me);if(!(Ie.includes(" ")||Ie.includes(`
|
|
148
148
|
`))&&me===se+Ie.length+1){S().has(se)||(E(se),p(Ie),_(!0));return}}_(!1),E(null)}function Se(z){if(z.type==="agent"){const K=z.agent.name;if(!$().some(Ie=>Ie.source.type==="agent"&&Ie.source.name===K)){const Ie=LW(K);cs(e.instanceId,e.sessionId,Ie)}const te=t(),se=g(),oe=(M==null?void 0:M.selectionStart)||0;if(se!==null){const Ie=te.substring(0,se),be=te.substring(oe),ge=`@${K}`,De=Ie+ge+" "+be;D(De),setTimeout(()=>{if(M){const Pe=se+ge.length+1;M.setSelectionRange(Pe,Pe)}},0)}}else if(z.type==="file"){const K=z.file.path,J=z.file.relativePath??K;if(z.file.isDirectory??K.endsWith("/")){const q=t(),F=g(),x=(M==null?void 0:M.selectionStart)||0,W=J==="."||J===""?"/":K;if(F!==null){const j=q.substring(0,F+1),re=q.substring(x),de=j+W+re;D(de),p(W),setTimeout(()=>{if(M){const Ae=F+1+W.length;M.setSelectionRange(Ae,Ae)}},0)}return}const te=J.replace(/\/+$/,"")||J,se=te.split("/"),oe=(()=>{const q=se[se.length-1]||te;return q==="."?"/":q})();if(!$().some(q=>q.source.type==="file"&&q.source.path===te)){const q=vd(te,oe,"text/plain",void 0,e.instanceFolder);cs(e.instanceId,e.sessionId,q)}const ge=t(),De=g(),Pe=(M==null?void 0:M.selectionStart)||0;if(De!==null){const q=ge.substring(0,De),F=ge.substring(Pe),x=`@${oe}`,W=q+x+" "+F;D(W),setTimeout(()=>{if(M){const j=De+x.length+1;M.setSelectionRange(j,j)}},0)}}_(!1),E(null),p(""),M==null||M.focus()}function ne(){const z=g();z!==null&&v(K=>new Set(K).add(z)),_(!1),E(null),p(""),setTimeout(()=>M==null?void 0:M.focus(),0)}function ie(z){z.preventDefault(),z.stopPropagation(),f(!0)}function Te(z){z.preventDefault(),z.stopPropagation(),f(!1)}function Ee(z){var J;z.preventDefault(),z.stopPropagation(),f(!1);const K=(J=z.dataTransfer)==null?void 0:J.files;if(!(!K||K.length===0)){for(let me=0;me<K.length;me++){const te=K[me],se=te.path||te.name,oe=te.name,Ie=te.type||"text/plain",be=ge=>{const De=vd(se,oe,Ie,void 0,e.instanceFolder);ge&&(Ie.startsWith("image/")||Ie.startsWith("text/"))&&(De.url=ge),cs(e.instanceId,e.sessionId,De)};if(Ie.startsWith("image/")&&typeof FileReader<"u"){const ge=new FileReader;ge.onload=()=>{const De=typeof ge.result=="string"?ge.result:void 0;be(De)},ge.readAsDataURL(te)}else if(Ie.startsWith("text/")&&typeof FileReader<"u"){const ge=new FileReader;ge.onload=()=>{const De=typeof ge.result=="string"?ge.result:void 0;be(De)},ge.readAsDataURL(te)}else be()}M==null||M.focus()}}const le=()=>{if(e.disabled)return!1;const z=t().trim().length>0;return U()==="shell"?z:z||$().length>0},Me=()=>U()==="shell"?{key:"Esc",text:"to exit shell mode"}:{key:"!",text:"for shell mode"},Re=()=>t().length===0,he=()=>eh();return(()=>{var z=UW(),K=z.firstChild,J=K.firstChild,me=J.firstChild,te=me.firstChild,se=J.nextSibling;K.addEventListener("drop",Ee),K.addEventListener("dragleave",Te),K.addEventListener("dragover",ie);var oe=Y;typeof oe=="function"?Nt(oe,K):Y=K,I(K,T(ee,{get when(){return ke(()=>!!u())()&&he()},get children(){return T(IW,{get open(){return u()},onClose:ne,onSelect:Se,get agents(){return k()},get instanceClient(){return he().client},get searchQuery(){return m()},textareaRef:M,get workspaceId(){return e.instanceId}})}}),J),I(J,T(ee,{get when(){return $().length>0},get children(){var be=MW();return I(be,T(We,{get each(){return $()},children:ge=>{const De=ge.mediaType.startsWith("image/");return(()=>{var Pe=GW(),q=Pe.firstChild,F=q.nextSibling;return He(Pe,`attachment-chip ${De?"attachment-chip-image":""}`),I(Pe,T(ee,{when:De,get fallback(){return T(ee,{get when(){return ge.source.type==="text"},get fallback(){return T(ee,{get when(){return ge.source.type==="agent"},get fallback(){return HW()},get children(){return VW()}})},get children(){return YW()}})},get children(){var x=BW();return ue(W=>{var j=ge.url,re=ge.filename;return j!==W.e&&Fe(x,"src",W.e=j),re!==W.t&&Fe(x,"alt",W.t=re),W},{e:void 0,t:void 0}),x}}),q),I(q,(()=>{var x=ke(()=>ge.source.type==="text");return()=>x()?ge.display:ge.filename})()),F.$$click=()=>N(ge.id),I(Pe,T(ee,{when:De,get children(){var x=$W(),W=x.firstChild;return ue(j=>{var re=ge.url,de=ge.filename;return re!==j.e&&Fe(W,"src",j.e=re),de!==j.t&&Fe(W,"alt",j.t=de),j},{e:void 0,t:void 0}),x}}),null),Pe})()}})),be}}),me),te.addEventListener("blur",()=>d(!1)),te.addEventListener("focus",()=>d(!0)),te.addEventListener("paste",P),te.$$keydown=H,te.$$input=ae;var Ie=M;return typeof Ie=="function"?Nt(Ie,te):M=te,Fe(te,"spellcheck",!1),I(me,T(ee,{get when(){return Re()},get children(){var be=PW();return I(be,T(ee,{get when(){return e.escapeInDebounce},get fallback(){return[(()=>{var ge=WW(),De=ge.firstChild,Pe=De.nextSibling,q=Pe.nextSibling,F=q.nextSibling,x=F.nextSibling,W=x.nextSibling;return W.nextSibling,I(ge,T(qt,{children:"Enter"}),De),I(ge,T(qt,{shortcut:"cmd+enter"}),Pe),I(ge,T(qt,{children:"@"}),F),I(ge,T(qt,{children:"↑↓"}),W),ge})(),T(ee,{get when(){return $().length>0},get children(){var ge=zW(),De=ge.firstChild,Pe=De.nextSibling;return Pe.nextSibling,I(ge,()=>$().length,Pe),ge}}),(()=>{var ge=KW(),De=ge.firstChild,Pe=De.nextSibling;return Pe.nextSibling,I(ge,T(qt,{get children(){return Me().key}}),Pe),I(ge,()=>Me().text,null),ge})(),T(ee,{get when(){return U()==="shell"},get children(){return xf()}})]},get children(){return[(()=>{var ge=kW(),De=ge.firstChild,Pe=De.nextSibling;return Pe.nextSibling,I(ge,T(qt,{children:"Esc"}),Pe),ge})(),T(ee,{get when(){return U()==="shell"},get children(){return xf()}})]}})),ue(()=>He(be,`prompt-input-overlay ${U()==="shell"?"shell-mode":""}`)),be}}),null),se.$$click=Z,I(se,T(ee,{get when(){return U()==="shell"},get fallback(){return qW()},get children(){return FW()}})),ue(be=>{var ge=`prompt-input-wrapper relative ${h()?"border-2":""}`,De=h()?"border-color: var(--accent-primary); background-color: rgba(0, 102, 255, 0.05);":"",Pe=`prompt-input ${U()==="shell"?"shell-mode":""}`,q=U()==="shell"?"Run a shell command (Esc to exit)...":"Type your message, @file, @agent, or paste images and text...",F=e.disabled,x=$().length>0?{"padding-top":"8px"}:{},W=`send-button ${U()==="shell"?"shell-mode":""}`,j=!le();return ge!==be.e&&He(K,be.e=ge),be.t=wn(K,De,be.t),Pe!==be.a&&He(te,be.a=Pe),q!==be.o&&Fe(te,"placeholder",be.o=q),F!==be.i&&(te.disabled=be.i=F),be.n=wn(te,x,be.n),W!==be.s&&He(se,be.s=W),j!==be.h&&(se.disabled=be.h=j),be},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),ue(()=>te.value=t()),z})()}At(["input","keydown","click"]);var XW=G('<div class="flex items-center justify-center h-full"><div class="text-center text-gray-500">Session not found'),jW=G("<div class=session-view>");function ZW(e){return(e==null?void 0:e.type)==="text"&&typeof e.text=="string"}const JW=e=>{const t=()=>e.activeSessions.get(e.sessionId),n=V(()=>AO(e.instanceId,e.sessionId)),i=V(()=>bt.getOrCreate(e.instanceId));fe(()=>{const c=t();c&&Xs(e.instanceId,c.id).catch(console.error)});async function r(c,d){await fL(e.instanceId,e.sessionId,c,d)}async function a(c){await hL(e.instanceId,e.sessionId,c)}function s(c){const d=i().getMessage(c);if(d&&d.role==="user"){const _=d.partIds.map(m=>{var p;return(p=d.parts[m])==null?void 0:p.data}).filter(m=>!!m).filter(ZW);if(_.length>0)return _.map(m=>m.text).join(`
|
|
149
149
|
`)}return null}async function o(c){const d=ze().get(e.instanceId);if(!(!d||!d.client))try{await d.client.session.revert({path:{id:e.sessionId},body:{messageID:c}});const u=s(c);if(u){const _=document.querySelector(".prompt-input");_&&(_.value=u,_.dispatchEvent(new Event("input",{bubbles:!0})),_.focus())}}catch(u){console.error("Failed to revert:",u),vi("Failed to revert to message",{title:"Revert failed",variant:"error"})}}async function l(c){if(!c){console.warn("Fork requires a user message id");return}const d=s(c);try{const u=await mL(e.instanceId,e.sessionId,{messageId:c}),_=u.parentId??u.id;if(Ys(e.instanceId,_),u.parentId&&Kn(e.instanceId,u.id),await Xs(e.instanceId,u.id).catch(console.error),d){const m=document.querySelector(".prompt-input");m&&(m.value=d,m.dispatchEvent(new Event("input",{bubbles:!0})),m.focus())}}catch(u){console.error("Failed to fork session:",u),vi("Failed to fork session",{title:"Fork failed",variant:"error"})}}return T(ee,{get when(){return t()},get fallback(){return XW()},children:c=>{const d=c();return d?(()=>{var u=jW();return I(u,T(oW,{get instanceId(){return e.instanceId},get sessionId(){return d.id},get loading(){return n()},onRevert:o,onFork:l}),null),I(u,T(QW,{get instanceId(){return e.instanceId},get instanceFolder(){return e.instanceFolder},get sessionId(){return d.id},onSend:r,onRunShell:a,get escapeInDebounce(){return e.escapeInDebounce}}),null),u})():null}})};var ez=G('<div class="flex flex-1 min-h-0"><div class="session-sidebar flex flex-col bg-surface-secondary"><div class="session-sidebar-separator border-t border-base"></div></div><div class="content-area flex-1 min-h-0 overflow-hidden flex flex-col">'),tz=G('<div class=session-sidebar-header><span class="session-sidebar-title text-sm font-semibold uppercase text-primary">Sessions</span><div class=session-sidebar-shortcuts>'),nz=G('<div class="session-sidebar-controls px-3 py-3 border-r 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">'),iz=G('<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');const rz=350,az=e=>{const[t,n]=Q(rz),i=V(()=>{const u=$s().get(e.instance.id);if(!u)return new Map;const _=bl(e.instance.id,u);return new Map(_.map(m=>[m.id,m]))}),r=V(()=>nr().get(e.instance.id)||null),a=V(()=>{const u=r();return!u||u==="info"?null:i().get(u)??null}),s=V(()=>BL(e.instance.id,hN(e.instance.id))),o=V(()=>[...e.paletteCommands(),...s()]),l=V(()=>GL(e.instance.id)),c=V(()=>[Ot.get("session-prev"),Ot.get("session-next")].filter(u=>!!u)),d=u=>{Kn(e.instance.id,u)};return[T(ee,{get when(){return i().size>0},get fallback(){return T(IM,{get instance(){return e.instance}})},get children(){var u=ez(),_=u.firstChild,m=_.firstChild,p=_.nextSibling;return I(_,T(rM,{get instanceId(){return e.instance.id},get sessions(){return i()},get activeSessionId(){return r()},onSelect:d,onClose:g=>{const E=e.onCloseSession(g);E instanceof Promise&&E.catch(h=>console.error("Failed to close session:",h))},onNew:()=>{const g=e.onNewSession();g instanceof Promise&&g.catch(E=>console.error("Failed to create session:",E))},showHeader:!0,showFooter:!1,get headerContent(){return(()=>{var g=tz(),E=g.firstChild,h=E.nextSibling;return I(h,(()=>{var f=ke(()=>!!c().length);return()=>f()?T(cc,{get shortcuts(){return c()},separator:" ",showDescription:!1}):null})()),g})()},onWidthChange:n}),m),I(_,T(ee,{get when(){return a()},children:g=>[T(BP,{get instanceId(){return e.instance.id},get sessionId(){return g().id}}),(()=>{var E=nz(),h=E.firstChild,f=h.firstChild,S=f.nextSibling;return I(E,T(EP,{get instanceId(){return e.instance.id},get sessionId(){return g().id},get currentAgent(){return g().agent},onAgentChange:v=>e.handleSidebarAgentChange(g().id,v)}),h),I(f,T(qt,{shortcut:"cmd+shift+a"})),I(S,T(qt,{shortcut:"cmd+shift+m"})),I(E,T(NP,{get instanceId(){return e.instance.id},get sessionId(){return g().id},get currentModel(){return g().model},onModelChange:v=>e.handleSidebarModelChange(g().id,v)}),null),E})()]}),null),I(p,T(ee,{get when(){return r()==="info"},get fallback(){return T(ee,{get when(){return r()},keyed:!0,get fallback(){return iz()},children:g=>T(JW,{sessionId:g,get activeSessions(){return i()},get instanceId(){return e.instance.id},get instanceFolder(){return e.instance.folder},get escapeInDebounce(){return e.escapeInDebounce}})})},get children(){return T(MM,{get instanceId(){return e.instance.id}})}})),ue(g=>bs(_,"width",`${t()}px`)),u}}),T(FP,{get open(){return l()},onClose:()=>gS(e.instance.id),get commands(){return o()},get onExecute(){return e.onExecuteCommand}})]};function sz(){const e=new Map;function t(o){e.set(o.id,o)}function n(o){e.delete(o)}function i(o){return e.get(o)}function r(){return Array.from(e.values())}function a(o){const l=e.get(o);if(l)return l.action()}function s(o){if(!o)return r();const l=o.toLowerCase();return r().filter(c=>{var p;const u=(typeof c.label=="function"?c.label():c.label).toLowerCase().includes(l),_=c.description.toLowerCase().includes(l),m=(p=c.keywords)==null?void 0:p.some(g=>g.toLowerCase().includes(l));return u||_||m})}return{register:t,unregister:n,get:i,getAll:r,execute:a,search:s}}function wf(e){if(!e)return null;const n=e.partIds.map(i=>{var r;return(r=e.parts[i])==null?void 0:r.data}).filter(i=>!!i).filter(i=>i.type==="text"&&typeof i.text=="string");return n.length===0?null:n.map(i=>i.text).join(`
|
|
150
|
-
`)}function oz(e){const t=sz(),[n,i]=Q([]);function r(){i(t.getAll())}function a(){const o=e.getActiveInstance,l=e.getActiveSessionIdForInstance;t.register({id:"new-instance",label:"New Instance",description:"Open folder picker to create new instance",category:"Instance",keywords:["folder","project","workspace"],shortcut:{key:"N",meta:!0},action:e.handleNewInstanceRequest}),t.register({id:"close-instance",label:"Close Instance",description:"Stop current instance's server",category:"Instance",keywords:["stop","quit","close"],shortcut:{key:"W",meta:!0},action:async()=>{const c=o();c&&await e.handleCloseInstance(c.id)}}),t.register({id:"instance-next",label:"Next Instance",description:"Cycle to next instance tab",category:"Instance",keywords:["switch","navigate"],shortcut:{key:"]",meta:!0},action:()=>{const c=Array.from(ze().keys());if(c.length<=1)return;const u=(c.indexOf(Ht()||"")+1)%c.length;c[u]&&Di(c[u])}}),t.register({id:"instance-prev",label:"Previous Instance",description:"Cycle to previous instance tab",category:"Instance",keywords:["switch","navigate"],shortcut:{key:"[",meta:!0},action:()=>{const c=Array.from(ze().keys());if(c.length<=1)return;const d=c.indexOf(Ht()||""),u=d<=0?c.length-1:d-1;c[u]&&Di(c[u])}}),t.register({id:"new-session",label:"New Session",description:"Create a new parent session",category:"Session",keywords:["create","start"],shortcut:{key:"N",meta:!0,shift:!0},action:async()=>{const c=o();c&&await e.handleNewSession(c.id)}}),t.register({id:"close-session",label:"Close Session",description:"Close current parent session",category:"Session",keywords:["close","stop"],shortcut:{key:"W",meta:!0,shift:!0},action:async()=>{const c=o(),d=l();!c||!d||d==="info"||await e.handleCloseSession(c.id,d)}}),t.register({id:"switch-to-info",label:"Instance Info",description:"Open the instance overview for logs and status",category:"Instance",keywords:["info","logs","console","output"],shortcut:{key:"L",meta:!0,shift:!0},action:()=>{const c=o();c&&Kn(c.id,"info")}}),t.register({id:"session-next",label:"Next Session",description:"Cycle to next session tab",category:"Session",keywords:["switch","navigate"],shortcut:{key:"]",meta:!0,shift:!0},action:()=>{const c=Ht();if(!c)return;const d=$s().get(c);if(!d)return;const _=bl(c,d).map(g=>g.id).concat(["info"]);if(_.length<=1)return;const p=(_.indexOf(nr().get(c)||"")+1)%_.length;_[p]&&Kn(c,_[p])}}),t.register({id:"session-prev",label:"Previous Session",description:"Cycle to previous session tab",category:"Session",keywords:["switch","navigate"],shortcut:{key:"[",meta:!0,shift:!0},action:()=>{const c=Ht();if(!c)return;const d=$s().get(c);if(!d)return;const _=bl(c,d).map(g=>g.id).concat(["info"]);if(_.length<=1)return;const m=_.indexOf(nr().get(c)||""),p=m<=0?_.length-1:m-1;_[p]&&Kn(c,_[p])}}),t.register({id:"compact",label:"Compact Session",description:"Summarize and compact the current session",category:"Session",keywords:["/compact","summarize","compress"],action:async()=>{const c=o(),d=l();if(!c||!c.client||!d||d==="info")return;const _=wr(c.id).find(m=>m.id===d);if(_)try{Hs(c.id,d,!0),await c.client.session.summarize({path:{id:d},body:{providerID:_.model.providerId,modelID:_.model.modelId}})}catch(m){Hs(c.id,d,!1),console.error("Failed to compact session:",m);const p=m instanceof Error?m.message:"Failed to compact session";vi(`Compact failed: ${p}`,{title:"Compact failed",variant:"error"})}}}),t.register({id:"undo",label:"Undo Last Message",description:"Revert the last message",category:"Session",keywords:["/undo","revert","undo"],action:async()=>{var v,b;const c=o(),d=l();if(!c||!c.client||!d||d==="info")return;const _=wr(c.id).find(C=>C.id===d);if(!_)return;const m=bt.getOrCreate(c.id),p=m.getSessionMessageIds(d),g=new Map;p.forEach(C=>{const R=m.getMessageInfo(C);R&&g.set(C,R)});const E=m.getSessionRevert(d)??_.revert;let h=0;if(E!=null&&E.messageID){const C=g.get(E.messageID)??m.getMessageInfo(E.messageID);h=((v=C==null?void 0:C.time)==null?void 0:v.created)||0}let f="",S=null;for(let C=p.length-1;C>=0;C--){const R=p[C],A=m.getMessage(R),U=g.get(R)??m.getMessageInfo(R);if((A==null?void 0:A.role)==="user"&&((b=U==null?void 0:U.time)!=null&&b.created)){if(h>0&&U.time.created>=h)continue;f=R,S=wf(A);break}}if(!f){vi("Nothing to undo",{title:"No actions to undo",variant:"info"});return}try{if(await c.client.session.revert({path:{id:d},body:{messageID:f}}),!S){const C=m.getMessage(f);S=wf(C)}if(S){const C=document.querySelector(".prompt-input");C&&(C.value=S,C.dispatchEvent(new Event("input",{bubbles:!0})),C.focus())}}catch(C){console.error("Failed to revert message:",C),vi("Failed to revert message",{title:"Undo failed",variant:"error"})}}}),t.register({id:"open-model-selector",label:"Open Model Selector",description:"Choose a different model",category:"Agent & Model",keywords:["model","llm","ai"],shortcut:{key:"M",meta:!0,shift:!0},action:()=>{const c=document.querySelector("[data-model-selector]");c&&(c.focus(),setTimeout(()=>{const d=new KeyboardEvent("keydown",{key:"ArrowDown",code:"ArrowDown",keyCode:40,which:40,bubbles:!0,cancelable:!0});c.dispatchEvent(d)},10))}}),t.register({id:"open-agent-selector",label:"Open Agent Selector",description:"Choose a different agent",category:"Agent & Model",keywords:["agent","mode"],shortcut:{key:"A",meta:!0,shift:!0},action:()=>{const c=document.querySelector("[data-agent-selector]");c&&(c.focus(),setTimeout(()=>{const d=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0});c.dispatchEvent(d)},50))}}),t.register({id:"clear-input",label:"Clear Input",description:"Clear the prompt textarea",category:"Input & Focus",keywords:["clear","reset"],shortcut:{key:"K",meta:!0},action:()=>{const c=document.querySelector(".prompt-input");c&&(c.value="")}}),t.register({id:"thinking",label:()=>`${e.preferences().showThinkingBlocks?"Hide":"Show"} Thinking Blocks`,description:"Show/hide AI thinking process",category:"System",keywords:["/thinking","thinking","reasoning","toggle","show","hide"],action:e.toggleShowThinkingBlocks}),t.register({id:"thinking-default-visibility",label:()=>`Thinking Blocks Default · ${(e.preferences().thinkingBlocksExpansion??"expanded")==="expanded"?"Expanded":"Collapsed"}`,description:"Toggle whether thinking blocks start expanded",category:"System",keywords:["/thinking","thinking","reasoning","expand","collapse","default"],action:()=>{const d=(e.preferences().thinkingBlocksExpansion??"expanded")==="expanded"?"collapsed":"expanded";e.setThinkingBlocksExpansion(d)}}),t.register({id:"diff-view-split",label:()=>`${(e.preferences().diffViewMode||"split")==="split"?"✓ ":""}Use Split Diff View`,description:"Display tool-call diffs side-by-side",category:"System",keywords:["diff","split","view"],action:()=>e.setDiffViewMode("split")}),t.register({id:"diff-view-unified",label:()=>`${(e.preferences().diffViewMode||"split")==="unified"?"✓ ":""}Use Unified Diff View`,description:"Display tool-call diffs inline",category:"System",keywords:["diff","unified","view"],action:()=>e.setDiffViewMode("unified")}),t.register({id:"tool-output-default-visibility",label:()=>`Tool Outputs Default · ${(e.preferences().toolOutputExpansion||"expanded")==="expanded"?"Expanded":"Collapsed"}`,description:"Toggle default expansion for tool outputs",category:"System",keywords:["tool","output","expand","collapse"],action:()=>{const d=(e.preferences().toolOutputExpansion||"expanded")==="expanded"?"collapsed":"expanded";e.setToolOutputExpansion(d)}}),t.register({id:"diagnostics-default-visibility",label:()=>`Diagnostics Default · ${(e.preferences().diagnosticsExpansion||"expanded")==="expanded"?"Expanded":"Collapsed"}`,description:"Toggle default expansion for diagnostics output",category:"System",keywords:["diagnostics","expand","collapse"],action:()=>{const d=(e.preferences().diagnosticsExpansion||"expanded")==="expanded"?"collapsed":"expanded";e.setDiagnosticsExpansion(d)}}),t.register({id:"token-usage-visibility",label:()=>`Token Usage Display · ${e.preferences().showUsageMetrics??!0?"Visible":"Hidden"}`,description:"Show or hide token and cost stats for assistant messages",category:"System",keywords:["token","usage","cost","stats"],action:e.toggleUsageMetrics}),t.register({id:"help",label:"Show Help",description:"Display keyboard shortcuts and help",category:"System",keywords:["/help","shortcuts","help"],action:()=>{console.log("Show help modal (not implemented)")}})}function s(o){var l;try{const c=(l=o.action)==null?void 0:l.call(o);c instanceof Promise&&c.catch(d=>{console.error("Command execution failed:",d)})}catch(c){console.error("Command execution failed:",c)}}return dn(()=>{a(),r()}),{commands:n,commandRegistry:t,refreshCommands:r,executeCommand:s}}function lz(e,t,n,i,r){Ot.register({id:"session-new",key:"n",modifiers:{shift:!0,meta:yi(),ctrl:!yi()},handler:()=>{const a=Ht();a&&n(a)},description:"New Session",context:"global"}),window.addEventListener("keydown",a=>{if((a.metaKey||a.ctrlKey)&&a.shiftKey&&a.key.toLowerCase()==="p"){a.preventDefault(),r();return}if((a.metaKey||a.ctrlKey)&&!a.shiftKey&&a.key>="1"&&a.key<="9"){a.preventDefault();const s=parseInt(a.key)-1,o=Array.from(ze().keys());o[s]&&Di(o[s])}if((a.metaKey||a.ctrlKey)&&a.shiftKey&&a.key>="1"&&a.key<="9"){a.preventDefault();const s=Ht();if(!s)return;const o=parseInt(a.key)-1,l=$s().get(s);if(!l)return;const u=wr(s).filter(_=>_.id===l||_.parentId===l).map(_=>_.id).concat(["logs"]);u[o]&&Kn(s,u[o])}if((a.metaKey||a.ctrlKey)&&!a.shiftKey&&a.key.toLowerCase()==="n"&&(a.preventDefault(),e()),(a.metaKey||a.ctrlKey)&&!a.shiftKey&&a.key.toLowerCase()==="w"){a.preventDefault();const s=Ht();s&&t(s)}if((a.metaKey||a.ctrlKey)&&a.shiftKey&&a.key.toLowerCase()==="w"){a.preventDefault();const s=Ht();if(!s)return;const o=nr().get(s);o&&o!=="logs"&&i(s,o)}})}function cz(){const e=()=>navigator.platform.toLowerCase().includes("mac"),t=n=>{const i=$s().get(n);if(!i)return[];const r=bl(n,i);if(r.length===0)return[];const[a,...s]=r;if(!a)return[];const o=s.slice().sort((l,c)=>c.time.updated-l.time.updated);return[a.id,"info",...o.map(l=>l.id)]};Ot.register({id:"instance-prev",key:"[",modifiers:{ctrl:!e(),meta:e()},handler:()=>{const n=Array.from(ze().keys());if(n.length<=1)return;const i=n.indexOf(Ht()||""),r=i<=0?n.length-1:i-1;n[r]&&Di(n[r])},description:"previous instance",context:"global"}),Ot.register({id:"instance-next",key:"]",modifiers:{ctrl:!e(),meta:e()},handler:()=>{const n=Array.from(ze().keys());if(n.length<=1)return;const r=(n.indexOf(Ht()||"")+1)%n.length;n[r]&&Di(n[r])},description:"next instance",context:"global"}),Ot.register({id:"session-prev",key:"[",modifiers:{ctrl:!e(),meta:e(),shift:!0},handler:()=>{const n=Ht();if(!n)return;const i=t(n);if(i.length===0)return;const r=nr().get(n);let a=i.indexOf(r||"");a===-1&&(a=i.length-1);const s=a<=0?i.length-1:a-1,o=i[s];Kn(n,o)},description:"previous session",context:"global"}),Ot.register({id:"session-next",key:"]",modifiers:{ctrl:!e(),meta:e(),shift:!0},handler:()=>{const n=Ht();if(!n)return;const i=t(n);if(i.length===0)return;const r=nr().get(n);let a=i.indexOf(r||"");a===-1&&(a=0);const s=(a+1)%i.length,o=i[s];Kn(n,o)},description:"next session",context:"global"}),Ot.register({id:"switch-to-info",key:"l",modifiers:{ctrl:!e(),meta:e(),shift:!0},handler:()=>{const n=Ht();n&&Kn(n,"info")},description:"info tab",context:"global"})}function dz(e,t){const n=()=>navigator.platform.toLowerCase().includes("mac");Ot.register({id:"clear-input",key:"k",modifiers:{ctrl:!n(),meta:n()},handler:e,description:"clear input",context:"global"}),Ot.register({id:"focus-input",key:"p",modifiers:{ctrl:!n(),meta:n()},handler:t,description:"focus input",context:"global"})}function uz(e,t){const n=()=>navigator.platform.toLowerCase().includes("mac");Ot.register({id:"focus-model",key:"M",modifiers:{ctrl:!n(),meta:n(),shift:!0},handler:e,description:"focus model",context:"global"}),Ot.register({id:"open-agent-selector",key:"A",modifiers:{ctrl:!n(),meta:n(),shift:!0},handler:t,description:"open agent",context:"global"})}const _z=1e3;let cl="idle",dl=null,ro=null;function mz(e){ro=e}function jo(){cl="idle",dl!==null&&(clearTimeout(dl),dl=null),ro&&ro(!1)}function pz(e,t,n,i){Ot.register({id:"escape",key:"Escape",modifiers:{},handler:()=>{if(document.querySelector('[role="dialog"]')!==null){i(),jo();return}if(e()){cl==="idle"?(cl="firstPress",ro&&ro(!0),dl=window.setTimeout(()=>{jo()},_z)):cl==="firstPress"&&(jo(),t());return}jo(),n()},description:"cancel/close",context:"global"})}function gz(e){dn(()=>{mz(e.setEscapeInDebounce),lz(e.handleNewInstanceRequest,e.handleCloseInstance,e.handleNewSession,e.handleCloseSession,()=>{const n=e.getActiveInstance();n&&pS(n.id)}),cz(),dz(()=>{const n=document.querySelector(".prompt-input");n&&(n.value="")},()=>{const n=document.querySelector(".prompt-input");n==null||n.focus()}),uz(()=>{const n=document.querySelector("[data-model-selector]");n&&(n.focus(),setTimeout(()=>{const i=new KeyboardEvent("keydown",{key:"ArrowDown",code:"ArrowDown",keyCode:40,which:40,bubbles:!0,cancelable:!0});n.dispatchEvent(i)},10))},()=>{const n=document.querySelector("[data-agent-selector]");n&&(n.focus(),setTimeout(()=>{const i=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0});n.dispatchEvent(i)},50))}),pz(()=>{if(e.showFolderSelection())return!0;const n=e.getActiveInstance();if(!n)return!1;const i=e.getActiveSessionIdForInstance();return!i||i==="info"||!wr(n.id).find(s=>s.id===i)?!1:NO(n.id,i)},async()=>{if(e.showFolderSelection()){e.setShowFolderSelection(!1);return}const n=e.getActiveInstance(),i=e.getActiveSessionIdForInstance();if(!(!n||!i||i==="info"))try{await SL(n.id,i),console.log("Session aborted successfully")}catch(r){console.error("Failed to abort session:",r)}},()=>{const n=document.activeElement;n==null||n.blur()},()=>gS());const t=n=>{const i=n.target,r=i.closest('[role="combobox"]')!==null,a=i.closest('[role="listbox"]')!==null,s=i.closest('[role="button"][data-agent-selector]')!==null;if(r||a||s)return;const o=Ot.findMatch(n);o&&(n.preventDefault(),o.handler())};window.addEventListener("keydown",t),xe(()=>{window.removeEventListener("keydown",t)})})}var fz=G("<div>"),Ez=G('<div class="rounded-lg border border-base bg-surface-secondary p-4"><p class="text-xs font-medium text-muted uppercase tracking-wide mb-1">Binary path</p><p class="text-sm font-mono text-primary break-all">'),hz=G('<div class="flex justify-end gap-2"><button type=button class="selector-button selector-button-secondary">Open Advanced Settings</button><button type=button class="selector-button selector-button-primary">Close'),Sz=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),bz=G('<div class="fixed inset-0 bg-black/50 z-50 flex items-center justify-center"><div class="w-full h-full relative"><button class="absolute top-4 right-4 z-10 p-2 bg-white dark:bg-gray-800 rounded-lg shadow-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"title="Close (Esc)"><svg class="w-5 h-5 text-gray-600 dark:text-gray-300"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M6 18L18 6M6 6l12 12">'),Tz=G('<div class="h-screen w-screen flex flex-col">');const vz=()=>{const{isDark:e}=bm(),{preferences:t,recordWorkspaceLaunch:n,toggleShowThinkingBlocks:i,toggleUsageMetrics:r,setDiffViewMode:a,setToolOutputExpansion:s,setDiagnosticsExpansion:o,setThinkingBlocksExpansion:l}=_r(),[c,d]=Q(!1),[u,_]=Q(null),[m,p]=Q(!1);fe(()=>{N_(e()).catch(console.error)});const g=V(()=>eh()),E=V(()=>{const O=g();return O&&nr().get(O.id)||null}),h=()=>{const O=u();return O&&O.trim()||"opencode"},f=O=>{if(!O)return!1;const N=(typeof O=="string"?O:O instanceof Error?O.message:String(O)).toLowerCase();return N.includes("opencode binary not found")||N.includes("binary not found")||N.includes("no such file or directory")||N.includes("binary is not executable")||N.includes("enoent")},S=()=>_(null);async function v(O,y){var P;if(!O)return;gp(!0);const N=y||t().lastUsedBinary||"opencode";try{n(O,N),S();const H=await YN(O,N);Dr(!0),xo(!1),p(!1),console.log("Created instance:",H,"Port:",(P=ze().get(H))==null?void 0:P.port)}catch(H){S(),f(H)&&_(N),console.error("Failed to create instance:",H)}finally{gp(!1)}}function b(){S()}function C(){S(),p(!0)}function R(){mp()&&xo(!0)}async function A(){try{await eA()}catch(O){console.error("Failed to finalize disconnected instance:",O)}}async function U(O){await mC("Stop OpenCode instance? This will stop the server.",{title:"Stop instance",variant:"warning",confirmLabel:"Stop",cancelLabel:"Keep running"})&&(await ZE(O),ze().size===0&&Dr(!1))}async function w(O){try{const y=await oS(O);Ys(O,y.id)}catch(y){console.error("Failed to create session:",y)}}async function M(O,y){const N=wr(O),P=N.find(ae=>ae.id===y);if(!P)return;const H=P.parentId??P.id,Z=N.find(ae=>ae.id===H);if(!(!Z||Z.parentId!==null)){RO(O);try{await sS(O)}catch(ae){console.error("Failed to refresh sessions after closing:",ae)}}}const Y=async(O,y,N)=>{!O||!y||y==="info"||await bL(O,y,N)},$=async(O,y,N)=>{!O||!y||y==="info"||await TL(O,y,N)},{commands:k,executeCommand:D}=oz({preferences:t,toggleShowThinkingBlocks:i,toggleUsageMetrics:r,setDiffViewMode:a,setToolOutputExpansion:s,setDiagnosticsExpansion:o,setThinkingBlocksExpansion:l,handleNewInstanceRequest:R,handleCloseInstance:U,handleNewSession:w,handleCloseSession:M,getActiveInstance:g,getActiveSessionIdForInstance:E});return gz({setEscapeInDebounce:d,handleNewInstanceRequest:R,handleCloseInstance:U,handleNewSession:w,handleCloseSession:M,showFolderSelection:fp,setShowFolderSelection:xo,getActiveInstance:g,getActiveSessionIdForInstance:E}),[T(pO,{get open(){return!!Jo()},get folder(){var O;return(O=Jo())==null?void 0:O.folder},get reason(){var O;return(O=Jo())==null?void 0:O.reason},onClose:A}),T(Ze,{get open(){return!!u()},modal:!0,get children(){return T(Ze.Portal,{get children(){return[T(Ze.Overlay,{class:"modal-overlay"}),(()=>{var O=Sz();return I(O,T(Ze.Content,{class:"modal-surface w-full max-w-md p-6 flex flex-col gap-6",get children(){return[(()=>{var y=fz();return I(y,T(Ze.Title,{class:"text-xl font-semibold text-primary",children:"Unable to launch OpenCode"}),null),I(y,T(Ze.Description,{class:"text-sm text-secondary mt-2",children:"Install the OpenCode CLI and make sure it is available in your PATH, or pick a custom binary from Advanced Settings."}),null),y})(),(()=>{var y=Ez(),N=y.firstChild,P=N.nextSibling;return I(P,h),y})(),(()=>{var y=hz(),N=y.firstChild,P=N.nextSibling;return N.$$click=C,P.$$click=b,y})()]}})),O})()]}})}}),(()=>{var O=Tz();return I(O,T(ee,{get when(){return!mp()},get fallback(){return[T(lO,{get instances(){return ze()},get activeInstanceId(){return Ht()},onSelect:Di,onClose:U,onNew:R}),T(ee,{get when(){return g()},keyed:!0,children:y=>T(az,{instance:y,get escapeInDebounce(){return c()},paletteCommands:k,onCloseSession:N=>M(y.id,N),onNewSession:()=>w(y.id),handleSidebarAgentChange:(N,P)=>Y(y.id,N,P),handleSidebarModelChange:(N,P)=>$(y.id,N,P),onExecuteCommand:D})})]},get children(){return T(cp,{onSelectFolder:v,get isLoading(){return pp()},get advancedSettingsOpen(){return m()},onAdvancedSettingsOpen:()=>p(!0),onAdvancedSettingsClose:()=>p(!1)})}}),null),I(O,T(ee,{get when(){return fp()},get children(){var y=bz(),N=y.firstChild,P=N.firstChild;return P.$$click=()=>{xo(!1),p(!1),S()},I(N,T(cp,{onSelectFolder:v,get isLoading(){return pp()},get advancedSettingsOpen(){return m()},onAdvancedSettingsOpen:()=>p(!0),onAdvancedSettingsClose:()=>p(!1)}),null),y}}),null),I(O,T(TC,{}),null),I(O,T(eC,{position:"top-right",gutter:16,toastOptions:{duration:8e3,className:"bg-transparent border-none shadow-none p-0"}}),null),O})()]};At(["click"]);const pv=document.getElementById("root");if(!pv)throw new Error("Root element not found");typeof document<"u"&&(document.documentElement.dataset.runtimeHost=Id.host,document.documentElement.dataset.runtimePlatform=Id.platform);Av(()=>T(VR,{get children(){return T(gR,{get children(){return T(yV,{get children(){return T(vz,{})}})}})}}),pv);
|
|
150
|
+
`)}function oz(e){const t=sz(),[n,i]=Q([]);function r(){i(t.getAll())}function a(){const o=e.getActiveInstance,l=e.getActiveSessionIdForInstance;t.register({id:"new-instance",label:"New Instance",description:"Open folder picker to create new instance",category:"Instance",keywords:["folder","project","workspace"],shortcut:{key:"N",meta:!0},action:e.handleNewInstanceRequest}),t.register({id:"close-instance",label:"Close Instance",description:"Stop current instance's server",category:"Instance",keywords:["stop","quit","close"],shortcut:{key:"W",meta:!0},action:async()=>{const c=o();c&&await e.handleCloseInstance(c.id)}}),t.register({id:"instance-next",label:"Next Instance",description:"Cycle to next instance tab",category:"Instance",keywords:["switch","navigate"],shortcut:{key:"]",meta:!0},action:()=>{const c=Array.from(ze().keys());if(c.length<=1)return;const u=(c.indexOf(Ht()||"")+1)%c.length;c[u]&&Di(c[u])}}),t.register({id:"instance-prev",label:"Previous Instance",description:"Cycle to previous instance tab",category:"Instance",keywords:["switch","navigate"],shortcut:{key:"[",meta:!0},action:()=>{const c=Array.from(ze().keys());if(c.length<=1)return;const d=c.indexOf(Ht()||""),u=d<=0?c.length-1:d-1;c[u]&&Di(c[u])}}),t.register({id:"new-session",label:"New Session",description:"Create a new parent session",category:"Session",keywords:["create","start"],shortcut:{key:"N",meta:!0,shift:!0},action:async()=>{const c=o();c&&await e.handleNewSession(c.id)}}),t.register({id:"close-session",label:"Close Session",description:"Close current parent session",category:"Session",keywords:["close","stop"],shortcut:{key:"W",meta:!0,shift:!0},action:async()=>{const c=o(),d=l();!c||!d||d==="info"||await e.handleCloseSession(c.id,d)}}),t.register({id:"switch-to-info",label:"Instance Info",description:"Open the instance overview for logs and status",category:"Instance",keywords:["info","logs","console","output"],shortcut:{key:"L",meta:!0,shift:!0},action:()=>{const c=o();c&&Kn(c.id,"info")}}),t.register({id:"session-next",label:"Next Session",description:"Cycle to next session tab",category:"Session",keywords:["switch","navigate"],shortcut:{key:"]",meta:!0,shift:!0},action:()=>{const c=Ht();if(!c)return;const d=$s().get(c);if(!d)return;const _=bl(c,d).map(g=>g.id).concat(["info"]);if(_.length<=1)return;const p=(_.indexOf(nr().get(c)||"")+1)%_.length;_[p]&&Kn(c,_[p])}}),t.register({id:"session-prev",label:"Previous Session",description:"Cycle to previous session tab",category:"Session",keywords:["switch","navigate"],shortcut:{key:"[",meta:!0,shift:!0},action:()=>{const c=Ht();if(!c)return;const d=$s().get(c);if(!d)return;const _=bl(c,d).map(g=>g.id).concat(["info"]);if(_.length<=1)return;const m=_.indexOf(nr().get(c)||""),p=m<=0?_.length-1:m-1;_[p]&&Kn(c,_[p])}}),t.register({id:"compact",label:"Compact Session",description:"Summarize and compact the current session",category:"Session",keywords:["/compact","summarize","compress"],action:async()=>{const c=o(),d=l();if(!c||!c.client||!d||d==="info")return;const _=wr(c.id).find(m=>m.id===d);if(_)try{Hs(c.id,d,!0),await c.client.session.summarize({path:{id:d},body:{providerID:_.model.providerId,modelID:_.model.modelId}})}catch(m){Hs(c.id,d,!1),console.error("Failed to compact session:",m);const p=m instanceof Error?m.message:"Failed to compact session";vi(`Compact failed: ${p}`,{title:"Compact failed",variant:"error"})}}}),t.register({id:"undo",label:"Undo Last Message",description:"Revert the last message",category:"Session",keywords:["/undo","revert","undo"],action:async()=>{var v,b;const c=o(),d=l();if(!c||!c.client||!d||d==="info")return;const _=wr(c.id).find(C=>C.id===d);if(!_)return;const m=bt.getOrCreate(c.id),p=m.getSessionMessageIds(d),g=new Map;p.forEach(C=>{const R=m.getMessageInfo(C);R&&g.set(C,R)});const E=m.getSessionRevert(d)??_.revert;let h=0;if(E!=null&&E.messageID){const C=g.get(E.messageID)??m.getMessageInfo(E.messageID);h=((v=C==null?void 0:C.time)==null?void 0:v.created)||0}let f="",S=null;for(let C=p.length-1;C>=0;C--){const R=p[C],A=m.getMessage(R),U=g.get(R)??m.getMessageInfo(R);if((A==null?void 0:A.role)==="user"&&((b=U==null?void 0:U.time)!=null&&b.created)){if(h>0&&U.time.created>=h)continue;f=R,S=wf(A);break}}if(!f){vi("Nothing to undo",{title:"No actions to undo",variant:"info"});return}try{if(await c.client.session.revert({path:{id:d},body:{messageID:f}}),!S){const C=m.getMessage(f);S=wf(C)}if(S){const C=document.querySelector(".prompt-input");C&&(C.value=S,C.dispatchEvent(new Event("input",{bubbles:!0})),C.focus())}}catch(C){console.error("Failed to revert message:",C),vi("Failed to revert message",{title:"Undo failed",variant:"error"})}}}),t.register({id:"open-model-selector",label:"Open Model Selector",description:"Choose a different model",category:"Agent & Model",keywords:["model","llm","ai"],shortcut:{key:"M",meta:!0,shift:!0},action:()=>{const c=document.querySelector("[data-model-selector]");c&&(c.focus(),setTimeout(()=>{const d=new KeyboardEvent("keydown",{key:"ArrowDown",code:"ArrowDown",keyCode:40,which:40,bubbles:!0,cancelable:!0});c.dispatchEvent(d)},10))}}),t.register({id:"open-agent-selector",label:"Open Agent Selector",description:"Choose a different agent",category:"Agent & Model",keywords:["agent","mode"],shortcut:{key:"A",meta:!0,shift:!0},action:()=>{const c=document.querySelector("[data-agent-selector]");c&&(c.focus(),setTimeout(()=>{const d=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0});c.dispatchEvent(d)},50))}}),t.register({id:"clear-input",label:"Clear Input",description:"Clear the prompt textarea",category:"Input & Focus",keywords:["clear","reset"],shortcut:{key:"K",meta:!0},action:()=>{const c=document.querySelector(".prompt-input");c&&(c.value="")}}),t.register({id:"thinking",label:()=>`${e.preferences().showThinkingBlocks?"Hide":"Show"} Thinking Blocks`,description:"Show/hide AI thinking process",category:"System",keywords:["/thinking","thinking","reasoning","toggle","show","hide"],action:e.toggleShowThinkingBlocks}),t.register({id:"thinking-default-visibility",label:()=>`Thinking Blocks Default · ${(e.preferences().thinkingBlocksExpansion??"expanded")==="expanded"?"Expanded":"Collapsed"}`,description:"Toggle whether thinking blocks start expanded",category:"System",keywords:["/thinking","thinking","reasoning","expand","collapse","default"],action:()=>{const d=(e.preferences().thinkingBlocksExpansion??"expanded")==="expanded"?"collapsed":"expanded";e.setThinkingBlocksExpansion(d)}}),t.register({id:"diff-view-split",label:()=>`${(e.preferences().diffViewMode||"split")==="split"?"✓ ":""}Use Split Diff View`,description:"Display tool-call diffs side-by-side",category:"System",keywords:["diff","split","view"],action:()=>e.setDiffViewMode("split")}),t.register({id:"diff-view-unified",label:()=>`${(e.preferences().diffViewMode||"split")==="unified"?"✓ ":""}Use Unified Diff View`,description:"Display tool-call diffs inline",category:"System",keywords:["diff","unified","view"],action:()=>e.setDiffViewMode("unified")}),t.register({id:"tool-output-default-visibility",label:()=>`Tool Outputs Default · ${(e.preferences().toolOutputExpansion||"expanded")==="expanded"?"Expanded":"Collapsed"}`,description:"Toggle default expansion for tool outputs",category:"System",keywords:["tool","output","expand","collapse"],action:()=>{const d=(e.preferences().toolOutputExpansion||"expanded")==="expanded"?"collapsed":"expanded";e.setToolOutputExpansion(d)}}),t.register({id:"diagnostics-default-visibility",label:()=>`Diagnostics Default · ${(e.preferences().diagnosticsExpansion||"expanded")==="expanded"?"Expanded":"Collapsed"}`,description:"Toggle default expansion for diagnostics output",category:"System",keywords:["diagnostics","expand","collapse"],action:()=>{const d=(e.preferences().diagnosticsExpansion||"expanded")==="expanded"?"collapsed":"expanded";e.setDiagnosticsExpansion(d)}}),t.register({id:"token-usage-visibility",label:()=>`Token Usage Display · ${e.preferences().showUsageMetrics??!0?"Visible":"Hidden"}`,description:"Show or hide token and cost stats for assistant messages",category:"System",keywords:["token","usage","cost","stats"],action:e.toggleUsageMetrics}),t.register({id:"help",label:"Show Help",description:"Display keyboard shortcuts and help",category:"System",keywords:["/help","shortcuts","help"],action:()=>{console.log("Show help modal (not implemented)")}})}function s(o){var l;try{const c=(l=o.action)==null?void 0:l.call(o);c instanceof Promise&&c.catch(d=>{console.error("Command execution failed:",d)})}catch(c){console.error("Command execution failed:",c)}}return dn(()=>{a(),r()}),{commands:n,commandRegistry:t,refreshCommands:r,executeCommand:s}}function lz(e,t,n,i,r){Ot.register({id:"session-new",key:"n",modifiers:{shift:!0,meta:yi(),ctrl:!yi()},handler:()=>{const a=Ht();a&&n(a)},description:"New Session",context:"global"}),window.addEventListener("keydown",a=>{if((a.metaKey||a.ctrlKey)&&a.shiftKey&&a.key.toLowerCase()==="p"){a.preventDefault(),r();return}if((a.metaKey||a.ctrlKey)&&!a.shiftKey&&a.key>="1"&&a.key<="9"){a.preventDefault();const s=parseInt(a.key)-1,o=Array.from(ze().keys());o[s]&&Di(o[s])}if((a.metaKey||a.ctrlKey)&&a.shiftKey&&a.key>="1"&&a.key<="9"){a.preventDefault();const s=Ht();if(!s)return;const o=parseInt(a.key)-1,l=$s().get(s);if(!l)return;const u=wr(s).filter(_=>_.id===l||_.parentId===l).map(_=>_.id).concat(["logs"]);u[o]&&Kn(s,u[o])}if((a.metaKey||a.ctrlKey)&&!a.shiftKey&&a.key.toLowerCase()==="n"&&(a.preventDefault(),e()),(a.metaKey||a.ctrlKey)&&!a.shiftKey&&a.key.toLowerCase()==="w"){a.preventDefault();const s=Ht();s&&t(s)}if((a.metaKey||a.ctrlKey)&&a.shiftKey&&a.key.toLowerCase()==="w"){a.preventDefault();const s=Ht();if(!s)return;const o=nr().get(s);o&&o!=="logs"&&i(s,o)}})}function cz(){const e=()=>navigator.platform.toLowerCase().includes("mac"),t=n=>{const i=$s().get(n);if(!i)return[];const r=bl(n,i);if(r.length===0)return[];const[a,...s]=r;if(!a)return[];const o=s.slice().sort((l,c)=>c.time.updated-l.time.updated);return[a.id,"info",...o.map(l=>l.id)]};Ot.register({id:"instance-prev",key:"[",modifiers:{ctrl:!e(),meta:e()},handler:()=>{const n=Array.from(ze().keys());if(n.length<=1)return;const i=n.indexOf(Ht()||""),r=i<=0?n.length-1:i-1;n[r]&&Di(n[r])},description:"previous instance",context:"global"}),Ot.register({id:"instance-next",key:"]",modifiers:{ctrl:!e(),meta:e()},handler:()=>{const n=Array.from(ze().keys());if(n.length<=1)return;const r=(n.indexOf(Ht()||"")+1)%n.length;n[r]&&Di(n[r])},description:"next instance",context:"global"}),Ot.register({id:"session-prev",key:"[",modifiers:{ctrl:!e(),meta:e(),shift:!0},handler:()=>{const n=Ht();if(!n)return;const i=t(n);if(i.length===0)return;const r=nr().get(n);let a=i.indexOf(r||"");a===-1&&(a=i.length-1);const s=a<=0?i.length-1:a-1,o=i[s];Kn(n,o)},description:"previous session",context:"global"}),Ot.register({id:"session-next",key:"]",modifiers:{ctrl:!e(),meta:e(),shift:!0},handler:()=>{const n=Ht();if(!n)return;const i=t(n);if(i.length===0)return;const r=nr().get(n);let a=i.indexOf(r||"");a===-1&&(a=0);const s=(a+1)%i.length,o=i[s];Kn(n,o)},description:"next session",context:"global"}),Ot.register({id:"switch-to-info",key:"l",modifiers:{ctrl:!e(),meta:e(),shift:!0},handler:()=>{const n=Ht();n&&Kn(n,"info")},description:"info tab",context:"global"})}function dz(e,t){const n=()=>navigator.platform.toLowerCase().includes("mac");Ot.register({id:"clear-input",key:"k",modifiers:{ctrl:!n(),meta:n()},handler:e,description:"clear input",context:"global"}),Ot.register({id:"focus-input",key:"p",modifiers:{ctrl:!n(),meta:n()},handler:t,description:"focus input",context:"global"})}function uz(e,t){const n=()=>navigator.platform.toLowerCase().includes("mac");Ot.register({id:"focus-model",key:"M",modifiers:{ctrl:!n(),meta:n(),shift:!0},handler:e,description:"focus model",context:"global"}),Ot.register({id:"open-agent-selector",key:"A",modifiers:{ctrl:!n(),meta:n(),shift:!0},handler:t,description:"open agent",context:"global"})}const _z=1e3;let cl="idle",dl=null,ro=null;function mz(e){ro=e}function jo(){cl="idle",dl!==null&&(clearTimeout(dl),dl=null),ro&&ro(!1)}function pz(e,t,n,i){Ot.register({id:"escape",key:"Escape",modifiers:{},handler:()=>{if(document.querySelector('[role="dialog"]')!==null){i(),jo();return}if(e()){cl==="idle"?(cl="firstPress",ro&&ro(!0),dl=window.setTimeout(()=>{jo()},_z)):cl==="firstPress"&&(jo(),t());return}jo(),n()},description:"cancel/close",context:"global"})}function gz(e){dn(()=>{mz(e.setEscapeInDebounce),lz(e.handleNewInstanceRequest,e.handleCloseInstance,e.handleNewSession,e.handleCloseSession,()=>{const n=e.getActiveInstance();n&&pS(n.id)}),cz(),dz(()=>{const n=document.querySelector(".prompt-input");n&&(n.value="")},()=>{const n=document.querySelector(".prompt-input");n==null||n.focus()}),uz(()=>{const n=document.querySelector("[data-model-selector]");n&&(n.focus(),setTimeout(()=>{const i=new KeyboardEvent("keydown",{key:"ArrowDown",code:"ArrowDown",keyCode:40,which:40,bubbles:!0,cancelable:!0});n.dispatchEvent(i)},10))},()=>{const n=document.querySelector("[data-agent-selector]");n&&(n.focus(),setTimeout(()=>{const i=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0});n.dispatchEvent(i)},50))}),pz(()=>{if(e.showFolderSelection())return!0;const n=e.getActiveInstance();if(!n)return!1;const i=e.getActiveSessionIdForInstance();return!i||i==="info"||!wr(n.id).find(s=>s.id===i)?!1:NO(n.id,i)},async()=>{if(e.showFolderSelection()){e.setShowFolderSelection(!1);return}const n=e.getActiveInstance(),i=e.getActiveSessionIdForInstance();if(!(!n||!i||i==="info"))try{await SL(n.id,i),console.log("Session aborted successfully")}catch(r){console.error("Failed to abort session:",r)}},()=>{const n=document.activeElement;n==null||n.blur()},()=>gS());const t=n=>{const i=n.target,r=i.closest('[role="combobox"]')!==null,a=i.closest('[role="listbox"]')!==null,s=i.closest('[role="button"][data-agent-selector]')!==null;if(r||a||s)return;const o=Ot.findMatch(n);o&&(n.preventDefault(),o.handler())};window.addEventListener("keydown",t),xe(()=>{window.removeEventListener("keydown",t)})})}var fz=G("<div>"),Ez=G('<div class="rounded-lg border border-base bg-surface-secondary p-4"><p class="text-xs font-medium text-muted uppercase tracking-wide mb-1">Binary path</p><p class="text-sm font-mono text-primary break-all">'),hz=G('<div class="flex justify-end gap-2"><button type=button class="selector-button selector-button-secondary">Open Advanced Settings</button><button type=button class="selector-button selector-button-primary">Close'),Sz=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),bz=G('<div class="fixed inset-0 bg-black/50 z-50 flex items-center justify-center"><div class="w-full h-full relative"><button class="absolute top-4 right-4 z-10 p-2 bg-white dark:bg-gray-800 rounded-lg shadow-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"title="Close (Esc)"><svg class="w-5 h-5 text-gray-600 dark:text-gray-300"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M6 18L18 6M6 6l12 12">'),Tz=G('<div class="h-screen w-screen flex flex-col">');const vz=()=>{const{isDark:e}=bm(),{preferences:t,recordWorkspaceLaunch:n,toggleShowThinkingBlocks:i,toggleUsageMetrics:r,setDiffViewMode:a,setToolOutputExpansion:s,setDiagnosticsExpansion:o,setThinkingBlocksExpansion:l}=_r(),[c,d]=Q(!1),[u,_]=Q(null),[m,p]=Q(!1);fe(()=>{N_(e()).catch(console.error)});const g=V(()=>eh()),E=V(()=>{const O=g();return O&&nr().get(O.id)||null}),h=()=>{const O=u();return O&&O.trim()||"opencode"},f=O=>{if(!O)return!1;const N=(typeof O=="string"?O:O instanceof Error?O.message:String(O)).toLowerCase();return N.includes("opencode binary not found")||N.includes("binary not found")||N.includes("no such file or directory")||N.includes("binary is not executable")||N.includes("enoent")},S=()=>_(null);async function v(O,y){var P;if(!O)return;gp(!0);const N=y||t().lastUsedBinary||"opencode";try{n(O,N),S();const H=await YN(O,N);Dr(!0),xo(!1),p(!1),console.log("Created instance:",H,"Port:",(P=ze().get(H))==null?void 0:P.port)}catch(H){S(),f(H)&&_(N),console.error("Failed to create instance:",H)}finally{gp(!1)}}function b(){S()}function C(){S(),p(!0)}function R(){mp()&&xo(!0)}async function A(){try{await eA()}catch(O){console.error("Failed to finalize disconnected instance:",O)}}async function U(O){await mC("Stop OpenCode instance? This will stop the server.",{title:"Stop instance",variant:"warning",confirmLabel:"Stop",cancelLabel:"Keep running"})&&(await ZE(O),ze().size===0&&Dr(!1))}async function w(O){try{const y=await oS(O);Ys(O,y.id)}catch(y){console.error("Failed to create session:",y)}}async function M(O,y){const N=wr(O),P=N.find(ae=>ae.id===y);if(!P)return;const H=P.parentId??P.id,Z=N.find(ae=>ae.id===H);if(!(!Z||Z.parentId!==null)){RO(O);try{await sS(O)}catch(ae){console.error("Failed to refresh sessions after closing:",ae)}}}const Y=async(O,y,N)=>{!O||!y||y==="info"||await bL(O,y,N)},$=async(O,y,N)=>{!O||!y||y==="info"||await TL(O,y,N)},{commands:k,executeCommand:D}=oz({preferences:t,toggleShowThinkingBlocks:i,toggleUsageMetrics:r,setDiffViewMode:a,setToolOutputExpansion:s,setDiagnosticsExpansion:o,setThinkingBlocksExpansion:l,handleNewInstanceRequest:R,handleCloseInstance:U,handleNewSession:w,handleCloseSession:M,getActiveInstance:g,getActiveSessionIdForInstance:E});return gz({setEscapeInDebounce:d,handleNewInstanceRequest:R,handleCloseInstance:U,handleNewSession:w,handleCloseSession:M,showFolderSelection:fp,setShowFolderSelection:xo,getActiveInstance:g,getActiveSessionIdForInstance:E}),[T(pO,{get open(){return!!Jo()},get folder(){var O;return(O=Jo())==null?void 0:O.folder},get reason(){var O;return(O=Jo())==null?void 0:O.reason},onClose:A}),T(Ze,{get open(){return!!u()},modal:!0,get children(){return T(Ze.Portal,{get children(){return[T(Ze.Overlay,{class:"modal-overlay"}),(()=>{var O=Sz();return I(O,T(Ze.Content,{class:"modal-surface w-full max-w-md p-6 flex flex-col gap-6",get children(){return[(()=>{var y=fz();return I(y,T(Ze.Title,{class:"text-xl font-semibold text-primary",children:"Unable to launch OpenCode"}),null),I(y,T(Ze.Description,{class:"text-sm text-secondary mt-2 break-words",children:"Install the OpenCode CLI and make sure it is available in your PATH, or pick a custom binary from Advanced Settings."}),null),y})(),(()=>{var y=Ez(),N=y.firstChild,P=N.nextSibling;return I(P,h),y})(),(()=>{var y=hz(),N=y.firstChild,P=N.nextSibling;return N.$$click=C,P.$$click=b,y})()]}})),O})()]}})}}),(()=>{var O=Tz();return I(O,T(ee,{get when(){return!mp()},get fallback(){return[T(lO,{get instances(){return ze()},get activeInstanceId(){return Ht()},onSelect:Di,onClose:U,onNew:R}),T(ee,{get when(){return g()},keyed:!0,children:y=>T(az,{instance:y,get escapeInDebounce(){return c()},paletteCommands:k,onCloseSession:N=>M(y.id,N),onNewSession:()=>w(y.id),handleSidebarAgentChange:(N,P)=>Y(y.id,N,P),handleSidebarModelChange:(N,P)=>$(y.id,N,P),onExecuteCommand:D})})]},get children(){return T(cp,{onSelectFolder:v,get isLoading(){return pp()},get advancedSettingsOpen(){return m()},onAdvancedSettingsOpen:()=>p(!0),onAdvancedSettingsClose:()=>p(!1)})}}),null),I(O,T(ee,{get when(){return fp()},get children(){var y=bz(),N=y.firstChild,P=N.firstChild;return P.$$click=()=>{xo(!1),p(!1),S()},I(N,T(cp,{onSelectFolder:v,get isLoading(){return pp()},get advancedSettingsOpen(){return m()},onAdvancedSettingsOpen:()=>p(!0),onAdvancedSettingsClose:()=>p(!1)}),null),y}}),null),I(O,T(TC,{}),null),I(O,T(eC,{position:"top-right",gutter:16,toastOptions:{duration:8e3,className:"bg-transparent border-none shadow-none p-0"}}),null),O})()]};At(["click"]);const pv=document.getElementById("root");if(!pv)throw new Error("Root element not found");typeof document<"u"&&(document.documentElement.dataset.runtimeHost=Id.host,document.documentElement.dataset.runtimePlatform=Id.platform);Av(()=>T(VR,{get children(){return T(gR,{get children(){return T(yV,{get children(){return T(vz,{})}})}})}}),pv);
|