wherever-dev 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/_app/immutable/chunks/{CKf1ZANJ.js → BpNdwm2g.js} +2 -2
- package/public/_app/immutable/chunks/{CKf1ZANJ.js.map → BpNdwm2g.js.map} +1 -1
- package/public/_app/immutable/chunks/{TfH41jhG.js → CFZwc5OM.js} +2 -2
- package/public/_app/immutable/chunks/{TfH41jhG.js.map → CFZwc5OM.js.map} +1 -1
- package/public/_app/immutable/chunks/{ZZTQFDzN.js → Ddnp1HFv.js} +2 -2
- package/public/_app/immutable/chunks/{ZZTQFDzN.js.map → Ddnp1HFv.js.map} +1 -1
- package/public/_app/immutable/entry/{app.CCKiLbc3.js → app.B0UlJ8C-.js} +3 -3
- package/public/_app/immutable/entry/{app.CCKiLbc3.js.map → app.B0UlJ8C-.js.map} +1 -1
- package/public/_app/immutable/entry/start.CmL4cMnM.js +2 -0
- package/public/_app/immutable/entry/start.CmL4cMnM.js.map +1 -0
- package/public/_app/immutable/nodes/{0.Icrdc4FQ.js → 0.Cvg2hYtP.js} +2 -2
- package/public/_app/immutable/nodes/{0.Icrdc4FQ.js.map → 0.Cvg2hYtP.js.map} +1 -1
- package/public/_app/immutable/nodes/{1.CdQkbXln.js → 1.DLtAtyAb.js} +2 -2
- package/public/_app/immutable/nodes/{1.CdQkbXln.js.map → 1.DLtAtyAb.js.map} +1 -1
- package/public/_app/immutable/nodes/{2.bgw2Mkz_.js → 2.riO6dO81.js} +19 -19
- package/public/_app/immutable/nodes/2.riO6dO81.js.map +1 -0
- package/public/_app/version.json +1 -1
- package/public/index.html +10 -10
- package/public/service-worker.js +1 -1
- package/public/_app/immutable/entry/start.DvmWDdRo.js +0 -2
- package/public/_app/immutable/entry/start.DvmWDdRo.js.map +0 -1
- package/public/_app/immutable/nodes/2.bgw2Mkz_.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as ms,a as h,c as jn,g,d as dr,e as H,s as Z,f as cr,t as An}from"../chunks/vMsF8lo6.js";import{ar as En,b2 as rs,al as Sr,be as B,ap as yo,M as mi,aS as gi,aq as Ms,d as ta,am as Ds,at as xi,n as _i,a0 as yi,u as wi,t as ki,a1 as Si,V as Ti,W as Ai,H as Ei,b3 as wo,C as ko,aE as ls,a2 as ar,ac as Ci,az as Ii,aZ as Ri,ay as na,bd as ra,bf as $i,bg as Ks,aU as Ys,aQ as So,aP as er,aM as tr,af as Nt,b6 as f,ai as t,a5 as Mi,bh as K,$ as Di,bl as On,ah as Kn,a8 as zt,aK as qr,a_ as p,X as u,aV as d,aI as et,b9 as G,aO as $n,bi as Dt,bj as Pi,aT as Li}from"../chunks/CEg8tgYI.js";import{i as E,s as _r,a as Me,p as vr}from"../chunks/MtE7VtNZ.js";import{a as Oi,b as me,r as at,c as sa,e as gn,i as Dn,d as Ni}from"../chunks/ZZTQFDzN.js";import{_ as Fi,b as Vn}from"../chunks/ylfInSZr.js";import{v as oa}from"../chunks/CKf1ZANJ.js";import{p as Ui}from"../chunks/TfH41jhG.js";function To(n,e,r=!1,s=!1,o=!1,a=!1){var l=n,c="";if(r){var _=n;En&&(l=rs(Sr(_)))}B(()=>{var m=mi;if(c===(c=e()??"")){En&&yo();return}if(r&&!En){m.nodes=null,_.innerHTML=c,c!==""&&ms(Sr(_),_.lastChild);return}if(m.nodes!==null&&(gi(m.nodes.start,m.nodes.end),m.nodes=null),c!==""){if(En){Ms.data;for(var x=yo(),I=x;x!==null&&(x.nodeType!==ta||x.data!=="");)I=x,x=Ds(x);if(x===null)throw xi(),_i;ms(Ms,I),l=rs(x);return}var P=s?wi:o?ki:void 0,O=yi(s?"svg":o?"math":"template",P);O.innerHTML=c;var k=s||o?O:O.content;if(ms(Sr(k),k.lastChild),s||o)for(;Sr(k);)l.before(Sr(k));else l.before(k)}})}function zi(n,e){let r=null,s=En;var o;if(En){r=Ms;for(var a=Sr(document.head);a!==null&&(a.nodeType!==ta||a.data!==n);)a=Ds(a);if(a===null)wo(!1);else{var l=Ds(a);a.remove(),rs(l)}}En||(o=document.head.appendChild(Si()));try{Ti(()=>{var c=Ai(()=>e(o));c.f|=Ei})}finally{s&&(wo(!0),rs(r))}}function aa(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=aa(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function Bi(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=aa(n))&&(s&&(s+=" "),s+=e);return s}function Hi(n){return typeof n=="object"?Bi(n):n??""}function Wi(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function Jt(n,e,r,s,o,a){var l=n[ko];if(En||l!==r||l===void 0){var c=Wi(r);(!En||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[ko]=r}return a}function Zs(n,e,r=!1){if(n.multiple){if(e==null)return;if(!Ii(e))return Ri();for(var s of n.options)s.selected=e.includes(zr(s));return}for(s of n.options){var o=zr(s);if(na(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function ia(n){var e=new MutationObserver(()=>{Zs(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),ra(()=>{e.disconnect()})}function Gr(n,e,r=e){var s=new WeakSet,o=!0;ls(n,"change",a=>{var l=a?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(l),zr);else{var _=n.querySelector(l)??n.querySelector("option:not([disabled])");c=_&&zr(_)}r(c),n.__value=c,ar!==null&&s.add(ar)}),Ci(()=>{var a=e();if(n===document.activeElement){var l=ar;if(s.has(l))return}if(Zs(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=zr(c),r(a))}n.__value=a,o=!1}),ia(n)}function zr(n){return"__value"in n?n.__value:n.value}function Pn(n,e,r=e){var s=new WeakSet;ls(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=xs(n)?_s(a):a,r(a),ar!==null&&s.add(ar),await $i(),a!==(a=e())){var l=n.selectionStart,c=n.selectionEnd,_=n.value.length;if(n.value=a??"",c!==null){var m=n.value.length;l===c&&c===_&&m>_?(n.selectionStart=m,n.selectionEnd=m):(n.selectionStart=l,n.selectionEnd=Math.min(c,m))}}}),(En&&n.defaultValue!==n.value||Ks(e)==null&&n.value)&&(r(xs(n)?_s(n.value):n.value),ar!==null&&s.add(ar)),Ys(()=>{var o=e();if(n===document.activeElement){var a=ar;if(s.has(a))return}xs(n)&&o===_s(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const gs=new Set;function lr(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",l=n;let c=!1;if(e!==null)for(var _ of e)l=l[_]??=[];l.push(r),ls(r,"change",()=>{var m=r.__value;a&&(m=Ao(l,m,r.checked)),o(m)},()=>o(a?[]:null)),Ys(()=>{var m=s();if(En&&r.defaultChecked!==r.checked){c=!0;return}a?(m=m||[],r.checked=m.includes(r.__value)):r.checked=na(r.__value,m)}),ra(()=>{var m=l.indexOf(r);m!==-1&&l.splice(m,1)}),gs.has(l)||(gs.add(l),So(()=>{l.sort((m,x)=>m.compareDocumentPosition(x)===4?-1:1),gs.delete(l)})),So(()=>{if(c){var m;if(a)m=Ao(l,m,r.checked);else{var x=l.find(I=>I.checked);m=x?.__value}o(m)}})}function Ln(n,e,r=e){ls(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(En&&n.defaultChecked!==n.checked||Ks(e)==null)&&r(n.checked),Ys(()=>{var s=e();n.checked=!!s})}function Ao(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 xs(n){var e=n.type;return e==="number"||e==="range"}function _s(n){return n===""?null:+n}const Gi=!1,ji=!0,fp=Object.freeze(Object.defineProperty({__proto__:null,prerender:ji,ssr:Gi},Symbol.toStringTag,{value:"Module"})),ys="Wherever",qi="Create & maintain apps from wherever with a beautiful remote workspace.",ws="https://localhost",Vi="#000000",Ki="black-translucent";function Ar(n,e){return Oi(n)}var Yi=g('<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 Zi(n,e){er(e,!0);const r=ws.endsWith("/")?ws.slice(0,-1):ws,s=r+"/preview.png";let o=K(()=>e.home||!1),a=K(()=>({type:e.type||"website",title:e.title||ys,description:e.description||qi,image:e.image||s,url:`${r}${Ui.url.pathname}`}));zi("13n5pl5",l=>{var c=Yi(),_=Nt(c),m=f(_,2),x=f(m,2);{var I=He=>{var lt=jn(),kt=Nt(lt);E(kt,tt=>{}),h(He,lt)};E(x,He=>{t(o)&&He(I)})}var P=f(x,2),O=f(P,2),k=f(O,2),q=f(k,2),te=f(q,2),de=f(te,4),re=f(de,2),je=f(re,2),_e=f(je,2),$e=f(_e,2),fe=f($e,2),Le=f(fe,2),Ee=f(Le,2),Et=f(Ee,2),it=f(Et,4),ue=f(it,4),Ve=f(ue,2),Bt=f(Ve,2);B((He,lt,kt,tt)=>{me(_,"content",t(a).title),me(m,"content",t(a).description),me(P,"content",t(a).type),me(O,"content",t(a).url),me(k,"content",t(a).title),me(q,"content",t(a).description),me(te,"content",t(a).image),me(de,"content",t(a).url),me(re,"content",t(a).title),me(je,"content",t(a).description),me(_e,"content",t(a).image),me($e,"href",He),me(fe,"href",lt),me(Le,"href",kt),me(Ee,"href",tt),me(Et,"content",Vi),me(it,"content",ys),me(ue,"content",Ki),me(Ve,"content",ys),me(Bt,"content",oa)},[()=>Ar("/pwa/favicon.png"),()=>Ar("/pwa/favicon.ico"),()=>Ar("/pwa/apple-touch-icon.png"),()=>Ar("/pwa/manifest.webmanifest")]),Mi(()=>{Di.title=t(a).title??""}),h(l,c)}),tr()}let Ir=null;function Xi(){if(typeof window>"u")return null;try{if(!Ir){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;Ir=new n}return Ir.state==="suspended"&&Ir.resume().catch(()=>{}),Ir}catch{return null}}function Eo(n,e,r,s,o){const a=n.createOscillator(),l=n.createGain();a.type="sine",a.frequency.value=e;const c=.015;l.gain.setValueAtTime(1e-4,r),l.gain.exponentialRampToValueAtTime(o,r+c),l.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(l),l.connect(n.destination),a.start(r),a.stop(r+s+.02)}const Co=new Map;function Qi(n){if(typeof Audio>"u")return!1;try{let e=Co.get(n);e||(e=new Audio(n),e.preload="auto",Co.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 la(n){if(n&&n.trim()&&Qi(n.trim()))return;const e=Xi();if(e)try{const r=e.currentTime;Eo(e,1046.5,r,.16,.12),Eo(e,1396.9,r+.13,.22,.12)}catch{}}function es(){}function Ji(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function el(n,...e){if(n==null)return es;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Vt(n){let e;return el(n,r=>e=r)(),e}var wr=[];function tl(n,e=es){let r;const s=new Set;function o(c){if(Ji(n,c)&&(n=c,r)){const _=!wr.length;for(const m of s)m[1](),wr.push(m,n);if(_){for(let m=0;m<wr.length;m+=2)wr[m][0](wr[m+1]);wr.length=0}}}function a(c){o(c(n))}function l(c,_=es){const m=[c,_];return s.add(m),s.size===1&&(r=e(o)||es),c(n),()=>{s.delete(m),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:l}}const ks={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,conflict: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};class Gn{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;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=tl({...ks,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(O=>r?{...O,connecting:!0,error:null}:{...ks,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}`,c=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!c){this.stateStore.update(O=>({...O,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const O=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=O?new c(l,O):new c(l)}catch(O){this.stateStore.update(k=>({...k,connecting:!1,error:`Failed to connect: ${O}`})),this.scheduleReconnect();return}const _=this.ws,m=()=>{if(this.ws!==_)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(de=>({...de,connected:!0,connecting:!1,error:null}));const O=Vt(this.stateStore),k=this.resumeSessionFile??O.activeSessionFile,q=this.resumeSessionFile!=null?this.resumeCwd:O.activeCwd??void 0,te=this.resumeSessionFile!=null?this.resumeModel:O.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,k?(this.stateStore.update(de=>de.resyncing?de:{...de,resyncing:!0}),this.send({type:"session_load",sessionFile:k,cwd:q,model:te}),this.armLoadWatchdog()):this.stateStore.update(de=>de.resyncing?{...de,resyncing:!1}:de)},x=O=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const k=typeof O.data=="string"?O.data:O.data.toString(),q=JSON.parse(k);this.handleMessage(q)}catch(k){console.error("Failed to parse WebSocket message:",k)}}},I=()=>{this.ws===_&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(O=>({...O,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:O.activeSessionFile?!0:O.resyncing})),this.scheduleReconnect())},P=O=>{this.ws===_&&this.stateStore.update(k=>({...k,error:k.error||"Connection error occurred"}))};typeof _.addEventListener=="function"?(_.addEventListener("open",m),_.addEventListener("message",x),_.addEventListener("close",I),_.addEventListener("error",P)):typeof _.on=="function"&&(_.on("open",m),_.on("message",O=>x({data:O})),_.on("close",I),_.on("error",P))}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({...ks,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=Vt(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=Vt(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||Vt(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,Gn.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=Vt(this.stateStore).isStreaming,a=o?Gn.TURN_STALL_MS:Gn.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(c=>({...c,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:o?"Connection to relay stalled mid-turn; reconnecting...":c.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,Gn.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=Vt(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."})))},Gn.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,Vt(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."})))},Gn.CREATE_WATCHDOG_MS)}clearCreateWatchdog(){this.createWatchdog&&(clearTimeout(this.createWatchdog),this.createWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`);const e=!!Vt(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_conflict":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_conflict":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_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(c=>c.role==="thinking"&&c.isStreaming);a&&(o=o.map(c=>c.id===a.id?{...c,isStreaming:!1}:c));const l=[...o].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(l)o=o.map(c=>c.id===l.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){if(e.role==="user"&&this.confirmDeliveredByContent(e.content))return Vt(this.stateStore);const c=[...o].reverse().find(m=>m.role==="user");e.role==="user"&&c&&c.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,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(c=>c.isStreaming&&(c.role==="assistant"||c.role==="thinking")?{...c,isStreaming:!1}:c),a=Date.now(),l={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...e.forceCommand?{forceCommand:!0}:{}};return{...s,messages:[...o,l]}});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 ms,a as h,c as jn,g,d as dr,e as H,s as Z,f as cr,t as An}from"../chunks/vMsF8lo6.js";import{ar as En,b2 as rs,al as Sr,be as B,ap as yo,M as mi,aS as gi,aq as Ms,d as ta,am as Ds,at as xi,n as _i,a0 as yi,u as wi,t as ki,a1 as Si,V as Ti,W as Ai,H as Ei,b3 as wo,C as ko,aE as ls,a2 as ar,ac as Ci,az as Ii,aZ as Ri,ay as na,bd as ra,bf as $i,bg as Ks,aU as Ys,aQ as So,aP as er,aM as tr,af as Nt,b6 as f,ai as t,a5 as Mi,bh as K,$ as Di,bl as Nn,ah as Kn,a8 as zt,aK as qr,a_ as p,X as u,aV as d,aI as et,b9 as G,aO as Mn,bi as Dt,bj as Pi,aT as Li}from"../chunks/CEg8tgYI.js";import{i as E,s as _r,a as Me,p as vr}from"../chunks/MtE7VtNZ.js";import{a as Oi,b as me,r as at,c as sa,e as gn,i as Pn,d as Ni}from"../chunks/Ddnp1HFv.js";import{_ as Fi,b as Vn}from"../chunks/ylfInSZr.js";import{v as oa}from"../chunks/BpNdwm2g.js";import{p as Ui}from"../chunks/CFZwc5OM.js";function To(n,e,r=!1,s=!1,o=!1,a=!1){var l=n,c="";if(r){var _=n;En&&(l=rs(Sr(_)))}B(()=>{var m=mi;if(c===(c=e()??"")){En&&yo();return}if(r&&!En){m.nodes=null,_.innerHTML=c,c!==""&&ms(Sr(_),_.lastChild);return}if(m.nodes!==null&&(gi(m.nodes.start,m.nodes.end),m.nodes=null),c!==""){if(En){Ms.data;for(var x=yo(),I=x;x!==null&&(x.nodeType!==ta||x.data!=="");)I=x,x=Ds(x);if(x===null)throw xi(),_i;ms(Ms,I),l=rs(x);return}var P=s?wi:o?ki:void 0,O=yi(s?"svg":o?"math":"template",P);O.innerHTML=c;var k=s||o?O:O.content;if(ms(Sr(k),k.lastChild),s||o)for(;Sr(k);)l.before(Sr(k));else l.before(k)}})}function zi(n,e){let r=null,s=En;var o;if(En){r=Ms;for(var a=Sr(document.head);a!==null&&(a.nodeType!==ta||a.data!==n);)a=Ds(a);if(a===null)wo(!1);else{var l=Ds(a);a.remove(),rs(l)}}En||(o=document.head.appendChild(Si()));try{Ti(()=>{var c=Ai(()=>e(o));c.f|=Ei})}finally{s&&(wo(!0),rs(r))}}function aa(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=aa(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function Bi(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=aa(n))&&(s&&(s+=" "),s+=e);return s}function Hi(n){return typeof n=="object"?Bi(n):n??""}function Wi(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function Jt(n,e,r,s,o,a){var l=n[ko];if(En||l!==r||l===void 0){var c=Wi(r);(!En||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[ko]=r}return a}function Zs(n,e,r=!1){if(n.multiple){if(e==null)return;if(!Ii(e))return Ri();for(var s of n.options)s.selected=e.includes(zr(s));return}for(s of n.options){var o=zr(s);if(na(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function ia(n){var e=new MutationObserver(()=>{Zs(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),ra(()=>{e.disconnect()})}function Gr(n,e,r=e){var s=new WeakSet,o=!0;ls(n,"change",a=>{var l=a?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(l),zr);else{var _=n.querySelector(l)??n.querySelector("option:not([disabled])");c=_&&zr(_)}r(c),n.__value=c,ar!==null&&s.add(ar)}),Ci(()=>{var a=e();if(n===document.activeElement){var l=ar;if(s.has(l))return}if(Zs(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=zr(c),r(a))}n.__value=a,o=!1}),ia(n)}function zr(n){return"__value"in n?n.__value:n.value}function Ln(n,e,r=e){var s=new WeakSet;ls(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=xs(n)?_s(a):a,r(a),ar!==null&&s.add(ar),await $i(),a!==(a=e())){var l=n.selectionStart,c=n.selectionEnd,_=n.value.length;if(n.value=a??"",c!==null){var m=n.value.length;l===c&&c===_&&m>_?(n.selectionStart=m,n.selectionEnd=m):(n.selectionStart=l,n.selectionEnd=Math.min(c,m))}}}),(En&&n.defaultValue!==n.value||Ks(e)==null&&n.value)&&(r(xs(n)?_s(n.value):n.value),ar!==null&&s.add(ar)),Ys(()=>{var o=e();if(n===document.activeElement){var a=ar;if(s.has(a))return}xs(n)&&o===_s(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const gs=new Set;function lr(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",l=n;let c=!1;if(e!==null)for(var _ of e)l=l[_]??=[];l.push(r),ls(r,"change",()=>{var m=r.__value;a&&(m=Ao(l,m,r.checked)),o(m)},()=>o(a?[]:null)),Ys(()=>{var m=s();if(En&&r.defaultChecked!==r.checked){c=!0;return}a?(m=m||[],r.checked=m.includes(r.__value)):r.checked=na(r.__value,m)}),ra(()=>{var m=l.indexOf(r);m!==-1&&l.splice(m,1)}),gs.has(l)||(gs.add(l),So(()=>{l.sort((m,x)=>m.compareDocumentPosition(x)===4?-1:1),gs.delete(l)})),So(()=>{if(c){var m;if(a)m=Ao(l,m,r.checked);else{var x=l.find(I=>I.checked);m=x?.__value}o(m)}})}function On(n,e,r=e){ls(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(En&&n.defaultChecked!==n.checked||Ks(e)==null)&&r(n.checked),Ys(()=>{var s=e();n.checked=!!s})}function Ao(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 xs(n){var e=n.type;return e==="number"||e==="range"}function _s(n){return n===""?null:+n}const Gi=!1,ji=!0,fp=Object.freeze(Object.defineProperty({__proto__:null,prerender:ji,ssr:Gi},Symbol.toStringTag,{value:"Module"})),ys="Wherever",qi="Create & maintain apps from wherever with a beautiful remote workspace.",ws="https://localhost",Vi="#000000",Ki="black-translucent";function Ar(n,e){return Oi(n)}var Yi=g('<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 Zi(n,e){er(e,!0);const r=ws.endsWith("/")?ws.slice(0,-1):ws,s=r+"/preview.png";let o=K(()=>e.home||!1),a=K(()=>({type:e.type||"website",title:e.title||ys,description:e.description||qi,image:e.image||s,url:`${r}${Ui.url.pathname}`}));zi("13n5pl5",l=>{var c=Yi(),_=Nt(c),m=f(_,2),x=f(m,2);{var I=He=>{var lt=jn(),kt=Nt(lt);E(kt,tt=>{}),h(He,lt)};E(x,He=>{t(o)&&He(I)})}var P=f(x,2),O=f(P,2),k=f(O,2),q=f(k,2),te=f(q,2),de=f(te,4),re=f(de,2),je=f(re,2),_e=f(je,2),$e=f(_e,2),fe=f($e,2),Le=f(fe,2),Ee=f(Le,2),Et=f(Ee,2),it=f(Et,4),ue=f(it,4),Ve=f(ue,2),Bt=f(Ve,2);B((He,lt,kt,tt)=>{me(_,"content",t(a).title),me(m,"content",t(a).description),me(P,"content",t(a).type),me(O,"content",t(a).url),me(k,"content",t(a).title),me(q,"content",t(a).description),me(te,"content",t(a).image),me(de,"content",t(a).url),me(re,"content",t(a).title),me(je,"content",t(a).description),me(_e,"content",t(a).image),me($e,"href",He),me(fe,"href",lt),me(Le,"href",kt),me(Ee,"href",tt),me(Et,"content",Vi),me(it,"content",ys),me(ue,"content",Ki),me(Ve,"content",ys),me(Bt,"content",oa)},[()=>Ar("/pwa/favicon.png"),()=>Ar("/pwa/favicon.ico"),()=>Ar("/pwa/apple-touch-icon.png"),()=>Ar("/pwa/manifest.webmanifest")]),Mi(()=>{Di.title=t(a).title??""}),h(l,c)}),tr()}let Ir=null;function Xi(){if(typeof window>"u")return null;try{if(!Ir){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;Ir=new n}return Ir.state==="suspended"&&Ir.resume().catch(()=>{}),Ir}catch{return null}}function Eo(n,e,r,s,o){const a=n.createOscillator(),l=n.createGain();a.type="sine",a.frequency.value=e;const c=.015;l.gain.setValueAtTime(1e-4,r),l.gain.exponentialRampToValueAtTime(o,r+c),l.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(l),l.connect(n.destination),a.start(r),a.stop(r+s+.02)}const Co=new Map;function Qi(n){if(typeof Audio>"u")return!1;try{let e=Co.get(n);e||(e=new Audio(n),e.preload="auto",Co.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 la(n){if(n&&n.trim()&&Qi(n.trim()))return;const e=Xi();if(e)try{const r=e.currentTime;Eo(e,1046.5,r,.16,.12),Eo(e,1396.9,r+.13,.22,.12)}catch{}}function es(){}function Ji(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function el(n,...e){if(n==null)return es;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Vt(n){let e;return el(n,r=>e=r)(),e}var wr=[];function tl(n,e=es){let r;const s=new Set;function o(c){if(Ji(n,c)&&(n=c,r)){const _=!wr.length;for(const m of s)m[1](),wr.push(m,n);if(_){for(let m=0;m<wr.length;m+=2)wr[m][0](wr[m+1]);wr.length=0}}}function a(c){o(c(n))}function l(c,_=es){const m=[c,_];return s.add(m),s.size===1&&(r=e(o)||es),c(n),()=>{s.delete(m),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:l}}const ks={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,conflict: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};class $n{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=tl({...ks,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(O=>r?{...O,connecting:!0,error:null}:{...ks,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}`,c=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!c){this.stateStore.update(O=>({...O,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const O=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=O?new c(l,O):new c(l)}catch(O){this.stateStore.update(k=>({...k,connecting:!1,error:`Failed to connect: ${O}`})),this.scheduleReconnect();return}const _=this.ws,m=()=>{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(de=>({...de,connected:!0,connecting:!1,error:null}));const O=Vt(this.stateStore),k=this.resumeSessionFile??O.activeSessionFile,q=this.resumeSessionFile!=null?this.resumeCwd:O.activeCwd??void 0,te=this.resumeSessionFile!=null?this.resumeModel:O.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,k?(this.stateStore.update(de=>de.resyncing?de:{...de,resyncing:!0}),this.send({type:"session_load",sessionFile:k,cwd:q,model:te}),this.armLoadWatchdog()):this.stateStore.update(de=>de.resyncing?{...de,resyncing:!1}:de)},x=O=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const k=typeof O.data=="string"?O.data:O.data.toString(),q=JSON.parse(k);this.handleMessage(q)}catch(k){console.error("Failed to parse WebSocket message:",k)}}},I=()=>{this.ws===_&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(O=>({...O,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:O.activeSessionFile?!0:O.resyncing})),this.scheduleReconnect())},P=O=>{this.ws===_&&this.stateStore.update(k=>({...k,error:k.error||"Connection error occurred"}))};typeof _.addEventListener=="function"?(_.addEventListener("open",m),_.addEventListener("message",x),_.addEventListener("close",I),_.addEventListener("error",P)):typeof _.on=="function"&&(_.on("open",m),_.on("message",O=>x({data:O})),_.on("close",I),_.on("error",P))}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({...ks,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=Vt(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=Vt(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||Vt(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,$n.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=Vt(this.stateStore).isStreaming,a=o?$n.TURN_STALL_MS:$n.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(c=>({...c,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:o?"Connection to relay stalled mid-turn; reconnecting...":c.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,$n.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=Vt(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."})))},$n.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,Vt(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."})))},$n.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>=$n.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=!!Vt(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_conflict":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_conflict":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_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(c=>c.role==="thinking"&&c.isStreaming);a&&(o=o.map(c=>c.id===a.id?{...c,isStreaming:!1}:c));const l=[...o].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(l)o=o.map(c=>c.id===l.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){if(e.role==="user"&&this.confirmDeliveredByContent(e.content))return Vt(this.stateStore);const c=[...o].reverse().find(m=>m.role==="user");e.role==="user"&&c&&c.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,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(c=>c.isStreaming&&(c.role==="assistant"||c.role==="thinking")?{...c,isStreaming:!1}:c),a=Date.now(),l={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...e.forceCommand?{forceCommand:!0}:{}};return{...s,messages:[...o,l]}});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(c=>{const _=c.messages.find(x=>x.role==="tool"&&x.toolName===e.toolName&&x.isStreaming)??[...c.messages].reverse().find(x=>x.role==="tool"&&x.toolName===e.toolName&&!x.content.startsWith("Tool error:")),m=Date.now();if(_){const x=a?"Error: ":"";return{...c,messages:c.messages.map(I=>I.id===_.id?{...I,content:`${x}${I.content}
|
|
4
4
|
${s}`,isStreaming:!1,isError:a,interrupted:o,toolOutput:s,...l?{images:l}:{},endedAt:m}:I)}}else{const x=a?`Tool error: ${e.toolName}
|
|
@@ -7,8 +7,8 @@ ${s}`,I={id:this.generateId(),role:"tool",content:x,timestamp:m,isStreaming:!1,t
|
|
|
7
7
|
`),s=(r[r.length-1]||"").trim();return/^(command|operation)?\s*aborted$/i.test(s)}mapHistory(e,r,s){const o=[],a={},l={},c=(x,I)=>{const P=a[x];if(!P)return;const O=P.indexOf(I);O!==-1&&P.splice(O,1)};for(const x of e)if(x.role==="tool_call"){const I=x.toolName||"unknown",P=x.content||"",O=o.length;o.push({id:this.generateId(),role:"tool",content:P?`$ ${I} ${P}`:`$ ${I}`,timestamp:x.timestamp,isStreaming:!1,toolName:I,toolArgs:P,toolOutput:"",sessionId:r,...Number.isFinite(x.timestamp)?{startedAt:x.timestamp}:{},...x.forceCommand?{forceCommand:!0}:{}}),a[I]||(a[I]=[]),a[I].push(O),typeof x.toolCallId=="string"&&x.toolCallId&&(l[x.toolCallId]=O)}else if(x.role==="tool_result"){const I=x.toolName||"unknown";let P;if(typeof x.toolCallId=="string"&&x.toolCallId&&l[x.toolCallId]!==void 0)P=l[x.toolCallId],delete l[x.toolCallId],c(I,P);else if(a[I]&&a[I].length>0){P=a[I].shift();for(const[q,te]of Object.entries(l))te===P&&delete l[q]}const O=x.isError&&!this.isAbortedToolResult(x.content),k=!!x.isError&&this.isAbortedToolResult(x.content);if(P!==void 0){const q=o[P],te=q.toolArgs||"",de=q.startedAt;o[P]={...q,content:te?`$ ${I} ${te}
|
|
8
8
|
${x.content}`:`$ ${I}
|
|
9
9
|
${x.content}`,isStreaming:!1,toolOutput:x.content,...Array.isArray(x.images)&&x.images.length>0?{images:x.images}:{},isError:O,interrupted:k,timestamp:x.timestamp,...de!==void 0&&Number.isFinite(de)&&Number.isFinite(x.timestamp)&&x.timestamp>=de?{endedAt:x.timestamp}:{}}}else o.push({id:this.generateId(),role:"tool",content:`$ ${I}
|
|
10
|
-
${x.content}`,timestamp:x.timestamp,isStreaming:!1,toolName:I,toolArgs:"",toolOutput:x.content,...Array.isArray(x.images)&&x.images.length>0?{images:x.images}:{},isError:O,interrupted:k,sessionId:r})}else o.push({id:this.generateId(),role:x.role,content:x.content,timestamp:x.timestamp,isStreaming:!1,toolName:x.toolName,sessionId:r});const _=[];for(const x of Object.values(a))_.push(...x);_.sort((x,I)=>x-I);const m=s&&_.length>0?_[_.length-1]:-1;for(const x of _)x===m?o[x]={...o[x],isStreaming:!0}:o[x]={...o[x],interrupted:!0};if(s&&o.length>0){const x=o.length-1,I=o[x];(I.role==="assistant"||I.role==="thinking")&&(o[x]={...I,isStreaming:!0})}return o}loadMoreHistory(){const e=Vt(this.stateStore);e.sessionId&&(e.loadingMoreHistory||e.historyOffset<=0||(this.stateStore.update(r=>({...r,loadingMoreHistory:!0})),this.send({type:"history_load_more",sessionId:e.sessionId,beforeOffset:e.historyOffset})))}send(e){if(this.ws&&this.ws.readyState===1)try{return this.ws.send(JSON.stringify(e)),!0}catch{return!1}return!1}sendMessage(e){const r=Vt(this.stateStore);if(!r.sessionId)return!1;if(r.agentPending)return this.stateStore.update(a=>({...a,sessionError:a.sessionError??"Preparing the session agent; please wait a moment, then resend."})),!1;if(!this.getIsConnected())return this.stateStore.update(a=>({...a,sessionError:"Not connected to the relay; your message was not sent. Reconnecting, then please resend."})),!this.ws&&!this.reconnectTimer&&this.scheduleReconnect(),!1;if(!this.send({type:"message",message:e,sessionId:r.sessionId}))return this.stateStore.update(a=>({...a,sessionError:"Message failed to send (connection dropped). Please resend once reconnected."})),!1;if(e.trimStart().startsWith("!"))return this.stateStore.update(a=>({...a,sessionError:null})),!0;const o={id:this.generateId(),role:"user",content:e,timestamp:Date.now(),isStreaming:!1,sessionId:r.sessionId,delivery:"sending"};return this.stateStore.update(a=>({...a,sessionError:null,messages:[...a.messages,o]})),this.armConfirm(o.id),this.persistPending(r.sessionId),!0}pendingKey(e){return Gn.PENDING_PREFIX+e}persistPending(e){if(!e||typeof localStorage>"u")return;const r=Vt(this.stateStore).messages.filter(s=>s.role==="user"&&s.delivery!==void 0);try{r.length===0?localStorage.removeItem(this.pendingKey(e)):localStorage.setItem(this.pendingKey(e),JSON.stringify(r.map(s=>({id:s.id,content:s.content,timestamp:s.timestamp,delivery:"failed"}))))}catch{}}loadPersistedPending(e){if(typeof localStorage>"u")return[];try{const r=localStorage.getItem(this.pendingKey(e));if(!r)return[];const s=JSON.parse(r);return Array.isArray(s)?s.filter(o=>o&&typeof o.content=="string").map(o=>({id:typeof o.id=="string"?o.id:this.generateId(),role:"user",content:o.content,timestamp:typeof o.timestamp=="number"?o.timestamp:Date.now(),isStreaming:!1,sessionId:e,delivery:"failed"})):[]}catch{return[]}}armConfirm(e){if(this.clearConfirm(e),typeof setTimeout!="function")return;const r=setTimeout(()=>{this.confirmTimers.delete(e);let s=null;this.stateStore.update(o=>{const a=o.messages.find(l=>l.id===e);return!a||a.delivery!=="sending"?o:(s=o.sessionId,{...o,messages:o.messages.map(l=>l.id===e?{...l,delivery:"failed"}:l)})}),s&&this.persistPending(s)},Gn.CONFIRM_MS);r&&typeof r.unref=="function"&&r.unref(),this.confirmTimers.set(e,r)}clearConfirm(e){const r=this.confirmTimers.get(e);r&&(clearTimeout(r),this.confirmTimers.delete(e))}confirmDeliveredByContent(e){let r=null,s=null;return this.stateStore.update(o=>{const a=o.messages.find(l=>l.role==="user"&&l.delivery!==void 0&&l.content===e);return a?(r=a.id,s=o.sessionId,{...o,messages:o.messages.map(l=>l.id===a.id?{...l,delivery:void 0}:l)}):o}),r?(this.clearConfirm(r),this.persistPending(s),!0):!1}resendMessage(e){const r=Vt(this.stateStore),s=r.messages.find(a=>a.id===e&&a.role==="user");return!s||!r.sessionId?!1:this.getIsConnected()?this.send({type:"message",message:s.content,sessionId:r.sessionId})?(this.stateStore.update(a=>({...a,sessionError:null,messages:a.messages.map(l=>l.id===e?{...l,delivery:"sending",timestamp:Date.now()}:l)})),this.armConfirm(e),this.persistPending(r.sessionId),!0):!1:(!this.ws&&!this.reconnectTimer&&this.scheduleReconnect(),!1)}discardMessage(e){let r=null;this.clearConfirm(e),this.stateStore.update(s=>(r=s.sessionId,{...s,messages:s.messages.filter(o=>o.id!==e)})),r&&this.persistPending(r)}abort(){const e=Vt(this.stateStore);e.sessionId&&this.send({type:"abort",sessionId:e.sessionId})}joinSession(e,r,s){this.stateStore.update(o=>({...o,conflict:null,sessionError:null,loadingSession:!0,agentPending:!1})),this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog()}switchSession(e,r,s){const o=Vt(this.stateStore);o.activeSessionFile===e&&!o.loadingSession&&!o.resyncing||(o.sessionId&&this.send({type:"session_leave",sessionId:o.sessionId}),this.stateStore.update(a=>({...a,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,conflict:null,sessionError:null,notice:null,sudoPrompt:null,creatingSession:!1,resyncing:!1,agentPending:!1,contextUsage:null,loadingSession:!0})),this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,this.clearCreateWatchdog(),this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog())}createSession(e,r,s,o,a,l){this.stateStore.update(c=>({...c,conflict:null,sessionError:null,creatingSession:!0,loadingSession:!1})),this.send({type:"session_new",cwd:e,model:r,gitInit:s,createRemote:o,repoVisibility:a,cloneRemote:l}),this.armCreateWatchdog()}leaveSession(){const e=Vt(this.stateStore);if(this.clearCreateWatchdog(),!e.sessionId){e.creatingSession&&this.stateStore.update(r=>({...r,creatingSession:!1}));return}this.send({type:"session_leave",sessionId:e.sessionId}),this.stateStore.update(r=>({...r,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,notice:null,sudoPrompt:null,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,contextUsage:null})),this.clearLoadWatchdog(),this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0}resolveConflict(e,r){const s=Vt(this.stateStore);s.conflict&&(this.send({type:"session_resolve_conflict",action:e,sessionId:s.conflict.targetSessionId,cwd:r||s.conflict.conflictingCwd}),this.stateStore.update(o=>({...o,conflict:null,readOnly:e==="read_only"})))}ping(){this.send({type:"ping"})}clearMessages(){this.stateStore.update(e=>({...e,messages:[]}))}dismissSessionError(){this.stateStore.update(e=>({...e,sessionError:null}))}dismissNotice(){this.stateStore.update(e=>({...e,notice:null}))}sendSudoPassword(e){const s=Vt(this.stateStore).sudoPrompt;s&&(this.send({type:"bash_sudo_password",sessionId:s.sessionId,promptId:s.promptId,password:e}),this.stateStore.update(o=>({...o,sudoPrompt:null})))}cancelSudoPrompt(){const r=Vt(this.stateStore).sudoPrompt;this.stateStore.update(s=>({...s,sudoPrompt:null})),r&&this.send({type:"bash_sudo_cancel",sessionId:r.sessionId,promptId:r.promptId})}changeModel(e){this.send({type:"model_change",model:e})}setConfig(e){this.config={...this.config,...e},this.stateStore.update(r=>{const s={...r};return e.hideThinking!==void 0&&(s.hideThinking=!!e.hideThinking),e.hideTools!==void 0&&(s.hideTools=!!e.hideTools),s})}onMessage(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}uploadFileViaWebSocket(e,r,s){return new Promise((o,a)=>{const l=this.generateId();this.pendingUploads.set(l,{resolve:o,reject:a}),this.send({type:"file_upload",uploadId:l,sessionId:e,filename:r,data:s})})}generateId(){return Math.random().toString(36).substring(2)+Date.now().toString(36)}getIsConnected(){return this.ws&&this.ws.readyState===1}}const Er=On({folders:[],activeSessions:[],currentSession:null,loading:!1}),Cr=On({models:[],loading:!1}),Nr=On({folders:[],activeSessions:[],currentSession:null,loading:!1});function Ss(){if(typeof window<"u"&&window.location){const n=window.location;if(n.port)return Number(n.port);if(n.protocol==="https:")return 443;if(n.protocol==="http:")return 80}return 31415}function Nn(){const n=localStorage.getItem("wherever-config"),e=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost";if(n){const r=JSON.parse(n),s=window.location.protocol==="https:"?"https:":"http:";let o=r.host||e;(o==="localhost"||o==="127.0.0.1")&&e&&e!=="localhost"&&e!=="127.0.0.1"&&(o=e),o=o.startsWith("http")?o.replace(/^wss?:\/\//,""):o;let a=r.port;return(a===31415||a===void 0)&&Ss()!==31415&&(a=Ss()),`${s}//${o}:${a||Ss()}`}return`${window.location.protocol}//${window.location.host}`}let Rr=null,Ps=[],Ls=!1,Os=!1,Io=0;const nl=150,rl=1e3;async function Ro(){Ls=!0;try{const n=Nn(),e=Fn(),r=`${n}/sessions${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();Er.set({folders:o.folders||[],activeSessions:(o.activeSessions||[]).map(a=>a.sessionFile),currentSession:Kn(Er).currentSession,loading:!1})}catch(n){Er.update(e=>({...e,loading:!1})),console.error("Failed to fetch sessions:",n)}finally{Ls=!1}}function Br(){Er.update(r=>({...r,loading:!0}));const n=new Promise(r=>{Ps.push(r)});if(Ls)return Os=!0,n;const e=Date.now();if(!Rr)Io=e;else if(clearTimeout(Rr),e-Io>=rl)return Rr=null,$o(),n;return Rr=setTimeout(()=>{Rr=null,$o()},nl),n}async function $o(){const n=[...Ps];Ps=[];try{for(await Ro();Os;)Os=!1,await Ro()}finally{for(const e of n)e()}}async function ca(){Nr.update(n=>({...n,loading:!0}));try{const n=Nn(),e=Fn(),r=`${n}/sessions?view=readonly${e?`&token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();Nr.set({folders:o.folders||[],activeSessions:(o.activeSessions||[]).map(a=>a.sessionFile),currentSession:Kn(Nr).currentSession,loading:!1})}catch(n){Nr.update(e=>({...e,loading:!1})),console.error("Failed to fetch read-only sessions:",n)}}async function sl(){Cr.update(n=>({...n,loading:!0}));try{const n=Nn(),e=Fn(),r=`${n}/models${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();Cr.set({models:o.models||[],loading:!1})}catch(n){Cr.update(e=>({...e,loading:!1})),console.error("Failed to fetch models:",n)}}function Fn(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n).token||""}catch{}return""}const Xs=On(!1),da=On("websocket"),Qs=On(null),ua=On(!1),fa=On(null);async function pa(n){if(!n.trim())return null;try{const e=Nn(),r=Fn(),s=`${e}/check-path?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return await o.json()}catch(e){return console.error("Failed to check path:",e),null}}async function ol(n){if(!n.trim())return null;try{const e=Nn(),r=Fn(),s=`${e}/check-remote-repo?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return await o.json()}catch(e){return console.error("Failed to check remote repo:",e),null}}async function ss(n){try{const e=Nn(),r=Fn(),s=`${e}/autocomplete-path?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return(await o.json()).completions||[]}catch(e){return console.error("Failed to autocomplete path:",e),[]}}async function al(){try{const n=Nn(),e=Fn(),r=`${n}/config${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();Xs.set(!!o.gitInitDefault),da.set(o.uploadMethod||"websocket"),Qs.set(o.searchFolder||null),ua.set(!!o.searchCreateRemote),fa.set(o.searchDefaultModel||null)}catch(n){console.error("Failed to fetch config:",n)}}function Hr(n){Er.update(e=>({...e,currentSession:n}))}function il(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n)}catch{}return null}function Vr(n){localStorage.setItem("wherever-config",JSON.stringify(n))}function Ts(){if(typeof window<"u"&&window.location){const n=window.location;if(n.port)return Number(n.port);if(n.protocol==="https:")return 443;if(n.protocol==="http:")return 80}return 31415}function nr(){const n=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost",e=il();return e?((e.port===31415||e.port===void 0)&&Ts()!==31415&&(e.port=Ts()),(!e.host||e.host==="localhost"||e.host==="127.0.0.1")&&n&&n!=="localhost"&&n!=="127.0.0.1"?{hideThinking:!1,hideTools:!1,...e,host:n}:(e.host||(e.host=n),{hideThinking:!1,hideTools:!1,beepDefault:!1,beepSoundUrl:"",...e})):{host:n,port:Ts(),token:"",hideThinking:!1,hideTools:!1,beepDefault:!1,beepSoundUrl:""}}const cs=On(!!nr().beepDefault),ha="wherever-beep-overrides";function ll(){try{const n=localStorage.getItem(ha);if(n){const e=JSON.parse(n);if(e&&typeof e=="object")return e}}catch{}return{}}function cl(n){try{localStorage.setItem(ha,JSON.stringify(n))}catch{}}const ba=On(typeof localStorage<"u"?ll():{}),Js=On("");function dl(){return Kn(cs)}function va(){const n=nr().beepSoundUrl;return typeof n=="string"?n:""}function ul(n){const e=nr();Vr({...e,beepSoundUrl:n})}const eo=zt([Js,ba],([n,e])=>n&&n in e?e[n]:void 0),to=zt([eo,cs],([n,e])=>n===void 0?e:n);function fl(n){const e=nr();Vr({...e,beepDefault:n}),cs.set(n)}function ts(n){const e=Kn(Js);e&&ba.update(r=>{const s={...r};return n===void 0?delete s[e]:s[e]=n,cl(s),s})}function ma(n){Js.set(n??"")}const $r=nr(),pt=new Gn({host:$r.host,port:$r.port,token:$r.token,secure:typeof window<"u"&&window.location&&window.location.protocol==="https:",hideThinking:!!$r.hideThinking,hideTools:!!$r.hideTools}),ds=pt.stateStore;let As=!1,Mo=null;ds.subscribe(n=>{const e=n.sessionId??n.activeSessionFile??null;if(e!==Mo){Mo=e,ma(e),As=n.isStreaming;return}As&&!n.isStreaming&&e&&Kn(to)&&la(va()),As=n.isStreaming});let Fr=null;pt.onMessage(n=>{switch(n.type){case"session_created":if(Hr(n.sessionFile),Fr!==null){const r=Fr;Fr=null,queueMicrotask(()=>pt.sendMessage(r))}break;case"session_error":Fr=null;break;case"session_destroyed":Kn(ds).sessionId===n.sessionId&&Hr(null);break;case"sessions_updated":Br();break;case"session_interrupted":Hr(null);break}});function mr(){const n=nr();Vr(n);const e=typeof window<"u"&&window.location&&window.location.protocol==="https:";pt.connect({host:n.host,port:n.port,token:n.token,secure:e,hideThinking:!!n.hideThinking,hideTools:!!n.hideTools})}function jr(){pt.disconnect(!0),Hr(null)}function ga(){pt.suspend()}function Ns(){pt.resume()}function pl(){return pt.hasSuspendedSession()}function Fs(){return pt.hasActiveSession()}let no=0;const hl=300*1e3;function xa(){no=Date.now()+hl}function ro(){no=0}function _a(){return Date.now()<no}function Us(n){return pt.sendMessage(n)}function ya(n){return pt.resendMessage(n)}function wa(n){pt.discardMessage(n)}function ka(){pt.abort()}function Sa(n,e,r){pt.joinSession(n,e,r)}function so(n,e,r){pt.switchSession(n,e,r)}function qn(n,e,r,s,o,a){pt.createSession(n,e,r,s,o,a)}function Ta(n,e){const r=n.trim();if(!r)return!1;const s=Kn(Qs);if(!s)return!1;const o=Kn(ua);return Fr=r,pt.createSession(s,e||void 0,o,o,o?"private":void 0),!0}function Mn(){pt.leaveSession(),Hr(null)}function Aa(){pt.loadMoreHistory()}function zs(n,e){pt.resolveConflict(n,e)}function bl(){pt.ping()}function Ea(){pt.clearMessages()}function Bs(n){Vr(n);const{host:e,port:r,token:s,hideThinking:o,hideTools:a}=n;pt.setConfig({host:e,port:r,token:s,hideThinking:o,hideTools:a}),n.beepDefault!==void 0&&cs.set(!!n.beepDefault)}function Ca(n){const r={...nr(),...n};Vr(r),pt.setConfig(r)}function gr(){pt.dismissSessionError()}function Ia(){pt.dismissNotice()}function Ra(n){pt.sendSudoPassword(n)}function $a(){pt.cancelSudoPrompt()}function Ma(n){pt.changeModel(n)}const Pt=zt(ds,n=>n),Kr=zt(Pt,n=>n.connected),oo=zt(Pt,n=>n.isStreaming),Da=zt(Pt,n=>n.messages),vl=zt(Pt,n=>n.error),ml=zt(Pt,n=>n.session),Pa=zt(Pt,n=>n.conflict),La=zt(Pt,n=>n.isInterrupted),ao=zt(Pt,n=>n.sessionError),Oa=zt(Pt,n=>n.notice),Na=zt(Pt,n=>n.sudoPrompt),us=zt(Pt,n=>n.readOnly),Yr=zt(Pt,n=>({sessionFile:n.activeSessionFile,cwd:n.activeCwd,model:n.activeModel,sessionId:n.sessionId})),gl=zt(Pt,n=>n.contextUsage),Fa=zt(Pt,n=>n.creatingSession),fs=zt(Pt,n=>n.loadingSession),io=zt(Pt,n=>n.resyncing),Ua=zt(Pt,n=>n.agentPending),za=zt(Pt,n=>n.historyOffset>0),Ba=zt(Pt,n=>n.loadingMoreHistory);async function xl(n,e){const r=Nn(),s=Fn(),o=`${r}/session/upload?sessionId=${encodeURIComponent(n)}&filename=${encodeURIComponent(e.name)}${s?`&token=${encodeURIComponent(s)}`:""}`,a=await e.arrayBuffer(),l=await fetch(o,{method:"POST",headers:{"Content-Type":"text/plain"},body:a});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||`Upload failed with status ${l.status}`)}return await l.json()}function _l(n,e){return new Promise((r,s)=>{try{const o=new FileReader;o.onload=()=>{try{const l=o.result.split(",")[1]||"";pt.uploadFileViaWebSocket(n,e.name,l).then(r).catch(s)}catch(a){s(new Error(`Failed to process file data: ${a.message}`))}},o.onerror=()=>{s(new Error("Failed to read file contents"))},o.readAsDataURL(e)}catch(o){s(o)}})}function Ha(n){const r=Kn(Pt).sessionId;if(!r)return null;const s=Nn(),o=Fn();return`${s}/session/download?sessionId=${encodeURIComponent(r)}&path=${encodeURIComponent(n)}`+(o?`&token=${encodeURIComponent(o)}`:"")}async function Wa(n,e){return Kn(da)==="post"?xl(n,e):_l(n,e)}async function Hs(n){try{const e=Nn(),r=Fn(),s=`${e}/session/delete${r?`?token=${encodeURIComponent(r)}`:""}`,o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionFile:n})});if(!o.ok){const a=await o.json().catch(()=>({}));throw new Error(a.error||`Delete failed with status ${o.status}`)}}catch(e){throw console.error("Failed to delete session:",e),e}}const yl=Object.freeze(Object.defineProperty({__proto__:null,abort:ka,activeSessionInfo:Yr,beepEnabled:to,beepSessionOverride:eo,beginFilePicker:xa,cancelSudoPrompt:$a,changeModel:Ma,clearMessages:Ea,client:pt,conflict:Pa,connect:mr,connectionError:vl,contextUsage:gl,createSession:qn,currentSession:ml,deleteSession:Hs,discardMessage:wa,disconnect:jr,dismissNotice:Ia,dismissSessionError:gr,downloadFileUrl:Ha,endFilePicker:ro,getBeepDefault:dl,getBeepSoundUrl:va,getConfig:nr,hasActiveSession:Fs,hasMoreHistory:za,hasSuspendedSession:pl,isAgentPending:Ua,isConnected:Kr,isCreatingSession:Fa,isFilePickerActive:_a,isInterrupted:La,isLoadingMoreHistory:Ba,isLoadingSession:fs,isReadOnly:us,isResyncing:io,isStreaming:oo,joinSession:Sa,leaveSession:Mn,loadMoreHistory:Aa,messages:Da,piState:Pt,ping:bl,resendMessage:ya,resolveConflict:zs,resume:Ns,runSearch:Ta,sendMessage:Us,sendSudoPassword:Ra,sessionError:ao,sessionNotice:Oa,setBeepDefault:fl,setBeepSessionKey:ma,setBeepSessionOverride:ts,setBeepSoundUrl:ul,setConfig:Bs,state:ds,sudoPrompt:Na,suspend:ga,switchSession:so,updateConfig:Ca,uploadFile:Wa},Symbol.toStringTag,{value:"Module"}));var wl=g('<button class="flex-1 rounded bg-rose-500 px-4 py-2 text-sm text-white transition-colors hover:bg-rose-600">Disconnect</button>'),kl=g('<button class="flex-1 rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-4 py-2 text-sm text-white transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:from-brand-surface-3 disabled:to-brand-surface-3"></button>'),Sl=g('<div class="border-b border-brand-border p-4"><div class="space-y-3"><div><label for="pi-host" class="mb-1 block text-xs text-brand-text-muted">Host</label> <input id="pi-host" type="text" placeholder="localhost" class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/></div> <div><label for="pi-port" class="mb-1 block text-xs text-brand-text-muted">Port</label> <input id="pi-port" type="number" class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/></div> <div><label for="pi-token" class="mb-1 block text-xs text-brand-text-muted">Token (optional)</label> <input id="pi-token" type="password" placeholder="Authentication token" class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/></div> <div class="flex items-center gap-2 py-1"><input id="pi-hide-thinking" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-0"/> <label for="pi-hide-thinking" class="cursor-pointer text-xs text-brand-text select-none">Hide thinking steps</label></div> <div class="flex items-center gap-2 py-1"><input id="pi-beep-default" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-0"/> <label for="pi-beep-default" class="cursor-pointer text-xs text-brand-text select-none">Beep when the agent is waiting (default for new sessions)</label></div> <div><label for="pi-beep-sound" class="mb-1 block text-xs text-brand-text-muted">Beep sound URL (optional, blank = built-in chime)</label> <div class="flex gap-2"><input id="pi-beep-sound" type="text" placeholder="/sounds/complete.mp3 or https://..." class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/> <button type="button" title="Play the beep to test it" class="flex-shrink-0 rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text transition-colors hover:bg-brand-surface-3">Test</button></div></div> <div class="flex gap-2"><!></div> <button title="Reload the page" class="flex w-full items-center justify-center gap-2 rounded border border-brand-border bg-brand-surface-2 px-4 py-2 text-sm text-brand-text transition-colors hover:bg-brand-surface-3"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" aria-hidden="true"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"></path><path d="M8 16H3v5"></path></svg> Reload</button></div></div>');function Tl(n,e){er(e,!0);const r=()=>Me(Kr,"$isConnected",s),[s,o]=_r();let a=G(""),l=G(0),c=G(""),_=G(!1),m=G(!1),x=G(""),I=!1,P=K(r);qr(()=>{const we=nr();p(a,we.host,!0),p(l,we.port,!0),p(c,we.token||"",!0),p(_,!!we.hideThinking),p(m,!!we.beepDefault),p(x,we.beepSoundUrl||"",!0)});function O(){la(t(x).trim()||void 0)}function k(){Bs({host:t(a),port:t(l),token:t(c),hideThinking:t(_),hideTools:!1,beepDefault:t(m),beepSoundUrl:t(x).trim()})}function q(){Bs({host:t(a),port:t(l),token:t(c),hideThinking:t(_),hideTools:!1,beepDefault:t(m),beepSoundUrl:t(x).trim()}),jr(),setTimeout(()=>mr(),100)}function te(){jr()}function de(){window.location.reload()}var re=Sl(),je=u(re),_e=u(je),$e=f(u(_e),2);at($e),d(_e);var fe=f(_e,2),Le=f(u(fe),2);at(Le),d(fe);var Ee=f(fe,2),Et=f(u(Ee),2);at(Et),d(Ee);var it=f(Ee,2),ue=u(it);at(ue),et(2),d(it);var Ve=f(it,2),Bt=u(Ve);at(Bt),et(2),d(Ve);var He=f(Ve,2),lt=f(u(He),2),kt=u(lt);at(kt);var tt=f(kt,2);d(lt),d(He);var nt=f(He,2),ge=u(nt);{var ct=we=>{var ht=wl();H("click",ht,te),h(we,ht)},De=we=>{var ht=kl();ht.disabled=I,ht.textContent="Connect",H("click",ht,q),h(we,ht)};E(ge,we=>{t(P)?we(ct):we(De,-1)})}d(nt);var St=f(nt,2);d(je),d(re),Pn($e,()=>t(a),we=>p(a,we)),Pn(Le,()=>t(l),we=>p(l,we)),Pn(Et,()=>t(c),we=>p(c,we)),H("change",ue,k),Ln(ue,()=>t(_),we=>p(_,we)),H("change",Bt,k),Ln(Bt,()=>t(m),we=>p(m,we)),H("change",kt,k),Pn(kt,()=>t(x),we=>p(x,we)),H("click",tt,O),H("click",St,de),h(n,re),tr(),o()}dr(["change","click"]);function lo(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var yr=lo();function Ga(n){yr=n}var Wr={exec:()=>null};function vt(n,e=""){let r=typeof n=="string"?n:n.source;const s={replace:(o,a)=>{let l=typeof a=="string"?a:a.source;return l=l.replace(bn.caret,"$1"),r=r.replace(o,l),s},getRegex:()=>new RegExp(r,e)};return s}var bn={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i")},Al=/^(?:[ \t]*(?:\n|$))+/,El=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Cl=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Zr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Il=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,co=/(?:[*+-]|\d{1,9}[.)])/,ja=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,qa=vt(ja).replace(/bull/g,co).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Rl=vt(ja).replace(/bull/g,co).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),uo=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,$l=/^[^\n]+/,fo=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ml=vt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",fo).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Dl=vt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,co).getRegex(),ps="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",po=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Pl=vt("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",po).replace("tag",ps).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Va=vt(uo).replace("hr",Zr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex(),Ll=vt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Va).getRegex(),ho={blockquote:Ll,code:El,def:Ml,fences:Cl,heading:Il,hr:Zr,html:Pl,lheading:qa,list:Dl,newline:Al,paragraph:Va,table:Wr,text:$l},Do=vt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Zr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex(),Ol={...ho,lheading:Rl,table:Do,paragraph:vt(uo).replace("hr",Zr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Do).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex()},Nl={...ho,html:vt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",po).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Wr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:vt(uo).replace("hr",Zr).replace("heading",` *#{1,6} *[^
|
|
11
|
-
]`).replace("lheading",qa).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Fl=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ul=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ka=/^( {2,}|\\)\n(?!\s*$)/,zl=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,hs=/[\p{P}\p{S}]/u,bo=/[\s\p{P}\p{S}]/u,Ya=/[^\s\p{P}\p{S}]/u,Bl=vt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,bo).getRegex(),Za=/(?!~)[\p{P}\p{S}]/u,Hl=/(?!~)[\s\p{P}\p{S}]/u,Wl=/(?:[^\s\p{P}\p{S}]|~)/u,Gl=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Xa=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,jl=vt(Xa,"u").replace(/punct/g,hs).getRegex(),ql=vt(Xa,"u").replace(/punct/g,Za).getRegex(),Qa="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Vl=vt(Qa,"gu").replace(/notPunctSpace/g,Ya).replace(/punctSpace/g,bo).replace(/punct/g,hs).getRegex(),Kl=vt(Qa,"gu").replace(/notPunctSpace/g,Wl).replace(/punctSpace/g,Hl).replace(/punct/g,Za).getRegex(),Yl=vt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ya).replace(/punctSpace/g,bo).replace(/punct/g,hs).getRegex(),Zl=vt(/\\(punct)/,"gu").replace(/punct/g,hs).getRegex(),Xl=vt(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ql=vt(po).replace("(?:-->|$)","-->").getRegex(),Jl=vt("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ql).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),os=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ec=vt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",os).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ja=vt(/^!?\[(label)\]\[(ref)\]/).replace("label",os).replace("ref",fo).getRegex(),ei=vt(/^!?\[(ref)\](?:\[\])?/).replace("ref",fo).getRegex(),tc=vt("reflink|nolink(?!\\()","g").replace("reflink",Ja).replace("nolink",ei).getRegex(),vo={_backpedal:Wr,anyPunctuation:Zl,autolink:Xl,blockSkip:Gl,br:Ka,code:Ul,del:Wr,emStrongLDelim:jl,emStrongRDelimAst:Vl,emStrongRDelimUnd:Yl,escape:Fl,link:ec,nolink:ei,punctuation:Bl,reflink:Ja,reflinkSearch:tc,tag:Jl,text:zl,url:Wr},nc={...vo,link:vt(/^!?\[(label)\]\((.*?)\)/).replace("label",os).getRegex(),reflink:vt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",os).getRegex()},Ws={...vo,emStrongRDelimAst:Kl,emStrongLDelim:ql,url:vt(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},rc={...Ws,br:vt(Ka).replace("{2,}","*").getRegex(),text:vt(Ws.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Qr={normal:ho,gfm:Ol,pedantic:Nl},Mr={normal:vo,gfm:Ws,breaks:rc,pedantic:nc},sc={"&":"&","<":"<",">":">",'"':""","'":"'"},Po=n=>sc[n];function
|
|
10
|
+
${x.content}`,timestamp:x.timestamp,isStreaming:!1,toolName:I,toolArgs:"",toolOutput:x.content,...Array.isArray(x.images)&&x.images.length>0?{images:x.images}:{},isError:O,interrupted:k,sessionId:r})}else o.push({id:this.generateId(),role:x.role,content:x.content,timestamp:x.timestamp,isStreaming:!1,toolName:x.toolName,sessionId:r});const _=[];for(const x of Object.values(a))_.push(...x);_.sort((x,I)=>x-I);const m=s&&_.length>0?_[_.length-1]:-1;for(const x of _)x===m?o[x]={...o[x],isStreaming:!0}:o[x]={...o[x],interrupted:!0};if(s&&o.length>0){const x=o.length-1,I=o[x];(I.role==="assistant"||I.role==="thinking")&&(o[x]={...I,isStreaming:!0})}return o}loadMoreHistory(){const e=Vt(this.stateStore);e.sessionId&&(e.loadingMoreHistory||e.historyOffset<=0||(this.stateStore.update(r=>({...r,loadingMoreHistory:!0})),this.send({type:"history_load_more",sessionId:e.sessionId,beforeOffset:e.historyOffset})))}send(e){if(this.ws&&this.ws.readyState===1)try{return this.ws.send(JSON.stringify(e)),!0}catch{return!1}return!1}sendMessage(e){const r=Vt(this.stateStore);if(!r.sessionId)return!1;if(r.agentPending)return this.stateStore.update(a=>({...a,sessionError:a.sessionError??"Preparing the session agent; please wait a moment, then resend."})),!1;if(!this.getIsConnected())return this.stateStore.update(a=>({...a,sessionError:"Not connected to the relay; your message was not sent. Reconnecting, then please resend."})),!this.ws&&!this.reconnectTimer&&this.scheduleReconnect(),!1;if(!this.send({type:"message",message:e,sessionId:r.sessionId}))return this.stateStore.update(a=>({...a,sessionError:"Message failed to send (connection dropped). Please resend once reconnected."})),!1;if(e.trimStart().startsWith("!"))return this.stateStore.update(a=>({...a,sessionError:null})),!0;const o={id:this.generateId(),role:"user",content:e,timestamp:Date.now(),isStreaming:!1,sessionId:r.sessionId,delivery:"sending"};return this.stateStore.update(a=>({...a,sessionError:null,messages:[...a.messages,o]})),this.armConfirm(o.id),this.persistPending(r.sessionId),!0}pendingKey(e){return $n.PENDING_PREFIX+e}persistPending(e){if(!e||typeof localStorage>"u")return;const r=Vt(this.stateStore).messages.filter(s=>s.role==="user"&&s.delivery!==void 0);try{r.length===0?localStorage.removeItem(this.pendingKey(e)):localStorage.setItem(this.pendingKey(e),JSON.stringify(r.map(s=>({id:s.id,content:s.content,timestamp:s.timestamp,delivery:"failed"}))))}catch{}}loadPersistedPending(e){if(typeof localStorage>"u")return[];try{const r=localStorage.getItem(this.pendingKey(e));if(!r)return[];const s=JSON.parse(r);return Array.isArray(s)?s.filter(o=>o&&typeof o.content=="string").map(o=>({id:typeof o.id=="string"?o.id:this.generateId(),role:"user",content:o.content,timestamp:typeof o.timestamp=="number"?o.timestamp:Date.now(),isStreaming:!1,sessionId:e,delivery:"failed"})):[]}catch{return[]}}armConfirm(e){if(this.clearConfirm(e),typeof setTimeout!="function")return;const r=setTimeout(()=>{this.confirmTimers.delete(e);let s=null;this.stateStore.update(o=>{const a=o.messages.find(l=>l.id===e);return!a||a.delivery!=="sending"?o:(s=o.sessionId,{...o,messages:o.messages.map(l=>l.id===e?{...l,delivery:"failed"}:l)})}),s&&this.persistPending(s)},$n.CONFIRM_MS);r&&typeof r.unref=="function"&&r.unref(),this.confirmTimers.set(e,r)}clearConfirm(e){const r=this.confirmTimers.get(e);r&&(clearTimeout(r),this.confirmTimers.delete(e))}confirmDeliveredByContent(e){let r=null,s=null;return this.stateStore.update(o=>{const a=o.messages.find(l=>l.role==="user"&&l.delivery!==void 0&&l.content===e);return a?(r=a.id,s=o.sessionId,{...o,messages:o.messages.map(l=>l.id===a.id?{...l,delivery:void 0}:l)}):o}),r?(this.clearConfirm(r),this.persistPending(s),!0):!1}resendMessage(e){const r=Vt(this.stateStore),s=r.messages.find(a=>a.id===e&&a.role==="user");return!s||!r.sessionId?!1:this.getIsConnected()?this.send({type:"message",message:s.content,sessionId:r.sessionId})?(this.stateStore.update(a=>({...a,sessionError:null,messages:a.messages.map(l=>l.id===e?{...l,delivery:"sending",timestamp:Date.now()}:l)})),this.armConfirm(e),this.persistPending(r.sessionId),!0):!1:(!this.ws&&!this.reconnectTimer&&this.scheduleReconnect(),!1)}discardMessage(e){let r=null;this.clearConfirm(e),this.stateStore.update(s=>(r=s.sessionId,{...s,messages:s.messages.filter(o=>o.id!==e)})),r&&this.persistPending(r)}abort(){const e=Vt(this.stateStore);e.sessionId&&this.send({type:"abort",sessionId:e.sessionId})}joinSession(e,r,s){this.stateStore.update(o=>({...o,conflict:null,sessionError:null,loadingSession:!0,agentPending:!1})),this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog()}switchSession(e,r,s){const o=Vt(this.stateStore);o.activeSessionFile===e&&!o.loadingSession&&!o.resyncing||(o.sessionId&&this.send({type:"session_leave",sessionId:o.sessionId}),this.stateStore.update(a=>({...a,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,conflict:null,sessionError:null,notice:null,sudoPrompt:null,creatingSession:!1,resyncing:!1,agentPending:!1,contextUsage:null,loadingSession:!0})),this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,this.clearCreateWatchdog(),this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog())}createSession(e,r,s,o,a,l){this.stateStore.update(c=>({...c,conflict:null,sessionError:null,creatingSession:!0,loadingSession:!1})),this.send({type:"session_new",cwd:e,model:r,gitInit:s,createRemote:o,repoVisibility:a,cloneRemote:l}),this.armCreateWatchdog()}leaveSession(){const e=Vt(this.stateStore);if(this.clearCreateWatchdog(),!e.sessionId){e.creatingSession&&this.stateStore.update(r=>({...r,creatingSession:!1}));return}this.send({type:"session_leave",sessionId:e.sessionId}),this.stateStore.update(r=>({...r,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,notice:null,sudoPrompt:null,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,contextUsage:null})),this.clearLoadWatchdog(),this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0}resolveConflict(e,r){const s=Vt(this.stateStore);s.conflict&&(this.send({type:"session_resolve_conflict",action:e,sessionId:s.conflict.targetSessionId,cwd:r||s.conflict.conflictingCwd}),this.stateStore.update(o=>({...o,conflict:null,readOnly:e==="read_only"})))}ping(){this.send({type:"ping"})}clearMessages(){this.stateStore.update(e=>({...e,messages:[]}))}dismissSessionError(){this.stateStore.update(e=>({...e,sessionError:null}))}dismissNotice(){this.stateStore.update(e=>({...e,notice:null}))}sendSudoPassword(e){const s=Vt(this.stateStore).sudoPrompt;s&&(this.send({type:"bash_sudo_password",sessionId:s.sessionId,promptId:s.promptId,password:e}),this.stateStore.update(o=>({...o,sudoPrompt:null})))}cancelSudoPrompt(){const r=Vt(this.stateStore).sudoPrompt;this.stateStore.update(s=>({...s,sudoPrompt:null})),r&&this.send({type:"bash_sudo_cancel",sessionId:r.sessionId,promptId:r.promptId})}changeModel(e){this.send({type:"model_change",model:e})}setConfig(e){this.config={...this.config,...e},this.stateStore.update(r=>{const s={...r};return e.hideThinking!==void 0&&(s.hideThinking=!!e.hideThinking),e.hideTools!==void 0&&(s.hideTools=!!e.hideTools),s})}onMessage(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}uploadFileViaWebSocket(e,r,s){return new Promise((o,a)=>{const l=this.generateId();this.pendingUploads.set(l,{resolve:o,reject:a}),this.send({type:"file_upload",uploadId:l,sessionId:e,filename:r,data:s})})}generateId(){return Math.random().toString(36).substring(2)+Date.now().toString(36)}getIsConnected(){return this.ws&&this.ws.readyState===1}}const Er=Nn({folders:[],activeSessions:[],currentSession:null,loading:!1}),Cr=Nn({models:[],loading:!1}),Nr=Nn({folders:[],activeSessions:[],currentSession:null,loading:!1});function Ss(){if(typeof window<"u"&&window.location){const n=window.location;if(n.port)return Number(n.port);if(n.protocol==="https:")return 443;if(n.protocol==="http:")return 80}return 31415}function Fn(){const n=localStorage.getItem("wherever-config"),e=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost";if(n){const r=JSON.parse(n),s=window.location.protocol==="https:"?"https:":"http:";let o=r.host||e;(o==="localhost"||o==="127.0.0.1")&&e&&e!=="localhost"&&e!=="127.0.0.1"&&(o=e),o=o.startsWith("http")?o.replace(/^wss?:\/\//,""):o;let a=r.port;return(a===31415||a===void 0)&&Ss()!==31415&&(a=Ss()),`${s}//${o}:${a||Ss()}`}return`${window.location.protocol}//${window.location.host}`}let Rr=null,Ps=[],Ls=!1,Os=!1,Io=0;const nl=150,rl=1e3;async function Ro(){Ls=!0;try{const n=Fn(),e=Un(),r=`${n}/sessions${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();Er.set({folders:o.folders||[],activeSessions:(o.activeSessions||[]).map(a=>a.sessionFile),currentSession:Kn(Er).currentSession,loading:!1})}catch(n){Er.update(e=>({...e,loading:!1})),console.error("Failed to fetch sessions:",n)}finally{Ls=!1}}function Br(){Er.update(r=>({...r,loading:!0}));const n=new Promise(r=>{Ps.push(r)});if(Ls)return Os=!0,n;const e=Date.now();if(!Rr)Io=e;else if(clearTimeout(Rr),e-Io>=rl)return Rr=null,$o(),n;return Rr=setTimeout(()=>{Rr=null,$o()},nl),n}async function $o(){const n=[...Ps];Ps=[];try{for(await Ro();Os;)Os=!1,await Ro()}finally{for(const e of n)e()}}async function ca(){Nr.update(n=>({...n,loading:!0}));try{const n=Fn(),e=Un(),r=`${n}/sessions?view=readonly${e?`&token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();Nr.set({folders:o.folders||[],activeSessions:(o.activeSessions||[]).map(a=>a.sessionFile),currentSession:Kn(Nr).currentSession,loading:!1})}catch(n){Nr.update(e=>({...e,loading:!1})),console.error("Failed to fetch read-only sessions:",n)}}async function sl(){Cr.update(n=>({...n,loading:!0}));try{const n=Fn(),e=Un(),r=`${n}/models${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();Cr.set({models:o.models||[],loading:!1})}catch(n){Cr.update(e=>({...e,loading:!1})),console.error("Failed to fetch models:",n)}}function Un(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n).token||""}catch{}return""}const Xs=Nn(!1),da=Nn("websocket"),Qs=Nn(null),ua=Nn(!1),fa=Nn(null);async function pa(n){if(!n.trim())return null;try{const e=Fn(),r=Un(),s=`${e}/check-path?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return await o.json()}catch(e){return console.error("Failed to check path:",e),null}}async function ol(n){if(!n.trim())return null;try{const e=Fn(),r=Un(),s=`${e}/check-remote-repo?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return await o.json()}catch(e){return console.error("Failed to check remote repo:",e),null}}async function ss(n){try{const e=Fn(),r=Un(),s=`${e}/autocomplete-path?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return(await o.json()).completions||[]}catch(e){return console.error("Failed to autocomplete path:",e),[]}}async function al(){try{const n=Fn(),e=Un(),r=`${n}/config${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();Xs.set(!!o.gitInitDefault),da.set(o.uploadMethod||"websocket"),Qs.set(o.searchFolder||null),ua.set(!!o.searchCreateRemote),fa.set(o.searchDefaultModel||null)}catch(n){console.error("Failed to fetch config:",n)}}function Hr(n){Er.update(e=>({...e,currentSession:n}))}function il(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n)}catch{}return null}function Vr(n){localStorage.setItem("wherever-config",JSON.stringify(n))}function Ts(){if(typeof window<"u"&&window.location){const n=window.location;if(n.port)return Number(n.port);if(n.protocol==="https:")return 443;if(n.protocol==="http:")return 80}return 31415}function nr(){const n=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost",e=il();return e?((e.port===31415||e.port===void 0)&&Ts()!==31415&&(e.port=Ts()),(!e.host||e.host==="localhost"||e.host==="127.0.0.1")&&n&&n!=="localhost"&&n!=="127.0.0.1"?{hideThinking:!1,hideTools:!1,...e,host:n}:(e.host||(e.host=n),{hideThinking:!1,hideTools:!1,beepDefault:!1,beepSoundUrl:"",...e})):{host:n,port:Ts(),token:"",hideThinking:!1,hideTools:!1,beepDefault:!1,beepSoundUrl:""}}const cs=Nn(!!nr().beepDefault),ha="wherever-beep-overrides";function ll(){try{const n=localStorage.getItem(ha);if(n){const e=JSON.parse(n);if(e&&typeof e=="object")return e}}catch{}return{}}function cl(n){try{localStorage.setItem(ha,JSON.stringify(n))}catch{}}const ba=Nn(typeof localStorage<"u"?ll():{}),Js=Nn("");function dl(){return Kn(cs)}function va(){const n=nr().beepSoundUrl;return typeof n=="string"?n:""}function ul(n){const e=nr();Vr({...e,beepSoundUrl:n})}const eo=zt([Js,ba],([n,e])=>n&&n in e?e[n]:void 0),to=zt([eo,cs],([n,e])=>n===void 0?e:n);function fl(n){const e=nr();Vr({...e,beepDefault:n}),cs.set(n)}function ts(n){const e=Kn(Js);e&&ba.update(r=>{const s={...r};return n===void 0?delete s[e]:s[e]=n,cl(s),s})}function ma(n){Js.set(n??"")}const $r=nr(),pt=new $n({host:$r.host,port:$r.port,token:$r.token,secure:typeof window<"u"&&window.location&&window.location.protocol==="https:",hideThinking:!!$r.hideThinking,hideTools:!!$r.hideTools}),ds=pt.stateStore;let As=!1,Mo=null;ds.subscribe(n=>{const e=n.sessionId??n.activeSessionFile??null;if(e!==Mo){Mo=e,ma(e),As=n.isStreaming;return}As&&!n.isStreaming&&e&&Kn(to)&&la(va()),As=n.isStreaming});let Fr=null;pt.onMessage(n=>{switch(n.type){case"session_created":if(Hr(n.sessionFile),Fr!==null){const r=Fr;Fr=null,queueMicrotask(()=>pt.sendMessage(r))}break;case"session_error":Fr=null;break;case"session_destroyed":Kn(ds).sessionId===n.sessionId&&Hr(null);break;case"sessions_updated":Br();break;case"session_interrupted":Hr(null);break}});function mr(){const n=nr();Vr(n);const e=typeof window<"u"&&window.location&&window.location.protocol==="https:";pt.connect({host:n.host,port:n.port,token:n.token,secure:e,hideThinking:!!n.hideThinking,hideTools:!!n.hideTools})}function jr(){pt.disconnect(!0),Hr(null)}function ga(){pt.suspend()}function Ns(){pt.resume()}function pl(){return pt.hasSuspendedSession()}function Fs(){return pt.hasActiveSession()}let no=0;const hl=300*1e3;function xa(){no=Date.now()+hl}function ro(){no=0}function _a(){return Date.now()<no}function Us(n){return pt.sendMessage(n)}function ya(n){return pt.resendMessage(n)}function wa(n){pt.discardMessage(n)}function ka(){pt.abort()}function Sa(n,e,r){pt.joinSession(n,e,r)}function so(n,e,r){pt.switchSession(n,e,r)}function qn(n,e,r,s,o,a){pt.createSession(n,e,r,s,o,a)}function Ta(n,e){const r=n.trim();if(!r)return!1;const s=Kn(Qs);if(!s)return!1;const o=Kn(ua);return Fr=r,pt.createSession(s,e||void 0,o,o,o?"private":void 0),!0}function Dn(){pt.leaveSession(),Hr(null)}function Aa(){pt.loadMoreHistory()}function zs(n,e){pt.resolveConflict(n,e)}function bl(){pt.ping()}function Ea(){pt.clearMessages()}function Bs(n){Vr(n);const{host:e,port:r,token:s,hideThinking:o,hideTools:a}=n;pt.setConfig({host:e,port:r,token:s,hideThinking:o,hideTools:a}),n.beepDefault!==void 0&&cs.set(!!n.beepDefault)}function Ca(n){const r={...nr(),...n};Vr(r),pt.setConfig(r)}function gr(){pt.dismissSessionError()}function Ia(){pt.dismissNotice()}function Ra(n){pt.sendSudoPassword(n)}function $a(){pt.cancelSudoPrompt()}function Ma(n){pt.changeModel(n)}const Pt=zt(ds,n=>n),Kr=zt(Pt,n=>n.connected),oo=zt(Pt,n=>n.isStreaming),Da=zt(Pt,n=>n.messages),vl=zt(Pt,n=>n.error),ml=zt(Pt,n=>n.session),Pa=zt(Pt,n=>n.conflict),La=zt(Pt,n=>n.isInterrupted),ao=zt(Pt,n=>n.sessionError),Oa=zt(Pt,n=>n.notice),Na=zt(Pt,n=>n.sudoPrompt),us=zt(Pt,n=>n.readOnly),Yr=zt(Pt,n=>({sessionFile:n.activeSessionFile,cwd:n.activeCwd,model:n.activeModel,sessionId:n.sessionId})),gl=zt(Pt,n=>n.contextUsage),Fa=zt(Pt,n=>n.creatingSession),fs=zt(Pt,n=>n.loadingSession),io=zt(Pt,n=>n.resyncing),Ua=zt(Pt,n=>n.agentPending),za=zt(Pt,n=>n.historyOffset>0),Ba=zt(Pt,n=>n.loadingMoreHistory);async function xl(n,e){const r=Fn(),s=Un(),o=`${r}/session/upload?sessionId=${encodeURIComponent(n)}&filename=${encodeURIComponent(e.name)}${s?`&token=${encodeURIComponent(s)}`:""}`,a=await e.arrayBuffer(),l=await fetch(o,{method:"POST",headers:{"Content-Type":"text/plain"},body:a});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||`Upload failed with status ${l.status}`)}return await l.json()}function _l(n,e){return new Promise((r,s)=>{try{const o=new FileReader;o.onload=()=>{try{const l=o.result.split(",")[1]||"";pt.uploadFileViaWebSocket(n,e.name,l).then(r).catch(s)}catch(a){s(new Error(`Failed to process file data: ${a.message}`))}},o.onerror=()=>{s(new Error("Failed to read file contents"))},o.readAsDataURL(e)}catch(o){s(o)}})}function Ha(n){const r=Kn(Pt).sessionId;if(!r)return null;const s=Fn(),o=Un();return`${s}/session/download?sessionId=${encodeURIComponent(r)}&path=${encodeURIComponent(n)}`+(o?`&token=${encodeURIComponent(o)}`:"")}async function Wa(n,e){return Kn(da)==="post"?xl(n,e):_l(n,e)}async function Hs(n){try{const e=Fn(),r=Un(),s=`${e}/session/delete${r?`?token=${encodeURIComponent(r)}`:""}`,o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionFile:n})});if(!o.ok){const a=await o.json().catch(()=>({}));throw new Error(a.error||`Delete failed with status ${o.status}`)}}catch(e){throw console.error("Failed to delete session:",e),e}}const yl=Object.freeze(Object.defineProperty({__proto__:null,abort:ka,activeSessionInfo:Yr,beepEnabled:to,beepSessionOverride:eo,beginFilePicker:xa,cancelSudoPrompt:$a,changeModel:Ma,clearMessages:Ea,client:pt,conflict:Pa,connect:mr,connectionError:vl,contextUsage:gl,createSession:qn,currentSession:ml,deleteSession:Hs,discardMessage:wa,disconnect:jr,dismissNotice:Ia,dismissSessionError:gr,downloadFileUrl:Ha,endFilePicker:ro,getBeepDefault:dl,getBeepSoundUrl:va,getConfig:nr,hasActiveSession:Fs,hasMoreHistory:za,hasSuspendedSession:pl,isAgentPending:Ua,isConnected:Kr,isCreatingSession:Fa,isFilePickerActive:_a,isInterrupted:La,isLoadingMoreHistory:Ba,isLoadingSession:fs,isReadOnly:us,isResyncing:io,isStreaming:oo,joinSession:Sa,leaveSession:Dn,loadMoreHistory:Aa,messages:Da,piState:Pt,ping:bl,resendMessage:ya,resolveConflict:zs,resume:Ns,runSearch:Ta,sendMessage:Us,sendSudoPassword:Ra,sessionError:ao,sessionNotice:Oa,setBeepDefault:fl,setBeepSessionKey:ma,setBeepSessionOverride:ts,setBeepSoundUrl:ul,setConfig:Bs,state:ds,sudoPrompt:Na,suspend:ga,switchSession:so,updateConfig:Ca,uploadFile:Wa},Symbol.toStringTag,{value:"Module"}));var wl=g('<button class="flex-1 rounded bg-rose-500 px-4 py-2 text-sm text-white transition-colors hover:bg-rose-600">Disconnect</button>'),kl=g('<button class="flex-1 rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-4 py-2 text-sm text-white transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:from-brand-surface-3 disabled:to-brand-surface-3"></button>'),Sl=g('<div class="border-b border-brand-border p-4"><div class="space-y-3"><div><label for="pi-host" class="mb-1 block text-xs text-brand-text-muted">Host</label> <input id="pi-host" type="text" placeholder="localhost" class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/></div> <div><label for="pi-port" class="mb-1 block text-xs text-brand-text-muted">Port</label> <input id="pi-port" type="number" class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/></div> <div><label for="pi-token" class="mb-1 block text-xs text-brand-text-muted">Token (optional)</label> <input id="pi-token" type="password" placeholder="Authentication token" class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/></div> <div class="flex items-center gap-2 py-1"><input id="pi-hide-thinking" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-0"/> <label for="pi-hide-thinking" class="cursor-pointer text-xs text-brand-text select-none">Hide thinking steps</label></div> <div class="flex items-center gap-2 py-1"><input id="pi-beep-default" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-0"/> <label for="pi-beep-default" class="cursor-pointer text-xs text-brand-text select-none">Beep when the agent is waiting (default for new sessions)</label></div> <div><label for="pi-beep-sound" class="mb-1 block text-xs text-brand-text-muted">Beep sound URL (optional, blank = built-in chime)</label> <div class="flex gap-2"><input id="pi-beep-sound" type="text" placeholder="/sounds/complete.mp3 or https://..." class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/> <button type="button" title="Play the beep to test it" class="flex-shrink-0 rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text transition-colors hover:bg-brand-surface-3">Test</button></div></div> <div class="flex gap-2"><!></div> <button title="Reload the page" class="flex w-full items-center justify-center gap-2 rounded border border-brand-border bg-brand-surface-2 px-4 py-2 text-sm text-brand-text transition-colors hover:bg-brand-surface-3"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" aria-hidden="true"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"></path><path d="M8 16H3v5"></path></svg> Reload</button></div></div>');function Tl(n,e){er(e,!0);const r=()=>Me(Kr,"$isConnected",s),[s,o]=_r();let a=G(""),l=G(0),c=G(""),_=G(!1),m=G(!1),x=G(""),I=!1,P=K(r);qr(()=>{const we=nr();p(a,we.host,!0),p(l,we.port,!0),p(c,we.token||"",!0),p(_,!!we.hideThinking),p(m,!!we.beepDefault),p(x,we.beepSoundUrl||"",!0)});function O(){la(t(x).trim()||void 0)}function k(){Bs({host:t(a),port:t(l),token:t(c),hideThinking:t(_),hideTools:!1,beepDefault:t(m),beepSoundUrl:t(x).trim()})}function q(){Bs({host:t(a),port:t(l),token:t(c),hideThinking:t(_),hideTools:!1,beepDefault:t(m),beepSoundUrl:t(x).trim()}),jr(),setTimeout(()=>mr(),100)}function te(){jr()}function de(){window.location.reload()}var re=Sl(),je=u(re),_e=u(je),$e=f(u(_e),2);at($e),d(_e);var fe=f(_e,2),Le=f(u(fe),2);at(Le),d(fe);var Ee=f(fe,2),Et=f(u(Ee),2);at(Et),d(Ee);var it=f(Ee,2),ue=u(it);at(ue),et(2),d(it);var Ve=f(it,2),Bt=u(Ve);at(Bt),et(2),d(Ve);var He=f(Ve,2),lt=f(u(He),2),kt=u(lt);at(kt);var tt=f(kt,2);d(lt),d(He);var nt=f(He,2),ge=u(nt);{var ct=we=>{var ht=wl();H("click",ht,te),h(we,ht)},De=we=>{var ht=kl();ht.disabled=I,ht.textContent="Connect",H("click",ht,q),h(we,ht)};E(ge,we=>{t(P)?we(ct):we(De,-1)})}d(nt);var St=f(nt,2);d(je),d(re),Ln($e,()=>t(a),we=>p(a,we)),Ln(Le,()=>t(l),we=>p(l,we)),Ln(Et,()=>t(c),we=>p(c,we)),H("change",ue,k),On(ue,()=>t(_),we=>p(_,we)),H("change",Bt,k),On(Bt,()=>t(m),we=>p(m,we)),H("change",kt,k),Ln(kt,()=>t(x),we=>p(x,we)),H("click",tt,O),H("click",St,de),h(n,re),tr(),o()}dr(["change","click"]);function lo(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var yr=lo();function Ga(n){yr=n}var Wr={exec:()=>null};function vt(n,e=""){let r=typeof n=="string"?n:n.source;const s={replace:(o,a)=>{let l=typeof a=="string"?a:a.source;return l=l.replace(bn.caret,"$1"),r=r.replace(o,l),s},getRegex:()=>new RegExp(r,e)};return s}var bn={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i")},Al=/^(?:[ \t]*(?:\n|$))+/,El=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Cl=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Zr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Il=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,co=/(?:[*+-]|\d{1,9}[.)])/,ja=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,qa=vt(ja).replace(/bull/g,co).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Rl=vt(ja).replace(/bull/g,co).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),uo=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,$l=/^[^\n]+/,fo=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ml=vt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",fo).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Dl=vt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,co).getRegex(),ps="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",po=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Pl=vt("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",po).replace("tag",ps).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Va=vt(uo).replace("hr",Zr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex(),Ll=vt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Va).getRegex(),ho={blockquote:Ll,code:El,def:Ml,fences:Cl,heading:Il,hr:Zr,html:Pl,lheading:qa,list:Dl,newline:Al,paragraph:Va,table:Wr,text:$l},Do=vt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Zr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex(),Ol={...ho,lheading:Rl,table:Do,paragraph:vt(uo).replace("hr",Zr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Do).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex()},Nl={...ho,html:vt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",po).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Wr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:vt(uo).replace("hr",Zr).replace("heading",` *#{1,6} *[^
|
|
11
|
+
]`).replace("lheading",qa).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Fl=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ul=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ka=/^( {2,}|\\)\n(?!\s*$)/,zl=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,hs=/[\p{P}\p{S}]/u,bo=/[\s\p{P}\p{S}]/u,Ya=/[^\s\p{P}\p{S}]/u,Bl=vt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,bo).getRegex(),Za=/(?!~)[\p{P}\p{S}]/u,Hl=/(?!~)[\s\p{P}\p{S}]/u,Wl=/(?:[^\s\p{P}\p{S}]|~)/u,Gl=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Xa=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,jl=vt(Xa,"u").replace(/punct/g,hs).getRegex(),ql=vt(Xa,"u").replace(/punct/g,Za).getRegex(),Qa="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Vl=vt(Qa,"gu").replace(/notPunctSpace/g,Ya).replace(/punctSpace/g,bo).replace(/punct/g,hs).getRegex(),Kl=vt(Qa,"gu").replace(/notPunctSpace/g,Wl).replace(/punctSpace/g,Hl).replace(/punct/g,Za).getRegex(),Yl=vt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ya).replace(/punctSpace/g,bo).replace(/punct/g,hs).getRegex(),Zl=vt(/\\(punct)/,"gu").replace(/punct/g,hs).getRegex(),Xl=vt(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ql=vt(po).replace("(?:-->|$)","-->").getRegex(),Jl=vt("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ql).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),os=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ec=vt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",os).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ja=vt(/^!?\[(label)\]\[(ref)\]/).replace("label",os).replace("ref",fo).getRegex(),ei=vt(/^!?\[(ref)\](?:\[\])?/).replace("ref",fo).getRegex(),tc=vt("reflink|nolink(?!\\()","g").replace("reflink",Ja).replace("nolink",ei).getRegex(),vo={_backpedal:Wr,anyPunctuation:Zl,autolink:Xl,blockSkip:Gl,br:Ka,code:Ul,del:Wr,emStrongLDelim:jl,emStrongRDelimAst:Vl,emStrongRDelimUnd:Yl,escape:Fl,link:ec,nolink:ei,punctuation:Bl,reflink:Ja,reflinkSearch:tc,tag:Jl,text:zl,url:Wr},nc={...vo,link:vt(/^!?\[(label)\]\((.*?)\)/).replace("label",os).getRegex(),reflink:vt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",os).getRegex()},Ws={...vo,emStrongRDelimAst:Kl,emStrongLDelim:ql,url:vt(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},rc={...Ws,br:vt(Ka).replace("{2,}","*").getRegex(),text:vt(Ws.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Qr={normal:ho,gfm:Ol,pedantic:Nl},Mr={normal:vo,gfm:Ws,breaks:rc,pedantic:nc},sc={"&":"&","<":"<",">":">",'"':""","'":"'"},Po=n=>sc[n];function Wn(n,e){if(e){if(bn.escapeTest.test(n))return n.replace(bn.escapeReplace,Po)}else if(bn.escapeTestNoEncode.test(n))return n.replace(bn.escapeReplaceNoEncode,Po);return n}function Lo(n){try{n=encodeURI(n).replace(bn.percentDecode,"%")}catch{return null}return n}function Oo(n,e){const r=n.replace(bn.findPipe,(a,l,c)=>{let _=!1,m=l;for(;--m>=0&&c[m]==="\\";)_=!_;return _?"|":" |"}),s=r.split(bn.splitPipe);let o=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;o<s.length;o++)s[o]=s[o].trim().replace(bn.slashPipe,"|");return s}function Dr(n,e,r){const s=n.length;if(s===0)return"";let o=0;for(;o<s&&n.charAt(s-o-1)===e;)o++;return n.slice(0,s-o)}function oc(n,e){if(n.indexOf(e[1])===-1)return-1;let r=0;for(let s=0;s<n.length;s++)if(n[s]==="\\")s++;else if(n[s]===e[0])r++;else if(n[s]===e[1]&&(r--,r<0))return s;return r>0?-2:-1}function No(n,e,r,s,o){const a=e.href,l=e.title||null,c=n[1].replace(o.other.outputLinkReplace,"$1");s.state.inLink=!0;const _={type:n[0].charAt(0)==="!"?"image":"link",raw:r,href:a,title:l,text:c,tokens:s.inlineTokens(c)};return s.state.inLink=!1,_}function ac(n,e,r){const s=n.match(r.other.indentCodeCompensation);if(s===null)return e;const o=s[1];return e.split(`
|
|
12
12
|
`).map(a=>{const l=a.match(r.other.beginningSpace);if(l===null)return a;const[c]=l;return c.length>=o.length?a.slice(o.length):a}).join(`
|
|
13
13
|
`)}var as=class{options;rules;lexer;constructor(n){this.options=n||yr}space(n){const e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){const e=this.rules.block.code.exec(n);if(e){const r=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Dr(r,`
|
|
14
14
|
`)}}}fences(n){const e=this.rules.block.fences.exec(n);if(e){const r=e[0],s=ac(r,e[3]||"",this.rules);return{type:"code",raw:r,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(n){const e=this.rules.block.heading.exec(n);if(e){let r=e[2].trim();if(this.rules.other.endingHash.test(r)){const s=Dr(r,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(r=s.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(n){const e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:Dr(e[0],`
|
|
@@ -43,15 +43,15 @@ ${x}`:x;const I=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
|
|
|
43
43
|
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):r.push(o),s=a.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length);const l=r.at(-1);l?.type==="text"?(l.raw+=`
|
|
44
44
|
`+o.raw,l.text+=`
|
|
45
45
|
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):r.push(o);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}inlineTokens(e,r=[]){let s=e,o=null;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)c.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,o.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(o=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let a=!1,l="";for(;e;){a||(l=""),a=!1;let c;if(this.options.extensions?.inline?.some(m=>(c=m.call({lexer:this},e,r))?(e=e.substring(c.raw.length),r.push(c),!0):!1))continue;if(c=this.tokenizer.escape(e)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.tag(e)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.link(e)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(c.raw.length);const m=r.at(-1);c.type==="text"&&m?.type==="text"?(m.raw+=c.raw,m.text+=c.text):r.push(c);continue}if(c=this.tokenizer.emStrong(e,s,l)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.codespan(e)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.br(e)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.del(e)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.autolink(e)){e=e.substring(c.raw.length),r.push(c);continue}if(!this.state.inLink&&(c=this.tokenizer.url(e))){e=e.substring(c.raw.length),r.push(c);continue}let _=e;if(this.options.extensions?.startInline){let m=1/0;const x=e.slice(1);let I;this.options.extensions.startInline.forEach(P=>{I=P.call({lexer:this},x),typeof I=="number"&&I>=0&&(m=Math.min(m,I))}),m<1/0&&m>=0&&(_=e.substring(0,m+1))}if(c=this.tokenizer.inlineText(_)){e=e.substring(c.raw.length),c.raw.slice(-1)!=="_"&&(l=c.raw.slice(-1)),a=!0;const m=r.at(-1);m?.type==="text"?(m.raw+=c.raw,m.text+=c.text):r.push(c);continue}if(e){const m="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(m);break}else throw new Error(m)}}return r}},is=class{options;parser;constructor(n){this.options=n||yr}space(n){return""}code({text:n,lang:e,escaped:r}){const s=(e||"").match(bn.notSpaceStart)?.[0],o=n.replace(bn.endingNewline,"")+`
|
|
46
|
-
`;return s?'<pre><code class="language-'+
|
|
47
|
-
`:"<pre><code>"+(r?o:
|
|
46
|
+
`;return s?'<pre><code class="language-'+Wn(s)+'">'+(r?o:Wn(o,!0))+`</code></pre>
|
|
47
|
+
`:"<pre><code>"+(r?o:Wn(o,!0))+`</code></pre>
|
|
48
48
|
`}blockquote({tokens:n}){return`<blockquote>
|
|
49
49
|
${this.parser.parse(n)}</blockquote>
|
|
50
50
|
`}html({text:n}){return n}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
|
|
51
51
|
`}hr(n){return`<hr>
|
|
52
52
|
`}list(n){const e=n.ordered,r=n.start;let s="";for(let l=0;l<n.items.length;l++){const c=n.items[l];s+=this.listitem(c)}const o=e?"ol":"ul",a=e&&r!==1?' start="'+r+'"':"";return"<"+o+a+`>
|
|
53
53
|
`+s+"</"+o+`>
|
|
54
|
-
`}listitem(n){let e="";if(n.task){const r=this.checkbox({checked:!!n.checked});n.loose?n.tokens[0]?.type==="paragraph"?(n.tokens[0].text=r+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type==="text"&&(n.tokens[0].tokens[0].text=r+" "+
|
|
54
|
+
`}listitem(n){let e="";if(n.task){const r=this.checkbox({checked:!!n.checked});n.loose?n.tokens[0]?.type==="paragraph"?(n.tokens[0].text=r+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type==="text"&&(n.tokens[0].tokens[0].text=r+" "+Wn(n.tokens[0].tokens[0].text),n.tokens[0].tokens[0].escaped=!0)):n.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):e+=r+" "}return e+=this.parser.parse(n.tokens,!!n.loose),`<li>${e}</li>
|
|
55
55
|
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
56
56
|
`}table(n){let e="",r="";for(let o=0;o<n.header.length;o++)r+=this.tablecell(n.header[o]);e+=this.tablerow({text:r});let s="";for(let o=0;o<n.rows.length;o++){const a=n.rows[o];r="";for(let l=0;l<a.length;l++)r+=this.tablecell(a[l]);s+=this.tablerow({text:r})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
57
57
|
<thead>
|
|
@@ -60,10 +60,10 @@ ${this.parser.parse(n)}</blockquote>
|
|
|
60
60
|
`}tablerow({text:n}){return`<tr>
|
|
61
61
|
${n}</tr>
|
|
62
62
|
`}tablecell(n){const e=this.parser.parseInline(n.tokens),r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+e+`</${r}>
|
|
63
|
-
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${
|
|
63
|
+
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${Wn(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:r}){const s=this.parser.parseInline(r),o=Lo(n);if(o===null)return s;n=o;let a='<a href="'+n+'"';return e&&(a+=' title="'+Wn(e)+'"'),a+=">"+s+"</a>",a}image({href:n,title:e,text:r,tokens:s}){s&&(r=this.parser.parseInline(s,this.parser.textRenderer));const o=Lo(n);if(o===null)return Wn(r);n=o;let a=`<img src="${n}" alt="${r}"`;return e&&(a+=` title="${Wn(e)}"`),a+=">",a}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:Wn(n.text)}},mo=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}},Jn=class js{options;renderer;textRenderer;constructor(e){this.options=e||yr,this.options.renderer=this.options.renderer||new is,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new mo}static parse(e,r){return new js(r).parse(e)}static parseInline(e,r){return new js(r).parseInline(e)}parse(e,r=!0){let s="";for(let o=0;o<e.length;o++){const a=e[o];if(this.options.extensions?.renderers?.[a.type]){const c=a,_=this.options.extensions.renderers[c.type].call({parser:this},c);if(_!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(c.type)){s+=_||"";continue}}const l=a;switch(l.type){case"space":{s+=this.renderer.space(l);continue}case"hr":{s+=this.renderer.hr(l);continue}case"heading":{s+=this.renderer.heading(l);continue}case"code":{s+=this.renderer.code(l);continue}case"table":{s+=this.renderer.table(l);continue}case"blockquote":{s+=this.renderer.blockquote(l);continue}case"list":{s+=this.renderer.list(l);continue}case"html":{s+=this.renderer.html(l);continue}case"paragraph":{s+=this.renderer.paragraph(l);continue}case"text":{let c=l,_=this.renderer.text(c);for(;o+1<e.length&&e[o+1].type==="text";)c=e[++o],_+=`
|
|
64
64
|
`+this.renderer.text(c);r?s+=this.renderer.paragraph({type:"paragraph",raw:_,text:_,tokens:[{type:"text",raw:_,text:_,escaped:!0}]}):s+=_;continue}default:{const c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}parseInline(e,r=this.renderer){let s="";for(let o=0;o<e.length;o++){const a=e[o];if(this.options.extensions?.renderers?.[a.type]){const c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=c||"";continue}}const l=a;switch(l.type){case"escape":{s+=r.text(l);break}case"html":{s+=r.html(l);break}case"link":{s+=r.link(l);break}case"image":{s+=r.image(l);break}case"strong":{s+=r.strong(l);break}case"em":{s+=r.em(l);break}case"codespan":{s+=r.codespan(l);break}case"br":{s+=r.br(l);break}case"del":{s+=r.del(l);break}case"text":{s+=r.text(l);break}default:{const c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},ns=class{options;block;constructor(n){this.options=n||yr}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Qn.lex:Qn.lexInline}provideParser(){return this.block?Jn.parse:Jn.parseInline}},ic=class{defaults=lo();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Jn;Renderer=is;TextRenderer=mo;Lexer=Qn;Tokenizer=as;Hooks=ns;constructor(...n){this.use(...n)}walkTokens(n,e){let r=[];for(const s of n)switch(r=r.concat(e.call(this,s)),s.type){case"table":{const o=s;for(const a of o.header)r=r.concat(this.walkTokens(a.tokens,e));for(const a of o.rows)for(const l of a)r=r.concat(this.walkTokens(l.tokens,e));break}case"list":{const o=s;r=r.concat(this.walkTokens(o.items,e));break}default:{const o=s;this.defaults.extensions?.childTokens?.[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{const l=o[a].flat(1/0);r=r.concat(this.walkTokens(l,e))}):o.tokens&&(r=r.concat(this.walkTokens(o.tokens,e)))}}return r}use(...n){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(r=>{const s={...r};if(s.async=this.defaults.async||s.async||!1,r.extensions&&(r.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){const a=e.renderers[o.name];a?e.renderers[o.name]=function(...l){let c=o.renderer.apply(this,l);return c===!1&&(c=a.apply(this,l)),c}:e.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const a=e[o.level];a?a.unshift(o.tokenizer):e[o.level]=[o.tokenizer],o.start&&(o.level==="block"?e.startBlock?e.startBlock.push(o.start):e.startBlock=[o.start]:o.level==="inline"&&(e.startInline?e.startInline.push(o.start):e.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(e.childTokens[o.name]=o.childTokens)}),s.extensions=e),r.renderer){const o=this.defaults.renderer||new is(this.defaults);for(const a in r.renderer){if(!(a in o))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;const l=a,c=r.renderer[l],_=o[l];o[l]=(...m)=>{let x=c.apply(o,m);return x===!1&&(x=_.apply(o,m)),x||""}}s.renderer=o}if(r.tokenizer){const o=this.defaults.tokenizer||new as(this.defaults);for(const a in r.tokenizer){if(!(a in o))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;const l=a,c=r.tokenizer[l],_=o[l];o[l]=(...m)=>{let x=c.apply(o,m);return x===!1&&(x=_.apply(o,m)),x}}s.tokenizer=o}if(r.hooks){const o=this.defaults.hooks||new ns;for(const a in r.hooks){if(!(a in o))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;const l=a,c=r.hooks[l],_=o[l];ns.passThroughHooks.has(a)?o[l]=m=>{if(this.defaults.async)return Promise.resolve(c.call(o,m)).then(I=>_.call(o,I));const x=c.call(o,m);return _.call(o,x)}:o[l]=(...m)=>{let x=c.apply(o,m);return x===!1&&(x=_.apply(o,m)),x}}s.hooks=o}if(r.walkTokens){const o=this.defaults.walkTokens,a=r.walkTokens;s.walkTokens=function(l){let c=[];return c.push(a.call(this,l)),o&&(c=c.concat(o.call(this,l))),c}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return Qn.lex(n,e??this.defaults)}parser(n,e){return Jn.parse(n,e??this.defaults)}parseMarkdown(n){return(r,s)=>{const o={...s},a={...this.defaults,...o},l=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&o.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=n);const c=a.hooks?a.hooks.provideLexer():n?Qn.lex:Qn.lexInline,_=a.hooks?a.hooks.provideParser():n?Jn.parse:Jn.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(r):r).then(m=>c(m,a)).then(m=>a.hooks?a.hooks.processAllTokens(m):m).then(m=>a.walkTokens?Promise.all(this.walkTokens(m,a.walkTokens)).then(()=>m):m).then(m=>_(m,a)).then(m=>a.hooks?a.hooks.postprocess(m):m).catch(l);try{a.hooks&&(r=a.hooks.preprocess(r));let m=c(r,a);a.hooks&&(m=a.hooks.processAllTokens(m)),a.walkTokens&&this.walkTokens(m,a.walkTokens);let x=_(m,a);return a.hooks&&(x=a.hooks.postprocess(x)),x}catch(m){return l(m)}}}onError(n,e){return r=>{if(r.message+=`
|
|
65
|
-
Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An error occurred:</p><pre>"+
|
|
66
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uc(n,e){return lc(n)||cc(n,e)||fc(n,e)||dc()}function fc(n,e){if(n){if(typeof n=="string")return Fo(n,e);var r={}.toString.call(n).slice(8,-1);return r==="Object"&&n.constructor&&(r=n.constructor.name),r==="Map"||r==="Set"?Array.from(n):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Fo(n,e):void 0}}const ti=Object.entries,Uo=Object.setPrototypeOf,pc=Object.isFrozen,hc=Object.getPrototypeOf,bc=Object.getOwnPropertyDescriptor;let an=Object.freeze,ln=Object.seal,Tr=Object.create,ni=typeof Reflect<"u"&&Reflect,qs=ni.apply,Vs=ni.construct;an||(an=function(e){return e});ln||(ln=function(e){return e});qs||(qs=function(e,r){for(var s=arguments.length,o=new Array(s>2?s-2:0),a=2;a<s;a++)o[a-2]=arguments[a];return e.apply(r,o)});Vs||(Vs=function(e){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return new e(...s)});const Pr=Kt(Array.prototype.forEach),vc=Kt(Array.prototype.lastIndexOf),zo=Kt(Array.prototype.pop),kr=Kt(Array.prototype.push),mc=Kt(Array.prototype.splice),ir=Array.isArray,Ur=Kt(String.prototype.toLowerCase),Es=Kt(String.prototype.toString),Bo=Kt(String.prototype.match),Lr=Kt(String.prototype.replace),Ho=Kt(String.prototype.indexOf),gc=Kt(String.prototype.trim),xc=Kt(Number.prototype.toString),_c=Kt(Boolean.prototype.toString),Wo=typeof BigInt>"u"?null:Kt(BigInt.prototype.toString),Go=typeof Symbol>"u"?null:Kt(Symbol.prototype.toString),rn=Kt(Object.prototype.hasOwnProperty),Or=Kt(Object.prototype.toString),on=Kt(RegExp.prototype.test),br=yc(TypeError);function Kt(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return qs(n,e,s)}}function yc(n){return function(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return Vs(n,r)}}function Ye(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ur;if(Uo&&Uo(n,null),!ir(e))return n;let s=e.length;for(;s--;){let o=e[s];if(typeof o=="string"){const a=r(o);a!==o&&(pc(e)||(e[s]=a),o=a)}n[o]=!0}return n}function wc(n){for(let e=0;e<n.length;e++)rn(n,e)||(n[e]=null);return n}function hn(n){const e=Tr(null);for(const s of ti(n)){var r=uc(s,2);const o=r[0],a=r[1];rn(n,o)&&(ir(a)?e[o]=wc(a):a&&typeof a=="object"&&a.constructor===Object?e[o]=hn(a):e[o]=a)}return e}function kc(n){switch(typeof n){case"string":return n;case"number":return xc(n);case"boolean":return _c(n);case"bigint":return Wo?Wo(n):"0";case"symbol":return Go?Go(n):"Symbol()";case"undefined":return Or(n);case"function":case"object":{if(n===null)return Or(n);const e=n,r=Wn(e,"toString");if(typeof r=="function"){const s=r(e);return typeof s=="string"?s:Or(s)}return Or(n)}default:return Or(n)}}function Wn(n,e){for(;n!==null;){const s=bc(n,e);if(s){if(s.get)return Kt(s.get);if(typeof s.value=="function")return Kt(s.value)}n=hc(n)}function r(){return null}return r}function Sc(n){try{return on(n,""),!0}catch{return!1}}const jo=an(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Cs=an(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Is=an(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Tc=an(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Rs=an(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Ac=an(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),qo=an(["#text"]),Vo=an(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),$s=an(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ko=an(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Jr=an(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ec=ln(/{{[\w\W]*|^[\w\W]*}}/g),Cc=ln(/<%[\w\W]*|^[\w\W]*%>/g),Ic=ln(/\${[\w\W]*/g),Rc=ln(/^data-[\-\w.\u00B7-\uFFFF]+$/),$c=ln(/^aria-[\-\w]+$/),Yo=ln(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Mc=ln(/^(?:\w+script|data):/i),Dc=ln(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pc=ln(/^html$/i),Lc=ln(/^[a-z][.\w]*(-[.\w]+)+$/i),Zo=ln(/<[/\w!]/g),Oc=ln(/<[/\w]/g),Nc=ln(/<\/no(script|embed|frames)/i),Fc=ln(/\/>/i),Bn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Uc=function(){return typeof window>"u"?null:window},zc=function(e,r){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let s=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(s=r.getAttribute(o));const a="dompurify"+(s?"#"+s:"");try{return e.createPolicy(a,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Xo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},or=function(e,r,s,o){return rn(e,r)&&ir(e[r])?Ye(o.base?hn(o.base):{},e[r],o.transform):s};function ri(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Uc();const e=R=>ri(R);if(e.version="3.4.11",e.removed=[],!n||!n.document||n.document.nodeType!==Bn.document||!n.Element)return e.isSupported=!1,e;let r=n.document;const s=r,o=s.currentScript;n.DocumentFragment;const a=n.HTMLTemplateElement,l=n.Node,c=n.Element,_=n.NodeFilter,m=n.NamedNodeMap;m===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const x=n.DOMParser,I=n.trustedTypes,P=c.prototype,O=Wn(P,"cloneNode"),k=Wn(P,"remove"),q=Wn(P,"nextSibling"),te=Wn(P,"childNodes"),de=Wn(P,"parentNode"),re=Wn(P,"shadowRoot"),je=Wn(P,"attributes"),_e=l&&l.prototype?Wn(l.prototype,"nodeType"):null,$e=l&&l.prototype?Wn(l.prototype,"nodeName"):null;if(typeof a=="function"){const R=r.createElement("template");R.content&&R.content.ownerDocument&&(r=R.content.ownerDocument)}let fe,Le="",Ee,Et=!1,it=0;const ue=function(){if(it>0)throw br('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ve=function(i){ue(),it++;try{return fe.createHTML(i)}finally{it--}},Bt=function(i){ue(),it++;try{return fe.createScriptURL(i)}finally{it--}},He=function(){return Et||(Ee=zc(I,o),Et=!0),Ee},lt=r,kt=lt.implementation,tt=lt.createNodeIterator,nt=lt.createDocumentFragment,ge=lt.getElementsByTagName,ct=s.importNode;let De=Xo();e.isSupported=typeof ti=="function"&&typeof de=="function"&&kt&&kt.createHTMLDocument!==void 0;const St=Ec,we=Cc,ht=Ic,Yt=Rc,gt=$c,xe=Mc,en=Dc,J=Lc;let pe=Yo,T=null;const F=Ye({},[...jo,...Cs,...Is,...Rs,...qo]);let A=null;const ae=Ye({},[...Vo,...$s,...Ko,...Jr]);let z=Object.seal(Tr(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),be=null,he=null;const We=Object.seal(Tr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Oe=!0,rt=!0,xt=!1,Ge=!0,Ue=!1,Ht=!0,Gt=!1,fn=!1,pn=null,Tt=null,yt=!1,Ze=!1,tn=!1,Zt=!1,Xt=!0,kn=!1;const le="user-content-";let dt=!0,Ft=!1,At={},mt=null;const Qt=Ye({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let jt=null;const xn=Ye({},["audio","video","img","source","image","track"]);let _n=null;const Cn=Ye({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),D="http://www.w3.org/1998/Math/MathML",V="http://www.w3.org/2000/svg",Y="http://www.w3.org/1999/xhtml";let X=Y,ye=!1,Wt=null;const Ct=Ye({},[D,V,Y],Es),Lt=an(["mi","mo","mn","ms","mtext"]);let It=Ye({},Lt);const Ot=an(["annotation-xml"]);let M=Ye({},Ot);const N=Ye({},["title","style","font","a","script"]);let ve=null;const ke=["application/xhtml+xml","text/html"],Pe="text/html";let ne=null,se=null;const Ce=r.createElement("form"),Se=function(i){return i instanceof RegExp||i instanceof Function},bt=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(se&&se===i)return;(!i||typeof i!="object")&&(i={}),i=hn(i),ve=ke.indexOf(i.PARSER_MEDIA_TYPE)===-1?Pe:i.PARSER_MEDIA_TYPE,ne=ve==="application/xhtml+xml"?Es:Ur,T=or(i,"ALLOWED_TAGS",F,{transform:ne}),A=or(i,"ALLOWED_ATTR",ae,{transform:ne}),Wt=or(i,"ALLOWED_NAMESPACES",Ct,{transform:Es}),_n=or(i,"ADD_URI_SAFE_ATTR",Cn,{transform:ne,base:Cn}),jt=or(i,"ADD_DATA_URI_TAGS",xn,{transform:ne,base:xn}),mt=or(i,"FORBID_CONTENTS",Qt,{transform:ne}),be=or(i,"FORBID_TAGS",hn({}),{transform:ne}),he=or(i,"FORBID_ATTR",hn({}),{transform:ne}),At=rn(i,"USE_PROFILES")?i.USE_PROFILES&&typeof i.USE_PROFILES=="object"?hn(i.USE_PROFILES):i.USE_PROFILES:!1,Oe=i.ALLOW_ARIA_ATTR!==!1,rt=i.ALLOW_DATA_ATTR!==!1,xt=i.ALLOW_UNKNOWN_PROTOCOLS||!1,Ge=i.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ue=i.SAFE_FOR_TEMPLATES||!1,Ht=i.SAFE_FOR_XML!==!1,Gt=i.WHOLE_DOCUMENT||!1,Ze=i.RETURN_DOM||!1,tn=i.RETURN_DOM_FRAGMENT||!1,Zt=i.RETURN_TRUSTED_TYPE||!1,yt=i.FORCE_BODY||!1,Xt=i.SANITIZE_DOM!==!1,kn=i.SANITIZE_NAMED_PROPS||!1,dt=i.KEEP_CONTENT!==!1,Ft=i.IN_PLACE||!1,pe=Sc(i.ALLOWED_URI_REGEXP)?i.ALLOWED_URI_REGEXP:Yo,X=typeof i.NAMESPACE=="string"?i.NAMESPACE:Y,It=rn(i,"MATHML_TEXT_INTEGRATION_POINTS")&&i.MATHML_TEXT_INTEGRATION_POINTS&&typeof i.MATHML_TEXT_INTEGRATION_POINTS=="object"?hn(i.MATHML_TEXT_INTEGRATION_POINTS):Ye({},Lt),M=rn(i,"HTML_INTEGRATION_POINTS")&&i.HTML_INTEGRATION_POINTS&&typeof i.HTML_INTEGRATION_POINTS=="object"?hn(i.HTML_INTEGRATION_POINTS):Ye({},Ot);const v=rn(i,"CUSTOM_ELEMENT_HANDLING")&&i.CUSTOM_ELEMENT_HANDLING&&typeof i.CUSTOM_ELEMENT_HANDLING=="object"?hn(i.CUSTOM_ELEMENT_HANDLING):Tr(null);if(z=Tr(null),rn(v,"tagNameCheck")&&Se(v.tagNameCheck)&&(z.tagNameCheck=v.tagNameCheck),rn(v,"attributeNameCheck")&&Se(v.attributeNameCheck)&&(z.attributeNameCheck=v.attributeNameCheck),rn(v,"allowCustomizedBuiltInElements")&&typeof v.allowCustomizedBuiltInElements=="boolean"&&(z.allowCustomizedBuiltInElements=v.allowCustomizedBuiltInElements),ln(z),Ue&&(rt=!1),tn&&(Ze=!0),At&&(T=Ye({},qo),A=Tr(null),At.html===!0&&(Ye(T,jo),Ye(A,Vo)),At.svg===!0&&(Ye(T,Cs),Ye(A,$s),Ye(A,Jr)),At.svgFilters===!0&&(Ye(T,Is),Ye(A,$s),Ye(A,Jr)),At.mathMl===!0&&(Ye(T,Rs),Ye(A,Ko),Ye(A,Jr))),We.tagCheck=null,We.attributeCheck=null,rn(i,"ADD_TAGS")&&(typeof i.ADD_TAGS=="function"?We.tagCheck=i.ADD_TAGS:ir(i.ADD_TAGS)&&(T===F&&(T=hn(T)),Ye(T,i.ADD_TAGS,ne))),rn(i,"ADD_ATTR")&&(typeof i.ADD_ATTR=="function"?We.attributeCheck=i.ADD_ATTR:ir(i.ADD_ATTR)&&(A===ae&&(A=hn(A)),Ye(A,i.ADD_ATTR,ne))),rn(i,"ADD_URI_SAFE_ATTR")&&ir(i.ADD_URI_SAFE_ATTR)&&Ye(_n,i.ADD_URI_SAFE_ATTR,ne),rn(i,"FORBID_CONTENTS")&&ir(i.FORBID_CONTENTS)&&(mt===Qt&&(mt=hn(mt)),Ye(mt,i.FORBID_CONTENTS,ne)),rn(i,"ADD_FORBID_CONTENTS")&&ir(i.ADD_FORBID_CONTENTS)&&(mt===Qt&&(mt=hn(mt)),Ye(mt,i.ADD_FORBID_CONTENTS,ne)),dt&&(T["#text"]=!0),Gt&&Ye(T,["html","head","body"]),T.table&&(Ye(T,["tbody"]),delete be.tbody),i.TRUSTED_TYPES_POLICY){if(typeof i.TRUSTED_TYPES_POLICY.createHTML!="function")throw br('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof i.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw br('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const y=fe;fe=i.TRUSTED_TYPES_POLICY;try{Le=Ve("")}catch(C){throw fe=y,C}}else i.TRUSTED_TYPES_POLICY===null?(fe=void 0,Le=""):(fe===void 0&&(fe=He()),fe&&typeof Le=="string"&&(Le=Ve("")));an&&an(i),se=i},qt=Ye({},[...Cs,...Is,...Tc]),cn=Ye({},[...Rs,...Ac]),dn=function(i,v,y){return v.namespaceURI===Y?i==="svg":v.namespaceURI===D?i==="svg"&&(y==="annotation-xml"||It[y]):!!qt[i]},wt=function(i,v,y){return v.namespaceURI===Y?i==="math":v.namespaceURI===V?i==="math"&&M[y]:!!cn[i]},Ne=function(i,v,y){return v.namespaceURI===V&&!M[y]||v.namespaceURI===D&&!It[y]?!1:!cn[i]&&(N[i]||!qt[i])},ie=function(i){let v=de(i);(!v||!v.tagName)&&(v={namespaceURI:X,tagName:"template"});const y=Ur(i.tagName),C=Ur(v.tagName);return Wt[i.namespaceURI]?i.namespaceURI===V?dn(y,v,C):i.namespaceURI===D?wt(y,v,C):i.namespaceURI===Y?Ne(y,v,C):!!(ve==="application/xhtml+xml"&&Wt[i.namespaceURI]):!1},ce=function(i){kr(e.removed,{element:i});try{de(i).removeChild(i)}catch{if(k(i),!de(i))throw br("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Fe=function(i){const v=te(i);if(v){const C=[];Pr(v,j=>{kr(C,j)}),Pr(C,j=>{try{k(j)}catch{}})}const y=je(i);if(y)for(let C=y.length-1;C>=0;--C){const j=y[C],U=j&&j.name;if(typeof U=="string")try{i.removeAttribute(U)}catch{}}},b=function(i,v){try{kr(e.removed,{attribute:v.getAttributeNode(i),from:v})}catch{kr(e.removed,{attribute:null,from:v})}if(v.removeAttribute(i),i==="is")if(Ze||tn)try{ce(v)}catch{}else try{v.setAttribute(i,"")}catch{}},w=function(i){const v=je(i);if(v)for(let y=v.length-1;y>=0;--y){const C=v[y],j=C&&C.name;if(!(typeof j!="string"||A[ne(j)]))try{i.removeAttribute(j)}catch{}}},L=function(i){const v=[i];for(;v.length>0;){const y=v.pop();(_e?_e(y):y.nodeType)===Bn.element&&w(y);const j=te(y);if(j)for(let U=j.length-1;U>=0;--U)v.push(j[U])}},$=function(i){let v=null,y=null;if(yt)i="<remove></remove>"+i;else{const U=Bo(i,/^[\r\n\t ]+/);y=U&&U[0]}ve==="application/xhtml+xml"&&X===Y&&(i='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+i+"</body></html>");const C=fe?Ve(i):i;if(X===Y)try{v=new x().parseFromString(C,ve)}catch{}if(!v||!v.documentElement){v=kt.createDocument(X,"template",null);try{v.documentElement.innerHTML=ye?Le:C}catch{}}const j=v.body||v.documentElement;return i&&y&&j.insertBefore(r.createTextNode(y),j.childNodes[0]||null),X===Y?ge.call(v,Gt?"html":"body")[0]:Gt?v.documentElement:j},W=function(i){return tt.call(i.ownerDocument||i,i,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},Q=function(i){return i=Lr(i,St," "),i=Lr(i,we," "),i=Lr(i,ht," "),i},S=function(i){var v;i.normalize();const y=tt.call(i.ownerDocument||i,i,_.SHOW_TEXT|_.SHOW_COMMENT|_.SHOW_CDATA_SECTION|_.SHOW_PROCESSING_INSTRUCTION,null);let C=y.nextNode();for(;C;)C.data=Q(C.data),C=y.nextNode();const j=(v=i.querySelectorAll)===null||v===void 0?void 0:v.call(i,"template");j&&Pr(j,U=>{Te(U.content)&&S(U.content)})},Ie=function(i){const v=$e?$e(i):null;return typeof v!="string"||ne(v)!=="form"?!1:typeof i.nodeName!="string"||typeof i.textContent!="string"||typeof i.removeChild!="function"||i.attributes!==je(i)||typeof i.removeAttribute!="function"||typeof i.setAttribute!="function"||typeof i.namespaceURI!="string"||typeof i.insertBefore!="function"||typeof i.hasChildNodes!="function"||i.nodeType!==_e(i)||i.childNodes!==te(i)},Te=function(i){if(!_e||typeof i!="object"||i===null)return!1;try{return _e(i)===Bn.documentFragment}catch{return!1}},Be=function(i){if(!_e||typeof i!="object"||i===null)return!1;try{return typeof _e(i)=="number"}catch{return!1}};function ut(R,i,v){R.length!==0&&Pr(R,y=>{y.call(e,i,v,se)})}const oe=function(i,v){return!!(Ht&&i.hasChildNodes()&&!Be(i.firstElementChild)&&on(Zo,i.textContent)&&on(Zo,i.innerHTML)||Ht&&i.namespaceURI===Y&&v==="style"&&Be(i.firstElementChild)||i.nodeType===Bn.processingInstruction||Ht&&i.nodeType===Bn.comment&&on(Oc,i.data))},Re=function(i,v){if(!be[v]&&Xe(v)&&(z.tagNameCheck instanceof RegExp&&on(z.tagNameCheck,v)||z.tagNameCheck instanceof Function&&z.tagNameCheck(v)))return!1;if(dt&&!mt[v]){const y=de(i),C=te(i);if(C&&y){const j=C.length;for(let U=j-1;U>=0;--U){const ee=Ft?C[U]:O(C[U],!0);y.insertBefore(ee,q(i))}}}return ce(i),!0},Ut=function(i){if(ut(De.beforeSanitizeElements,i,null),Ie(i))return ce(i),!0;const v=ne($e?$e(i):i.nodeName);if(ut(De.uponSanitizeElement,i,{tagName:v,allowedTags:T}),oe(i,v))return ce(i),!0;if(be[v]||!(We.tagCheck instanceof Function&&We.tagCheck(v))&&!T[v])return Re(i,v);if((_e?_e(i):i.nodeType)===Bn.element&&!ie(i)||(v==="noscript"||v==="noembed"||v==="noframes")&&on(Nc,i.innerHTML))return ce(i),!0;if(Ue&&i.nodeType===Bn.text){const C=Q(i.textContent);i.textContent!==C&&(kr(e.removed,{element:i.cloneNode()}),i.textContent=C)}return ut(De.afterSanitizeElements,i,null),!1},vn=function(i,v,y){if(he[v]||Xt&&(v==="id"||v==="name")&&(y in r||y in Ce))return!1;const C=A[v]||We.attributeCheck instanceof Function&&We.attributeCheck(v,i);if(!(rt&&on(Yt,v))){if(!(Oe&&on(gt,v))){if(C){if(!_n[v]){if(!on(pe,Lr(y,en,""))){if(!((v==="src"||v==="xlink:href"||v==="href")&&i!=="script"&&Ho(y,"data:")===0&&jt[i])){if(!(xt&&!on(xe,Lr(y,en,"")))){if(y)return!1}}}}}else if(!(Xe(i)&&(z.tagNameCheck instanceof RegExp&&on(z.tagNameCheck,i)||z.tagNameCheck instanceof Function&&z.tagNameCheck(i))&&(z.attributeNameCheck instanceof RegExp&&on(z.attributeNameCheck,v)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(v,i))||v==="is"&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&on(z.tagNameCheck,y)||z.tagNameCheck instanceof Function&&z.tagNameCheck(y))))return!1}}return!0},Sn=Ye({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Xe=function(i){return!Sn[Ur(i)]&&on(J,i)},st=function(i,v,y,C){if(fe&&typeof I=="object"&&typeof I.getAttributeType=="function"&&!y)switch(I.getAttributeType(i,v)){case"TrustedHTML":return Ve(C);case"TrustedScriptURL":return Bt(C)}return C},Ke=function(i,v,y,C){try{y?i.setAttributeNS(y,v,C):i.setAttribute(v,C),Ie(i)?ce(i):zo(e.removed)}catch{b(v,i)}},_t=function(i){ut(De.beforeSanitizeAttributes,i,null);const v=i.attributes;if(!v||Ie(i))return;const y={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:A,forceKeepAttr:void 0};let C=v.length;const j=ne(i.nodeName);for(;C--;){const U=v[C],ee=U.name,Ae=U.namespaceURI,Qe=U.value,ot=ne(ee),Mt=Qe;let qe=ee==="value"?Mt:gc(Mt);if(y.attrName=ot,y.attrValue=qe,y.keepAttr=!0,y.forceKeepAttr=void 0,ut(De.uponSanitizeAttribute,i,y),qe=y.attrValue,kn&&(ot==="id"||ot==="name")&&Ho(qe,le)!==0&&(b(ee,i),qe=le+qe),Ht&&on(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,qe)){b(ee,i);continue}if(ot==="attributename"&&Bo(qe,"href")){b(ee,i);continue}if(!y.forceKeepAttr){if(!y.keepAttr){b(ee,i);continue}if(!Ge&&on(Fc,qe)){b(ee,i);continue}if(Ue&&(qe=Q(qe)),!vn(j,ot,qe)){b(ee,i);continue}qe=st(j,ot,Ae,qe),qe!==Mt&&Ke(i,ee,Ae,qe)}}ut(De.afterSanitizeAttributes,i,null)},Rt=function(i){let v=null;const y=W(i);for(ut(De.beforeSanitizeShadowDOM,i,null);v=y.nextNode();)if(ut(De.uponSanitizeShadowNode,v,null),Ut(v),_t(v),Te(v.content)&&Rt(v.content),(_e?_e(v):v.nodeType)===Bn.element){const j=re(v);Te(j)&&($t(j),Rt(j))}ut(De.afterSanitizeShadowDOM,i,null)},$t=function(i){const v=[{node:i,shadow:null}];for(;v.length>0;){const y=v.pop();if(y.shadow){Rt(y.shadow);continue}const C=y.node,U=(_e?_e(C):C.nodeType)===Bn.element,ee=te(C);if(ee)for(let Ae=ee.length-1;Ae>=0;--Ae)v.push({node:ee[Ae],shadow:null});if(U){const Ae=$e?$e(C):null;if(typeof Ae=="string"&&ne(Ae)==="template"){const Qe=C.content;Te(Qe)&&v.push({node:Qe,shadow:null})}}if(U){const Ae=re(C);Te(Ae)&&v.push({node:null,shadow:Ae},{node:Ae,shadow:null})}}};return e.sanitize=function(R){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},v=null,y=null,C=null,j=null;if(ye=!R,ye&&(R="<!-->"),typeof R!="string"&&!Be(R)&&(R=kc(R),typeof R!="string"))throw br("dirty is not a string, aborting");if(!e.isSupported)return R;fn?(T=pn,A=Tt):bt(i),(De.uponSanitizeElement.length>0||De.uponSanitizeAttribute.length>0)&&(T=hn(T)),De.uponSanitizeAttribute.length>0&&(A=hn(A)),e.removed=[];const U=Ft&&typeof R!="string"&&Be(R);if(U){const Qe=$e?$e(R):R.nodeName;if(typeof Qe=="string"){const ot=ne(Qe);if(!T[ot]||be[ot])throw br("root node is forbidden and cannot be sanitized in-place")}if(Ie(R))throw br("root node is clobbered and cannot be sanitized in-place");try{$t(R)}catch(ot){throw Fe(R),ot}}else if(Be(R))v=$("<!---->"),y=v.ownerDocument.importNode(R,!0),y.nodeType===Bn.element&&y.nodeName==="BODY"||y.nodeName==="HTML"?v=y:v.appendChild(y),$t(y);else{if(!Ze&&!Ue&&!Gt&&R.indexOf("<")===-1)return fe&&Zt?Ve(R):R;if(v=$(R),!v)return Ze?null:Zt?Le:""}v&&yt&&ce(v.firstChild);const ee=W(U?R:v);try{for(;C=ee.nextNode();)Ut(C),_t(C),Te(C.content)&&Rt(C.content)}catch(Qe){throw U&&Fe(R),Qe}if(U)return Pr(e.removed,Qe=>{Qe.element&&L(Qe.element)}),Ue&&S(R),R;if(Ze){if(Ue&&S(v),tn)for(j=nt.call(v.ownerDocument);v.firstChild;)j.appendChild(v.firstChild);else j=v;return(A.shadowroot||A.shadowrootmode)&&(j=ct.call(s,j,!0)),j}let Ae=Gt?v.outerHTML:v.innerHTML;return Gt&&T["!doctype"]&&v.ownerDocument&&v.ownerDocument.doctype&&v.ownerDocument.doctype.name&&on(Pc,v.ownerDocument.doctype.name)&&(Ae="<!DOCTYPE "+v.ownerDocument.doctype.name+`>
|
|
65
|
+
Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An error occurred:</p><pre>"+Wn(r.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(r);throw r}}},xr=new ic;function ft(n,e){return xr.parse(n,e)}ft.options=ft.setOptions=function(n){return xr.setOptions(n),ft.defaults=xr.defaults,Ga(ft.defaults),ft};ft.getDefaults=lo;ft.defaults=yr;ft.use=function(...n){return xr.use(...n),ft.defaults=xr.defaults,Ga(ft.defaults),ft};ft.walkTokens=function(n,e){return xr.walkTokens(n,e)};ft.parseInline=xr.parseInline;ft.Parser=Jn;ft.parser=Jn.parse;ft.Renderer=is;ft.TextRenderer=mo;ft.Lexer=Qn;ft.lexer=Qn.lex;ft.Tokenizer=as;ft.Hooks=ns;ft.parse=ft;ft.options;ft.setOptions;ft.use;ft.walkTokens;ft.parseInline;Jn.parse;Qn.lex;function Fo(n,e){(e==null||e>n.length)&&(e=n.length);for(var r=0,s=Array(e);r<e;r++)s[r]=n[r];return s}function lc(n){if(Array.isArray(n))return n}function cc(n,e){var r=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(r!=null){var s,o,a,l,c=[],_=!0,m=!1;try{if(a=(r=r.call(n)).next,e!==0)for(;!(_=(s=a.call(r)).done)&&(c.push(s.value),c.length!==e);_=!0);}catch(x){m=!0,o=x}finally{try{if(!_&&r.return!=null&&(l=r.return(),Object(l)!==l))return}finally{if(m)throw o}}return c}}function dc(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
66
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uc(n,e){return lc(n)||cc(n,e)||fc(n,e)||dc()}function fc(n,e){if(n){if(typeof n=="string")return Fo(n,e);var r={}.toString.call(n).slice(8,-1);return r==="Object"&&n.constructor&&(r=n.constructor.name),r==="Map"||r==="Set"?Array.from(n):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Fo(n,e):void 0}}const ti=Object.entries,Uo=Object.setPrototypeOf,pc=Object.isFrozen,hc=Object.getPrototypeOf,bc=Object.getOwnPropertyDescriptor;let an=Object.freeze,ln=Object.seal,Tr=Object.create,ni=typeof Reflect<"u"&&Reflect,qs=ni.apply,Vs=ni.construct;an||(an=function(e){return e});ln||(ln=function(e){return e});qs||(qs=function(e,r){for(var s=arguments.length,o=new Array(s>2?s-2:0),a=2;a<s;a++)o[a-2]=arguments[a];return e.apply(r,o)});Vs||(Vs=function(e){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return new e(...s)});const Pr=Kt(Array.prototype.forEach),vc=Kt(Array.prototype.lastIndexOf),zo=Kt(Array.prototype.pop),kr=Kt(Array.prototype.push),mc=Kt(Array.prototype.splice),ir=Array.isArray,Ur=Kt(String.prototype.toLowerCase),Es=Kt(String.prototype.toString),Bo=Kt(String.prototype.match),Lr=Kt(String.prototype.replace),Ho=Kt(String.prototype.indexOf),gc=Kt(String.prototype.trim),xc=Kt(Number.prototype.toString),_c=Kt(Boolean.prototype.toString),Wo=typeof BigInt>"u"?null:Kt(BigInt.prototype.toString),Go=typeof Symbol>"u"?null:Kt(Symbol.prototype.toString),rn=Kt(Object.prototype.hasOwnProperty),Or=Kt(Object.prototype.toString),on=Kt(RegExp.prototype.test),br=yc(TypeError);function Kt(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return qs(n,e,s)}}function yc(n){return function(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return Vs(n,r)}}function Ye(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ur;if(Uo&&Uo(n,null),!ir(e))return n;let s=e.length;for(;s--;){let o=e[s];if(typeof o=="string"){const a=r(o);a!==o&&(pc(e)||(e[s]=a),o=a)}n[o]=!0}return n}function wc(n){for(let e=0;e<n.length;e++)rn(n,e)||(n[e]=null);return n}function hn(n){const e=Tr(null);for(const s of ti(n)){var r=uc(s,2);const o=r[0],a=r[1];rn(n,o)&&(ir(a)?e[o]=wc(a):a&&typeof a=="object"&&a.constructor===Object?e[o]=hn(a):e[o]=a)}return e}function kc(n){switch(typeof n){case"string":return n;case"number":return xc(n);case"boolean":return _c(n);case"bigint":return Wo?Wo(n):"0";case"symbol":return Go?Go(n):"Symbol()";case"undefined":return Or(n);case"function":case"object":{if(n===null)return Or(n);const e=n,r=Gn(e,"toString");if(typeof r=="function"){const s=r(e);return typeof s=="string"?s:Or(s)}return Or(n)}default:return Or(n)}}function Gn(n,e){for(;n!==null;){const s=bc(n,e);if(s){if(s.get)return Kt(s.get);if(typeof s.value=="function")return Kt(s.value)}n=hc(n)}function r(){return null}return r}function Sc(n){try{return on(n,""),!0}catch{return!1}}const jo=an(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Cs=an(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Is=an(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Tc=an(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Rs=an(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Ac=an(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),qo=an(["#text"]),Vo=an(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),$s=an(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ko=an(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Jr=an(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ec=ln(/{{[\w\W]*|^[\w\W]*}}/g),Cc=ln(/<%[\w\W]*|^[\w\W]*%>/g),Ic=ln(/\${[\w\W]*/g),Rc=ln(/^data-[\-\w.\u00B7-\uFFFF]+$/),$c=ln(/^aria-[\-\w]+$/),Yo=ln(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Mc=ln(/^(?:\w+script|data):/i),Dc=ln(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pc=ln(/^html$/i),Lc=ln(/^[a-z][.\w]*(-[.\w]+)+$/i),Zo=ln(/<[/\w!]/g),Oc=ln(/<[/\w]/g),Nc=ln(/<\/no(script|embed|frames)/i),Fc=ln(/\/>/i),Hn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Uc=function(){return typeof window>"u"?null:window},zc=function(e,r){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let s=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(s=r.getAttribute(o));const a="dompurify"+(s?"#"+s:"");try{return e.createPolicy(a,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Xo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},or=function(e,r,s,o){return rn(e,r)&&ir(e[r])?Ye(o.base?hn(o.base):{},e[r],o.transform):s};function ri(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Uc();const e=R=>ri(R);if(e.version="3.4.11",e.removed=[],!n||!n.document||n.document.nodeType!==Hn.document||!n.Element)return e.isSupported=!1,e;let r=n.document;const s=r,o=s.currentScript;n.DocumentFragment;const a=n.HTMLTemplateElement,l=n.Node,c=n.Element,_=n.NodeFilter,m=n.NamedNodeMap;m===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const x=n.DOMParser,I=n.trustedTypes,P=c.prototype,O=Gn(P,"cloneNode"),k=Gn(P,"remove"),q=Gn(P,"nextSibling"),te=Gn(P,"childNodes"),de=Gn(P,"parentNode"),re=Gn(P,"shadowRoot"),je=Gn(P,"attributes"),_e=l&&l.prototype?Gn(l.prototype,"nodeType"):null,$e=l&&l.prototype?Gn(l.prototype,"nodeName"):null;if(typeof a=="function"){const R=r.createElement("template");R.content&&R.content.ownerDocument&&(r=R.content.ownerDocument)}let fe,Le="",Ee,Et=!1,it=0;const ue=function(){if(it>0)throw br('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ve=function(i){ue(),it++;try{return fe.createHTML(i)}finally{it--}},Bt=function(i){ue(),it++;try{return fe.createScriptURL(i)}finally{it--}},He=function(){return Et||(Ee=zc(I,o),Et=!0),Ee},lt=r,kt=lt.implementation,tt=lt.createNodeIterator,nt=lt.createDocumentFragment,ge=lt.getElementsByTagName,ct=s.importNode;let De=Xo();e.isSupported=typeof ti=="function"&&typeof de=="function"&&kt&&kt.createHTMLDocument!==void 0;const St=Ec,we=Cc,ht=Ic,Yt=Rc,gt=$c,xe=Mc,en=Dc,J=Lc;let pe=Yo,T=null;const F=Ye({},[...jo,...Cs,...Is,...Rs,...qo]);let A=null;const ae=Ye({},[...Vo,...$s,...Ko,...Jr]);let z=Object.seal(Tr(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),be=null,he=null;const We=Object.seal(Tr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Oe=!0,rt=!0,xt=!1,Ge=!0,Ue=!1,Ht=!0,Gt=!1,fn=!1,pn=null,Tt=null,yt=!1,Ze=!1,tn=!1,Zt=!1,Xt=!0,kn=!1;const le="user-content-";let dt=!0,Ft=!1,At={},mt=null;const Qt=Ye({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let jt=null;const xn=Ye({},["audio","video","img","source","image","track"]);let _n=null;const Cn=Ye({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),D="http://www.w3.org/1998/Math/MathML",V="http://www.w3.org/2000/svg",Y="http://www.w3.org/1999/xhtml";let X=Y,ye=!1,Wt=null;const Ct=Ye({},[D,V,Y],Es),Lt=an(["mi","mo","mn","ms","mtext"]);let It=Ye({},Lt);const Ot=an(["annotation-xml"]);let M=Ye({},Ot);const N=Ye({},["title","style","font","a","script"]);let ve=null;const ke=["application/xhtml+xml","text/html"],Pe="text/html";let ne=null,se=null;const Ce=r.createElement("form"),Se=function(i){return i instanceof RegExp||i instanceof Function},bt=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(se&&se===i)return;(!i||typeof i!="object")&&(i={}),i=hn(i),ve=ke.indexOf(i.PARSER_MEDIA_TYPE)===-1?Pe:i.PARSER_MEDIA_TYPE,ne=ve==="application/xhtml+xml"?Es:Ur,T=or(i,"ALLOWED_TAGS",F,{transform:ne}),A=or(i,"ALLOWED_ATTR",ae,{transform:ne}),Wt=or(i,"ALLOWED_NAMESPACES",Ct,{transform:Es}),_n=or(i,"ADD_URI_SAFE_ATTR",Cn,{transform:ne,base:Cn}),jt=or(i,"ADD_DATA_URI_TAGS",xn,{transform:ne,base:xn}),mt=or(i,"FORBID_CONTENTS",Qt,{transform:ne}),be=or(i,"FORBID_TAGS",hn({}),{transform:ne}),he=or(i,"FORBID_ATTR",hn({}),{transform:ne}),At=rn(i,"USE_PROFILES")?i.USE_PROFILES&&typeof i.USE_PROFILES=="object"?hn(i.USE_PROFILES):i.USE_PROFILES:!1,Oe=i.ALLOW_ARIA_ATTR!==!1,rt=i.ALLOW_DATA_ATTR!==!1,xt=i.ALLOW_UNKNOWN_PROTOCOLS||!1,Ge=i.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ue=i.SAFE_FOR_TEMPLATES||!1,Ht=i.SAFE_FOR_XML!==!1,Gt=i.WHOLE_DOCUMENT||!1,Ze=i.RETURN_DOM||!1,tn=i.RETURN_DOM_FRAGMENT||!1,Zt=i.RETURN_TRUSTED_TYPE||!1,yt=i.FORCE_BODY||!1,Xt=i.SANITIZE_DOM!==!1,kn=i.SANITIZE_NAMED_PROPS||!1,dt=i.KEEP_CONTENT!==!1,Ft=i.IN_PLACE||!1,pe=Sc(i.ALLOWED_URI_REGEXP)?i.ALLOWED_URI_REGEXP:Yo,X=typeof i.NAMESPACE=="string"?i.NAMESPACE:Y,It=rn(i,"MATHML_TEXT_INTEGRATION_POINTS")&&i.MATHML_TEXT_INTEGRATION_POINTS&&typeof i.MATHML_TEXT_INTEGRATION_POINTS=="object"?hn(i.MATHML_TEXT_INTEGRATION_POINTS):Ye({},Lt),M=rn(i,"HTML_INTEGRATION_POINTS")&&i.HTML_INTEGRATION_POINTS&&typeof i.HTML_INTEGRATION_POINTS=="object"?hn(i.HTML_INTEGRATION_POINTS):Ye({},Ot);const v=rn(i,"CUSTOM_ELEMENT_HANDLING")&&i.CUSTOM_ELEMENT_HANDLING&&typeof i.CUSTOM_ELEMENT_HANDLING=="object"?hn(i.CUSTOM_ELEMENT_HANDLING):Tr(null);if(z=Tr(null),rn(v,"tagNameCheck")&&Se(v.tagNameCheck)&&(z.tagNameCheck=v.tagNameCheck),rn(v,"attributeNameCheck")&&Se(v.attributeNameCheck)&&(z.attributeNameCheck=v.attributeNameCheck),rn(v,"allowCustomizedBuiltInElements")&&typeof v.allowCustomizedBuiltInElements=="boolean"&&(z.allowCustomizedBuiltInElements=v.allowCustomizedBuiltInElements),ln(z),Ue&&(rt=!1),tn&&(Ze=!0),At&&(T=Ye({},qo),A=Tr(null),At.html===!0&&(Ye(T,jo),Ye(A,Vo)),At.svg===!0&&(Ye(T,Cs),Ye(A,$s),Ye(A,Jr)),At.svgFilters===!0&&(Ye(T,Is),Ye(A,$s),Ye(A,Jr)),At.mathMl===!0&&(Ye(T,Rs),Ye(A,Ko),Ye(A,Jr))),We.tagCheck=null,We.attributeCheck=null,rn(i,"ADD_TAGS")&&(typeof i.ADD_TAGS=="function"?We.tagCheck=i.ADD_TAGS:ir(i.ADD_TAGS)&&(T===F&&(T=hn(T)),Ye(T,i.ADD_TAGS,ne))),rn(i,"ADD_ATTR")&&(typeof i.ADD_ATTR=="function"?We.attributeCheck=i.ADD_ATTR:ir(i.ADD_ATTR)&&(A===ae&&(A=hn(A)),Ye(A,i.ADD_ATTR,ne))),rn(i,"ADD_URI_SAFE_ATTR")&&ir(i.ADD_URI_SAFE_ATTR)&&Ye(_n,i.ADD_URI_SAFE_ATTR,ne),rn(i,"FORBID_CONTENTS")&&ir(i.FORBID_CONTENTS)&&(mt===Qt&&(mt=hn(mt)),Ye(mt,i.FORBID_CONTENTS,ne)),rn(i,"ADD_FORBID_CONTENTS")&&ir(i.ADD_FORBID_CONTENTS)&&(mt===Qt&&(mt=hn(mt)),Ye(mt,i.ADD_FORBID_CONTENTS,ne)),dt&&(T["#text"]=!0),Gt&&Ye(T,["html","head","body"]),T.table&&(Ye(T,["tbody"]),delete be.tbody),i.TRUSTED_TYPES_POLICY){if(typeof i.TRUSTED_TYPES_POLICY.createHTML!="function")throw br('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof i.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw br('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const y=fe;fe=i.TRUSTED_TYPES_POLICY;try{Le=Ve("")}catch(C){throw fe=y,C}}else i.TRUSTED_TYPES_POLICY===null?(fe=void 0,Le=""):(fe===void 0&&(fe=He()),fe&&typeof Le=="string"&&(Le=Ve("")));an&&an(i),se=i},qt=Ye({},[...Cs,...Is,...Tc]),cn=Ye({},[...Rs,...Ac]),dn=function(i,v,y){return v.namespaceURI===Y?i==="svg":v.namespaceURI===D?i==="svg"&&(y==="annotation-xml"||It[y]):!!qt[i]},wt=function(i,v,y){return v.namespaceURI===Y?i==="math":v.namespaceURI===V?i==="math"&&M[y]:!!cn[i]},Ne=function(i,v,y){return v.namespaceURI===V&&!M[y]||v.namespaceURI===D&&!It[y]?!1:!cn[i]&&(N[i]||!qt[i])},ie=function(i){let v=de(i);(!v||!v.tagName)&&(v={namespaceURI:X,tagName:"template"});const y=Ur(i.tagName),C=Ur(v.tagName);return Wt[i.namespaceURI]?i.namespaceURI===V?dn(y,v,C):i.namespaceURI===D?wt(y,v,C):i.namespaceURI===Y?Ne(y,v,C):!!(ve==="application/xhtml+xml"&&Wt[i.namespaceURI]):!1},ce=function(i){kr(e.removed,{element:i});try{de(i).removeChild(i)}catch{if(k(i),!de(i))throw br("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Fe=function(i){const v=te(i);if(v){const C=[];Pr(v,j=>{kr(C,j)}),Pr(C,j=>{try{k(j)}catch{}})}const y=je(i);if(y)for(let C=y.length-1;C>=0;--C){const j=y[C],U=j&&j.name;if(typeof U=="string")try{i.removeAttribute(U)}catch{}}},b=function(i,v){try{kr(e.removed,{attribute:v.getAttributeNode(i),from:v})}catch{kr(e.removed,{attribute:null,from:v})}if(v.removeAttribute(i),i==="is")if(Ze||tn)try{ce(v)}catch{}else try{v.setAttribute(i,"")}catch{}},w=function(i){const v=je(i);if(v)for(let y=v.length-1;y>=0;--y){const C=v[y],j=C&&C.name;if(!(typeof j!="string"||A[ne(j)]))try{i.removeAttribute(j)}catch{}}},L=function(i){const v=[i];for(;v.length>0;){const y=v.pop();(_e?_e(y):y.nodeType)===Hn.element&&w(y);const j=te(y);if(j)for(let U=j.length-1;U>=0;--U)v.push(j[U])}},$=function(i){let v=null,y=null;if(yt)i="<remove></remove>"+i;else{const U=Bo(i,/^[\r\n\t ]+/);y=U&&U[0]}ve==="application/xhtml+xml"&&X===Y&&(i='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+i+"</body></html>");const C=fe?Ve(i):i;if(X===Y)try{v=new x().parseFromString(C,ve)}catch{}if(!v||!v.documentElement){v=kt.createDocument(X,"template",null);try{v.documentElement.innerHTML=ye?Le:C}catch{}}const j=v.body||v.documentElement;return i&&y&&j.insertBefore(r.createTextNode(y),j.childNodes[0]||null),X===Y?ge.call(v,Gt?"html":"body")[0]:Gt?v.documentElement:j},W=function(i){return tt.call(i.ownerDocument||i,i,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},Q=function(i){return i=Lr(i,St," "),i=Lr(i,we," "),i=Lr(i,ht," "),i},S=function(i){var v;i.normalize();const y=tt.call(i.ownerDocument||i,i,_.SHOW_TEXT|_.SHOW_COMMENT|_.SHOW_CDATA_SECTION|_.SHOW_PROCESSING_INSTRUCTION,null);let C=y.nextNode();for(;C;)C.data=Q(C.data),C=y.nextNode();const j=(v=i.querySelectorAll)===null||v===void 0?void 0:v.call(i,"template");j&&Pr(j,U=>{Te(U.content)&&S(U.content)})},Ie=function(i){const v=$e?$e(i):null;return typeof v!="string"||ne(v)!=="form"?!1:typeof i.nodeName!="string"||typeof i.textContent!="string"||typeof i.removeChild!="function"||i.attributes!==je(i)||typeof i.removeAttribute!="function"||typeof i.setAttribute!="function"||typeof i.namespaceURI!="string"||typeof i.insertBefore!="function"||typeof i.hasChildNodes!="function"||i.nodeType!==_e(i)||i.childNodes!==te(i)},Te=function(i){if(!_e||typeof i!="object"||i===null)return!1;try{return _e(i)===Hn.documentFragment}catch{return!1}},Be=function(i){if(!_e||typeof i!="object"||i===null)return!1;try{return typeof _e(i)=="number"}catch{return!1}};function ut(R,i,v){R.length!==0&&Pr(R,y=>{y.call(e,i,v,se)})}const oe=function(i,v){return!!(Ht&&i.hasChildNodes()&&!Be(i.firstElementChild)&&on(Zo,i.textContent)&&on(Zo,i.innerHTML)||Ht&&i.namespaceURI===Y&&v==="style"&&Be(i.firstElementChild)||i.nodeType===Hn.processingInstruction||Ht&&i.nodeType===Hn.comment&&on(Oc,i.data))},Re=function(i,v){if(!be[v]&&Xe(v)&&(z.tagNameCheck instanceof RegExp&&on(z.tagNameCheck,v)||z.tagNameCheck instanceof Function&&z.tagNameCheck(v)))return!1;if(dt&&!mt[v]){const y=de(i),C=te(i);if(C&&y){const j=C.length;for(let U=j-1;U>=0;--U){const ee=Ft?C[U]:O(C[U],!0);y.insertBefore(ee,q(i))}}}return ce(i),!0},Ut=function(i){if(ut(De.beforeSanitizeElements,i,null),Ie(i))return ce(i),!0;const v=ne($e?$e(i):i.nodeName);if(ut(De.uponSanitizeElement,i,{tagName:v,allowedTags:T}),oe(i,v))return ce(i),!0;if(be[v]||!(We.tagCheck instanceof Function&&We.tagCheck(v))&&!T[v])return Re(i,v);if((_e?_e(i):i.nodeType)===Hn.element&&!ie(i)||(v==="noscript"||v==="noembed"||v==="noframes")&&on(Nc,i.innerHTML))return ce(i),!0;if(Ue&&i.nodeType===Hn.text){const C=Q(i.textContent);i.textContent!==C&&(kr(e.removed,{element:i.cloneNode()}),i.textContent=C)}return ut(De.afterSanitizeElements,i,null),!1},vn=function(i,v,y){if(he[v]||Xt&&(v==="id"||v==="name")&&(y in r||y in Ce))return!1;const C=A[v]||We.attributeCheck instanceof Function&&We.attributeCheck(v,i);if(!(rt&&on(Yt,v))){if(!(Oe&&on(gt,v))){if(C){if(!_n[v]){if(!on(pe,Lr(y,en,""))){if(!((v==="src"||v==="xlink:href"||v==="href")&&i!=="script"&&Ho(y,"data:")===0&&jt[i])){if(!(xt&&!on(xe,Lr(y,en,"")))){if(y)return!1}}}}}else if(!(Xe(i)&&(z.tagNameCheck instanceof RegExp&&on(z.tagNameCheck,i)||z.tagNameCheck instanceof Function&&z.tagNameCheck(i))&&(z.attributeNameCheck instanceof RegExp&&on(z.attributeNameCheck,v)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(v,i))||v==="is"&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&on(z.tagNameCheck,y)||z.tagNameCheck instanceof Function&&z.tagNameCheck(y))))return!1}}return!0},Sn=Ye({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Xe=function(i){return!Sn[Ur(i)]&&on(J,i)},st=function(i,v,y,C){if(fe&&typeof I=="object"&&typeof I.getAttributeType=="function"&&!y)switch(I.getAttributeType(i,v)){case"TrustedHTML":return Ve(C);case"TrustedScriptURL":return Bt(C)}return C},Ke=function(i,v,y,C){try{y?i.setAttributeNS(y,v,C):i.setAttribute(v,C),Ie(i)?ce(i):zo(e.removed)}catch{b(v,i)}},_t=function(i){ut(De.beforeSanitizeAttributes,i,null);const v=i.attributes;if(!v||Ie(i))return;const y={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:A,forceKeepAttr:void 0};let C=v.length;const j=ne(i.nodeName);for(;C--;){const U=v[C],ee=U.name,Ae=U.namespaceURI,Qe=U.value,ot=ne(ee),Mt=Qe;let qe=ee==="value"?Mt:gc(Mt);if(y.attrName=ot,y.attrValue=qe,y.keepAttr=!0,y.forceKeepAttr=void 0,ut(De.uponSanitizeAttribute,i,y),qe=y.attrValue,kn&&(ot==="id"||ot==="name")&&Ho(qe,le)!==0&&(b(ee,i),qe=le+qe),Ht&&on(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,qe)){b(ee,i);continue}if(ot==="attributename"&&Bo(qe,"href")){b(ee,i);continue}if(!y.forceKeepAttr){if(!y.keepAttr){b(ee,i);continue}if(!Ge&&on(Fc,qe)){b(ee,i);continue}if(Ue&&(qe=Q(qe)),!vn(j,ot,qe)){b(ee,i);continue}qe=st(j,ot,Ae,qe),qe!==Mt&&Ke(i,ee,Ae,qe)}}ut(De.afterSanitizeAttributes,i,null)},Rt=function(i){let v=null;const y=W(i);for(ut(De.beforeSanitizeShadowDOM,i,null);v=y.nextNode();)if(ut(De.uponSanitizeShadowNode,v,null),Ut(v),_t(v),Te(v.content)&&Rt(v.content),(_e?_e(v):v.nodeType)===Hn.element){const j=re(v);Te(j)&&($t(j),Rt(j))}ut(De.afterSanitizeShadowDOM,i,null)},$t=function(i){const v=[{node:i,shadow:null}];for(;v.length>0;){const y=v.pop();if(y.shadow){Rt(y.shadow);continue}const C=y.node,U=(_e?_e(C):C.nodeType)===Hn.element,ee=te(C);if(ee)for(let Ae=ee.length-1;Ae>=0;--Ae)v.push({node:ee[Ae],shadow:null});if(U){const Ae=$e?$e(C):null;if(typeof Ae=="string"&&ne(Ae)==="template"){const Qe=C.content;Te(Qe)&&v.push({node:Qe,shadow:null})}}if(U){const Ae=re(C);Te(Ae)&&v.push({node:null,shadow:Ae},{node:Ae,shadow:null})}}};return e.sanitize=function(R){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},v=null,y=null,C=null,j=null;if(ye=!R,ye&&(R="<!-->"),typeof R!="string"&&!Be(R)&&(R=kc(R),typeof R!="string"))throw br("dirty is not a string, aborting");if(!e.isSupported)return R;fn?(T=pn,A=Tt):bt(i),(De.uponSanitizeElement.length>0||De.uponSanitizeAttribute.length>0)&&(T=hn(T)),De.uponSanitizeAttribute.length>0&&(A=hn(A)),e.removed=[];const U=Ft&&typeof R!="string"&&Be(R);if(U){const Qe=$e?$e(R):R.nodeName;if(typeof Qe=="string"){const ot=ne(Qe);if(!T[ot]||be[ot])throw br("root node is forbidden and cannot be sanitized in-place")}if(Ie(R))throw br("root node is clobbered and cannot be sanitized in-place");try{$t(R)}catch(ot){throw Fe(R),ot}}else if(Be(R))v=$("<!---->"),y=v.ownerDocument.importNode(R,!0),y.nodeType===Hn.element&&y.nodeName==="BODY"||y.nodeName==="HTML"?v=y:v.appendChild(y),$t(y);else{if(!Ze&&!Ue&&!Gt&&R.indexOf("<")===-1)return fe&&Zt?Ve(R):R;if(v=$(R),!v)return Ze?null:Zt?Le:""}v&&yt&&ce(v.firstChild);const ee=W(U?R:v);try{for(;C=ee.nextNode();)Ut(C),_t(C),Te(C.content)&&Rt(C.content)}catch(Qe){throw U&&Fe(R),Qe}if(U)return Pr(e.removed,Qe=>{Qe.element&&L(Qe.element)}),Ue&&S(R),R;if(Ze){if(Ue&&S(v),tn)for(j=nt.call(v.ownerDocument);v.firstChild;)j.appendChild(v.firstChild);else j=v;return(A.shadowroot||A.shadowrootmode)&&(j=ct.call(s,j,!0)),j}let Ae=Gt?v.outerHTML:v.innerHTML;return Gt&&T["!doctype"]&&v.ownerDocument&&v.ownerDocument.doctype&&v.ownerDocument.doctype.name&&on(Pc,v.ownerDocument.doctype.name)&&(Ae="<!DOCTYPE "+v.ownerDocument.doctype.name+`>
|
|
67
67
|
`+Ae),Ue&&(Ae=Q(Ae)),fe&&Zt?Ve(Ae):Ae},e.setConfig=function(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};bt(R),fn=!0,pn=T,Tt=A},e.clearConfig=function(){se=null,fn=!1,pn=null,Tt=null,fe=Ee,Le=""},e.isValidAttribute=function(R,i,v){se||bt({});const y=ne(R),C=ne(i);return vn(y,C,v)},e.addHook=function(R,i){typeof i=="function"&&rn(De,R)&&kr(De[R],i)},e.removeHook=function(R,i){if(rn(De,R)){if(i!==void 0){const v=vc(De[R],i);return v===-1?void 0:mc(De[R],v,1)[0]}return zo(De[R])}},e.removeHooks=function(R){rn(De,R)&&(De[R]=[])},e.removeAllHooks=function(){De=Xo()},e}var go=ri();ft.setOptions({gfm:!0,breaks:!0});const Qo=80;function Xn(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Bc={code(n){const{text:e,lang:r}=n,s=(r??"").trim().split(/\s+/)[0]??"",a=e.split(`
|
|
68
68
|
`).filter(I=>I.trim()!==""),l=a.length>1,c=`<pre><code>${Xn(e)}</code></pre>`;if(!l)return c;let m=a[0]??"";return m.length>Qo?m=m.slice(0,Qo)+"…":a.length>1&&(m+=" …"),`<details class="code-collapsible"><summary>${s?`<span class="code-lang">${Xn(s)}</span> ${Xn(m)}`:Xn(m)}</summary>${c}</details>`}};ft.use({renderer:Bc});let Jo=!1;function si(){Jo||typeof window>"u"||(Jo=!0,go.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))}))}function Hc(n){if(!n)return"";const e=ft.parse(n,{async:!1});return typeof window>"u"?"":(si(),go.sanitize(e,{ADD_ATTR:["target","rel"],ADD_TAGS:["details","summary"]}))}const Wc=/\b(https?:\/\/[^\s<]+|www\.[^\s<]+)/gi;function Gc(n){if(!n||typeof window>"u")return"";let e="",r=0;for(const s of n.matchAll(Wc)){const o=s.index??0;e+=Xn(n.slice(r,o));let a=s[0],l="";const c=a.match(/[.,;:!?)\]}'"]+$/);c&&(l=c[0],a=a.slice(0,a.length-l.length));const _=a.startsWith("www.")?`https://${a}`:a;e+=`<a href="${Xn(_)}">${Xn(a)}</a>`,e+=Xn(l),r=o+s[0].length}return e+=Xn(n.slice(r)),si(),go.sanitize(e,{ADD_ATTR:["target","rel"]})}var jc=g('<div class="flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted"><div class="text-center"><div class="mb-4 inline-block h-8 w-8 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <p class="text-base font-medium text-brand-text">Connecting to Wherever Server...</p> <p class="mt-1 text-xs text-brand-text-muted">Establishing secure connection to your agent</p></div></div>'),qc=g('<p class="mt-3 max-h-24 overflow-y-auto rounded bg-brand-surface-3 p-2 font-mono text-xs text-rose-300/80"> </p>'),Vc=g(`<div class="flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted"><div class="w-full max-w-md rounded-lg border border-red-500/30 bg-red-500/10 p-6 text-center text-brand-text"><div class="mb-3 text-4xl">⚠️</div> <h3 class="text-lg font-bold text-rose-400">Not Connected to Server</h3> <p class="mt-2 text-sm text-brand-text-muted">We couldn't connect to the Wherever Server. Please verify the server
|
|
69
69
|
is running and check your connection settings in the sidebar.</p> <!> <button class="mt-5 rounded bg-brand-surface-2 px-4 py-2 text-sm font-semibold text-brand-text transition-colors hover:bg-brand-surface-3">Retry Connection</button></div></div>`),Kc=g('<div class="flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted"><div class="text-center"><div class="mb-4 inline-block h-8 w-8 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <p class="text-base font-medium text-brand-text">Loading session...</p> <p class="mt-1 text-xs text-brand-text-muted">Retrieving workspace session history</p></div></div>'),Yc=g('<button type="button" class="block w-full px-3 py-1.5 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"> </button>'),Zc=g('<div class="absolute right-0 left-0 z-50 mt-1 max-h-48 overflow-y-auto rounded border border-brand-border bg-brand-surface-2 py-1 shadow-xl"></div>'),Xc=g('<span class="ml-1 font-medium text-emerald-400">(Git repo detected)</span>'),Qc=g('<span class="mt-1.5 block text-xs font-medium text-yellow-400">📁 Folder already exists. Joining will create a session in it. <!></span>'),Jc=g('<span class="mt-1 block text-[10px] text-brand-text-muted">Relative paths are created inside your home folder.</span>'),ed=g("<option> </option>"),td=g('<select id="main-model-select" class="w-full rounded border border-brand-border bg-brand-surface-3 px-3 py-2 text-sm text-brand-text focus:border-brand-blue focus:outline-none"></select>'),nd=g('<input id="main-model-select" type="text" placeholder="provider:model" class="w-full rounded border border-brand-border bg-brand-surface-3 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/>'),rd=g('<div class="flex items-center gap-4 pl-6 text-xs text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1.5 transition-colors select-none hover:text-brand-text"><input type="radio" name="main-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.5 transition-colors select-none hover:text-brand-text"><input type="radio" name="main-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),sd=g('<div class="space-y-1.5 pt-1"><div class="flex items-center gap-2"><input id="main-create-remote" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="main-create-remote" class="cursor-pointer text-sm text-brand-text select-none"> </label></div> <!></div>'),od=g('<div class="flex items-center gap-2 pt-1"><input id="main-git-init" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="main-git-init" class="cursor-pointer text-sm text-brand-text select-none">Initialize Git repository</label></div>'),ad=g(`<div class="flex flex-1 items-center justify-center p-6"><div class="w-full max-w-md rounded-lg border border-brand-border bg-brand-surface/40 p-6 text-brand-text"><div class="mb-5 text-center"><div class="mb-3 flex justify-center"><img alt="Wherever" class="h-16 w-16"/></div> <h2 class="mb-1 text-2xl font-bold"><span class="gradient-text">Wherever</span></h2> <h3 class="text-sm font-semibold text-brand-text">Create a New Session</h3> <p class="mt-1 text-xs text-brand-text-muted">Start a coding session in any folder on your machine, or use the
|
|
@@ -71,19 +71,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
71
71
|
running tool was stopped, e.g. by a CLI takeover).
|
|
72
72
|
Its outcome is unknown.</div>`),Fd=g('<div class="p-1 text-xs text-brand-text-muted italic">No output returned</div>'),Ud=g('<div class="mt-2 flex flex-col gap-3 overflow-hidden border-t border-brand-border/40 pt-2"><!> <div class="flex flex-col gap-1"><span class="font-sans text-[10px] font-bold tracking-wider text-brand-text-muted uppercase">Output</span> <!></div></div>'),zd=g('<div class="flex max-w-full min-w-[280px] flex-col sm:min-w-[400px] md:min-w-[550px]"><div class="flex w-full items-center gap-1"><button class="flex min-w-0 flex-1 items-center justify-between gap-3 rounded p-1 text-left transition-colors hover:bg-brand-surface-3/30 focus:outline-none"><div class="flex flex-1 items-center gap-2 overflow-hidden"><!> <span class="font-mono text-sm font-bold text-brand-text"> </span> <!> <!></div> <div class="flex shrink-0 items-center gap-1 font-sans text-xs font-medium whitespace-nowrap text-brand-text-muted select-none hover:text-brand-text"><!></div></button> <!></div> <!> <!></div>'),Bd=g('<pre class="chat-selectable font-sans text-sm leading-relaxed whitespace-pre-wrap"> <span class="ml-0.5 inline-block h-4 w-1.5 animate-pulse bg-brand-cyan align-text-bottom"></span></pre>'),Hd=g('<div class="chat-selectable markdown-body text-sm leading-relaxed"></div>'),Wd=g("<span></span>"),Gd=g('<span class="text-brand-text-muted italic"> </span>'),jd=g('<span class="ml-1 inline-block h-4 w-1.5 animate-pulse bg-brand-cyan"></span>'),qd=g('<div class="flex items-center gap-1.5 rounded bg-brand-blue/20 px-2 py-1 font-mono text-xs text-brand-text select-all"><span>📎</span> <span class="truncate"> </span></div>'),Vd=g('<div class="mt-2 flex flex-col gap-1 border-t border-brand-blue/20 pt-2"></div>'),Kd=g('<div class="chat-selectable text-sm leading-relaxed whitespace-pre-wrap"><!> <!></div> <!>',1),Yd=g('<span title="Sending, awaiting confirmation">Sending...</span> <span>·</span>',1),Zd=g('<div class="mt-1.5 flex flex-wrap items-center justify-end gap-2 text-xs"><span class="font-medium text-amber-400">⚠️ Not delivered</span> <button type="button" class="rounded bg-brand-blue/80 px-2 py-0.5 font-medium text-brand-text transition-colors hover:bg-brand-blue">Retry</button> <button type="button" class="rounded bg-brand-surface-3 px-2 py-0.5 font-medium text-brand-text-muted transition-colors hover:text-brand-text">Discard</button></div>'),Xd=g("<div><!> </div> <!>",1),Qd=g("<div><div><!> <!></div></div>"),Jd=g('<div class="flex-1 space-y-4 overflow-y-auto overscroll-y-contain p-4"><!> <!></div>'),eu=g('<button type="button" aria-label="Cycle waiting-for-human beep for this session"><span> </span> <span> </span></button>'),tu=g('<div class="flex items-center gap-1 text-xs text-brand-text-muted"><span class="flex-shrink-0">🧠</span> <span class="whitespace-nowrap tabular-nums"> </span></div>'),nu=g('<span class="ml-1 text-xs text-brand-text-muted">(already a Git repository)</span>'),ru=g('<span class="ml-1 text-xs font-medium text-yellow-500">(folder not empty)</span>'),su=g('<div class="flex items-center gap-4 pl-6 text-xs text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1.5 transition-colors select-none hover:text-brand-text"><input type="radio" name="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.5 transition-colors select-none hover:text-brand-text"><input type="radio" name="modal-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),ou=g('<div class="space-y-1.5"><div class="flex items-center gap-2"><input id="modal-create-remote" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> <label for="modal-create-remote" class="cursor-pointer text-sm text-brand-text select-none"> </label></div> <!></div>'),au=g('<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-full max-w-sm rounded-lg border border-brand-border bg-brand-surface-2 p-6 text-brand-text"><h3 class="mb-2 text-base font-bold text-brand-text">Folder Already Exists</h3> <p class="mb-4 text-sm text-brand-text-muted">The folder <span class="font-mono text-xs text-brand-text"> </span> already exists. Do you want to initialize a Git repository in it?</p> <div class="mb-6 flex flex-col gap-3.5"><div class="flex items-center gap-2"><input id="modal-git-init" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue disabled:opacity-50"/> <label for="modal-git-init" class="cursor-pointer text-sm text-brand-text select-none disabled:opacity-50">Initialize Git repository <!></label></div> <!></div> <div class="flex justify-end gap-2.5"><button type="button" class="rounded bg-brand-surface-3 px-3.5 py-1.5 text-xs font-semibold 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.5 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Confirm & Create</button></div></div></div>'),iu=g('<p class="mb-4 rounded bg-brand-surface-3 px-2.5 py-1.5 font-mono text-xs break-all text-brand-text-muted"> </p>'),lu=g('<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-full max-w-sm rounded-lg border border-brand-border bg-brand-surface-2 p-6 text-brand-text"><h3 class="mb-2 text-base font-bold text-brand-text">Remote Repository Already Exists</h3> <p class="mb-3 text-sm text-brand-text-muted"> <span class="font-mono text-xs text-brand-text"> </span> already exists. Do you want to clone it instead of creating a new one?</p> <!> <div class="flex justify-end gap-2.5"><button type="button" class="rounded bg-brand-surface-3 px-3.5 py-1.5 text-xs font-semibold text-brand-text transition-colors hover:bg-brand-surface-2">Create New Instead</button> <button type="button" class="rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3.5 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Clone Repository</button></div></div></div>'),cu=g('<div class="flex flex-1 flex-col overflow-hidden bg-brand-dark"><!> <div class="app-chrome flex flex-wrap items-center justify-between gap-x-4 gap-y-2 border-t border-brand-border p-2"><div class="flex flex-wrap items-center gap-x-4 gap-y-2"><label class="flex cursor-pointer items-center gap-1.5 text-xs text-brand-text-muted select-none hover:text-brand-text"><input type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Hide Thinking</label> <!> <!></div> <button class="rounded bg-rose-500 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-rose-600 disabled:cursor-not-allowed disabled:opacity-50" title="Abort">Abort</button></div> <!> <!></div>');function du(n,e){er(e,!0);const r=()=>Me(Pt,"$piState",k),s=()=>Me(Cr,"$availableModels",k),o=()=>Me(Xs,"$gitInitDefaultStore",k),a=()=>Me(Yr,"$activeSessionInfo",k),l=()=>Me(fs,"$isLoadingSession",k),c=()=>Me(eo,"$beepSessionOverride",k),_=()=>Me(to,"$beepEnabled",k),m=()=>Me(Da,"$messages",k),x=()=>Me(oo,"$isStreaming",k),I=()=>Me(za,"$hasMoreHistory",k),P=()=>Me(Ba,"$isLoadingMoreHistory",k),O=()=>Me(us,"$isReadOnly",k),[k,q]=_r(),te=[],de=new Map;function re(b,w){const L=`${b}:${w.length}`;let $=de.get(L);return $===void 0&&($=Hc(w),de.set(L,$)),$}const je=new Map;function _e(b){let w=je.get(b);return w===void 0&&(w=Gc(b),je.set(b,w)),w}function $e(b){if(b>=1e6){const w=b/1e6;return(w>=10?Math.round(w).toString():w.toFixed(1))+"M"}return b>=1e3?Math.round(b/1e3)+"K":String(b)}let fe=K(()=>{const b=r().contextUsage;if(!b||!b.contextWindow)return null;const w=$e(b.contextWindow);return b.percent==null?`– / ${w}`:`${b.percent.toFixed(1)}% / ${w}`});function Le(b){if(!b)return{cleanContent:"",attachments:[]};const w=b.split(`
|
|
73
73
|
`),L=/^\[Uploaded file: (.+)\]$/,$=[],W=[];for(const S of w){const Ie=S.match(L);Ie?W.push(Ie[1]):$.push(S)}let Q=$.join(`
|
|
74
|
-
`).trim();return Q==="I have uploaded the following file(s) for you:"&&(Q=""),{cleanContent:Q,attachments:W}}let Ee=G(""),Et=G(
|
|
75
|
-
`),ut=Be!==-1?Te.slice(0,Be):Te;$=Be!==-1?Te.slice(Be+1):"";let oe=ut.trim();oe.startsWith("$ ")&&(oe=oe.slice(2));const Re=oe.indexOf(" ");w=b.toolName||(Re!==-1?oe.slice(0,Re):oe)||"tool",L=Re!==-1?oe.slice(Re+1):""}const Q=Ue(L),S=Ht(w,Q,L),Ie=Gt(Q,L);return{toolName:w,smartTitleArgs:S,fullArgs:Ie,toolOutput:$,isError:W,interrupted:!!b.interrupted,downloadPath:pn(w,Q,W)}}function pn(b,w,L){if(L||!w)return null;const $=(b||"").toLowerCase();if(!["attach_file","read","write","edit"].includes($))return null;const W=w.path||w.filepath||w.file;return!W||typeof W!="string"?null:W.trim()||null}function Tt(b){return b.scrollHeight-b.scrollTop-b.clientHeight<=20}function yt(){t(F)&&p(Oe,Tt(t(F)),!0)}function Ze(){t(F)&&(t(F).scrollTop=t(F).scrollHeight)}function tn(){(t(Oe)||t(rt))&&(Ze(),p(rt,!1))}qr(Ze),Dt(()=>{if(t(F))return t(F).addEventListener("scroll",yt),()=>{t(F)&&t(F).removeEventListener("scroll",yt)}});let Zt=G(null),Xt=G(!1);function kn(){p(rt,!0),Ze(),requestAnimationFrame(()=>{Ze(),requestAnimationFrame(Ze)}),setTimeout(Ze,60),setTimeout(Ze,150)}Dt(()=>{const b=t(A).sessionFile;b!==t(Zt)&&(p(Zt,b,!0),p(rt,!0));const w=t(ae);t(Xt)&&!w&&kn(),p(Xt,w,!0)});let le=K(()=>{const b=m().filter(L=>L.role==="thinking"&&r().hideThinking?!1:L.role==="tool"&&r().hideTools&&L.toolName!=="attach_file"?jt(L)||!!L.isStreaming:L.role!=="assistant"&&L.role!=="thinking"||L.isStreaming||L.content.trim()!==""),w=b.some(L=>L.isStreaming);if(t(dt)&&!w){const L=m().some($=>$.role==="thinking"&&$.isStreaming);b.push({id:"fallback-loader-message-id",role:"thinking",content:L?"FALLBACK_THINKING_LOADER":"FALLBACK_LOADER",timestamp:Date.now(),isStreaming:!0})}return b}),dt=K(x),Ft=G(
|
|
76
|
-
${hr??""}`)},[()=>mt(t(S))]),h(ze,Je)},oi=K(()=>mt(t(S)));E(pr,ze=>{t(oi)&&ze(bs)})}d(
|
|
77
|
-
the message.</p></div> <!></div>`,1),vu=g('<div class="relative flex shrink-0 items-center gap-1 select-none"><button type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-5 w-5"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" x2="12" y1="19" y2="22"></line></svg></button> <button type="button" class="flex h-[48px] w-[28px] items-center justify-center rounded-lg border border-gray-600 bg-gray-800 text-gray-400 hover:bg-gray-700 hover:text-white disabled:cursor-not-allowed disabled:opacity-40" title="Speech Settings"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg></button> <!></div>');function mu(n,e){er(e,!0);let r=vr(e,"text",15);const s=typeof window<"u"?window.SpeechRecognition||window.webkitSpeechRecognition:null,o=!!s;let a=G(!1),l=G(!1),c=G(!1),_=G(!1),m=G(!1),x=G("en-US"),I=G("browser"),P=G(null),O=G(null),k=null,q=null,te=null,de=null,re=null,je=[],_e="",$e=!1;const fe=[{code:"en-US",label:"English (US)"},{code:"en-GB",label:"English (UK)"},{code:"en-IN",label:"English (India)"},{code:"en-AU",label:"English (Australia)"},{code:"en-CA",label:"English (Canada)"},{code:"en-ZA",label:"English (South Africa)"}];qr(()=>{const T=localStorage.getItem("wherever-speech-direct-send");T!==null&&p(m,T==="true");const F=localStorage.getItem("wherever-speech-locale");F!==null&&p(x,F,!0);const A=localStorage.getItem("wherever-speech-engine");return A!==null?p(I,A,!0):o||p(I,"cloud"),()=>{if(k)try{k.abort()}catch{}if(de)try{de.disconnect()}catch{}if(te)try{te.disconnect()}catch{}if(re)try{re.getTracks().forEach(ae=>ae.stop())}catch{}if(q)try{q.close()}catch{}t(O)&&clearTimeout(t(O))}});function Le(){localStorage.setItem("wherever-speech-direct-send",String(t(m))),localStorage.setItem("wherever-speech-locale",t(x)),localStorage.setItem("wherever-speech-engine",t(I))}function Ee(){const T=localStorage.getItem("wherever-config");if(T){const F=JSON.parse(T),A=window.location.protocol==="https:"?"https:":"http:",ae=F.host.startsWith("http")?F.host.replace(/^wss?:\/\//,""):F.host;return`${A}//${ae}:${F.port}`}return`${window.location.protocol}//${window.location.host}`}function Et(){try{const T=localStorage.getItem("wherever-config");if(T)return JSON.parse(T).token||""}catch{}return""}function it(){try{const T=window.AudioContext||window.webkitAudioContext;if(!T)return;const F=new T,A=F.createOscillator(),ae=F.createGain();A.type="sine",A.frequency.setValueAtTime(400,F.currentTime),ae.gain.setValueAtTime(.08,F.currentTime),ae.gain.exponentialRampToValueAtTime(.001,F.currentTime+.12),A.connect(ae),ae.connect(F.destination),A.start(),A.stop(F.currentTime+.12)}catch(T){console.warn("Could not play audio beep feedback:",T)}}function ue(T,F,A){if(F===A)return T;const ae=F/A,z=Math.round(T.length/ae),be=new Float32Array(z);let he=0,We=0;for(;he<be.length;){const Oe=Math.round((he+1)*ae);let rt=0,xt=0;for(let Ge=We;Ge<Oe&&Ge<T.length;Ge++)rt+=T[Ge],xt++;be[he]=xt>0?rt/xt:0,he++,We=Oe}return be}function Ve(){if(o)try{k=new s,k.continuous=!0,k.interimResults=!0,k.lang=t(x),k.onstart=()=>{p(a,!0),p(l,!1),it()},k.onresult=T=>{let F="",A="";for(let z=T.resultIndex;z<T.results.length;++z){const be=T.results[z];be.isFinal?F+=be[0].transcript:A+=be[0].transcript}const ae=(F+A).trim();ae&&($e=!0,r(_e+(_e?" ":"")+ae))},k.onerror=T=>{console.error("Browser speech recognition error:",T.error),T.error!=="no-speech"&&p(P,`Error: ${T.error}`),Bt()},k.onend=()=>{p(a,!1),t(m)&&$e&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50)},k.start(),navigator.vibrate&&navigator.vibrate(40)}catch(T){console.error("Failed to start browser speech recognition:",T),p(P,"Failed to start browser recording"),p(a,!1)}}function Bt(){if(k)try{k.stop()}catch{}p(a,!1)}async function He(){try{const T=await navigator.mediaDevices.getUserMedia({audio:!0});re=T,je=[];const F=window.AudioContext||window.webkitAudioContext;q=new F,te=q.createMediaStreamSource(T),de=q.createScriptProcessor(4096,1,1),de.onaudioprocess=A=>{const ae=A.inputBuffer.getChannelData(0);je.push(new Float32Array(ae))},te.connect(de),de.connect(q.destination),p(a,!0),p(l,!1),it(),navigator.vibrate&&navigator.vibrate(40)}catch(T){console.error("Failed to start cloud audio recording:",T),p(P,T.message||"Microphone access denied",!0),p(a,!1),p(l,!1)}}function lt(){if(t(a)){if(p(a,!1),p(l,!0),de){try{de.disconnect()}catch{}de.onaudioprocess=null}if(te)try{te.disconnect()}catch{}if(re)try{re.getTracks().forEach(T=>T.stop())}catch{}kt()}}async function kt(){try{if(je.length===0){p(l,!1);return}p(P,null);let T=0;for(const Ht of je)T+=Ht.length;const F=new Float32Array(T);let A=0;for(const Ht of je)F.set(Ht,A),A+=Ht.length;const ae=q?q.sampleRate:48e3,z=16e3,be=ue(F,ae,z),he=St(be,1,z,1,16),We=new Blob([he],{type:"audio/wav"}),Oe=Ee(),rt=Et(),xt=`${Oe}/session/transcribe${rt?`?token=${encodeURIComponent(rt)}`:""}`,Ge=await fetch(xt,{method:"POST",body:We,headers:{"Content-Type":"application/octet-stream"}}),Ue=await Ge.json();if(!Ge.ok)throw new Error(Ue.error||`HTTP ${Ge.status}`);Ue.text&&Ue.text.trim()&&($e=!0,r(_e+(_e?" ":"")+Ue.text.trim()),t(m)&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50))}catch(T){console.error("Cloud transcription request failed:",T),p(P,T.message||"Cloud API failed",!0)}finally{if(p(l,!1),q){try{q.close()}catch{}q=null}}}function tt(){e.disabled||t(a)||t(l)||(p(P,null),$e=!1,_e=r(),t(I)==="cloud"?He():Ve())}function nt(){t(I)==="cloud"?lt():Bt()}function ge(T){if(T.button===0&&!e.disabled){if(T.preventDefault(),t(a)){nt();return}p(c,!1),p(O,setTimeout(()=>{p(c,!0),tt()},350),!0)}}function ct(T){t(O)&&(clearTimeout(t(O)),p(O,null)),t(c)?(p(c,!1),nt()):t(a)||tt()}function De(){t(O)&&(clearTimeout(t(O)),p(O,null)),t(c)&&(p(c,!1),nt())}function St(T,F,A,ae,z){const be=new ArrayBuffer(44+T.length*2),he=new DataView(be);return ht(he,0,"RIFF"),he.setUint32(4,36+T.length*2,!0),ht(he,8,"WAVE"),ht(he,12,"fmt "),he.setUint32(16,16,!0),he.setUint16(20,ae,!0),he.setUint16(22,F,!0),he.setUint32(24,A,!0),he.setUint32(28,A*F*(z/8),!0),he.setUint16(32,F*(z/8),!0),he.setUint16(34,z,!0),ht(he,36,"data"),he.setUint32(40,T.length*2,!0),we(he,44,T),be}function we(T,F,A){for(let ae=0;ae<A.length;ae++,F+=2){let z=Math.max(-1,Math.min(1,A[ae]));T.setInt16(F,z<0?z*32768:z*32767,!0)}}function ht(T,F,A){for(let ae=0;ae<A.length;ae++)T.setUint8(F+ae,A.charCodeAt(ae))}var Yt=vu(),gt=u(Yt),xe=f(gt,2),en=u(xe);d(xe);var J=f(xe,2);{var pe=T=>{var F=bu(),A=Nt(F),ae=f(A,2),z=f(u(ae),2),be=f(u(z),2),he=u(be),We=f(he,2);d(be);var Oe=f(be,2),rt=u(Oe,!0);d(Oe),d(z);var xt=f(z,2);{var Ge=Tt=>{var yt=pu(),Ze=f(u(yt),2);gn(Ze,21,()=>fe,
|
|
74
|
+
`).trim();return Q==="I have uploaded the following file(s) for you:"&&(Q=""),{cleanContent:Q,attachments:W}}let Ee=G(""),Et=G(Mn([])),it=G(!1),ue=G(null),Ve=G(null),Bt="",He=G(""),lt=G(!1),kt=G(null),tt=G(!0),nt=G("private"),ge=G(!1),ct=G(!1),De=G(!1),St=G(null);function we(b){qn(t(Ee).trim(),t(He)||void 0,b?!1:t(lt),b?!1:t(xe).matchingRule?t(tt):void 0,b?void 0:t(xe).matchingRule?t(nt):void 0,b||void 0)}let ht=K(r),Yt=K(s),gt=K(o);Dt(()=>{t(kt)===null&&p(lt,t(gt),!0)});let xe=G(Mn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),en=K(()=>t(xe).exists!==!0&&t(xe).matchingRule&&t(tt)),J=null;async function pe(b,w=!1){if(J&&clearTimeout(J),b===Bt&&!w)return;if(Bt=b,!b.trim()){p(xe,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const $=async()=>{const W=await ss("");p(Et,W||[],!0)};w?await $():J=setTimeout($,300);return}const L=async()=>{const[$,W]=await Promise.all([pa(b),ss(b)]);p(Et,W||[],!0),$?(p(xe,{exists:$.exists,isGit:$.isGit,resolvedPath:$.resolvedPath,matchingRule:$.matchingRule||null},!0),$.exists||(p(lt,t(kt)!==null?t(kt):t(gt),!0),p(tt,!0),$.matchingRule&&p(nt,$.matchingRule.visibility,!0))):p(xe,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};w?await L():J=setTimeout(L,300)}Dt(()=>{const b=t(Ee);pe(b,!1)}),Dt(()=>{if(t(Yt).models.length>0&&!t(He)){const b=t(Yt).models.find(w=>w.isDefault);b?p(He,`${b.provider}:${b.modelId}`):p(He,`${t(Yt).models[0].provider}:${t(Yt).models[0].modelId}`)}});async function T(){if(t(Ee).trim()){if(t(xe).exists===!0){p(lt,!1),p(tt,!1),t(xe).matchingRule&&p(nt,t(xe).matchingRule.visibility,!0),p(ge,!0);return}if(t(xe).matchingRule&&t(tt)){p(De,!0);try{const b=await ol(t(Ee).trim());if(b&&b.matched&&b.exists){p(St,{provider:b.provider,sshUrl:b.sshUrl},!0),p(ct,!0);return}}finally{p(De,!1)}}we(!1)}}let F=G(void 0),A=K(a),ae=K(l),z=K(c),be=K(_);function he(){t(z)===void 0?ts(!0):t(z)===!0?ts(!1):ts(void 0)}let We=K(()=>!!t(A).sessionFile),Oe=G(!0),rt=G(!1),xt=Mn({});function Ge(b,w){xt[b]=!w}function Ue(b){if(!b)return null;const w=b.trim();if(!w)return null;if(w.startsWith("{"))try{return JSON.parse(w)}catch{}const L={},$=/([a-zA-Z0-9_-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|(\S+))/g;let W;for(;(W=$.exec(w))!==null;){const Q=W[1],S=W[2]!==void 0?W[2]:W[3]!==void 0?W[3]:W[4];L[Q]=S}return Object.keys(L).length>0?L:null}function Ht(b,w,L){if(!w)return L?L.trim():"";const $=b.toLowerCase();if(["read","write","edit","ls"].includes($)){const Q=w.path||w.filepath||w.file;if(Q)return String(Q)}if($==="bash"){const Q=w.command||w.cmd;if(Q){const S=String(Q).replace(/\s+/g," ").trim();return S.length>50?S.slice(0,47)+"...":S}}if($==="grep"){const Q=w.pattern,S=w.path;if(Q)return S?`"${Q}" in ${S}`:`"${Q}"`}if($==="find"){const Q=w.pattern||w.path;if(Q)return String(Q)}const W=w.path||w.filepath||w.file||w.name||w.query;return W?String(W):Object.entries(w).filter(([Q,S])=>S!==void 0&&S!=="").map(([Q,S])=>`${Q}=${typeof S=="object"?JSON.stringify(S):S}`).join(" ")}function Gt(b,w){return b?JSON.stringify(b,null,2):w?w.trim():""}function fn(b){let w=b.toolName||"tool",L=b.toolArgs!==void 0?b.toolArgs:"",$=b.toolOutput!==void 0?b.toolOutput:"",W=!!b.isError;if(!L&&!$&&b.content){let Te=b.content||"";Te.startsWith("Error: ")?(W=!0,Te=Te.slice(7)):Te.startsWith("Tool error: ")&&(W=!0,Te=Te.slice(12));const Be=Te.indexOf(`
|
|
75
|
+
`),ut=Be!==-1?Te.slice(0,Be):Te;$=Be!==-1?Te.slice(Be+1):"";let oe=ut.trim();oe.startsWith("$ ")&&(oe=oe.slice(2));const Re=oe.indexOf(" ");w=b.toolName||(Re!==-1?oe.slice(0,Re):oe)||"tool",L=Re!==-1?oe.slice(Re+1):""}const Q=Ue(L),S=Ht(w,Q,L),Ie=Gt(Q,L);return{toolName:w,smartTitleArgs:S,fullArgs:Ie,toolOutput:$,isError:W,interrupted:!!b.interrupted,downloadPath:pn(w,Q,W)}}function pn(b,w,L){if(L||!w)return null;const $=(b||"").toLowerCase();if(!["attach_file","read","write","edit"].includes($))return null;const W=w.path||w.filepath||w.file;return!W||typeof W!="string"?null:W.trim()||null}function Tt(b){return b.scrollHeight-b.scrollTop-b.clientHeight<=20}function yt(){t(F)&&p(Oe,Tt(t(F)),!0)}function Ze(){t(F)&&(t(F).scrollTop=t(F).scrollHeight)}function tn(){(t(Oe)||t(rt))&&(Ze(),p(rt,!1))}qr(Ze),Dt(()=>{if(t(F))return t(F).addEventListener("scroll",yt),()=>{t(F)&&t(F).removeEventListener("scroll",yt)}});let Zt=G(null),Xt=G(!1);function kn(){p(rt,!0),Ze(),requestAnimationFrame(()=>{Ze(),requestAnimationFrame(Ze)}),setTimeout(Ze,60),setTimeout(Ze,150)}Dt(()=>{const b=t(A).sessionFile;b!==t(Zt)&&(p(Zt,b,!0),p(rt,!0));const w=t(ae);t(Xt)&&!w&&kn(),p(Xt,w,!0)});let le=K(()=>{const b=m().filter(L=>L.role==="thinking"&&r().hideThinking?!1:L.role==="tool"&&r().hideTools&&L.toolName!=="attach_file"?jt(L)||!!L.isStreaming:L.role!=="assistant"&&L.role!=="thinking"||L.isStreaming||L.content.trim()!==""),w=b.some(L=>L.isStreaming);if(t(dt)&&!w){const L=m().some($=>$.role==="thinking"&&$.isStreaming);b.push({id:"fallback-loader-message-id",role:"thinking",content:L?"FALLBACK_THINKING_LOADER":"FALLBACK_LOADER",timestamp:Date.now(),isStreaming:!0})}return b}),dt=K(x),Ft=G(Mn(Date.now())),At=K(()=>t(le).some(b=>b.role==="tool"&&b.isStreaming));Dt(()=>{if(!t(At))return;p(Ft,Date.now(),!0);const b=setInterval(()=>p(Ft,Date.now(),!0),100);return()=>clearInterval(b)});function mt(b){if(b.startedAt===void 0)return null;const w=b.endedAt??(b.isStreaming?t(Ft):void 0);return w===void 0?null:`${(Math.max(0,w-b.startedAt)/1e3).toFixed(1)}s`}Pi(()=>{const b=t(le)[t(le).length-1];b&&`${t(le).length}${b.content.length}`,t(F)&&p(Oe,Tt(t(F)),!0)}),Dt(()=>{const b=t(le)[t(le).length-1];b&&`${t(le).length}${b.content.length}`,tn()});function Qt(b){return new Date(b).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function jt(b){return b.role==="tool"&&b.forceCommand===!0}function xn(b,w){return jt(b)}function _n(){p(rt,!0),setTimeout(Ze,0)}let Cn=K(I),D=K(P);const V=64;let Y=G(null),X=G(null);function ye(){!t(F)||t(D)||!t(Cn)||(p(Y,t(le)[0]?.id??null,!0),p(X,t(F).scrollHeight-t(F).scrollTop),Aa())}Dt(()=>{if(m().length,(t(Y)!==null||t(X)!==null)&&t(F)){const b=t(Y),w=t(X);p(Y,null),p(X,null),requestAnimationFrame(()=>{if(!t(F))return;const L=b?t(F).querySelector(`[data-msg-id="${CSS.escape(b)}"]`):null;if(L){const $=L.getBoundingClientRect().top-t(F).getBoundingClientRect().top;t(F).scrollTop=Math.max(0,t(F).scrollTop+$-V)}else w!==null&&(t(F).scrollTop=t(F).scrollHeight-w)})}});var Wt={forceScrollToBottom:_n},Ct=cu(),Lt=u(Ct);{var It=b=>{var w=jc();h(b,w)},Ot=b=>{var w=Vc(),L=u(w),$=f(u(L),6);{var W=S=>{var Ie=qc(),Te=u(Ie,!0);d(Ie),B(()=>Z(Te,t(ht).error)),h(S,Ie)};E($,S=>{t(ht).error&&S(W)})}var Q=f($,2);d(L),d(w),H("click",Q,()=>{Fi(()=>Promise.resolve().then(()=>yl),void 0,import.meta.url).then(S=>S.connect())}),h(b,w)},M=b=>{var w=Kc();h(b,w)},N=b=>{var w=ad(),L=u(w),$=u(L),W=u($),Q=u(W);d(W),et(6),d($);var S=f($,2),Ie=u(S),Te=f(u(Ie),2),Be=u(Te);at(Be),Vn(Be,y=>p(ue,y),()=>t(ue));var ut=f(Be,2);{var oe=y=>{var C=Zc();gn(C,21,()=>t(Et),Pn,(j,U)=>{var ee=Yc(),Ae=u(ee,!0);d(ee),B(()=>Z(Ae,t(U))),H("click",ee,()=>{p(Ee,t(U),!0),pe(t(U),!0),t(ue)?.focus()}),h(j,ee)}),d(C),h(y,C)};E(ut,y=>{t(it)&&t(Et).length>0&&y(oe)})}d(Te),Vn(Te,y=>p(Ve,y),()=>t(Ve));var Re=f(Te,2);{var Ut=y=>{var C=Qc(),j=f(u(C));{var U=ee=>{var Ae=Xc();h(ee,Ae)};E(j,ee=>{t(xe).isGit&&ee(U)})}d(C),h(y,C)},vn=y=>{var C=Jc();h(y,C)};E(Re,y=>{t(xe).exists===!0?y(Ut):y(vn,-1)})}d(Ie);var Sn=f(Ie,2),Xe=f(u(Sn),2);{var st=y=>{var C=td();gn(C,21,()=>t(Yt).models,Pn,(j,U)=>{var ee=ed(),Ae=u(ee);d(ee);var Qe={};B(()=>{Z(Ae,`${t(U).label??""}${t(U).isDefault?" (default)":""}`),Qe!==(Qe=`${t(U).provider}:${t(U).modelId}`)&&(ee.value=ee.__value=`${t(U).provider}:${t(U).modelId}`)}),h(j,ee)}),d(C),Gr(C,()=>t(He),j=>p(He,j)),h(y,C)},Ke=y=>{var C=nd();at(C),Ln(C,()=>t(He),j=>p(He,j)),h(y,C)};E(Xe,y=>{t(Yt).models.length>0?y(st):y(Ke,-1)})}d(Sn);var _t=f(Sn,2);{var Rt=y=>{var C=sd(),j=u(C),U=u(j);at(U);var ee=f(U,2),Ae=u(ee);d(ee),d(j);var Qe=f(j,2);{var ot=Mt=>{var qe=rd(),sn=f(u(qe),2),zn=u(sn);at(zn),zn.value=zn.__value="private",et(),d(sn);var ur=f(sn,2),rr=u(ur);at(rr),rr.value=rr.__value="public",et(),d(ur),d(qe),lr(te,[],zn,()=>t(nt),fr=>p(nt,fr)),lr(te,[],rr,()=>t(nt),fr=>p(nt,fr)),h(Mt,qe)};E(Qe,Mt=>{t(tt)&&Mt(ot)})}d(C),B(()=>Z(Ae,`Create remote ${t(xe).matchingRule.provider??""} repository`)),On(U,()=>t(tt),Mt=>p(tt,Mt)),h(y,C)};E(_t,y=>{t(xe).exists!==!0&&t(xe).matchingRule&&y(Rt)})}var $t=f(_t,2);{var R=y=>{var C=od(),j=u(C);at(j),et(2),d(C),H("change",j,U=>{p(kt,U.currentTarget.checked,!0)}),On(j,()=>t(lt),U=>p(lt,U)),h(y,C)};E($t,y=>{t(xe).exists!==!0&&(!t(xe).matchingRule||!t(tt))&&y(R)})}var i=f($t,2),v=u(i,!0);d(i),d(S),d(L),d(w),B((y,C)=>{me(Q,"src",y),Jt(Be,1,`w-full rounded border px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted transition-all duration-200 focus:outline-none ${t(en)?"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-surface-3 focus:border-brand-blue"}`),i.disabled=C,Z(v,t(De)?"Checking remote...":"Create & Start Session")},[()=>Ar("/logo.svg"),()=>!t(Ee).trim()||t(De)]),cr("submit",S,y=>{y.preventDefault(),T()}),cr("focus",Be,()=>{p(it,!0),pe(t(Ee),!0)}),cr("blur",Be,y=>{t(Ve)&&t(Ve).contains(y.relatedTarget)||p(it,!1)}),H("keydown",Be,y=>{y.key==="Escape"&&p(it,!1)}),Ln(Be,()=>t(Ee),y=>p(Ee,y)),h(b,w)},ve=b=>{var w=id();h(b,w)},ke=b=>{var w=Jd(),L=u(w);{var $=Q=>{var S=ld(),Ie=u(S),Te=u(Ie);{var Be=oe=>{var Re=An("Loading older messages...");h(oe,Re)},ut=oe=>{var Re=An("Load older messages");h(oe,Re)};E(Te,oe=>{t(D)?oe(Be):oe(ut,-1)})}d(Ie),d(S),B(()=>Ie.disabled=t(D)),H("click",Ie,ye),h(Q,S)};E(L,Q=>{t(Cn)&&Q($)})}var W=f(L,2);gn(W,17,()=>t(le),Q=>Q.id,(Q,S)=>{var Ie=Qd(),Te=u(Ie),Be=u(Te);{var ut=Xe=>{var st=jn(),Ke=Nt(st);{var _t=i=>{var v=cd();h(i,v)},Rt=i=>{var v=dd();h(i,v)},$t=i=>{var v=ud();h(i,v)},R=i=>{var v=pd(),y=u(v);{var C=ee=>{var Ae=fd();h(ee,Ae)};E(y,ee=>{t(S).isStreaming&&ee(C)})}var j=f(y,2),U=u(j,!0);d(j),d(v),B(()=>Z(U,t(S).content)),h(i,v)};E(Ke,i=>{t(S).content==="FALLBACK_THINKING_LOADER"?i(_t):t(S).content==="FALLBACK_LOADER"?i(Rt,1):r().hideThinking?i($t,2):i(R,-1)})}h(Xe,st)},oe=Xe=>{var st=jn(),Ke=Nt(st);{var _t=R=>{var i=bd(),v=f(u(i),2),y=f(u(v)),C=u(y,!0);d(y),et(),d(v);var j=f(v,2);{var U=Ae=>{var Qe=hd(),ot=u(Qe,!0);d(Qe),B(Mt=>Z(ot,Mt),[()=>mt(t(S))]),h(Ae,Qe)},ee=K(()=>mt(t(S)));E(j,Ae=>{t(ee)&&Ae(U)})}d(i),B(()=>Z(C,t(S).toolName||"agent")),h(R,i)},Rt=K(()=>r().hideTools&&t(S).toolName!=="attach_file"&&!jt(t(S))),$t=R=>{const i=K(()=>fn(t(S))),v=K(()=>xt[t(S).id]!==void 0?xt[t(S).id]:xn(t(S),t(le))),y=K(()=>t(i).downloadPath),C=K(()=>t(y)?Ha(t(y)):null),j=K(()=>t(i).toolName==="attach_file");var U=jn(),ee=Nt(U);{var Ae=ot=>{const Mt=K(()=>t(y)?t(y).split("/").pop()||t(y):"");var qe=yd(),sn=u(qe);{var zn=mn=>{var nn=vd();h(mn,nn)},ur=mn=>{var nn=gd(),Tn=f(u(nn),2),Bn=f(u(Tn),2);{var sr=Yn=>{var pr=md(),bs=u(pr,!0);d(pr),B(()=>Z(bs,t(i).toolOutput)),h(Yn,pr)};E(Bn,Yn=>{t(i).toolOutput&&Yn(sr)})}d(Tn),d(nn),h(mn,nn)},rr=mn=>{var nn=xd(),Tn=f(u(nn),2),Bn=u(Tn),sr=u(Bn,!0);d(Bn);var Yn=f(Bn,2),pr=u(Yn,!0);d(Yn),d(Tn),et(2),d(nn),B(()=>{me(nn,"href",t(C)),me(nn,"download",t(Mt)),me(nn,"title",`Download ${t(y)}`),Z(sr,t(Mt)),me(Yn,"title",t(y)),Z(pr,t(y))}),h(mn,nn)},fr=mn=>{var nn=_d(),Tn=f(u(nn),2),Bn=u(Tn),sr=u(Bn,!0);d(Bn),et(2),d(Tn),d(nn),B(()=>Z(sr,t(Mt))),h(mn,nn)};E(sn,mn=>{t(S).isStreaming?mn(zn):t(i).isError?mn(ur,1):t(C)?mn(rr,2):mn(fr,-1)})}d(qe),h(ot,qe)},Qe=ot=>{var Mt=zd(),qe=u(Mt),sn=u(qe),zn=u(sn),ur=u(zn);{var rr=ze=>{var Je=wd();h(ze,Je)},fr=ze=>{var Je=kd();h(ze,Je)},mn=ze=>{var Je=Sd();h(ze,Je)},nn=ze=>{var Je=Td();h(ze,Je)};E(ur,ze=>{t(S).isStreaming?ze(rr):t(i).isError?ze(fr,1):t(i).interrupted?ze(mn,2):ze(nn,-1)})}var Tn=f(ur,2),Bn=u(Tn,!0);d(Tn);var sr=f(Tn,2);{var Yn=ze=>{var Je=Ad(),In=u(Je,!0);d(Je),B(()=>{me(Je,"title",t(i).smartTitleArgs),Z(In,t(i).smartTitleArgs)}),h(ze,Je)};E(sr,ze=>{t(i).smartTitleArgs&&ze(Yn)})}var pr=f(sr,2);{var bs=ze=>{var Je=Ed(),In=u(Je);d(Je),B(hr=>{Jt(Je,1,`shrink-0 font-mono text-xs tabular-nums ${t(S).isStreaming?"text-amber-400":"text-brand-text-muted"}`),me(Je,"title",t(S).isStreaming?"Elapsed time":"Time taken"),Z(In,`${t(S).isStreaming?"Elapsed":"Took"}
|
|
76
|
+
${hr??""}`)},[()=>mt(t(S))]),h(ze,Je)},oi=K(()=>mt(t(S)));E(pr,ze=>{t(oi)&&ze(bs)})}d(zn);var xo=f(zn,2),ai=u(xo);{var ii=ze=>{var Je=Cd();et(),h(ze,Je)},li=ze=>{var Je=Id();et(),h(ze,Je)};E(ai,ze=>{t(v)?ze(ii):ze(li,-1)})}d(xo),d(sn);var ci=f(sn,2);{var di=ze=>{var Je=jn(),In=Nt(Je);{var hr=yn=>{var Rn=Rd();B(vs=>{me(Rn,"href",t(C)),me(Rn,"download",vs),me(Rn,"title",`Download ${t(y)}`),me(Rn,"aria-label",`Download ${t(y)}`)},[()=>t(y).split("/").pop()||""]),h(yn,Rn)},Zn=yn=>{var Rn=$d();h(yn,Rn)};E(In,yn=>{t(C)?yn(hr):yn(Zn,-1)})}h(ze,Je)};E(ci,ze=>{t(y)&&ze(di)})}d(qe);var _o=f(qe,2);{var ui=ze=>{var Je=Dd(),In=u(Je);gn(In,21,()=>t(S).images,Pn,(hr,Zn)=>{var yn=Md(),Rn=u(yn);d(yn),B(()=>{me(yn,"href",`data:${t(Zn).mimeType};base64,${t(Zn).data}`),me(Rn,"src",`data:${t(Zn).mimeType};base64,${t(Zn).data}`)}),h(hr,yn)}),d(In),d(Je),h(ze,Je)};E(_o,ze=>{t(S).images&&t(S).images.length>0&&ze(ui)})}var fi=f(_o,2);{var pi=ze=>{var Je=Ud(),In=u(Je);{var hr=un=>{var wn=Pd(),Xr=f(u(wn),2),vi=u(Xr,!0);d(Xr),d(wn),B(()=>Z(vi,t(i).fullArgs)),h(un,wn)};E(In,un=>{t(i).fullArgs&&t(i).fullArgs!=="{}"&&un(hr)})}var Zn=f(In,2),yn=f(u(Zn),2);{var Rn=un=>{var wn=Ld(),Xr=u(wn,!0);d(wn),B(()=>Z(Xr,t(i).toolOutput)),h(un,wn)},vs=un=>{var wn=Od();h(un,wn)},hi=un=>{var wn=Nd();h(un,wn)},bi=un=>{var wn=Fd();h(un,wn)};E(yn,un=>{t(i).toolOutput?un(Rn):t(S).isStreaming?un(vs,1):t(i).interrupted?un(hi,2):un(bi,-1)})}d(Zn),d(Je),h(ze,Je)};E(fi,ze=>{t(v)&&ze(pi)})}d(Mt),B(()=>Z(Bn,t(i).toolName)),H("click",sn,()=>Ge(t(S).id,t(v))),h(ot,Mt)};E(ee,ot=>{t(j)?ot(Ae):ot(Qe,-1)})}h(R,U)};E(Ke,R=>{t(Rt)?R(_t):R($t,-1)})}h(Xe,st)},Re=Xe=>{var st=jn(),Ke=Nt(st);{var _t=$t=>{var R=Bd(),i=u(R,!0);et(),d(R),B(()=>Z(i,t(S).content)),h($t,R)},Rt=$t=>{var R=Hd();To(R,()=>re(t(S).id,t(S).content),!0),d(R),h($t,R)};E(Ke,$t=>{t(S).isStreaming?$t(_t):$t(Rt,-1)})}h(Xe,st)},Ut=Xe=>{const st=K(()=>Le(t(S).content));var Ke=Kd(),_t=Nt(Ke),Rt=u(_t);{var $t=U=>{const ee=K(()=>_e(t(st).cleanContent));var Ae=jn(),Qe=Nt(Ae);{var ot=qe=>{var sn=Wd();To(sn,()=>t(ee),!0),d(sn),h(qe,sn)},Mt=qe=>{var sn=An();B(()=>Z(sn,t(st).cleanContent)),h(qe,sn)};E(Qe,qe=>{t(ee)?qe(ot):qe(Mt,-1)})}h(U,Ae)},R=U=>{var ee=Gd(),Ae=u(ee);d(ee),B(()=>Z(Ae,`Shared file${t(st).attachments.length>1?"s":""} with agent:`)),h(U,ee)},i=U=>{var ee=An();B(()=>Z(ee,t(S).content||(t(S).isStreaming?"Thinking...":""))),h(U,ee)};E(Rt,U=>{t(st).cleanContent?U($t):t(st).attachments.length>0?U(R,1):U(i,-1)})}var v=f(Rt,2);{var y=U=>{var ee=jd();h(U,ee)};E(v,U=>{t(S).isStreaming&&t(dt)&&U(y)})}d(_t);var C=f(_t,2);{var j=U=>{var ee=Vd();gn(ee,21,()=>t(st).attachments,Pn,(Ae,Qe)=>{var ot=qd(),Mt=f(u(ot),2),qe=u(Mt,!0);d(Mt),d(ot),B(()=>{me(Mt,"title",t(Qe)),Z(qe,t(Qe))}),h(Ae,ot)}),d(ee),h(U,ee)};E(C,U=>{t(st).attachments.length>0&&U(j)})}h(Xe,Ke)};E(Be,Xe=>{t(S).role==="thinking"?Xe(ut):t(S).role==="tool"?Xe(oe,1):t(S).role==="assistant"&&t(S).content!==""?Xe(Re,2):Xe(Ut,-1)})}var vn=f(Be,2);{var Sn=Xe=>{var st=Xd(),Ke=Nt(st),_t=u(Ke);{var Rt=v=>{var y=Yd();et(2),h(v,y)};E(_t,v=>{t(S).role==="user"&&t(S).delivery==="sending"&&v(Rt)})}var $t=f(_t);d(Ke);var R=f(Ke,2);{var i=v=>{var y=Zd(),C=f(u(y),2),j=f(C,2);d(y),H("click",C,()=>ya(t(S).id)),H("click",j,()=>wa(t(S).id)),h(v,y)};E(R,v=>{t(S).role==="user"&&t(S).delivery==="failed"&&v(i)})}B(v=>{Jt(Ke,1,`mt-1 flex items-center gap-1.5 text-xs opacity-50 ${t(S).role==="user"?"justify-end text-brand-text-muted":t(S).role==="assistant"?"text-brand-purple":"text-brand-text-muted"}`),Z($t,` ${v??""}`)},[()=>Qt(t(S).timestamp)]),h(Xe,st)};E(vn,Xe=>{t(S).role!=="thinking"&&t(S).role!=="tool"&&Xe(Sn)})}d(Te),d(Ie),B(Xe=>{me(Ie,"data-msg-id",t(S).id),Jt(Ie,1,`flex ${t(S).role==="user"?"justify-end":"justify-start"}`),Jt(Te,1,`max-w-[85%] rounded-lg px-4 py-3 ${Xe??""}`)},[()=>t(S).role==="user"?"bg-brand-blue/80 text-brand-text":t(S).role==="thinking"?"border-l-2 border-brand-border bg-brand-surface/30 text-sm text-brand-text-muted":t(S).role==="tool"&&t(S).toolName==="attach_file"?"bg-transparent p-0 text-brand-text":t(S).role==="tool"?r().hideTools&&!jt(t(S))?"border-l-2 border-brand-border bg-brand-surface/30 text-sm text-brand-text-muted":`border-l-2 bg-brand-surface-2 font-mono text-sm text-brand-text ${t(S).isStreaming?"border-amber-400":t(S).isError?"border-rose-400":t(S).interrupted?"border-brand-border":"border-emerald-400"}`:t(S).role==="assistant"?"border-l-2 border-brand-purple bg-brand-purple/10 text-brand-text":t(S).content===""&&t(S).isStreaming?"bg-brand-surface-3 text-brand-text-muted italic":"bg-brand-surface-2 text-brand-text"]),h(Q,Ie)}),d(w),Vn(w,Q=>p(F,Q),()=>t(F)),h(b,w)};E(Lt,b=>{t(ht).connecting&&!t(We)?b(It):!t(ht).connected&&!t(We)?b(Ot,1):!t(We)&&(t(ae)||typeof window<"u"&&window.location.hash)?b(M,2):t(A).sessionFile?t(le).length===0?b(ve,4):b(ke,-1):b(N,3)})}var Pe=f(Lt,2),ne=u(Pe),se=u(ne),Ce=u(se);at(Ce),et(),d(se);var Se=f(se,2);{var bt=b=>{var w=eu(),L=u(w),$=u(L,!0);d(L);var W=f(L,2),Q=u(W,!0);d(W),d(w),B(()=>{Jt(w,1,`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs select-none hover:text-brand-text ${t(z)===void 0?"text-brand-text-muted":"text-brand-blue"}`),me(w,"title",t(z)===void 0?`Beep when the agent is waiting: following the default (${t(be)?"on":"off"}). Click to set On for this session.`:t(z)===!0?"Beep when the agent is waiting: ON for this session. Click to set Off.":"Beep when the agent is waiting: OFF for this session. Click to follow the default."),Z($,t(be)?"🔔":"🔕"),Z(Q,t(z)===void 0?`Beep: Default (${t(be)?"on":"off"})`:t(z)?"Beep: On":"Beep: Off")}),H("click",w,he),h(b,w)};E(Se,b=>{t(A).sessionFile&&!O()&&b(bt)})}var qt=f(Se,2);{var cn=b=>{var w=tu(),L=f(u(w),2),$=u(L,!0);d(L),d(w),B(W=>{me(w,"title",W),Z($,t(fe))},[()=>r().contextUsage?.tokens!=null?`${r().contextUsage.tokens.toLocaleString()} context tokens of ${r().contextUsage.contextWindow.toLocaleString()}`:"Context window size"]),h(b,w)};E(qt,b=>{t(fe)&&b(cn)})}d(ne);var dn=f(ne,2);d(Pe);var wt=f(Pe,2);{var Ne=b=>{var w=au(),L=u(w),$=f(u(L),2),W=f(u($)),Q=u(W,!0);d(W),et(),d($);var S=f($,2),Ie=u(S),Te=u(Ie);at(Te);var Be=f(Te,2),ut=f(u(Be));{var oe=Ke=>{var _t=nu();h(Ke,_t)},Re=Ke=>{var _t=ru();h(Ke,_t)};E(ut,Ke=>{t(xe).isGit?Ke(oe):Ke(Re,-1)})}d(Be),d(Ie);var Ut=f(Ie,2);{var vn=Ke=>{var _t=ou(),Rt=u(_t),$t=u(Rt);at($t);var R=f($t,2),i=u(R);d(R),d(Rt);var v=f(Rt,2);{var y=C=>{var j=su(),U=f(u(j),2),ee=u(U);at(ee),ee.value=ee.__value="private",et(),d(U);var Ae=f(U,2),Qe=u(Ae);at(Qe),Qe.value=Qe.__value="public",et(),d(Ae),d(j),lr(te,[],ee,()=>t(nt),ot=>p(nt,ot)),lr(te,[],Qe,()=>t(nt),ot=>p(nt,ot)),h(C,j)};E(v,C=>{t(tt)&&C(y)})}d(_t),B(()=>Z(i,`Create remote ${t(xe).matchingRule.provider??""} repository`)),On($t,()=>t(tt),C=>p(tt,C)),h(Ke,_t)};E(Ut,Ke=>{t(xe).matchingRule&&Ke(vn)})}d(S);var Sn=f(S,2),Xe=u(Sn),st=f(Xe,2);d(Sn),d(L),d(w),B(()=>{Z(Q,t(Ee)),Te.disabled=t(xe).isGit}),On(Te,()=>t(lt),Ke=>p(lt,Ke)),H("click",Xe,()=>p(ge,!1)),H("click",st,()=>{p(ge,!1),qn(t(Ee).trim(),t(He)||void 0,t(lt),t(xe).matchingRule?t(tt):void 0,t(xe).matchingRule?t(nt):void 0)}),h(b,w)};E(wt,b=>{t(ge)&&b(Ne)})}var ie=f(wt,2);{var ce=b=>{var w=lu(),L=u(w),$=f(u(L),2),W=u($),Q=f(W),S=u(Q,!0);d(Q),et(),d($);var Ie=f($,2);{var Te=Re=>{var Ut=iu(),vn=u(Ut,!0);d(Ut),B(()=>Z(vn,t(St).sshUrl)),h(Re,Ut)};E(Ie,Re=>{t(St)?.sshUrl&&Re(Te)})}var Be=f(Ie,2),ut=u(Be),oe=f(ut,2);d(Be),d(L),d(w),B(()=>{Z(W,`A ${t(St)?.provider??"remote"??""} repository matching `),Z(S,t(Ee))}),H("click",ut,()=>{p(ct,!1),p(St,null),we(!1)}),H("click",oe,()=>{p(ct,!1),p(St,null),we(!0)}),h(b,w)};E(ie,b=>{t(ct)&&b(ce)})}d(Ct),B(()=>{sa(Ce,r().hideThinking),dn.disabled=!t(dt)}),H("change",Ce,b=>Ca({hideThinking:b.currentTarget.checked})),H("click",dn,function(...b){ka?.apply(this,b)}),h(n,Ct);var Fe=tr(Wt);return q(),Fe}dr(["click","keydown","change"]);function uu(n,e){return n.hasSession?n.readOnly?{action:"blocked",reason:"read-only"}:n.connected?n.agentPending?{action:"blocked",reason:"agent-pending"}:{action:"send",deliverAs:"steer"}:{action:"blocked",reason:"disconnected"}:{action:"blocked",reason:"no-session"}}var fu=g("<option> </option>"),pu=g('<div class="mb-3.5"><label for="speech-locale" class="mb-1 block font-medium text-gray-400">Accent / Locale</label> <select id="speech-locale" class="w-full rounded border border-gray-600 bg-gray-950 px-2 py-1.5 text-white focus:border-blue-500 focus:outline-none"></select></div>'),hu=g('<div class="mt-2 rounded border border-red-900/40 bg-red-950/40 p-2 leading-normal text-red-400"> </div>'),bu=g(`<div class="fixed inset-0 z-40"></div> <div class="absolute right-0 bottom-14 z-50 w-64 rounded-lg border border-gray-600 bg-gray-800 p-4 text-xs text-white shadow-xl"><h4 class="mb-3 border-b border-gray-700 pb-1.5 font-semibold text-gray-300">Speech Settings</h4> <div class="mb-3.5"><span class="mb-1 block font-medium text-gray-400">Speech-to-Text Engine</span> <div class="flex gap-2"><button type="button">On-Device</button> <button type="button">Cloud AI</button></div> <p class="mt-1 text-[10px] leading-relaxed text-gray-400"> </p></div> <!> <div class="mb-2"><label class="flex cursor-pointer items-center gap-2 py-1"><input type="checkbox" class="rounded border-gray-600 bg-gray-950 text-blue-600 focus:ring-0 focus:ring-offset-0"/> <span class="font-medium text-gray-300">Direct Send (Auto-dispatch)</span></label> <p class="pl-6 text-[10px] leading-relaxed text-gray-400">When enabled, releasing or stopping the microphone immediately sends
|
|
77
|
+
the message.</p></div> <!></div>`,1),vu=g('<div class="relative flex shrink-0 items-center gap-1 select-none"><button type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-5 w-5"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" x2="12" y1="19" y2="22"></line></svg></button> <button type="button" class="flex h-[48px] w-[28px] items-center justify-center rounded-lg border border-gray-600 bg-gray-800 text-gray-400 hover:bg-gray-700 hover:text-white disabled:cursor-not-allowed disabled:opacity-40" title="Speech Settings"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg></button> <!></div>');function mu(n,e){er(e,!0);let r=vr(e,"text",15);const s=typeof window<"u"?window.SpeechRecognition||window.webkitSpeechRecognition:null,o=!!s;let a=G(!1),l=G(!1),c=G(!1),_=G(!1),m=G(!1),x=G("en-US"),I=G("browser"),P=G(null),O=G(null),k=null,q=null,te=null,de=null,re=null,je=[],_e="",$e=!1;const fe=[{code:"en-US",label:"English (US)"},{code:"en-GB",label:"English (UK)"},{code:"en-IN",label:"English (India)"},{code:"en-AU",label:"English (Australia)"},{code:"en-CA",label:"English (Canada)"},{code:"en-ZA",label:"English (South Africa)"}];qr(()=>{const T=localStorage.getItem("wherever-speech-direct-send");T!==null&&p(m,T==="true");const F=localStorage.getItem("wherever-speech-locale");F!==null&&p(x,F,!0);const A=localStorage.getItem("wherever-speech-engine");return A!==null?p(I,A,!0):o||p(I,"cloud"),()=>{if(k)try{k.abort()}catch{}if(de)try{de.disconnect()}catch{}if(te)try{te.disconnect()}catch{}if(re)try{re.getTracks().forEach(ae=>ae.stop())}catch{}if(q)try{q.close()}catch{}t(O)&&clearTimeout(t(O))}});function Le(){localStorage.setItem("wherever-speech-direct-send",String(t(m))),localStorage.setItem("wherever-speech-locale",t(x)),localStorage.setItem("wherever-speech-engine",t(I))}function Ee(){const T=localStorage.getItem("wherever-config");if(T){const F=JSON.parse(T),A=window.location.protocol==="https:"?"https:":"http:",ae=F.host.startsWith("http")?F.host.replace(/^wss?:\/\//,""):F.host;return`${A}//${ae}:${F.port}`}return`${window.location.protocol}//${window.location.host}`}function Et(){try{const T=localStorage.getItem("wherever-config");if(T)return JSON.parse(T).token||""}catch{}return""}function it(){try{const T=window.AudioContext||window.webkitAudioContext;if(!T)return;const F=new T,A=F.createOscillator(),ae=F.createGain();A.type="sine",A.frequency.setValueAtTime(400,F.currentTime),ae.gain.setValueAtTime(.08,F.currentTime),ae.gain.exponentialRampToValueAtTime(.001,F.currentTime+.12),A.connect(ae),ae.connect(F.destination),A.start(),A.stop(F.currentTime+.12)}catch(T){console.warn("Could not play audio beep feedback:",T)}}function ue(T,F,A){if(F===A)return T;const ae=F/A,z=Math.round(T.length/ae),be=new Float32Array(z);let he=0,We=0;for(;he<be.length;){const Oe=Math.round((he+1)*ae);let rt=0,xt=0;for(let Ge=We;Ge<Oe&&Ge<T.length;Ge++)rt+=T[Ge],xt++;be[he]=xt>0?rt/xt:0,he++,We=Oe}return be}function Ve(){if(o)try{k=new s,k.continuous=!0,k.interimResults=!0,k.lang=t(x),k.onstart=()=>{p(a,!0),p(l,!1),it()},k.onresult=T=>{let F="",A="";for(let z=T.resultIndex;z<T.results.length;++z){const be=T.results[z];be.isFinal?F+=be[0].transcript:A+=be[0].transcript}const ae=(F+A).trim();ae&&($e=!0,r(_e+(_e?" ":"")+ae))},k.onerror=T=>{console.error("Browser speech recognition error:",T.error),T.error!=="no-speech"&&p(P,`Error: ${T.error}`),Bt()},k.onend=()=>{p(a,!1),t(m)&&$e&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50)},k.start(),navigator.vibrate&&navigator.vibrate(40)}catch(T){console.error("Failed to start browser speech recognition:",T),p(P,"Failed to start browser recording"),p(a,!1)}}function Bt(){if(k)try{k.stop()}catch{}p(a,!1)}async function He(){try{const T=await navigator.mediaDevices.getUserMedia({audio:!0});re=T,je=[];const F=window.AudioContext||window.webkitAudioContext;q=new F,te=q.createMediaStreamSource(T),de=q.createScriptProcessor(4096,1,1),de.onaudioprocess=A=>{const ae=A.inputBuffer.getChannelData(0);je.push(new Float32Array(ae))},te.connect(de),de.connect(q.destination),p(a,!0),p(l,!1),it(),navigator.vibrate&&navigator.vibrate(40)}catch(T){console.error("Failed to start cloud audio recording:",T),p(P,T.message||"Microphone access denied",!0),p(a,!1),p(l,!1)}}function lt(){if(t(a)){if(p(a,!1),p(l,!0),de){try{de.disconnect()}catch{}de.onaudioprocess=null}if(te)try{te.disconnect()}catch{}if(re)try{re.getTracks().forEach(T=>T.stop())}catch{}kt()}}async function kt(){try{if(je.length===0){p(l,!1);return}p(P,null);let T=0;for(const Ht of je)T+=Ht.length;const F=new Float32Array(T);let A=0;for(const Ht of je)F.set(Ht,A),A+=Ht.length;const ae=q?q.sampleRate:48e3,z=16e3,be=ue(F,ae,z),he=St(be,1,z,1,16),We=new Blob([he],{type:"audio/wav"}),Oe=Ee(),rt=Et(),xt=`${Oe}/session/transcribe${rt?`?token=${encodeURIComponent(rt)}`:""}`,Ge=await fetch(xt,{method:"POST",body:We,headers:{"Content-Type":"application/octet-stream"}}),Ue=await Ge.json();if(!Ge.ok)throw new Error(Ue.error||`HTTP ${Ge.status}`);Ue.text&&Ue.text.trim()&&($e=!0,r(_e+(_e?" ":"")+Ue.text.trim()),t(m)&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50))}catch(T){console.error("Cloud transcription request failed:",T),p(P,T.message||"Cloud API failed",!0)}finally{if(p(l,!1),q){try{q.close()}catch{}q=null}}}function tt(){e.disabled||t(a)||t(l)||(p(P,null),$e=!1,_e=r(),t(I)==="cloud"?He():Ve())}function nt(){t(I)==="cloud"?lt():Bt()}function ge(T){if(T.button===0&&!e.disabled){if(T.preventDefault(),t(a)){nt();return}p(c,!1),p(O,setTimeout(()=>{p(c,!0),tt()},350),!0)}}function ct(T){t(O)&&(clearTimeout(t(O)),p(O,null)),t(c)?(p(c,!1),nt()):t(a)||tt()}function De(){t(O)&&(clearTimeout(t(O)),p(O,null)),t(c)&&(p(c,!1),nt())}function St(T,F,A,ae,z){const be=new ArrayBuffer(44+T.length*2),he=new DataView(be);return ht(he,0,"RIFF"),he.setUint32(4,36+T.length*2,!0),ht(he,8,"WAVE"),ht(he,12,"fmt "),he.setUint32(16,16,!0),he.setUint16(20,ae,!0),he.setUint16(22,F,!0),he.setUint32(24,A,!0),he.setUint32(28,A*F*(z/8),!0),he.setUint16(32,F*(z/8),!0),he.setUint16(34,z,!0),ht(he,36,"data"),he.setUint32(40,T.length*2,!0),we(he,44,T),be}function we(T,F,A){for(let ae=0;ae<A.length;ae++,F+=2){let z=Math.max(-1,Math.min(1,A[ae]));T.setInt16(F,z<0?z*32768:z*32767,!0)}}function ht(T,F,A){for(let ae=0;ae<A.length;ae++)T.setUint8(F+ae,A.charCodeAt(ae))}var Yt=vu(),gt=u(Yt),xe=f(gt,2),en=u(xe);d(xe);var J=f(xe,2);{var pe=T=>{var F=bu(),A=Nt(F),ae=f(A,2),z=f(u(ae),2),be=f(u(z),2),he=u(be),We=f(he,2);d(be);var Oe=f(be,2),rt=u(Oe,!0);d(Oe),d(z);var xt=f(z,2);{var Ge=Tt=>{var yt=pu(),Ze=f(u(yt),2);gn(Ze,21,()=>fe,Pn,(tn,Zt)=>{var Xt=fu(),kn=u(Xt,!0);d(Xt);var le={};B(()=>{Z(kn,t(Zt).label),le!==(le=t(Zt).code)&&(Xt.value=(Xt.__value=t(Zt).code)??"")}),h(tn,Xt)}),d(Ze),d(yt),H("change",Ze,Le),Gr(Ze,()=>t(x),tn=>p(x,tn)),h(Tt,yt)};E(xt,Tt=>{t(I)==="browser"&&Tt(Ge)})}var Ue=f(xt,2),Ht=u(Ue),Gt=u(Ht);at(Gt),et(2),d(Ht),et(2),d(Ue);var fn=f(Ue,2);{var pn=Tt=>{var yt=hu(),Ze=u(yt,!0);d(yt),B(()=>Z(Ze,t(P))),h(Tt,yt)};E(fn,Tt=>{t(P)&&Tt(pn)})}d(ae),B(()=>{he.disabled=!o,Jt(he,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors disabled:opacity-40
|
|
78
78
|
${t(I)==="browser"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),Jt(We,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors
|
|
79
|
-
${t(I)==="cloud"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),Z(rt,t(I)==="browser"?"Uses free built-in browser dictation. Streaming, zero-latency.":"Uses server-side Z.ai / Groq / OpenAI keys. High accent tolerance.")}),H("click",A,()=>p(_,!1)),H("click",he,()=>{p(I,"browser"),Le()}),H("click",We,()=>{p(I,"cloud"),Le()}),H("change",Gt,Le),
|
|
80
|
-
${t(a)?"animate-pulse border-red-500 bg-red-600 text-white":t(l)?"cursor-wait border-amber-500 bg-amber-600 text-white":"border-gray-600 bg-gray-800 text-gray-400 hover:bg-gray-700 hover:text-white"}`),me(gt,"title",t(a)?"Recording (release/tap to stop)...":t(l)?"Processing speech...":"Hold to speak (walkie-talkie) or Tap to toggle recording"),xe.disabled=e.disabled&&!t(a)&&!t(l)||t(l),Jt(en,0,`h-4 w-4 transition-transform duration-200 ${t(_)?"rotate-45 text-white":""}`)}),H("pointerdown",gt,ge),H("pointerup",gt,ct),cr("pointercancel",gt,De),H("click",xe,()=>p(_,!t(_))),h(n,Yt),tr()}dr(["pointerdown","pointerup","click","change"]);var gu=g('<span class="inline-block h-1.5 w-1.5 animate-ping rounded-full bg-amber-400"></span> <span>Connecting to remote server...</span>',1),xu=g('<span class="text-rose-400">⚠️</span> <span class="text-rose-400/80"> </span>',1),_u=g('<span class="inline-block h-1.5 w-1.5 rounded-full bg-brand-surface-3"></span> <span>Disconnected from remote server</span>',1),yu=g('<div class="mb-2.5 flex items-center gap-1.5 text-xs font-medium text-brand-text-muted select-none"><!></div>'),wu=g('<div class="flex items-center"><button type="button" class="flex w-full items-center justify-between rounded-lg border border-brand-border bg-brand-surface-2 px-4 py-2.5 text-sm text-brand-text-muted transition-all hover:bg-brand-surface-3 hover:text-brand-text"><span class="flex items-center gap-2"><span> </span> <span><!></span></span> <span class="rounded bg-brand-surface-3 px-2 py-1 text-xs font-medium text-brand-text transition-colors hover:bg-brand-surface-2">Expand ▲</span></button></div>'),ku=g('<span class="inline-block h-3 w-3 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span>'),Su=g('<a target="_blank" class="ml-1 shrink-0 font-semibold text-brand-blue underline hover:opacity-80">[Test Link]</a>'),Tu=g('<span class="flex items-center gap-1 text-[10px] font-medium text-rose-400"><span class="max-w-[120px] truncate"> </span> <!></span>'),Au=g('<span class="text-emerald-400">✓</span>'),Eu=g('<div class="flex items-center gap-2 rounded border border-brand-border bg-brand-surface-2 px-2.5 py-1.5 text-xs"><span class="max-w-[150px] truncate font-medium text-brand-text"> </span> <!> <button type="button" class="ml-1 font-bold text-brand-text-muted hover:text-brand-text">×</button></div>'),Cu=g('<div class="mb-3 flex flex-wrap gap-2"></div>'),Iu=g("<option> </option>"),Ru=g('<div class="mb-2 flex items-center gap-2"><label for="search-model" class="text-xs font-medium text-brand-text-muted">Model</label> <select id="search-model" class="min-w-0 flex-1 rounded-lg border border-brand-border bg-brand-surface-2 px-2 py-1.5 text-xs text-brand-text focus:border-brand-blue focus:outline-none disabled:opacity-50"></select></div>'),$u=g('<button type="button" class="flex h-[40px] w-full items-center justify-center rounded-lg border border-brand-border bg-brand-surface-2 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text disabled:cursor-not-allowed disabled:opacity-50" title="Attach file (image or document)">📎</button> <input type="file" multiple="" class="hidden"/>',1),Mu=g('<span class="hidden font-mono opacity-60 sm:inline">Shift+Enter to send</span>'),Du=g('<!> <!> <form class="flex items-stretch gap-3"><div class="min-w-0 flex-1"><textarea class="h-full max-h-48 min-h-[120px] w-full resize-none overflow-y-auto rounded-lg border border-brand-border bg-brand-surface-2 px-4 py-3 leading-relaxed text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none disabled:opacity-50"></textarea></div> <div class="flex w-[80px] shrink-0 flex-col justify-end gap-2"><!> <div class="flex w-full justify-center"><!></div> <button type="submit" class="flex h-[40px] w-full items-center justify-center rounded-lg bg-gradient-to-r from-brand-cyan to-brand-blue text-xs font-medium text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:bg-brand-surface-3 disabled:from-brand-surface-3 disabled:to-brand-surface-3 disabled:opacity-50"><!></button></div></form> <div class="mt-2 flex items-center justify-between px-1 text-[11px] text-brand-text-muted select-none"><label class="flex cursor-pointer items-center gap-1.5 hover:text-brand-text"><input type="checkbox" class="rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-0 focus:ring-offset-0"/> <span>Press Enter to send</span></label> <div class="flex items-center gap-3"><button type="button" class="rounded bg-brand-surface-3/50 px-2 py-0.5 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text">Collapse ▽</button> <!></div></div>',1),Pu=g('<div class="border-t border-brand-border p-4"><!> <!></div>');function Lu(n,e){er(e,!0);const r=()=>Me(oo,"$isStreaming",c),s=()=>Me(us,"$isReadOnly",c),o=()=>Me(Yr,"$activeSessionInfo",c),a=()=>Me(Kr,"$isConnected",c),l=()=>Me(Pt,"$piState",c),[c,_]=_r();let m=vr(e,"showAttach",3,!0),x=vr(e,"searchMode",3,!1),I=vr(e,"searchConfigured",3,!1),P=vr(e,"searchModels",19,()=>[]),O=vr(e,"searchModel",15,""),k=G(""),q=G(!0),te=G(!1),de=G(void 0),re=G(
|
|
79
|
+
${t(I)==="cloud"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),Z(rt,t(I)==="browser"?"Uses free built-in browser dictation. Streaming, zero-latency.":"Uses server-side Z.ai / Groq / OpenAI keys. High accent tolerance.")}),H("click",A,()=>p(_,!1)),H("click",he,()=>{p(I,"browser"),Le()}),H("click",We,()=>{p(I,"cloud"),Le()}),H("change",Gt,Le),On(Gt,()=>t(m),Tt=>p(m,Tt)),h(T,F)};E(J,T=>{t(_)&&T(pe)})}d(Yt),B(()=>{gt.disabled=e.disabled&&!t(a)&&!t(l)||t(l),Jt(gt,1,`flex h-[48px] w-[48px] items-center justify-center rounded-lg border transition-all duration-150 disabled:cursor-not-allowed disabled:opacity-40
|
|
80
|
+
${t(a)?"animate-pulse border-red-500 bg-red-600 text-white":t(l)?"cursor-wait border-amber-500 bg-amber-600 text-white":"border-gray-600 bg-gray-800 text-gray-400 hover:bg-gray-700 hover:text-white"}`),me(gt,"title",t(a)?"Recording (release/tap to stop)...":t(l)?"Processing speech...":"Hold to speak (walkie-talkie) or Tap to toggle recording"),xe.disabled=e.disabled&&!t(a)&&!t(l)||t(l),Jt(en,0,`h-4 w-4 transition-transform duration-200 ${t(_)?"rotate-45 text-white":""}`)}),H("pointerdown",gt,ge),H("pointerup",gt,ct),cr("pointercancel",gt,De),H("click",xe,()=>p(_,!t(_))),h(n,Yt),tr()}dr(["pointerdown","pointerup","click","change"]);var gu=g('<span class="inline-block h-1.5 w-1.5 animate-ping rounded-full bg-amber-400"></span> <span>Connecting to remote server...</span>',1),xu=g('<span class="text-rose-400">⚠️</span> <span class="text-rose-400/80"> </span>',1),_u=g('<span class="inline-block h-1.5 w-1.5 rounded-full bg-brand-surface-3"></span> <span>Disconnected from remote server</span>',1),yu=g('<div class="mb-2.5 flex items-center gap-1.5 text-xs font-medium text-brand-text-muted select-none"><!></div>'),wu=g('<div class="flex items-center"><button type="button" class="flex w-full items-center justify-between rounded-lg border border-brand-border bg-brand-surface-2 px-4 py-2.5 text-sm text-brand-text-muted transition-all hover:bg-brand-surface-3 hover:text-brand-text"><span class="flex items-center gap-2"><span> </span> <span><!></span></span> <span class="rounded bg-brand-surface-3 px-2 py-1 text-xs font-medium text-brand-text transition-colors hover:bg-brand-surface-2">Expand ▲</span></button></div>'),ku=g('<span class="inline-block h-3 w-3 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span>'),Su=g('<a target="_blank" class="ml-1 shrink-0 font-semibold text-brand-blue underline hover:opacity-80">[Test Link]</a>'),Tu=g('<span class="flex items-center gap-1 text-[10px] font-medium text-rose-400"><span class="max-w-[120px] truncate"> </span> <!></span>'),Au=g('<span class="text-emerald-400">✓</span>'),Eu=g('<div class="flex items-center gap-2 rounded border border-brand-border bg-brand-surface-2 px-2.5 py-1.5 text-xs"><span class="max-w-[150px] truncate font-medium text-brand-text"> </span> <!> <button type="button" class="ml-1 font-bold text-brand-text-muted hover:text-brand-text">×</button></div>'),Cu=g('<div class="mb-3 flex flex-wrap gap-2"></div>'),Iu=g("<option> </option>"),Ru=g('<div class="mb-2 flex items-center gap-2"><label for="search-model" class="text-xs font-medium text-brand-text-muted">Model</label> <select id="search-model" class="min-w-0 flex-1 rounded-lg border border-brand-border bg-brand-surface-2 px-2 py-1.5 text-xs text-brand-text focus:border-brand-blue focus:outline-none disabled:opacity-50"></select></div>'),$u=g('<button type="button" class="flex h-[40px] w-full items-center justify-center rounded-lg border border-brand-border bg-brand-surface-2 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text disabled:cursor-not-allowed disabled:opacity-50" title="Attach file (image or document)">📎</button> <input type="file" multiple="" class="hidden"/>',1),Mu=g('<span class="hidden font-mono opacity-60 sm:inline">Shift+Enter to send</span>'),Du=g('<!> <!> <form class="flex items-stretch gap-3"><div class="min-w-0 flex-1"><textarea class="h-full max-h-48 min-h-[120px] w-full resize-none overflow-y-auto rounded-lg border border-brand-border bg-brand-surface-2 px-4 py-3 leading-relaxed text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none disabled:opacity-50"></textarea></div> <div class="flex w-[80px] shrink-0 flex-col justify-end gap-2"><!> <div class="flex w-full justify-center"><!></div> <button type="submit" class="flex h-[40px] w-full items-center justify-center rounded-lg bg-gradient-to-r from-brand-cyan to-brand-blue text-xs font-medium text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:bg-brand-surface-3 disabled:from-brand-surface-3 disabled:to-brand-surface-3 disabled:opacity-50"><!></button></div></form> <div class="mt-2 flex items-center justify-between px-1 text-[11px] text-brand-text-muted select-none"><label class="flex cursor-pointer items-center gap-1.5 hover:text-brand-text"><input type="checkbox" class="rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-0 focus:ring-offset-0"/> <span>Press Enter to send</span></label> <div class="flex items-center gap-3"><button type="button" class="rounded bg-brand-surface-3/50 px-2 py-0.5 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text">Collapse ▽</button> <!></div></div>',1),Pu=g('<div class="border-t border-brand-border p-4"><!> <!></div>');function Lu(n,e){er(e,!0);const r=()=>Me(oo,"$isStreaming",c),s=()=>Me(us,"$isReadOnly",c),o=()=>Me(Yr,"$activeSessionInfo",c),a=()=>Me(Kr,"$isConnected",c),l=()=>Me(Pt,"$piState",c),[c,_]=_r();let m=vr(e,"showAttach",3,!0),x=vr(e,"searchMode",3,!1),I=vr(e,"searchConfigured",3,!1),P=vr(e,"searchModels",19,()=>[]),O=vr(e,"searchModel",15,""),k=G(""),q=G(!0),te=G(!1),de=G(void 0),re=G(Mn([])),je=K(r),_e=K(s),$e=K(o),fe=K(a),Le=K(l),Ee=K(()=>x()?e.disabled||!t(fe)||!I():e.disabled||!t(fe)||t(_e)||!t($e).sessionId),Et=K(()=>t(re).some(J=>J.uploading)),it=K(()=>!t(Ee)&&!t(Et)&&(t(k).trim().length>0||t(re).length>0)),ue=G(void 0);const Ve="wherever-draft:";let Bt=K(()=>Ve+(t($e).sessionId??"search")),He=G(null);qr(()=>{const J=localStorage.getItem("wherever-enter-to-send");J!==null&&p(q,J==="true")}),Dt(()=>{const J=t(Bt);J!==t(He)&&Ks(()=>{let pe=null;if(typeof localStorage<"u")try{pe=localStorage.getItem(J)}catch{}p(k,pe??"",!0),p(He,J,!0)})}),Dt(()=>{const J=t(k),pe=t(Bt);if(!(pe!==t(He)||typeof localStorage>"u"))try{J.trim().length>0?localStorage.setItem(pe,J):localStorage.removeItem(pe)}catch{}});function lt(){t(te)&&p(te,!1),t(ue)?.focus()}function kt(){p(q,!t(q)),localStorage.setItem("wherever-enter-to-send",String(t(q)))}Dt(()=>{t(ue)&&(t(k),t(ue).style.height="auto",t(ue).style.height=`${t(ue).scrollHeight}px`)}),Dt(()=>{!t(Ee)&&t(ue)&&t(ue).focus()});async function tt(J){ro();const pe=J.target;if(!pe.files)return;const T=Array.from(pe.files);pe.value="";const F=t(re).length;p(re,[...t(re),...T.map(A=>({name:A.name,uploading:!0}))],!0);for(let A=0;A<T.length;A++){const ae=T[A],z=F+A;try{if(!t($e).sessionId)throw new Error("No active session");const be=await Wa(t($e).sessionId,ae);p(re,t(re).map((he,We)=>We===z?{name:ae.name,path:be.savedPath,uploading:!1}:he),!0)}catch(be){const he=be.message||"Failed to upload";console.error("File upload error details:",be);let We="";try{const Oe=Fn(),rt=Un();We=`${Oe}/health${rt?`?token=${encodeURIComponent(rt)}`:""}`}catch{}p(re,t(re).map((Oe,rt)=>rt===z?{name:ae.name,error:he,url:We,uploading:!1}:Oe),!0)}}}function nt(J){p(re,t(re).filter((pe,T)=>T!==J),!0)}function ge(){const J=t(k).trim();if(x()){if(!J||t(Ee))return;e.onSubmit?.(J),p(k,""),e.onSend?.();return}if(!J&&t(re).length===0)return;let pe=J;if(t(re).length>0){const A=t(re).filter(ae=>ae.path);if(A.length>0){const ae=A.map(z=>`[Uploaded file: ${z.path}]`).join(`
|
|
81
81
|
`);pe?pe+=`
|
|
82
82
|
|
|
83
83
|
`+ae:pe=`I have uploaded the following file(s) for you:
|
|
84
|
-
${ae}`}}if(J.startsWith("/")&&t(re).length===0){const A=J.toLowerCase();if(A==="/new"||A==="/reset"){if(t($e).cwd){qn(t($e).cwd,t($e).model||void 0),p(k,"");return}}else if(A==="/clear"){Ea(),p(k,"");return}else if(A==="/leave"||A==="/exit"){Mn(),p(k,"");return}}const T=uu({streaming:t(je),connected:t(fe),agentPending:t(Le).agentPending,readOnly:t(_e),hasSession:!!t($e).sessionId});if(T.action!=="send"){(T.reason==="disconnected"||T.reason==="agent-pending")&&Us(pe);return}Us(pe)&&(p(k,""),p(re,[],!0),e.onSend?.())}function ct(J){J.key==="Enter"&&(t(q)?J.shiftKey||(J.preventDefault(),ge()):J.shiftKey&&(J.preventDefault(),ge()))}var De={focusInput:lt},St=Pu(),we=u(St);{var ht=J=>{var pe=yu(),T=u(pe);{var F=z=>{var be=gu();et(2),h(z,be)},A=z=>{var be=xu(),he=f(Nt(be),2),We=u(he,!0);d(he),B(()=>Z(We,t(Le).error)),h(z,be)},ae=z=>{var be=_u();et(2),h(z,be)};E(T,z=>{t(Le).connecting?z(F):t(Le).error?z(A,1):t(fe)||z(ae,2)})}d(pe),h(J,pe)};E(we,J=>{(!t(fe)||t(Le).connecting||t(Le).error)&&J(ht)})}var Yt=f(we,2);{var gt=J=>{var pe=wu(),T=u(pe),F=u(T),A=u(F),ae=u(A,!0);d(A);var z=f(A,2),be=u(z);{var he=Ge=>{var Ue=An();B(()=>Z(Ue,e.placeholder??"Search the web...")),h(Ge,Ue)},We=Ge=>{var Ue=An("Agent is working, tap to Steer...");h(Ge,Ue)},Oe=Ge=>{var Ue=An("Read-only mode");h(Ge,Ue)},rt=Ge=>{var Ue=An("Select a session first...");h(Ge,Ue)},xt=Ge=>{var Ue=An("Tap to type a message...");h(Ge,Ue)};E(be,Ge=>{x()?Ge(he):t(je)?Ge(We,1):t(_e)?Ge(Oe,2):t($e).sessionId?Ge(xt,-1):Ge(rt,3)})}d(z),d(F),et(2),d(T),d(pe),B(()=>Z(ae,x()?"🔍":"💬")),H("click",T,()=>{p(te,!1),setTimeout(()=>t(ue)?.focus(),50)}),h(J,pe)},xe=J=>{var pe=Du(),T=Nt(pe);{var F=le=>{var dt=Cu();gn(dt,21,()=>t(re),Dn,(Ft,At,mt)=>{var Qt=Eu(),jt=u(Qt),xn=u(jt,!0);d(jt);var _n=f(jt,2);{var Cn=X=>{var ye=ku();h(X,ye)},D=X=>{var ye=Tu(),Wt=u(ye),Ct=u(Wt);d(Wt);var Lt=f(Wt,2);{var It=Ot=>{var M=Su();B(()=>me(M,"href",t(At).url)),h(Ot,M)};E(Lt,Ot=>{t(At).url&&Ot(It)})}d(ye),B(()=>{me(ye,"title",t(At).error),Z(Ct,`⚠️ ${t(At).error??""}`)}),h(X,ye)},V=X=>{var ye=Au();h(X,ye)};E(_n,X=>{t(At).uploading?X(Cn):t(At).error?X(D,1):X(V,-1)})}var Y=f(_n,2);d(Qt),B(()=>{me(jt,"title",t(At).name),Z(xn,t(At).name)}),H("click",Y,()=>nt(mt)),h(Ft,Qt)}),d(dt),h(le,dt)};E(T,le=>{t(re).length>0&&le(F)})}var A=f(T,2);{var ae=le=>{var dt=Ru(),Ft=f(u(dt),2);gn(Ft,21,P,Dn,(At,mt)=>{var Qt=Iu(),jt=u(Qt,!0);d(Qt);var xn={};B(()=>{Z(jt,t(mt).label),xn!==(xn=t(mt).value)&&(Qt.value=(Qt.__value=t(mt).value)??"")}),h(At,Qt)}),d(Ft),d(dt),B(()=>Ft.disabled=t(Ee)),Gr(Ft,O),h(le,dt)};E(A,le=>{x()&&P().length>0&&le(ae)})}var z=f(A,2),be=u(z),he=u(be);Li(he),me(he,"rows",1),Vn(he,le=>p(ue,le),()=>t(ue)),d(be);var We=f(be,2),Oe=u(We);{var rt=le=>{var dt=$u(),Ft=Nt(dt),At=f(Ft,2);Vn(At,mt=>p(de,mt),()=>t(de)),B(()=>Ft.disabled=t(Ee)),H("click",Ft,()=>{xa(),t(de)?.click()}),H("change",At,tt),h(le,dt)};E(Oe,le=>{m()&&!x()&&le(rt)})}var xt=f(Oe,2),Ge=u(xt);mu(Ge,{get disabled(){return t(Ee)},onSend:ge,get text(){return t(k)},set text(le){p(k,le,!0)}}),d(xt);var Ue=f(xt,2),Ht=u(Ue);{var Gt=le=>{var dt=An();B(()=>Z(dt,e.submitLabel??"Search")),h(le,dt)},fn=le=>{var dt=An("Steer");h(le,dt)},pn=le=>{var dt=An("Send");h(le,dt)};E(Ht,le=>{x()?le(Gt):t(je)?le(fn,1):le(pn,-1)})}d(Ue),d(We),d(z);var Tt=f(z,2),yt=u(Tt),Ze=u(yt);at(Ze),et(2),d(yt);var tn=f(yt,2),Zt=u(tn),Xt=f(Zt,2);{var kn=le=>{var dt=Mu();h(le,dt)};E(Xt,le=>{t(q)||le(kn)})}d(tn),d(Tt),B(()=>{he.disabled=t(Ee),me(he,"placeholder",x()?e.placeholder??"Search the web...":t(fe)?t(je)?"Agent is working, Steer to interrupt...":t(_e)?"Read-only mode":t($e).sessionId?"Type a message...":"Select a session first...":t(Le).connecting?"Reconnecting to remote server...":"Disconnected - cannot send"),Ue.disabled=!t(it),me(Ue,"title",!x()&&t(je)?"Steer the agent now (injected at the next step, before the next model call)":void 0),sa(Ze,t(q))}),cr("submit",z,le=>{le.preventDefault(),ge()}),H("keydown",he,ct),Pn(he,()=>t(k),le=>p(k,le)),H("change",Ze,kt),H("click",Zt,()=>p(te,!0)),h(J,pe)};E(Yt,J=>{t(te)?J(gt):J(xe,-1)})}d(St),h(n,St);var en=tr(De);return _(),en}dr(["click","keydown","change"]);var Ou=g('<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>'),Nu=g('<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>'),Fu=g('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),Uu=g('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),zu=g("<option> </option>"),Bu=g('<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>'),Hu=g('<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"/>'),Wu=g('<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>'),Gu=g('<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>'),ju=g('<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>'),qu=g('<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>'),Vu=g('<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>'),Ku=g('<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>'),Yu=g('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),Zu=g('<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>'),Xu=g('<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>'),Qu=g('<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>'),Ju=g('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),ef=g('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),tf=g('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),nf=g('<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>'),rf=g('<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>'),sf=g('<div class="flex-shrink-0"><!></div>'),of=g('<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>'),af=g('<div class="px-3 pb-2"><!> <!></div>'),lf=g('<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>'),cf=g("<option> </option>"),df=g('<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>'),uf=g('<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"/>'),ff=g('<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>'),pf=g('<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>'),hf=g('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),bf=g('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),vf=g('<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>'),mf=g('<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>'),gf=g('<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>'),xf=g('<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 ea(n,e){er(e,!0);const r=()=>Me(Nr,"$readOnlySessionFolders",I),s=()=>Me(Er,"$sessionFolders",I),o=()=>Me(Yr,"$activeSessionInfo",I),a=()=>Me(Kr,"$isConnected",I),l=()=>Me(fs,"$isLoadingSession",I),c=()=>Me(io,"$isResyncing",I),_=()=>Me(Cr,"$availableModels",I),m=()=>Me(Xs,"$gitInitDefaultStore",I),x=()=>Me(ao,"$sessionError",I),[I,P]=_r(),O=[];let k=vr(e,"readOnly",3,!1),q=K(()=>k()?r().folders:s().folders),te=K(()=>k()?r().loading:s().loading);function de(){k()?ca():Br()}let re=K(()=>o().sessionFile),je=K(a),_e=K(l),$e=K(c),fe=K(()=>_().models),Le=$n({}),Ee=G($n({})),Et=G(null),it=G(null),ue=G(""),Ve=G($n([]));Dt(()=>{t(je)&&(de(),k()||(sl(),al()))});function Bt(D,V,Y){if(!Y)return!0;const X=Y.toLowerCase();return(D.name||"").toLowerCase().includes(X)||D.firstMessage.toLowerCase().includes(X)||V.toLowerCase().includes(X)}Dt(()=>{const D=t(ue),V=t(q);D?p(Ve,V.map(Y=>({...Y,sessions:Y.sessions.filter(X=>Bt(X,Y.name,D))})).filter(Y=>Y.sessions.length>0),!0):(p(Ve,V,!0),p(Ee,{},!0))});function He(D){return t(ue)?t(Ee)[D]!==void 0?t(Ee)[D]:!0:!!Le[D]}function lt(D){t(ue)?t(Ee)[D]=!He(D):Le[D]=!He(D)}async function kt(D){try{t(re)===D&&(typeof window<"u"&&(window.location.hash=""),Mn()),await Hs(D),t(Et)===D&&p(Et,null),Br()}catch(V){console.error("Failed to delete session:",V)}}async function tt(D){try{const V=D.sessions.map(Y=>Y.path);t(re)&&V.includes(t(re))&&(typeof window<"u"&&(window.location.hash=""),Mn()),await Promise.all(D.sessions.map(Y=>Hs(Y.path))),t(it)===D.path&&p(it,null),Br()}catch(V){console.error("Failed to delete all sessions of folder:",V)}}function nt(D){t(re)===D&&!t(_e)&&!t($e)||(gr(),so(D))}let ge=G(!1),ct=G(""),De=G($n([])),St=G(!1),we=G(null),ht=G(null),Yt="",gt=G(""),xe=G(!1),en=G(null),J=G(!0),pe=G("private"),T=G(!1),F=K(m);Dt(()=>{t(en)===null&&p(xe,t(F),!0)});let A=G($n({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),ae=K(()=>t(A).exists!==!0&&t(A).matchingRule&&t(J)),z=null;async function be(D,V=!1){if(z&&clearTimeout(z),D===Yt&&!V)return;if(Yt=D,!D.trim()){p(A,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const X=async()=>{const ye=await ss("");p(De,ye||[],!0)};V?await X():z=setTimeout(X,300);return}const Y=async()=>{const[X,ye]=await Promise.all([pa(D),ss(D)]);p(De,ye||[],!0),X?(p(A,{exists:X.exists,isGit:X.isGit,resolvedPath:X.resolvedPath,matchingRule:X.matchingRule||null},!0),X.exists||(p(xe,t(en)!==null?t(en):t(F),!0),p(J,!0),X.matchingRule&&p(pe,X.matchingRule.visibility,!0))):p(A,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};V?await Y():z=setTimeout(Y,300)}Dt(()=>{const D=t(ct);be(D,!1)}),Dt(()=>{if(t(fe).length>0&&!t(gt)){const D=t(fe).find(V=>V.isDefault);D?p(gt,`${D.provider}:${D.modelId}`):p(gt,`${t(fe)[0].provider}:${t(fe)[0].modelId}`)}});function he(){if(t(ct).trim())if(t(A).exists===!0)p(xe,!1),p(J,!1),t(A).matchingRule&&p(pe,t(A).matchingRule.visibility,!0),p(T,!0);else{gr();const D=t(ct).trim(),V=t(gt)||void 0,Y=t(xe),X=t(A).matchingRule?t(J):void 0,ye=t(A).matchingRule?t(pe):void 0;p(ct,""),p(ge,!1),t(re)?(Mn(),setTimeout(()=>{qn(D,V,Y,X,ye)},100)):qn(D,V,Y,X,ye)}}function We(){p(T,!1),gr();const D=t(ct).trim(),V=t(gt)||void 0,Y=t(xe),X=t(A).matchingRule?t(J):void 0,ye=t(A).matchingRule?t(pe):void 0;p(ct,""),p(ge,!1),t(re)?(Mn(),setTimeout(()=>{qn(D,V,Y,X,ye)},100)):qn(D,V,Y,X,ye)}let Oe=G($n({open:!1,folderPath:"",selected:""}));function rt(D){const V=t(fe).find(Y=>Y.isDefault);p(Oe,{open:!0,folderPath:D,selected:V?`${V.provider}:${V.modelId}`:""},!0)}function xt(){t(Oe).open=!1}function Ge(){if(!t(Oe).open)return;gr();const D=t(Oe).folderPath,V=t(Oe).selected||void 0;xt(),t(re)?(Mn(),setTimeout(()=>{qn(D,V)},100)):qn(D,V)}function Ue(D){const V=Date.now()-new Date(D).getTime(),Y=Math.floor(V/6e4);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;const X=Math.floor(Y/60);return X<24?`${X}h ago`:`${Math.floor(X/24)}d ago`}function Ht(D,V=40){return D.length>V?D.slice(0,V)+"...":D}var Gt=xf(),fn=Nt(Gt),pn=u(fn),Tt=u(pn),yt=u(Tt);at(yt);var Ze=f(yt,2),tn=u(Ze);d(Ze),d(Tt),d(pn);var Zt=f(pn,2),Xt=u(Zt);{var kn=D=>{var V=Vu(),Y=u(V),X=u(Y),ye=u(X,!0);d(X),d(Y);var Wt=f(Y,2);{var Ct=Lt=>{var It=qu(),Ot=u(It),M=f(u(Ot),2),N=u(M);at(N),Vn(N,ie=>p(we,ie),()=>t(we));var ve=f(N,2);{var ke=ie=>{var ce=Nu();gn(ce,21,()=>t(De),Dn,(Fe,b)=>{var w=Ou(),L=u(w,!0);d(w),B(()=>Z(L,t(b))),H("click",w,()=>{p(ct,t(b),!0),be(t(b),!0),t(we)?.focus()}),h(Fe,w)}),d(ce),h(ie,ce)};E(ve,ie=>{t(St)&&t(De).length>0&&ie(ke)})}d(M),Vn(M,ie=>p(ht,ie),()=>t(ht));var Pe=f(M,2);{var ne=ie=>{var ce=Uu(),Fe=f(u(ce));{var b=w=>{var L=Fu();h(w,L)};E(Fe,w=>{t(A).isGit&&w(b)})}d(ce),h(ie,ce)};E(Pe,ie=>{t(A).exists===!0&&ie(ne)})}d(Ot);var se=f(Ot,2),Ce=f(u(se),2);{var Se=ie=>{var ce=Bu();gn(ce,21,()=>t(fe),Dn,(Fe,b)=>{var w=zu(),L=u(w);d(w);var $={};B(()=>{Z(L,`${t(b).label??""}${t(b).isDefault?" (default)":""}`),$!==($=`${t(b).provider}:${t(b).modelId}`)&&(w.value=w.__value=`${t(b).provider}:${t(b).modelId}`)}),h(Fe,w)}),d(ce),Gr(ce,()=>t(gt),Fe=>p(gt,Fe)),h(ie,ce)},bt=ie=>{var ce=Hu();at(ce),Pn(ce,()=>t(gt),Fe=>p(gt,Fe)),h(ie,ce)};E(Ce,ie=>{t(fe).length>0?ie(Se):ie(bt,-1)})}d(se);var qt=f(se,2);{var cn=ie=>{var ce=Gu(),Fe=u(ce),b=u(Fe);at(b);var w=f(b,2),L=u(w);d(w),d(Fe);var $=f(Fe,2);{var W=Q=>{var S=Wu(),Ie=f(u(S),2),Te=u(Ie);at(Te),Te.value=Te.__value="private",et(),d(Ie);var Be=f(Ie,2),ut=u(Be);at(ut),ut.value=ut.__value="public",et(),d(Be),d(S),lr(O,[],Te,()=>t(pe),oe=>p(pe,oe)),lr(O,[],ut,()=>t(pe),oe=>p(pe,oe)),h(Q,S)};E($,Q=>{t(J)&&Q(W)})}d(ce),B(()=>Z(L,`Create remote ${t(A).matchingRule.provider??""} repository`)),Ln(b,()=>t(J),Q=>p(J,Q)),h(ie,ce)};E(qt,ie=>{t(A).exists!==!0&&t(A).matchingRule&&ie(cn)})}var dn=f(qt,2);{var wt=ie=>{var ce=ju(),Fe=u(ce);at(Fe),et(2),d(ce),H("change",Fe,b=>{p(en,b.currentTarget.checked,!0)}),Ln(Fe,()=>t(xe),b=>p(xe,b)),h(ie,ce)};E(dn,ie=>{t(A).exists!==!0&&(!t(A).matchingRule||!t(J))&&ie(wt)})}var Ne=f(dn,2);d(It),B(ie=>{Jt(N,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(ae)?"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"}`),Ne.disabled=ie},[()=>!t(ct).trim()]),cr("submit",It,ie=>{ie.preventDefault(),he()}),cr("focus",N,()=>{p(St,!0),be(t(ct),!0)}),cr("blur",N,ie=>{t(ht)&&t(ht).contains(ie.relatedTarget)||p(St,!1)}),H("keydown",N,ie=>{ie.key==="Escape"&&p(St,!1)}),Pn(N,()=>t(ct),ie=>p(ct,ie)),h(Lt,It)};E(Wt,Lt=>{t(ge)&&Lt(Ct)})}d(V),B(()=>Z(ye,t(ge)?"▼ Close Create Session":"✚ Create New Session")),H("click",Y,()=>p(ge,!t(ge))),h(D,V)};E(Xt,D=>{k()||D(kn)})}var le=f(Xt,2);{var dt=D=>{var V=Ku();h(D,V)},Ft=D=>{var V=Yu(),Y=u(V,!0);d(V),B(()=>Z(Y,t(ue)?"No sessions match your filter":"No sessions found")),h(D,V)},At=D=>{var V=jn(),Y=Nt(V);gn(Y,17,()=>t(Ve),X=>X.path,(X,ye)=>{var Wt=lf(),Ct=u(Wt),Lt=u(Ct),It=f(Lt,2),Ot=u(It),M=u(Ot,!0);d(Ot);var N=f(Ot,2),ve=u(N,!0);d(N),d(It);var ke=f(It,2),Pe=u(ke,!0);d(ke),d(Ct);var ne=f(Ct,2);{var se=Se=>{var bt=af(),qt=u(bt);{var cn=wt=>{var Ne=Qu(),ie=u(Ne),ce=f(ie,2),Fe=u(ce);{var b=L=>{var $=Zu(),W=u($),Q=f(W,2);d($),H("click",W,S=>{S.stopPropagation(),tt(t(ye))}),H("click",Q,S=>{S.stopPropagation(),p(it,null)}),h(L,$)},w=L=>{var $=Xu();H("click",$,W=>{W.stopPropagation(),p(it,t(ye).path,!0)}),h(L,$)};E(Fe,L=>{t(it)===t(ye).path?L(b):L(w,-1)})}d(ce),d(Ne),H("click",ie,()=>rt(t(ye).path)),h(wt,Ne)};E(qt,wt=>{k()||wt(cn)})}var dn=f(qt,2);gn(dn,17,()=>t(ye).sessions,wt=>wt.path,(wt,Ne)=>{var ie=of(),ce=u(ie),Fe=u(ce);{var b=oe=>{var Re=Ju();h(oe,Re)},w=oe=>{var Re=ef();h(oe,Re)};E(Fe,oe=>{t(Ne).isActive?oe(b):oe(w,-1)})}var L=f(Fe,2),$=u(L),W=u($,!0);d($);var Q=f($,2),S=u(Q);d(Q),d(L);var Ie=f(L,2);{var Te=oe=>{var Re=tf(),Ut=u(Re,!0);d(Re),B(()=>Z(Ut,t(Ne).clientCount)),h(oe,Re)};E(Ie,oe=>{t(Ne).clientCount>0&&oe(Te)})}d(ce);var Be=f(ce,2);{var ut=oe=>{var Re=sf(),Ut=u(Re);{var vn=Xe=>{var st=nf(),Ke=u(st),_t=f(Ke,2);d(st),H("click",Ke,Rt=>{Rt.stopPropagation(),kt(t(Ne).path)}),H("click",_t,Rt=>{Rt.stopPropagation(),p(Et,null)}),h(Xe,st)},Sn=Xe=>{var st=rf();H("click",st,Ke=>{Ke.stopPropagation(),p(Et,t(Ne).path,!0)}),h(Xe,st)};E(Ut,Xe=>{t(Et)===t(Ne).path?Xe(vn):Xe(Sn,-1)})}d(Re),h(oe,Re)};E(Be,oe=>{k()||oe(ut)})}d(ie),B((oe,Re,Ut)=>{Jt(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 ${t(re)===t(Ne).path?"bg-brand-surface-3":""}`),me(ce,"href",`#${oe??""}`),Z(W,Re),Z(S,`${Ut??""} · ${t(Ne).messageCount??""}
|
|
85
|
-
msgs`)},[()=>encodeURIComponent(t(Ne).id),()=>t(Ne).name||Ht(t(Ne).firstMessage)||"Empty session",()=>Ue(t(Ne).modified)]),H("click",ce,oe=>{oe.button===0&&!oe.ctrlKey&&!oe.metaKey&&!oe.altKey&&!oe.shiftKey&&(oe.preventDefault(),nt(t(Ne).path))}),h(wt,ie)}),d(bt),h(Se,bt)},Ce=K(()=>He(t(ye).path));E(ne,Se=>{t(Ce)&&Se(se)})}d(Wt),B(Se=>{Jt(Lt,1,`text-xs text-brand-text-muted transition-transform ${Se??""}`),Z(M,t(ye).name),Z(ve,t(ye).path),Z(Pe,t(ye).sessions.length)},[()=>He(t(ye).path)?"rotate-90":""]),H("click",Ct,()=>lt(t(ye).path)),h(X,Wt)}),h(D,V)};E(le,D=>{t(te)&&t(Ve).length===0?D(dt):t(Ve).length===0?D(Ft,1):D(At,-1)})}d(Zt),d(fn);var mt=f(fn,2);{var Qt=D=>{var V=ff(),Y=u(V),X=f(u(Y),2),ye=f(u(X),2),Wt=u(ye,!0);d(ye),d(X);var Ct=f(X,2),Lt=f(u(Ct),2);{var It=ke=>{var Pe=df();gn(Pe,21,()=>t(fe),
|
|
84
|
+
${ae}`}}if(J.startsWith("/")&&t(re).length===0){const A=J.toLowerCase();if(A==="/new"||A==="/reset"){if(t($e).cwd){qn(t($e).cwd,t($e).model||void 0),p(k,"");return}}else if(A==="/clear"){Ea(),p(k,"");return}else if(A==="/leave"||A==="/exit"){Dn(),p(k,"");return}}const T=uu({streaming:t(je),connected:t(fe),agentPending:t(Le).agentPending,readOnly:t(_e),hasSession:!!t($e).sessionId});if(T.action!=="send"){(T.reason==="disconnected"||T.reason==="agent-pending")&&Us(pe);return}Us(pe)&&(p(k,""),p(re,[],!0),e.onSend?.())}function ct(J){J.key==="Enter"&&(t(q)?J.shiftKey||(J.preventDefault(),ge()):J.shiftKey&&(J.preventDefault(),ge()))}var De={focusInput:lt},St=Pu(),we=u(St);{var ht=J=>{var pe=yu(),T=u(pe);{var F=z=>{var be=gu();et(2),h(z,be)},A=z=>{var be=xu(),he=f(Nt(be),2),We=u(he,!0);d(he),B(()=>Z(We,t(Le).error)),h(z,be)},ae=z=>{var be=_u();et(2),h(z,be)};E(T,z=>{t(Le).connecting?z(F):t(Le).error?z(A,1):t(fe)||z(ae,2)})}d(pe),h(J,pe)};E(we,J=>{(!t(fe)||t(Le).connecting||t(Le).error)&&J(ht)})}var Yt=f(we,2);{var gt=J=>{var pe=wu(),T=u(pe),F=u(T),A=u(F),ae=u(A,!0);d(A);var z=f(A,2),be=u(z);{var he=Ge=>{var Ue=An();B(()=>Z(Ue,e.placeholder??"Search the web...")),h(Ge,Ue)},We=Ge=>{var Ue=An("Agent is working, tap to Steer...");h(Ge,Ue)},Oe=Ge=>{var Ue=An("Read-only mode");h(Ge,Ue)},rt=Ge=>{var Ue=An("Select a session first...");h(Ge,Ue)},xt=Ge=>{var Ue=An("Tap to type a message...");h(Ge,Ue)};E(be,Ge=>{x()?Ge(he):t(je)?Ge(We,1):t(_e)?Ge(Oe,2):t($e).sessionId?Ge(xt,-1):Ge(rt,3)})}d(z),d(F),et(2),d(T),d(pe),B(()=>Z(ae,x()?"🔍":"💬")),H("click",T,()=>{p(te,!1),setTimeout(()=>t(ue)?.focus(),50)}),h(J,pe)},xe=J=>{var pe=Du(),T=Nt(pe);{var F=le=>{var dt=Cu();gn(dt,21,()=>t(re),Pn,(Ft,At,mt)=>{var Qt=Eu(),jt=u(Qt),xn=u(jt,!0);d(jt);var _n=f(jt,2);{var Cn=X=>{var ye=ku();h(X,ye)},D=X=>{var ye=Tu(),Wt=u(ye),Ct=u(Wt);d(Wt);var Lt=f(Wt,2);{var It=Ot=>{var M=Su();B(()=>me(M,"href",t(At).url)),h(Ot,M)};E(Lt,Ot=>{t(At).url&&Ot(It)})}d(ye),B(()=>{me(ye,"title",t(At).error),Z(Ct,`⚠️ ${t(At).error??""}`)}),h(X,ye)},V=X=>{var ye=Au();h(X,ye)};E(_n,X=>{t(At).uploading?X(Cn):t(At).error?X(D,1):X(V,-1)})}var Y=f(_n,2);d(Qt),B(()=>{me(jt,"title",t(At).name),Z(xn,t(At).name)}),H("click",Y,()=>nt(mt)),h(Ft,Qt)}),d(dt),h(le,dt)};E(T,le=>{t(re).length>0&&le(F)})}var A=f(T,2);{var ae=le=>{var dt=Ru(),Ft=f(u(dt),2);gn(Ft,21,P,Pn,(At,mt)=>{var Qt=Iu(),jt=u(Qt,!0);d(Qt);var xn={};B(()=>{Z(jt,t(mt).label),xn!==(xn=t(mt).value)&&(Qt.value=(Qt.__value=t(mt).value)??"")}),h(At,Qt)}),d(Ft),d(dt),B(()=>Ft.disabled=t(Ee)),Gr(Ft,O),h(le,dt)};E(A,le=>{x()&&P().length>0&&le(ae)})}var z=f(A,2),be=u(z),he=u(be);Li(he),me(he,"rows",1),Vn(he,le=>p(ue,le),()=>t(ue)),d(be);var We=f(be,2),Oe=u(We);{var rt=le=>{var dt=$u(),Ft=Nt(dt),At=f(Ft,2);Vn(At,mt=>p(de,mt),()=>t(de)),B(()=>Ft.disabled=t(Ee)),H("click",Ft,()=>{xa(),t(de)?.click()}),H("change",At,tt),h(le,dt)};E(Oe,le=>{m()&&!x()&&le(rt)})}var xt=f(Oe,2),Ge=u(xt);mu(Ge,{get disabled(){return t(Ee)},onSend:ge,get text(){return t(k)},set text(le){p(k,le,!0)}}),d(xt);var Ue=f(xt,2),Ht=u(Ue);{var Gt=le=>{var dt=An();B(()=>Z(dt,e.submitLabel??"Search")),h(le,dt)},fn=le=>{var dt=An("Steer");h(le,dt)},pn=le=>{var dt=An("Send");h(le,dt)};E(Ht,le=>{x()?le(Gt):t(je)?le(fn,1):le(pn,-1)})}d(Ue),d(We),d(z);var Tt=f(z,2),yt=u(Tt),Ze=u(yt);at(Ze),et(2),d(yt);var tn=f(yt,2),Zt=u(tn),Xt=f(Zt,2);{var kn=le=>{var dt=Mu();h(le,dt)};E(Xt,le=>{t(q)||le(kn)})}d(tn),d(Tt),B(()=>{he.disabled=t(Ee),me(he,"placeholder",x()?e.placeholder??"Search the web...":t(fe)?t(je)?"Agent is working, Steer to interrupt...":t(_e)?"Read-only mode":t($e).sessionId?"Type a message...":"Select a session first...":t(Le).connecting?"Reconnecting to remote server...":"Disconnected - cannot send"),Ue.disabled=!t(it),me(Ue,"title",!x()&&t(je)?"Steer the agent now (injected at the next step, before the next model call)":void 0),sa(Ze,t(q))}),cr("submit",z,le=>{le.preventDefault(),ge()}),H("keydown",he,ct),Ln(he,()=>t(k),le=>p(k,le)),H("change",Ze,kt),H("click",Zt,()=>p(te,!0)),h(J,pe)};E(Yt,J=>{t(te)?J(gt):J(xe,-1)})}d(St),h(n,St);var en=tr(De);return _(),en}dr(["click","keydown","change"]);var Ou=g('<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>'),Nu=g('<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>'),Fu=g('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),Uu=g('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),zu=g("<option> </option>"),Bu=g('<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>'),Hu=g('<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"/>'),Wu=g('<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>'),Gu=g('<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>'),ju=g('<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>'),qu=g('<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>'),Vu=g('<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>'),Ku=g('<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>'),Yu=g('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),Zu=g('<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>'),Xu=g('<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>'),Qu=g('<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>'),Ju=g('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),ef=g('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),tf=g('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),nf=g('<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>'),rf=g('<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>'),sf=g('<div class="flex-shrink-0"><!></div>'),of=g('<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>'),af=g('<div class="px-3 pb-2"><!> <!></div>'),lf=g('<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>'),cf=g("<option> </option>"),df=g('<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>'),uf=g('<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"/>'),ff=g('<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>'),pf=g('<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>'),hf=g('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),bf=g('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),vf=g('<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>'),mf=g('<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>'),gf=g('<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>'),xf=g('<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 ea(n,e){er(e,!0);const r=()=>Me(Nr,"$readOnlySessionFolders",I),s=()=>Me(Er,"$sessionFolders",I),o=()=>Me(Yr,"$activeSessionInfo",I),a=()=>Me(Kr,"$isConnected",I),l=()=>Me(fs,"$isLoadingSession",I),c=()=>Me(io,"$isResyncing",I),_=()=>Me(Cr,"$availableModels",I),m=()=>Me(Xs,"$gitInitDefaultStore",I),x=()=>Me(ao,"$sessionError",I),[I,P]=_r(),O=[];let k=vr(e,"readOnly",3,!1),q=K(()=>k()?r().folders:s().folders),te=K(()=>k()?r().loading:s().loading);function de(){k()?ca():Br()}let re=K(()=>o().sessionFile),je=K(a),_e=K(l),$e=K(c),fe=K(()=>_().models),Le=Mn({}),Ee=G(Mn({})),Et=G(null),it=G(null),ue=G(""),Ve=G(Mn([]));Dt(()=>{t(je)&&(de(),k()||(sl(),al()))});function Bt(D,V,Y){if(!Y)return!0;const X=Y.toLowerCase();return(D.name||"").toLowerCase().includes(X)||D.firstMessage.toLowerCase().includes(X)||V.toLowerCase().includes(X)}Dt(()=>{const D=t(ue),V=t(q);D?p(Ve,V.map(Y=>({...Y,sessions:Y.sessions.filter(X=>Bt(X,Y.name,D))})).filter(Y=>Y.sessions.length>0),!0):(p(Ve,V,!0),p(Ee,{},!0))});function He(D){return t(ue)?t(Ee)[D]!==void 0?t(Ee)[D]:!0:!!Le[D]}function lt(D){t(ue)?t(Ee)[D]=!He(D):Le[D]=!He(D)}async function kt(D){try{t(re)===D&&(typeof window<"u"&&(window.location.hash=""),Dn()),await Hs(D),t(Et)===D&&p(Et,null),Br()}catch(V){console.error("Failed to delete session:",V)}}async function tt(D){try{const V=D.sessions.map(Y=>Y.path);t(re)&&V.includes(t(re))&&(typeof window<"u"&&(window.location.hash=""),Dn()),await Promise.all(D.sessions.map(Y=>Hs(Y.path))),t(it)===D.path&&p(it,null),Br()}catch(V){console.error("Failed to delete all sessions of folder:",V)}}function nt(D){t(re)===D&&!t(_e)&&!t($e)||(gr(),so(D))}let ge=G(!1),ct=G(""),De=G(Mn([])),St=G(!1),we=G(null),ht=G(null),Yt="",gt=G(""),xe=G(!1),en=G(null),J=G(!0),pe=G("private"),T=G(!1),F=K(m);Dt(()=>{t(en)===null&&p(xe,t(F),!0)});let A=G(Mn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),ae=K(()=>t(A).exists!==!0&&t(A).matchingRule&&t(J)),z=null;async function be(D,V=!1){if(z&&clearTimeout(z),D===Yt&&!V)return;if(Yt=D,!D.trim()){p(A,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const X=async()=>{const ye=await ss("");p(De,ye||[],!0)};V?await X():z=setTimeout(X,300);return}const Y=async()=>{const[X,ye]=await Promise.all([pa(D),ss(D)]);p(De,ye||[],!0),X?(p(A,{exists:X.exists,isGit:X.isGit,resolvedPath:X.resolvedPath,matchingRule:X.matchingRule||null},!0),X.exists||(p(xe,t(en)!==null?t(en):t(F),!0),p(J,!0),X.matchingRule&&p(pe,X.matchingRule.visibility,!0))):p(A,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};V?await Y():z=setTimeout(Y,300)}Dt(()=>{const D=t(ct);be(D,!1)}),Dt(()=>{if(t(fe).length>0&&!t(gt)){const D=t(fe).find(V=>V.isDefault);D?p(gt,`${D.provider}:${D.modelId}`):p(gt,`${t(fe)[0].provider}:${t(fe)[0].modelId}`)}});function he(){if(t(ct).trim())if(t(A).exists===!0)p(xe,!1),p(J,!1),t(A).matchingRule&&p(pe,t(A).matchingRule.visibility,!0),p(T,!0);else{gr();const D=t(ct).trim(),V=t(gt)||void 0,Y=t(xe),X=t(A).matchingRule?t(J):void 0,ye=t(A).matchingRule?t(pe):void 0;p(ct,""),p(ge,!1),t(re)?(Dn(),setTimeout(()=>{qn(D,V,Y,X,ye)},100)):qn(D,V,Y,X,ye)}}function We(){p(T,!1),gr();const D=t(ct).trim(),V=t(gt)||void 0,Y=t(xe),X=t(A).matchingRule?t(J):void 0,ye=t(A).matchingRule?t(pe):void 0;p(ct,""),p(ge,!1),t(re)?(Dn(),setTimeout(()=>{qn(D,V,Y,X,ye)},100)):qn(D,V,Y,X,ye)}let Oe=G(Mn({open:!1,folderPath:"",selected:""}));function rt(D){const V=t(fe).find(Y=>Y.isDefault);p(Oe,{open:!0,folderPath:D,selected:V?`${V.provider}:${V.modelId}`:""},!0)}function xt(){t(Oe).open=!1}function Ge(){if(!t(Oe).open)return;gr();const D=t(Oe).folderPath,V=t(Oe).selected||void 0;xt(),t(re)?(Dn(),setTimeout(()=>{qn(D,V)},100)):qn(D,V)}function Ue(D){const V=Date.now()-new Date(D).getTime(),Y=Math.floor(V/6e4);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;const X=Math.floor(Y/60);return X<24?`${X}h ago`:`${Math.floor(X/24)}d ago`}function Ht(D,V=40){return D.length>V?D.slice(0,V)+"...":D}var Gt=xf(),fn=Nt(Gt),pn=u(fn),Tt=u(pn),yt=u(Tt);at(yt);var Ze=f(yt,2),tn=u(Ze);d(Ze),d(Tt),d(pn);var Zt=f(pn,2),Xt=u(Zt);{var kn=D=>{var V=Vu(),Y=u(V),X=u(Y),ye=u(X,!0);d(X),d(Y);var Wt=f(Y,2);{var Ct=Lt=>{var It=qu(),Ot=u(It),M=f(u(Ot),2),N=u(M);at(N),Vn(N,ie=>p(we,ie),()=>t(we));var ve=f(N,2);{var ke=ie=>{var ce=Nu();gn(ce,21,()=>t(De),Pn,(Fe,b)=>{var w=Ou(),L=u(w,!0);d(w),B(()=>Z(L,t(b))),H("click",w,()=>{p(ct,t(b),!0),be(t(b),!0),t(we)?.focus()}),h(Fe,w)}),d(ce),h(ie,ce)};E(ve,ie=>{t(St)&&t(De).length>0&&ie(ke)})}d(M),Vn(M,ie=>p(ht,ie),()=>t(ht));var Pe=f(M,2);{var ne=ie=>{var ce=Uu(),Fe=f(u(ce));{var b=w=>{var L=Fu();h(w,L)};E(Fe,w=>{t(A).isGit&&w(b)})}d(ce),h(ie,ce)};E(Pe,ie=>{t(A).exists===!0&&ie(ne)})}d(Ot);var se=f(Ot,2),Ce=f(u(se),2);{var Se=ie=>{var ce=Bu();gn(ce,21,()=>t(fe),Pn,(Fe,b)=>{var w=zu(),L=u(w);d(w);var $={};B(()=>{Z(L,`${t(b).label??""}${t(b).isDefault?" (default)":""}`),$!==($=`${t(b).provider}:${t(b).modelId}`)&&(w.value=w.__value=`${t(b).provider}:${t(b).modelId}`)}),h(Fe,w)}),d(ce),Gr(ce,()=>t(gt),Fe=>p(gt,Fe)),h(ie,ce)},bt=ie=>{var ce=Hu();at(ce),Ln(ce,()=>t(gt),Fe=>p(gt,Fe)),h(ie,ce)};E(Ce,ie=>{t(fe).length>0?ie(Se):ie(bt,-1)})}d(se);var qt=f(se,2);{var cn=ie=>{var ce=Gu(),Fe=u(ce),b=u(Fe);at(b);var w=f(b,2),L=u(w);d(w),d(Fe);var $=f(Fe,2);{var W=Q=>{var S=Wu(),Ie=f(u(S),2),Te=u(Ie);at(Te),Te.value=Te.__value="private",et(),d(Ie);var Be=f(Ie,2),ut=u(Be);at(ut),ut.value=ut.__value="public",et(),d(Be),d(S),lr(O,[],Te,()=>t(pe),oe=>p(pe,oe)),lr(O,[],ut,()=>t(pe),oe=>p(pe,oe)),h(Q,S)};E($,Q=>{t(J)&&Q(W)})}d(ce),B(()=>Z(L,`Create remote ${t(A).matchingRule.provider??""} repository`)),On(b,()=>t(J),Q=>p(J,Q)),h(ie,ce)};E(qt,ie=>{t(A).exists!==!0&&t(A).matchingRule&&ie(cn)})}var dn=f(qt,2);{var wt=ie=>{var ce=ju(),Fe=u(ce);at(Fe),et(2),d(ce),H("change",Fe,b=>{p(en,b.currentTarget.checked,!0)}),On(Fe,()=>t(xe),b=>p(xe,b)),h(ie,ce)};E(dn,ie=>{t(A).exists!==!0&&(!t(A).matchingRule||!t(J))&&ie(wt)})}var Ne=f(dn,2);d(It),B(ie=>{Jt(N,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(ae)?"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"}`),Ne.disabled=ie},[()=>!t(ct).trim()]),cr("submit",It,ie=>{ie.preventDefault(),he()}),cr("focus",N,()=>{p(St,!0),be(t(ct),!0)}),cr("blur",N,ie=>{t(ht)&&t(ht).contains(ie.relatedTarget)||p(St,!1)}),H("keydown",N,ie=>{ie.key==="Escape"&&p(St,!1)}),Ln(N,()=>t(ct),ie=>p(ct,ie)),h(Lt,It)};E(Wt,Lt=>{t(ge)&&Lt(Ct)})}d(V),B(()=>Z(ye,t(ge)?"▼ Close Create Session":"✚ Create New Session")),H("click",Y,()=>p(ge,!t(ge))),h(D,V)};E(Xt,D=>{k()||D(kn)})}var le=f(Xt,2);{var dt=D=>{var V=Ku();h(D,V)},Ft=D=>{var V=Yu(),Y=u(V,!0);d(V),B(()=>Z(Y,t(ue)?"No sessions match your filter":"No sessions found")),h(D,V)},At=D=>{var V=jn(),Y=Nt(V);gn(Y,17,()=>t(Ve),X=>X.path,(X,ye)=>{var Wt=lf(),Ct=u(Wt),Lt=u(Ct),It=f(Lt,2),Ot=u(It),M=u(Ot,!0);d(Ot);var N=f(Ot,2),ve=u(N,!0);d(N),d(It);var ke=f(It,2),Pe=u(ke,!0);d(ke),d(Ct);var ne=f(Ct,2);{var se=Se=>{var bt=af(),qt=u(bt);{var cn=wt=>{var Ne=Qu(),ie=u(Ne),ce=f(ie,2),Fe=u(ce);{var b=L=>{var $=Zu(),W=u($),Q=f(W,2);d($),H("click",W,S=>{S.stopPropagation(),tt(t(ye))}),H("click",Q,S=>{S.stopPropagation(),p(it,null)}),h(L,$)},w=L=>{var $=Xu();H("click",$,W=>{W.stopPropagation(),p(it,t(ye).path,!0)}),h(L,$)};E(Fe,L=>{t(it)===t(ye).path?L(b):L(w,-1)})}d(ce),d(Ne),H("click",ie,()=>rt(t(ye).path)),h(wt,Ne)};E(qt,wt=>{k()||wt(cn)})}var dn=f(qt,2);gn(dn,17,()=>t(ye).sessions,wt=>wt.path,(wt,Ne)=>{var ie=of(),ce=u(ie),Fe=u(ce);{var b=oe=>{var Re=Ju();h(oe,Re)},w=oe=>{var Re=ef();h(oe,Re)};E(Fe,oe=>{t(Ne).isActive?oe(b):oe(w,-1)})}var L=f(Fe,2),$=u(L),W=u($,!0);d($);var Q=f($,2),S=u(Q);d(Q),d(L);var Ie=f(L,2);{var Te=oe=>{var Re=tf(),Ut=u(Re,!0);d(Re),B(()=>Z(Ut,t(Ne).clientCount)),h(oe,Re)};E(Ie,oe=>{t(Ne).clientCount>0&&oe(Te)})}d(ce);var Be=f(ce,2);{var ut=oe=>{var Re=sf(),Ut=u(Re);{var vn=Xe=>{var st=nf(),Ke=u(st),_t=f(Ke,2);d(st),H("click",Ke,Rt=>{Rt.stopPropagation(),kt(t(Ne).path)}),H("click",_t,Rt=>{Rt.stopPropagation(),p(Et,null)}),h(Xe,st)},Sn=Xe=>{var st=rf();H("click",st,Ke=>{Ke.stopPropagation(),p(Et,t(Ne).path,!0)}),h(Xe,st)};E(Ut,Xe=>{t(Et)===t(Ne).path?Xe(vn):Xe(Sn,-1)})}d(Re),h(oe,Re)};E(Be,oe=>{k()||oe(ut)})}d(ie),B((oe,Re,Ut)=>{Jt(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 ${t(re)===t(Ne).path?"bg-brand-surface-3":""}`),me(ce,"href",`#${oe??""}`),Z(W,Re),Z(S,`${Ut??""} · ${t(Ne).messageCount??""}
|
|
85
|
+
msgs`)},[()=>encodeURIComponent(t(Ne).id),()=>t(Ne).name||Ht(t(Ne).firstMessage)||"Empty session",()=>Ue(t(Ne).modified)]),H("click",ce,oe=>{oe.button===0&&!oe.ctrlKey&&!oe.metaKey&&!oe.altKey&&!oe.shiftKey&&(oe.preventDefault(),nt(t(Ne).path))}),h(wt,ie)}),d(bt),h(Se,bt)},Ce=K(()=>He(t(ye).path));E(ne,Se=>{t(Ce)&&Se(se)})}d(Wt),B(Se=>{Jt(Lt,1,`text-xs text-brand-text-muted transition-transform ${Se??""}`),Z(M,t(ye).name),Z(ve,t(ye).path),Z(Pe,t(ye).sessions.length)},[()=>He(t(ye).path)?"rotate-90":""]),H("click",Ct,()=>lt(t(ye).path)),h(X,Wt)}),h(D,V)};E(le,D=>{t(te)&&t(Ve).length===0?D(dt):t(Ve).length===0?D(Ft,1):D(At,-1)})}d(Zt),d(fn);var mt=f(fn,2);{var Qt=D=>{var V=ff(),Y=u(V),X=f(u(Y),2),ye=f(u(X),2),Wt=u(ye,!0);d(ye),d(X);var Ct=f(X,2),Lt=f(u(Ct),2);{var It=ke=>{var Pe=df();gn(Pe,21,()=>t(fe),Pn,(ne,se)=>{var Ce=cf(),Se=u(Ce);d(Ce);var bt={};B(()=>{Z(Se,`${t(se).label??""}${t(se).isDefault?" (default)":""}`),bt!==(bt=`${t(se).provider}:${t(se).modelId}`)&&(Ce.value=Ce.__value=`${t(se).provider}:${t(se).modelId}`)}),h(ne,Ce)}),d(Pe),Gr(Pe,()=>t(Oe).selected,ne=>t(Oe).selected=ne),h(ke,Pe)},Ot=ke=>{var Pe=uf();at(Pe),Ln(Pe,()=>t(Oe).selected,ne=>t(Oe).selected=ne),h(ke,Pe)};E(Lt,ke=>{t(fe).length>0?ke(It):ke(Ot,-1)})}d(Ct);var M=f(Ct,2),N=u(M),ve=f(N,2);d(M),d(Y),d(V),B(()=>Z(Wt,t(Oe).folderPath)),H("click",V,xt),H("click",Y,ke=>ke.stopPropagation()),H("click",N,xt),H("click",ve,Ge),h(D,V)};E(mt,D=>{t(Oe).open&&D(Qt)})}var jt=f(mt,2);{var xn=D=>{var V=pf(),Y=u(V),X=u(Y,!0);d(Y);var ye=f(Y,2);d(V),B(()=>Z(X,x())),H("click",ye,()=>gr()),h(D,V)};E(jt,D=>{x()&&D(xn)})}var _n=f(jt,2);{var Cn=D=>{var V=gf(),Y=u(V),X=f(u(Y),2),ye=f(u(X)),Wt=u(ye,!0);d(ye),et(),d(X);var Ct=f(X,2),Lt=u(Ct),It=u(Lt);at(It);var Ot=f(It,2),M=f(u(Ot));{var N=Se=>{var bt=hf();h(Se,bt)},ve=Se=>{var bt=bf();h(Se,bt)};E(M,Se=>{t(A).isGit?Se(N):Se(ve,-1)})}d(Ot),d(Lt);var ke=f(Lt,2);{var Pe=Se=>{var bt=mf(),qt=u(bt),cn=u(qt);at(cn);var dn=f(cn,2),wt=u(dn);d(dn),d(qt);var Ne=f(qt,2);{var ie=ce=>{var Fe=vf(),b=f(u(Fe),2),w=u(b);at(w),w.value=w.__value="private",et(),d(b);var L=f(b,2),$=u(L);at($),$.value=$.__value="public",et(),d(L),d(Fe),lr(O,[],w,()=>t(pe),W=>p(pe,W)),lr(O,[],$,()=>t(pe),W=>p(pe,W)),h(ce,Fe)};E(Ne,ce=>{t(J)&&ce(ie)})}d(bt),B(()=>Z(wt,`Create remote ${t(A).matchingRule.provider??""} repository`)),On(cn,()=>t(J),ce=>p(J,ce)),h(Se,bt)};E(ke,Se=>{t(A).matchingRule&&Se(Pe)})}d(Ct);var ne=f(Ct,2),se=u(ne),Ce=f(se,2);d(ne),d(Y),d(V),B(()=>{Z(Wt,t(ct)),It.disabled=t(A).isGit}),On(It,()=>t(xe),Se=>p(xe,Se)),H("click",se,()=>p(T,!1)),H("click",Ce,We),h(D,V)};E(_n,D=>{t(T)&&D(Cn)})}B(()=>{Ni(yt,t(ue)),Jt(tn,1,Hi(t(te)?"animate-spin":""))}),H("input",yt,D=>p(ue,D.currentTarget.value,!0)),H("click",Ze,()=>de()),h(n,Gt),tr(),P()}dr(["input","click","keydown","change"]);var _f=g(`<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">Session Conflict</h2> <p class="mb-6 text-sm text-brand-text-muted">Another client is active on a session in folder <span class="font-mono text-xs text-brand-text"> </span>. What would you like to do?</p> <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">Read Only</button> <button class="flex-1 rounded-lg bg-rose-500 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-rose-600">Take Over</button></div> <p class="mt-4 text-xs text-brand-text-muted"><strong class="text-brand-text">Read Only:</strong> Observe the session
|
|
86
86
|
live but cannot send messages.<br/> <strong class="text-brand-text">Take Over:</strong> Interrupt the other client
|
|
87
87
|
and gain control.</p></div></div>`);function yf(n,e){er(e,!0);const r=()=>Me(Pa,"$conflict",s),[s,o]=_r();let a=K(r);var l=jn(),c=Nt(l);{var _=m=>{var x=_f(),I=u(x),P=f(u(I),2),O=f(u(P)),k=u(O,!0);d(O),et(),d(P);var q=f(P,2),te=u(q),de=f(te,2);d(q),et(2),d(I),d(x),B(()=>Z(k,t(a).conflictingCwd)),H("click",te,()=>zs("read_only")),H("click",de,()=>zs("take_over")),h(m,x)};E(c,m=>{t(a)&&m(_)})}h(n,l),tr(),o()}dr(["click"]);var wf=g(`<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
|
|
88
|
-
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 kf(n,e){er(e,!0);const r=()=>Me(Na,"$sudoPrompt",s),[s,o]=_r();let a=K(r),l=G(""),c=G(null),_=G(null);Dt(()=>{const q=t(a)?.promptId??null;q!==t(_)&&(p(_,q,!0),p(l,""),q&&queueMicrotask(()=>t(c)?.focus()))});function m(){t(a)&&(Ra(t(l)),p(l,""))}function x(){$a(),p(l,"")}function I(q){q.key==="Enter"?(q.preventDefault(),m()):q.key==="Escape"&&(q.preventDefault(),x())}var P=jn(),O=Nt(P);{var k=q=>{var te=wf(),de=u(te),re=f(u(de),4),je=u(re,!0);d(re);var _e=f(re,2);at(_e),Vn(_e,Ee=>p(c,Ee),()=>t(c));var $e=f(_e,2),fe=u($e),Le=f(fe,2);d($e),d(de),d(te),B(()=>Z(je,t(a).command)),H("keydown",_e,I),Pn(_e,()=>t(l),Ee=>p(l,Ee)),H("click",fe,x),H("click",Le,m),h(q,te)};E(O,q=>{t(a)&&q(k)})}h(n,P),tr(),o()}dr(["keydown","click"]);function Sf(n){return n.loading||n.resyncing||n.hasSessionHash}function Tf(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!Sf(n)}var Af=g('<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>'),Ef=g('<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),Cf=g('<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),If=g('<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>'),Rf=g('<div class="truncate text-xs text-brand-text-muted"> </div>'),$f=g('<div class="truncate text-xs text-brand-text-muted"> </div>'),Mf=g('<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>'),Df=g('<div class="mt-2 text-xs text-rose-400"> </div>'),Pf=g('<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>'),Lf=g('<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>'),Of=g('<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),Nf=g('<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>'),Ff=g('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Uf=g('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),zf=g('<span class="text-sm text-brand-text-muted">Not connected</span>'),Bf=g('<div class="flex min-w-0 items-center gap-2"><!></div>'),Hf=g('<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>'),Wf=g("<option> </option>"),Gf=g('<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>'),jf=g('<span class="truncate text-brand-text-muted"> </span>'),qf=g('<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>'),Vf=g('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),Kf=g('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),Yf=g('<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>'),Zf=g('<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>'),Xf=g('<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>'),Qf=g('<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>'),Jf=g('<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>'),ep=g('<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>'),tp=g('<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>'),np=g("<!> <!>",1),rp=g('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),sp=g('<!> <!> <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 pp(n,e){er(e,!0);const r=()=>Me(Kr,"$isConnected",te),s=()=>Me(io,"$isResyncing",te),o=()=>Me(Ua,"$isAgentPending",te),a=()=>Me(fs,"$isLoadingSession",te),l=()=>Me(La,"$isInterrupted",te),c=()=>Me(ao,"$sessionError",te),_=()=>Me(Oa,"$sessionNotice",te),m=()=>Me(us,"$isReadOnly",te),x=()=>Me(Yr,"$activeSessionInfo",te),I=()=>Me(Pt,"$piState",te),P=()=>Me(Cr,"$availableModels",te),O=()=>Me(Fa,"$isCreatingSession",te),k=()=>Me(Qs,"$searchFolderStore",te),q=()=>Me(fa,"$searchDefaultModelStore",te),[te,de]=_r();let re=G(!1),je=G("main"),_e=G(!1),$e;qr(()=>{setTimeout(()=>mr(),200);const M=()=>{if(t(ue)){const ne=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";ne&&ne!==t(we)?so(ne):!ne&&t(we)&&Mn()}};window.addEventListener("hashchange",M);let N=null;const ve=8e3,ke=()=>{if(document.visibilityState==="hidden"){if(_a())return;N&&clearTimeout(N),N=setTimeout(()=>{N=null,document.visibilityState==="hidden"&&t(ue)&&ga()},ve)}else ro(),N&&(clearTimeout(N),N=null),t(ue)||(Fs()?Ns():mr())},Pe=ne=>{N&&(clearTimeout(N),N=null),document.visibilityState!=="hidden"&&!t(ue)&&(Fs()?Ns():mr())};return document.addEventListener("visibilitychange",ke),window.addEventListener("pageshow",Pe),()=>{window.removeEventListener("hashchange",M),document.removeEventListener("visibilitychange",ke),window.removeEventListener("pageshow",Pe),N&&clearTimeout(N)}});function fe(){mr()}function Le(){Mn(),jr()}function Ee(){jr(),setTimeout(()=>mr(),100)}function Et(){Br()}function it(){typeof window<"u"&&(window.location.hash=""),Mn(),p(re,!1)}let ue=K(r),Ve=K(s),Bt=K(o),He=K(a),lt=K(l),kt=K(c),tt=K(_),nt=K(m),ge=K(x),ct=K(I),De=K(()=>P().models),St=G(!1),we=K(()=>t(ge).sessionId);Dt(()=>{typeof window<"u"&&t(ue)&&(t(we)?(window.location.hash=encodeURIComponent(t(we)),p(St,!0)):t(St)&&(p(St,!1),window.location.hash&&(window.location.hash="")))});let ht=null;Dt(()=>{if(!t(ue)||typeof window>"u"||!window.location.hash)return;const M=decodeURIComponent(window.location.hash.slice(1));M&&(t(we)===M||t(He)||t(Ve)||ht||(ht=setTimeout(()=>{ht=null,!(t(we)===M||t(He)||t(Ve))&&Sa(M)},300)))}),Dt(()=>{t(ue)||p(St,!1)}),Dt(()=>{(t(we)||t(He)||t(Ve))&&p(re,!1)});let Yt=K(O),gt=K(k),xe=G(void 0),en=K(()=>Tf({connected:t(ue),searchConfigured:!!t(gt),hasSession:!!t(ge).sessionFile,loading:t(He),resyncing:t(Ve),hasSessionHash:typeof window<"u"&&!!window.location.hash})),J=K(()=>t(De).map(M=>({value:`${M.provider}:${M.modelId}`,label:`${M.label}${M.isDefault?" (default)":""}`}))),pe=K(q),T=G("");Dt(()=>{if(t(J).length===0||t(J).some(ke=>ke.value===t(T)))return;const N=t(J).find(ke=>ke.value===t(pe)),ve=t(De).find(ke=>ke.isDefault);p(T,N?N.value:ve?`${ve.provider}:${ve.modelId}`:t(J)[0].value,!0)});let F=G(!1);Dt(()=>{t(en)&&!t(F)&&t(xe)&&(p(F,!0),t(xe).focusInput())});function A(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),Mn(),t(xe)?.focusInput()}var ae=sp(),z=Nt(ae);Zi(z,{title:"Wherever",description:"Create & maintain apps from wherever"});var be=f(z,2);{var he=M=>{var N=Af();h(M,N)};E(be,M=>{t(Yt)&&M(he)})}var We=f(be,2),Oe=u(We),rt=u(Oe),xt=u(rt),Ge=u(xt);{var Ue=M=>{var N=Ef(),ve=f(Nt(N),2);H("click",ve,()=>p(_e,!1)),h(M,N)},Ht=M=>{var N=Cf(),ve=Nt(N),ke=u(ve);et(2),d(ve);var Pe=f(ve,2),ne=u(Pe),se=f(ne,2);d(Pe),B(Ce=>me(ke,"src",Ce),[()=>Ar("/logo.svg")]),H("click",ve,it),H("click",ne,()=>p(_e,!0)),H("click",se,()=>p(re,!1)),h(M,N)};E(Ge,M=>{t(_e)?M(Ue):M(Ht,-1)})}d(xt),d(rt);var Gt=f(rt,2);{var fn=M=>{var N=If(),ve=u(N);{let Se=K(()=>(t(ct).connected,"localhost"));Tl(ve,{get host(){return t(Se)},port:31415,token:"",onConnected:fe})}var ke=f(ve,2),Pe=f(u(ke),2),ne=u(Pe),se=f(ne,2),Ce=f(se,2);d(Pe),d(ke),d(N),H("click",ne,Et),H("click",se,Ee),H("click",Ce,Le),h(M,N)},pn=M=>{var N=Of(),ve=Nt(N),ke=u(ve),Pe=u(ke),ne=f(Pe,2),se=u(ne,!0);d(ne);var Ce=f(ne,2),Se=u(Ce);d(Ce),d(ke);var bt=f(ke,2);{var qt=$=>{var W=Mf(),Q=u(W);{var S=oe=>{var Re=Rf(),Ut=u(Re);d(Re),B(vn=>{me(Re,"title",t(ge).cwd),Z(Ut,`📁 ${vn??""}`)},[()=>t(ge).cwd.split("/").pop()||t(ge).cwd]),h(oe,Re)};E(Q,oe=>{t(ge).cwd&&oe(S)})}var Ie=f(Q,2);{var Te=oe=>{var Re=$f(),Ut=u(Re);d(Re),B(()=>{me(Re,"title",t(ge).model),Z(Ut,`🤖 ${t(ge).model??""}`)}),h(oe,Re)};E(Ie,oe=>{t(ge).model&&oe(Te)})}var Be=f(Ie,2),ut=u(Be);d(Be),d(W),H("click",ut,it),h($,W)};E(bt,$=>{t(ge).sessionFile&&$(qt)})}var cn=f(bt,2);{var dn=$=>{var W=Df(),Q=u(W,!0);d(W),B(()=>Z(Q,t(ct).error)),h($,W)};E(cn,$=>{t(ct).error&&!t(ue)&&$(dn)})}d(ve);var wt=f(ve,2),Ne=u(wt);{var ie=$=>{var W=Pf();H("click",W,()=>{p(je,"readonly"),ca()}),h($,W)},ce=$=>{var W=Lf();H("click",W,()=>p(je,"main")),h($,W)};E(Ne,$=>{t(je)==="main"?$(ie):$(ce,-1)})}d(wt);var Fe=f(wt,2),b=u(Fe);{var w=$=>{ea($,{readOnly:!0})},L=$=>{ea($,{})};E(b,$=>{t(je)==="readonly"?$(w):$(L,-1)})}d(Fe),B(()=>{Jt(Pe,1,`h-2.5 w-2.5 rounded-full ${t(ue)?"bg-emerald-500":"bg-rose-500"}`),Jt(ne,1,`text-sm ${t(ue)?"text-emerald-400":"text-rose-400"}`),Z(se,t(ue)?"Connected":"Disconnected"),Z(Se,`v${oa}`)}),h(M,N)};E(Gt,M=>{t(_e)?M(fn):M(pn,-1)})}d(Oe);var Tt=f(Oe,2),yt=u(Tt),Ze=u(yt),tn=f(Ze,2);{var Zt=M=>{var N=Nf();H("click",N,A),h(M,N)};E(tn,M=>{t(ue)&&t(gt)&&t(ge).sessionFile&&M(Zt)})}var Xt=f(tn,2);{var kn=M=>{var N=Bf(),ve=u(N);{var ke=se=>{var Ce=Ff();h(se,Ce)},Pe=se=>{var Ce=Uf();h(se,Ce)},ne=se=>{var Ce=zf();h(se,Ce)};E(ve,se=>{t(ue)&&t(en)?se(ke):t(ue)?se(Pe,1):se(ne,-1)})}d(N),h(M,N)};E(Xt,M=>{(!t(ue)||!t(ge).sessionFile)&&M(kn)})}var le=f(Xt,2);{var dt=M=>{var N=Vf(),ve=u(N);{var ke=se=>{var Ce=Hf(),Se=f(u(Ce),2),bt=u(Se,!0);d(Se),d(Ce),B(qt=>{me(Se,"title",t(ge).cwd),Z(bt,qt)},[()=>t(ge).cwd.split("/").pop()||t(ge).cwd]),h(se,Ce)};E(ve,se=>{t(ge).cwd&&se(ke)})}var Pe=f(ve,2);{var ne=se=>{var Ce=qf(),Se=u(Ce),bt=f(u(Se),2);d(Se);var qt=f(Se,2);{var cn=wt=>{var Ne=Gf();gn(Ne,21,()=>t(De),Dn,(ce,Fe)=>{var b=Wf(),w=u(b,!0);d(b);var L={};B(()=>{Z(w,t(Fe).label),L!==(L=`${t(Fe).provider}:${t(Fe).modelId}`)&&(b.value=b.__value=`${t(Fe).provider}:${t(Fe).modelId}`)}),h(ce,b)}),d(Ne);var ie;ia(Ne),B(()=>{ie!==(ie=t(ge).model)&&(Ne.value=(Ne.__value=t(ge).model)??"",Zs(Ne,t(ge).model))}),H("input",Ne,ce=>Ma(ce.currentTarget.value)),h(wt,Ne)},dn=wt=>{var Ne=jf(),ie=u(Ne,!0);d(Ne),B(()=>{me(Ne,"title",t(ge).model),Z(ie,t(ge).model)}),h(wt,Ne)};E(qt,wt=>{t(De).length>0&&!t(nt)?wt(cn):wt(dn,-1)})}d(Ce),B(()=>{Jt(bt,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(ct).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),me(bt,"title",t(ct).isStreaming?"Agent working...":"Ready")}),h(se,Ce)};E(Pe,se=>{t(ge).model&&se(ne)})}d(N),h(M,N)};E(le,M=>{t(ge).sessionFile&&M(dt)})}var Ft=f(le,2);{var At=M=>{var N=Kf();h(M,N)};E(Ft,M=>{t(nt)&&M(At)})}d(yt);var mt=f(yt,2);{var Qt=M=>{var N=Yf();h(M,N)};E(mt,M=>{t(lt)&&M(Qt)})}var jt=f(mt,2);{var xn=M=>{var N=Zf(),ve=u(N),ke=u(ve,!0);d(ve);var Pe=f(ve,2);d(N),B(()=>{Jt(N,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(tt).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),Z(ke,t(tt).message)}),H("click",Pe,()=>Ia()),h(M,N)};E(jt,M=>{t(tt)&&M(xn)})}var _n=f(jt,2);{var Cn=M=>{var N=Xf(),ve=u(N),ke=u(ve,!0);d(ve);var Pe=f(ve,2);d(N),B(()=>Z(ke,t(kt))),H("click",Pe,()=>gr()),h(M,N)};E(_n,M=>{t(kt)&&M(Cn)})}var D=f(_n,2);{var V=M=>{var N=Qf();h(M,N)};E(D,M=>{t(nt)&&!t(lt)&&M(V)})}var Y=f(D,2);Vn(du(Y,{onMessageSent:()=>{}}),M=>$e=M,()=>$e);var X=f(Y,2);{var ye=M=>{var N=Jf();h(M,N)},Wt=M=>{var N=np(),ve=Nt(N);{var ke=se=>{var Ce=ep();h(se,Ce)},Pe=se=>{var Ce=tp();h(se,Ce)};E(ve,se=>{t(ge).sessionFile&&(t(Ve)||!t(ue))?se(ke):t(ge).sessionFile&&t(Bt)&&se(Pe,1)})}var ne=f(ve,2);{let se=K(()=>!!t(gt)),Ce=K(()=>t(en)?!t(ue):!t(ue)||t(nt)||!t(ge).sessionFile||t(Ve)||t(Bt));Vn(Lu(ne,{get searchMode(){return t(en)},get searchConfigured(){return t(se)},get searchModels(){return t(J)},onSubmit:Se=>Ta(Se,t(T)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(Ce)},onSend:()=>$e?.forceScrollToBottom(),get searchModel(){return t(T)},set searchModel(Se){p(T,Se,!0)}}),Se=>p(xe,Se,!0),()=>t(xe))}h(M,N)};E(X,M=>{t(nt)&&t(ge).sessionFile?M(ye):M(Wt,-1)})}d(Tt);var Ct=f(Tt,2);yf(Ct,{});var Lt=f(Ct,2);kf(Lt,{});var It=f(Lt,2);{var Ot=M=>{var N=rp();H("click",N,()=>p(re,!1)),h(M,N)};E(It,M=>{t(re)&&M(Ot)})}d(We),B(()=>Jt(Oe,1,`app-chrome ${t(re)?"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`)),H("click",Ze,()=>p(re,!t(re))),h(n,ae),tr(),de()}dr(["click","input"]);export{pp as component,fp as universal};
|
|
89
|
-
//# sourceMappingURL=2.
|
|
88
|
+
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 kf(n,e){er(e,!0);const r=()=>Me(Na,"$sudoPrompt",s),[s,o]=_r();let a=K(r),l=G(""),c=G(null),_=G(null);Dt(()=>{const q=t(a)?.promptId??null;q!==t(_)&&(p(_,q,!0),p(l,""),q&&queueMicrotask(()=>t(c)?.focus()))});function m(){t(a)&&(Ra(t(l)),p(l,""))}function x(){$a(),p(l,"")}function I(q){q.key==="Enter"?(q.preventDefault(),m()):q.key==="Escape"&&(q.preventDefault(),x())}var P=jn(),O=Nt(P);{var k=q=>{var te=wf(),de=u(te),re=f(u(de),4),je=u(re,!0);d(re);var _e=f(re,2);at(_e),Vn(_e,Ee=>p(c,Ee),()=>t(c));var $e=f(_e,2),fe=u($e),Le=f(fe,2);d($e),d(de),d(te),B(()=>Z(je,t(a).command)),H("keydown",_e,I),Ln(_e,()=>t(l),Ee=>p(l,Ee)),H("click",fe,x),H("click",Le,m),h(q,te)};E(O,q=>{t(a)&&q(k)})}h(n,P),tr(),o()}dr(["keydown","click"]);function Sf(n){return n.loading||n.resyncing||n.hasSessionHash}function Tf(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!Sf(n)}var Af=g('<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>'),Ef=g('<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),Cf=g('<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),If=g('<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>'),Rf=g('<div class="truncate text-xs text-brand-text-muted"> </div>'),$f=g('<div class="truncate text-xs text-brand-text-muted"> </div>'),Mf=g('<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>'),Df=g('<div class="mt-2 text-xs text-rose-400"> </div>'),Pf=g('<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>'),Lf=g('<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>'),Of=g('<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),Nf=g('<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>'),Ff=g('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Uf=g('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),zf=g('<span class="text-sm text-brand-text-muted">Not connected</span>'),Bf=g('<div class="flex min-w-0 items-center gap-2"><!></div>'),Hf=g('<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>'),Wf=g("<option> </option>"),Gf=g('<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>'),jf=g('<span class="truncate text-brand-text-muted"> </span>'),qf=g('<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>'),Vf=g('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),Kf=g('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),Yf=g('<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>'),Zf=g('<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>'),Xf=g('<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>'),Qf=g('<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>'),Jf=g('<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>'),ep=g('<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>'),tp=g('<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>'),np=g("<!> <!>",1),rp=g('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),sp=g('<!> <!> <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 pp(n,e){er(e,!0);const r=()=>Me(Kr,"$isConnected",te),s=()=>Me(io,"$isResyncing",te),o=()=>Me(Ua,"$isAgentPending",te),a=()=>Me(fs,"$isLoadingSession",te),l=()=>Me(La,"$isInterrupted",te),c=()=>Me(ao,"$sessionError",te),_=()=>Me(Oa,"$sessionNotice",te),m=()=>Me(us,"$isReadOnly",te),x=()=>Me(Yr,"$activeSessionInfo",te),I=()=>Me(Pt,"$piState",te),P=()=>Me(Cr,"$availableModels",te),O=()=>Me(Fa,"$isCreatingSession",te),k=()=>Me(Qs,"$searchFolderStore",te),q=()=>Me(fa,"$searchDefaultModelStore",te),[te,de]=_r();let re=G(!1),je=G("main"),_e=G(!1),$e;qr(()=>{setTimeout(()=>mr(),200);const M=()=>{if(t(ue)){const ne=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";ne&&ne!==t(we)?so(ne):!ne&&t(we)&&Dn()}};window.addEventListener("hashchange",M);let N=null;const ve=8e3,ke=()=>{if(document.visibilityState==="hidden"){if(_a())return;N&&clearTimeout(N),N=setTimeout(()=>{N=null,document.visibilityState==="hidden"&&t(ue)&&ga()},ve)}else ro(),N&&(clearTimeout(N),N=null),t(ue)||(Fs()?Ns():mr())},Pe=ne=>{N&&(clearTimeout(N),N=null),document.visibilityState!=="hidden"&&!t(ue)&&(Fs()?Ns():mr())};return document.addEventListener("visibilitychange",ke),window.addEventListener("pageshow",Pe),()=>{window.removeEventListener("hashchange",M),document.removeEventListener("visibilitychange",ke),window.removeEventListener("pageshow",Pe),N&&clearTimeout(N)}});function fe(){mr()}function Le(){Dn(),jr()}function Ee(){jr(),setTimeout(()=>mr(),100)}function Et(){Br()}function it(){typeof window<"u"&&(window.location.hash=""),Dn(),p(re,!1)}let ue=K(r),Ve=K(s),Bt=K(o),He=K(a),lt=K(l),kt=K(c),tt=K(_),nt=K(m),ge=K(x),ct=K(I),De=K(()=>P().models),St=G(!1),we=K(()=>t(ge).sessionId);Dt(()=>{typeof window<"u"&&t(ue)&&(t(we)?(window.location.hash=encodeURIComponent(t(we)),p(St,!0)):t(St)&&(p(St,!1),window.location.hash&&(window.location.hash="")))});let ht=null;Dt(()=>{if(!t(ue)||typeof window>"u"||!window.location.hash)return;const M=decodeURIComponent(window.location.hash.slice(1));M&&(t(we)===M||t(He)||t(Ve)||ht||(ht=setTimeout(()=>{ht=null,!(t(we)===M||t(He)||t(Ve))&&Sa(M)},300)))}),Dt(()=>{t(ue)||p(St,!1)}),Dt(()=>{(t(we)||t(He)||t(Ve))&&p(re,!1)});let Yt=K(O),gt=K(k),xe=G(void 0),en=K(()=>Tf({connected:t(ue),searchConfigured:!!t(gt),hasSession:!!t(ge).sessionFile,loading:t(He),resyncing:t(Ve),hasSessionHash:typeof window<"u"&&!!window.location.hash})),J=K(()=>t(De).map(M=>({value:`${M.provider}:${M.modelId}`,label:`${M.label}${M.isDefault?" (default)":""}`}))),pe=K(q),T=G("");Dt(()=>{if(t(J).length===0||t(J).some(ke=>ke.value===t(T)))return;const N=t(J).find(ke=>ke.value===t(pe)),ve=t(De).find(ke=>ke.isDefault);p(T,N?N.value:ve?`${ve.provider}:${ve.modelId}`:t(J)[0].value,!0)});let F=G(!1);Dt(()=>{t(en)&&!t(F)&&t(xe)&&(p(F,!0),t(xe).focusInput())});function A(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),Dn(),t(xe)?.focusInput()}var ae=sp(),z=Nt(ae);Zi(z,{title:"Wherever",description:"Create & maintain apps from wherever"});var be=f(z,2);{var he=M=>{var N=Af();h(M,N)};E(be,M=>{t(Yt)&&M(he)})}var We=f(be,2),Oe=u(We),rt=u(Oe),xt=u(rt),Ge=u(xt);{var Ue=M=>{var N=Ef(),ve=f(Nt(N),2);H("click",ve,()=>p(_e,!1)),h(M,N)},Ht=M=>{var N=Cf(),ve=Nt(N),ke=u(ve);et(2),d(ve);var Pe=f(ve,2),ne=u(Pe),se=f(ne,2);d(Pe),B(Ce=>me(ke,"src",Ce),[()=>Ar("/logo.svg")]),H("click",ve,it),H("click",ne,()=>p(_e,!0)),H("click",se,()=>p(re,!1)),h(M,N)};E(Ge,M=>{t(_e)?M(Ue):M(Ht,-1)})}d(xt),d(rt);var Gt=f(rt,2);{var fn=M=>{var N=If(),ve=u(N);{let Se=K(()=>(t(ct).connected,"localhost"));Tl(ve,{get host(){return t(Se)},port:31415,token:"",onConnected:fe})}var ke=f(ve,2),Pe=f(u(ke),2),ne=u(Pe),se=f(ne,2),Ce=f(se,2);d(Pe),d(ke),d(N),H("click",ne,Et),H("click",se,Ee),H("click",Ce,Le),h(M,N)},pn=M=>{var N=Of(),ve=Nt(N),ke=u(ve),Pe=u(ke),ne=f(Pe,2),se=u(ne,!0);d(ne);var Ce=f(ne,2),Se=u(Ce);d(Ce),d(ke);var bt=f(ke,2);{var qt=$=>{var W=Mf(),Q=u(W);{var S=oe=>{var Re=Rf(),Ut=u(Re);d(Re),B(vn=>{me(Re,"title",t(ge).cwd),Z(Ut,`📁 ${vn??""}`)},[()=>t(ge).cwd.split("/").pop()||t(ge).cwd]),h(oe,Re)};E(Q,oe=>{t(ge).cwd&&oe(S)})}var Ie=f(Q,2);{var Te=oe=>{var Re=$f(),Ut=u(Re);d(Re),B(()=>{me(Re,"title",t(ge).model),Z(Ut,`🤖 ${t(ge).model??""}`)}),h(oe,Re)};E(Ie,oe=>{t(ge).model&&oe(Te)})}var Be=f(Ie,2),ut=u(Be);d(Be),d(W),H("click",ut,it),h($,W)};E(bt,$=>{t(ge).sessionFile&&$(qt)})}var cn=f(bt,2);{var dn=$=>{var W=Df(),Q=u(W,!0);d(W),B(()=>Z(Q,t(ct).error)),h($,W)};E(cn,$=>{t(ct).error&&!t(ue)&&$(dn)})}d(ve);var wt=f(ve,2),Ne=u(wt);{var ie=$=>{var W=Pf();H("click",W,()=>{p(je,"readonly"),ca()}),h($,W)},ce=$=>{var W=Lf();H("click",W,()=>p(je,"main")),h($,W)};E(Ne,$=>{t(je)==="main"?$(ie):$(ce,-1)})}d(wt);var Fe=f(wt,2),b=u(Fe);{var w=$=>{ea($,{readOnly:!0})},L=$=>{ea($,{})};E(b,$=>{t(je)==="readonly"?$(w):$(L,-1)})}d(Fe),B(()=>{Jt(Pe,1,`h-2.5 w-2.5 rounded-full ${t(ue)?"bg-emerald-500":"bg-rose-500"}`),Jt(ne,1,`text-sm ${t(ue)?"text-emerald-400":"text-rose-400"}`),Z(se,t(ue)?"Connected":"Disconnected"),Z(Se,`v${oa}`)}),h(M,N)};E(Gt,M=>{t(_e)?M(fn):M(pn,-1)})}d(Oe);var Tt=f(Oe,2),yt=u(Tt),Ze=u(yt),tn=f(Ze,2);{var Zt=M=>{var N=Nf();H("click",N,A),h(M,N)};E(tn,M=>{t(ue)&&t(gt)&&t(ge).sessionFile&&M(Zt)})}var Xt=f(tn,2);{var kn=M=>{var N=Bf(),ve=u(N);{var ke=se=>{var Ce=Ff();h(se,Ce)},Pe=se=>{var Ce=Uf();h(se,Ce)},ne=se=>{var Ce=zf();h(se,Ce)};E(ve,se=>{t(ue)&&t(en)?se(ke):t(ue)?se(Pe,1):se(ne,-1)})}d(N),h(M,N)};E(Xt,M=>{(!t(ue)||!t(ge).sessionFile)&&M(kn)})}var le=f(Xt,2);{var dt=M=>{var N=Vf(),ve=u(N);{var ke=se=>{var Ce=Hf(),Se=f(u(Ce),2),bt=u(Se,!0);d(Se),d(Ce),B(qt=>{me(Se,"title",t(ge).cwd),Z(bt,qt)},[()=>t(ge).cwd.split("/").pop()||t(ge).cwd]),h(se,Ce)};E(ve,se=>{t(ge).cwd&&se(ke)})}var Pe=f(ve,2);{var ne=se=>{var Ce=qf(),Se=u(Ce),bt=f(u(Se),2);d(Se);var qt=f(Se,2);{var cn=wt=>{var Ne=Gf();gn(Ne,21,()=>t(De),Pn,(ce,Fe)=>{var b=Wf(),w=u(b,!0);d(b);var L={};B(()=>{Z(w,t(Fe).label),L!==(L=`${t(Fe).provider}:${t(Fe).modelId}`)&&(b.value=b.__value=`${t(Fe).provider}:${t(Fe).modelId}`)}),h(ce,b)}),d(Ne);var ie;ia(Ne),B(()=>{ie!==(ie=t(ge).model)&&(Ne.value=(Ne.__value=t(ge).model)??"",Zs(Ne,t(ge).model))}),H("input",Ne,ce=>Ma(ce.currentTarget.value)),h(wt,Ne)},dn=wt=>{var Ne=jf(),ie=u(Ne,!0);d(Ne),B(()=>{me(Ne,"title",t(ge).model),Z(ie,t(ge).model)}),h(wt,Ne)};E(qt,wt=>{t(De).length>0&&!t(nt)?wt(cn):wt(dn,-1)})}d(Ce),B(()=>{Jt(bt,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(ct).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),me(bt,"title",t(ct).isStreaming?"Agent working...":"Ready")}),h(se,Ce)};E(Pe,se=>{t(ge).model&&se(ne)})}d(N),h(M,N)};E(le,M=>{t(ge).sessionFile&&M(dt)})}var Ft=f(le,2);{var At=M=>{var N=Kf();h(M,N)};E(Ft,M=>{t(nt)&&M(At)})}d(yt);var mt=f(yt,2);{var Qt=M=>{var N=Yf();h(M,N)};E(mt,M=>{t(lt)&&M(Qt)})}var jt=f(mt,2);{var xn=M=>{var N=Zf(),ve=u(N),ke=u(ve,!0);d(ve);var Pe=f(ve,2);d(N),B(()=>{Jt(N,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(tt).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),Z(ke,t(tt).message)}),H("click",Pe,()=>Ia()),h(M,N)};E(jt,M=>{t(tt)&&M(xn)})}var _n=f(jt,2);{var Cn=M=>{var N=Xf(),ve=u(N),ke=u(ve,!0);d(ve);var Pe=f(ve,2);d(N),B(()=>Z(ke,t(kt))),H("click",Pe,()=>gr()),h(M,N)};E(_n,M=>{t(kt)&&M(Cn)})}var D=f(_n,2);{var V=M=>{var N=Qf();h(M,N)};E(D,M=>{t(nt)&&!t(lt)&&M(V)})}var Y=f(D,2);Vn(du(Y,{onMessageSent:()=>{}}),M=>$e=M,()=>$e);var X=f(Y,2);{var ye=M=>{var N=Jf();h(M,N)},Wt=M=>{var N=np(),ve=Nt(N);{var ke=se=>{var Ce=ep();h(se,Ce)},Pe=se=>{var Ce=tp();h(se,Ce)};E(ve,se=>{t(ge).sessionFile&&(t(Ve)||!t(ue))?se(ke):t(ge).sessionFile&&t(Bt)&&se(Pe,1)})}var ne=f(ve,2);{let se=K(()=>!!t(gt)),Ce=K(()=>t(en)?!t(ue):!t(ue)||t(nt)||!t(ge).sessionFile||t(Ve)||t(Bt));Vn(Lu(ne,{get searchMode(){return t(en)},get searchConfigured(){return t(se)},get searchModels(){return t(J)},onSubmit:Se=>Ta(Se,t(T)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(Ce)},onSend:()=>$e?.forceScrollToBottom(),get searchModel(){return t(T)},set searchModel(Se){p(T,Se,!0)}}),Se=>p(xe,Se,!0),()=>t(xe))}h(M,N)};E(X,M=>{t(nt)&&t(ge).sessionFile?M(ye):M(Wt,-1)})}d(Tt);var Ct=f(Tt,2);yf(Ct,{});var Lt=f(Ct,2);kf(Lt,{});var It=f(Lt,2);{var Ot=M=>{var N=rp();H("click",N,()=>p(re,!1)),h(M,N)};E(It,M=>{t(re)&&M(Ot)})}d(We),B(()=>Jt(Oe,1,`app-chrome ${t(re)?"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`)),H("click",Ze,()=>p(re,!t(re))),h(n,ae),tr(),de()}dr(["click","input"]);export{pp as component,fp as universal};
|
|
89
|
+
//# sourceMappingURL=2.riO6dO81.js.map
|