@neuralnomads/codenomad 0.2.2-dev → 0.2.3-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.
@@ -1,5 +1,7 @@
1
1
  import { fetch } from "undici";
2
+ import { Agent as UndiciAgent } from "undici";
2
3
  const INSTANCE_HOST = "127.0.0.1";
4
+ const STREAM_AGENT = new UndiciAgent({ bodyTimeout: 0, headersTimeout: 0 });
3
5
  const RECONNECT_DELAY_MS = 1000;
4
6
  export class InstanceEventBridge {
5
7
  constructor(options) {
@@ -7,8 +9,8 @@ export class InstanceEventBridge {
7
9
  this.streams = new Map();
8
10
  const bus = this.options.eventBus;
9
11
  bus.on("workspace.started", (event) => this.startStream(event.workspace.id));
10
- bus.on("workspace.stopped", (event) => this.stopStream(event.workspaceId));
11
- bus.on("workspace.error", (event) => this.stopStream(event.workspace.id));
12
+ bus.on("workspace.stopped", (event) => this.stopStream(event.workspaceId, "workspace stopped"));
13
+ bus.on("workspace.error", (event) => this.stopStream(event.workspace.id, "workspace error"));
12
14
  }
13
15
  shutdown() {
14
16
  for (const [id, active] of this.streams) {
@@ -37,14 +39,14 @@ export class InstanceEventBridge {
37
39
  });
38
40
  this.streams.set(workspaceId, { controller, task });
39
41
  }
40
- stopStream(workspaceId) {
42
+ stopStream(workspaceId, reason) {
41
43
  const active = this.streams.get(workspaceId);
42
44
  if (!active) {
43
45
  return;
44
46
  }
45
47
  active.controller.abort();
46
48
  this.streams.delete(workspaceId);
47
- this.publishStatus(workspaceId, "disconnected");
49
+ this.publishStatus(workspaceId, "disconnected", reason);
48
50
  }
49
51
  async runStream(workspaceId, signal) {
50
52
  while (!signal.aborted) {
@@ -72,6 +74,7 @@ export class InstanceEventBridge {
72
74
  const response = await fetch(url, {
73
75
  headers: { Accept: "text/event-stream" },
74
76
  signal,
77
+ dispatcher: STREAM_AGENT,
75
78
  });
76
79
  if (!response.ok || !response.body) {
77
80
  throw new Error(`Instance event stream unavailable (${response.status})`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neuralnomads/codenomad",
3
- "version": "0.2.2-dev",
3
+ "version": "0.2.3-dev",
4
4
  "description": "CodeNomad Server",
5
5
  "author": {
6
6
  "name": "Neural Nomads",
@@ -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 YT=Object.defineProperty;var mm=e=>{throw TypeError(e)};var VT=(e,t,n)=>t in e?YT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var X=(e,t,n)=>VT(e,typeof t!="symbol"?t+"":t,n),HT=(e,t,n)=>t.has(e)||mm("Cannot "+n);var pm=(e,t,n)=>t.has(e)?mm("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var jo=(e,t,n)=>(HT(e,t,"access private method"),n);import{o as Oe,c as ge,a as de,b as V,$ as ad,u as ha,d as od,e as q,m as Ne,s as He,f as v,D as sf,g as Zt,h as Yn,i as jt,j as un,k as ke,l as pr,P as fu,S as j,n as ar,p as WT,q as sd,t as G,r as C,F as Ge,v as In,w as Be,M as ni,x as Eu,y as Hn,z as Tt,A as Pe,B as mt,C as zr,E as Gi,G as ld,H as zT,I as lf,J as KT,K as qT}from"./index-Cpjhgy_m.js";function QT(e){return(...t)=>{for(const n of e)n&&n(...t)}}const oe=e=>typeof e=="function"&&!e.length?e():e,gm=e=>Array.isArray(e)?e:e?[e]:[];function XT(e,...t){return typeof e=="function"?e(...t):e}const ZT=Oe;function jT(e,t,n,i){return e.addEventListener(t,n,i),ZT(e.removeEventListener.bind(e,t,n,i))}function JT(e,t,n,i){const r=()=>{gm(oe(e)).forEach(a=>{a&&gm(oe(t)).forEach(o=>jT(a,o,n,i))})};typeof e=="function"?ge(r):de(r)}const gc=Symbol("fallback");function fm(e){for(const t of e)t.dispose()}function ev(e,t,n,i={}){const r=new Map;return Oe(()=>fm(r.values())),()=>{const o=e()||[];return o[ad],ha(()=>{var d,u;if(!o.length)return fm(r.values()),r.clear(),i.fallback?[od(m=>(r.set(gc,{dispose:m}),i.fallback()))]:[];const s=new Array(o.length),l=r.get(gc);if(!r.size||l){l==null||l.dispose(),r.delete(gc);for(let _=0;_<o.length;_++){const m=o[_],p=t(m,_);a(s,m,_,p)}return s}const c=new Set(r.keys());for(let _=0;_<o.length;_++){const m=o[_],p=t(m,_);c.delete(p);const g=r.get(p);g?(s[_]=g.mapped,(d=g.setIndex)==null||d.call(g,_),g.setItem(()=>m)):a(s,m,_,p)}for(const _ of c)(u=r.get(_))==null||u.dispose(),r.delete(_);return s})};function a(o,s,l,c){od(d=>{const[u,_]=q(s),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),o[l]=m.mapped})}}function tv(e){const{by:t}=e;return V(ev(()=>e.each,typeof t=="function"?t:n=>n[t],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}const nv=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Em(e){const t={};let n;for(;n=nv.exec(e);)t[n[1]]=n[2];return t}function $o(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=Em(e)}else typeof t=="string"&&(t=Em(t));return{...e,...t}}function Nt(...e){return QT(e)}function hm(e,t){const n=[...e],i=n.indexOf(t);return i!==-1&&n.splice(i,1),n}function iv(e){return typeof e=="number"}function Nr(e){return Object.prototype.toString.call(e)==="[object String]"}function Ci(e){return typeof e=="function"}function Sa(e){return t=>`${e()}-${t}`}function On(e,t){return e?e===t||e.contains(t):!1}function Wa(e,t=!1){const{activeElement:n}=di(e);if(!(n!=null&&n.nodeName))return null;if(cf(n)&&n.contentDocument)return Wa(n.contentDocument.body,t);if(t){const i=n.getAttribute("aria-activedescendant");if(i){const r=di(n).getElementById(i);if(r)return r}}return n}function rv(e){return di(e).defaultView||window}function di(e){return e?e.ownerDocument||e:document}function cf(e){return e.tagName==="IFRAME"}var df=(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))(df||{});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 hu(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 Go(){return hu(/^Mac/i)}function av(){return hu(/^iPhone/i)}function ov(){return hu(/^iPad/i)||Go()&&navigator.maxTouchPoints>1}function sv(){return av()||ov()}function xs(){return Go()||sv()}function lv(){return uf(/AppleWebKit/i)&&!cv()}function cv(){return uf(/Chrome/i)}function it(e,t){return t&&(Ci(t)?t(e):t[0](t[1],e)),e==null?void 0:e.defaultPrevented}function gn(e){return t=>{for(const n of e)it(t,n)}}function dv(e){return Go()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Dt(e){if(e)if(uv())e.focus({preventScroll:!0});else{const t=_v(e);e.focus(),mv(t)}}var Jo=null;function uv(){if(Jo==null){Jo=!1;try{document.createElement("div").focus({get preventScroll(){return Jo=!0,!0}})}catch{}}return Jo}function _v(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 mv(e){for(const{element:t,scrollTop:n,scrollLeft:i}of e)t.scrollTop=n,t.scrollLeft=i}var _f=["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'])"],pv=[..._f,'[tabindex]:not([tabindex="-1"]):not([disabled])'],Su=`${_f.join(":not([hidden]),")},[tabindex]:not([disabled]):not([hidden])`,gv=pv.join(':not([hidden]):not([tabindex="-1"]),');function mf(e,t){const i=Array.from(e.querySelectorAll(Su)).filter(Sm);return t&&Sm(e)&&i.unshift(e),i.forEach((r,a)=>{if(cf(r)&&r.contentDocument){const o=r.contentDocument.body,s=mf(o,!1);i.splice(a,1,...s)}}),i}function Sm(e){return pf(e)&&!fv(e)}function pf(e){return e.matches(Su)&&bu(e)}function fv(e){return Number.parseInt(e.getAttribute("tabindex")||"0",10)<0}function bu(e,t){return e.nodeName!=="#comment"&&Ev(e)&&hv(e,t)&&(!e.parentElement||bu(e.parentElement,e))}function Ev(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:o}=r(e);i=a!=="none"&&o!=="hidden"&&o!=="collapse"}return i}function hv(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function Sv(e,t,n){const i=t!=null&&t.tabbable?gv:Su,r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(a){var o;return(o=t==null?void 0:t.from)!=null&&o.contains(a)?NodeFilter.FILTER_REJECT:a.matches(i)&&bu(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 bv(){}function Xe(e,t){return Ne(e,t)}var Ma=new Map,bm=new Set;function Tm(){if(typeof window>"u")return;const e=n=>{if(!n.target)return;let i=Ma.get(n.target);i||(i=new Set,Ma.set(n.target,i),n.target.addEventListener("transitioncancel",t)),i.add(n.propertyName)},t=n=>{if(!n.target)return;const i=Ma.get(n.target);if(i&&(i.delete(n.propertyName),i.size===0&&(n.target.removeEventListener("transitioncancel",t),Ma.delete(n.target)),Ma.size===0)){for(const r of bm)r();bm.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?Tm():document.addEventListener("DOMContentLoaded",Tm));function vm(e,t){const n=ym(e,t,"left"),i=ym(e,t,"top"),r=t.offsetWidth,a=t.offsetHeight;let o=e.scrollLeft,s=e.scrollTop;const l=o+e.offsetWidth,c=s+e.offsetHeight;n<=o?o=n:n+r>l&&(o+=n+r-l),i<=s?s=i:i+a>c&&(s+=i+a-c),e.scrollLeft=o,e.scrollTop=s}function ym(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 Tu={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"},Hs="data-kb-top-layer",gf,cd=!1,ui=[];function fo(e){return ui.findIndex(t=>t.node===e)}function Tv(e){return ui[fo(e)]}function vv(e){return ui[ui.length-1].node===e}function ff(){return ui.filter(e=>e.isPointerBlocking)}function yv(){return[...ff()].slice(-1)[0]}function vu(){return ff().length>0}function Ef(e){var n;const t=fo((n=yv())==null?void 0:n.node);return fo(e)<t}function Cv(e){ui.push(e)}function Rv(e){const t=fo(e);t<0||ui.splice(t,1)}function Iv(){for(const{node:e}of ui)e.style.pointerEvents=Ef(e)?"none":"auto"}function Nv(e){if(vu()&&!cd){const t=di(e);gf=document.body.style.pointerEvents,t.body.style.pointerEvents="none",cd=!0}}function Ov(e){if(vu())return;const t=di(e);t.body.style.pointerEvents=gf,t.body.style.length===0&&t.body.removeAttribute("style"),cd=!1}var en={layers:ui,isTopMostLayer:vv,hasPointerBlockingLayer:vu,isBelowPointerBlockingLayer:Ef,addLayer:Cv,removeLayer:Rv,indexOf:fo,find:Tv,assignPointerEventToLayers:Iv,disableBodyPointerEvents:Nv,restoreBodyPointerEvents:Ov},fc="focusScope.autoFocusOnMount",Ec="focusScope.autoFocusOnUnmount",Cm={bubbles:!1,cancelable:!0},Rm={stack:[],active(){return this.stack[0]},add(e){var t;e!==this.active()&&((t=this.active())==null||t.pause()),this.stack=hm(this.stack,e),this.stack.unshift(e)},remove(e){var t;this.stack=hm(this.stack,e),(t=this.active())==null||t.resume()}};function yu(e,t){const[n,i]=q(!1),r={pause(){i(!0)},resume(){i(!1)}};let a=null;const o=p=>{var g;return(g=e.onMountAutoFocus)==null?void 0:g.call(e,p)},s=p=>{var g;return(g=e.onUnmountAutoFocus)==null?void 0:g.call(e,p)},l=()=>di(t()),c=()=>{const p=l().createElement("span");return p.setAttribute("data-focus-trap",""),p.tabIndex=0,Object.assign(p.style,Tu),p},d=()=>{const p=t();return p?mf(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=Wa(p);return!g||On(p,g)?!1:pf(g)};ge(()=>{const p=t();if(!p)return;Rm.add(r);const g=Wa(p);if(!On(p,g)){const h=new CustomEvent(fc,Cm);p.addEventListener(fc,o),p.dispatchEvent(h),h.defaultPrevented||setTimeout(()=>{Dt(u()),Wa(p)===g&&Dt(p)},0)}Oe(()=>{p.removeEventListener(fc,o),setTimeout(()=>{const h=new CustomEvent(Ec,Cm);m()&&h.preventDefault(),p.addEventListener(Ec,s),p.dispatchEvent(h),h.defaultPrevented||Dt(g??l().body),p.removeEventListener(Ec,s),Rm.remove(r)},0)})}),ge(()=>{const p=t();if(!p||!oe(e.trapFocus)||n())return;const g=h=>{const f=h.target;f!=null&&f.closest(`[${Hs}]`)||(On(p,f)?a=f:Dt(a))},E=h=>{const S=h.relatedTarget??Wa(p);S!=null&&S.closest(`[${Hs}]`)||On(p,S)||Dt(a)};l().addEventListener("focusin",g),l().addEventListener("focusout",E),Oe(()=>{l().removeEventListener("focusin",g),l().removeEventListener("focusout",E)})}),ge(()=>{const p=t();if(!p||!oe(e.trapFocus)||n())return;const g=c();p.insertAdjacentElement("afterbegin",g);const E=c();p.insertAdjacentElement("beforeend",E);function h(S){const T=u(),b=_();S.relatedTarget===T?Dt(b):Dt(T)}g.addEventListener("focusin",h),E.addEventListener("focusin",h);const f=new MutationObserver(S=>{for(const T of S)T.previousSibling===E&&(E.remove(),p.insertAdjacentElement("beforeend",E)),T.nextSibling===g&&(g.remove(),p.insertAdjacentElement("afterbegin",g))});f.observe(p,{childList:!0,subtree:!1}),Oe(()=>{g.removeEventListener("focusin",h),E.removeEventListener("focusin",h),g.remove(),E.remove(),f.disconnect()})})}var hf=7e3,hc=null,Av="data-live-announcer";function Sc(e,t="assertive",n=hf){hc||(hc=new wv),hc.announce(e,t,n)}var wv=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,Tu),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=hf){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 Cu(e){ge(()=>{oe(e.isDisabled)||Oe(xv(oe(e.targets),oe(e.root)))})}var ka=new WeakMap,_n=[];function xv(e,t=document.body){const n=new Set(e),i=new Set,r=l=>{for(const _ of l.querySelectorAll(`[${Av}], [${Hs}]`))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=ka.get(l)??0;l.getAttribute("aria-hidden")==="true"&&c===0||(c===0&&l.setAttribute("aria-hidden","true"),i.add(l),ka.set(l,c+1))};_n.length&&_n[_n.length-1].disconnect(),r(t);const o=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)}});o.observe(t,{childList:!0,subtree:!0});const s={observe(){o.observe(t,{childList:!0,subtree:!0})},disconnect(){o.disconnect()}};return _n.push(s),()=>{o.disconnect();for(const l of i){const c=ka.get(l);if(c==null)return;c===1?(l.removeAttribute("aria-hidden"),ka.delete(l)):ka.set(l,c-1)}s===_n[_n.length-1]?(_n.pop(),_n.length&&_n[_n.length-1].observe()):_n.splice(_n.indexOf(s),1)}}var Im="interactOutside.pointerDownOutside",Nm="interactOutside.focusOutside";function Dv(e,t){let n,i=bv;const r=()=>di(t()),a=u=>{var _;return(_=e.onPointerDownOutside)==null?void 0:_.call(e,u)},o=u=>{var _;return(_=e.onFocusOutside)==null?void 0:_.call(e,u)},s=u=>{var _;return(_=e.onInteractOutside)==null?void 0:_.call(e,u)},l=u=>{var m;const _=u.target;return!(_ instanceof Element)||_.closest(`[${Hs}]`)||!On(r(),_)||On(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=gn([a,s]);p.addEventListener(Im,g,{once:!0});const E=new CustomEvent(Im,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:u.button===2||dv(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=gn([o,s]);m.addEventListener(Nm,p,{once:!0});const g=new CustomEvent(Nm,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:!1}});m.dispatchEvent(g)};ge(()=>{oe(e.isDisabled)||(n=window.setTimeout(()=>{r().addEventListener("pointerdown",c,!0)},0),r().addEventListener("focusin",d,!0),Oe(()=>{window.clearTimeout(n),r().removeEventListener("click",i),r().removeEventListener("pointerdown",c,!0),r().removeEventListener("focusin",d,!0)}))})}function Lv(e){const t=n=>{var i;n.key===df.Escape&&((i=e.onEscapeKeyDown)==null||i.call(e,n))};ge(()=>{var i;if(oe(e.isDisabled))return;const n=((i=e.ownerDocument)==null?void 0:i.call(e))??di();n.addEventListener("keydown",t),Oe(()=>{n.removeEventListener("keydown",t)})})}function st(e){const[t,n]=He(e,["as"]);if(!t.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return v(sf,Ne(n,{get component(){return t.as}}))}var Sf=jt();function Mv(){return un(Sf)}function Ru(e){let t;const n=Mv(),[i,r]=He(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),a=new Set([]),o=u=>{a.add(u);const _=n==null?void 0:n.registerNestedLayer(u);return()=>{a.delete(u),_==null||_()}};Dv({shouldExcludeElement:u=>{var _;return t?((_=i.excludedElements)==null?void 0:_.some(m=>On(m(),u)))||[...a].some(m=>On(m,u)):!1},onPointerDownOutside:u=>{var _,m,p;!t||en.isBelowPointerBlockingLayer(t)||!i.bypassTopMostLayerCheck&&!en.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),Lv({ownerDocument:()=>di(t),onEscapeKeyDown:u=>{var _;!t||!en.isTopMostLayer(t)||((_=i.onEscapeKeyDown)==null||_.call(i,u),!u.defaultPrevented&&i.onDismiss&&(u.preventDefault(),i.onDismiss()))}}),Zt(()=>{if(!t)return;en.addLayer({node:t,isPointerBlocking:i.disableOutsidePointerEvents,dismiss:i.onDismiss});const u=n==null?void 0:n.registerNestedLayer(t);en.assignPointerEventToLayers(),en.disableBodyPointerEvents(t),Oe(()=>{t&&(en.removeLayer(t),u==null||u(),en.assignPointerEventToLayers(),en.restoreBodyPointerEvents(t))})}),ge(Yn([()=>t,()=>i.disableOutsidePointerEvents],([u,_])=>{if(!u)return;const m=en.find(u);m&&m.isPointerBlocking!==_&&(m.isPointerBlocking=_,en.assignPointerEventToLayers()),_&&en.disableBodyPointerEvents(u),Oe(()=>{en.restoreBodyPointerEvents(u)})},{defer:!0}));const d={registerNestedLayer:o};return v(Sf.Provider,{value:d,get children(){return v(st,Ne({as:"div",ref(u){var _=Nt(m=>t=m,i.ref);typeof _=="function"&&_(u)}},r))}})}function Iu(e){var o;const[t,n]=q((o=e.defaultValue)==null?void 0:o.call(e)),i=V(()=>{var s;return((s=e.value)==null?void 0:s.call(e))!==void 0}),r=V(()=>{var s;return i()?(s=e.value)==null?void 0:s.call(e):t()});return[r,s=>{ha(()=>{var c;const l=XT(s,r());return Object.is(l,r())||(i()||n(l),(c=e.onChange)==null||c.call(e,l)),l})}]}function kv(e){const[t,n]=Iu(e);return[()=>t()??!1,n]}function Nu(e={}){const[t,n]=kv({value:()=>oe(e.open),defaultValue:()=>!!oe(e.defaultOpen),onChange:o=>{var s;return(s=e.onOpenChange)==null?void 0:s.call(e,o)}}),i=()=>{n(!0)},r=()=>{n(!1)};return{isOpen:t,setIsOpen:n,open:i,close:r,toggle:()=>{t()?r():i()}}}function bf(e,t){const[n,i]=q(Om(t==null?void 0:t()));return ge(()=>{var r;i(((r=e())==null?void 0:r.tagName.toLowerCase())||Om(t==null?void 0:t()))}),n}function Om(e){return Nr(e)?e:void 0}var Pv=Object.defineProperty,Yo=(e,t)=>{for(var n in t)Pv(e,n,{get:t[n],enumerable:!0})},Fv={};Yo(Fv,{Button:()=>$v,Root:()=>ba});var Uv=["button","color","file","image","reset","submit"];function Bv(e){const t=e.tagName.toLowerCase();return t==="button"?!0:t==="input"&&e.type?Uv.indexOf(e.type)!==-1:!1}function ba(e){let t;const n=Xe({type:"button"},e),[i,r]=He(n,["ref","type","disabled"]),a=bf(()=>t,()=>"button"),o=V(()=>{const c=a();return c==null?!1:Bv({tagName:c,type:i.type})}),s=V(()=>a()==="input"),l=V(()=>a()==="a"&&(t==null?void 0:t.getAttribute("href"))!=null);return v(st,Ne({as:"button",ref(c){var d=Nt(u=>t=u,i.ref);typeof d=="function"&&d(c)},get type(){return ke(()=>!!(o()||s()))()?i.type:void 0},get role(){return!o()&&!l()?"button":void 0},get tabIndex(){return!o()&&!l()&&!i.disabled?0:void 0},get disabled(){return ke(()=>!!(o()||s()))()?i.disabled:void 0},get"aria-disabled"(){return!o()&&!s()&&i.disabled?!0:void 0},get"data-disabled"(){return i.disabled?"":void 0}},r))}var $v=ba;function ln(e){return t=>(e(t),()=>e(void 0))}var Ut=e=>typeof e=="function"?e():e,dd=(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},es=new Map,Gv=e=>{ge(()=>{const t=Ut(e.style)??{},n=Ut(e.properties)??[],i={};for(const a in t)i[a]=e.element.style[a];const r=es.get(e.key);r?r.activeCount++:es.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);Oe(()=>{var o;const a=es.get(e.key);if(a){if(a.activeCount!==1){a.activeCount--;return}es.delete(e.key);for(const[s,l]of Object.entries(a.originalStyles))e.element.style[s]=l;for(const s of a.properties)e.element.style.removeProperty(s);e.element.style.length===0&&e.element.removeAttribute("style"),(o=e.cleanup)==null||o.call(e)}})})},Am=Gv,Yv=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},Vv=(e,t)=>{const n=getComputedStyle(e),i=t==="x"?n.overflowX:n.overflowY;return i==="auto"||i==="scroll"||e.tagName==="HTML"&&i==="visible"},Hv=(e,t,n)=>{const i=t==="x"&&window.getComputedStyle(e).direction==="rtl"?-1:1;let r=e,a=0,o=0,s=!1;do{const[l,c,d]=Yv(r,t),u=d-l-i*c;(c!==0||u!==0)&&Vv(r,t)&&(a+=u,o+=c),r===(n??document.documentElement)?s=!0:r=r._$host??r.parentElement}while(r&&!s);return[a,o]},[wm,xm]=q([]),Wv=e=>wm().indexOf(e)===wm().length-1,zv=e=>{const t=Ne({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=pr();let i=[0,0],r=null,a=null;ge(()=>{Ut(t.enabled)&&(xm(c=>[...c,n]),Oe(()=>{xm(c=>c.filter(d=>d!==n))}))}),ge(()=>{if(!Ut(t.enabled)||!Ut(t.hideScrollbar))return;const{body:c}=document,d=window.innerWidth-c.offsetWidth;if(Ut(t.preventScrollbarShift)){const u={overflow:"hidden"},_=[];d>0&&(Ut(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;Am({key:"prevent-scroll",element:c,style:u,properties:_,cleanup:()=>{Ut(t.restoreScrollPosition)&&d>0&&window.scrollTo(p,m)}})}else Am({key:"prevent-scroll",element:c,style:{overflow:"hidden"}})}),ge(()=>{!Wv(n)||!Ut(t.enabled)||(document.addEventListener("wheel",s,{passive:!1}),document.addEventListener("touchstart",o,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),Oe(()=>{document.removeEventListener("wheel",s),document.removeEventListener("touchstart",o),document.removeEventListener("touchmove",l)}))});const o=c=>{i=Dm(c),r=null,a=null},s=c=>{const d=c.target,u=Ut(t.element),_=Kv(c),m=Math.abs(_[0])>Math.abs(_[1])?"x":"y",p=m==="x"?_[0]:_[1],g=Lm(d,m,p,u);let E;u&&dd(u,d)?E=!g:E=!0,E&&c.cancelable&&c.preventDefault()},l=c=>{const d=Ut(t.element),u=c.target;let _;if(c.touches.length===2)_=!Ut(t.allowPinchZoom);else{if(r==null||a===null){const m=Dm(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=Lm(u,r,a,d);d&&dd(d,u)?_=!m:_=!0}}_&&c.cancelable&&c.preventDefault()}},Kv=e=>[e.deltaX,e.deltaY],Dm=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],Lm=(e,t,n,i)=>{const r=i!==null&&dd(i,e),[a,o]=Hv(e,t,r?i:void 0);return!(n>0&&Math.abs(a)<=1||n<0&&Math.abs(o)<1)},qv=zv,Ou=qv,Qv=e=>{const t=V(()=>{const o=Ut(e.element);if(o)return getComputedStyle(o)}),n=()=>{var o;return((o=t())==null?void 0:o.animationName)??"none"},[i,r]=q(Ut(e.show)?"present":"hidden");let a="none";return ge(o=>{const s=Ut(e.show);return ha(()=>{var d;if(o===s)return s;const l=a,c=n();s?r("present"):c==="none"||((d=t())==null?void 0:d.display)==="none"?r("hidden"):r(o===!0&&l!==c?"hiding":"hidden")}),s}),ge(()=>{const o=Ut(e.element);if(!o)return;const s=c=>{c.target===o&&(a=n())},l=c=>{const u=n().includes(c.animationName);c.target===o&&u&&i()==="hiding"&&r("hidden")};o.addEventListener("animationstart",s),o.addEventListener("animationcancel",l),o.addEventListener("animationend",l),Oe(()=>{o.removeEventListener("animationstart",s),o.removeEventListener("animationcancel",l),o.removeEventListener("animationend",l)})}),{present:()=>i()==="present"||i()==="hiding",state:i,setState:r}},Xv=Qv,Ws=Xv,Zv={};Yo(Zv,{CloseButton:()=>vf,Content:()=>yf,Description:()=>Cf,Dialog:()=>ze,Overlay:()=>Rf,Portal:()=>If,Root:()=>Nf,Title:()=>Of,Trigger:()=>Af,useDialogContext:()=>Yi});var Tf=jt();function Yi(){const e=un(Tf);if(e===void 0)throw new Error("[kobalte]: `useDialogContext` must be used within a `Dialog` component");return e}function vf(e){const t=Yi(),[n,i]=He(e,["aria-label","onClick"]);return v(ba,Ne({get"aria-label"(){return n["aria-label"]||t.translations().dismiss},onClick:a=>{it(a,n.onClick),t.close()}},i))}function yf(e){let t;const n=Yi(),i=Xe({id:n.generateId("content")},e),[r,a]=He(i,["ref","onOpenAutoFocus","onCloseAutoFocus","onPointerDownOutside","onFocusOutside","onInteractOutside"]);let o=!1,s=!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||(o=!0,_.detail.originalEvent.type==="pointerdown"&&(s=!0)),On(n.triggerRef(),_.target)&&_.preventDefault(),_.detail.originalEvent.type==="focusin"&&s&&_.preventDefault())},u=_=>{var m;(m=r.onCloseAutoFocus)==null||m.call(r,_),n.modal()?(_.preventDefault(),Dt(n.triggerRef())):(_.defaultPrevented||(o||Dt(n.triggerRef()),_.preventDefault()),o=!1,s=!1)};return Cu({isDisabled:()=>!(n.isOpen()&&n.modal()),targets:()=>t?[t]:[]}),Ou({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),yu({trapFocus:()=>n.isOpen()&&n.modal(),onMountAutoFocus:r.onOpenAutoFocus,onUnmountAutoFocus:u},()=>t),ge(()=>Oe(n.registerContentId(a.id))),v(j,{get when(){return n.contentPresent()},get children(){return v(Ru,Ne({ref(_){var m=Nt(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 Cf(e){const t=Yi(),n=Xe({id:t.generateId("description")},e),[i,r]=He(n,["id"]);return ge(()=>Oe(t.registerDescriptionId(i.id))),v(st,Ne({as:"p",get id(){return i.id}},r))}function Rf(e){const t=Yi(),[n,i]=He(e,["ref","style","onPointerDown"]),r=a=>{it(a,n.onPointerDown),a.target===a.currentTarget&&a.preventDefault()};return v(j,{get when(){return t.overlayPresent()},get children(){return v(st,Ne({as:"div",ref(a){var o=Nt(t.setOverlayRef,n.ref);typeof o=="function"&&o(a)},get style(){return $o({"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 If(e){const t=Yi();return v(j,{get when(){return t.contentPresent()||t.overlayPresent()},get children(){return v(fu,e)}})}var Mm={dismiss:"Dismiss"};function Nf(e){const t=`dialog-${pr()}`,n=Xe({id:t,modal:!0,translations:Mm},e),[i,r]=q(),[a,o]=q(),[s,l]=q(),[c,d]=q(),[u,_]=q(),[m,p]=q(),g=Nu({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:T=>{var b;return(b=n.onOpenChange)==null?void 0:b.call(n,T)}}),E=()=>n.forceMount||g.isOpen(),{present:h}=Ws({show:E,element:()=>c()??null}),{present:f}=Ws({show:E,element:()=>u()??null}),S={translations:()=>n.translations??Mm,isOpen:g.isOpen,modal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??S.modal(),contentId:i,titleId:a,descriptionId:s,triggerRef:m,overlayRef:c,setOverlayRef:d,contentRef:u,setContentRef:_,overlayPresent:h,contentPresent:f,close:g.close,toggle:g.toggle,setTriggerRef:p,generateId:Sa(()=>n.id),registerContentId:ln(r),registerTitleId:ln(o),registerDescriptionId:ln(l)};return v(Tf.Provider,{value:S,get children(){return n.children}})}function Of(e){const t=Yi(),n=Xe({id:t.generateId("title")},e),[i,r]=He(n,["id"]);return ge(()=>Oe(t.registerTitleId(i.id))),v(st,Ne({as:"h2",get id(){return i.id}},r))}function Af(e){const t=Yi(),[n,i]=He(e,["ref","onClick"]);return v(ba,Ne({ref(a){var o=Nt(t.setTriggerRef,n.ref);typeof o=="function"&&o(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=>{it(a,n.onClick),t.toggle()}},i))}var ze=Object.assign(Nf,{CloseButton:vf,Content:yf,Description:Cf,Overlay:Rf,Portal:If,Title:Of,Trigger:Af});const jv=e=>typeof e=="function",zs=(e,t)=>jv(e)?e(t):e;var ht;(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"})(ht||(ht={}));const Ks=Symbol("store-raw"),Kr=Symbol("store-node"),ei=Symbol("store-has"),wf=Symbol("store-self");function xf(e){let t=e[ar];if(!t&&(Object.defineProperty(e,ar,{value:t=new Proxy(e,ty)}),!Array.isArray(e))){const n=Object.keys(e),i=Object.getOwnPropertyDescriptors(e);for(let r=0,a=n.length;r<a;r++){const o=n[r];i[o].get&&Object.defineProperty(e,o,{enumerable:i[o].enumerable,get:i[o].get.bind(t)})}}return t}function na(e){let t;return e!=null&&typeof e=="object"&&(e[ar]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function ia(e,t=new Set){let n,i,r,a;if(n=e!=null&&e[Ks])return n;if(!na(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let o=0,s=e.length;o<s;o++)r=e[o],(i=ia(r,t))!==r&&(e[o]=i)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);const o=Object.keys(e),s=Object.getOwnPropertyDescriptors(e);for(let l=0,c=o.length;l<c;l++)a=o[l],!s[a].get&&(r=e[a],(i=ia(r,t))!==r&&(e[a]=i))}return e}function qs(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Eo(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 Jv(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===ar||t===Kr||(delete n.value,delete n.writable,n.get=()=>e[ar][t]),n}function Df(e){sd()&&Eo(qs(e,Kr),wf)()}function ey(e){return Df(e),Reflect.ownKeys(e)}const ty={get(e,t,n){if(t===Ks)return e;if(t===ar)return n;if(t===ad)return Df(e),n;const i=qs(e,Kr),r=i[t];let a=r?r():e[t];if(t===Kr||t===ei||t==="__proto__")return a;if(!r){const o=Object.getOwnPropertyDescriptor(e,t);sd()&&(typeof a!="function"||e.hasOwnProperty(t))&&!(o&&o.get)&&(a=Eo(i,t,a)())}return na(a)?xf(a):a},has(e,t){return t===Ks||t===ar||t===ad||t===Kr||t===ei||t==="__proto__"?!0:(sd()&&Eo(qs(e,ei),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:ey,getOwnPropertyDescriptor:Jv};function ra(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[ei]&&e[ei][t]&&r!==void 0&&e[ei][t].$()):(e[t]=n,e[ei]&&e[ei][t]&&r===void 0&&e[ei][t].$());let o=qs(e,Kr),s;if((s=Eo(o,t,r))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let l=e.length;l<a;l++)(s=o[l])&&s.$();(s=Eo(o,"length",a))&&s.$(e.length)}(s=o[wf])&&s.$()}function Lf(e,t){const n=Object.keys(t);for(let i=0;i<n.length;i+=1){const r=n[i];ra(e,r,t[r])}}function ny(e,t){if(typeof t=="function"&&(t=t(e)),t=ia(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&&ra(e,n,r)}ra(e,"length",i)}else Lf(e,t)}function za(e,t,n=[]){let i,r=e;if(t.length>1){i=t.shift();const o=typeof i,s=Array.isArray(e);if(Array.isArray(i)){for(let l=0;l<i.length;l++)za(e,[i[l]].concat(t),n);return}else if(s&&o==="function"){for(let l=0;l<e.length;l++)i(e[l],l)&&za(e,[l].concat(t),n);return}else if(s&&o==="object"){const{from:l=0,to:c=e.length-1,by:d=1}=i;for(let u=l;u<=c;u+=d)za(e,[u].concat(t),n);return}else if(t.length>1){za(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=ia(a),i===void 0||na(r)&&na(a)&&!Array.isArray(a)?Lf(r,a):ra(e,i,a))}function iy(...[e,t]){const n=ia(e||{}),i=Array.isArray(n),r=xf(n);function a(...o){WT(()=>{i&&o.length===1?ny(n,o[0]):za(n,o)})}return[r,a]}const Qs=new WeakMap,Mf={get(e,t){if(t===Ks)return e;const n=e[t];let i;return na(n)?Qs.get(n)||(Qs.set(n,i=new Proxy(n,Mf)),i):n},set(e,t,n){return ra(e,t,ia(n)),!0},deleteProperty(e,t){return ra(e,t,void 0,!0),!0}};function ts(e){return t=>{if(na(t)){let n;(n=Qs.get(t))||Qs.set(t,n=new Proxy(t,Mf)),e(n)}return t}}const[nr,Ei]=iy({toasts:[],pausedAt:void 0}),ry=()=>{const{pausedAt:e,toasts:t}=nr;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&&Dn({type:ht.DISMISS_TOAST,toastId:r.id});return}return setTimeout(()=>{Dn({type:ht.DISMISS_TOAST,toastId:r.id})},a)})},to=new Map,km=(e,t)=>{if(to.has(e))return;const n=setTimeout(()=>{to.delete(e),Dn({type:ht.REMOVE_TOAST,toastId:e})},t);to.set(e,n)},ay=e=>{const t=to.get(e);to.delete(e),t&&clearTimeout(t)},Dn=e=>{switch(e.type){case ht.ADD_TOAST:Ei("toasts",r=>{const a=r;return[e.toast,...a]});break;case ht.DISMISS_TOAST:const{toastId:t}=e,n=nr.toasts;if(t){const r=n.find(a=>a.id===t);r&&km(t,r.unmountDelay),Ei("toasts",a=>a.id===t,ts(a=>a.visible=!1))}else n.forEach(r=>{km(r.id,r.unmountDelay)}),Ei("toasts",r=>r.id!==void 0,ts(r=>r.visible=!1));break;case ht.REMOVE_TOAST:if(!e.toastId){Ei("toasts",[]);break}Ei("toasts",r=>r.filter(o=>o.id!==e.toastId));break;case ht.UPDATE_TOAST:e.toast.id&&ay(e.toast.id),Ei("toasts",r=>r.id===e.toast.id,r=>({...r,...e.toast}));break;case ht.UPSERT_TOAST:nr.toasts.find(r=>r.id===e.toast.id)?Dn({type:ht.UPDATE_TOAST,toast:e.toast}):Dn({type:ht.ADD_TOAST,toast:e.toast});break;case ht.START_PAUSE:Ei(ts(r=>{r.pausedAt=Date.now(),r.toasts.forEach(a=>{a.paused=!0})}));break;case ht.END_PAUSE:const i=e.time-(nr.pausedAt||0);Ei(ts(r=>{r.pausedAt=void 0,r.toasts.forEach(a=>{a.pauseDuration+=i,a.paused=!1})}));break}},oy={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},qr={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},kf={position:"top-right",toastOptions:qr,gutter:8,containerStyle:{},containerClassName:""},ns="16px",sy={position:"fixed","z-index":9999,top:ns,bottom:ns,left:ns,right:ns,"pointer-events":"none"},ly=(()=>{let e=0;return()=>String(++e)})(),cy=e=>{fy(t=>({containerClassName:e.containerClassName??t.containerClassName,containerStyle:e.containerStyle??t.containerStyle,gutter:e.gutter??t.gutter,position:e.position??t.position,toastOptions:{...e.toastOptions}}))},dy=(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}},uy=(e,t)=>{const n=e.getBoundingClientRect();n.height!==t.height&&Dn({type:ht.UPDATE_TOAST,toast:{id:t.id,height:n.height}})},_y=(e,t)=>{const{toasts:n}=nr,i=Or().gutter||kf.gutter||8,r=n.filter(l=>(l.position||t)===t&&l.height),a=r.findIndex(l=>l.id===e.id),o=r.filter((l,c)=>c<a&&l.visible).length;return r.slice(0,o).reduce((l,c)=>l+i+(c.height||0),0)},my=(e,t)=>(e.position||t).includes("top")?1:-1,py={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"},gy={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},is={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},Xs=e=>({calcMode:"spline",keyTimes:"0; 1",keySplines:e}),[Or,fy]=q(kf),Ey=(e,t="blank",n)=>{var i,r,a;return{...qr,...Or().toastOptions,...n,type:t,message:e,pauseDuration:0,createdAt:Date.now(),visible:!0,id:n.id||ly(),paused:!1,style:{...qr.style,...(i=Or().toastOptions)==null?void 0:i.style,...n.style},duration:n.duration||((r=Or().toastOptions)==null?void 0:r.duration)||oy[t],position:n.position||((a=Or().toastOptions)==null?void 0:a.position)||Or().position||qr.position}},Vo=e=>(t,n={})=>od(()=>{const i=nr.toasts.find(a=>a.id===n.id),r=Ey(t,e,{...i,duration:void 0,...n});return Dn({type:ht.UPSERT_TOAST,toast:r}),r.id}),En=(e,t)=>Vo("blank")(e,t);ha(()=>En);En.error=Vo("error");En.success=Vo("success");En.loading=Vo("loading");En.custom=Vo("custom");En.dismiss=e=>{Dn({type:ht.DISMISS_TOAST,toastId:e})};En.promise=(e,t,n)=>{const i=En.loading(t.loading,{...n});return e.then(r=>(En.success(zs(t.success,r),{id:i,...n}),r)).catch(r=>{En.error(zs(t.error,r),{id:i,...n})}),e};En.remove=e=>{Dn({type:ht.REMOVE_TOAST,toastId:e})};var hy=G("<div><style>.sldt-active{z-index:9999;}.sldt-active>*{pointer-events:auto;}");const Sy=e=>(ge(()=>{cy(e)}),ge(()=>{const t=ry();Oe(()=>{t&&t.forEach(n=>n&&clearTimeout(n))})}),(()=>{var t=hy();return t.firstChild,C(t,v(Ge,{get each(){return nr.toasts},children:n=>v(yy,{toast:n})}),null),de(n=>{var i={...sy,...e.containerStyle},r=e.containerClassName;return n.e=In(t,i,n.e),r!==n.t&&Be(t,n.t=r),n},{e:void 0,t:void 0}),t})());var rs=G("<div>"),by=G("<div><div>");const Ty=e=>{let t;return ge(()=>{if(!t)return;const n=my(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=by(),i=n.firstChild,r=t;return typeof r=="function"?Tt(r,n):t=n,C(n,v(Eu,{get children(){return[v(ni,{get when(){return e.toast.icon},get children(){var a=rs();return C(a,()=>e.toast.icon),de(o=>In(a,is,o)),a}}),v(ni,{get when(){return e.toast.type==="loading"},get children(){var a=rs();return C(a,v(xy,Ne(()=>e.toast.iconTheme))),de(o=>In(a,is,o)),a}}),v(ni,{get when(){return e.toast.type==="success"},get children(){var a=rs();return C(a,v(Ny,Ne(()=>e.toast.iconTheme))),de(o=>In(a,is,o)),a}}),v(ni,{get when(){return e.toast.type==="error"},get children(){var a=rs();return C(a,v(Ay,Ne(()=>e.toast.iconTheme))),de(o=>In(a,is,o)),a}})]}}),i),Hn(i,Ne(()=>e.toast.ariaProps),!1,!0),C(i,()=>zs(e.toast.message,e.toast)),de(a=>{var o=e.toast.className,s={...py,...e.toast.style},l=gy;return o!==a.e&&Be(n,a.e=o),a.t=In(n,s,a.t),a.a=In(i,l,a.a),a},{e:void 0,t:void 0,a:void 0}),n})()};var vy=G("<div>");const yy=e=>{const t=()=>{const r=e.toast.position||qr.position,a=_y(e.toast,r);return dy(r,a)},n=V(()=>t());let i;return Zt(()=>{i&&uy(i,e.toast)}),(()=>{var r=vy();r.addEventListener("mouseleave",()=>Dn({type:ht.END_PAUSE,time:Date.now()})),r.addEventListener("mouseenter",()=>Dn({type:ht.START_PAUSE,time:Date.now()}));var a=i;return typeof a=="function"?Tt(a,r):i=r,C(r,(()=>{var o=ke(()=>e.toast.type==="custom");return()=>o()?zs(e.toast.message,e.toast):v(Ty,{get toast(){return e.toast},get position(){return e.toast.position||qr.position}})})()),de(o=>{var s=n(),l=e.toast.visible?"sldt-active":"";return o.e=In(r,s,o.e),l!==o.t&&Be(r,o.t=l),o},{e:void 0,t:void 0}),r})()};var Cy=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),Ry=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 Pf=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=Cy(),i=n.firstChild,r=i.nextSibling;return Hn(i,t,!0,!1),Hn(r,t,!0,!1),de(()=>Pe(n,"fill",e.fill)),n})()},Ff=e=>{const t={dur:"1s",begin:e.begin||"320ms",fill:"freeze",...Xs("0.0 0.0 0.2 1")};return(()=>{var n=Ry(),i=n.firstChild,r=i.nextSibling;return Hn(i,t,!0,!1),Hn(r,t,!0,!1),de(()=>Pe(n,"fill",e.fill)),n})()};var Iy=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 Ny=e=>{const t=e.primary||"#34C759";return(()=>{var n=Iy(),i=n.firstChild,r=i.firstChild;return C(n,v(Pf,{fill:t}),i),C(n,v(Ff,{fill:t,begin:"350ms"}),i),Hn(r,Ne(()=>Xs("0.0, 0.0, 0.58, 1.0")),!0,!1),de(()=>Pe(i,"stroke",e.secondary||"#FCFCFC")),n})()};var Oy=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 Ay=e=>{const t=e.primary||"#FF3B30";return(()=>{var n=Oy(),i=n.firstChild,r=i.firstChild,a=i.nextSibling,o=a.firstChild;return C(n,v(Pf,{fill:t}),i),C(n,v(Ff,{fill:t}),i),Hn(r,Ne(()=>Xs("0.0, 0.0, 0.58, 1.0")),!0,!1),Hn(o,Ne(()=>Xs("0.0, 0.0, 0.58, 1.0")),!0,!1),de(s=>{var l=e.secondary||"#FFFFFF",c=e.secondary||"#FFFFFF";return l!==s.e&&Pe(i,"stroke",s.e=l),c!==s.t&&Pe(a,"fill",s.t=c),s},{e:void 0,t:void 0}),n})()};var wy=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 xy=e=>(()=>{var t=wy(),n=t.firstChild,i=n.nextSibling;return de(r=>{var a=e.primary||"#E5E7EB",o=e.secondary||"#4b5563";return a!==r.e&&Pe(n,"stroke",r.e=a),o!==r.t&&Pe(i,"stroke",r.t=o),r},{e:void 0,t:void 0}),t})(),[ud,Au]=q(null);function ri(e,t){Au({type:"alert",message:e,...t})}function Dy(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(i=>{Au({type:"confirm",message:e,...t,resolve:i})})}function Ly(){Au(null)}var My=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>'),ky=G('<div class="mt-6 flex justify-end gap-3"><button type=button class=button-primary>'),Py=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),Fy=G('<p class="mt-2 text-secondary">'),Uy=G("<button type=button class=button-secondary>");const By={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 bc(e,t){var i,r,a,o;const n=t??ud();(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&&((o=n==null?void 0:n.onConfirm)==null||o.call(n)),Ly()}const $y=()=>{let e;return ge(()=>{ud()&&queueMicrotask(()=>{e==null||e.focus()})}),v(j,{get when(){return ud()},keyed:!0,children:t=>{const n=t.variant??"info",i=By[n],r=t.title||i.fallbackTitle,a=t.type==="confirm",o=t.confirmLabel||(a?"Confirm":"OK"),s=t.cancelLabel||"Cancel";return v(ze,{open:!0,modal:!0,onOpenChange:l=>{l||bc(!1,t)},get children(){return v(ze.Portal,{get children(){return[v(ze.Overlay,{class:"modal-overlay"}),(()=>{var l=Py();return C(l,v(ze.Content,{class:"modal-surface w-full max-w-sm p-6 border border-base shadow-2xl",tabIndex:-1,get children(){return[(()=>{var c=My(),d=c.firstChild,u=d.nextSibling;return C(d,()=>i.symbol),C(u,v(ze.Title,{class:"text-lg font-semibold text-primary",children:r}),null),C(u,v(ze.Description,{class:"text-sm text-secondary mt-1 whitespace-pre-line",get children(){return[ke(()=>t.message),ke(()=>ke(()=>!!t.detail)()&&(()=>{var _=Fy();return C(_,()=>t.detail),_})())]}}),null),de(_=>{var m=i.badgeBg,p=i.badgeBorder,g=i.badgeText;return m!==_.e&&zr(d,"background-color",_.e=m),p!==_.t&&zr(d,"border-color",_.t=p),g!==_.a&&zr(d,"color",_.a=g),_},{e:void 0,t:void 0,a:void 0}),c})(),(()=>{var c=ky(),d=c.firstChild;return C(c,a&&(()=>{var u=Uy();return u.$$click=()=>bc(!1,t),C(u,s),u})(),d),d.$$click=()=>bc(!0,t),Tt(u=>{e=u},d),C(d,o),c})()]}})),l})()]}})}})}})};mt(["click"]);const vr={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 Gy=G("<svg>");const Yy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),pt=e=>{const[t,n]=He(e,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var i=Gy();return Hn(i,Ne(vr,{get width(){return t.size??vr.width},get height(){return t.size??vr.height},get stroke(){return t.color??vr.stroke},get"stroke-width"(){return ke(()=>!!t.absoluteStrokeWidth)()?Number(t.strokeWidth??vr["stroke-width"])*24/Number(t.size):Number(t.strokeWidth??vr["stroke-width"])},get class(){return`lucide lucide-${Yy((t==null?void 0:t.name)??"icon")} ${t.class!=null?t.class:""}`}},n),!0,!0),C(i,v(Ge,{get each(){return t.iconNode},children:([r,a])=>v(sf,Ne({component:r},a))})),i})()},Vy=[["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"}]],Hy=e=>v(pt,Ne(e,{name:"AlertCircle",iconNode:Vy})),Wy=[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]],Uf=e=>v(pt,Ne(e,{name:"ArrowUpLeft",iconNode:Wy})),zy=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ky=e=>v(pt,Ne(e,{name:"Check",iconNode:zy})),qy=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],wu=e=>v(pt,Ne(e,{name:"ChevronDown",iconNode:qy})),Qy=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Xy=e=>v(pt,Ne(e,{name:"ChevronRight",iconNode:Qy})),Zy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],jy=e=>v(pt,Ne(e,{name:"Clock",iconNode:Zy})),Jy=[["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"}]],eC=e=>v(pt,Ne(e,{name:"Copy",iconNode:Jy})),tC=[["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"}]],nC=e=>v(pt,Ne(e,{name:"File",iconNode:tC})),iC=[["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"}]],Bf=e=>v(pt,Ne(e,{name:"FolderOpen",iconNode:iC})),rC=[["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"}]],aC=e=>v(pt,Ne(e,{name:"FolderPlus",iconNode:rC})),oC=[["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"}]],xu=e=>v(pt,Ne(e,{name:"Folder",iconNode:oC})),sC=[["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"}]],lC=e=>v(pt,Ne(e,{name:"Globe",iconNode:sC})),cC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],dC=e=>v(pt,Ne(e,{name:"Info",iconNode:cC})),uC=[["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"}]],Pm=e=>v(pt,Ne(e,{name:"Key",iconNode:uC})),_C=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ho=e=>v(pt,Ne(e,{name:"Loader2",iconNode:_C})),mC=[["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"}]],pC=e=>v(pt,Ne(e,{name:"MessageSquare",iconNode:mC})),gC=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Du=e=>v(pt,Ne(e,{name:"Plus",iconNode:gC})),fC=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],EC=e=>v(pt,Ne(e,{name:"Search",iconNode:fC})),hC=[["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"}]],SC=e=>v(pt,Ne(e,{name:"Settings",iconNode:hC})),bC=[["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"}]],Lu=e=>v(pt,Ne(e,{name:"Trash2",iconNode:bC})),TC=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],kl=e=>v(pt,Ne(e,{name:"X",iconNode:TC})),Fm="http://127.0.0.1:9898";var of;const vC=typeof window<"u"?(of=window.location)==null?void 0:of.origin:void 0,yC=typeof window<"u"?window.__CODENOMAD_API_BASE__??vC??Fm:Fm,CC=typeof window<"u"?window.__CODENOMAD_EVENTS_URL__??"/api/events":"/api/events",Zs=yC,Um=IC(Zs,CC),RC=Zs;function IC(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 Bm="[HTTP]";function as(e,t){if(t){console.log(`${Bm} ${e}`,t);return}console.log(`${Bm} ${e}`)}async function At(e,t){const n=Zs?new URL(e,Zs).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();as(`${r} ${e}`);try{const o=await fetch(n,{...t,headers:i});if(!o.ok){const l=await o.text();throw as(`${r} ${e} -> ${o.status}`,{durationMs:Date.now()-a,error:l}),new Error(l||`Request failed with ${o.status}`)}const s=Date.now()-a;return as(`${r} ${e} -> ${o.status}`,{durationMs:s}),o.status===204?void 0:await o.json()}catch(o){throw as(`${r} ${e} failed`,{durationMs:Date.now()-a,error:o}),o}}const Xt={fetchWorkspaces(){return At("/api/workspaces")},createWorkspace(e){return At("/api/workspaces",{method:"POST",body:JSON.stringify(e)})},fetchServerMeta(){return At("/api/meta")},deleteWorkspace(e){return At(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})},listWorkspaceFiles(e,t="."){const n=new URLSearchParams({path:t});return At(`/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),At(`/api/workspaces/${encodeURIComponent(e)}/files/search?${r.toString()}`)},readWorkspaceFile(e,t){const n=new URLSearchParams({path:t});return At(`/api/workspaces/${encodeURIComponent(e)}/files/content?${n.toString()}`)},fetchConfig(){return At("/api/config/app")},updateConfig(e){return At("/api/config/app",{method:"PUT",body:JSON.stringify(e)})},listBinaries(){return At("/api/config/binaries")},createBinary(e){return At("/api/config/binaries",{method:"POST",body:JSON.stringify(e)})},updateBinary(e,t){return At(`/api/config/binaries/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})},deleteBinary(e){return At(`/api/config/binaries/${encodeURIComponent(e)}`,{method:"DELETE"})},validateBinary(e){return At("/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 At(i?`/api/filesystem?${i}`:"/api/filesystem")},readInstanceData(e){return At(`/api/storage/instances/${encodeURIComponent(e)}`)},writeInstanceData(e,t){return At(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})},deleteInstanceData(e){return At(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"DELETE"})},connectEvents(e,t){console.log(`[SSE] Connecting to ${Um}`);const n=new EventSource(Um);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}},$m=1e3,NC=1e4,Gm="[SSE]";function os(e,t){if(t){console.log(`${Gm} ${e}`,t);return}console.log(`${Gm} ${e}`)}class OC{constructor(){this.handlers=new Map,this.source=null,this.retryDelay=$m,this.connect()}connect(){this.source&&this.source.close(),os("Connecting to backend events stream"),this.source=Xt.connectEvents(t=>this.dispatch(t),()=>this.scheduleReconnect()),this.source.onopen=()=>{os("Events stream connected"),this.retryDelay=$m}}scheduleReconnect(){this.source&&(this.source.close(),this.source=null),os("Events stream disconnected, scheduling reconnect",{delayMs:this.retryDelay}),setTimeout(()=>{this.retryDelay=Math.min(this.retryDelay*2,NC),this.connect()},this.retryDelay)}dispatch(t){var n,i;os(`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 So=new OC,Ym={messageHistory:[],agentModelSelections:{}};function Vm(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 AC{constructor(){this.configChangeListeners=new Set,this.configCache=null,this.loadPromise=null,this.instanceDataCache=new Map,this.instanceDataListeners=new Map,this.instanceLoadPromises=new Map,So.on("config.appChanged",t=>{t.type==="config.appChanged"&&this.setConfigCache(t.config)}),So.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=Xt.fetchConfig().then(t=>(this.setConfigCache(t),t)).finally(()=>{this.loadPromise=null})),this.loadPromise)}async updateConfig(t){const n=await Xt.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=Xt.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 Xt.writeInstanceData(t,i),this.setInstanceDataCache(t,i)}async deleteInstanceData(t){await Xt.deleteInstanceData(t),this.setInstanceDataCache(t,Ym)}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&&Vm(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??Ym,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&&Vm(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 or=new AC,Pl={messageHistory:[],agentModelSelections:{}},[Mu,$f]=q(new Map),ss=new Map,aa=new Map;function Gf(e){const t=e??Pl;return{...t,messageHistory:Array.isArray(t.messageHistory)?[...t.messageHistory]:[],agentModelSelections:{...t.agentModelSelections??{}}}}function Hm(e){if(aa.has(e))return;const t=or.onInstanceDataChanged(e,n=>{js(e,n)});aa.set(e,t)}function wC(e){const t=aa.get(e);t&&(t(),aa.delete(e))}function js(e,t){$f(n=>{const i=new Map(n);return i.set(e,Gf(t)),i})}async function gr(e){if(!e||Mu().has(e))return;if(ss.has(e)){await ss.get(e);return}const t=or.loadInstanceData(e).then(n=>{js(e,n),Hm(e)}).catch(n=>{console.warn("Failed to load instance data:",n),js(e,Pl),Hm(e)}).finally(()=>{ss.delete(e)});ss.set(e,t),await t}async function ku(e,t){if(!e)return;await gr(e);const n=Mu().get(e)??Pl,i=Gf(n);t(i);try{await or.saveInstanceData(e,i)}catch(r){console.warn("Failed to persist instance data:",r)}js(e,i)}function Pu(e){return Mu().get(e)??Pl}function xC(e){$f(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),wC(e)}const DC=jt(),LC={getInstanceConfig:Pu,ensureInstanceConfig:gr,updateInstanceConfig:ku,clearInstanceConfig:xC},MC=e=>(Oe(()=>{for(const t of aa.values())t();aa.clear()}),v(DC.Provider,{value:LC,get children(){return e.children}})),kC=20,PC=5,Wi={showThinkingBlocks:!1,environmentVariables:{},modelRecents:[],diffViewMode:"split",toolOutputExpansion:"expanded",diagnosticsExpansion:"expanded"};function Yf(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 Fl(e){const t=e??{},n={...Wi.environmentVariables,...t.environmentVariables??{}},r=(t.modelRecents??Wi.modelRecents).map(a=>({...a}));return{showThinkingBlocks:t.showThinkingBlocks??Wi.showThinkingBlocks,lastUsedBinary:t.lastUsedBinary??Wi.lastUsedBinary,environmentVariables:n,modelRecents:r,diffViewMode:t.diffViewMode??Wi.diffViewMode,toolOutputExpansion:t.toolOutputExpansion??Wi.toolOutputExpansion,diagnosticsExpansion:t.diagnosticsExpansion??Wi.diagnosticsExpansion}}const[Vi,FC]=q(Wf()),UC=V(()=>Vi()),[Vf,BC]=q(!1),_t=V(()=>Vi().preferences),$C=V(()=>Vi().recentFolders??[]),GC=V(()=>Vi().opencodeBinaries??[]),Hf=V(()=>Vi().theme??"dark");let ls=null;function Ul(e){return{preferences:Fl(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 Wf(){return Ul()}function YC(e){var i;const t=!!((i=e==null?void 0:e.preferences)!=null&&i.agentModelSelections);return{cleaned:Ul(e),migrated:t}}async function Fu(e){try{const t=e??await or.loadConfig(),{cleaned:n,migrated:i}=YC(t);_d(n),i&&or.updateConfig(n).catch(r=>{console.error("Failed to persist legacy config cleanup:",r)})}catch(t){console.error("Failed to load config:",t),_d(Wf())}}function _d(e){FC(Ul(e)),BC(!0)}function VC(){return Ul(Vi())}function HC(e,t){if(Yf(e,t))return;const n=zf(e,t);n.length>0&&console.debug("[Config] Changes",n)}function zf(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]),o=[];for(const s of a){const l=[...n,s],c=e[s],d=t[s];o.push(...zf(c,d,l))}return o}function pi(e){const t=Vi(),n=VC();e(n),HC(t,n),_d(n),WC(n)}async function WC(e){try{await Uu(),await or.updateConfig(e)}catch(t){console.error("Failed to save config:",t),Fu().catch(n=>{console.error("Failed to refresh config:",n)})}}function zC(e){Hf()!==e&&pi(t=>{t.theme=e})}async function Uu(){Vf()||(ls||(ls=Fu().finally(()=>{ls=null})),await ls)}function Kf(e,t){const n=t.filter(i=>i.path!==e);return n.unshift({path:e,lastAccessed:Date.now()}),n.slice(0,kC)}function Bu(e,t,n){const i=Date.now(),r=n.find(o=>o.path===e);if(r){const o={...r,lastUsed:i},s=n.filter(l=>l.path!==e);return[o,...s]}return[t?{path:e,version:t,lastUsed:i}:{path:e,lastUsed:i},...n].slice(0,10)}function fr(e){const t=Vi().preferences,n=Fl({...t,...e});Yf(t,n)||pi(i=>{i.preferences=n})}function KC(e){_t().diffViewMode!==e&&fr({diffViewMode:e})}function qC(e){_t().toolOutputExpansion!==e&&fr({toolOutputExpansion:e})}function QC(e){_t().diagnosticsExpansion!==e&&fr({diagnosticsExpansion:e})}function XC(){fr({showThinkingBlocks:!_t().showThinkingBlocks})}function ZC(e){pi(t=>{t.recentFolders=Kf(e,t.recentFolders)})}function jC(e){pi(t=>{t.recentFolders=t.recentFolders.filter(n=>n.path!==e)})}function JC(e,t){pi(n=>{n.opencodeBinaries=Bu(e,t,n.opencodeBinaries)})}function eR(e){pi(t=>{t.opencodeBinaries=t.opencodeBinaries.filter(n=>n.path!==e)})}function tR(e){const t=e||_t().lastUsedBinary||"opencode";pi(n=>{n.preferences=Fl({...n.preferences,lastUsedBinary:t}),n.opencodeBinaries=Bu(t,void 0,n.opencodeBinaries)})}function nR(e,t){pi(n=>{const i=t&&t.trim().length>0?t:n.preferences.lastUsedBinary||"opencode";n.recentFolders=Kf(e,n.recentFolders),n.preferences=Fl({...n.preferences,lastUsedBinary:i}),n.opencodeBinaries=Bu(i,void 0,n.opencodeBinaries)})}function $u(e){fr({environmentVariables:e})}function iR(e,t){const i={..._t().environmentVariables||{},[e]:t};$u(i)}function rR(e){const t=_t().environmentVariables||{},{[e]:n,...i}=t;$u(i)}function qf(e){if(!e.providerId||!e.modelId)return;const n=(_t().modelRecents??[]).filter(r=>r.providerId!==e.providerId||r.modelId!==e.modelId),i=[e,...n].slice(0,PC);fr({modelRecents:i})}async function Bl(e,t,n){!e||!t||!n.providerId||!n.modelId||(await gr(e),await ku(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 Qf(e,t){return!e||!t?void 0:(await gr(e),(Pu(e).agentModelSelections??{})[t])}Uu().catch(e=>{console.error("Failed to initialize config:",e)});const Xf=jt(),aR={isLoaded:Vf,config:UC,preferences:_t,recentFolders:$C,opencodeBinaries:GC,themePreference:Hf,setThemePreference:zC,updateConfig:pi,toggleShowThinkingBlocks:XC,setDiffViewMode:KC,setToolOutputExpansion:qC,setDiagnosticsExpansion:QC,addRecentFolder:ZC,removeRecentFolder:jC,addOpenCodeBinary:JC,removeOpenCodeBinary:eR,updateLastUsedBinary:tR,recordWorkspaceLaunch:nR,updatePreferences:fr,updateEnvironmentVariables:$u,addEnvironmentVariable:iR,removeEnvironmentVariable:rR,addRecentModelPreference:qf,setAgentModelPreference:Bl,getAgentModelPreference:Qf},oR=e=>(Zt(()=>{Uu().catch(n=>{console.error("Failed to initialize config:",n)});const t=or.onConfigChanged(n=>{Fu(n).catch(i=>{console.error("Failed to refresh config:",i)})});return()=>{t()}}),v(Xf.Provider,{value:aR,get children(){return e.children}}));function Hi(){const e=un(Xf);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e}var sR=G('<p class="text-xs text-muted mt-1 font-mono break-all">Root: '),lR=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'),cR=G('<div class="flex items-center gap-2 px-4 py-2 text-xs text-secondary"><span>Loading <!>…'),dR=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'),uR=G('<div class="flex items-center gap-2"><span>Loading <!>…'),_R=G('<div class="flex items-center justify-center py-6 text-sm text-secondary">'),mR=G("<span class=text-red-500>"),pR=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'),gR=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'),fR=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 ER=200;function Tc(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 Pa(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 hR=e=>{const[t,n]=q(""),[i,r]=q([]),[a,o]=q(null),[s,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([]),o(null),l(null)}async function T(N,I=!1){const x=Tc(N);if(E.has(x)&&h.has(x))return I&&(o(h.get(x)??null),r(E.get(x)??[])),h.get(x);if(f.has(x)){const W=await f.get(x);return I&&(o(W),r(E.get(x)??[])),W}const L=(async()=>{l(x);const W=await Xt.listFileSystem(x==="."?".":x,{includeFiles:e.mode==="files"});return E.set(x,W.entries),h.set(x,W.metadata),t()||n(W.metadata.rootPath),s()===x&&l(null),W.metadata})().catch(W=>{throw s()===x&&l(null),W});f.set(x,L);try{const W=await L;if(I){const J=Tc(W.currentPath);o(W),r(E.get(J)??E.get(x)??[])}return W}finally{f.delete(x)}}async function b(){d(null),S();try{const N=await T(".",!0);n(N.rootPath),r(E.get(Tc(N.currentPath))??[])}catch(N){const I=N instanceof Error?N.message:"Unable to load filesystem";d(I)}}function R(){const N=s();return N?N==="."?t()||"workspace root":Pa(t(),N):"filesystem"}function y(){const N=a();return N?N.pathKind==="relative"?Pa(t(),N.currentPath):N.displayPath:t()}function O(N){N.target===N.currentTarget&&e.onClose()}function P(N){const I=Pa(t(),N.path);e.onSelect(I)}function w(N){T(N,!0).catch(I=>{console.error("Failed to open directory",I),d(I instanceof Error?I.message:"Unable to open directory")})}function F(){var I;const N=(I=a())==null?void 0:I.parentPath;N&&w(N)}const Y=V(()=>{const N=u().trim().toLowerCase(),I=i().filter(x=>e.mode==="directories"?x.type==="directory":!0);return N?I.filter(x=>Pa(t(),x.path).toLowerCase().includes(N)||x.name.toLowerCase().includes(N)):I}),B=V(()=>Y().slice(0,ER)),A=V(()=>{const N=[],I=a();I!=null&&I.parentPath&&N.push({type:"up",path:I.parentPath});for(const x of B())N.push({type:"entry",entry:x});return N});return ge(()=>{const N=B();if(N.length===0){p(0);return}m()>=N.length&&p(N.length-1)}),ge(()=>{if(!e.open)return;_(""),p(0),b(),setTimeout(()=>g==null?void 0:g.focus(),50);const N=I=>{if(!e.open)return;const x=B();if(I.key==="Escape"){I.preventDefault(),e.onClose();return}if(x.length!==0){if(I.key==="ArrowDown")I.preventDefault(),p(L=>Math.min(L+1,x.length-1));else if(I.key==="ArrowUp")I.preventDefault(),p(L=>Math.max(L-1,0));else if(I.key==="Enter"){I.preventDefault();const L=x[m()];L&&P(L)}}};window.addEventListener("keydown",N),Oe(()=>{window.removeEventListener("keydown",N),S(),n(""),d(null)})}),v(j,{get when(){return e.open},get children(){var N=dR(),I=N.firstChild,x=I.firstChild,L=x.firstChild,W=L.firstChild,J=W.firstChild,se=J.nextSibling,pe=W.nextSibling,be=pe.firstChild,ue=L.nextSibling,ne=ue.firstChild,Se=ne.nextSibling,fe=Se.firstChild,re=fe.nextSibling,Ce=ue.nextSibling;return N.$$click=O,C(J,()=>e.title),C(se,()=>e.description||"Search for a path under the configured workspace root."),C(W,v(j,{get when(){return t()},get children(){var he=sR();return he.firstChild,C(he,t,null),he}}),null),Gi(pe,"click",e.onClose,!0),C(pe,v(kl,{class:"w-4 h-4"}),be),C(fe,v(EC,{class:"w-4 h-4"})),re.$$input=he=>_(he.currentTarget.value),Tt(he=>{g=he},re),C(x,v(j,{get when(){return e.mode==="directories"},get children(){var he=lR(),K=he.firstChild,ie=K.firstChild,M=ie.firstChild,U=M.nextSibling,z=ie.nextSibling;return C(U,y),z.$$click=()=>e.onSelect(y()),he}}),Ce),C(Ce,v(j,{get when(){return i().length>0},get fallback(){return(()=>{var he=_R();return C(he,v(j,{get when(){return s()!==null},get fallback(){return(()=>{var K=mR();return C(K,c),K})()},get children(){var K=uR(),ie=K.firstChild,M=ie.firstChild,U=M.nextSibling;return U.nextSibling,C(K,v(ho,{class:"w-4 h-4 animate-spin"}),ie),C(ie,R,U),K}})),he})()},get children(){return[v(j,{get when(){return s()},get children(){var he=cR(),K=he.firstChild,ie=K.firstChild,M=ie.nextSibling;return M.nextSibling,C(he,v(ho,{class:"w-3.5 h-3.5 animate-spin"}),K),C(K,R,M),he}}),v(j,{get when(){return A().length>0},get fallback(){return(()=>{var he=pR(),K=he.firstChild,ie=K.nextSibling;return ie.$$click=b,he})()},get children(){return v(Ge,{get each(){return A()},children:he=>{if(he.type==="up")return(()=>{var U=gR(),z=U.firstChild,H=z.firstChild,te=H.firstChild;return H.$$click=F,C(te,v(Uf,{class:"w-4 h-4"})),U})();const K=he.entry,ie=()=>P(K),M=()=>{K.type==="directory"?w(K.path):ie()};return(()=>{var U=fR(),z=U.firstChild,H=z.firstChild,te=H.firstChild,Q=te.nextSibling,ee=Q.firstChild,ce=ee.nextSibling,_e=H.nextSibling;return H.$$click=M,C(te,v(j,{get when(){return K.type==="directory"},get fallback(){return v(nC,{class:"w-4 h-4"})},get children(){return v(xu,{class:"w-4 h-4"})}})),C(ee,()=>K.name||K.path),C(ce,()=>Pa(t(),K.path)),_e.$$click=we=>{we.stopPropagation(),ie()},U})()}})}})]}})),de(()=>Pe(re,"placeholder",e.mode==="directories"?"Search for folders":"Search for files")),de(()=>re.value=u()),N}})};mt(["click","input"]);function SR(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 bR(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 SR(n)}catch(n){return console.error("[native] electron dialog failed",n),null}}async function TR(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 Zf(){switch(ld.host){case"electron":return bR;case"tauri":return TR;default:return null}}function jf(){return Zf()!==null}async function Jf(e){const t=Zf();return t?t(e):null}async function vR(e){return Jf({mode:"directory",...e??{}})}async function yR(e){return Jf({mode:"file",...e??{}})}var CR=G('<div class="selector-loading text-xs"><span>Checking versions…'),RR=G("<div class=selector-validation-error><div class=selector-validation-error-content><span class=selector-validation-error-text>"),IR=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">'),NR=G('<div class="text-xs font-mono truncate pl-6 text-muted">'),OR=G("<span class=selector-badge-version>v"),AR=G("<span class=selector-badge-time>Checking…"),wR=G("<span class=selector-badge-time>"),xR=G("<span class=selector-badge-time>Use binary from system PATH"),DR=G('<button type=button class="p-2 text-muted hover:text-primary"title="Remove binary">'),LR=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 MR=e=>{const{opencodeBinaries:t,addOpenCodeBinary:n,removeOpenCodeBinary:i,preferences:r,updatePreferences:a}=Hi(),[o,s]=q(""),[l,c]=q(!1),[d,u]=q(null),[_,m]=q(new Map),[p,g]=q(new Set),[E,h]=q(!1),f=jf(),S=()=>t(),T=()=>r().lastUsedBinary,b=V(()=>S().filter(L=>L.path!=="opencode")),R=V(()=>[{path:"opencode",isDefault:!0},...b()]),y=()=>e.selectedBinary||"opencode";ge(()=>{if(!e.selectedBinary&&T())e.onBinaryChange(T());else if(!e.selectedBinary){const L=S()[0];L&&e.onBinaryChange(L.path)}}),ge(()=>{const L=new Map(_());let W=!1;S().forEach(J=>{J.version&&!L.has(J.path)&&(L.set(J.path,J.version),W=!0)}),W&&m(L)}),ge(()=>{if(!e.isVisible)return;const L=_(),W=["opencode",...b().map(J=>J.path)].filter(J=>!L.has(J));W.length!==0&&setTimeout(()=>{W.forEach(J=>{O(J).catch(console.error)})},0)}),Oe(()=>{g(new Set),c(!1)});async function O(L){if(_().has(L)){const W=_().get(L);return W?{valid:!0,version:W}:{valid:!0}}if(p().has(L))return{valid:!1,error:"Already validating"};try{g(J=>new Set(J).add(L)),c(!0),u(null);const W=await Xt.validateBinary(L);if(W.valid&&W.version){const J=new Map(_());J.set(L,W.version),m(J)}return W}catch(W){return{valid:!1,error:W instanceof Error?W.message:String(W)}}finally{g(W=>{const J=new Set(W);return J.delete(L),J.size===0&&c(!1),J})}}async function P(){if(!e.disabled){if(u(null),f){const L=await yR({title:"Select OpenCode Binary"});L&&(s(L),w(L));return}h(!0)}}async function w(L){const W=await O(L);W.valid?(n(L,W.version),e.onBinaryChange(L),a({lastUsedBinary:L}),s(""),u(null)):u(W.error||"Invalid OpenCode binary")}function F(L){h(!1),s(L),w(L)}async function Y(){const L=o().trim();L&&await w(L)}function B(L){e.disabled||L!==e.selectedBinary&&(e.onBinaryChange(L),a({lastUsedBinary:L}))}function A(L,W){W.stopPropagation(),!e.disabled&&(i(L),e.selectedBinary===L&&(e.onBinaryChange("opencode"),a({lastUsedBinary:"opencode"})))}function N(L){if(!L)return"";const W=Math.floor((Date.now()-L)/1e3),J=Math.floor(W/60),se=Math.floor(J/60),pe=Math.floor(se/24);return pe>0?`${pe}d ago`:se>0?`${se}h ago`:J>0?`${J}m ago`:"just now"}function I(L){if(L==="opencode")return"opencode (system PATH)";const W=L.split(/[/\\]/);return W[W.length-1]??L}const x=L=>p().has(L);return[(()=>{var L=IR(),W=L.firstChild;W.firstChild;var J=W.nextSibling,se=J.firstChild,pe=se.firstChild,be=pe.nextSibling,ue=be.firstChild,ne=se.nextSibling,Se=ne.firstChild,fe=J.nextSibling;return C(W,v(j,{get when(){return l()},get children(){var re=CR(),Ce=re.firstChild;return C(re,v(ho,{class:"selector-loading-spinner"}),Ce),re}}),null),pe.$$keydown=re=>{re.key==="Enter"&&(re.preventDefault(),Y())},pe.$$input=re=>s(re.currentTarget.value),be.$$click=Y,C(be,v(Du,{class:"w-4 h-4"}),ue),ne.$$click=()=>void P(),C(ne,v(Bf,{class:"w-4 h-4"}),Se),C(J,v(j,{get when(){return d()},get children(){var re=RR(),Ce=re.firstChild,he=Ce.firstChild;return C(Ce,v(Hy,{class:"selector-validation-error-icon"}),he),C(he,d),re}}),null),C(fe,v(Ge,{get each(){return R()},children:re=>{const Ce=re.isDefault,he=()=>_().get(re.path)??re.version;return(()=>{var K=LR(),ie=K.firstChild,M=ie.firstChild,U=M.firstChild,z=U.firstChild,H=U.nextSibling;return ie.$$click=()=>B(re.path),C(U,v(Ky,{get class(){return`w-4 h-4 transition-opacity ${y()===re.path?"opacity-100":"opacity-0"}`}}),z),C(z,()=>I(re.path)),C(M,v(j,{when:!Ce,get children(){var te=NR();return C(te,()=>re.path),te}}),H),C(H,v(j,{get when(){return he()},get children(){var te=OR();return te.firstChild,C(te,he,null),te}}),null),C(H,v(j,{get when(){return x(re.path)},get children(){return AR()}}),null),C(H,v(j,{get when(){return!Ce&&re.lastUsed},get children(){var te=wR();return C(te,()=>N(re.lastUsed)),te}}),null),C(H,v(j,{when:Ce,get children(){return xR()}}),null),C(K,v(j,{when:!Ce,get children(){var te=DR();return te.$$click=Q=>A(re.path,Q),C(te,v(Lu,{class:"w-3.5 h-3.5"})),de(()=>te.disabled=e.disabled),te}}),null),de(te=>{var Q=y()===re.path,ee=e.disabled;return Q!==te.e&&K.classList.toggle("panel-list-item-highlight",te.e=Q),ee!==te.t&&(ie.disabled=te.t=ee),te},{e:void 0,t:void 0}),K})()}})),de(re=>{var Ce=e.disabled,he=e.disabled||!o().trim(),K=e.disabled;return Ce!==re.e&&(pe.disabled=re.e=Ce),he!==re.t&&(be.disabled=re.t=he),K!==re.a&&(ne.disabled=re.a=K),re},{e:void 0,t:void 0,a:void 0}),de(()=>pe.value=o()),L})(),v(hR,{get open(){return E()},mode:"files",title:"Select OpenCode Binary",description:"Browse files exposed by the CLI server.",onClose:()=>h(!1),onSelect:F})]};mt(["input","keydown","click"]);var kR=G("<div class=space-y-2>"),PR=G('<div class="text-xs text-muted text-center py-2">No environment variables configured. Add variables above to customize the OpenCode environment.'),FR=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.'),UR=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 BR=e=>{const{preferences:t,addEnvironmentVariable:n,removeEnvironmentVariable:i,updateEnvironmentVariables:r}=Hi(),[a,o]=q(t().environmentVariables||{}),[s,l]=q(""),[c,d]=q(""),u=()=>Object.entries(a());function _(){const E=s().trim(),h=c().trim();E&&(n(E,h),o({...a(),[E]:h}),l(""),d(""))}function m(E){i(E);const{[E]:h,...f}=a();o(f)}function p(E,h){const f={...a(),[E]:h};o(f),r(f)}function g(E){E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),_())}return(()=>{var E=FR(),h=E.firstChild,f=h.firstChild,S=f.nextSibling,T=S.firstChild,b=T.nextSibling,R=b.nextSibling,y=R.nextSibling;y.nextSibling;var O=h.nextSibling,P=O.firstChild,w=P.firstChild,F=w.nextSibling,Y=P.nextSibling,B=O.nextSibling;return C(h,v(lC,{class:"w-4 h-4 icon-muted"}),f),C(S,()=>u().length,b),C(S,()=>u().length!==1?"s":"",y),C(E,v(j,{get when(){return u().length>0},get children(){var A=kR();return C(A,v(Ge,{get each(){return u()},children:([N,I])=>(()=>{var x=UR(),L=x.firstChild,W=L.firstChild,J=W.nextSibling,se=L.nextSibling;return C(L,v(Pm,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),W),W.value=N,J.$$input=pe=>p(N,pe.currentTarget.value),J.value=I,se.$$click=()=>m(N),C(se,v(Lu,{class:"w-3.5 h-3.5"})),de(pe=>{var be=e.disabled,ue=e.disabled,ne=e.disabled;return be!==pe.e&&(W.disabled=pe.e=be),ue!==pe.t&&(J.disabled=pe.t=ue),ne!==pe.a&&(se.disabled=pe.a=ne),pe},{e:void 0,t:void 0,a:void 0}),x})()})),A}}),O),C(P,v(Pm,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),w),w.addEventListener("keypress",g),w.$$input=A=>l(A.currentTarget.value),F.addEventListener("keypress",g),F.$$input=A=>d(A.currentTarget.value),Y.$$click=_,C(Y,v(Du,{class:"w-3.5 h-3.5"})),C(E,v(j,{get when(){return u().length===0},get children(){return PR()}}),B),de(A=>{var N=e.disabled,I=e.disabled,x=e.disabled||!s().trim();return N!==A.e&&(w.disabled=A.e=N),I!==A.t&&(F.disabled=A.t=I),x!==A.a&&(Y.disabled=A.a=x),A},{e:void 0,t:void 0,a:void 0}),de(()=>w.value=s()),de(()=>F.value=c()),E})()};mt(["input","click"]);var $R=G('<header class="px-6 py-4 border-b"style=border-color:var(--border-base)>'),GR=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>'),YR=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'),VR=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">');const HR=e=>v(ze,{get open(){return e.open},onOpenChange:t=>!t&&e.onClose(),get children(){return v(ze.Portal,{get children(){return[v(ze.Overlay,{class:"modal-overlay"}),(()=>{var t=VR();return C(t,v(ze.Content,{class:"modal-surface w-full max-w-5xl max-h-[90vh] flex flex-col overflow-hidden",get children(){return[(()=>{var n=$R();return C(n,v(ze.Title,{class:"text-xl font-semibold text-primary",children:"Advanced Settings"})),n})(),(()=>{var n=GR(),i=n.firstChild,r=i.firstChild,a=r.nextSibling;return C(n,v(MR,{get selectedBinary(){return e.selectedBinary},get onBinaryChange(){return e.onBinaryChange},get disabled(){return!!e.isLoading},get isVisible(){return e.open}}),i),C(a,v(BR,{get disabled(){return!!e.isLoading}})),n})(),(()=>{var n=YR(),i=n.firstChild;return Gi(i,"click",e.onClose,!0),n})()]}})),t})()]}})}});mt(["click"]);const Wm="__drives__";var WR=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'),zR=G('<div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto directory-browser-list"role=listbox>'),KR=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">'),qR=G("<div class=directory-browser-loading><span>Loading folders…"),QR=G('<div class="panel-empty-state flex-1">'),XR=G("<span class=text-red-500>"),ZR=G('<div class="panel-empty-state flex-1">No folders available.'),jR=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>'),JR=G('<button type=button class="selector-button selector-button-secondary directory-browser-select">Select');function cs(e){if(!e||e==="."||e==="./")return".";if(e===Wm)return Wm;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 eE(e){return e.startsWith("/")||/^[a-zA-Z]:/.test(e)||e.startsWith("\\\\")}function zm(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;if(eE(t))return t;const n=e.includes("\\")?"\\":"/",i=e.endsWith(n)?e:`${e}${n}`,r=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${i}${r}`}const eI=e=>{const[t,n]=q(""),[i,r]=q(!1),[a,o]=q(null),[s,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(),o(null)}ge(()=>{if(!e.open)return;h(),f();const A=N=>{N.key==="Escape"&&(N.preventDefault(),e.onClose())};window.addEventListener("keydown",A),Oe(()=>{window.removeEventListener("keydown",A)})});async function f(){r(!0);try{const A=await T();S(A)}catch(A){const N=A instanceof Error?A.message:"Unable to load filesystem";o(N)}finally{r(!1)}}function S(A){const N=cs(A.currentPath);_(N),p(A),n(A.rootPath)}async function T(A){const N=A?cs(A):void 0;if(N){const x=g.get(N);if(x)return x;const L=E.get(N);if(L)return L}const I=(async()=>{N&&d(J=>{const se=new Set(J);return se.add(N),se});const x=await Xt.listFileSystem(A,{includeFiles:!1}),L=cs(x.metadata.currentPath),W=x.entries.filter(J=>J.type==="directory").sort((J,se)=>J.name.localeCompare(se.name));return l(J=>{const se=new Map(J);return se.set(L,W),se}),g.set(L,x.metadata),d(J=>{const se=new Set(J);return N&&se.delete(N),se.delete(L),se}),x.metadata})().catch(x=>{throw N&&d(L=>{const W=new Set(L);return W.delete(N),W}),x}).finally(()=>{N&&E.delete(N)});return N&&E.set(N,I),I}async function b(A){o(null);try{const N=await T(A);S(N)}catch(N){const I=N instanceof Error?N.message:"Unable to load filesystem";o(I)}}const R=V(()=>{const A=[],N=m();N!=null&&N.parentPath&&A.push({type:"up",path:N.parentPath});const I=u();if(!I)return A;const x=s().get(I)??[];for(const L of x)A.push({type:"folder",entry:L});return A});function y(A){b(A)}function O(){var N;const A=(N=m())==null?void 0:N.parentPath;A&&b(A)}const P=V(()=>{const A=m();return!A||A.pathKind==="drives"?"":A.pathKind==="relative"?zm(A.rootPath,A.currentPath):A.displayPath}),w=V(()=>!!P());function F(A){const N=A.absolutePath?A.absolutePath:eE(A.path)?A.path:zm(t(),A.path);e.onSelect(N)}function Y(A){return c().has(cs(A))}function B(A){A.target===A.currentTarget&&e.onClose()}return v(j,{get when(){return e.open},get children(){var A=KR(),N=A.firstChild,I=N.firstChild,x=I.firstChild,L=x.firstChild,W=L.firstChild,J=W.nextSibling,se=L.nextSibling,pe=x.nextSibling;return A.$$click=B,C(W,()=>e.title),C(J,()=>e.description||"Browse folders under the configured workspace root."),Gi(se,"click",e.onClose,!0),C(se,v(kl,{class:"w-5 h-5"})),C(pe,v(j,{get when(){return t()},get children(){var be=WR(),ue=be.firstChild,ne=ue.firstChild,Se=ne.nextSibling,fe=ue.nextSibling;return C(Se,P),fe.$$click=()=>{const re=P();re&&e.onSelect(re)},de(()=>fe.disabled=!w()),be}}),null),C(pe,v(j,{get when(){return ke(()=>!i())()&&!a()},get fallback(){return(()=>{var be=QR();return C(be,v(j,{get when(){return i()},get fallback(){return(()=>{var ue=XR();return C(ue,a),ue})()},get children(){var ue=qR(),ne=ue.firstChild;return C(ue,v(ho,{class:"w-5 h-5 animate-spin"}),ne),ue}})),be})()},get children(){return v(j,{get when(){return R().length>0},get fallback(){return ZR()},get children(){var be=zR();return C(be,v(Ge,{get each(){return R()},children:ue=>{const ne=ue.type==="folder",Se=ne?ue.entry.name||ue.entry.path:"Up one level",fe=()=>ne?y(ue.entry.path):O();return(()=>{var re=jR(),Ce=re.firstChild,he=Ce.firstChild,K=he.firstChild,ie=K.nextSibling,M=ie.firstChild;return he.$$click=fe,C(K,v(j,{when:!ne,get fallback(){return v(xu,{class:"w-4 h-4"})},get children(){return v(Uf,{class:"w-4 h-4"})}})),C(M,Se),C(he,v(j,{get when(){return ne&&Y(ue.entry.path)},get children(){return v(ho,{class:"directory-browser-row-spinner animate-spin"})}}),null),C(Ce,ne?(()=>{var U=JR();return U.$$click=z=>{z.stopPropagation(),F(ue.entry)},U})():null,null),re})()}})),be}})}}),null),A}})};mt(["click"]);const ai=()=>navigator.platform.toLowerCase().includes("mac"),tI=e=>{const t=[];return(e.modifiers.ctrl||e.modifiers.meta)&&t.push(ai()?"Cmd":"Ctrl"),e.modifiers.shift&&t.push("Shift"),e.modifiers.alt&&t.push(ai()?"Option":"Alt"),t.push(e.key.toUpperCase()),t.join("+")};var nI=G("<kbd>"),iI=G("<span>"),rI=G("<span class=kbd-separator>+");const aI={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:"→"},Bt=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 o=a.trim(),s=o.toLowerCase();if(s==="cmd"||s==="command")n.push({text:ai()?"Cmd":"Ctrl",isModifier:!1});else if(s==="shift")n.push({text:"Shift",isModifier:!1});else if(s==="alt"||s==="option")n.push({text:ai()?"Option":"Alt",isModifier:!1});else if(s==="ctrl"||s==="control")n.push({text:"Ctrl",isModifier:!1});else{const l=aI[s];l?n.push({text:l,isModifier:!1}):o.length===1?n.push({text:o.toUpperCase(),isModifier:!1}):n.push({text:o.charAt(0).toUpperCase()+o.slice(1),isModifier:!1})}}),n};return(()=>{var n=nI();return C(n,v(Ge,{get each(){return t()},children:(i,r)=>[ke(()=>ke(()=>r()>0)()&&rI()),(()=>{var a=iI();return C(a,()=>i.text),a})()]})),de(()=>Be(n,`kbd ${e.class||""}`)),n})()};var oI=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">'),sI=G('<div class="flex items-center gap-1.5"><kbd class=kbd>↑</kbd><kbd class=kbd>↓</kbd><span>Navigate'),lI=G('<div class="flex items-center gap-1.5"><kbd class=kbd>Enter</kbd><span>Select'),cI=G('<div class="flex items-center gap-1.5"><kbd class=kbd>Del</kbd><span>Remove'),dI=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."),uI=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-48 w-auto"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><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"><div class=panel-footer-hints><div class="flex items-center gap-1.5"><span>Browse',!0,!1,!1),_I=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'),mI=G("<kbd class=kbd>↵"),pI=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 gI=new URL("/assets/CodeNomad-Icon-bmTWNPXy.png",import.meta.url).href,Km=e=>{const{recentFolders:t,removeRecentFolder:n,preferences:i}=Hi(),[r,a]=q(0),[o,s]=q("recent"),[l,c]=q(i().lastUsedBinary||"opencode"),[d,u]=q(!1),_=jf();let m;const p=()=>t(),g=()=>!!e.isLoading;ge(()=>{const w=i().lastUsedBinary;w&&c(F=>F===w?F:w)});function E(w){const F=m;if(!F)return;const Y=F.querySelector(`[data-folder-index="${w}"]`);if(!Y)return;const B=F.getBoundingClientRect(),A=Y.getBoundingClientRect();A.top<B.top?F.scrollTop-=B.top-A.top:A.bottom>B.bottom&&(F.scrollTop+=A.bottom-B.bottom)}function h(w){const F=w.key.toLowerCase(),Y=(w.metaKey||w.ctrlKey)&&!w.shiftKey&&F==="n",B=["ArrowDown","ArrowUp","PageDown","PageUp","Home","End","Enter","Backspace","Delete"];if(g()){(Y||B.includes(w.key))&&w.preventDefault();return}const A=p();if(Y){w.preventDefault(),b();return}if(A.length!==0){if(w.key==="ArrowDown"){w.preventDefault();const N=Math.min(r()+1,A.length-1);a(N),s("recent"),E(N)}else if(w.key==="ArrowUp"){w.preventDefault();const N=Math.max(r()-1,0);a(N),s("recent"),E(N)}else if(w.key==="PageDown"){w.preventDefault();const I=Math.min(r()+5,A.length-1);a(I),s("recent"),E(I)}else if(w.key==="PageUp"){w.preventDefault();const I=Math.max(r()-5,0);a(I),s("recent"),E(I)}else if(w.key==="Home")w.preventDefault(),a(0),s("recent"),E(0);else if(w.key==="End"){w.preventDefault();const N=A.length-1;a(N),s("recent"),E(N)}else if(w.key==="Enter")w.preventDefault(),f();else if((w.key==="Backspace"||w.key==="Delete")&&(w.preventDefault(),A.length>0&&o()==="recent")){const N=A[r()];N&&O(N.path)}}}function f(){if(g())return;const w=p(),F=r(),Y=w[F];Y&&T(Y.path)}Zt(()=>{window.addEventListener("keydown",h),Oe(()=>{window.removeEventListener("keydown",h)})});function S(w){const F=Math.floor((Date.now()-w)/1e3),Y=Math.floor(F/60),B=Math.floor(Y/60),A=Math.floor(B/24);return A>0?`${A}d ago`:B>0?`${B}h ago`:Y>0?`${Y}m ago`:"just now"}function T(w){g()||e.onSelectFolder(w,l())}async function b(){var w;if(!g()){if(s("new"),_){const F=(w=p()[0])==null?void 0:w.path,Y=await vR({title:"Select Workspace",defaultPath:F});Y&&T(Y);return}u(!0)}}function R(w){u(!1),T(w)}function y(w){c(w)}function O(w,F){if(g())return;F==null||F.stopPropagation(),n(w);const Y=p();r()>=Y.length&&Y.length>0&&a(Y.length-1)}function P(w){return w.startsWith("/Users/")?w.replace(/^\/Users\/[^/]+/,"~"):w}return[(()=>{var w=uI(),F=w.firstChild,Y=F.firstChild,B=Y.firstChild,A=B.firstChild,N=Y.nextSibling,I=N.firstChild,x=I.firstChild,L=x.nextSibling,W=L.firstChild,J=W.firstChild,se=J.firstChild,pe=L.nextSibling,be=pe.firstChild,ue=be.firstChild,ne=ue.firstChild,Se=N.nextSibling,fe=Se.firstChild,re=fe.firstChild,Ce=re.firstChild;return Pe(A,"src",gI),C(N,v(j,{get when(){return p().length>0},get fallback(){return(()=>{var he=_I(),K=he.firstChild;return C(K,v(jy,{class:"w-12 h-12 mx-auto"})),he})()},get children(){var he=oI(),K=he.firstChild,ie=K.firstChild,M=ie.nextSibling,U=M.firstChild,z=U.nextSibling;z.nextSibling;var H=K.nextSibling;return C(M,()=>p().length,U),C(M,()=>p().length===1?"folder":"folders",z),Tt(te=>m=te,H),C(H,v(Ge,{get each(){return p()},children:(te,Q)=>(()=>{var ee=pI(),ce=ee.firstChild,_e=ce.firstChild,we=_e.firstChild,Ae=we.firstChild,Le=Ae.firstChild,ae=Le.firstChild,$=Le.nextSibling,Z=$.nextSibling,Ee=_e.nextSibling;return _e.addEventListener("mouseenter",()=>{g()||(s("recent"),a(Q()))}),_e.$$click=()=>T(te.path),C(Le,v(xu,{class:"w-4 h-4 flex-shrink-0 icon-muted"}),ae),C(ae,()=>te.path.split("/").pop()),C($,()=>P(te.path)),C(Z,()=>S(te.lastAccessed)),C(we,v(j,{get when(){return ke(()=>o()==="recent")()&&r()===Q()},get children(){return mI()}}),null),Ee.$$click=Re=>O(te.path,Re),C(Ee,v(Lu,{class:"w-3.5 h-3.5 transition-colors icon-muted hover:text-red-600 dark:hover:text-red-400"})),de(Re=>{var Me=o()==="recent"&&r()===Q(),$e=!!g(),gt=Q(),lt=g(),ct=g();return Me!==Re.e&&ee.classList.toggle("panel-list-item-highlight",Re.e=Me),$e!==Re.t&&ee.classList.toggle("panel-list-item-disabled",Re.t=$e),gt!==Re.a&&Pe(_e,"data-folder-index",Re.a=gt),lt!==Re.o&&(_e.disabled=Re.o=lt),ct!==Re.i&&(Ee.disabled=Re.i=ct),Re},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),ee})()})),he}}),I),W.addEventListener("mouseenter",()=>s("new")),W.$$click=()=>void b(),C(J,v(aC,{class:"w-4 h-4"}),se),C(se,()=>e.isLoading?"Opening...":"Browse Folders"),C(W,v(Bt,{shortcut:"cmd+n",class:"ml-2"}),null),be.$$click=()=>{var he;return(he=e.onAdvancedSettingsOpen)==null?void 0:he.call(e)},C(ue,v(SC,{class:"w-4 h-4 icon-muted"}),ne),C(be,v(Xy,{class:"w-4 h-4 icon-muted"}),null),C(fe,v(j,{get when(){return p().length>0},get children(){return[sI(),lI(),cI()]}}),re),C(re,v(Bt,{shortcut:"cmd+n"}),Ce),C(w,v(j,{get when(){return g()},get children(){return dI()}}),null),de(he=>{var K=g()?"true":"false",ie=e.isLoading;return K!==he.e&&Pe(F,"aria-busy",he.e=K),ie!==he.t&&(W.disabled=he.t=ie),he},{e:void 0,t:void 0}),w})(),v(HR,{get open(){return!!e.advancedSettingsOpen},onClose:()=>{var w;return(w=e.onAdvancedSettingsClose)==null?void 0:w.call(e)},get selectedBinary(){return l()},onBinaryChange:y,get isLoading(){return e.isLoading}}),v(eI,{get open(){return d()},title:"Select Workspace",description:"Select workspace to start coding.",onClose:()=>u(!1),onSelect:R})]};mt(["click"]);var fI=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 EI=e=>(()=>{var t=fI(),n=t.firstChild,i=n.firstChild,r=i.nextSibling;return Gi(n,"click",e.onSelect,!0),C(n,v(Bf,{class:"w-4 h-4 flex-shrink-0"}),i),C(i,()=>e.instance.folder.split("/").pop()||e.instance.folder),r.$$click=a=>{a.stopPropagation(),e.onClose()},C(r,v(kl,{class:"w-3 h-3"})),de(a=>{var o=`tab-base ${e.active?"tab-active":"tab-inactive"}`,s=e.instance.folder,l=e.active;return o!==a.e&&Be(n,a.e=o),s!==a.t&&Pe(n,"title",a.t=s),l!==a.a&&Pe(n,"aria-selected",a.a=l),a},{e:void 0,t:void 0,a:void 0}),t})();mt(["click"]);var hI=G("<span>");const md=e=>(()=>{var t=hI();return C(t,()=>e.children),de(()=>Be(t,`text-xs text-muted ${e.class||""}`)),t})();var SI=G("<span class=mx-1>"),bI=G("<span class=mr-1>");const $l=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 v(md,{get children(){return v(Ge,{get each(){return e.shortcuts},children:(n,i)=>[ke(()=>ke(()=>i()>0)()&&(()=>{var r=SI();return C(r,()=>e.separator||"•"),r})()),ke(()=>ke(()=>e.showDescription!==!1)()&&(()=>{var r=bI();return C(r,()=>n.description),r})()),v(Bt,{get shortcut(){return t(n)}})]})}})};class TI{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():"",o=r===i||a===i,s=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 o&&s&&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 bt=new TI;var vI=G('<div class="flex-shrink-0 ml-4">'),yI=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 CI=e=>(()=>{var t=yI(),n=t.firstChild,i=n.firstChild,r=i.firstChild;return C(i,v(Ge,{get each(){return Array.from(e.instances.entries())},children:([a,o])=>v(EI,{instance:o,get active(){return a===e.activeInstanceId},onSelect:()=>e.onSelect(a),onClose:()=>e.onClose(a)})}),r),Gi(r,"click",e.onNew,!0),C(r,v(Du,{class:"w-4 h-4"})),C(n,v(j,{get when(){return Array.from(e.instances.entries()).length>1},get children(){var a=vI();return C(a,v($l,{get shortcuts(){return[bt.get("instance-prev"),bt.get("instance-next")].filter(Boolean)}})),a}}),null),t})();mt(["click"]);var RI=G("<div>"),II=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">'),NI=G('<div class="flex justify-end"><button type=button class="selector-button selector-button-primary">Close Instance'),OI=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),AI=G('<p class="mt-2 text-secondary">Folder: <span class="font-mono text-primary break-all">');function wI(e){const t=e.folder||"this workspace",n=e.reason||"The server stopped responding";return v(ze,{get open(){return e.open},modal:!0,get children(){return v(ze.Portal,{get children(){return[v(ze.Overlay,{class:"modal-overlay"}),(()=>{var i=OI();return C(i,v(ze.Content,{class:"modal-surface w-full max-w-md p-6 flex flex-col gap-6",get children(){return[(()=>{var r=RI();return C(r,v(ze.Title,{class:"text-xl font-semibold text-primary",children:"Instance Disconnected"}),null),C(r,v(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=II(),a=r.firstChild,o=a.nextSibling;return C(o,n),C(r,(()=>{var s=ke(()=>!!e.folder);return()=>s()&&(()=>{var l=AI(),c=l.firstChild,d=c.nextSibling;return C(d,()=>e.folder),l})()})(),null),r})(),(()=>{var r=NI(),a=r.firstChild;return Gi(a,"click",e.onClose,!0),r})()]}})),i})()]}})}})}mt(["click"]);const[qm,xI]=q(new Map);class DI{constructor(){So.on("instance.eventStatus",t=>{var i;const n=t;if(this.updateConnectionStatus(n.instanceId,n.status),n.status==="error"){const r=n.reason??"Instance stream error";(i=this.onConnectionLost)==null||i.call(this,n.instanceId,r)}}),So.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,o,s,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":(o=this.onMessagePartRemoved)==null||o.call(this,t,n);break;case"session.updated":(s=this.onSessionUpdate)==null||s.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){xI(i=>{const r=new Map(i);return r.set(t,n),r})}getStatus(t){return qm().get(t)??null}getStatuses(){return qm()}}const Gt=new DI,[Lt,sr]=q(new Map),[Li,tE]=q(new Map),[bo,nE]=q(new Map),[Gl,LI]=q(new Map),[Ta,MI]=q(new Map),[kI,Yl]=q(new Map),[iE,oa]=q({fetchingSessions:new Map,creatingSession:new Map,deletingSession:new Map,loadingMessages:new Map}),[PI,pd]=q(new Map),[FI,Gu]=q(new Map);function Yu(e,t){return`${e}:${t}`}function UI(e,t){if(!e||!t)return"";const n=Yu(e,t);return kI().get(n)??""}function vc(e,t,n){const i=Yu(e,t);Yl(r=>{const a=new Map(r);return n?a.set(i,n):a.delete(i),a})}function BI(e,t){const n=Yu(e,t);Yl(i=>{if(!i.has(n))return i;const r=new Map(i);return r.delete(n),r})}function $I(e){e&&Yl(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 GI(e,t){Yl(n=>{let i=!1;const r=new Map(n),a=`${e}:`;for(const o of Array.from(r.keys()))if(o.startsWith(a)){const s=o.slice(a.length);t.has(s)||(r.delete(o),i=!0)}return i?r:n})}function Mi(e,t,n){const i=Lt().get(e);if(!i)return;const r=i.get(t);if(!r)return;n(r);const a={...r,messages:[...r.messages],messagesInfo:new Map(r.messagesInfo)};sr(o=>{const s=new Map(o),l=new Map(i);return l.set(t,a),s.set(e,l),s})}function To(e,t,n){Mi(e,t,i=>{i.pendingPermission!==n&&(i.pendingPermission=n)})}function An(e,t){tE(n=>{const i=new Map(n);return i.set(e,t),i})}function vo(e,t){nE(n=>{const i=new Map(n);return i.set(e,t),i}),An(e,t)}function YI(e){nE(t=>{const n=new Map(t);return n.delete(e),n}),tE(t=>{const n=new Map(t);return n.delete(e),n})}function lr(e){const t=Lt().get(e);return t?Array.from(t.values()):[]}function VI(e){return lr(e).filter(n=>n.parentId===null)}function HI(e,t){return lr(e).filter(i=>i.parentId===t)}function Js(e,t){var r;const n=(r=Lt().get(e))==null?void 0:r.get(t);if(!n)return[];const i=HI(e,t);return[n,...i]}function WI(e,t){const n=Lt().get(e);return!(!n||!n.has(t))}function zI(e,t){var n;return!!((n=iE().loadingMessages.get(e))!=null&&n.has(t))}function rE(e,t){var n;return(n=FI().get(e))==null?void 0:n.get(t)}const Qm=32e3;function sa(e,t){if(!(t!=null&&t.providerId)||!t.modelId)return!1;const i=(Ta().get(e)||[]).find(r=>r.id===t.providerId);return i?i.models.some(r=>r.id===t.modelId):!1}function KI(e){const t=_t().modelRecents??[];for(const n of t)if(sa(e,n))return n}async function Vu(e,t){const n=Ta().get(e)||[],i=Gl().get(e)||[];if(t){const a=i.find(s=>s.name===t);if(a&&a.model&&sa(e,a.model))return{providerId:a.model.providerId,modelId:a.model.modelId};const o=await Qf(e,t);if(sa(e,o))return o}const r=KI(e);if(r)return r;for(const a of n)if(a.defaultModelId){const o=a.models.find(s=>s.id===a.defaultModelId);if(o)return{providerId:a.id,modelId:o.id}}if(n.length>0){const a=n[0],o=a.models[0];if(o)return{providerId:a.id,modelId:o.id}}return{providerId:"",modelId:""}}function Xm(e){return typeof e=="string"?e.trim().length>0:e&&typeof e=="object"&&e.text?typeof e.text=="string"&&e.text.trim().length>0:!1}function yo(e){if(!e||typeof e!="object")return!1;const t=e;return!!(t.type==="text"&&Xm(t.text)||t.type==="file"&&t.filename||t.type==="tool"||t.type==="reasoning"&&Xm(t.text))}function Hu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Er=Hu();function aE(e){Er=e}const oE=/[&<>"']/,qI=new RegExp(oE.source,"g"),sE=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,QI=new RegExp(sE.source,"g"),XI={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Zm=e=>XI[e];function an(e,t){if(t){if(oE.test(e))return e.replace(qI,Zm)}else if(sE.test(e))return e.replace(QI,Zm);return e}const ZI=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function jI(e){return e.replace(ZI,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const JI=/(^|[^\[])\^/g;function Qe(e,t){let n=typeof e=="string"?e:e.source;t=t||"";const i={replace:(r,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(JI,"$1"),n=n.replace(r,o),i},getRegex:()=>new RegExp(n,t)};return i}function jm(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch{return null}return e}const no={exec:()=>null};function Jm(e,t){const n=e.replace(/\|/g,(a,o,s)=>{let l=!1,c=o;for(;--c>=0&&s[c]==="\\";)l=!l;return l?"|":" |"}),i=n.split(/ \|/);let r=0;if(i[0].trim()||i.shift(),i.length>0&&!i[i.length-1].trim()&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(/\\\|/g,"|");return i}function ds(e,t,n){const i=e.length;if(i===0)return"";let r=0;for(;r<i&&e.charAt(i-r-1)===t;)r++;return e.slice(0,i-r)}function eN(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return-1}function ep(e,t,n,i){const r=t.href,a=t.title?an(t.title):null,o=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){i.state.inLink=!0;const s={type:"link",raw:n,href:r,title:a,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,s}return{type:"image",raw:n,href:r,title:a,text:an(o)}}function tN(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const i=n[1];return t.split(`
2
+ var YT=Object.defineProperty;var mm=e=>{throw TypeError(e)};var VT=(e,t,n)=>t in e?YT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var X=(e,t,n)=>VT(e,typeof t!="symbol"?t+"":t,n),HT=(e,t,n)=>t.has(e)||mm("Cannot "+n);var pm=(e,t,n)=>t.has(e)?mm("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var jo=(e,t,n)=>(HT(e,t,"access private method"),n);import{o as Oe,c as ge,a as de,b as V,$ as ad,u as ha,d as od,e as q,m as Ne,s as He,f as v,D as sf,g as Zt,h as Yn,i as jt,j as un,k as ke,l as pr,P as fu,S as j,n as ar,p as WT,q as sd,t as G,r as C,F as Ge,v as In,w as Be,M as ni,x as Eu,y as Hn,z as Tt,A as Pe,B as mt,C as zr,E as Gi,G as ld,H as zT,I as lf,J as KT,K as qT}from"./index-Cpjhgy_m.js";function QT(e){return(...t)=>{for(const n of e)n&&n(...t)}}const oe=e=>typeof e=="function"&&!e.length?e():e,gm=e=>Array.isArray(e)?e:e?[e]:[];function XT(e,...t){return typeof e=="function"?e(...t):e}const ZT=Oe;function jT(e,t,n,i){return e.addEventListener(t,n,i),ZT(e.removeEventListener.bind(e,t,n,i))}function JT(e,t,n,i){const r=()=>{gm(oe(e)).forEach(a=>{a&&gm(oe(t)).forEach(o=>jT(a,o,n,i))})};typeof e=="function"?ge(r):de(r)}const gc=Symbol("fallback");function fm(e){for(const t of e)t.dispose()}function ev(e,t,n,i={}){const r=new Map;return Oe(()=>fm(r.values())),()=>{const o=e()||[];return o[ad],ha(()=>{var d,u;if(!o.length)return fm(r.values()),r.clear(),i.fallback?[od(m=>(r.set(gc,{dispose:m}),i.fallback()))]:[];const s=new Array(o.length),l=r.get(gc);if(!r.size||l){l==null||l.dispose(),r.delete(gc);for(let _=0;_<o.length;_++){const m=o[_],p=t(m,_);a(s,m,_,p)}return s}const c=new Set(r.keys());for(let _=0;_<o.length;_++){const m=o[_],p=t(m,_);c.delete(p);const g=r.get(p);g?(s[_]=g.mapped,(d=g.setIndex)==null||d.call(g,_),g.setItem(()=>m)):a(s,m,_,p)}for(const _ of c)(u=r.get(_))==null||u.dispose(),r.delete(_);return s})};function a(o,s,l,c){od(d=>{const[u,_]=q(s),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),o[l]=m.mapped})}}function tv(e){const{by:t}=e;return V(ev(()=>e.each,typeof t=="function"?t:n=>n[t],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}const nv=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Em(e){const t={};let n;for(;n=nv.exec(e);)t[n[1]]=n[2];return t}function $o(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=Em(e)}else typeof t=="string"&&(t=Em(t));return{...e,...t}}function Nt(...e){return QT(e)}function hm(e,t){const n=[...e],i=n.indexOf(t);return i!==-1&&n.splice(i,1),n}function iv(e){return typeof e=="number"}function Nr(e){return Object.prototype.toString.call(e)==="[object String]"}function Ci(e){return typeof e=="function"}function Sa(e){return t=>`${e()}-${t}`}function On(e,t){return e?e===t||e.contains(t):!1}function Wa(e,t=!1){const{activeElement:n}=di(e);if(!(n!=null&&n.nodeName))return null;if(cf(n)&&n.contentDocument)return Wa(n.contentDocument.body,t);if(t){const i=n.getAttribute("aria-activedescendant");if(i){const r=di(n).getElementById(i);if(r)return r}}return n}function rv(e){return di(e).defaultView||window}function di(e){return e?e.ownerDocument||e:document}function cf(e){return e.tagName==="IFRAME"}var df=(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))(df||{});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 hu(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 Go(){return hu(/^Mac/i)}function av(){return hu(/^iPhone/i)}function ov(){return hu(/^iPad/i)||Go()&&navigator.maxTouchPoints>1}function sv(){return av()||ov()}function xs(){return Go()||sv()}function lv(){return uf(/AppleWebKit/i)&&!cv()}function cv(){return uf(/Chrome/i)}function it(e,t){return t&&(Ci(t)?t(e):t[0](t[1],e)),e==null?void 0:e.defaultPrevented}function gn(e){return t=>{for(const n of e)it(t,n)}}function dv(e){return Go()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Dt(e){if(e)if(uv())e.focus({preventScroll:!0});else{const t=_v(e);e.focus(),mv(t)}}var Jo=null;function uv(){if(Jo==null){Jo=!1;try{document.createElement("div").focus({get preventScroll(){return Jo=!0,!0}})}catch{}}return Jo}function _v(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 mv(e){for(const{element:t,scrollTop:n,scrollLeft:i}of e)t.scrollTop=n,t.scrollLeft=i}var _f=["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'])"],pv=[..._f,'[tabindex]:not([tabindex="-1"]):not([disabled])'],Su=`${_f.join(":not([hidden]),")},[tabindex]:not([disabled]):not([hidden])`,gv=pv.join(':not([hidden]):not([tabindex="-1"]),');function mf(e,t){const i=Array.from(e.querySelectorAll(Su)).filter(Sm);return t&&Sm(e)&&i.unshift(e),i.forEach((r,a)=>{if(cf(r)&&r.contentDocument){const o=r.contentDocument.body,s=mf(o,!1);i.splice(a,1,...s)}}),i}function Sm(e){return pf(e)&&!fv(e)}function pf(e){return e.matches(Su)&&bu(e)}function fv(e){return Number.parseInt(e.getAttribute("tabindex")||"0",10)<0}function bu(e,t){return e.nodeName!=="#comment"&&Ev(e)&&hv(e,t)&&(!e.parentElement||bu(e.parentElement,e))}function Ev(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:o}=r(e);i=a!=="none"&&o!=="hidden"&&o!=="collapse"}return i}function hv(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function Sv(e,t,n){const i=t!=null&&t.tabbable?gv:Su,r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(a){var o;return(o=t==null?void 0:t.from)!=null&&o.contains(a)?NodeFilter.FILTER_REJECT:a.matches(i)&&bu(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 bv(){}function Xe(e,t){return Ne(e,t)}var Ma=new Map,bm=new Set;function Tm(){if(typeof window>"u")return;const e=n=>{if(!n.target)return;let i=Ma.get(n.target);i||(i=new Set,Ma.set(n.target,i),n.target.addEventListener("transitioncancel",t)),i.add(n.propertyName)},t=n=>{if(!n.target)return;const i=Ma.get(n.target);if(i&&(i.delete(n.propertyName),i.size===0&&(n.target.removeEventListener("transitioncancel",t),Ma.delete(n.target)),Ma.size===0)){for(const r of bm)r();bm.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?Tm():document.addEventListener("DOMContentLoaded",Tm));function vm(e,t){const n=ym(e,t,"left"),i=ym(e,t,"top"),r=t.offsetWidth,a=t.offsetHeight;let o=e.scrollLeft,s=e.scrollTop;const l=o+e.offsetWidth,c=s+e.offsetHeight;n<=o?o=n:n+r>l&&(o+=n+r-l),i<=s?s=i:i+a>c&&(s+=i+a-c),e.scrollLeft=o,e.scrollTop=s}function ym(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 Tu={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"},Hs="data-kb-top-layer",gf,cd=!1,ui=[];function fo(e){return ui.findIndex(t=>t.node===e)}function Tv(e){return ui[fo(e)]}function vv(e){return ui[ui.length-1].node===e}function ff(){return ui.filter(e=>e.isPointerBlocking)}function yv(){return[...ff()].slice(-1)[0]}function vu(){return ff().length>0}function Ef(e){var n;const t=fo((n=yv())==null?void 0:n.node);return fo(e)<t}function Cv(e){ui.push(e)}function Rv(e){const t=fo(e);t<0||ui.splice(t,1)}function Iv(){for(const{node:e}of ui)e.style.pointerEvents=Ef(e)?"none":"auto"}function Nv(e){if(vu()&&!cd){const t=di(e);gf=document.body.style.pointerEvents,t.body.style.pointerEvents="none",cd=!0}}function Ov(e){if(vu())return;const t=di(e);t.body.style.pointerEvents=gf,t.body.style.length===0&&t.body.removeAttribute("style"),cd=!1}var en={layers:ui,isTopMostLayer:vv,hasPointerBlockingLayer:vu,isBelowPointerBlockingLayer:Ef,addLayer:Cv,removeLayer:Rv,indexOf:fo,find:Tv,assignPointerEventToLayers:Iv,disableBodyPointerEvents:Nv,restoreBodyPointerEvents:Ov},fc="focusScope.autoFocusOnMount",Ec="focusScope.autoFocusOnUnmount",Cm={bubbles:!1,cancelable:!0},Rm={stack:[],active(){return this.stack[0]},add(e){var t;e!==this.active()&&((t=this.active())==null||t.pause()),this.stack=hm(this.stack,e),this.stack.unshift(e)},remove(e){var t;this.stack=hm(this.stack,e),(t=this.active())==null||t.resume()}};function yu(e,t){const[n,i]=q(!1),r={pause(){i(!0)},resume(){i(!1)}};let a=null;const o=p=>{var g;return(g=e.onMountAutoFocus)==null?void 0:g.call(e,p)},s=p=>{var g;return(g=e.onUnmountAutoFocus)==null?void 0:g.call(e,p)},l=()=>di(t()),c=()=>{const p=l().createElement("span");return p.setAttribute("data-focus-trap",""),p.tabIndex=0,Object.assign(p.style,Tu),p},d=()=>{const p=t();return p?mf(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=Wa(p);return!g||On(p,g)?!1:pf(g)};ge(()=>{const p=t();if(!p)return;Rm.add(r);const g=Wa(p);if(!On(p,g)){const h=new CustomEvent(fc,Cm);p.addEventListener(fc,o),p.dispatchEvent(h),h.defaultPrevented||setTimeout(()=>{Dt(u()),Wa(p)===g&&Dt(p)},0)}Oe(()=>{p.removeEventListener(fc,o),setTimeout(()=>{const h=new CustomEvent(Ec,Cm);m()&&h.preventDefault(),p.addEventListener(Ec,s),p.dispatchEvent(h),h.defaultPrevented||Dt(g??l().body),p.removeEventListener(Ec,s),Rm.remove(r)},0)})}),ge(()=>{const p=t();if(!p||!oe(e.trapFocus)||n())return;const g=h=>{const f=h.target;f!=null&&f.closest(`[${Hs}]`)||(On(p,f)?a=f:Dt(a))},E=h=>{const S=h.relatedTarget??Wa(p);S!=null&&S.closest(`[${Hs}]`)||On(p,S)||Dt(a)};l().addEventListener("focusin",g),l().addEventListener("focusout",E),Oe(()=>{l().removeEventListener("focusin",g),l().removeEventListener("focusout",E)})}),ge(()=>{const p=t();if(!p||!oe(e.trapFocus)||n())return;const g=c();p.insertAdjacentElement("afterbegin",g);const E=c();p.insertAdjacentElement("beforeend",E);function h(S){const T=u(),b=_();S.relatedTarget===T?Dt(b):Dt(T)}g.addEventListener("focusin",h),E.addEventListener("focusin",h);const f=new MutationObserver(S=>{for(const T of S)T.previousSibling===E&&(E.remove(),p.insertAdjacentElement("beforeend",E)),T.nextSibling===g&&(g.remove(),p.insertAdjacentElement("afterbegin",g))});f.observe(p,{childList:!0,subtree:!1}),Oe(()=>{g.removeEventListener("focusin",h),E.removeEventListener("focusin",h),g.remove(),E.remove(),f.disconnect()})})}var hf=7e3,hc=null,Av="data-live-announcer";function Sc(e,t="assertive",n=hf){hc||(hc=new wv),hc.announce(e,t,n)}var wv=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,Tu),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=hf){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 Cu(e){ge(()=>{oe(e.isDisabled)||Oe(xv(oe(e.targets),oe(e.root)))})}var ka=new WeakMap,_n=[];function xv(e,t=document.body){const n=new Set(e),i=new Set,r=l=>{for(const _ of l.querySelectorAll(`[${Av}], [${Hs}]`))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=ka.get(l)??0;l.getAttribute("aria-hidden")==="true"&&c===0||(c===0&&l.setAttribute("aria-hidden","true"),i.add(l),ka.set(l,c+1))};_n.length&&_n[_n.length-1].disconnect(),r(t);const o=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)}});o.observe(t,{childList:!0,subtree:!0});const s={observe(){o.observe(t,{childList:!0,subtree:!0})},disconnect(){o.disconnect()}};return _n.push(s),()=>{o.disconnect();for(const l of i){const c=ka.get(l);if(c==null)return;c===1?(l.removeAttribute("aria-hidden"),ka.delete(l)):ka.set(l,c-1)}s===_n[_n.length-1]?(_n.pop(),_n.length&&_n[_n.length-1].observe()):_n.splice(_n.indexOf(s),1)}}var Im="interactOutside.pointerDownOutside",Nm="interactOutside.focusOutside";function Dv(e,t){let n,i=bv;const r=()=>di(t()),a=u=>{var _;return(_=e.onPointerDownOutside)==null?void 0:_.call(e,u)},o=u=>{var _;return(_=e.onFocusOutside)==null?void 0:_.call(e,u)},s=u=>{var _;return(_=e.onInteractOutside)==null?void 0:_.call(e,u)},l=u=>{var m;const _=u.target;return!(_ instanceof Element)||_.closest(`[${Hs}]`)||!On(r(),_)||On(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=gn([a,s]);p.addEventListener(Im,g,{once:!0});const E=new CustomEvent(Im,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:u.button===2||dv(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=gn([o,s]);m.addEventListener(Nm,p,{once:!0});const g=new CustomEvent(Nm,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:!1}});m.dispatchEvent(g)};ge(()=>{oe(e.isDisabled)||(n=window.setTimeout(()=>{r().addEventListener("pointerdown",c,!0)},0),r().addEventListener("focusin",d,!0),Oe(()=>{window.clearTimeout(n),r().removeEventListener("click",i),r().removeEventListener("pointerdown",c,!0),r().removeEventListener("focusin",d,!0)}))})}function Lv(e){const t=n=>{var i;n.key===df.Escape&&((i=e.onEscapeKeyDown)==null||i.call(e,n))};ge(()=>{var i;if(oe(e.isDisabled))return;const n=((i=e.ownerDocument)==null?void 0:i.call(e))??di();n.addEventListener("keydown",t),Oe(()=>{n.removeEventListener("keydown",t)})})}function st(e){const[t,n]=He(e,["as"]);if(!t.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return v(sf,Ne(n,{get component(){return t.as}}))}var Sf=jt();function Mv(){return un(Sf)}function Ru(e){let t;const n=Mv(),[i,r]=He(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),a=new Set([]),o=u=>{a.add(u);const _=n==null?void 0:n.registerNestedLayer(u);return()=>{a.delete(u),_==null||_()}};Dv({shouldExcludeElement:u=>{var _;return t?((_=i.excludedElements)==null?void 0:_.some(m=>On(m(),u)))||[...a].some(m=>On(m,u)):!1},onPointerDownOutside:u=>{var _,m,p;!t||en.isBelowPointerBlockingLayer(t)||!i.bypassTopMostLayerCheck&&!en.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),Lv({ownerDocument:()=>di(t),onEscapeKeyDown:u=>{var _;!t||!en.isTopMostLayer(t)||((_=i.onEscapeKeyDown)==null||_.call(i,u),!u.defaultPrevented&&i.onDismiss&&(u.preventDefault(),i.onDismiss()))}}),Zt(()=>{if(!t)return;en.addLayer({node:t,isPointerBlocking:i.disableOutsidePointerEvents,dismiss:i.onDismiss});const u=n==null?void 0:n.registerNestedLayer(t);en.assignPointerEventToLayers(),en.disableBodyPointerEvents(t),Oe(()=>{t&&(en.removeLayer(t),u==null||u(),en.assignPointerEventToLayers(),en.restoreBodyPointerEvents(t))})}),ge(Yn([()=>t,()=>i.disableOutsidePointerEvents],([u,_])=>{if(!u)return;const m=en.find(u);m&&m.isPointerBlocking!==_&&(m.isPointerBlocking=_,en.assignPointerEventToLayers()),_&&en.disableBodyPointerEvents(u),Oe(()=>{en.restoreBodyPointerEvents(u)})},{defer:!0}));const d={registerNestedLayer:o};return v(Sf.Provider,{value:d,get children(){return v(st,Ne({as:"div",ref(u){var _=Nt(m=>t=m,i.ref);typeof _=="function"&&_(u)}},r))}})}function Iu(e){var o;const[t,n]=q((o=e.defaultValue)==null?void 0:o.call(e)),i=V(()=>{var s;return((s=e.value)==null?void 0:s.call(e))!==void 0}),r=V(()=>{var s;return i()?(s=e.value)==null?void 0:s.call(e):t()});return[r,s=>{ha(()=>{var c;const l=XT(s,r());return Object.is(l,r())||(i()||n(l),(c=e.onChange)==null||c.call(e,l)),l})}]}function kv(e){const[t,n]=Iu(e);return[()=>t()??!1,n]}function Nu(e={}){const[t,n]=kv({value:()=>oe(e.open),defaultValue:()=>!!oe(e.defaultOpen),onChange:o=>{var s;return(s=e.onOpenChange)==null?void 0:s.call(e,o)}}),i=()=>{n(!0)},r=()=>{n(!1)};return{isOpen:t,setIsOpen:n,open:i,close:r,toggle:()=>{t()?r():i()}}}function bf(e,t){const[n,i]=q(Om(t==null?void 0:t()));return ge(()=>{var r;i(((r=e())==null?void 0:r.tagName.toLowerCase())||Om(t==null?void 0:t()))}),n}function Om(e){return Nr(e)?e:void 0}var Pv=Object.defineProperty,Yo=(e,t)=>{for(var n in t)Pv(e,n,{get:t[n],enumerable:!0})},Fv={};Yo(Fv,{Button:()=>$v,Root:()=>ba});var Uv=["button","color","file","image","reset","submit"];function Bv(e){const t=e.tagName.toLowerCase();return t==="button"?!0:t==="input"&&e.type?Uv.indexOf(e.type)!==-1:!1}function ba(e){let t;const n=Xe({type:"button"},e),[i,r]=He(n,["ref","type","disabled"]),a=bf(()=>t,()=>"button"),o=V(()=>{const c=a();return c==null?!1:Bv({tagName:c,type:i.type})}),s=V(()=>a()==="input"),l=V(()=>a()==="a"&&(t==null?void 0:t.getAttribute("href"))!=null);return v(st,Ne({as:"button",ref(c){var d=Nt(u=>t=u,i.ref);typeof d=="function"&&d(c)},get type(){return ke(()=>!!(o()||s()))()?i.type:void 0},get role(){return!o()&&!l()?"button":void 0},get tabIndex(){return!o()&&!l()&&!i.disabled?0:void 0},get disabled(){return ke(()=>!!(o()||s()))()?i.disabled:void 0},get"aria-disabled"(){return!o()&&!s()&&i.disabled?!0:void 0},get"data-disabled"(){return i.disabled?"":void 0}},r))}var $v=ba;function ln(e){return t=>(e(t),()=>e(void 0))}var Ut=e=>typeof e=="function"?e():e,dd=(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},es=new Map,Gv=e=>{ge(()=>{const t=Ut(e.style)??{},n=Ut(e.properties)??[],i={};for(const a in t)i[a]=e.element.style[a];const r=es.get(e.key);r?r.activeCount++:es.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);Oe(()=>{var o;const a=es.get(e.key);if(a){if(a.activeCount!==1){a.activeCount--;return}es.delete(e.key);for(const[s,l]of Object.entries(a.originalStyles))e.element.style[s]=l;for(const s of a.properties)e.element.style.removeProperty(s);e.element.style.length===0&&e.element.removeAttribute("style"),(o=e.cleanup)==null||o.call(e)}})})},Am=Gv,Yv=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},Vv=(e,t)=>{const n=getComputedStyle(e),i=t==="x"?n.overflowX:n.overflowY;return i==="auto"||i==="scroll"||e.tagName==="HTML"&&i==="visible"},Hv=(e,t,n)=>{const i=t==="x"&&window.getComputedStyle(e).direction==="rtl"?-1:1;let r=e,a=0,o=0,s=!1;do{const[l,c,d]=Yv(r,t),u=d-l-i*c;(c!==0||u!==0)&&Vv(r,t)&&(a+=u,o+=c),r===(n??document.documentElement)?s=!0:r=r._$host??r.parentElement}while(r&&!s);return[a,o]},[wm,xm]=q([]),Wv=e=>wm().indexOf(e)===wm().length-1,zv=e=>{const t=Ne({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=pr();let i=[0,0],r=null,a=null;ge(()=>{Ut(t.enabled)&&(xm(c=>[...c,n]),Oe(()=>{xm(c=>c.filter(d=>d!==n))}))}),ge(()=>{if(!Ut(t.enabled)||!Ut(t.hideScrollbar))return;const{body:c}=document,d=window.innerWidth-c.offsetWidth;if(Ut(t.preventScrollbarShift)){const u={overflow:"hidden"},_=[];d>0&&(Ut(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;Am({key:"prevent-scroll",element:c,style:u,properties:_,cleanup:()=>{Ut(t.restoreScrollPosition)&&d>0&&window.scrollTo(p,m)}})}else Am({key:"prevent-scroll",element:c,style:{overflow:"hidden"}})}),ge(()=>{!Wv(n)||!Ut(t.enabled)||(document.addEventListener("wheel",s,{passive:!1}),document.addEventListener("touchstart",o,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),Oe(()=>{document.removeEventListener("wheel",s),document.removeEventListener("touchstart",o),document.removeEventListener("touchmove",l)}))});const o=c=>{i=Dm(c),r=null,a=null},s=c=>{const d=c.target,u=Ut(t.element),_=Kv(c),m=Math.abs(_[0])>Math.abs(_[1])?"x":"y",p=m==="x"?_[0]:_[1],g=Lm(d,m,p,u);let E;u&&dd(u,d)?E=!g:E=!0,E&&c.cancelable&&c.preventDefault()},l=c=>{const d=Ut(t.element),u=c.target;let _;if(c.touches.length===2)_=!Ut(t.allowPinchZoom);else{if(r==null||a===null){const m=Dm(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=Lm(u,r,a,d);d&&dd(d,u)?_=!m:_=!0}}_&&c.cancelable&&c.preventDefault()}},Kv=e=>[e.deltaX,e.deltaY],Dm=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],Lm=(e,t,n,i)=>{const r=i!==null&&dd(i,e),[a,o]=Hv(e,t,r?i:void 0);return!(n>0&&Math.abs(a)<=1||n<0&&Math.abs(o)<1)},qv=zv,Ou=qv,Qv=e=>{const t=V(()=>{const o=Ut(e.element);if(o)return getComputedStyle(o)}),n=()=>{var o;return((o=t())==null?void 0:o.animationName)??"none"},[i,r]=q(Ut(e.show)?"present":"hidden");let a="none";return ge(o=>{const s=Ut(e.show);return ha(()=>{var d;if(o===s)return s;const l=a,c=n();s?r("present"):c==="none"||((d=t())==null?void 0:d.display)==="none"?r("hidden"):r(o===!0&&l!==c?"hiding":"hidden")}),s}),ge(()=>{const o=Ut(e.element);if(!o)return;const s=c=>{c.target===o&&(a=n())},l=c=>{const u=n().includes(c.animationName);c.target===o&&u&&i()==="hiding"&&r("hidden")};o.addEventListener("animationstart",s),o.addEventListener("animationcancel",l),o.addEventListener("animationend",l),Oe(()=>{o.removeEventListener("animationstart",s),o.removeEventListener("animationcancel",l),o.removeEventListener("animationend",l)})}),{present:()=>i()==="present"||i()==="hiding",state:i,setState:r}},Xv=Qv,Ws=Xv,Zv={};Yo(Zv,{CloseButton:()=>vf,Content:()=>yf,Description:()=>Cf,Dialog:()=>ze,Overlay:()=>Rf,Portal:()=>If,Root:()=>Nf,Title:()=>Of,Trigger:()=>Af,useDialogContext:()=>Yi});var Tf=jt();function Yi(){const e=un(Tf);if(e===void 0)throw new Error("[kobalte]: `useDialogContext` must be used within a `Dialog` component");return e}function vf(e){const t=Yi(),[n,i]=He(e,["aria-label","onClick"]);return v(ba,Ne({get"aria-label"(){return n["aria-label"]||t.translations().dismiss},onClick:a=>{it(a,n.onClick),t.close()}},i))}function yf(e){let t;const n=Yi(),i=Xe({id:n.generateId("content")},e),[r,a]=He(i,["ref","onOpenAutoFocus","onCloseAutoFocus","onPointerDownOutside","onFocusOutside","onInteractOutside"]);let o=!1,s=!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||(o=!0,_.detail.originalEvent.type==="pointerdown"&&(s=!0)),On(n.triggerRef(),_.target)&&_.preventDefault(),_.detail.originalEvent.type==="focusin"&&s&&_.preventDefault())},u=_=>{var m;(m=r.onCloseAutoFocus)==null||m.call(r,_),n.modal()?(_.preventDefault(),Dt(n.triggerRef())):(_.defaultPrevented||(o||Dt(n.triggerRef()),_.preventDefault()),o=!1,s=!1)};return Cu({isDisabled:()=>!(n.isOpen()&&n.modal()),targets:()=>t?[t]:[]}),Ou({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),yu({trapFocus:()=>n.isOpen()&&n.modal(),onMountAutoFocus:r.onOpenAutoFocus,onUnmountAutoFocus:u},()=>t),ge(()=>Oe(n.registerContentId(a.id))),v(j,{get when(){return n.contentPresent()},get children(){return v(Ru,Ne({ref(_){var m=Nt(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 Cf(e){const t=Yi(),n=Xe({id:t.generateId("description")},e),[i,r]=He(n,["id"]);return ge(()=>Oe(t.registerDescriptionId(i.id))),v(st,Ne({as:"p",get id(){return i.id}},r))}function Rf(e){const t=Yi(),[n,i]=He(e,["ref","style","onPointerDown"]),r=a=>{it(a,n.onPointerDown),a.target===a.currentTarget&&a.preventDefault()};return v(j,{get when(){return t.overlayPresent()},get children(){return v(st,Ne({as:"div",ref(a){var o=Nt(t.setOverlayRef,n.ref);typeof o=="function"&&o(a)},get style(){return $o({"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 If(e){const t=Yi();return v(j,{get when(){return t.contentPresent()||t.overlayPresent()},get children(){return v(fu,e)}})}var Mm={dismiss:"Dismiss"};function Nf(e){const t=`dialog-${pr()}`,n=Xe({id:t,modal:!0,translations:Mm},e),[i,r]=q(),[a,o]=q(),[s,l]=q(),[c,d]=q(),[u,_]=q(),[m,p]=q(),g=Nu({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:T=>{var b;return(b=n.onOpenChange)==null?void 0:b.call(n,T)}}),E=()=>n.forceMount||g.isOpen(),{present:h}=Ws({show:E,element:()=>c()??null}),{present:f}=Ws({show:E,element:()=>u()??null}),S={translations:()=>n.translations??Mm,isOpen:g.isOpen,modal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??S.modal(),contentId:i,titleId:a,descriptionId:s,triggerRef:m,overlayRef:c,setOverlayRef:d,contentRef:u,setContentRef:_,overlayPresent:h,contentPresent:f,close:g.close,toggle:g.toggle,setTriggerRef:p,generateId:Sa(()=>n.id),registerContentId:ln(r),registerTitleId:ln(o),registerDescriptionId:ln(l)};return v(Tf.Provider,{value:S,get children(){return n.children}})}function Of(e){const t=Yi(),n=Xe({id:t.generateId("title")},e),[i,r]=He(n,["id"]);return ge(()=>Oe(t.registerTitleId(i.id))),v(st,Ne({as:"h2",get id(){return i.id}},r))}function Af(e){const t=Yi(),[n,i]=He(e,["ref","onClick"]);return v(ba,Ne({ref(a){var o=Nt(t.setTriggerRef,n.ref);typeof o=="function"&&o(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=>{it(a,n.onClick),t.toggle()}},i))}var ze=Object.assign(Nf,{CloseButton:vf,Content:yf,Description:Cf,Overlay:Rf,Portal:If,Title:Of,Trigger:Af});const jv=e=>typeof e=="function",zs=(e,t)=>jv(e)?e(t):e;var ht;(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"})(ht||(ht={}));const Ks=Symbol("store-raw"),Kr=Symbol("store-node"),ei=Symbol("store-has"),wf=Symbol("store-self");function xf(e){let t=e[ar];if(!t&&(Object.defineProperty(e,ar,{value:t=new Proxy(e,ty)}),!Array.isArray(e))){const n=Object.keys(e),i=Object.getOwnPropertyDescriptors(e);for(let r=0,a=n.length;r<a;r++){const o=n[r];i[o].get&&Object.defineProperty(e,o,{enumerable:i[o].enumerable,get:i[o].get.bind(t)})}}return t}function na(e){let t;return e!=null&&typeof e=="object"&&(e[ar]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function ia(e,t=new Set){let n,i,r,a;if(n=e!=null&&e[Ks])return n;if(!na(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let o=0,s=e.length;o<s;o++)r=e[o],(i=ia(r,t))!==r&&(e[o]=i)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);const o=Object.keys(e),s=Object.getOwnPropertyDescriptors(e);for(let l=0,c=o.length;l<c;l++)a=o[l],!s[a].get&&(r=e[a],(i=ia(r,t))!==r&&(e[a]=i))}return e}function qs(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Eo(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 Jv(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===ar||t===Kr||(delete n.value,delete n.writable,n.get=()=>e[ar][t]),n}function Df(e){sd()&&Eo(qs(e,Kr),wf)()}function ey(e){return Df(e),Reflect.ownKeys(e)}const ty={get(e,t,n){if(t===Ks)return e;if(t===ar)return n;if(t===ad)return Df(e),n;const i=qs(e,Kr),r=i[t];let a=r?r():e[t];if(t===Kr||t===ei||t==="__proto__")return a;if(!r){const o=Object.getOwnPropertyDescriptor(e,t);sd()&&(typeof a!="function"||e.hasOwnProperty(t))&&!(o&&o.get)&&(a=Eo(i,t,a)())}return na(a)?xf(a):a},has(e,t){return t===Ks||t===ar||t===ad||t===Kr||t===ei||t==="__proto__"?!0:(sd()&&Eo(qs(e,ei),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:ey,getOwnPropertyDescriptor:Jv};function ra(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[ei]&&e[ei][t]&&r!==void 0&&e[ei][t].$()):(e[t]=n,e[ei]&&e[ei][t]&&r===void 0&&e[ei][t].$());let o=qs(e,Kr),s;if((s=Eo(o,t,r))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let l=e.length;l<a;l++)(s=o[l])&&s.$();(s=Eo(o,"length",a))&&s.$(e.length)}(s=o[wf])&&s.$()}function Lf(e,t){const n=Object.keys(t);for(let i=0;i<n.length;i+=1){const r=n[i];ra(e,r,t[r])}}function ny(e,t){if(typeof t=="function"&&(t=t(e)),t=ia(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&&ra(e,n,r)}ra(e,"length",i)}else Lf(e,t)}function za(e,t,n=[]){let i,r=e;if(t.length>1){i=t.shift();const o=typeof i,s=Array.isArray(e);if(Array.isArray(i)){for(let l=0;l<i.length;l++)za(e,[i[l]].concat(t),n);return}else if(s&&o==="function"){for(let l=0;l<e.length;l++)i(e[l],l)&&za(e,[l].concat(t),n);return}else if(s&&o==="object"){const{from:l=0,to:c=e.length-1,by:d=1}=i;for(let u=l;u<=c;u+=d)za(e,[u].concat(t),n);return}else if(t.length>1){za(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=ia(a),i===void 0||na(r)&&na(a)&&!Array.isArray(a)?Lf(r,a):ra(e,i,a))}function iy(...[e,t]){const n=ia(e||{}),i=Array.isArray(n),r=xf(n);function a(...o){WT(()=>{i&&o.length===1?ny(n,o[0]):za(n,o)})}return[r,a]}const Qs=new WeakMap,Mf={get(e,t){if(t===Ks)return e;const n=e[t];let i;return na(n)?Qs.get(n)||(Qs.set(n,i=new Proxy(n,Mf)),i):n},set(e,t,n){return ra(e,t,ia(n)),!0},deleteProperty(e,t){return ra(e,t,void 0,!0),!0}};function ts(e){return t=>{if(na(t)){let n;(n=Qs.get(t))||Qs.set(t,n=new Proxy(t,Mf)),e(n)}return t}}const[nr,Ei]=iy({toasts:[],pausedAt:void 0}),ry=()=>{const{pausedAt:e,toasts:t}=nr;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&&Dn({type:ht.DISMISS_TOAST,toastId:r.id});return}return setTimeout(()=>{Dn({type:ht.DISMISS_TOAST,toastId:r.id})},a)})},to=new Map,km=(e,t)=>{if(to.has(e))return;const n=setTimeout(()=>{to.delete(e),Dn({type:ht.REMOVE_TOAST,toastId:e})},t);to.set(e,n)},ay=e=>{const t=to.get(e);to.delete(e),t&&clearTimeout(t)},Dn=e=>{switch(e.type){case ht.ADD_TOAST:Ei("toasts",r=>{const a=r;return[e.toast,...a]});break;case ht.DISMISS_TOAST:const{toastId:t}=e,n=nr.toasts;if(t){const r=n.find(a=>a.id===t);r&&km(t,r.unmountDelay),Ei("toasts",a=>a.id===t,ts(a=>a.visible=!1))}else n.forEach(r=>{km(r.id,r.unmountDelay)}),Ei("toasts",r=>r.id!==void 0,ts(r=>r.visible=!1));break;case ht.REMOVE_TOAST:if(!e.toastId){Ei("toasts",[]);break}Ei("toasts",r=>r.filter(o=>o.id!==e.toastId));break;case ht.UPDATE_TOAST:e.toast.id&&ay(e.toast.id),Ei("toasts",r=>r.id===e.toast.id,r=>({...r,...e.toast}));break;case ht.UPSERT_TOAST:nr.toasts.find(r=>r.id===e.toast.id)?Dn({type:ht.UPDATE_TOAST,toast:e.toast}):Dn({type:ht.ADD_TOAST,toast:e.toast});break;case ht.START_PAUSE:Ei(ts(r=>{r.pausedAt=Date.now(),r.toasts.forEach(a=>{a.paused=!0})}));break;case ht.END_PAUSE:const i=e.time-(nr.pausedAt||0);Ei(ts(r=>{r.pausedAt=void 0,r.toasts.forEach(a=>{a.pauseDuration+=i,a.paused=!1})}));break}},oy={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},qr={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},kf={position:"top-right",toastOptions:qr,gutter:8,containerStyle:{},containerClassName:""},ns="16px",sy={position:"fixed","z-index":9999,top:ns,bottom:ns,left:ns,right:ns,"pointer-events":"none"},ly=(()=>{let e=0;return()=>String(++e)})(),cy=e=>{fy(t=>({containerClassName:e.containerClassName??t.containerClassName,containerStyle:e.containerStyle??t.containerStyle,gutter:e.gutter??t.gutter,position:e.position??t.position,toastOptions:{...e.toastOptions}}))},dy=(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}},uy=(e,t)=>{const n=e.getBoundingClientRect();n.height!==t.height&&Dn({type:ht.UPDATE_TOAST,toast:{id:t.id,height:n.height}})},_y=(e,t)=>{const{toasts:n}=nr,i=Or().gutter||kf.gutter||8,r=n.filter(l=>(l.position||t)===t&&l.height),a=r.findIndex(l=>l.id===e.id),o=r.filter((l,c)=>c<a&&l.visible).length;return r.slice(0,o).reduce((l,c)=>l+i+(c.height||0),0)},my=(e,t)=>(e.position||t).includes("top")?1:-1,py={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"},gy={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},is={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},Xs=e=>({calcMode:"spline",keyTimes:"0; 1",keySplines:e}),[Or,fy]=q(kf),Ey=(e,t="blank",n)=>{var i,r,a;return{...qr,...Or().toastOptions,...n,type:t,message:e,pauseDuration:0,createdAt:Date.now(),visible:!0,id:n.id||ly(),paused:!1,style:{...qr.style,...(i=Or().toastOptions)==null?void 0:i.style,...n.style},duration:n.duration||((r=Or().toastOptions)==null?void 0:r.duration)||oy[t],position:n.position||((a=Or().toastOptions)==null?void 0:a.position)||Or().position||qr.position}},Vo=e=>(t,n={})=>od(()=>{const i=nr.toasts.find(a=>a.id===n.id),r=Ey(t,e,{...i,duration:void 0,...n});return Dn({type:ht.UPSERT_TOAST,toast:r}),r.id}),En=(e,t)=>Vo("blank")(e,t);ha(()=>En);En.error=Vo("error");En.success=Vo("success");En.loading=Vo("loading");En.custom=Vo("custom");En.dismiss=e=>{Dn({type:ht.DISMISS_TOAST,toastId:e})};En.promise=(e,t,n)=>{const i=En.loading(t.loading,{...n});return e.then(r=>(En.success(zs(t.success,r),{id:i,...n}),r)).catch(r=>{En.error(zs(t.error,r),{id:i,...n})}),e};En.remove=e=>{Dn({type:ht.REMOVE_TOAST,toastId:e})};var hy=G("<div><style>.sldt-active{z-index:9999;}.sldt-active>*{pointer-events:auto;}");const Sy=e=>(ge(()=>{cy(e)}),ge(()=>{const t=ry();Oe(()=>{t&&t.forEach(n=>n&&clearTimeout(n))})}),(()=>{var t=hy();return t.firstChild,C(t,v(Ge,{get each(){return nr.toasts},children:n=>v(yy,{toast:n})}),null),de(n=>{var i={...sy,...e.containerStyle},r=e.containerClassName;return n.e=In(t,i,n.e),r!==n.t&&Be(t,n.t=r),n},{e:void 0,t:void 0}),t})());var rs=G("<div>"),by=G("<div><div>");const Ty=e=>{let t;return ge(()=>{if(!t)return;const n=my(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=by(),i=n.firstChild,r=t;return typeof r=="function"?Tt(r,n):t=n,C(n,v(Eu,{get children(){return[v(ni,{get when(){return e.toast.icon},get children(){var a=rs();return C(a,()=>e.toast.icon),de(o=>In(a,is,o)),a}}),v(ni,{get when(){return e.toast.type==="loading"},get children(){var a=rs();return C(a,v(xy,Ne(()=>e.toast.iconTheme))),de(o=>In(a,is,o)),a}}),v(ni,{get when(){return e.toast.type==="success"},get children(){var a=rs();return C(a,v(Ny,Ne(()=>e.toast.iconTheme))),de(o=>In(a,is,o)),a}}),v(ni,{get when(){return e.toast.type==="error"},get children(){var a=rs();return C(a,v(Ay,Ne(()=>e.toast.iconTheme))),de(o=>In(a,is,o)),a}})]}}),i),Hn(i,Ne(()=>e.toast.ariaProps),!1,!0),C(i,()=>zs(e.toast.message,e.toast)),de(a=>{var o=e.toast.className,s={...py,...e.toast.style},l=gy;return o!==a.e&&Be(n,a.e=o),a.t=In(n,s,a.t),a.a=In(i,l,a.a),a},{e:void 0,t:void 0,a:void 0}),n})()};var vy=G("<div>");const yy=e=>{const t=()=>{const r=e.toast.position||qr.position,a=_y(e.toast,r);return dy(r,a)},n=V(()=>t());let i;return Zt(()=>{i&&uy(i,e.toast)}),(()=>{var r=vy();r.addEventListener("mouseleave",()=>Dn({type:ht.END_PAUSE,time:Date.now()})),r.addEventListener("mouseenter",()=>Dn({type:ht.START_PAUSE,time:Date.now()}));var a=i;return typeof a=="function"?Tt(a,r):i=r,C(r,(()=>{var o=ke(()=>e.toast.type==="custom");return()=>o()?zs(e.toast.message,e.toast):v(Ty,{get toast(){return e.toast},get position(){return e.toast.position||qr.position}})})()),de(o=>{var s=n(),l=e.toast.visible?"sldt-active":"";return o.e=In(r,s,o.e),l!==o.t&&Be(r,o.t=l),o},{e:void 0,t:void 0}),r})()};var Cy=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),Ry=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 Pf=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=Cy(),i=n.firstChild,r=i.nextSibling;return Hn(i,t,!0,!1),Hn(r,t,!0,!1),de(()=>Pe(n,"fill",e.fill)),n})()},Ff=e=>{const t={dur:"1s",begin:e.begin||"320ms",fill:"freeze",...Xs("0.0 0.0 0.2 1")};return(()=>{var n=Ry(),i=n.firstChild,r=i.nextSibling;return Hn(i,t,!0,!1),Hn(r,t,!0,!1),de(()=>Pe(n,"fill",e.fill)),n})()};var Iy=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 Ny=e=>{const t=e.primary||"#34C759";return(()=>{var n=Iy(),i=n.firstChild,r=i.firstChild;return C(n,v(Pf,{fill:t}),i),C(n,v(Ff,{fill:t,begin:"350ms"}),i),Hn(r,Ne(()=>Xs("0.0, 0.0, 0.58, 1.0")),!0,!1),de(()=>Pe(i,"stroke",e.secondary||"#FCFCFC")),n})()};var Oy=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 Ay=e=>{const t=e.primary||"#FF3B30";return(()=>{var n=Oy(),i=n.firstChild,r=i.firstChild,a=i.nextSibling,o=a.firstChild;return C(n,v(Pf,{fill:t}),i),C(n,v(Ff,{fill:t}),i),Hn(r,Ne(()=>Xs("0.0, 0.0, 0.58, 1.0")),!0,!1),Hn(o,Ne(()=>Xs("0.0, 0.0, 0.58, 1.0")),!0,!1),de(s=>{var l=e.secondary||"#FFFFFF",c=e.secondary||"#FFFFFF";return l!==s.e&&Pe(i,"stroke",s.e=l),c!==s.t&&Pe(a,"fill",s.t=c),s},{e:void 0,t:void 0}),n})()};var wy=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 xy=e=>(()=>{var t=wy(),n=t.firstChild,i=n.nextSibling;return de(r=>{var a=e.primary||"#E5E7EB",o=e.secondary||"#4b5563";return a!==r.e&&Pe(n,"stroke",r.e=a),o!==r.t&&Pe(i,"stroke",r.t=o),r},{e:void 0,t:void 0}),t})(),[ud,Au]=q(null);function ri(e,t){Au({type:"alert",message:e,...t})}function Dy(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(i=>{Au({type:"confirm",message:e,...t,resolve:i})})}function Ly(){Au(null)}var My=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>'),ky=G('<div class="mt-6 flex justify-end gap-3"><button type=button class=button-primary>'),Py=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),Fy=G('<p class="mt-2 text-secondary">'),Uy=G("<button type=button class=button-secondary>");const By={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 bc(e,t){var i,r,a,o;const n=t??ud();(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&&((o=n==null?void 0:n.onConfirm)==null||o.call(n)),Ly()}const $y=()=>{let e;return ge(()=>{ud()&&queueMicrotask(()=>{e==null||e.focus()})}),v(j,{get when(){return ud()},keyed:!0,children:t=>{const n=t.variant??"info",i=By[n],r=t.title||i.fallbackTitle,a=t.type==="confirm",o=t.confirmLabel||(a?"Confirm":"OK"),s=t.cancelLabel||"Cancel";return v(ze,{open:!0,modal:!0,onOpenChange:l=>{l||bc(!1,t)},get children(){return v(ze.Portal,{get children(){return[v(ze.Overlay,{class:"modal-overlay"}),(()=>{var l=Py();return C(l,v(ze.Content,{class:"modal-surface w-full max-w-sm p-6 border border-base shadow-2xl",tabIndex:-1,get children(){return[(()=>{var c=My(),d=c.firstChild,u=d.nextSibling;return C(d,()=>i.symbol),C(u,v(ze.Title,{class:"text-lg font-semibold text-primary",children:r}),null),C(u,v(ze.Description,{class:"text-sm text-secondary mt-1 whitespace-pre-line",get children(){return[ke(()=>t.message),ke(()=>ke(()=>!!t.detail)()&&(()=>{var _=Fy();return C(_,()=>t.detail),_})())]}}),null),de(_=>{var m=i.badgeBg,p=i.badgeBorder,g=i.badgeText;return m!==_.e&&zr(d,"background-color",_.e=m),p!==_.t&&zr(d,"border-color",_.t=p),g!==_.a&&zr(d,"color",_.a=g),_},{e:void 0,t:void 0,a:void 0}),c})(),(()=>{var c=ky(),d=c.firstChild;return C(c,a&&(()=>{var u=Uy();return u.$$click=()=>bc(!1,t),C(u,s),u})(),d),d.$$click=()=>bc(!0,t),Tt(u=>{e=u},d),C(d,o),c})()]}})),l})()]}})}})}})};mt(["click"]);const vr={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 Gy=G("<svg>");const Yy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),pt=e=>{const[t,n]=He(e,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var i=Gy();return Hn(i,Ne(vr,{get width(){return t.size??vr.width},get height(){return t.size??vr.height},get stroke(){return t.color??vr.stroke},get"stroke-width"(){return ke(()=>!!t.absoluteStrokeWidth)()?Number(t.strokeWidth??vr["stroke-width"])*24/Number(t.size):Number(t.strokeWidth??vr["stroke-width"])},get class(){return`lucide lucide-${Yy((t==null?void 0:t.name)??"icon")} ${t.class!=null?t.class:""}`}},n),!0,!0),C(i,v(Ge,{get each(){return t.iconNode},children:([r,a])=>v(sf,Ne({component:r},a))})),i})()},Vy=[["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"}]],Hy=e=>v(pt,Ne(e,{name:"AlertCircle",iconNode:Vy})),Wy=[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]],Uf=e=>v(pt,Ne(e,{name:"ArrowUpLeft",iconNode:Wy})),zy=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ky=e=>v(pt,Ne(e,{name:"Check",iconNode:zy})),qy=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],wu=e=>v(pt,Ne(e,{name:"ChevronDown",iconNode:qy})),Qy=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Xy=e=>v(pt,Ne(e,{name:"ChevronRight",iconNode:Qy})),Zy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],jy=e=>v(pt,Ne(e,{name:"Clock",iconNode:Zy})),Jy=[["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"}]],eC=e=>v(pt,Ne(e,{name:"Copy",iconNode:Jy})),tC=[["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"}]],nC=e=>v(pt,Ne(e,{name:"File",iconNode:tC})),iC=[["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"}]],Bf=e=>v(pt,Ne(e,{name:"FolderOpen",iconNode:iC})),rC=[["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"}]],aC=e=>v(pt,Ne(e,{name:"FolderPlus",iconNode:rC})),oC=[["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"}]],xu=e=>v(pt,Ne(e,{name:"Folder",iconNode:oC})),sC=[["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"}]],lC=e=>v(pt,Ne(e,{name:"Globe",iconNode:sC})),cC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],dC=e=>v(pt,Ne(e,{name:"Info",iconNode:cC})),uC=[["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"}]],Pm=e=>v(pt,Ne(e,{name:"Key",iconNode:uC})),_C=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ho=e=>v(pt,Ne(e,{name:"Loader2",iconNode:_C})),mC=[["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"}]],pC=e=>v(pt,Ne(e,{name:"MessageSquare",iconNode:mC})),gC=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Du=e=>v(pt,Ne(e,{name:"Plus",iconNode:gC})),fC=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],EC=e=>v(pt,Ne(e,{name:"Search",iconNode:fC})),hC=[["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"}]],SC=e=>v(pt,Ne(e,{name:"Settings",iconNode:hC})),bC=[["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"}]],Lu=e=>v(pt,Ne(e,{name:"Trash2",iconNode:bC})),TC=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],kl=e=>v(pt,Ne(e,{name:"X",iconNode:TC})),Fm="http://127.0.0.1:9898";var of;const vC=typeof window<"u"?(of=window.location)==null?void 0:of.origin:void 0,yC=typeof window<"u"?window.__CODENOMAD_API_BASE__??vC??Fm:Fm,CC=typeof window<"u"?window.__CODENOMAD_EVENTS_URL__??"/api/events":"/api/events",Zs=yC,Um=IC(Zs,CC),RC=Zs;function IC(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 Bm="[HTTP]";function as(e,t){if(t){console.log(`${Bm} ${e}`,t);return}console.log(`${Bm} ${e}`)}async function At(e,t){const n=Zs?new URL(e,Zs).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();as(`${r} ${e}`);try{const o=await fetch(n,{...t,headers:i});if(!o.ok){const l=await o.text();throw as(`${r} ${e} -> ${o.status}`,{durationMs:Date.now()-a,error:l}),new Error(l||`Request failed with ${o.status}`)}const s=Date.now()-a;return as(`${r} ${e} -> ${o.status}`,{durationMs:s}),o.status===204?void 0:await o.json()}catch(o){throw as(`${r} ${e} failed`,{durationMs:Date.now()-a,error:o}),o}}const Xt={fetchWorkspaces(){return At("/api/workspaces")},createWorkspace(e){return At("/api/workspaces",{method:"POST",body:JSON.stringify(e)})},fetchServerMeta(){return At("/api/meta")},deleteWorkspace(e){return At(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})},listWorkspaceFiles(e,t="."){const n=new URLSearchParams({path:t});return At(`/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),At(`/api/workspaces/${encodeURIComponent(e)}/files/search?${r.toString()}`)},readWorkspaceFile(e,t){const n=new URLSearchParams({path:t});return At(`/api/workspaces/${encodeURIComponent(e)}/files/content?${n.toString()}`)},fetchConfig(){return At("/api/config/app")},updateConfig(e){return At("/api/config/app",{method:"PUT",body:JSON.stringify(e)})},listBinaries(){return At("/api/config/binaries")},createBinary(e){return At("/api/config/binaries",{method:"POST",body:JSON.stringify(e)})},updateBinary(e,t){return At(`/api/config/binaries/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})},deleteBinary(e){return At(`/api/config/binaries/${encodeURIComponent(e)}`,{method:"DELETE"})},validateBinary(e){return At("/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 At(i?`/api/filesystem?${i}`:"/api/filesystem")},readInstanceData(e){return At(`/api/storage/instances/${encodeURIComponent(e)}`)},writeInstanceData(e,t){return At(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})},deleteInstanceData(e){return At(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"DELETE"})},connectEvents(e,t){console.log(`[SSE] Connecting to ${Um}`);const n=new EventSource(Um);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}},$m=1e3,NC=1e4,Gm="[SSE]";function os(e,t){if(t){console.log(`${Gm} ${e}`,t);return}console.log(`${Gm} ${e}`)}class OC{constructor(){this.handlers=new Map,this.source=null,this.retryDelay=$m,this.connect()}connect(){this.source&&this.source.close(),os("Connecting to backend events stream"),this.source=Xt.connectEvents(t=>this.dispatch(t),()=>this.scheduleReconnect()),this.source.onopen=()=>{os("Events stream connected"),this.retryDelay=$m}}scheduleReconnect(){this.source&&(this.source.close(),this.source=null),os("Events stream disconnected, scheduling reconnect",{delayMs:this.retryDelay}),setTimeout(()=>{this.retryDelay=Math.min(this.retryDelay*2,NC),this.connect()},this.retryDelay)}dispatch(t){var n,i;os(`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 So=new OC,Ym={messageHistory:[],agentModelSelections:{}};function Vm(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 AC{constructor(){this.configChangeListeners=new Set,this.configCache=null,this.loadPromise=null,this.instanceDataCache=new Map,this.instanceDataListeners=new Map,this.instanceLoadPromises=new Map,So.on("config.appChanged",t=>{t.type==="config.appChanged"&&this.setConfigCache(t.config)}),So.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=Xt.fetchConfig().then(t=>(this.setConfigCache(t),t)).finally(()=>{this.loadPromise=null})),this.loadPromise)}async updateConfig(t){const n=await Xt.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=Xt.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 Xt.writeInstanceData(t,i),this.setInstanceDataCache(t,i)}async deleteInstanceData(t){await Xt.deleteInstanceData(t),this.setInstanceDataCache(t,Ym)}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&&Vm(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??Ym,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&&Vm(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 or=new AC,Pl={messageHistory:[],agentModelSelections:{}},[Mu,$f]=q(new Map),ss=new Map,aa=new Map;function Gf(e){const t=e??Pl;return{...t,messageHistory:Array.isArray(t.messageHistory)?[...t.messageHistory]:[],agentModelSelections:{...t.agentModelSelections??{}}}}function Hm(e){if(aa.has(e))return;const t=or.onInstanceDataChanged(e,n=>{js(e,n)});aa.set(e,t)}function wC(e){const t=aa.get(e);t&&(t(),aa.delete(e))}function js(e,t){$f(n=>{const i=new Map(n);return i.set(e,Gf(t)),i})}async function gr(e){if(!e||Mu().has(e))return;if(ss.has(e)){await ss.get(e);return}const t=or.loadInstanceData(e).then(n=>{js(e,n),Hm(e)}).catch(n=>{console.warn("Failed to load instance data:",n),js(e,Pl),Hm(e)}).finally(()=>{ss.delete(e)});ss.set(e,t),await t}async function ku(e,t){if(!e)return;await gr(e);const n=Mu().get(e)??Pl,i=Gf(n);t(i);try{await or.saveInstanceData(e,i)}catch(r){console.warn("Failed to persist instance data:",r)}js(e,i)}function Pu(e){return Mu().get(e)??Pl}function xC(e){$f(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),wC(e)}const DC=jt(),LC={getInstanceConfig:Pu,ensureInstanceConfig:gr,updateInstanceConfig:ku,clearInstanceConfig:xC},MC=e=>(Oe(()=>{for(const t of aa.values())t();aa.clear()}),v(DC.Provider,{value:LC,get children(){return e.children}})),kC=20,PC=5,Wi={showThinkingBlocks:!1,environmentVariables:{},modelRecents:[],diffViewMode:"split",toolOutputExpansion:"expanded",diagnosticsExpansion:"expanded"};function Yf(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 Fl(e){const t=e??{},n={...Wi.environmentVariables,...t.environmentVariables??{}},r=(t.modelRecents??Wi.modelRecents).map(a=>({...a}));return{showThinkingBlocks:t.showThinkingBlocks??Wi.showThinkingBlocks,lastUsedBinary:t.lastUsedBinary??Wi.lastUsedBinary,environmentVariables:n,modelRecents:r,diffViewMode:t.diffViewMode??Wi.diffViewMode,toolOutputExpansion:t.toolOutputExpansion??Wi.toolOutputExpansion,diagnosticsExpansion:t.diagnosticsExpansion??Wi.diagnosticsExpansion}}const[Vi,FC]=q(Wf()),UC=V(()=>Vi()),[Vf,BC]=q(!1),_t=V(()=>Vi().preferences),$C=V(()=>Vi().recentFolders??[]),GC=V(()=>Vi().opencodeBinaries??[]),Hf=V(()=>Vi().theme??"dark");let ls=null;function Ul(e){return{preferences:Fl(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 Wf(){return Ul()}function YC(e){var i;const t=!!((i=e==null?void 0:e.preferences)!=null&&i.agentModelSelections);return{cleaned:Ul(e),migrated:t}}async function Fu(e){try{const t=e??await or.loadConfig(),{cleaned:n,migrated:i}=YC(t);_d(n),i&&or.updateConfig(n).catch(r=>{console.error("Failed to persist legacy config cleanup:",r)})}catch(t){console.error("Failed to load config:",t),_d(Wf())}}function _d(e){FC(Ul(e)),BC(!0)}function VC(){return Ul(Vi())}function HC(e,t){if(Yf(e,t))return;const n=zf(e,t);n.length>0&&console.debug("[Config] Changes",n)}function zf(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]),o=[];for(const s of a){const l=[...n,s],c=e[s],d=t[s];o.push(...zf(c,d,l))}return o}function pi(e){const t=Vi(),n=VC();e(n),HC(t,n),_d(n),WC(n)}async function WC(e){try{await Uu(),await or.updateConfig(e)}catch(t){console.error("Failed to save config:",t),Fu().catch(n=>{console.error("Failed to refresh config:",n)})}}function zC(e){Hf()!==e&&pi(t=>{t.theme=e})}async function Uu(){Vf()||(ls||(ls=Fu().finally(()=>{ls=null})),await ls)}function Kf(e,t){const n=t.filter(i=>i.path!==e);return n.unshift({path:e,lastAccessed:Date.now()}),n.slice(0,kC)}function Bu(e,t,n){const i=Date.now(),r=n.find(o=>o.path===e);if(r){const o={...r,lastUsed:i},s=n.filter(l=>l.path!==e);return[o,...s]}return[t?{path:e,version:t,lastUsed:i}:{path:e,lastUsed:i},...n].slice(0,10)}function fr(e){const t=Vi().preferences,n=Fl({...t,...e});Yf(t,n)||pi(i=>{i.preferences=n})}function KC(e){_t().diffViewMode!==e&&fr({diffViewMode:e})}function qC(e){_t().toolOutputExpansion!==e&&fr({toolOutputExpansion:e})}function QC(e){_t().diagnosticsExpansion!==e&&fr({diagnosticsExpansion:e})}function XC(){fr({showThinkingBlocks:!_t().showThinkingBlocks})}function ZC(e){pi(t=>{t.recentFolders=Kf(e,t.recentFolders)})}function jC(e){pi(t=>{t.recentFolders=t.recentFolders.filter(n=>n.path!==e)})}function JC(e,t){pi(n=>{n.opencodeBinaries=Bu(e,t,n.opencodeBinaries)})}function eR(e){pi(t=>{t.opencodeBinaries=t.opencodeBinaries.filter(n=>n.path!==e)})}function tR(e){const t=e||_t().lastUsedBinary||"opencode";pi(n=>{n.preferences=Fl({...n.preferences,lastUsedBinary:t}),n.opencodeBinaries=Bu(t,void 0,n.opencodeBinaries)})}function nR(e,t){pi(n=>{const i=t&&t.trim().length>0?t:n.preferences.lastUsedBinary||"opencode";n.recentFolders=Kf(e,n.recentFolders),n.preferences=Fl({...n.preferences,lastUsedBinary:i}),n.opencodeBinaries=Bu(i,void 0,n.opencodeBinaries)})}function $u(e){fr({environmentVariables:e})}function iR(e,t){const i={..._t().environmentVariables||{},[e]:t};$u(i)}function rR(e){const t=_t().environmentVariables||{},{[e]:n,...i}=t;$u(i)}function qf(e){if(!e.providerId||!e.modelId)return;const n=(_t().modelRecents??[]).filter(r=>r.providerId!==e.providerId||r.modelId!==e.modelId),i=[e,...n].slice(0,PC);fr({modelRecents:i})}async function Bl(e,t,n){!e||!t||!n.providerId||!n.modelId||(await gr(e),await ku(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 Qf(e,t){return!e||!t?void 0:(await gr(e),(Pu(e).agentModelSelections??{})[t])}Uu().catch(e=>{console.error("Failed to initialize config:",e)});const Xf=jt(),aR={isLoaded:Vf,config:UC,preferences:_t,recentFolders:$C,opencodeBinaries:GC,themePreference:Hf,setThemePreference:zC,updateConfig:pi,toggleShowThinkingBlocks:XC,setDiffViewMode:KC,setToolOutputExpansion:qC,setDiagnosticsExpansion:QC,addRecentFolder:ZC,removeRecentFolder:jC,addOpenCodeBinary:JC,removeOpenCodeBinary:eR,updateLastUsedBinary:tR,recordWorkspaceLaunch:nR,updatePreferences:fr,updateEnvironmentVariables:$u,addEnvironmentVariable:iR,removeEnvironmentVariable:rR,addRecentModelPreference:qf,setAgentModelPreference:Bl,getAgentModelPreference:Qf},oR=e=>(Zt(()=>{Uu().catch(n=>{console.error("Failed to initialize config:",n)});const t=or.onConfigChanged(n=>{Fu(n).catch(i=>{console.error("Failed to refresh config:",i)})});return()=>{t()}}),v(Xf.Provider,{value:aR,get children(){return e.children}}));function Hi(){const e=un(Xf);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e}var sR=G('<p class="text-xs text-muted mt-1 font-mono break-all">Root: '),lR=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'),cR=G('<div class="flex items-center gap-2 px-4 py-2 text-xs text-secondary"><span>Loading <!>…'),dR=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'),uR=G('<div class="flex items-center gap-2"><span>Loading <!>…'),_R=G('<div class="flex items-center justify-center py-6 text-sm text-secondary">'),mR=G("<span class=text-red-500>"),pR=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'),gR=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'),fR=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 ER=200;function Tc(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 Pa(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 hR=e=>{const[t,n]=q(""),[i,r]=q([]),[a,o]=q(null),[s,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([]),o(null),l(null)}async function T(N,I=!1){const x=Tc(N);if(E.has(x)&&h.has(x))return I&&(o(h.get(x)??null),r(E.get(x)??[])),h.get(x);if(f.has(x)){const W=await f.get(x);return I&&(o(W),r(E.get(x)??[])),W}const L=(async()=>{l(x);const W=await Xt.listFileSystem(x==="."?".":x,{includeFiles:e.mode==="files"});return E.set(x,W.entries),h.set(x,W.metadata),t()||n(W.metadata.rootPath),s()===x&&l(null),W.metadata})().catch(W=>{throw s()===x&&l(null),W});f.set(x,L);try{const W=await L;if(I){const J=Tc(W.currentPath);o(W),r(E.get(J)??E.get(x)??[])}return W}finally{f.delete(x)}}async function b(){d(null),S();try{const N=await T(".",!0);n(N.rootPath),r(E.get(Tc(N.currentPath))??[])}catch(N){const I=N instanceof Error?N.message:"Unable to load filesystem";d(I)}}function R(){const N=s();return N?N==="."?t()||"workspace root":Pa(t(),N):"filesystem"}function y(){const N=a();return N?N.pathKind==="relative"?Pa(t(),N.currentPath):N.displayPath:t()}function O(N){N.target===N.currentTarget&&e.onClose()}function P(N){const I=Pa(t(),N.path);e.onSelect(I)}function w(N){T(N,!0).catch(I=>{console.error("Failed to open directory",I),d(I instanceof Error?I.message:"Unable to open directory")})}function F(){var I;const N=(I=a())==null?void 0:I.parentPath;N&&w(N)}const Y=V(()=>{const N=u().trim().toLowerCase(),I=i().filter(x=>e.mode==="directories"?x.type==="directory":!0);return N?I.filter(x=>Pa(t(),x.path).toLowerCase().includes(N)||x.name.toLowerCase().includes(N)):I}),B=V(()=>Y().slice(0,ER)),A=V(()=>{const N=[],I=a();I!=null&&I.parentPath&&N.push({type:"up",path:I.parentPath});for(const x of B())N.push({type:"entry",entry:x});return N});return ge(()=>{const N=B();if(N.length===0){p(0);return}m()>=N.length&&p(N.length-1)}),ge(()=>{if(!e.open)return;_(""),p(0),b(),setTimeout(()=>g==null?void 0:g.focus(),50);const N=I=>{if(!e.open)return;const x=B();if(I.key==="Escape"){I.preventDefault(),e.onClose();return}if(x.length!==0){if(I.key==="ArrowDown")I.preventDefault(),p(L=>Math.min(L+1,x.length-1));else if(I.key==="ArrowUp")I.preventDefault(),p(L=>Math.max(L-1,0));else if(I.key==="Enter"){I.preventDefault();const L=x[m()];L&&P(L)}}};window.addEventListener("keydown",N),Oe(()=>{window.removeEventListener("keydown",N),S(),n(""),d(null)})}),v(j,{get when(){return e.open},get children(){var N=dR(),I=N.firstChild,x=I.firstChild,L=x.firstChild,W=L.firstChild,J=W.firstChild,se=J.nextSibling,pe=W.nextSibling,be=pe.firstChild,ue=L.nextSibling,ne=ue.firstChild,Se=ne.nextSibling,fe=Se.firstChild,re=fe.nextSibling,Ce=ue.nextSibling;return N.$$click=O,C(J,()=>e.title),C(se,()=>e.description||"Search for a path under the configured workspace root."),C(W,v(j,{get when(){return t()},get children(){var he=sR();return he.firstChild,C(he,t,null),he}}),null),Gi(pe,"click",e.onClose,!0),C(pe,v(kl,{class:"w-4 h-4"}),be),C(fe,v(EC,{class:"w-4 h-4"})),re.$$input=he=>_(he.currentTarget.value),Tt(he=>{g=he},re),C(x,v(j,{get when(){return e.mode==="directories"},get children(){var he=lR(),K=he.firstChild,ie=K.firstChild,M=ie.firstChild,U=M.nextSibling,z=ie.nextSibling;return C(U,y),z.$$click=()=>e.onSelect(y()),he}}),Ce),C(Ce,v(j,{get when(){return i().length>0},get fallback(){return(()=>{var he=_R();return C(he,v(j,{get when(){return s()!==null},get fallback(){return(()=>{var K=mR();return C(K,c),K})()},get children(){var K=uR(),ie=K.firstChild,M=ie.firstChild,U=M.nextSibling;return U.nextSibling,C(K,v(ho,{class:"w-4 h-4 animate-spin"}),ie),C(ie,R,U),K}})),he})()},get children(){return[v(j,{get when(){return s()},get children(){var he=cR(),K=he.firstChild,ie=K.firstChild,M=ie.nextSibling;return M.nextSibling,C(he,v(ho,{class:"w-3.5 h-3.5 animate-spin"}),K),C(K,R,M),he}}),v(j,{get when(){return A().length>0},get fallback(){return(()=>{var he=pR(),K=he.firstChild,ie=K.nextSibling;return ie.$$click=b,he})()},get children(){return v(Ge,{get each(){return A()},children:he=>{if(he.type==="up")return(()=>{var U=gR(),z=U.firstChild,H=z.firstChild,te=H.firstChild;return H.$$click=F,C(te,v(Uf,{class:"w-4 h-4"})),U})();const K=he.entry,ie=()=>P(K),M=()=>{K.type==="directory"?w(K.path):ie()};return(()=>{var U=fR(),z=U.firstChild,H=z.firstChild,te=H.firstChild,Q=te.nextSibling,ee=Q.firstChild,ce=ee.nextSibling,_e=H.nextSibling;return H.$$click=M,C(te,v(j,{get when(){return K.type==="directory"},get fallback(){return v(nC,{class:"w-4 h-4"})},get children(){return v(xu,{class:"w-4 h-4"})}})),C(ee,()=>K.name||K.path),C(ce,()=>Pa(t(),K.path)),_e.$$click=we=>{we.stopPropagation(),ie()},U})()}})}})]}})),de(()=>Pe(re,"placeholder",e.mode==="directories"?"Search for folders":"Search for files")),de(()=>re.value=u()),N}})};mt(["click","input"]);function SR(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 bR(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 SR(n)}catch(n){return console.error("[native] electron dialog failed",n),null}}async function TR(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 Zf(){switch(ld.host){case"electron":return bR;case"tauri":return TR;default:return null}}function jf(){return Zf()!==null}async function Jf(e){const t=Zf();return t?t(e):null}async function vR(e){return Jf({mode:"directory",...e??{}})}async function yR(e){return Jf({mode:"file",...e??{}})}var CR=G('<div class="selector-loading text-xs"><span>Checking versions…'),RR=G("<div class=selector-validation-error><div class=selector-validation-error-content><span class=selector-validation-error-text>"),IR=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">'),NR=G('<div class="text-xs font-mono truncate pl-6 text-muted">'),OR=G("<span class=selector-badge-version>v"),AR=G("<span class=selector-badge-time>Checking…"),wR=G("<span class=selector-badge-time>"),xR=G("<span class=selector-badge-time>Use binary from system PATH"),DR=G('<button type=button class="p-2 text-muted hover:text-primary"title="Remove binary">'),LR=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 MR=e=>{const{opencodeBinaries:t,addOpenCodeBinary:n,removeOpenCodeBinary:i,preferences:r,updatePreferences:a}=Hi(),[o,s]=q(""),[l,c]=q(!1),[d,u]=q(null),[_,m]=q(new Map),[p,g]=q(new Set),[E,h]=q(!1),f=jf(),S=()=>t(),T=()=>r().lastUsedBinary,b=V(()=>S().filter(L=>L.path!=="opencode")),R=V(()=>[{path:"opencode",isDefault:!0},...b()]),y=()=>e.selectedBinary||"opencode";ge(()=>{if(!e.selectedBinary&&T())e.onBinaryChange(T());else if(!e.selectedBinary){const L=S()[0];L&&e.onBinaryChange(L.path)}}),ge(()=>{const L=new Map(_());let W=!1;S().forEach(J=>{J.version&&!L.has(J.path)&&(L.set(J.path,J.version),W=!0)}),W&&m(L)}),ge(()=>{if(!e.isVisible)return;const L=_(),W=["opencode",...b().map(J=>J.path)].filter(J=>!L.has(J));W.length!==0&&setTimeout(()=>{W.forEach(J=>{O(J).catch(console.error)})},0)}),Oe(()=>{g(new Set),c(!1)});async function O(L){if(_().has(L)){const W=_().get(L);return W?{valid:!0,version:W}:{valid:!0}}if(p().has(L))return{valid:!1,error:"Already validating"};try{g(J=>new Set(J).add(L)),c(!0),u(null);const W=await Xt.validateBinary(L);if(W.valid&&W.version){const J=new Map(_());J.set(L,W.version),m(J)}return W}catch(W){return{valid:!1,error:W instanceof Error?W.message:String(W)}}finally{g(W=>{const J=new Set(W);return J.delete(L),J.size===0&&c(!1),J})}}async function P(){if(!e.disabled){if(u(null),f){const L=await yR({title:"Select OpenCode Binary"});L&&(s(L),w(L));return}h(!0)}}async function w(L){const W=await O(L);W.valid?(n(L,W.version),e.onBinaryChange(L),a({lastUsedBinary:L}),s(""),u(null)):u(W.error||"Invalid OpenCode binary")}function F(L){h(!1),s(L),w(L)}async function Y(){const L=o().trim();L&&await w(L)}function B(L){e.disabled||L!==e.selectedBinary&&(e.onBinaryChange(L),a({lastUsedBinary:L}))}function A(L,W){W.stopPropagation(),!e.disabled&&(i(L),e.selectedBinary===L&&(e.onBinaryChange("opencode"),a({lastUsedBinary:"opencode"})))}function N(L){if(!L)return"";const W=Math.floor((Date.now()-L)/1e3),J=Math.floor(W/60),se=Math.floor(J/60),pe=Math.floor(se/24);return pe>0?`${pe}d ago`:se>0?`${se}h ago`:J>0?`${J}m ago`:"just now"}function I(L){if(L==="opencode")return"opencode (system PATH)";const W=L.split(/[/\\]/);return W[W.length-1]??L}const x=L=>p().has(L);return[(()=>{var L=IR(),W=L.firstChild;W.firstChild;var J=W.nextSibling,se=J.firstChild,pe=se.firstChild,be=pe.nextSibling,ue=be.firstChild,ne=se.nextSibling,Se=ne.firstChild,fe=J.nextSibling;return C(W,v(j,{get when(){return l()},get children(){var re=CR(),Ce=re.firstChild;return C(re,v(ho,{class:"selector-loading-spinner"}),Ce),re}}),null),pe.$$keydown=re=>{re.key==="Enter"&&(re.preventDefault(),Y())},pe.$$input=re=>s(re.currentTarget.value),be.$$click=Y,C(be,v(Du,{class:"w-4 h-4"}),ue),ne.$$click=()=>void P(),C(ne,v(Bf,{class:"w-4 h-4"}),Se),C(J,v(j,{get when(){return d()},get children(){var re=RR(),Ce=re.firstChild,he=Ce.firstChild;return C(Ce,v(Hy,{class:"selector-validation-error-icon"}),he),C(he,d),re}}),null),C(fe,v(Ge,{get each(){return R()},children:re=>{const Ce=re.isDefault,he=()=>_().get(re.path)??re.version;return(()=>{var K=LR(),ie=K.firstChild,M=ie.firstChild,U=M.firstChild,z=U.firstChild,H=U.nextSibling;return ie.$$click=()=>B(re.path),C(U,v(Ky,{get class(){return`w-4 h-4 transition-opacity ${y()===re.path?"opacity-100":"opacity-0"}`}}),z),C(z,()=>I(re.path)),C(M,v(j,{when:!Ce,get children(){var te=NR();return C(te,()=>re.path),te}}),H),C(H,v(j,{get when(){return he()},get children(){var te=OR();return te.firstChild,C(te,he,null),te}}),null),C(H,v(j,{get when(){return x(re.path)},get children(){return AR()}}),null),C(H,v(j,{get when(){return!Ce&&re.lastUsed},get children(){var te=wR();return C(te,()=>N(re.lastUsed)),te}}),null),C(H,v(j,{when:Ce,get children(){return xR()}}),null),C(K,v(j,{when:!Ce,get children(){var te=DR();return te.$$click=Q=>A(re.path,Q),C(te,v(Lu,{class:"w-3.5 h-3.5"})),de(()=>te.disabled=e.disabled),te}}),null),de(te=>{var Q=y()===re.path,ee=e.disabled;return Q!==te.e&&K.classList.toggle("panel-list-item-highlight",te.e=Q),ee!==te.t&&(ie.disabled=te.t=ee),te},{e:void 0,t:void 0}),K})()}})),de(re=>{var Ce=e.disabled,he=e.disabled||!o().trim(),K=e.disabled;return Ce!==re.e&&(pe.disabled=re.e=Ce),he!==re.t&&(be.disabled=re.t=he),K!==re.a&&(ne.disabled=re.a=K),re},{e:void 0,t:void 0,a:void 0}),de(()=>pe.value=o()),L})(),v(hR,{get open(){return E()},mode:"files",title:"Select OpenCode Binary",description:"Browse files exposed by the CLI server.",onClose:()=>h(!1),onSelect:F})]};mt(["input","keydown","click"]);var kR=G("<div class=space-y-2>"),PR=G('<div class="text-xs text-muted text-center py-2">No environment variables configured. Add variables above to customize the OpenCode environment.'),FR=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.'),UR=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 BR=e=>{const{preferences:t,addEnvironmentVariable:n,removeEnvironmentVariable:i,updateEnvironmentVariables:r}=Hi(),[a,o]=q(t().environmentVariables||{}),[s,l]=q(""),[c,d]=q(""),u=()=>Object.entries(a());function _(){const E=s().trim(),h=c().trim();E&&(n(E,h),o({...a(),[E]:h}),l(""),d(""))}function m(E){i(E);const{[E]:h,...f}=a();o(f)}function p(E,h){const f={...a(),[E]:h};o(f),r(f)}function g(E){E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),_())}return(()=>{var E=FR(),h=E.firstChild,f=h.firstChild,S=f.nextSibling,T=S.firstChild,b=T.nextSibling,R=b.nextSibling,y=R.nextSibling;y.nextSibling;var O=h.nextSibling,P=O.firstChild,w=P.firstChild,F=w.nextSibling,Y=P.nextSibling,B=O.nextSibling;return C(h,v(lC,{class:"w-4 h-4 icon-muted"}),f),C(S,()=>u().length,b),C(S,()=>u().length!==1?"s":"",y),C(E,v(j,{get when(){return u().length>0},get children(){var A=kR();return C(A,v(Ge,{get each(){return u()},children:([N,I])=>(()=>{var x=UR(),L=x.firstChild,W=L.firstChild,J=W.nextSibling,se=L.nextSibling;return C(L,v(Pm,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),W),W.value=N,J.$$input=pe=>p(N,pe.currentTarget.value),J.value=I,se.$$click=()=>m(N),C(se,v(Lu,{class:"w-3.5 h-3.5"})),de(pe=>{var be=e.disabled,ue=e.disabled,ne=e.disabled;return be!==pe.e&&(W.disabled=pe.e=be),ue!==pe.t&&(J.disabled=pe.t=ue),ne!==pe.a&&(se.disabled=pe.a=ne),pe},{e:void 0,t:void 0,a:void 0}),x})()})),A}}),O),C(P,v(Pm,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),w),w.addEventListener("keypress",g),w.$$input=A=>l(A.currentTarget.value),F.addEventListener("keypress",g),F.$$input=A=>d(A.currentTarget.value),Y.$$click=_,C(Y,v(Du,{class:"w-3.5 h-3.5"})),C(E,v(j,{get when(){return u().length===0},get children(){return PR()}}),B),de(A=>{var N=e.disabled,I=e.disabled,x=e.disabled||!s().trim();return N!==A.e&&(w.disabled=A.e=N),I!==A.t&&(F.disabled=A.t=I),x!==A.a&&(Y.disabled=A.a=x),A},{e:void 0,t:void 0,a:void 0}),de(()=>w.value=s()),de(()=>F.value=c()),E})()};mt(["input","click"]);var $R=G('<header class="px-6 py-4 border-b"style=border-color:var(--border-base)>'),GR=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>'),YR=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'),VR=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">');const HR=e=>v(ze,{get open(){return e.open},onOpenChange:t=>!t&&e.onClose(),get children(){return v(ze.Portal,{get children(){return[v(ze.Overlay,{class:"modal-overlay"}),(()=>{var t=VR();return C(t,v(ze.Content,{class:"modal-surface w-full max-w-5xl max-h-[90vh] flex flex-col overflow-hidden",get children(){return[(()=>{var n=$R();return C(n,v(ze.Title,{class:"text-xl font-semibold text-primary",children:"Advanced Settings"})),n})(),(()=>{var n=GR(),i=n.firstChild,r=i.firstChild,a=r.nextSibling;return C(n,v(MR,{get selectedBinary(){return e.selectedBinary},get onBinaryChange(){return e.onBinaryChange},get disabled(){return!!e.isLoading},get isVisible(){return e.open}}),i),C(a,v(BR,{get disabled(){return!!e.isLoading}})),n})(),(()=>{var n=YR(),i=n.firstChild;return Gi(i,"click",e.onClose,!0),n})()]}})),t})()]}})}});mt(["click"]);const Wm="__drives__";var WR=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'),zR=G('<div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto directory-browser-list"role=listbox>'),KR=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">'),qR=G("<div class=directory-browser-loading><span>Loading folders…"),QR=G('<div class="panel-empty-state flex-1">'),XR=G("<span class=text-red-500>"),ZR=G('<div class="panel-empty-state flex-1">No folders available.'),jR=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>'),JR=G('<button type=button class="selector-button selector-button-secondary directory-browser-select">Select');function cs(e){if(!e||e==="."||e==="./")return".";if(e===Wm)return Wm;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 eE(e){return e.startsWith("/")||/^[a-zA-Z]:/.test(e)||e.startsWith("\\\\")}function zm(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;if(eE(t))return t;const n=e.includes("\\")?"\\":"/",i=e.endsWith(n)?e:`${e}${n}`,r=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${i}${r}`}const eI=e=>{const[t,n]=q(""),[i,r]=q(!1),[a,o]=q(null),[s,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(),o(null)}ge(()=>{if(!e.open)return;h(),f();const A=N=>{N.key==="Escape"&&(N.preventDefault(),e.onClose())};window.addEventListener("keydown",A),Oe(()=>{window.removeEventListener("keydown",A)})});async function f(){r(!0);try{const A=await T();S(A)}catch(A){const N=A instanceof Error?A.message:"Unable to load filesystem";o(N)}finally{r(!1)}}function S(A){const N=cs(A.currentPath);_(N),p(A),n(A.rootPath)}async function T(A){const N=A?cs(A):void 0;if(N){const x=g.get(N);if(x)return x;const L=E.get(N);if(L)return L}const I=(async()=>{N&&d(J=>{const se=new Set(J);return se.add(N),se});const x=await Xt.listFileSystem(A,{includeFiles:!1}),L=cs(x.metadata.currentPath),W=x.entries.filter(J=>J.type==="directory").sort((J,se)=>J.name.localeCompare(se.name));return l(J=>{const se=new Map(J);return se.set(L,W),se}),g.set(L,x.metadata),d(J=>{const se=new Set(J);return N&&se.delete(N),se.delete(L),se}),x.metadata})().catch(x=>{throw N&&d(L=>{const W=new Set(L);return W.delete(N),W}),x}).finally(()=>{N&&E.delete(N)});return N&&E.set(N,I),I}async function b(A){o(null);try{const N=await T(A);S(N)}catch(N){const I=N instanceof Error?N.message:"Unable to load filesystem";o(I)}}const R=V(()=>{const A=[],N=m();N!=null&&N.parentPath&&A.push({type:"up",path:N.parentPath});const I=u();if(!I)return A;const x=s().get(I)??[];for(const L of x)A.push({type:"folder",entry:L});return A});function y(A){b(A)}function O(){var N;const A=(N=m())==null?void 0:N.parentPath;A&&b(A)}const P=V(()=>{const A=m();return!A||A.pathKind==="drives"?"":A.pathKind==="relative"?zm(A.rootPath,A.currentPath):A.displayPath}),w=V(()=>!!P());function F(A){const N=A.absolutePath?A.absolutePath:eE(A.path)?A.path:zm(t(),A.path);e.onSelect(N)}function Y(A){return c().has(cs(A))}function B(A){A.target===A.currentTarget&&e.onClose()}return v(j,{get when(){return e.open},get children(){var A=KR(),N=A.firstChild,I=N.firstChild,x=I.firstChild,L=x.firstChild,W=L.firstChild,J=W.nextSibling,se=L.nextSibling,pe=x.nextSibling;return A.$$click=B,C(W,()=>e.title),C(J,()=>e.description||"Browse folders under the configured workspace root."),Gi(se,"click",e.onClose,!0),C(se,v(kl,{class:"w-5 h-5"})),C(pe,v(j,{get when(){return t()},get children(){var be=WR(),ue=be.firstChild,ne=ue.firstChild,Se=ne.nextSibling,fe=ue.nextSibling;return C(Se,P),fe.$$click=()=>{const re=P();re&&e.onSelect(re)},de(()=>fe.disabled=!w()),be}}),null),C(pe,v(j,{get when(){return ke(()=>!i())()&&!a()},get fallback(){return(()=>{var be=QR();return C(be,v(j,{get when(){return i()},get fallback(){return(()=>{var ue=XR();return C(ue,a),ue})()},get children(){var ue=qR(),ne=ue.firstChild;return C(ue,v(ho,{class:"w-5 h-5 animate-spin"}),ne),ue}})),be})()},get children(){return v(j,{get when(){return R().length>0},get fallback(){return ZR()},get children(){var be=zR();return C(be,v(Ge,{get each(){return R()},children:ue=>{const ne=ue.type==="folder",Se=ne?ue.entry.name||ue.entry.path:"Up one level",fe=()=>ne?y(ue.entry.path):O();return(()=>{var re=jR(),Ce=re.firstChild,he=Ce.firstChild,K=he.firstChild,ie=K.nextSibling,M=ie.firstChild;return he.$$click=fe,C(K,v(j,{when:!ne,get fallback(){return v(xu,{class:"w-4 h-4"})},get children(){return v(Uf,{class:"w-4 h-4"})}})),C(M,Se),C(he,v(j,{get when(){return ne&&Y(ue.entry.path)},get children(){return v(ho,{class:"directory-browser-row-spinner animate-spin"})}}),null),C(Ce,ne?(()=>{var U=JR();return U.$$click=z=>{z.stopPropagation(),F(ue.entry)},U})():null,null),re})()}})),be}})}}),null),A}})};mt(["click"]);const ai=()=>navigator.platform.toLowerCase().includes("mac"),tI=e=>{const t=[];return(e.modifiers.ctrl||e.modifiers.meta)&&t.push(ai()?"Cmd":"Ctrl"),e.modifiers.shift&&t.push("Shift"),e.modifiers.alt&&t.push(ai()?"Option":"Alt"),t.push(e.key.toUpperCase()),t.join("+")};var nI=G("<kbd>"),iI=G("<span>"),rI=G("<span class=kbd-separator>+");const aI={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:"→"},Bt=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 o=a.trim(),s=o.toLowerCase();if(s==="cmd"||s==="command")n.push({text:ai()?"Cmd":"Ctrl",isModifier:!1});else if(s==="shift")n.push({text:"Shift",isModifier:!1});else if(s==="alt"||s==="option")n.push({text:ai()?"Option":"Alt",isModifier:!1});else if(s==="ctrl"||s==="control")n.push({text:"Ctrl",isModifier:!1});else{const l=aI[s];l?n.push({text:l,isModifier:!1}):o.length===1?n.push({text:o.toUpperCase(),isModifier:!1}):n.push({text:o.charAt(0).toUpperCase()+o.slice(1),isModifier:!1})}}),n};return(()=>{var n=nI();return C(n,v(Ge,{get each(){return t()},children:(i,r)=>[ke(()=>ke(()=>r()>0)()&&rI()),(()=>{var a=iI();return C(a,()=>i.text),a})()]})),de(()=>Be(n,`kbd ${e.class||""}`)),n})()};var oI=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">'),sI=G('<div class="flex items-center gap-1.5"><kbd class=kbd>↑</kbd><kbd class=kbd>↓</kbd><span>Navigate'),lI=G('<div class="flex items-center gap-1.5"><kbd class=kbd>Enter</kbd><span>Select'),cI=G('<div class="flex items-center gap-1.5"><kbd class=kbd>Del</kbd><span>Remove'),dI=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."),uI=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-48 w-auto"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><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"><div class=panel-footer-hints><div class="flex items-center gap-1.5"><span>Browse',!0,!1,!1),_I=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'),mI=G("<kbd class=kbd>↵"),pI=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 gI=new URL("/assets/CodeNomad-Icon-bmTWNPXy.png",import.meta.url).href,Km=e=>{const{recentFolders:t,removeRecentFolder:n,preferences:i}=Hi(),[r,a]=q(0),[o,s]=q("recent"),[l,c]=q(i().lastUsedBinary||"opencode"),[d,u]=q(!1),_=jf();let m;const p=()=>t(),g=()=>!!e.isLoading;ge(()=>{const w=i().lastUsedBinary;w&&c(F=>F===w?F:w)});function E(w){const F=m;if(!F)return;const Y=F.querySelector(`[data-folder-index="${w}"]`);if(!Y)return;const B=F.getBoundingClientRect(),A=Y.getBoundingClientRect();A.top<B.top?F.scrollTop-=B.top-A.top:A.bottom>B.bottom&&(F.scrollTop+=A.bottom-B.bottom)}function h(w){const F=w.key.toLowerCase(),Y=(w.metaKey||w.ctrlKey)&&!w.shiftKey&&F==="n",B=["ArrowDown","ArrowUp","PageDown","PageUp","Home","End","Enter","Backspace","Delete"];if(g()){(Y||B.includes(w.key))&&w.preventDefault();return}const A=p();if(Y){w.preventDefault(),b();return}if(A.length!==0){if(w.key==="ArrowDown"){w.preventDefault();const N=Math.min(r()+1,A.length-1);a(N),s("recent"),E(N)}else if(w.key==="ArrowUp"){w.preventDefault();const N=Math.max(r()-1,0);a(N),s("recent"),E(N)}else if(w.key==="PageDown"){w.preventDefault();const I=Math.min(r()+5,A.length-1);a(I),s("recent"),E(I)}else if(w.key==="PageUp"){w.preventDefault();const I=Math.max(r()-5,0);a(I),s("recent"),E(I)}else if(w.key==="Home")w.preventDefault(),a(0),s("recent"),E(0);else if(w.key==="End"){w.preventDefault();const N=A.length-1;a(N),s("recent"),E(N)}else if(w.key==="Enter")w.preventDefault(),f();else if((w.key==="Backspace"||w.key==="Delete")&&(w.preventDefault(),A.length>0&&o()==="recent")){const N=A[r()];N&&O(N.path)}}}function f(){if(g())return;const w=p(),F=r(),Y=w[F];Y&&T(Y.path)}Zt(()=>{window.addEventListener("keydown",h),Oe(()=>{window.removeEventListener("keydown",h)})});function S(w){const F=Math.floor((Date.now()-w)/1e3),Y=Math.floor(F/60),B=Math.floor(Y/60),A=Math.floor(B/24);return A>0?`${A}d ago`:B>0?`${B}h ago`:Y>0?`${Y}m ago`:"just now"}function T(w){g()||e.onSelectFolder(w,l())}async function b(){var w;if(!g()){if(s("new"),_){const F=(w=p()[0])==null?void 0:w.path,Y=await vR({title:"Select Workspace",defaultPath:F});Y&&T(Y);return}u(!0)}}function R(w){u(!1),T(w)}function y(w){c(w)}function O(w,F){if(g())return;F==null||F.stopPropagation(),n(w);const Y=p();r()>=Y.length&&Y.length>0&&a(Y.length-1)}function P(w){return w.startsWith("/Users/")?w.replace(/^\/Users\/[^/]+/,"~"):w}return[(()=>{var w=uI(),F=w.firstChild,Y=F.firstChild,B=Y.firstChild,A=B.firstChild,N=Y.nextSibling,I=N.firstChild,x=I.firstChild,L=x.nextSibling,W=L.firstChild,J=W.firstChild,se=J.firstChild,pe=L.nextSibling,be=pe.firstChild,ue=be.firstChild,ne=ue.firstChild,Se=N.nextSibling,fe=Se.firstChild,re=fe.firstChild,Ce=re.firstChild;return Pe(A,"src",gI),C(N,v(j,{get when(){return p().length>0},get fallback(){return(()=>{var he=_I(),K=he.firstChild;return C(K,v(jy,{class:"w-12 h-12 mx-auto"})),he})()},get children(){var he=oI(),K=he.firstChild,ie=K.firstChild,M=ie.nextSibling,U=M.firstChild,z=U.nextSibling;z.nextSibling;var H=K.nextSibling;return C(M,()=>p().length,U),C(M,()=>p().length===1?"folder":"folders",z),Tt(te=>m=te,H),C(H,v(Ge,{get each(){return p()},children:(te,Q)=>(()=>{var ee=pI(),ce=ee.firstChild,_e=ce.firstChild,we=_e.firstChild,Ae=we.firstChild,Le=Ae.firstChild,ae=Le.firstChild,$=Le.nextSibling,Z=$.nextSibling,Ee=_e.nextSibling;return _e.addEventListener("mouseenter",()=>{g()||(s("recent"),a(Q()))}),_e.$$click=()=>T(te.path),C(Le,v(xu,{class:"w-4 h-4 flex-shrink-0 icon-muted"}),ae),C(ae,()=>te.path.split("/").pop()),C($,()=>P(te.path)),C(Z,()=>S(te.lastAccessed)),C(we,v(j,{get when(){return ke(()=>o()==="recent")()&&r()===Q()},get children(){return mI()}}),null),Ee.$$click=Re=>O(te.path,Re),C(Ee,v(Lu,{class:"w-3.5 h-3.5 transition-colors icon-muted hover:text-red-600 dark:hover:text-red-400"})),de(Re=>{var Me=o()==="recent"&&r()===Q(),$e=!!g(),gt=Q(),lt=g(),ct=g();return Me!==Re.e&&ee.classList.toggle("panel-list-item-highlight",Re.e=Me),$e!==Re.t&&ee.classList.toggle("panel-list-item-disabled",Re.t=$e),gt!==Re.a&&Pe(_e,"data-folder-index",Re.a=gt),lt!==Re.o&&(_e.disabled=Re.o=lt),ct!==Re.i&&(Ee.disabled=Re.i=ct),Re},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),ee})()})),he}}),I),W.addEventListener("mouseenter",()=>s("new")),W.$$click=()=>void b(),C(J,v(aC,{class:"w-4 h-4"}),se),C(se,()=>e.isLoading?"Opening...":"Browse Folders"),C(W,v(Bt,{shortcut:"cmd+n",class:"ml-2"}),null),be.$$click=()=>{var he;return(he=e.onAdvancedSettingsOpen)==null?void 0:he.call(e)},C(ue,v(SC,{class:"w-4 h-4 icon-muted"}),ne),C(be,v(Xy,{class:"w-4 h-4 icon-muted"}),null),C(fe,v(j,{get when(){return p().length>0},get children(){return[sI(),lI(),cI()]}}),re),C(re,v(Bt,{shortcut:"cmd+n"}),Ce),C(w,v(j,{get when(){return g()},get children(){return dI()}}),null),de(he=>{var K=g()?"true":"false",ie=e.isLoading;return K!==he.e&&Pe(F,"aria-busy",he.e=K),ie!==he.t&&(W.disabled=he.t=ie),he},{e:void 0,t:void 0}),w})(),v(HR,{get open(){return!!e.advancedSettingsOpen},onClose:()=>{var w;return(w=e.onAdvancedSettingsClose)==null?void 0:w.call(e)},get selectedBinary(){return l()},onBinaryChange:y,get isLoading(){return e.isLoading}}),v(eI,{get open(){return d()},title:"Select Workspace",description:"Select workspace to start coding.",onClose:()=>u(!1),onSelect:R})]};mt(["click"]);var fI=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 EI=e=>(()=>{var t=fI(),n=t.firstChild,i=n.firstChild,r=i.nextSibling;return Gi(n,"click",e.onSelect,!0),C(n,v(Bf,{class:"w-4 h-4 flex-shrink-0"}),i),C(i,()=>e.instance.folder.split("/").pop()||e.instance.folder),r.$$click=a=>{a.stopPropagation(),e.onClose()},C(r,v(kl,{class:"w-3 h-3"})),de(a=>{var o=`tab-base ${e.active?"tab-active":"tab-inactive"}`,s=e.instance.folder,l=e.active;return o!==a.e&&Be(n,a.e=o),s!==a.t&&Pe(n,"title",a.t=s),l!==a.a&&Pe(n,"aria-selected",a.a=l),a},{e:void 0,t:void 0,a:void 0}),t})();mt(["click"]);var hI=G("<span>");const md=e=>(()=>{var t=hI();return C(t,()=>e.children),de(()=>Be(t,`text-xs text-muted ${e.class||""}`)),t})();var SI=G("<span class=mx-1>"),bI=G("<span class=mr-1>");const $l=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 v(md,{get children(){return v(Ge,{get each(){return e.shortcuts},children:(n,i)=>[ke(()=>ke(()=>i()>0)()&&(()=>{var r=SI();return C(r,()=>e.separator||"•"),r})()),ke(()=>ke(()=>e.showDescription!==!1)()&&(()=>{var r=bI();return C(r,()=>n.description),r})()),v(Bt,{get shortcut(){return t(n)}})]})}})};class TI{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():"",o=r===i||a===i,s=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 o&&s&&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 bt=new TI;var vI=G('<div class="flex-shrink-0 ml-4">'),yI=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 CI=e=>(()=>{var t=yI(),n=t.firstChild,i=n.firstChild,r=i.firstChild;return C(i,v(Ge,{get each(){return Array.from(e.instances.entries())},children:([a,o])=>v(EI,{instance:o,get active(){return a===e.activeInstanceId},onSelect:()=>e.onSelect(a),onClose:()=>e.onClose(a)})}),r),Gi(r,"click",e.onNew,!0),C(r,v(Du,{class:"w-4 h-4"})),C(n,v(j,{get when(){return Array.from(e.instances.entries()).length>1},get children(){var a=vI();return C(a,v($l,{get shortcuts(){return[bt.get("instance-prev"),bt.get("instance-next")].filter(Boolean)}})),a}}),null),t})();mt(["click"]);var RI=G("<div>"),II=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">'),NI=G('<div class="flex justify-end"><button type=button class="selector-button selector-button-primary">Close Instance'),OI=G('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">'),AI=G('<p class="mt-2 text-secondary">Folder: <span class="font-mono text-primary break-all">');function wI(e){const t=e.folder||"this workspace",n=e.reason||"The server stopped responding";return v(ze,{get open(){return e.open},modal:!0,get children(){return v(ze.Portal,{get children(){return[v(ze.Overlay,{class:"modal-overlay"}),(()=>{var i=OI();return C(i,v(ze.Content,{class:"modal-surface w-full max-w-md p-6 flex flex-col gap-6",get children(){return[(()=>{var r=RI();return C(r,v(ze.Title,{class:"text-xl font-semibold text-primary",children:"Instance Disconnected"}),null),C(r,v(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=II(),a=r.firstChild,o=a.nextSibling;return C(o,n),C(r,(()=>{var s=ke(()=>!!e.folder);return()=>s()&&(()=>{var l=AI(),c=l.firstChild,d=c.nextSibling;return C(d,()=>e.folder),l})()})(),null),r})(),(()=>{var r=NI(),a=r.firstChild;return Gi(a,"click",e.onClose,!0),r})()]}})),i})()]}})}})}mt(["click"]);const[qm,xI]=q(new Map);class DI{constructor(){So.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)}}),So.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,o,s,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":(o=this.onMessagePartRemoved)==null||o.call(this,t,n);break;case"session.updated":(s=this.onSessionUpdate)==null||s.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){xI(i=>{const r=new Map(i);return r.set(t,n),r})}getStatus(t){return qm().get(t)??null}getStatuses(){return qm()}}const Gt=new DI,[Lt,sr]=q(new Map),[Li,tE]=q(new Map),[bo,nE]=q(new Map),[Gl,LI]=q(new Map),[Ta,MI]=q(new Map),[kI,Yl]=q(new Map),[iE,oa]=q({fetchingSessions:new Map,creatingSession:new Map,deletingSession:new Map,loadingMessages:new Map}),[PI,pd]=q(new Map),[FI,Gu]=q(new Map);function Yu(e,t){return`${e}:${t}`}function UI(e,t){if(!e||!t)return"";const n=Yu(e,t);return kI().get(n)??""}function vc(e,t,n){const i=Yu(e,t);Yl(r=>{const a=new Map(r);return n?a.set(i,n):a.delete(i),a})}function BI(e,t){const n=Yu(e,t);Yl(i=>{if(!i.has(n))return i;const r=new Map(i);return r.delete(n),r})}function $I(e){e&&Yl(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 GI(e,t){Yl(n=>{let i=!1;const r=new Map(n),a=`${e}:`;for(const o of Array.from(r.keys()))if(o.startsWith(a)){const s=o.slice(a.length);t.has(s)||(r.delete(o),i=!0)}return i?r:n})}function Mi(e,t,n){const i=Lt().get(e);if(!i)return;const r=i.get(t);if(!r)return;n(r);const a={...r,messages:[...r.messages],messagesInfo:new Map(r.messagesInfo)};sr(o=>{const s=new Map(o),l=new Map(i);return l.set(t,a),s.set(e,l),s})}function To(e,t,n){Mi(e,t,i=>{i.pendingPermission!==n&&(i.pendingPermission=n)})}function An(e,t){tE(n=>{const i=new Map(n);return i.set(e,t),i})}function vo(e,t){nE(n=>{const i=new Map(n);return i.set(e,t),i}),An(e,t)}function YI(e){nE(t=>{const n=new Map(t);return n.delete(e),n}),tE(t=>{const n=new Map(t);return n.delete(e),n})}function lr(e){const t=Lt().get(e);return t?Array.from(t.values()):[]}function VI(e){return lr(e).filter(n=>n.parentId===null)}function HI(e,t){return lr(e).filter(i=>i.parentId===t)}function Js(e,t){var r;const n=(r=Lt().get(e))==null?void 0:r.get(t);if(!n)return[];const i=HI(e,t);return[n,...i]}function WI(e,t){const n=Lt().get(e);return!(!n||!n.has(t))}function zI(e,t){var n;return!!((n=iE().loadingMessages.get(e))!=null&&n.has(t))}function rE(e,t){var n;return(n=FI().get(e))==null?void 0:n.get(t)}const Qm=32e3;function sa(e,t){if(!(t!=null&&t.providerId)||!t.modelId)return!1;const i=(Ta().get(e)||[]).find(r=>r.id===t.providerId);return i?i.models.some(r=>r.id===t.modelId):!1}function KI(e){const t=_t().modelRecents??[];for(const n of t)if(sa(e,n))return n}async function Vu(e,t){const n=Ta().get(e)||[],i=Gl().get(e)||[];if(t){const a=i.find(s=>s.name===t);if(a&&a.model&&sa(e,a.model))return{providerId:a.model.providerId,modelId:a.model.modelId};const o=await Qf(e,t);if(sa(e,o))return o}const r=KI(e);if(r)return r;for(const a of n)if(a.defaultModelId){const o=a.models.find(s=>s.id===a.defaultModelId);if(o)return{providerId:a.id,modelId:o.id}}if(n.length>0){const a=n[0],o=a.models[0];if(o)return{providerId:a.id,modelId:o.id}}return{providerId:"",modelId:""}}function Xm(e){return typeof e=="string"?e.trim().length>0:e&&typeof e=="object"&&e.text?typeof e.text=="string"&&e.text.trim().length>0:!1}function yo(e){if(!e||typeof e!="object")return!1;const t=e;return!!(t.type==="text"&&Xm(t.text)||t.type==="file"&&t.filename||t.type==="tool"||t.type==="reasoning"&&Xm(t.text))}function Hu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Er=Hu();function aE(e){Er=e}const oE=/[&<>"']/,qI=new RegExp(oE.source,"g"),sE=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,QI=new RegExp(sE.source,"g"),XI={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Zm=e=>XI[e];function an(e,t){if(t){if(oE.test(e))return e.replace(qI,Zm)}else if(sE.test(e))return e.replace(QI,Zm);return e}const ZI=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function jI(e){return e.replace(ZI,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const JI=/(^|[^\[])\^/g;function Qe(e,t){let n=typeof e=="string"?e:e.source;t=t||"";const i={replace:(r,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(JI,"$1"),n=n.replace(r,o),i},getRegex:()=>new RegExp(n,t)};return i}function jm(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch{return null}return e}const no={exec:()=>null};function Jm(e,t){const n=e.replace(/\|/g,(a,o,s)=>{let l=!1,c=o;for(;--c>=0&&s[c]==="\\";)l=!l;return l?"|":" |"}),i=n.split(/ \|/);let r=0;if(i[0].trim()||i.shift(),i.length>0&&!i[i.length-1].trim()&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(/\\\|/g,"|");return i}function ds(e,t,n){const i=e.length;if(i===0)return"";let r=0;for(;r<i&&e.charAt(i-r-1)===t;)r++;return e.slice(0,i-r)}function eN(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return-1}function ep(e,t,n,i){const r=t.href,a=t.title?an(t.title):null,o=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){i.state.inLink=!0;const s={type:"link",raw:n,href:r,title:a,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,s}return{type:"image",raw:n,href:r,title:a,text:an(o)}}function tN(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const i=n[1];return t.split(`
3
3
  `).map(r=>{const a=r.match(/^\s+/);if(a===null)return r;const[o]=a;return o.length>=i.length?r.slice(i.length):r}).join(`
4
4
  `)}class el{constructor(t){X(this,"options");X(this,"rules");X(this,"lexer");this.options=t||Er}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const i=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?i:ds(i,`
5
5
  `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const i=n[0],r=tN(i,n[3]||"");return{type:"code",raw:i,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:r}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let i=n[2].trim();if(/#$/.test(i)){const r=ds(i,"#");(this.options.pedantic||!r||/ $/.test(r))&&(i=r.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:i,tokens:this.lexer.inline(i)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){let i=n[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
package/public/index.html CHANGED
@@ -23,7 +23,7 @@
23
23
  }
24
24
  })()
25
25
  </script>
26
- <script type="module" crossorigin src="/assets/main-DuOwgG36.js"></script>
26
+ <script type="module" crossorigin src="/assets/main-BToBcvrm.js"></script>
27
27
  <link rel="modulepreload" crossorigin href="/assets/index-Cpjhgy_m.js">
28
28
  <link rel="stylesheet" crossorigin href="/assets/index-CMK1bVZN.css">
29
29
  <link rel="stylesheet" crossorigin href="/assets/main-HAZkIolJ.css">