wherever-dev 0.10.3 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/LICENSE +661 -21
  2. package/package.json +2 -1
  3. package/public/_app/immutable/chunks/{Db10dKf4.js → 138z6LBp.js} +2 -2
  4. package/public/_app/immutable/chunks/{Db10dKf4.js.map → 138z6LBp.js.map} +1 -1
  5. package/public/_app/immutable/chunks/{i1k0VSTY.js → 3xtiz3Ra.js} +2 -2
  6. package/public/_app/immutable/chunks/{i1k0VSTY.js.map → 3xtiz3Ra.js.map} +1 -1
  7. package/public/_app/immutable/chunks/{BKsSWUiC.js → T3k8PneW.js} +2 -2
  8. package/public/_app/immutable/chunks/{BKsSWUiC.js.map → T3k8PneW.js.map} +1 -1
  9. package/public/_app/immutable/entry/{app.CBnODo4B.js → app.D8ceYtzB.js} +3 -3
  10. package/public/_app/immutable/entry/{app.CBnODo4B.js.map → app.D8ceYtzB.js.map} +1 -1
  11. package/public/_app/immutable/entry/start.BoK7lpDR.js +2 -0
  12. package/public/_app/immutable/entry/start.BoK7lpDR.js.map +1 -0
  13. package/public/_app/immutable/nodes/{0.ByBtLES_.js → 0.D5zbOzjT.js} +2 -2
  14. package/public/_app/immutable/nodes/{0.ByBtLES_.js.map → 0.D5zbOzjT.js.map} +1 -1
  15. package/public/_app/immutable/nodes/{1.nndQb_ZD.js → 1.CP0aHame.js} +2 -2
  16. package/public/_app/immutable/nodes/{1.nndQb_ZD.js.map → 1.CP0aHame.js.map} +1 -1
  17. package/public/_app/immutable/nodes/{2.q7p9NmjW.js → 2.DWP05EYK.js} +2 -2
  18. package/public/_app/immutable/nodes/{2.q7p9NmjW.js.map → 2.DWP05EYK.js.map} +1 -1
  19. package/public/_app/version.json +1 -1
  20. package/public/index.html +10 -10
  21. package/public/service-worker.js +1 -1
  22. package/public/_app/immutable/entry/start.yx2kNVt2.js +0 -2
  23. package/public/_app/immutable/entry/start.yx2kNVt2.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import{b as Ds,a as h,c as sr,g as b,d as Tr,e as j,s as te,f as lr,t as Cn}from"../chunks/CoQYrr6F.js";import{as as In,b3 as hs,am as Rr,bf as U,aq as Fo,O as Fi,aT as Ui,ar as Ks,d as xa,an as Ys,au as zi,n as Bi,a1 as Hi,u as Wi,t as ji,a2 as Gi,W as qi,X as Vi,H as Ki,b4 as Uo,C as zo,z as Bo,aF as xs,a3 as ur,ad as Yi,aA as Xi,a_ as Zi,az as _a,be as ya,bg as Ji,bh as _r,aV as co,aR as Ho,aQ as hr,aN as br,ag as Jt,b7 as f,aj as t,a6 as Qi,bi as Z,$ as el,bm as On,ai as tr,a9 as Yt,aL as es,a$ as p,Y as u,aW as c,aJ as _t,ba as Y,aP as Hn,bj as Bt,bk as tl,aU as nl}from"../chunks/CRRPBe07.js";import{i as k,s as Lr,a as Ne,p as yr}from"../chunks/Dtm96ZKi.js";import{a as rl,b as se,r as vt,c as wa,e as wn,i as jn,d as sl}from"../chunks/Db10dKf4.js";import{_ as ol,b as er}from"../chunks/CAWbdcQM.js";import{v as ka}from"../chunks/i1k0VSTY.js";import{p as al}from"../chunks/BKsSWUiC.js";function Wo(n,e,r=!1,s=!1,o=!1,a=!1){var l=n,d="";if(r){var _=n;In&&(l=hs(Rr(_)))}U(()=>{var v=Fi;if(d===(d=e()??"")){In&&Fo();return}if(r&&!In){v.nodes=null,_.innerHTML=d,d!==""&&Ds(Rr(_),_.lastChild);return}if(v.nodes!==null&&(Ui(v.nodes.start,v.nodes.end),v.nodes=null),d!==""){if(In){Ks.data;for(var g=Fo(),S=g;g!==null&&(g.nodeType!==xa||g.data!=="");)S=g,g=Ys(g);if(g===null)throw zi(),Bi;Ds(Ks,S),l=hs(g);return}var F=s?Wi:o?ji:void 0,z=Hi(s?"svg":o?"math":"template",F);z.innerHTML=d;var M=s||o?z:z.content;if(Ds(Rr(M),M.lastChild),s||o)for(;Rr(M);)l.before(Rr(M));else l.before(M)}})}function il(n,e){let r=null,s=In;var o;if(In){r=Ks;for(var a=Rr(document.head);a!==null&&(a.nodeType!==xa||a.data!==n);)a=Ys(a);if(a===null)Uo(!1);else{var l=Ys(a);a.remove(),hs(l)}}In||(o=document.head.appendChild(Gi()));try{qi(()=>{var d=Vi(()=>e(o));d.f|=Ki})}finally{s&&(Uo(!0),hs(r))}}function Sa(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(r=Sa(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function ll(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=Sa(n))&&(s&&(s+=" "),s+=e);return s}function cl(n){return typeof n=="object"?ll(n):n??""}function dl(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function ul(n,e){return n==null?null:String(n)}function rn(n,e,r,s,o,a){var l=n[zo];if(In||l!==r||l===void 0){var d=dl(r);(!In||d!==n.getAttribute("class"))&&(d==null?n.removeAttribute("class"):e?n.className=d:n.setAttribute("class",d)),n[zo]=r}return a}function fl(n,e,r,s){var o=n[Bo];if(In||o!==e){var a=ul(e);(!In||a!==n.getAttribute("style"))&&(a==null?n.removeAttribute("style"):n.style.cssText=a),n[Bo]=e}return s}function uo(n,e,r=!1){if(n.multiple){if(e==null)return;if(!Xi(e))return Zi();for(var s of n.options)s.selected=e.includes(Kr(s));return}for(s of n.options){var o=Kr(s);if(_a(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function Ta(n){var e=new MutationObserver(()=>{uo(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),ya(()=>{e.disconnect()})}function Jr(n,e,r=e){var s=new WeakSet,o=!0;xs(n,"change",a=>{var l=a?"[selected]":":checked",d;if(n.multiple)d=[].map.call(n.querySelectorAll(l),Kr);else{var _=n.querySelector(l)??n.querySelector("option:not([disabled])");d=_&&Kr(_)}r(d),n.__value=d,ur!==null&&s.add(ur)}),Yi(()=>{var a=e();if(n===document.activeElement){var l=ur;if(s.has(l))return}if(uo(n,a,o),o&&a===void 0){var d=n.querySelector(":checked");d!==null&&(a=Kr(d),r(a))}n.__value=a,o=!1}),Ta(n)}function Kr(n){return"__value"in n?n.__value:n.value}function Gn(n,e,r=e){var s=new WeakSet;xs(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=Ls(n)?Os(a):a,r(a),ur!==null&&s.add(ur),await Ji(),a!==(a=e())){var l=n.selectionStart,d=n.selectionEnd,_=n.value.length;if(n.value=a??"",d!==null){var v=n.value.length;l===d&&d===_&&v>_?(n.selectionStart=v,n.selectionEnd=v):(n.selectionStart=l,n.selectionEnd=Math.min(d,v))}}}),(In&&n.defaultValue!==n.value||_r(e)==null&&n.value)&&(r(Ls(n)?Os(n.value):n.value),ur!==null&&s.add(ur)),co(()=>{var o=e();if(n===document.activeElement){var a=ur;if(s.has(a))return}Ls(n)&&o===Os(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const Ps=new Set;function pr(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",l=n;let d=!1;if(e!==null)for(var _ of e)l=l[_]??=[];l.push(r),xs(r,"change",()=>{var v=r.__value;a&&(v=jo(l,v,r.checked)),o(v)},()=>o(a?[]:null)),co(()=>{var v=s();if(In&&r.defaultChecked!==r.checked){d=!0;return}a?(v=v||[],r.checked=v.includes(r.__value)):r.checked=_a(r.__value,v)}),ya(()=>{var v=l.indexOf(r);v!==-1&&l.splice(v,1)}),Ps.has(l)||(Ps.add(l),Ho(()=>{l.sort((v,g)=>v.compareDocumentPosition(g)===4?-1:1),Ps.delete(l)})),Ho(()=>{if(d){var v;if(a)v=jo(l,v,r.checked);else{var g=l.find(S=>S.checked);v=g?.__value}o(v)}})}function qn(n,e,r=e){xs(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(In&&n.defaultChecked!==n.checked||_r(e)==null)&&r(n.checked),co(()=>{var s=e();n.checked=!!s})}function jo(n,e,r){for(var s=new Set,o=0;o<n.length;o+=1)n[o].checked&&s.add(n[o].__value);return r||s.delete(e),Array.from(s)}function Ls(n){var e=n.type;return e==="number"||e==="range"}function Os(n){return n===""?null:+n}const pl=!1,hl=!0,rh=Object.freeze(Object.defineProperty({__proto__:null,prerender:hl,ssr:pl},Symbol.toStringTag,{value:"Module"})),Ns="Wherever",bl="Create & maintain apps from wherever with a beautiful remote workspace.",Fs="https://localhost",vl="#000000",ml="black-translucent";function Mr(n,e){return rl(n)}var gl=b('<meta name="title"/> <meta name="description"/> <!> <meta property="og:type"/> <meta property="og:url"/> <meta property="og:title"/> <meta property="og:description"/> <meta property="og:image"/> <meta property="twitter:card" content="summary_large_image"/> <meta property="twitter:url"/> <meta property="twitter:title"/> <meta property="twitter:description"/> <meta property="twitter:image"/> <link rel="icon" type="image/png"/> <link rel="icon" sizes="any"/> <link rel="apple-touch-icon"/> <link rel="manifest"/> <meta name="theme-color"/> <meta name="mobile-web-app-capable" content="yes"/> <meta name="application-name"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style"/> <meta name="apple-mobile-web-app-title"/> <meta name="version"/>',1);function xl(n,e){hr(e,!0);const r=Fs.endsWith("/")?Fs.slice(0,-1):Fs,s=r+"/preview.png";let o=Z(()=>e.home||!1),a=Z(()=>({type:e.type||"website",title:e.title||Ns,description:e.description||bl,image:e.image||s,url:`${r}${al.url.pathname}`}));il("13n5pl5",l=>{var d=gl(),_=Jt(d),v=f(_,2),g=f(v,2);{var S=pt=>{var lt=sr(),mt=Jt(lt);k(mt,st=>{}),h(pt,lt)};k(g,pt=>{t(o)&&pt(S)})}var F=f(g,2),z=f(F,2),M=f(z,2),N=f(M,2),$e=f(N,2),Q=f($e,4),Pe=f(Q,2),Le=f(Pe,2),Se=f(Le,2),ge=f(Se,2),xe=f(ge,2),Ge=f(xe,2),tt=f(Ge,2),Ye=f(tt,2),Je=f(Ye,4),Tt=f(Je,4),fe=f(Tt,2),Pt=f(fe,2);U((pt,lt,mt,st)=>{se(_,"content",t(a).title),se(v,"content",t(a).description),se(F,"content",t(a).type),se(z,"content",t(a).url),se(M,"content",t(a).title),se(N,"content",t(a).description),se($e,"content",t(a).image),se(Q,"content",t(a).url),se(Pe,"content",t(a).title),se(Le,"content",t(a).description),se(Se,"content",t(a).image),se(ge,"href",pt),se(xe,"href",lt),se(Ge,"href",mt),se(tt,"href",st),se(Ye,"content",vl),se(Je,"content",Ns),se(Tt,"content",ml),se(fe,"content",Ns),se(Pt,"content",ka)},[()=>Mr("/pwa/favicon.png"),()=>Mr("/pwa/favicon.ico"),()=>Mr("/pwa/apple-touch-icon.png"),()=>Mr("/pwa/manifest.webmanifest")]),Qi(()=>{el.title=t(a).title??""}),h(l,d)}),br()}let Or=null;function _l(){if(typeof window>"u")return null;try{if(!Or){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;Or=new n}return Or.state==="suspended"&&Or.resume().catch(()=>{}),Or}catch{return null}}function Go(n,e,r,s,o){const a=n.createOscillator(),l=n.createGain();a.type="sine",a.frequency.value=e;const d=.015;l.gain.setValueAtTime(1e-4,r),l.gain.exponentialRampToValueAtTime(o,r+d),l.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(l),l.connect(n.destination),a.start(r),a.stop(r+s+.02)}const qo=new Map;function yl(n){if(typeof Audio>"u")return!1;try{let e=qo.get(n);e||(e=new Audio(n),e.preload="auto",qo.set(n,e));try{e.currentTime=0}catch{}const r=e.play();return r&&typeof r.catch=="function"&&r.catch(()=>{}),!0}catch{return!1}}function Aa(n){if(n&&n.trim()&&yl(n.trim()))return;const e=_l();if(e)try{const r=e.currentTime;Go(e,1046.5,r,.16,.12),Go(e,1396.9,r+.13,.22,.12)}catch{}}function fo(n){if(!n)return null;const e=n.trimStart(),r=e.match(/^<skill\s+name="([^"]*)"[^>]*>/);if(r){const s=e.indexOf("</skill>");return s===-1?null:{skillName:r[1],args:e.slice(s+8).trim()}}if(e.startsWith("/skill:")){const s=e.slice(7),o=s.indexOf(" "),a=o===-1?s:s.slice(0,o);if(!a)return null;const l=o===-1?"":s.slice(o+1).trim();return{skillName:a,args:l}}return null}function ls(n){const e=fo(n);return e?`skill:${e.skillName}\0${e.args}`:null}function us(){}function wl(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function kl(n,...e){if(n==null)return us;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Zt(n){let e;return kl(n,r=>e=r)(),e}var Cr=[];function Sl(n,e=us){let r;const s=new Set;function o(d){if(wl(n,d)&&(n=d,r)){const _=!Cr.length;for(const v of s)v[1](),Cr.push(v,n);if(_){for(let v=0;v<Cr.length;v+=2)Cr[v][0](Cr[v+1]);Cr.length=0}}}function a(d){o(d(n))}function l(d,_=us){const v=[d,_];return s.add(v),s.size===1&&(r=e(o)||us),d(n),()=>{s.delete(v),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:l}}const Us={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,folderConflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null,pendingSteering:[],skills:[]};class Bn{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;createWatchdog=null;static CREATE_WATCHDOG_MS=25e3;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;hasEverConnected=!1;static HANDSHAKE_FAIL_HINT_AFTER=2;livenessTimer=null;heartbeatTimer=null;lastInboundAt=0;static STALE_SOCKET_MS=6e4;static TURN_STALL_MS=45e3;static HEARTBEAT_MS=25e3;isInitialConnect=!0;resumeSessionFile=null;resumeCwd;resumeModel;listeners=new Set;pendingUploads=new Map;confirmTimers=new Map;static CONFIRM_MS=12e3;static PENDING_PREFIX="wherever-pending:";constructor(e){this.config={secure:!0,...e},this.stateStore=Sl({...Us,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(z=>r?{...z,connecting:!0,error:null}:{...Us,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const s=this.config.secure?"wss":"ws",o=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,a=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",l=`${s}://${o}:${this.config.port}/ws${a}`,d=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!d){this.stateStore.update(z=>({...z,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const z=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=z?new d(l,z):new d(l)}catch(z){this.stateStore.update(M=>({...M,connecting:!1,error:`Failed to connect: ${z}`})),this.scheduleReconnect();return}const _=this.ws,v=()=>{if(this.ws!==_)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.hasEverConnected=!0,this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(Q=>({...Q,connected:!0,connecting:!1,error:null}));const z=Zt(this.stateStore),M=this.resumeSessionFile??z.activeSessionFile,N=this.resumeSessionFile!=null?this.resumeCwd:z.activeCwd??void 0,$e=this.resumeSessionFile!=null?this.resumeModel:z.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,M?(this.stateStore.update(Q=>Q.resyncing?Q:{...Q,resyncing:!0}),this.send({type:"session_load",sessionFile:M,cwd:N,model:$e}),this.armLoadWatchdog()):this.stateStore.update(Q=>Q.resyncing?{...Q,resyncing:!1}:Q)},g=z=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const M=typeof z.data=="string"?z.data:z.data.toString(),N=JSON.parse(M);this.handleMessage(N)}catch(M){console.error("Failed to parse WebSocket message:",M)}}},S=()=>{this.ws===_&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(z=>({...z,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:z.activeSessionFile?!0:z.resyncing})),this.scheduleReconnect())},F=z=>{this.ws===_&&this.stateStore.update(M=>({...M,error:M.error||"Connection error occurred"}))};typeof _.addEventListener=="function"?(_.addEventListener("open",v),_.addEventListener("message",g),_.addEventListener("close",S),_.addEventListener("error",F)):typeof _.on=="function"&&(_.on("open",v),_.on("message",z=>g({data:z})),_.on("close",S),_.on("error",F))}disconnect(e=!0){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.clearCreateWatchdog(),this.ws){const r=this.ws;try{typeof r.removeAllListeners=="function"&&r.removeAllListeners();const s=()=>{};typeof r.on=="function"?r.on("error",s):typeof r.addEventListener=="function"?r.addEventListener("error",s):r.onerror=s,r.close()}catch{}this.ws=null}if(e){for(const r of this.confirmTimers.values())clearTimeout(r);this.confirmTimers.clear(),this.stateStore.set({...Us,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}else this.stateStore.update(r=>({...r,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1}))}suspend(){const e=Zt(this.stateStore);e.activeSessionFile&&(this.resumeSessionFile=e.activeSessionFile,this.resumeCwd=e.activeCwd??void 0,this.resumeModel=e.activeModel??void 0),e.isStreaming&&this.stateStore.update(r=>({...r,isStreaming:!1})),this.disconnect(!1)}resume(){const e=Zt(this.stateStore);e.connected||e.connecting||((this.resumeSessionFile||e.activeSessionFile)&&(this.stateStore.update(r=>({...r,resyncing:!0})),this.armLoadWatchdog()),this.connect(void 0,!0))}hasSuspendedSession(){return this.resumeSessionFile!==null}hasActiveSession(){return this.resumeSessionFile!==null||Zt(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,Bn.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now()-this.lastInboundAt,o=Zt(this.stateStore).isStreaming,a=o?Bn.TURN_STALL_MS:Bn.STALE_SOCKET_MS;if(s<a)return;console.warn(`[wherever] relay connection stale: no inbound frame for ${s}ms (threshold ${a}ms, ${o?"mid-turn":"idle"}); tearing down dead socket and reconnecting`),this.stopLivenessWatchdog();const l=this.ws;this.ws=null;try{typeof l.terminate=="function"?l.terminate():typeof l.close=="function"&&l.close()}catch{}this.stateStore.update(d=>({...d,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:o?"Connection to relay stalled mid-turn; reconnecting...":d.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,Bn.HEARTBEAT_MS),this.livenessTimer&&typeof this.livenessTimer.unref=="function"&&this.livenessTimer.unref())}stopLivenessWatchdog(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.livenessTimer&&(clearInterval(this.livenessTimer),this.livenessTimer=null)}armLoadWatchdog(){this.clearLoadWatchdog(),this.loadWatchdog=setTimeout(()=>{this.loadWatchdog=null;const e=Zt(this.stateStore);!e.loadingSession&&!e.resyncing||(console.warn("[wherever] session load timed out; clearing loading state"),this.stateStore.update(r=>({...r,loadingSession:!1,resyncing:!1,sessionError:r.sessionError||"Loading the session timed out. Please retry from the sidebar or reload."})))},Bn.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,Zt(this.stateStore).creatingSession&&(console.warn("[wherever] session create timed out; clearing creating state"),this.stateStore.update(r=>({...r,creatingSession:!1,sessionError:r.sessionError||"Creating the session timed out. It may still be starting on the server; check the sidebar or reload."})))},Bn.CREATE_WATCHDOG_MS)}clearCreateWatchdog(){this.createWatchdog&&(clearTimeout(this.createWatchdog),this.createWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{if(this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`),!this.hasEverConnected&&this.reconnectAttempts>=Bn.HANDSHAKE_FAIL_HINT_AFTER){const r=this.config.secure?"wss":"ws";this.stateStore.update(s=>({...s,error:`Cannot connect to the wherever server: the connection is being rejected. This usually means a missing or wrong token, or a wrong host/port/scheme (currently ${r}://${this.config.host}:${this.config.port}). Check the auth token and connection settings.`}))}const e=!!Zt(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)},this.reconnectDelay))}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":case"session_error":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(e.uploadId);s&&(s.resolve({savedPath:e.savedPath,filename:e.filename}),this.pendingUploads.delete(e.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(e.uploadId);s&&(s.reject(new Error(e.error)),this.pendingUploads.delete(e.uploadId));break}case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="thinking"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="assistant"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_ack":typeof e.content=="string"&&this.confirmDeliveredByContent(e.content);break;case"queue_update":this.stateStore.update(s=>({...s,pendingSteering:Array.isArray(e.steering)?[...e.steering]:[]}));break;case"message_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(d=>d.role==="thinking"&&d.isStreaming);a&&(o=o.map(d=>d.id===a.id?{...d,isStreaming:!1}:d));const l=[...o].reverse().find(d=>d.role==="assistant"&&d.isStreaming);if(l)o=o.map(d=>d.id===l.id?{...d,content:e.content||d.content,isStreaming:!1}:d);else if(e.content){if(e.role==="user"&&this.confirmDeliveredByContent(e.content))return Zt(this.stateStore);const d=e.role==="user"?ls(e.content):null;if(d){const g=[...o].reverse().find(S=>S.role==="user"&&ls(S.content)===d);if(g)return g.content!==e.content&&(o=o.map(S=>S.id===g.id?{...S,content:e.content}:S)),{...s,messages:o}}const _=[...o].reverse().find(g=>g.role==="user");e.role==="user"&&_&&_.content===e.content||(o=[...o,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:o}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{const s=Date.now();this.stateStore.update(o=>({...o,isStreaming:!1,pendingSteering:[],messages:o.messages.map(a=>a.isStreaming?{...a,isStreaming:!1,...a.role==="tool"?{interrupted:!0}:{},endedAt:a.role==="tool"&&a.endedAt===void 0?s:a.endedAt}:a)})),this.agentEndTimeout=null},300);break;case"tool_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null);const r=e.args?Object.entries(e.args).filter(([s,o])=>o!==void 0&&o!=="").map(([s,o])=>`${s}=${JSON.stringify(o)}`).join(" "):"";this.stateStore.update(s=>{const o=s.messages.map(_=>_.isStreaming&&(_.role==="assistant"||_.role==="thinking")?{..._,isStreaming:!1}:_),a=Date.now(),l=!!e.forceCommand;if(l){const _=o.find(v=>v.role==="tool"&&v.optimistic&&v.isStreaming);if(_)return{...s,messages:o.map(v=>v.id===_.id?{...v,optimistic:!1,toolName:e.toolName,toolArgs:r,content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,startedAt:a,timestamp:a,forceCommand:!0}:v)}}const d={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...l?{forceCommand:!0}:{}};return{...s,messages:[...o,d]}});break;case"tool_update":{this.stateStore.update(s=>{const o=[...s.messages].reverse().find(a=>a.role==="tool"&&a.toolName===e.toolName&&a.isStreaming);return o?{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content.includes(`
1
+ import{b as Ds,a as h,c as sr,g as b,d as Tr,e as j,s as te,f as lr,t as Cn}from"../chunks/CoQYrr6F.js";import{as as In,b3 as hs,am as Rr,bf as U,aq as Fo,O as Fi,aT as Ui,ar as Ks,d as xa,an as Ys,au as zi,n as Bi,a1 as Hi,u as Wi,t as ji,a2 as Gi,W as qi,X as Vi,H as Ki,b4 as Uo,C as zo,z as Bo,aF as xs,a3 as ur,ad as Yi,aA as Xi,a_ as Zi,az as _a,be as ya,bg as Ji,bh as _r,aV as co,aR as Ho,aQ as hr,aN as br,ag as Jt,b7 as f,aj as t,a6 as Qi,bi as Z,$ as el,bm as On,ai as tr,a9 as Yt,aL as es,a$ as p,Y as u,aW as c,aJ as _t,ba as Y,aP as Hn,bj as Bt,bk as tl,aU as nl}from"../chunks/CRRPBe07.js";import{i as k,s as Lr,a as Ne,p as yr}from"../chunks/Dtm96ZKi.js";import{a as rl,b as se,r as vt,c as wa,e as wn,i as jn,d as sl}from"../chunks/138z6LBp.js";import{_ as ol,b as er}from"../chunks/CAWbdcQM.js";import{v as ka}from"../chunks/3xtiz3Ra.js";import{p as al}from"../chunks/T3k8PneW.js";function Wo(n,e,r=!1,s=!1,o=!1,a=!1){var l=n,d="";if(r){var _=n;In&&(l=hs(Rr(_)))}U(()=>{var v=Fi;if(d===(d=e()??"")){In&&Fo();return}if(r&&!In){v.nodes=null,_.innerHTML=d,d!==""&&Ds(Rr(_),_.lastChild);return}if(v.nodes!==null&&(Ui(v.nodes.start,v.nodes.end),v.nodes=null),d!==""){if(In){Ks.data;for(var g=Fo(),S=g;g!==null&&(g.nodeType!==xa||g.data!=="");)S=g,g=Ys(g);if(g===null)throw zi(),Bi;Ds(Ks,S),l=hs(g);return}var F=s?Wi:o?ji:void 0,z=Hi(s?"svg":o?"math":"template",F);z.innerHTML=d;var M=s||o?z:z.content;if(Ds(Rr(M),M.lastChild),s||o)for(;Rr(M);)l.before(Rr(M));else l.before(M)}})}function il(n,e){let r=null,s=In;var o;if(In){r=Ks;for(var a=Rr(document.head);a!==null&&(a.nodeType!==xa||a.data!==n);)a=Ys(a);if(a===null)Uo(!1);else{var l=Ys(a);a.remove(),hs(l)}}In||(o=document.head.appendChild(Gi()));try{qi(()=>{var d=Vi(()=>e(o));d.f|=Ki})}finally{s&&(Uo(!0),hs(r))}}function Sa(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(r=Sa(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function ll(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=Sa(n))&&(s&&(s+=" "),s+=e);return s}function cl(n){return typeof n=="object"?ll(n):n??""}function dl(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function ul(n,e){return n==null?null:String(n)}function rn(n,e,r,s,o,a){var l=n[zo];if(In||l!==r||l===void 0){var d=dl(r);(!In||d!==n.getAttribute("class"))&&(d==null?n.removeAttribute("class"):e?n.className=d:n.setAttribute("class",d)),n[zo]=r}return a}function fl(n,e,r,s){var o=n[Bo];if(In||o!==e){var a=ul(e);(!In||a!==n.getAttribute("style"))&&(a==null?n.removeAttribute("style"):n.style.cssText=a),n[Bo]=e}return s}function uo(n,e,r=!1){if(n.multiple){if(e==null)return;if(!Xi(e))return Zi();for(var s of n.options)s.selected=e.includes(Kr(s));return}for(s of n.options){var o=Kr(s);if(_a(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function Ta(n){var e=new MutationObserver(()=>{uo(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),ya(()=>{e.disconnect()})}function Jr(n,e,r=e){var s=new WeakSet,o=!0;xs(n,"change",a=>{var l=a?"[selected]":":checked",d;if(n.multiple)d=[].map.call(n.querySelectorAll(l),Kr);else{var _=n.querySelector(l)??n.querySelector("option:not([disabled])");d=_&&Kr(_)}r(d),n.__value=d,ur!==null&&s.add(ur)}),Yi(()=>{var a=e();if(n===document.activeElement){var l=ur;if(s.has(l))return}if(uo(n,a,o),o&&a===void 0){var d=n.querySelector(":checked");d!==null&&(a=Kr(d),r(a))}n.__value=a,o=!1}),Ta(n)}function Kr(n){return"__value"in n?n.__value:n.value}function Gn(n,e,r=e){var s=new WeakSet;xs(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=Ls(n)?Os(a):a,r(a),ur!==null&&s.add(ur),await Ji(),a!==(a=e())){var l=n.selectionStart,d=n.selectionEnd,_=n.value.length;if(n.value=a??"",d!==null){var v=n.value.length;l===d&&d===_&&v>_?(n.selectionStart=v,n.selectionEnd=v):(n.selectionStart=l,n.selectionEnd=Math.min(d,v))}}}),(In&&n.defaultValue!==n.value||_r(e)==null&&n.value)&&(r(Ls(n)?Os(n.value):n.value),ur!==null&&s.add(ur)),co(()=>{var o=e();if(n===document.activeElement){var a=ur;if(s.has(a))return}Ls(n)&&o===Os(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const Ps=new Set;function pr(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",l=n;let d=!1;if(e!==null)for(var _ of e)l=l[_]??=[];l.push(r),xs(r,"change",()=>{var v=r.__value;a&&(v=jo(l,v,r.checked)),o(v)},()=>o(a?[]:null)),co(()=>{var v=s();if(In&&r.defaultChecked!==r.checked){d=!0;return}a?(v=v||[],r.checked=v.includes(r.__value)):r.checked=_a(r.__value,v)}),ya(()=>{var v=l.indexOf(r);v!==-1&&l.splice(v,1)}),Ps.has(l)||(Ps.add(l),Ho(()=>{l.sort((v,g)=>v.compareDocumentPosition(g)===4?-1:1),Ps.delete(l)})),Ho(()=>{if(d){var v;if(a)v=jo(l,v,r.checked);else{var g=l.find(S=>S.checked);v=g?.__value}o(v)}})}function qn(n,e,r=e){xs(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(In&&n.defaultChecked!==n.checked||_r(e)==null)&&r(n.checked),co(()=>{var s=e();n.checked=!!s})}function jo(n,e,r){for(var s=new Set,o=0;o<n.length;o+=1)n[o].checked&&s.add(n[o].__value);return r||s.delete(e),Array.from(s)}function Ls(n){var e=n.type;return e==="number"||e==="range"}function Os(n){return n===""?null:+n}const pl=!1,hl=!0,rh=Object.freeze(Object.defineProperty({__proto__:null,prerender:hl,ssr:pl},Symbol.toStringTag,{value:"Module"})),Ns="Wherever",bl="Create & maintain apps from wherever with a beautiful remote workspace.",Fs="https://localhost",vl="#000000",ml="black-translucent";function Mr(n,e){return rl(n)}var gl=b('<meta name="title"/> <meta name="description"/> <!> <meta property="og:type"/> <meta property="og:url"/> <meta property="og:title"/> <meta property="og:description"/> <meta property="og:image"/> <meta property="twitter:card" content="summary_large_image"/> <meta property="twitter:url"/> <meta property="twitter:title"/> <meta property="twitter:description"/> <meta property="twitter:image"/> <link rel="icon" type="image/png"/> <link rel="icon" sizes="any"/> <link rel="apple-touch-icon"/> <link rel="manifest"/> <meta name="theme-color"/> <meta name="mobile-web-app-capable" content="yes"/> <meta name="application-name"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style"/> <meta name="apple-mobile-web-app-title"/> <meta name="version"/>',1);function xl(n,e){hr(e,!0);const r=Fs.endsWith("/")?Fs.slice(0,-1):Fs,s=r+"/preview.png";let o=Z(()=>e.home||!1),a=Z(()=>({type:e.type||"website",title:e.title||Ns,description:e.description||bl,image:e.image||s,url:`${r}${al.url.pathname}`}));il("13n5pl5",l=>{var d=gl(),_=Jt(d),v=f(_,2),g=f(v,2);{var S=pt=>{var lt=sr(),mt=Jt(lt);k(mt,st=>{}),h(pt,lt)};k(g,pt=>{t(o)&&pt(S)})}var F=f(g,2),z=f(F,2),M=f(z,2),N=f(M,2),$e=f(N,2),Q=f($e,4),Pe=f(Q,2),Le=f(Pe,2),Se=f(Le,2),ge=f(Se,2),xe=f(ge,2),Ge=f(xe,2),tt=f(Ge,2),Ye=f(tt,2),Je=f(Ye,4),Tt=f(Je,4),fe=f(Tt,2),Pt=f(fe,2);U((pt,lt,mt,st)=>{se(_,"content",t(a).title),se(v,"content",t(a).description),se(F,"content",t(a).type),se(z,"content",t(a).url),se(M,"content",t(a).title),se(N,"content",t(a).description),se($e,"content",t(a).image),se(Q,"content",t(a).url),se(Pe,"content",t(a).title),se(Le,"content",t(a).description),se(Se,"content",t(a).image),se(ge,"href",pt),se(xe,"href",lt),se(Ge,"href",mt),se(tt,"href",st),se(Ye,"content",vl),se(Je,"content",Ns),se(Tt,"content",ml),se(fe,"content",Ns),se(Pt,"content",ka)},[()=>Mr("/pwa/favicon.png"),()=>Mr("/pwa/favicon.ico"),()=>Mr("/pwa/apple-touch-icon.png"),()=>Mr("/pwa/manifest.webmanifest")]),Qi(()=>{el.title=t(a).title??""}),h(l,d)}),br()}let Or=null;function _l(){if(typeof window>"u")return null;try{if(!Or){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;Or=new n}return Or.state==="suspended"&&Or.resume().catch(()=>{}),Or}catch{return null}}function Go(n,e,r,s,o){const a=n.createOscillator(),l=n.createGain();a.type="sine",a.frequency.value=e;const d=.015;l.gain.setValueAtTime(1e-4,r),l.gain.exponentialRampToValueAtTime(o,r+d),l.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(l),l.connect(n.destination),a.start(r),a.stop(r+s+.02)}const qo=new Map;function yl(n){if(typeof Audio>"u")return!1;try{let e=qo.get(n);e||(e=new Audio(n),e.preload="auto",qo.set(n,e));try{e.currentTime=0}catch{}const r=e.play();return r&&typeof r.catch=="function"&&r.catch(()=>{}),!0}catch{return!1}}function Aa(n){if(n&&n.trim()&&yl(n.trim()))return;const e=_l();if(e)try{const r=e.currentTime;Go(e,1046.5,r,.16,.12),Go(e,1396.9,r+.13,.22,.12)}catch{}}function fo(n){if(!n)return null;const e=n.trimStart(),r=e.match(/^<skill\s+name="([^"]*)"[^>]*>/);if(r){const s=e.indexOf("</skill>");return s===-1?null:{skillName:r[1],args:e.slice(s+8).trim()}}if(e.startsWith("/skill:")){const s=e.slice(7),o=s.indexOf(" "),a=o===-1?s:s.slice(0,o);if(!a)return null;const l=o===-1?"":s.slice(o+1).trim();return{skillName:a,args:l}}return null}function ls(n){const e=fo(n);return e?`skill:${e.skillName}\0${e.args}`:null}function us(){}function wl(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function kl(n,...e){if(n==null)return us;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Zt(n){let e;return kl(n,r=>e=r)(),e}var Cr=[];function Sl(n,e=us){let r;const s=new Set;function o(d){if(wl(n,d)&&(n=d,r)){const _=!Cr.length;for(const v of s)v[1](),Cr.push(v,n);if(_){for(let v=0;v<Cr.length;v+=2)Cr[v][0](Cr[v+1]);Cr.length=0}}}function a(d){o(d(n))}function l(d,_=us){const v=[d,_];return s.add(v),s.size===1&&(r=e(o)||us),d(n),()=>{s.delete(v),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:l}}const Us={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,folderConflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null,pendingSteering:[],skills:[]};class Bn{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;createWatchdog=null;static CREATE_WATCHDOG_MS=25e3;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;hasEverConnected=!1;static HANDSHAKE_FAIL_HINT_AFTER=2;livenessTimer=null;heartbeatTimer=null;lastInboundAt=0;static STALE_SOCKET_MS=6e4;static TURN_STALL_MS=45e3;static HEARTBEAT_MS=25e3;isInitialConnect=!0;resumeSessionFile=null;resumeCwd;resumeModel;listeners=new Set;pendingUploads=new Map;confirmTimers=new Map;static CONFIRM_MS=12e3;static PENDING_PREFIX="wherever-pending:";constructor(e){this.config={secure:!0,...e},this.stateStore=Sl({...Us,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(z=>r?{...z,connecting:!0,error:null}:{...Us,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const s=this.config.secure?"wss":"ws",o=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,a=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",l=`${s}://${o}:${this.config.port}/ws${a}`,d=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!d){this.stateStore.update(z=>({...z,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const z=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=z?new d(l,z):new d(l)}catch(z){this.stateStore.update(M=>({...M,connecting:!1,error:`Failed to connect: ${z}`})),this.scheduleReconnect();return}const _=this.ws,v=()=>{if(this.ws!==_)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.hasEverConnected=!0,this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(Q=>({...Q,connected:!0,connecting:!1,error:null}));const z=Zt(this.stateStore),M=this.resumeSessionFile??z.activeSessionFile,N=this.resumeSessionFile!=null?this.resumeCwd:z.activeCwd??void 0,$e=this.resumeSessionFile!=null?this.resumeModel:z.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,M?(this.stateStore.update(Q=>Q.resyncing?Q:{...Q,resyncing:!0}),this.send({type:"session_load",sessionFile:M,cwd:N,model:$e}),this.armLoadWatchdog()):this.stateStore.update(Q=>Q.resyncing?{...Q,resyncing:!1}:Q)},g=z=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const M=typeof z.data=="string"?z.data:z.data.toString(),N=JSON.parse(M);this.handleMessage(N)}catch(M){console.error("Failed to parse WebSocket message:",M)}}},S=()=>{this.ws===_&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(z=>({...z,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:z.activeSessionFile?!0:z.resyncing})),this.scheduleReconnect())},F=z=>{this.ws===_&&this.stateStore.update(M=>({...M,error:M.error||"Connection error occurred"}))};typeof _.addEventListener=="function"?(_.addEventListener("open",v),_.addEventListener("message",g),_.addEventListener("close",S),_.addEventListener("error",F)):typeof _.on=="function"&&(_.on("open",v),_.on("message",z=>g({data:z})),_.on("close",S),_.on("error",F))}disconnect(e=!0){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.clearCreateWatchdog(),this.ws){const r=this.ws;try{typeof r.removeAllListeners=="function"&&r.removeAllListeners();const s=()=>{};typeof r.on=="function"?r.on("error",s):typeof r.addEventListener=="function"?r.addEventListener("error",s):r.onerror=s,r.close()}catch{}this.ws=null}if(e){for(const r of this.confirmTimers.values())clearTimeout(r);this.confirmTimers.clear(),this.stateStore.set({...Us,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}else this.stateStore.update(r=>({...r,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1}))}suspend(){const e=Zt(this.stateStore);e.activeSessionFile&&(this.resumeSessionFile=e.activeSessionFile,this.resumeCwd=e.activeCwd??void 0,this.resumeModel=e.activeModel??void 0),e.isStreaming&&this.stateStore.update(r=>({...r,isStreaming:!1})),this.disconnect(!1)}resume(){const e=Zt(this.stateStore);e.connected||e.connecting||((this.resumeSessionFile||e.activeSessionFile)&&(this.stateStore.update(r=>({...r,resyncing:!0})),this.armLoadWatchdog()),this.connect(void 0,!0))}hasSuspendedSession(){return this.resumeSessionFile!==null}hasActiveSession(){return this.resumeSessionFile!==null||Zt(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,Bn.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now()-this.lastInboundAt,o=Zt(this.stateStore).isStreaming,a=o?Bn.TURN_STALL_MS:Bn.STALE_SOCKET_MS;if(s<a)return;console.warn(`[wherever] relay connection stale: no inbound frame for ${s}ms (threshold ${a}ms, ${o?"mid-turn":"idle"}); tearing down dead socket and reconnecting`),this.stopLivenessWatchdog();const l=this.ws;this.ws=null;try{typeof l.terminate=="function"?l.terminate():typeof l.close=="function"&&l.close()}catch{}this.stateStore.update(d=>({...d,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:o?"Connection to relay stalled mid-turn; reconnecting...":d.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,Bn.HEARTBEAT_MS),this.livenessTimer&&typeof this.livenessTimer.unref=="function"&&this.livenessTimer.unref())}stopLivenessWatchdog(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.livenessTimer&&(clearInterval(this.livenessTimer),this.livenessTimer=null)}armLoadWatchdog(){this.clearLoadWatchdog(),this.loadWatchdog=setTimeout(()=>{this.loadWatchdog=null;const e=Zt(this.stateStore);!e.loadingSession&&!e.resyncing||(console.warn("[wherever] session load timed out; clearing loading state"),this.stateStore.update(r=>({...r,loadingSession:!1,resyncing:!1,sessionError:r.sessionError||"Loading the session timed out. Please retry from the sidebar or reload."})))},Bn.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,Zt(this.stateStore).creatingSession&&(console.warn("[wherever] session create timed out; clearing creating state"),this.stateStore.update(r=>({...r,creatingSession:!1,sessionError:r.sessionError||"Creating the session timed out. It may still be starting on the server; check the sidebar or reload."})))},Bn.CREATE_WATCHDOG_MS)}clearCreateWatchdog(){this.createWatchdog&&(clearTimeout(this.createWatchdog),this.createWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{if(this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`),!this.hasEverConnected&&this.reconnectAttempts>=Bn.HANDSHAKE_FAIL_HINT_AFTER){const r=this.config.secure?"wss":"ws";this.stateStore.update(s=>({...s,error:`Cannot connect to the wherever server: the connection is being rejected. This usually means a missing or wrong token, or a wrong host/port/scheme (currently ${r}://${this.config.host}:${this.config.port}). Check the auth token and connection settings.`}))}const e=!!Zt(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)},this.reconnectDelay))}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":case"session_error":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(e.uploadId);s&&(s.resolve({savedPath:e.savedPath,filename:e.filename}),this.pendingUploads.delete(e.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(e.uploadId);s&&(s.reject(new Error(e.error)),this.pendingUploads.delete(e.uploadId));break}case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="thinking"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="assistant"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_ack":typeof e.content=="string"&&this.confirmDeliveredByContent(e.content);break;case"queue_update":this.stateStore.update(s=>({...s,pendingSteering:Array.isArray(e.steering)?[...e.steering]:[]}));break;case"message_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(d=>d.role==="thinking"&&d.isStreaming);a&&(o=o.map(d=>d.id===a.id?{...d,isStreaming:!1}:d));const l=[...o].reverse().find(d=>d.role==="assistant"&&d.isStreaming);if(l)o=o.map(d=>d.id===l.id?{...d,content:e.content||d.content,isStreaming:!1}:d);else if(e.content){if(e.role==="user"&&this.confirmDeliveredByContent(e.content))return Zt(this.stateStore);const d=e.role==="user"?ls(e.content):null;if(d){const g=[...o].reverse().find(S=>S.role==="user"&&ls(S.content)===d);if(g)return g.content!==e.content&&(o=o.map(S=>S.id===g.id?{...S,content:e.content}:S)),{...s,messages:o}}const _=[...o].reverse().find(g=>g.role==="user");e.role==="user"&&_&&_.content===e.content||(o=[...o,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:o}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{const s=Date.now();this.stateStore.update(o=>({...o,isStreaming:!1,pendingSteering:[],messages:o.messages.map(a=>a.isStreaming?{...a,isStreaming:!1,...a.role==="tool"?{interrupted:!0}:{},endedAt:a.role==="tool"&&a.endedAt===void 0?s:a.endedAt}:a)})),this.agentEndTimeout=null},300);break;case"tool_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null);const r=e.args?Object.entries(e.args).filter(([s,o])=>o!==void 0&&o!=="").map(([s,o])=>`${s}=${JSON.stringify(o)}`).join(" "):"";this.stateStore.update(s=>{const o=s.messages.map(_=>_.isStreaming&&(_.role==="assistant"||_.role==="thinking")?{..._,isStreaming:!1}:_),a=Date.now(),l=!!e.forceCommand;if(l){const _=o.find(v=>v.role==="tool"&&v.optimistic&&v.isStreaming);if(_)return{...s,messages:o.map(v=>v.id===_.id?{...v,optimistic:!1,toolName:e.toolName,toolArgs:r,content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,startedAt:a,timestamp:a,forceCommand:!0}:v)}}const d={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...l?{forceCommand:!0}:{}};return{...s,messages:[...o,d]}});break;case"tool_update":{this.stateStore.update(s=>{const o=[...s.messages].reverse().find(a=>a.role==="tool"&&a.toolName===e.toolName&&a.isStreaming);return o?{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content.includes(`
2
2
  `)?a.content+e.delta:`${a.content}
3
3
  ${e.delta}`,toolOutput:`${a.toolOutput}${e.delta}`}:a)}:s});break}case"tool_end":{const s=e.result?`${e.result}`:"",o=!!e.isError&&this.isAbortedToolResult(s),a=!!e.isError&&!o,l=Array.isArray(e.images)&&e.images.length>0?e.images:void 0;this.stateStore.update(d=>{const _=d.messages.find(g=>g.role==="tool"&&g.toolName===e.toolName&&g.isStreaming)??[...d.messages].reverse().find(g=>g.role==="tool"&&g.toolName===e.toolName&&!g.content.startsWith("Tool error:")),v=Date.now();if(_){const g=a?"Error: ":"";return{...d,messages:d.messages.map(S=>S.id===_.id?{...S,content:`${g}${S.content}
4
4
  ${s}`,isStreaming:!1,isError:a,interrupted:o,toolOutput:s,...l?{images:l}:{},endedAt:v}:S)}}else{const g=a?`Tool error: ${e.toolName}
@@ -84,4 +84,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
84
84
  ${qe}`}}if(D.startsWith("/")&&t(ge).length===0){const ue=D.toLowerCase();if(ue==="/new"||ue==="/reset"){if(t(tt).cwd){Qn(t(tt).cwd,t(tt).model||void 0),p(N,"");return}}else if(ue==="/clear"){Ya(),p(N,"");return}else if(ue==="/leave"||ue==="/exit"){Wn(),p(N,"");return}}const Te=Ju({streaming:t(xe),connected:t(Ye),agentPending:t(Je).agentPending,readOnly:t(Ge),hasSession:!!t(tt).sessionId});if(Te.action!=="send"){(Te.reason==="disconnected"||Te.reason==="agent-pending")&&to(H);return}to(H)&&(p(N,""),p(ge,[],!0),e.onSend?.())}function jt(D){if(t(Pe)&&t(fe).length>0){if(D.key==="ArrowDown"){D.preventDefault(),p(Le,(t(Le)+1)%t(fe).length);return}if(D.key==="ArrowUp"){D.preventDefault(),p(Le,(t(Le)-1+t(fe).length)%t(fe).length);return}if(D.key==="Enter"||D.key==="Tab"){D.preventDefault();const H=t(fe)[t(Le)]??t(fe)[0];H&&Pt(H.name);return}if(D.key==="Escape"){D.preventDefault(),p(Pe,!1);return}}D.key==="Enter"&&(t($e)?D.shiftKey||(D.preventDefault(),$t()):D.shiftKey&&(D.preventDefault(),$t()))}var Oe={focusInput:Gt},en=Tf(),wt=u(en);{var E=D=>{var H=cf(),Te=u(H);{var ct=ke=>{var Me=of();_t(2),h(ke,Me)},ue=ke=>{var Me=af(),dt=f(Jt(Me),2),Mt=u(dt,!0);c(dt),U(()=>te(Mt,t(Je).error)),h(ke,Me)},qe=ke=>{var Me=lf();_t(2),h(ke,Me)};k(Te,ke=>{t(Je).connecting?ke(ct):t(Je).error?ke(ue,1):t(Ye)||ke(qe,2)})}c(H),h(D,H)};k(wt,D=>{(!t(Ye)||t(Je).connecting||t(Je).error)&&D(E)})}var ve=f(wt,2);{var L=D=>{var H=df(),Te=u(H),ct=u(Te),ue=u(ct),qe=u(ue,!0);c(ue);var ke=f(ue,2),Me=u(ke);{var dt=nt=>{var We=Cn();U(()=>te(We,e.placeholder??"Search the web...")),h(nt,We)},Mt=nt=>{var We=Cn("Agent is working, tap to Steer...");h(nt,We)},Lt=nt=>{var We=Cn("Read-only mode");h(nt,We)},qt=nt=>{var We=Cn("Select a session first...");h(nt,We)},Nt=nt=>{var We=Cn("Tap to type a message...");h(nt,We)};k(Me,nt=>{S()?nt(dt):t(xe)?nt(Mt,1):t(Ge)?nt(Lt,2):t(tt).sessionId?nt(Nt,-1):nt(qt,3)})}c(ke),c(ct),_t(2),c(Te),c(H),U(()=>te(qe,S()?"🔍":"💬")),j("click",Te,()=>{p(Q,!1),setTimeout(()=>t(st)?.focus(),50)}),h(D,H)},ne=D=>{var H=Sf(),Te=Jt(H);{var ct=De=>{var ot=vf();wn(ot,21,()=>t(ge),jn,(A,$,X)=>{var ee=bf(),ie=u(ee),Et=u(ie,!0);c(ie);var Ct=f(ie,2);{var Fe=Xe=>{var R=uf();h(Xe,R)},Qe=Xe=>{var R=pf(),O=u(R),G=u(O);c(O);var pe=f(O,2);{var Ee=Ce=>{var re=ff();U(()=>se(re,"href",t($).url)),h(Ce,re)};k(pe,Ce=>{t($).url&&Ce(Ee)})}c(R),U(()=>{se(R,"title",t($).error),te(G,`⚠️ ${t($).error??""}`)}),h(Xe,R)},xt=Xe=>{var R=hf();h(Xe,R)};k(Ct,Xe=>{t($).uploading?Xe(Fe):t($).error?Xe(Qe,1):Xe(xt,-1)})}var Kt=f(Ct,2);c(ee),U(()=>{se(ie,"title",t($).name),te(Et,t($).name)}),j("click",Kt,()=>Ht(X)),h(A,ee)}),c(ot),h(De,ot)};k(Te,De=>{t(ge).length>0&&De(ct)})}var ue=f(Te,2);{var qe=De=>{var ot=gf(),A=f(u(ot),2);wn(A,21,z,jn,($,X)=>{var ee=mf(),ie=u(ee,!0);c(ee);var Et={};U(()=>{te(ie,t(X).label),Et!==(Et=t(X).value)&&(ee.value=(ee.__value=t(X).value)??"")}),h($,ee)}),c(A),c(ot),U(()=>A.disabled=t(pt)),Jr(A,M),h(De,ot)};k(ue,De=>{S()&&z().length>0&&De(qe)})}var ke=f(ue,2),Me=u(ke),dt=u(Me);{var Mt=De=>{var ot=yf();wn(ot,23,()=>t(fe),A=>A.name,(A,$,X)=>{var ee=_f(),ie=u(ee),Et=u(ie),Ct=u(Et);c(Et);var Fe=f(Et,2);{var Qe=xt=>{var Kt=xf(),Xe=u(Kt,!0);c(Kt),U(()=>te(Xe,t($).description)),h(xt,Kt)};k(Fe,xt=>{t($).description&&xt(Qe)})}c(ie),c(ee),U(()=>{se(ie,"aria-selected",t(X)===t(Le)),rn(ie,1,`flex w-full flex-col items-start gap-0.5 px-3 py-1.5 text-left text-sm ${t(X)===t(Le)?"bg-brand-surface-3 text-brand-text":"text-brand-text-muted hover:bg-brand-surface-3/60"}`),te(Ct,`/${t($).name??""}`)}),j("mousedown",ie,xt=>{xt.preventDefault(),Pt(t($).name)}),lr("mouseenter",ie,()=>p(Le,t(X),!0)),h(A,ee)}),c(ot),h(De,ot)};k(dt,De=>{t(Pe)&&t(fe).length>0&&De(Mt)})}var Lt=f(dt,2);nl(Lt),se(Lt,"rows",1),er(Lt,De=>p(st,De),()=>t(st)),c(Me);var qt=f(Me,2),Nt=u(qt);{var nt=De=>{var ot=wf(),A=Jt(ot),$=f(A,2);er($,X=>p(Se,X),()=>t(Se)),U(()=>A.disabled=t(pt)),j("click",A,()=>{Fa(),t(Se)?.click()}),j("change",$,At),h(De,ot)};k(Nt,De=>{g()&&!S()&&De(nt)})}var We=f(Nt,2),Qt=u(We);sf(Qt,{get disabled(){return t(pt)},onSend:$t,get text(){return t(N)},set text(De){p(N,De,!0)}}),c(We);var Ot=f(We,2),on=u(Ot);{var Sn=De=>{var ot=Cn();U(()=>te(ot,e.submitLabel??"Search")),h(De,ot)},mn=De=>{var ot=Cn("Steer");h(De,ot)},Nn=De=>{var ot=Cn("Send");h(De,ot)};k(on,De=>{S()?De(Sn):t(xe)?De(mn,1):De(Nn,-1)})}c(Ot),c(qt),c(ke);var Vt=f(ke,2),an=u(Vt),Xt=u(an);vt(Xt),_t(2),c(an);var Rn=f(an,2),gn=u(Rn),Fn=f(gn,2);{var xn=De=>{var ot=kf();h(De,ot)};k(Fn,De=>{t($e)||De(xn)})}c(Rn),c(Vt),U(()=>{Lt.disabled=t(pt),se(Lt,"placeholder",S()?e.placeholder??"Search the web...":t(Ye)?t(xe)?"Agent is working, Steer to interrupt...":t(Ge)?"Read-only mode":t(tt).sessionId?"Type a message...":"Select a session first...":t(Je).connecting?"Reconnecting to remote server...":"Disconnected - cannot send"),Ot.disabled=!t(mt),se(Ot,"title",!S()&&t(xe)?"Steer the agent now (injected at the next step, before the next model call)":void 0),wa(Xt,t($e))}),lr("submit",ke,De=>{De.preventDefault(),$t()}),j("keydown",Lt,jt),Gn(Lt,()=>t(N),De=>p(N,De)),j("change",Xt,Ae),j("click",gn,()=>p(Q,!0)),h(D,H)};k(ve,D=>{t(Q)?D(L):D(ne,-1)})}c(en),h(n,en);var _e=br(Oe);return v(),_e}Tr(["click","mousedown","keydown","change"]);var Ef=b('<button type="button" class="block w-full px-2.5 py-1 text-left text-xs text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"> </button>'),Cf=b('<div class="absolute right-0 left-0 z-50 mt-1 max-h-40 overflow-y-auto rounded border border-brand-border bg-brand-surface-2 py-1 shadow-xl"></div>'),If=b('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),Rf=b('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),$f=b("<option> </option>"),Mf=b('<select id="sidebar-model" class="w-full rounded border border-brand-border bg-brand-dark/60 px-2 py-1 text-xs text-brand-text focus:border-brand-blue focus:outline-none"></select>'),Df=b('<input id="sidebar-model" type="text" placeholder="provider:model" class="w-full rounded border border-brand-border bg-brand-dark/60 px-2 py-1 text-xs text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/>'),Pf=b('<div class="flex items-center gap-3 pl-5 text-[10px] text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-visibility" class="border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue"/> Private</label> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-visibility" class="border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),Lf=b('<div class="space-y-1 py-0.5"><div class="flex items-center gap-1.5"><input id="sidebar-create-remote" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="sidebar-create-remote" class="cursor-pointer text-xs text-brand-text select-none"> </label></div> <!></div>'),Of=b('<div class="flex items-center gap-1.5 py-0.5"><input id="sidebar-git-init" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="sidebar-git-init" class="cursor-pointer text-xs text-brand-text select-none">Initialize Git repository</label></div>'),Nf=b('<form class="space-y-2.5 border-t border-brand-border/30 bg-brand-surface/30 p-3"><div><label class="mb-1 block text-[10px] font-bold tracking-wider text-brand-text-muted uppercase" for="sidebar-folder">Folder Path</label> <div class="relative"><input id="sidebar-folder" type="text" autocomplete="off" spellcheck="false" placeholder="e.g. ~/projects/my-new-app"/> <!></div> <!></div> <div><label class="mb-1 block text-[10px] font-bold tracking-wider text-brand-text-muted uppercase" for="sidebar-model">Model</label> <!></div> <!> <!> <button type="submit" class="w-full rounded bg-gradient-to-r from-brand-cyan to-brand-blue py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50">Create Session</button></form>'),Ff=b('<div class="border-b border-brand-border/50 bg-brand-surface/10"><button class="flex w-full items-center justify-between px-3 py-2 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/30"><span> </span></button> <!></div>'),Uf=b('<div class="p-4 text-center text-brand-text-muted"><div class="inline-block h-4 w-4 animate-spin rounded-full border-2 border-brand-text-muted border-t-transparent"></div> <span class="ml-2 text-sm">Loading sessions...</span></div>'),zf=b('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),Bf=b('<div class="flex items-center gap-1 rounded border border-red-500/30 bg-brand-surface-2/80 px-1 py-0.5"><button class="px-1.5 text-xs font-bold text-rose-400 hover:text-rose-300 focus:outline-none" title="Confirm Delete All">Delete All?</button> <button class="px-1.5 text-[10px] text-brand-text-muted hover:text-brand-text focus:outline-none" title="Cancel">✕</button></div>'),Hf=b('<button class="rounded px-2 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3/50 hover:text-rose-400 focus:outline-none" title="Delete all sessions in this folder">Delete All</button>'),Wf=b('<div class="mb-1.5 flex items-center justify-between"><button class="rounded px-2 py-1 text-left text-xs text-brand-blue transition-colors hover:bg-brand-surface-3/50 hover:opacity-90">+ New Session Here</button> <div class="flex-shrink-0"><!></div></div>'),jf=b('<span class="flex-shrink-0 text-brand-text-muted" title="Forked from the session above" aria-label="Forked session">↳</span>'),Gf=b('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),qf=b('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),Vf=b('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),Kf=b('<div class="flex items-center gap-1 rounded border border-red-500/30 bg-brand-surface-2/80 px-1 py-0.5"><button class="px-1.5 text-xs font-bold text-rose-400 hover:text-rose-300 focus:outline-none" title="Confirm Delete">❓</button> <button class="px-1.5 text-[10px] text-brand-text-muted hover:text-brand-text focus:outline-none" title="Cancel">✕</button></div>'),Yf=b('<button class="p-1 text-xs text-brand-text-muted transition-opacity hover:text-rose-400 focus:outline-none md:opacity-0 md:group-hover:opacity-100" title="Delete session">✕</button>'),Xf=b('<div class="flex-shrink-0"><!></div>'),Zf=b('<div><!> <a class="flex min-w-0 flex-1 items-center gap-2 text-left no-underline"><!> <div class="min-w-0 flex-1"><div class="truncate text-xs text-brand-text"> </div> <div class="text-xs text-brand-text-muted"> </div></div> <!></a> <!></div>'),Jf=b('<div class="px-3 pb-2"><!> <!></div>'),Qf=b('<div class="border-b border-brand-border/50"><button class="flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-brand-surface-3/50"><span>▶</span> <div class="min-w-0 flex-1"><div class="truncate text-sm font-medium text-brand-text"> </div> <div class="truncate text-[10px] text-brand-text-muted"> </div></div> <span class="text-xs text-brand-text-muted"> </span></button> <!></div>'),ep=b("<option> </option>"),tp=b('<select id="model-select" class="w-full rounded border border-brand-border bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text"></select>'),np=b('<input id="model-select" type="text" placeholder="provider:model" class="w-full rounded border border-brand-border bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text placeholder-brand-text-muted"/>'),rp=b('<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60" role="presentation"><div class="w-80 rounded-lg border border-brand-border bg-brand-surface-2 p-6" role="dialog" tabindex="-1"><h3 class="mb-4 text-sm font-bold text-brand-text">New Session</h3> <div class="mb-4"><span class="mb-1 block text-xs text-brand-text-muted">Folder</span> <div class="truncate rounded bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text"> </div></div> <div class="mb-4"><label class="mb-1 block text-xs text-brand-text-muted" for="model-select">Model</label> <!></div> <div class="flex justify-end gap-2"><button class="rounded bg-brand-surface-3 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button class="rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Create</button></div></div></div>'),sp=b('<div class="absolute right-0 bottom-0 left-0 flex items-center justify-between border-t border-red-500/30 bg-red-500/10 px-3 py-2 text-xs text-rose-400"><span class="truncate"> </span> <button class="ml-2 flex-shrink-0 text-rose-300 hover:text-rose-200">✕</button></div>'),op=b('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),ap=b('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),ip=b('<div class="flex items-center gap-3 pl-5 text-[10px] text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-modal-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Private</label> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-modal-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),lp=b('<div class="space-y-1"><div class="flex items-center gap-1.5"><input id="sidebar-modal-create-remote" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> <label for="sidebar-modal-create-remote" class="cursor-pointer text-xs text-brand-text select-none"> </label></div> <!></div>'),cp=b('<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/65 p-4" role="dialog" aria-modal="true"><div class="w-80 rounded-lg border border-brand-border bg-brand-surface-2 p-5 text-brand-text"><h3 class="mb-2 text-sm font-bold text-brand-text">Folder Already Exists</h3> <p class="mb-3 text-xs text-brand-text-muted">The folder <span class="font-mono text-[11px] break-all text-brand-text"> </span> already exists. Do you want to initialize a Git repository in it?</p> <div class="mb-4 flex flex-col gap-3"><div class="flex items-center gap-1.5"><input id="sidebar-modal-git-init" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue disabled:opacity-50"/> <label for="sidebar-modal-git-init" class="cursor-pointer text-xs text-brand-text select-none disabled:opacity-50">Initialize Git repository <!></label></div> <!></div> <div class="flex justify-end gap-2"><button type="button" class="rounded bg-brand-surface-3 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button type="button" class="rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Confirm & Create</button></div></div></div>'),dp=b('<div class="flex h-full flex-col"><div class="border-b border-brand-border/50 p-2"><div class="flex gap-1.5"><input type="text" placeholder="Filter sessions..." class="min-w-0 flex-1 rounded border border-brand-border bg-brand-surface-2 px-2 py-1.5 text-xs text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/> <button type="button" class="flex shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-1.5 py-1.5 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Refresh session list"><span>↻</span></button></div></div> <div class="flex-1 overflow-y-auto"><!> <!></div></div> <!> <!> <!>',1);function ga(n,e){hr(e,!0);const r=()=>Ne(Gr,"$readOnlySessionFolders",S),s=()=>Ne(Dr,"$sessionFolders",S),o=()=>Ne(rs,"$activeSessionInfo",S),a=()=>Ne(ns,"$isConnected",S),l=()=>Ne(Ss,"$isLoadingSession",S),d=()=>Ne(ko,"$isResyncing",S),_=()=>Ne(Pr,"$availableModels",S),v=()=>Ne(po,"$gitInitDefaultStore",S),g=()=>Ne(wo,"$sessionError",S),[S,F]=Lr(),z=[];let M=yr(e,"readOnly",3,!1),N=Z(()=>M()?r().folders:s().folders),$e=Z(()=>M()?r().loading:s().loading);function Q(){M()?Ea():Yr()}let Pe=Z(()=>o().sessionFile),Le=Z(a),Se=Z(l),ge=Z(d),xe=Z(()=>_().models),Ge=Hn({}),tt=Y(Hn({})),Ye=Y(null),Je=Y(null),Tt=Y(""),fe=Y(Hn([]));Bt(()=>{t(Le)&&(Q(),M()||(El(),Il()))});function Pt(A,$,X){if(!X)return!0;const ee=X.toLowerCase();return(A.name||"").toLowerCase().includes(ee)||A.firstMessage.toLowerCase().includes(ee)||$.toLowerCase().includes(ee)}Bt(()=>{const A=t(Tt),$=t(N);A?p(fe,$.map(X=>({...X,sessions:X.sessions.filter(ee=>Pt(ee,X.name,A))})).filter(X=>X.sessions.length>0),!0):(p(fe,$,!0),p(tt,{},!0))});function pt(A){return t(Tt)?t(tt)[A]!==void 0?t(tt)[A]:!0:!!Ge[A]}function lt(A){t(Tt)?t(tt)[A]=!pt(A):Ge[A]=!pt(A)}async function mt(A){try{t(Pe)===A&&(typeof window<"u"&&(window.location.hash=""),Wn()),await ro(A),t(Ye)===A&&p(Ye,null),Yr()}catch($){console.error("Failed to delete session:",$)}}async function st(A){try{const $=A.sessions.map(X=>X.path);t(Pe)&&$.includes(t(Pe))&&(typeof window<"u"&&(window.location.hash=""),Wn()),await Promise.all(A.sessions.map(X=>ro(X.path))),t(Je)===A.path&&p(Je,null),Yr()}catch($){console.error("Failed to delete all sessions of folder:",$)}}function gt(A){const $=new Map;for(const Fe of A)$.set(Fe.path,Fe);const X=new Map,ee=[];for(const Fe of A){const Qe=Fe.parentSessionPath;Qe&&$.has(Qe)&&Qe!==Fe.path?(X.has(Qe)||X.set(Qe,[]),X.get(Qe).push(Fe)):ee.push(Fe)}const ie=[],Et=new Set,Ct=(Fe,Qe)=>{if(!Et.has(Fe.path)){Et.add(Fe.path),ie.push({session:Fe,depth:Qe});for(const xt of X.get(Fe.path)??[])Ct(xt,Qe+1)}};for(const Fe of ee)Ct(Fe,0);for(const Fe of A)Et.has(Fe.path)||ie.push({session:Fe,depth:0});return ie}function It(A){t(Pe)===A&&!t(Se)&&!t(ge)||(kr(),ws(A))}let Rt=Y(!1),J=Y(""),Gt=Y(Hn([])),Ae=Y(!1),At=Y(null),Ht=Y(null),$t="",jt=Y(""),Oe=Y(!1),en=Y(null),wt=Y(!0),E=Y("private"),ve=Y(!1),L=Z(v);Bt(()=>{t(en)===null&&p(Oe,t(L),!0)});let ne=Y(Hn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),_e=Z(()=>t(ne).exists!==!0&&t(ne).matchingRule&&t(wt)),D=null;async function H(A,$=!1){if(D&&clearTimeout(D),A===$t&&!$)return;if($t=A,!A.trim()){p(ne,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const ee=async()=>{const ie=await bs("");p(Gt,ie||[],!0)};$?await ee():D=setTimeout(ee,300);return}const X=async()=>{const[ee,ie]=await Promise.all([$a(A),bs(A)]);p(Gt,ie||[],!0),ee?(p(ne,{exists:ee.exists,isGit:ee.isGit,resolvedPath:ee.resolvedPath,matchingRule:ee.matchingRule||null},!0),ee.exists||(p(Oe,t(en)!==null?t(en):t(L),!0),p(wt,!0),ee.matchingRule&&p(E,ee.matchingRule.visibility,!0))):p(ne,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};$?await X():D=setTimeout(X,300)}Bt(()=>{const A=t(J);H(A,!1)}),Bt(()=>{if(t(xe).length>0&&!t(jt)){const A=t(xe).find($=>$.isDefault);A?p(jt,`${A.provider}:${A.modelId}`):p(jt,`${t(xe)[0].provider}:${t(xe)[0].modelId}`)}});function Te(){if(t(J).trim())if(t(ne).exists===!0)p(Oe,!1),p(wt,!1),t(ne).matchingRule&&p(E,t(ne).matchingRule.visibility,!0),p(ve,!0);else{kr();const A=t(J).trim(),$=t(jt)||void 0,X=t(Oe),ee=t(ne).matchingRule?t(wt):void 0,ie=t(ne).matchingRule?t(E):void 0;p(J,""),p(Rt,!1),t(Pe)?(Wn(),setTimeout(()=>{Qn(A,$,X,ee,ie)},100)):Qn(A,$,X,ee,ie)}}function ct(){p(ve,!1),kr();const A=t(J).trim(),$=t(jt)||void 0,X=t(Oe),ee=t(ne).matchingRule?t(wt):void 0,ie=t(ne).matchingRule?t(E):void 0;p(J,""),p(Rt,!1),t(Pe)?(Wn(),setTimeout(()=>{Qn(A,$,X,ee,ie)},100)):Qn(A,$,X,ee,ie)}let ue=Y(Hn({open:!1,folderPath:"",selected:""}));function qe(A){const $=t(xe).find(X=>X.isDefault);p(ue,{open:!0,folderPath:A,selected:$?`${$.provider}:${$.modelId}`:""},!0)}function ke(){t(ue).open=!1}function Me(){if(!t(ue).open)return;kr();const A=t(ue).folderPath,$=t(ue).selected||void 0;ke(),t(Pe)?(Wn(),setTimeout(()=>{Qn(A,$)},100)):Qn(A,$)}function dt(A){const $=Date.now()-new Date(A).getTime(),X=Math.floor($/6e4);if(X<1)return"just now";if(X<60)return`${X}m ago`;const ee=Math.floor(X/60);return ee<24?`${ee}h ago`:`${Math.floor(ee/24)}d ago`}function Mt(A,$=40){return A.length>$?A.slice(0,$)+"...":A}var Lt=dp(),qt=Jt(Lt),Nt=u(qt),nt=u(Nt),We=u(nt);vt(We);var Qt=f(We,2),Ot=u(Qt);c(Qt),c(nt),c(Nt);var on=f(Nt,2),Sn=u(on);{var mn=A=>{var $=Ff(),X=u($),ee=u(X),ie=u(ee,!0);c(ee),c(X);var Et=f(X,2);{var Ct=Fe=>{var Qe=Nf(),xt=u(Qe),Kt=f(u(xt),2),Xe=u(Kt);vt(Xe),er(Xe,V=>p(At,V),()=>t(At));var R=f(Xe,2);{var O=V=>{var le=Cf();wn(le,21,()=>t(Gt),jn,(Ie,Ve)=>{var Ke=Ef(),rt=u(Ke,!0);c(Ke),U(()=>te(rt,t(Ve))),j("click",Ke,()=>{p(J,t(Ve),!0),H(t(Ve),!0),t(At)?.focus()}),h(Ie,Ke)}),c(le),h(V,le)};k(R,V=>{t(Ae)&&t(Gt).length>0&&V(O)})}c(Kt),er(Kt,V=>p(Ht,V),()=>t(Ht));var G=f(Kt,2);{var pe=V=>{var le=Rf(),Ie=f(u(le));{var Ve=Ke=>{var rt=If();h(Ke,rt)};k(Ie,Ke=>{t(ne).isGit&&Ke(Ve)})}c(le),h(V,le)};k(G,V=>{t(ne).exists===!0&&V(pe)})}c(xt);var Ee=f(xt,2),Ce=f(u(Ee),2);{var re=V=>{var le=Mf();wn(le,21,()=>t(xe),jn,(Ie,Ve)=>{var Ke=$f(),rt=u(Ke);c(Ke);var Dt={};U(()=>{te(rt,`${t(Ve).label??""}${t(Ve).isDefault?" (default)":""}`),Dt!==(Dt=`${t(Ve).provider}:${t(Ve).modelId}`)&&(Ke.value=Ke.__value=`${t(Ve).provider}:${t(Ve).modelId}`)}),h(Ie,Ke)}),c(le),Jr(le,()=>t(jt),Ie=>p(jt,Ie)),h(V,le)},ye=V=>{var le=Df();vt(le),Gn(le,()=>t(jt),Ie=>p(jt,Ie)),h(V,le)};k(Ce,V=>{t(xe).length>0?V(re):V(ye,-1)})}c(Ee);var ze=f(Ee,2);{var Ft=V=>{var le=Lf(),Ie=u(le),Ve=u(Ie);vt(Ve);var Ke=f(Ve,2),rt=u(Ke);c(Ke),c(Ie);var Dt=f(Ie,2);{var x=y=>{var P=Pf(),K=f(u(P),2),he=u(K);vt(he),he.value=he.__value="private",_t(),c(K);var ae=f(K,2),w=u(ae);vt(w),w.value=w.__value="public",_t(),c(ae),c(P),pr(z,[],he,()=>t(E),He=>p(E,He)),pr(z,[],w,()=>t(E),He=>p(E,He)),h(y,P)};k(Dt,y=>{t(wt)&&y(x)})}c(le),U(()=>te(rt,`Create remote ${t(ne).matchingRule.provider??""} repository`)),qn(Ve,()=>t(wt),y=>p(wt,y)),h(V,le)};k(ze,V=>{t(ne).exists!==!0&&t(ne).matchingRule&&V(Ft)})}var cn=f(ze,2);{var tn=V=>{var le=Of(),Ie=u(le);vt(Ie),_t(2),c(le),j("change",Ie,Ve=>{p(en,Ve.currentTarget.checked,!0)}),qn(Ie,()=>t(Oe),Ve=>p(Oe,Ve)),h(V,le)};k(cn,V=>{t(ne).exists!==!0&&(!t(ne).matchingRule||!t(wt))&&V(tn)})}var nn=f(cn,2);c(Qe),U(V=>{rn(Xe,1,`w-full rounded border px-2 py-1 text-xs text-brand-text placeholder-brand-text-muted transition-all duration-200 focus:outline-none ${t(_e)?"border-emerald-500/80 bg-emerald-500/10 focus:border-emerald-400 focus:ring-1 focus:ring-emerald-400/30":"border-brand-border bg-brand-dark/60 focus:border-brand-blue"}`),nn.disabled=V},[()=>!t(J).trim()]),lr("submit",Qe,V=>{V.preventDefault(),Te()}),lr("focus",Xe,()=>{p(Ae,!0),H(t(J),!0)}),lr("blur",Xe,V=>{t(Ht)&&t(Ht).contains(V.relatedTarget)||p(Ae,!1)}),j("keydown",Xe,V=>{V.key==="Escape"&&p(Ae,!1)}),Gn(Xe,()=>t(J),V=>p(J,V)),h(Fe,Qe)};k(Et,Fe=>{t(Rt)&&Fe(Ct)})}c($),U(()=>te(ie,t(Rt)?"▼ Close Create Session":"✚ Create New Session")),j("click",X,()=>p(Rt,!t(Rt))),h(A,$)};k(Sn,A=>{M()||A(mn)})}var Nn=f(Sn,2);{var Vt=A=>{var $=Uf();h(A,$)},an=A=>{var $=zf(),X=u($,!0);c($),U(()=>te(X,t(Tt)?"No sessions match your filter":"No sessions found")),h(A,$)},Xt=A=>{var $=sr(),X=Jt($);wn(X,17,()=>t(fe),ee=>ee.path,(ee,ie)=>{var Et=Qf(),Ct=u(Et),Fe=u(Ct),Qe=f(Fe,2),xt=u(Qe),Kt=u(xt,!0);c(xt);var Xe=f(xt,2),R=u(Xe,!0);c(Xe),c(Qe);var O=f(Qe,2),G=u(O,!0);c(O),c(Ct);var pe=f(Ct,2);{var Ee=re=>{var ye=Jf(),ze=u(ye);{var Ft=tn=>{var nn=Wf(),V=u(nn),le=f(V,2),Ie=u(le);{var Ve=rt=>{var Dt=Bf(),x=u(Dt),y=f(x,2);c(Dt),j("click",x,P=>{P.stopPropagation(),st(t(ie))}),j("click",y,P=>{P.stopPropagation(),p(Je,null)}),h(rt,Dt)},Ke=rt=>{var Dt=Hf();j("click",Dt,x=>{x.stopPropagation(),p(Je,t(ie).path,!0)}),h(rt,Dt)};k(Ie,rt=>{t(Je)===t(ie).path?rt(Ve):rt(Ke,-1)})}c(le),c(nn),j("click",V,()=>qe(t(ie).path)),h(tn,nn)};k(ze,tn=>{M()||tn(Ft)})}var cn=f(ze,2);wn(cn,17,()=>gt(t(ie).sessions),({session:tn,depth:nn})=>tn.path,(tn,nn)=>{let V=()=>t(nn).session,le=()=>t(nn).depth;var Ie=Zf(),Ve=u(Ie);{var Ke=ce=>{var Ze=jf();h(ce,Ze)};k(Ve,ce=>{le()>0&&ce(Ke)})}var rt=f(Ve,2),Dt=u(rt);{var x=ce=>{var Ze=Gf();h(ce,Ze)},y=ce=>{var Ze=qf();h(ce,Ze)};k(Dt,ce=>{V().isActive?ce(x):ce(y,-1)})}var P=f(Dt,2),K=u(P),he=u(K,!0);c(K);var ae=f(K,2),w=u(ae);c(ae),c(P);var He=f(P,2);{var je=ce=>{var Ze=Vf(),dn=u(Ze,!0);c(Ze),U(()=>te(dn,V().clientCount)),h(ce,Ze)};k(He,ce=>{V().clientCount>0&&ce(je)})}c(rt);var et=f(rt,2);{var Ut=ce=>{var Ze=Xf(),dn=u(Ze);{var Ln=at=>{var T=Kf(),i=u(T),m=f(i,2);c(T),j("click",i,I=>{I.stopPropagation(),mt(V().path)}),j("click",m,I=>{I.stopPropagation(),p(Ye,null)}),h(at,T)},_n=at=>{var T=Yf();j("click",T,i=>{i.stopPropagation(),p(Ye,V().path,!0)}),h(at,T)};k(dn,at=>{t(Ye)===V().path?at(Ln):at(_n,-1)})}c(Ze),h(ce,Ze)};k(et,ce=>{M()||ce(Ut)})}c(Ie),U((ce,Ze,dn)=>{fl(Ie,le()>0?`margin-left: ${le()*.85}rem`:""),rn(Ie,1,`group flex w-full items-center gap-2 rounded px-2 py-1.5 text-left transition-colors hover:bg-brand-surface-3/30 ${le()>0?"border-l border-brand-border/60 pl-2":""} ${t(Pe)===V().path?"bg-brand-surface-3":""}`),se(rt,"href",`#${ce??""}`),te(he,Ze),te(w,`${dn??""} · ${V().messageCount??""}
85
85
  msgs`)},[()=>encodeURIComponent(V().id),()=>V().name||Mt(V().firstMessage)||"Empty session",()=>dt(V().modified)]),j("click",rt,ce=>{ce.button===0&&!ce.ctrlKey&&!ce.metaKey&&!ce.altKey&&!ce.shiftKey&&(ce.preventDefault(),It(V().path))}),h(tn,Ie)}),c(ye),h(re,ye)},Ce=Z(()=>pt(t(ie).path));k(pe,re=>{t(Ce)&&re(Ee)})}c(Et),U(re=>{rn(Fe,1,`text-xs text-brand-text-muted transition-transform ${re??""}`),te(Kt,t(ie).name),te(R,t(ie).path),te(G,t(ie).sessions.length)},[()=>pt(t(ie).path)?"rotate-90":""]),j("click",Ct,()=>lt(t(ie).path)),h(ee,Et)}),h(A,$)};k(Nn,A=>{t($e)&&t(fe).length===0?A(Vt):t(fe).length===0?A(an,1):A(Xt,-1)})}c(on),c(qt);var Rn=f(qt,2);{var gn=A=>{var $=rp(),X=u($),ee=f(u(X),2),ie=f(u(ee),2),Et=u(ie,!0);c(ie),c(ee);var Ct=f(ee,2),Fe=f(u(Ct),2);{var Qe=O=>{var G=tp();wn(G,21,()=>t(xe),jn,(pe,Ee)=>{var Ce=ep(),re=u(Ce);c(Ce);var ye={};U(()=>{te(re,`${t(Ee).label??""}${t(Ee).isDefault?" (default)":""}`),ye!==(ye=`${t(Ee).provider}:${t(Ee).modelId}`)&&(Ce.value=Ce.__value=`${t(Ee).provider}:${t(Ee).modelId}`)}),h(pe,Ce)}),c(G),Jr(G,()=>t(ue).selected,pe=>t(ue).selected=pe),h(O,G)},xt=O=>{var G=np();vt(G),Gn(G,()=>t(ue).selected,pe=>t(ue).selected=pe),h(O,G)};k(Fe,O=>{t(xe).length>0?O(Qe):O(xt,-1)})}c(Ct);var Kt=f(Ct,2),Xe=u(Kt),R=f(Xe,2);c(Kt),c(X),c($),U(()=>te(Et,t(ue).folderPath)),j("click",$,ke),j("click",X,O=>O.stopPropagation()),j("click",Xe,ke),j("click",R,Me),h(A,$)};k(Rn,A=>{t(ue).open&&A(gn)})}var Fn=f(Rn,2);{var xn=A=>{var $=sp(),X=u($),ee=u(X,!0);c(X);var ie=f(X,2);c($),U(()=>te(ee,g())),j("click",ie,()=>kr()),h(A,$)};k(Fn,A=>{g()&&A(xn)})}var De=f(Fn,2);{var ot=A=>{var $=cp(),X=u($),ee=f(u(X),2),ie=f(u(ee)),Et=u(ie,!0);c(ie),_t(),c(ee);var Ct=f(ee,2),Fe=u(Ct),Qe=u(Fe);vt(Qe);var xt=f(Qe,2),Kt=f(u(xt));{var Xe=re=>{var ye=op();h(re,ye)},R=re=>{var ye=ap();h(re,ye)};k(Kt,re=>{t(ne).isGit?re(Xe):re(R,-1)})}c(xt),c(Fe);var O=f(Fe,2);{var G=re=>{var ye=lp(),ze=u(ye),Ft=u(ze);vt(Ft);var cn=f(Ft,2),tn=u(cn);c(cn),c(ze);var nn=f(ze,2);{var V=le=>{var Ie=ip(),Ve=f(u(Ie),2),Ke=u(Ve);vt(Ke),Ke.value=Ke.__value="private",_t(),c(Ve);var rt=f(Ve,2),Dt=u(rt);vt(Dt),Dt.value=Dt.__value="public",_t(),c(rt),c(Ie),pr(z,[],Ke,()=>t(E),x=>p(E,x)),pr(z,[],Dt,()=>t(E),x=>p(E,x)),h(le,Ie)};k(nn,le=>{t(wt)&&le(V)})}c(ye),U(()=>te(tn,`Create remote ${t(ne).matchingRule.provider??""} repository`)),qn(Ft,()=>t(wt),le=>p(wt,le)),h(re,ye)};k(O,re=>{t(ne).matchingRule&&re(G)})}c(Ct);var pe=f(Ct,2),Ee=u(pe),Ce=f(Ee,2);c(pe),c(X),c($),U(()=>{te(Et,t(J)),Qe.disabled=t(ne).isGit}),qn(Qe,()=>t(Oe),re=>p(Oe,re)),j("click",Ee,()=>p(ve,!1)),j("click",Ce,ct),h(A,$)};k(De,A=>{t(ve)&&A(ot)})}U(()=>{sl(We,t(Tt)),rn(Ot,1,cl(t($e)?"animate-spin":""))}),j("input",We,A=>p(Tt,A.currentTarget.value,!0)),j("click",Qt,()=>Q()),h(n,Lt),br(),F()}Tr(["input","click","keydown","change"]);var up=b(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60"><div class="mx-4 w-full max-w-md rounded-xl border border-brand-border bg-brand-surface-2 p-6 shadow-xl"><h2 class="mb-2 text-lg font-bold text-brand-text">Sudo password</h2> <p class="mb-3 text-sm text-brand-text-muted">This command needs your sudo password to run. It is used once and never
86
86
  stored.</p> <pre class="mb-4 overflow-x-auto rounded-lg bg-brand-surface-3 px-3 py-2 font-mono text-xs text-brand-text"> </pre> <input type="password" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" placeholder="Password" class="mb-4 w-full rounded-lg border border-brand-border bg-brand-surface-3 px-3 py-2.5 text-sm text-brand-text outline-none focus:border-brand-blue"/> <div class="flex gap-3"><button class="flex-1 rounded-lg bg-brand-surface-3 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button class="flex-1 rounded-lg bg-brand-blue px-4 py-2.5 text-sm text-brand-text transition-colors hover:opacity-90">Run</button></div></div></div>`);function fp(n,e){hr(e,!0);const r=()=>Ne(ai,"$sudoPrompt",s),[s,o]=Lr();let a=Z(r),l=Y(""),d=Y(null),_=Y(null);Bt(()=>{const N=t(a)?.promptId??null;N!==t(_)&&(p(_,N,!0),p(l,""),N&&queueMicrotask(()=>t(d)?.focus()))});function v(){t(a)&&(Ja(t(l)),p(l,""))}function g(){Qa(),p(l,"")}function S(N){N.key==="Enter"?(N.preventDefault(),v()):N.key==="Escape"&&(N.preventDefault(),g())}var F=sr(),z=Jt(F);{var M=N=>{var $e=up(),Q=u($e),Pe=f(u(Q),4),Le=u(Pe,!0);c(Pe);var Se=f(Pe,2);vt(Se),er(Se,tt=>p(d,tt),()=>t(d));var ge=f(Se,2),xe=u(ge),Ge=f(xe,2);c(ge),c(Q),c($e),U(()=>te(Le,t(a).command)),j("keydown",Se,S),Gn(Se,()=>t(l),tt=>p(l,tt)),j("click",xe,g),j("click",Ge,v),h(N,$e)};k(z,N=>{t(a)&&N(M)})}h(n,F),br(),o()}Tr(["keydown","click"]);function pp(n){return n.loading||n.resyncing||n.hasSessionHash}function hp(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!pp(n)}var bp=b('<div class="fixed inset-0 z-[100] flex items-center justify-center bg-brand-dark/60 backdrop-blur-sm"><div class="flex flex-col items-center gap-4"><div class="h-12 w-12 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <span class="text-lg font-bold text-brand-text">Creating session...</span></div></div>'),vp=b('<span class="text-lg font-bold text-brand-text">Connection Settings</span> <button class="rounded px-2 py-1 text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-2 hover:text-brand-blue">◀ Back</button>',1),mp=b('<button class="flex items-center gap-2 text-left" title="Show Main Screen / New Session"><img alt="Wherever" class="h-6 w-6"/> <span class="gradient-text text-lg font-bold">Wherever</span></button> <div class="flex items-center gap-2"><button class="flex items-center gap-1 rounded border border-brand-border px-1.5 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-2 hover:text-brand-text" title="Connection Settings">⚙️ Config</button> <button class="text-brand-text-muted hover:text-brand-text md:hidden">X</button></div>',1),gp=b('<div class="flex-1 overflow-y-auto"><!> <div class="mt-2 border-t border-brand-border p-4"><h3 class="mb-3 text-xs font-bold tracking-wider text-brand-text-muted uppercase">Server Control</h3> <div class="space-y-2"><button class="flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"><span>Refresh Session List</span> <span>🔄</span></button> <button class="flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"><span>Reconnect WebSocket</span> <span>🔌</span></button> <button class="flex w-full items-center justify-between rounded border border-red-500/30 bg-red-500/10 px-3 py-2 text-left text-sm text-rose-400 transition-colors hover:bg-red-500/20 hover:text-rose-300"><span>Disconnect Server</span> <span>🛑</span></button></div></div></div>'),xp=b('<div class="truncate text-xs text-brand-text-muted"> </div>'),_p=b('<div class="truncate text-xs text-brand-text-muted"> </div>'),yp=b('<div class="mt-2 space-y-1"><!> <!> <div class="pt-1.5"><button class="w-full rounded border border-brand-border bg-brand-surface-2 px-2 py-1 text-center text-xs text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Show Main Screen (Clear URL Hash)">Close Session</button></div></div>'),wp=b('<div class="mt-2 text-xs text-rose-400"> </div>'),kp=b('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3/50 hover:text-brand-text" title="View read-only sessions (e.g. autonomous agent fleets)"><span>👁️</span> <span>Read-only sessions</span> <span class="ml-auto">→</span></button>'),Sp=b('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/50" title="Back to your sessions"><span>←</span> <span>Back to sessions</span></button>'),Tp=b('<div class="border-b border-brand-border p-4"><div class="flex items-center gap-2"><div></div> <span> </span> <span class="ml-auto font-mono text-xs text-brand-text-muted" title="App build version"> </span></div> <!> <!></div> <div class="border-b border-brand-border/50 px-2 py-1.5"><!></div> <div class="flex-1 overflow-hidden"><!></div>',1),Ap=b('<button type="button" class="flex flex-shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-2.5 py-1.5 text-sm text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Search the web" aria-label="Search the web">🔍</button>'),Ep=b('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Cp=b('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),Ip=b('<span class="text-sm text-brand-text-muted">Not connected</span>'),Rp=b('<div class="flex min-w-0 items-center gap-2"><!></div>'),$p=b('<div class="flex min-w-0 items-center gap-1.5 text-xs text-brand-text-muted"><span class="flex-shrink-0">📁</span> <span class="truncate"> </span></div>'),Mp=b("<option> </option>"),Dp=b('<select class="max-w-48 truncate rounded border border-brand-border bg-brand-surface-2 px-1.5 py-0.5 text-brand-text focus:border-brand-blue focus:outline-none"></select>'),Pp=b('<span class="truncate text-brand-text-muted"> </span>'),Lp=b('<div class="flex min-w-0 items-center gap-1.5 text-xs"><span class="relative flex flex-shrink-0 items-center justify-center text-sm"><span>🤖</span> <span></span></span> <!></div>'),Op=b('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),Np=b('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),Fp=b('<div class="border border-red-500/30 bg-red-500/10 px-4 py-2 text-center text-sm text-rose-400">Your session was interrupted — another client took over.</div>'),Up=b('<div><span class="min-w-0 flex-1 break-words whitespace-pre-wrap"> </span> <button aria-label="Dismiss notice" class="flex-shrink-0 opacity-80 hover:opacity-100">X</button></div>'),zp=b('<button class="flex-shrink-0 rounded-md border border-yellow-500/40 bg-yellow-500/20 px-3 py-1 text-xs font-medium text-yellow-300 transition-colors hover:bg-yellow-500/30">Continue anyway</button>'),Bp=b('<div class="flex items-center justify-between gap-3 border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-sm text-yellow-400"><span class="min-w-0 flex-1 break-words">⚠️ Another client is active in this folder. <!></span> <!></div>'),Hp=b('<div class="flex items-start justify-between gap-2 border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm text-rose-400"><span class="max-h-24 min-w-0 flex-1 overflow-y-auto break-words whitespace-pre-wrap"> </span> <button aria-label="Dismiss error" class="flex-shrink-0 text-rose-300 hover:text-rose-200">X</button></div>'),Wp=b('<div class="border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-center text-sm text-yellow-400">Read-only: this session cannot be driven from here</div>'),jp=b('<div class="border-t border-brand-border bg-brand-surface px-4 py-3 text-center text-xs text-brand-text-muted">👁️ Read-only session, observing only, no input.</div>'),Gp=b('<div class="flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted"><span class="h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span> <span>Reconnecting and syncing session...</span></div>'),qp=b('<div class="flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted"><span class="h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span> <span>Preparing the session agent...</span></div>'),Vp=b("<!> <!>",1),Kp=b('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),Yp=b('<!> <!> <div class="fixed inset-0 flex overflow-hidden overscroll-none bg-brand-dark text-brand-text"><div><div class="border-b border-brand-border bg-brand-surface-2/20 p-4"><div class="flex items-center justify-between"><!></div></div> <!></div> <div class="flex min-w-0 flex-1 flex-col"><div class="app-chrome flex items-center gap-3 border-b border-brand-border bg-brand-surface p-3"><button class="p-1 text-brand-text-muted hover:text-brand-text md:hidden">=</button> <!> <!> <!> <!></div> <!> <!> <!> <!> <!> <!> <!></div> <!> <!></div>',1);function sh(n,e){hr(e,!0);const r=()=>Ne(ns,"$isConnected",Q),s=()=>Ne(ko,"$isResyncing",Q),o=()=>Ne(li,"$isAgentPending",Q),a=()=>Ne(Ss,"$isLoadingSession",Q),l=()=>Ne(ri,"$isInterrupted",Q),d=()=>Ne(wo,"$sessionError",Q),_=()=>Ne(oi,"$sessionNotice",Q),v=()=>Ne(ni,"$folderConflict",Q),g=()=>Ne(ks,"$isReadOnly",Q),S=()=>Ne(rs,"$activeSessionInfo",Q),F=()=>Ne(Wt,"$piState",Q),z=()=>Ne(Pr,"$availableModels",Q),M=()=>Ne(ii,"$isCreatingSession",Q),N=()=>Ne(ho,"$searchFolderStore",Q),$e=()=>Ne(Ra,"$searchDefaultModelStore",Q),[Q,Pe]=Lr();let Le=Y(!1),Se=Y("main"),ge=Y(!1),xe;es(()=>{setTimeout(()=>wr(),200);const R=()=>{if(t(fe)){const Ce=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";Ce&&Ce!==t(Ht)?ws(Ce):!Ce&&t(Ht)&&Wn()}};window.addEventListener("hashchange",R);let O=null;const G=8e3,pe=()=>{if(document.visibilityState==="hidden"){if(Ua())return;O&&clearTimeout(O),O=setTimeout(()=>{O=null,document.visibilityState==="hidden"&&t(fe)&&Na()},G)}else _o(),O&&(clearTimeout(O),O=null),t(fe)||(eo()?Qs():wr())},Ee=Ce=>{O&&(clearTimeout(O),O=null),document.visibilityState!=="hidden"&&!t(fe)&&(eo()?Qs():wr())};return document.addEventListener("visibilitychange",pe),window.addEventListener("pageshow",Ee),()=>{window.removeEventListener("hashchange",R),document.removeEventListener("visibilitychange",pe),window.removeEventListener("pageshow",Ee),O&&clearTimeout(O)}});function Ge(){wr()}function tt(){Wn(),Qr()}function Ye(){Qr(),setTimeout(()=>wr(),100)}function Je(){Yr()}function Tt(){typeof window<"u"&&(window.location.hash=""),Wn(),p(Le,!1)}let fe=Z(r),Pt=Z(s),pt=Z(o),lt=Z(a),mt=Z(l),st=Z(d),gt=Z(_),It=Z(v),Rt=Z(g),J=Z(S),Gt=Z(F),Ae=Z(()=>z().models),At=Y(!1),Ht=Z(()=>t(J).sessionId);Bt(()=>{typeof window<"u"&&t(fe)&&(t(Ht)?(window.location.hash=encodeURIComponent(t(Ht)),p(At,!0)):t(At)&&(p(At,!1),window.location.hash&&(window.location.hash="")))});let $t=null;Bt(()=>{if(!t(fe)||typeof window>"u"||!window.location.hash)return;const R=decodeURIComponent(window.location.hash.slice(1));R&&(t(Ht)===R||t(lt)||t(Pt)||$t||($t=setTimeout(()=>{$t=null,!(t(Ht)===R||t(lt)||t(Pt))&&ja(R)},300)))}),Bt(()=>{t(fe)||p(At,!1)}),Bt(()=>{(t(Ht)||t(lt)||t(Pt))&&p(Le,!1)});let jt=Z(M),Oe=Z(N),en=Y(void 0),wt=Z(()=>hp({connected:t(fe),searchConfigured:!!t(Oe),hasSession:!!t(J).sessionFile,loading:t(lt),resyncing:t(Pt),hasSessionHash:typeof window<"u"&&!!window.location.hash})),E=Z(()=>t(Ae).map(R=>({value:`${R.provider}:${R.modelId}`,label:`${R.label}${R.isDefault?" (default)":""}`}))),ve=Z($e),L=Y("");Bt(()=>{if(t(E).length===0||t(E).some(pe=>pe.value===t(L)))return;const O=t(E).find(pe=>pe.value===t(ve)),G=t(Ae).find(pe=>pe.isDefault);p(L,O?O.value:G?`${G.provider}:${G.modelId}`:t(E)[0].value,!0)});let ne=Y(!1);Bt(()=>{t(wt)&&!t(ne)&&t(en)&&(p(ne,!0),t(en).focusInput())});function _e(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),Wn(),t(en)?.focusInput()}var D=Yp(),H=Jt(D);xl(H,{title:"Wherever",description:"Create & maintain apps from wherever"});var Te=f(H,2);{var ct=R=>{var O=bp();h(R,O)};k(Te,R=>{t(jt)&&R(ct)})}var ue=f(Te,2),qe=u(ue),ke=u(qe),Me=u(ke),dt=u(Me);{var Mt=R=>{var O=vp(),G=f(Jt(O),2);j("click",G,()=>p(ge,!1)),h(R,O)},Lt=R=>{var O=mp(),G=Jt(O),pe=u(G);_t(2),c(G);var Ee=f(G,2),Ce=u(Ee),re=f(Ce,2);c(Ee),U(ye=>se(pe,"src",ye),[()=>Mr("/logo.svg")]),j("click",G,Tt),j("click",Ce,()=>p(ge,!0)),j("click",re,()=>p(Le,!1)),h(R,O)};k(dt,R=>{t(ge)?R(Mt):R(Lt,-1)})}c(Me),c(ke);var qt=f(ke,2);{var Nt=R=>{var O=gp(),G=u(O);{let ze=Z(()=>(t(Gt).connected,"localhost"));Kl(G,{get host(){return t(ze)},port:31415,token:"",onConnected:Ge})}var pe=f(G,2),Ee=f(u(pe),2),Ce=u(Ee),re=f(Ce,2),ye=f(re,2);c(Ee),c(pe),c(O),j("click",Ce,Je),j("click",re,Ye),j("click",ye,tt),h(R,O)},nt=R=>{var O=Tp(),G=Jt(O),pe=u(G),Ee=u(pe),Ce=f(Ee,2),re=u(Ce,!0);c(Ce);var ye=f(Ce,2),ze=u(ye);c(ye),c(pe);var Ft=f(pe,2);{var cn=y=>{var P=yp(),K=u(P);{var he=et=>{var Ut=xp(),ce=u(Ut);c(Ut),U(Ze=>{se(Ut,"title",t(J).cwd),te(ce,`📁 ${Ze??""}`)},[()=>t(J).cwd.split("/").pop()||t(J).cwd]),h(et,Ut)};k(K,et=>{t(J).cwd&&et(he)})}var ae=f(K,2);{var w=et=>{var Ut=_p(),ce=u(Ut);c(Ut),U(()=>{se(Ut,"title",t(J).model),te(ce,`🤖 ${t(J).model??""}`)}),h(et,Ut)};k(ae,et=>{t(J).model&&et(w)})}var He=f(ae,2),je=u(He);c(He),c(P),j("click",je,Tt),h(y,P)};k(Ft,y=>{t(J).sessionFile&&y(cn)})}var tn=f(Ft,2);{var nn=y=>{var P=wp(),K=u(P,!0);c(P),U(()=>te(K,t(Gt).error)),h(y,P)};k(tn,y=>{t(Gt).error&&!t(fe)&&y(nn)})}c(G);var V=f(G,2),le=u(V);{var Ie=y=>{var P=kp();j("click",P,()=>{p(Se,"readonly"),Ea()}),h(y,P)},Ve=y=>{var P=Sp();j("click",P,()=>p(Se,"main")),h(y,P)};k(le,y=>{t(Se)==="main"?y(Ie):y(Ve,-1)})}c(V);var Ke=f(V,2),rt=u(Ke);{var Dt=y=>{ga(y,{readOnly:!0})},x=y=>{ga(y,{})};k(rt,y=>{t(Se)==="readonly"?y(Dt):y(x,-1)})}c(Ke),U(()=>{rn(Ee,1,`h-2.5 w-2.5 rounded-full ${t(fe)?"bg-emerald-500":"bg-rose-500"}`),rn(Ce,1,`text-sm ${t(fe)?"text-emerald-400":"text-rose-400"}`),te(re,t(fe)?"Connected":"Disconnected"),te(ze,`v${ka}`)}),h(R,O)};k(qt,R=>{t(ge)?R(Nt):R(nt,-1)})}c(qe);var We=f(qe,2),Qt=u(We),Ot=u(Qt),on=f(Ot,2);{var Sn=R=>{var O=Ap();j("click",O,_e),h(R,O)};k(on,R=>{t(fe)&&t(Oe)&&t(J).sessionFile&&R(Sn)})}var mn=f(on,2);{var Nn=R=>{var O=Rp(),G=u(O);{var pe=re=>{var ye=Ep();h(re,ye)},Ee=re=>{var ye=Cp();h(re,ye)},Ce=re=>{var ye=Ip();h(re,ye)};k(G,re=>{t(fe)&&t(wt)?re(pe):t(fe)?re(Ee,1):re(Ce,-1)})}c(O),h(R,O)};k(mn,R=>{(!t(fe)||!t(J).sessionFile)&&R(Nn)})}var Vt=f(mn,2);{var an=R=>{var O=Op(),G=u(O);{var pe=re=>{var ye=$p(),ze=f(u(ye),2),Ft=u(ze,!0);c(ze),c(ye),U(cn=>{se(ze,"title",t(J).cwd),te(Ft,cn)},[()=>t(J).cwd.split("/").pop()||t(J).cwd]),h(re,ye)};k(G,re=>{t(J).cwd&&re(pe)})}var Ee=f(G,2);{var Ce=re=>{var ye=Lp(),ze=u(ye),Ft=f(u(ze),2);c(ze);var cn=f(ze,2);{var tn=V=>{var le=Dp();wn(le,21,()=>t(Ae),jn,(Ve,Ke)=>{var rt=Mp(),Dt=u(rt,!0);c(rt);var x={};U(()=>{te(Dt,t(Ke).label),x!==(x=`${t(Ke).provider}:${t(Ke).modelId}`)&&(rt.value=rt.__value=`${t(Ke).provider}:${t(Ke).modelId}`)}),h(Ve,rt)}),c(le);var Ie;Ta(le),U(()=>{Ie!==(Ie=t(J).model)&&(le.value=(le.__value=t(J).model)??"",uo(le,t(J).model))}),j("input",le,Ve=>ei(Ve.currentTarget.value)),h(V,le)},nn=V=>{var le=Pp(),Ie=u(le,!0);c(le),U(()=>{se(le,"title",t(J).model),te(Ie,t(J).model)}),h(V,le)};k(cn,V=>{t(Ae).length>0&&!t(Rt)?V(tn):V(nn,-1)})}c(ye),U(()=>{rn(Ft,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(Gt).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),se(Ft,"title",t(Gt).isStreaming?"Agent working...":"Ready")}),h(re,ye)};k(Ee,re=>{t(J).model&&re(Ce)})}c(O),h(R,O)};k(Vt,R=>{t(J).sessionFile&&R(an)})}var Xt=f(Vt,2);{var Rn=R=>{var O=Np();h(R,O)};k(Xt,R=>{t(Rt)&&R(Rn)})}c(Qt);var gn=f(Qt,2);{var Fn=R=>{var O=Fp();h(R,O)};k(gn,R=>{t(mt)&&R(Fn)})}var xn=f(gn,2);{var De=R=>{var O=Up(),G=u(O),pe=u(G,!0);c(G);var Ee=f(G,2);c(O),U(()=>{rn(O,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(gt).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),te(pe,t(gt).message)}),j("click",Ee,()=>Za()),h(R,O)};k(xn,R=>{t(gt)&&R(De)})}var ot=f(xn,2);{var A=R=>{var O=Bp(),G=u(O),pe=f(u(G));{var Ee=ze=>{var Ft=Cn("You are both working in it — changes may conflict.");h(ze,Ft)},Ce=ze=>{var Ft=Cn("You are observing (read-only) to avoid clashing.");h(ze,Ft)};k(pe,ze=>{t(It).continued?ze(Ee):ze(Ce,-1)})}c(G);var re=f(G,2);{var ye=ze=>{var Ft=zp();j("click",Ft,()=>Ka()),h(ze,Ft)};k(re,ze=>{t(It).continued||ze(ye)})}c(O),h(R,O)};k(ot,R=>{t(It)?.active&&R(A)})}var $=f(ot,2);{var X=R=>{var O=Hp(),G=u(O),pe=u(G,!0);c(G);var Ee=f(G,2);c(O),U(()=>te(pe,t(st))),j("click",Ee,()=>kr()),h(R,O)};k($,R=>{t(st)&&R(X)})}var ee=f($,2);{var ie=R=>{var O=Wp();h(R,O)};k(ee,R=>{t(Rt)&&!t(mt)&&R(ie)})}var Et=f(ee,2);er(Zu(Et,{onMessageSent:()=>{}}),R=>xe=R,()=>xe);var Ct=f(Et,2);{var Fe=R=>{var O=jp();h(R,O)},Qe=R=>{var O=Vp(),G=Jt(O);{var pe=re=>{var ye=Gp();h(re,ye)},Ee=re=>{var ye=qp();h(re,ye)};k(G,re=>{t(J).sessionFile&&(t(Pt)||!t(fe))?re(pe):t(J).sessionFile&&t(pt)&&re(Ee,1)})}var Ce=f(G,2);{let re=Z(()=>!!t(Oe)),ye=Z(()=>t(wt)?!t(fe):!t(fe)||t(Rt)||!t(J).sessionFile||t(Pt)||t(pt));er(Af(Ce,{get searchMode(){return t(wt)},get searchConfigured(){return t(re)},get searchModels(){return t(E)},onSubmit:ze=>qa(ze,t(L)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(ye)},onSend:()=>xe?.forceScrollToBottom(),get searchModel(){return t(L)},set searchModel(ze){p(L,ze,!0)}}),ze=>p(en,ze,!0),()=>t(en))}h(R,O)};k(Ct,R=>{t(Rt)&&t(J).sessionFile?R(Fe):R(Qe,-1)})}c(We);var xt=f(We,2);fp(xt,{});var Kt=f(xt,2);{var Xe=R=>{var O=Kp();j("click",O,()=>p(Le,!1)),h(R,O)};k(Kt,R=>{t(Le)&&R(Xe)})}c(ue),U(()=>rn(qe,1,`app-chrome ${t(Le)?"translate-x-0":"-translate-x-full"} fixed z-20 flex h-full w-72 flex-col border-r border-brand-border bg-brand-surface transition-transform duration-200 md:relative md:translate-x-0`)),j("click",Ot,()=>p(Le,!t(Le))),h(n,D),br(),Pe()}Tr(["click","input"]);export{sh as component,rh as universal};
87
- //# sourceMappingURL=2.q7p9NmjW.js.map
87
+ //# sourceMappingURL=2.DWP05EYK.js.map