wherever-dev 0.9.0 → 0.9.2
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 +3 -3
- package/public/_app/immutable/chunks/{CL5QpF5Q.js → B59dpE7G.js} +2 -2
- package/public/_app/immutable/chunks/{CL5QpF5Q.js.map → B59dpE7G.js.map} +1 -1
- package/public/_app/immutable/chunks/{D6hR9Kco.js → BOgjnF-w.js} +2 -2
- package/public/_app/immutable/chunks/{D6hR9Kco.js.map → BOgjnF-w.js.map} +1 -1
- package/public/_app/immutable/chunks/{BDScRLia.js → CYfubaPP.js} +2 -2
- package/public/_app/immutable/chunks/{BDScRLia.js.map → CYfubaPP.js.map} +1 -1
- package/public/_app/immutable/entry/{app.DeLAGEKb.js → app.LM_7ATgU.js} +3 -3
- package/public/_app/immutable/entry/{app.DeLAGEKb.js.map → app.LM_7ATgU.js.map} +1 -1
- package/public/_app/immutable/entry/start.Buwt9w46.js +2 -0
- package/public/_app/immutable/entry/start.Buwt9w46.js.map +1 -0
- package/public/_app/immutable/nodes/{0.CnfgGkkx.js → 0.BNpm9PB_.js} +2 -2
- package/public/_app/immutable/nodes/{0.CnfgGkkx.js.map → 0.BNpm9PB_.js.map} +1 -1
- package/public/_app/immutable/nodes/{1.BXHAt3FG.js → 1.CLkGyfBZ.js} +2 -2
- package/public/_app/immutable/nodes/{1.BXHAt3FG.js.map → 1.CLkGyfBZ.js.map} +1 -1
- package/public/_app/immutable/nodes/{2.BgbWxE1g.js → 2.CKCpNIHO.js} +47 -47
- package/public/_app/immutable/nodes/2.CKCpNIHO.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.s2u3_iKS.js +0 -2
- package/public/_app/immutable/entry/start.s2u3_iKS.js.map +0 -1
- package/public/_app/immutable/nodes/2.BgbWxE1g.js.map +0 -1
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import{b as ms,a as h,c as Zn,g as m,d as xr,e as W,s as Q,f as ir,t as xn}from"../chunks/vMsF8lo6.js";import{ar as En,b2 as rs,al as kr,be as H,ap as _o,M as mi,aS as gi,aq as Ms,d as ea,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 yo,C as wo,aE as ls,a2 as sr,ac as Ci,az as Ii,aZ as Ri,ay as ta,bd as na,bf as $i,bg as Vs,aU as Ks,aQ as ko,aP as lr,aM as cr,af as Wt,b6 as f,ai as t,a5 as Mi,bh as V,$ as Di,bl as Nn,ah as Vn,a8 as Gt,aK as qr,a_ as p,X as u,aV as d,aI as lt,b9 as G,aO as Mn,bi as Pt,bj as Pi,aT as Li}from"../chunks/CEg8tgYI.js";import{i as E,s as Cr,a as $e,p as br}from"../chunks/MtE7VtNZ.js";import{a as Oi,b as ge,r as nt,c as ra,e as _n,i as Pn,d as Ni}from"../chunks/CL5QpF5Q.js";import{_ as Fi,b as qn}from"../chunks/ylfInSZr.js";import{v as sa}from"../chunks/D6hR9Kco.js";import{p as Ui}from"../chunks/BDScRLia.js";function So(n,e,r=!1,s=!1,o=!1,a=!1){var l=n,c="";if(r){var _=n;En&&(l=rs(kr(_)))}H(()=>{var g=mi;if(c===(c=e()??"")){En&&_o();return}if(r&&!En){g.nodes=null,_.innerHTML=c,c!==""&&ms(kr(_),_.lastChild);return}if(g.nodes!==null&&(gi(g.nodes.start,g.nodes.end),g.nodes=null),c!==""){if(En){Ms.data;for(var x=_o(),R=x;x!==null&&(x.nodeType!==ea||x.data!=="");)R=x,x=Ds(x);if(x===null)throw xi(),_i;ms(Ms,R),l=rs(x);return}var O=s?wi:o?ki:void 0,N=yi(s?"svg":o?"math":"template",O);N.innerHTML=c;var S=s||o?N:N.content;if(ms(kr(S),S.lastChild),s||o)for(;kr(S);)l.before(kr(S));else l.before(S)}})}function zi(n,e){let r=null,s=En;var o;if(En){r=Ms;for(var a=kr(document.head);a!==null&&(a.nodeType!==ea||a.data!==n);)a=Ds(a);if(a===null)yo(!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&&(yo(!0),rs(r))}}function oa(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=oa(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=oa(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 rn(n,e,r,s,o,a){var l=n[wo];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[wo]=r}return a}function Ys(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(ta(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function aa(n){var e=new MutationObserver(()=>{Ys(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),na(()=>{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,sr!==null&&s.add(sr)}),Ci(()=>{var a=e();if(n===document.activeElement){var l=sr;if(s.has(l))return}if(Ys(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=zr(c),r(a))}n.__value=a,o=!1}),aa(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),sr!==null&&s.add(sr),await $i(),a!==(a=e())){var l=n.selectionStart,c=n.selectionEnd,_=n.value.length;if(n.value=a??"",c!==null){var g=n.value.length;l===c&&c===_&&g>_?(n.selectionStart=g,n.selectionEnd=g):(n.selectionStart=l,n.selectionEnd=Math.min(c,g))}}}),(En&&n.defaultValue!==n.value||Vs(e)==null&&n.value)&&(r(xs(n)?_s(n.value):n.value),sr!==null&&s.add(sr)),Ks(()=>{var o=e();if(n===document.activeElement){var a=sr;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 ar(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 g=r.__value;a&&(g=To(l,g,r.checked)),o(g)},()=>o(a?[]:null)),Ks(()=>{var g=s();if(En&&r.defaultChecked!==r.checked){c=!0;return}a?(g=g||[],r.checked=g.includes(r.__value)):r.checked=ta(r.__value,g)}),na(()=>{var g=l.indexOf(r);g!==-1&&l.splice(g,1)}),gs.has(l)||(gs.add(l),ko(()=>{l.sort((g,x)=>g.compareDocumentPosition(x)===4?-1:1),gs.delete(l)})),ko(()=>{if(c){var g;if(a)g=To(l,g,r.checked);else{var x=l.find(R=>R.checked);g=x?.__value}o(g)}})}function On(n,e,r=e){ls(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(En&&n.defaultChecked!==n.checked||Vs(e)==null)&&r(n.checked),Ks(()=>{var s=e();n.checked=!!s})}function To(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 Tr(n,e){return Oi(n)}var Yi=m('<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){lr(e,!0);const r=ws.endsWith("/")?ws.slice(0,-1):ws,s=r+"/preview.png";let o=V(()=>e.home||!1),a=V(()=>({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(),_=Wt(c),g=f(_,2),x=f(g,2);{var R=qe=>{var Xe=Zn(),yt=Wt(Xe);E(yt,rt=>{}),h(qe,Xe)};E(x,qe=>{t(o)&&qe(R)})}var O=f(x,2),N=f(O,2),S=f(N,2),Y=f(S,2),ke=f(Y,2),J=f(ke,4),ue=f(J,2),Le=f(ue,2),_e=f(Le,2),Ce=f(_e,2),fe=f(Ce,2),Me=f(fe,2),Ie=f(Me,2),St=f(Ie,2),ut=f(St,4),Ge=f(ut,4),we=f(Ge,2),Tt=f(we,2);H((qe,Xe,yt,rt)=>{ge(_,"content",t(a).title),ge(g,"content",t(a).description),ge(O,"content",t(a).type),ge(N,"content",t(a).url),ge(S,"content",t(a).title),ge(Y,"content",t(a).description),ge(ke,"content",t(a).image),ge(J,"content",t(a).url),ge(ue,"content",t(a).title),ge(Le,"content",t(a).description),ge(_e,"content",t(a).image),ge(Ce,"href",qe),ge(fe,"href",Xe),ge(Me,"href",yt),ge(Ie,"href",rt),ge(St,"content",Vi),ge(ut,"content",ys),ge(Ge,"content",Ki),ge(we,"content",ys),ge(Tt,"content",sa)},[()=>Tr("/pwa/favicon.png"),()=>Tr("/pwa/favicon.ico"),()=>Tr("/pwa/apple-touch-icon.png"),()=>Tr("/pwa/manifest.webmanifest")]),Mi(()=>{Di.title=t(a).title??""}),h(l,c)}),cr()}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 Ao(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 Eo=new Map;function Qi(n){if(typeof Audio>"u")return!1;try{let e=Eo.get(n);e||(e=new Audio(n),e.preload="auto",Eo.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 ia(n){if(n&&n.trim()&&Qi(n.trim()))return;const e=Xi();if(e)try{const r=e.currentTime;Ao(e,1046.5,r,.16,.12),Ao(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 Qt(n){let e;return el(n,r=>e=r)(),e}var yr=[];function tl(n,e=es){let r;const s=new Set;function o(c){if(Ji(n,c)&&(n=c,r)){const _=!yr.length;for(const g of s)g[1](),yr.push(g,n);if(_){for(let g=0;g<yr.length;g+=2)yr[g][0](yr[g+1]);yr.length=0}}}function a(c){o(c(n))}function l(c,_=es){const g=[c,_];return s.add(g),s.size===1&&(r=e(o)||es),c(n),()=>{s.delete(g),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,folderConflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null};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(N=>r?{...N,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(N=>({...N,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const N=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=N?new c(l,N):new c(l)}catch(N){this.stateStore.update(S=>({...S,connecting:!1,error:`Failed to connect: ${N}`})),this.scheduleReconnect();return}const _=this.ws,g=()=>{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(J=>({...J,connected:!0,connecting:!1,error:null}));const N=Qt(this.stateStore),S=this.resumeSessionFile??N.activeSessionFile,Y=this.resumeSessionFile!=null?this.resumeCwd:N.activeCwd??void 0,ke=this.resumeSessionFile!=null?this.resumeModel:N.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,S?(this.stateStore.update(J=>J.resyncing?J:{...J,resyncing:!0}),this.send({type:"session_load",sessionFile:S,cwd:Y,model:ke}),this.armLoadWatchdog()):this.stateStore.update(J=>J.resyncing?{...J,resyncing:!1}:J)},x=N=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const S=typeof N.data=="string"?N.data:N.data.toString(),Y=JSON.parse(S);this.handleMessage(Y)}catch(S){console.error("Failed to parse WebSocket message:",S)}}},R=()=>{this.ws===_&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(N=>({...N,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:N.activeSessionFile?!0:N.resyncing})),this.scheduleReconnect())},O=N=>{this.ws===_&&this.stateStore.update(S=>({...S,error:S.error||"Connection error occurred"}))};typeof _.addEventListener=="function"?(_.addEventListener("open",g),_.addEventListener("message",x),_.addEventListener("close",R),_.addEventListener("error",O)):typeof _.on=="function"&&(_.on("open",g),_.on("message",N=>x({data:N})),_.on("close",R),_.on("error",O))}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=Qt(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=Qt(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||Qt(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=Qt(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=Qt(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,Qt(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=!!Qt(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)},this.reconnectDelay))}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":case"session_error":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(e.uploadId);s&&(s.resolve({savedPath:e.savedPath,filename:e.filename}),this.pendingUploads.delete(e.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(e.uploadId);s&&(s.reject(new Error(e.error)),this.pendingUploads.delete(e.uploadId));break}case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="thinking"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="assistant"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_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 Qt(this.stateStore);const c=[...o].reverse().find(g=>g.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 Zn,g,d as xr,e as W,s as J,f as ir,t as xn}from"../chunks/vMsF8lo6.js";import{ar as En,b2 as rs,al as kr,be as H,ap as _o,M as mi,aS as gi,aq as Ms,d as ea,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 yo,C as wo,aE as ls,a2 as sr,ac as Ci,az as Ii,aZ as Ri,ay as ta,bd as na,bf as $i,bg as Vs,aU as Ks,aQ as ko,aP as lr,aM as cr,af as Wt,b6 as f,ai as t,a5 as Mi,bh as V,$ as Di,bl as Nn,ah as Vn,a8 as Gt,aK as qr,a_ as p,X as u,aV as d,aI as lt,b9 as G,aO as Mn,bi as Pt,bj as Pi,aT as Li}from"../chunks/CEg8tgYI.js";import{i as E,s as Cr,a as $e,p as br}from"../chunks/MtE7VtNZ.js";import{a as Oi,b as ge,r as nt,c as ra,e as _n,i as Pn,d as Ni}from"../chunks/B59dpE7G.js";import{_ as Fi,b as qn}from"../chunks/ylfInSZr.js";import{v as sa}from"../chunks/BOgjnF-w.js";import{p as Ui}from"../chunks/CYfubaPP.js";function So(n,e,r=!1,s=!1,o=!1,a=!1){var l=n,c="";if(r){var _=n;En&&(l=rs(kr(_)))}H(()=>{var m=mi;if(c===(c=e()??"")){En&&_o();return}if(r&&!En){m.nodes=null,_.innerHTML=c,c!==""&&ms(kr(_),_.lastChild);return}if(m.nodes!==null&&(gi(m.nodes.start,m.nodes.end),m.nodes=null),c!==""){if(En){Ms.data;for(var x=_o(),I=x;x!==null&&(x.nodeType!==ea||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,N=yi(s?"svg":o?"math":"template",P);N.innerHTML=c;var S=s||o?N:N.content;if(ms(kr(S),S.lastChild),s||o)for(;kr(S);)l.before(kr(S));else l.before(S)}})}function zi(n,e){let r=null,s=En;var o;if(En){r=Ms;for(var a=kr(document.head);a!==null&&(a.nodeType!==ea||a.data!==n);)a=Ds(a);if(a===null)yo(!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&&(yo(!0),rs(r))}}function oa(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=oa(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=oa(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 rn(n,e,r,s,o,a){var l=n[wo];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[wo]=r}return a}function Ys(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(ta(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function aa(n){var e=new MutationObserver(()=>{Ys(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),na(()=>{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,sr!==null&&s.add(sr)}),Ci(()=>{var a=e();if(n===document.activeElement){var l=sr;if(s.has(l))return}if(Ys(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=zr(c),r(a))}n.__value=a,o=!1}),aa(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),sr!==null&&s.add(sr),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||Vs(e)==null&&n.value)&&(r(xs(n)?_s(n.value):n.value),sr!==null&&s.add(sr)),Ks(()=>{var o=e();if(n===document.activeElement){var a=sr;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 ar(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=To(l,m,r.checked)),o(m)},()=>o(a?[]:null)),Ks(()=>{var m=s();if(En&&r.defaultChecked!==r.checked){c=!0;return}a?(m=m||[],r.checked=m.includes(r.__value)):r.checked=ta(r.__value,m)}),na(()=>{var m=l.indexOf(r);m!==-1&&l.splice(m,1)}),gs.has(l)||(gs.add(l),ko(()=>{l.sort((m,x)=>m.compareDocumentPosition(x)===4?-1:1),gs.delete(l)})),ko(()=>{if(c){var m;if(a)m=To(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||Vs(e)==null)&&r(n.checked),Ks(()=>{var s=e();n.checked=!!s})}function To(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 Tr(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){lr(e,!0);const r=ws.endsWith("/")?ws.slice(0,-1):ws,s=r+"/preview.png";let o=V(()=>e.home||!1),a=V(()=>({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(),_=Wt(c),m=f(_,2),x=f(m,2);{var I=qe=>{var Xe=Zn(),yt=Wt(Xe);E(yt,rt=>{}),h(qe,Xe)};E(x,qe=>{t(o)&&qe(I)})}var P=f(x,2),N=f(P,2),S=f(N,2),Y=f(S,2),ke=f(Y,2),Q=f(ke,4),ue=f(Q,2),Le=f(ue,2),_e=f(Le,2),Ce=f(_e,2),fe=f(Ce,2),Me=f(fe,2),Ie=f(Me,2),St=f(Ie,2),ut=f(St,4),Ge=f(ut,4),we=f(Ge,2),Tt=f(we,2);H((qe,Xe,yt,rt)=>{ge(_,"content",t(a).title),ge(m,"content",t(a).description),ge(P,"content",t(a).type),ge(N,"content",t(a).url),ge(S,"content",t(a).title),ge(Y,"content",t(a).description),ge(ke,"content",t(a).image),ge(Q,"content",t(a).url),ge(ue,"content",t(a).title),ge(Le,"content",t(a).description),ge(_e,"content",t(a).image),ge(Ce,"href",qe),ge(fe,"href",Xe),ge(Me,"href",yt),ge(Ie,"href",rt),ge(St,"content",Vi),ge(ut,"content",ys),ge(Ge,"content",Ki),ge(we,"content",ys),ge(Tt,"content",sa)},[()=>Tr("/pwa/favicon.png"),()=>Tr("/pwa/favicon.ico"),()=>Tr("/pwa/apple-touch-icon.png"),()=>Tr("/pwa/manifest.webmanifest")]),Mi(()=>{Di.title=t(a).title??""}),h(l,c)}),cr()}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 Ao(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 Eo=new Map;function Ji(n){if(typeof Audio>"u")return!1;try{let e=Eo.get(n);e||(e=new Audio(n),e.preload="auto",Eo.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 ia(n){if(n&&n.trim()&&Ji(n.trim()))return;const e=Xi();if(e)try{const r=e.currentTime;Ao(e,1046.5,r,.16,.12),Ao(e,1396.9,r+.13,.22,.12)}catch{}}function es(){}function Qi(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 Jt(n){let e;return el(n,r=>e=r)(),e}var yr=[];function tl(n,e=es){let r;const s=new Set;function o(c){if(Qi(n,c)&&(n=c,r)){const _=!yr.length;for(const m of s)m[1](),yr.push(m,n);if(_){for(let m=0;m<yr.length;m+=2)yr[m][0](yr[m+1]);yr.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,folderConflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null};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(N=>r?{...N,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(N=>({...N,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const N=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=N?new c(l,N):new c(l)}catch(N){this.stateStore.update(S=>({...S,connecting:!1,error:`Failed to connect: ${N}`})),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(Q=>({...Q,connected:!0,connecting:!1,error:null}));const N=Jt(this.stateStore),S=this.resumeSessionFile??N.activeSessionFile,Y=this.resumeSessionFile!=null?this.resumeCwd:N.activeCwd??void 0,ke=this.resumeSessionFile!=null?this.resumeModel:N.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,S?(this.stateStore.update(Q=>Q.resyncing?Q:{...Q,resyncing:!0}),this.send({type:"session_load",sessionFile:S,cwd:Y,model:ke}),this.armLoadWatchdog()):this.stateStore.update(Q=>Q.resyncing?{...Q,resyncing:!1}:Q)},x=N=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const S=typeof N.data=="string"?N.data:N.data.toString(),Y=JSON.parse(S);this.handleMessage(Y)}catch(S){console.error("Failed to parse WebSocket message:",S)}}},I=()=>{this.ws===_&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(N=>({...N,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:N.activeSessionFile?!0:N.resyncing})),this.scheduleReconnect())},P=N=>{this.ws===_&&this.stateStore.update(S=>({...S,error:S.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",N=>x({data:N})),_.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=Jt(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=Jt(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||Jt(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=Jt(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=Jt(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,Jt(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=!!Jt(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)},this.reconnectDelay))}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":case"session_error":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(e.uploadId);s&&(s.resolve({savedPath:e.savedPath,filename:e.filename}),this.pendingUploads.delete(e.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(e.uploadId);s&&(s.reject(new Error(e.error)),this.pendingUploads.delete(e.uploadId));break}case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="thinking"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="assistant"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_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 Jt(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(_=>_.isStreaming&&(_.role==="assistant"||_.role==="thinking")?{..._,isStreaming:!1}:_),a=Date.now(),l=!!e.forceCommand;if(l){const _=o.find(m=>m.role==="tool"&&m.optimistic&&m.isStreaming);if(_)return{...s,messages:o.map(m=>m.id===_.id?{...m,optimistic:!1,toolName:e.toolName,toolArgs:r,content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,startedAt:a,timestamp:a,forceCommand:!0}:m)}}const c={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...l?{forceCommand:!0}:{}};return{...s,messages:[...o,c]}});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
|
-
${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:")),
|
|
4
|
-
${s}`,isStreaming:!1,isError:a,interrupted:o,toolOutput:s,...l?{images:l}:{},endedAt:
|
|
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
|
+
${s}`,isStreaming:!1,isError:a,interrupted:o,toolOutput:s,...l?{images:l}:{},endedAt:m}:I)}}else{const x=a?`Tool error: ${e.toolName}
|
|
5
5
|
${s}`:`${e.toolName}
|
|
6
|
-
${s}`,
|
|
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,
|
|
8
|
-
${x.content}`:`$ ${
|
|
9
|
-
${x.content}`,isStreaming:!1,toolOutput:x.content,...Array.isArray(x.images)&&x.images.length>0?{images:x.images}:{},isError:N,interrupted:S,timestamp:x.timestamp,...
|
|
10
|
-
${x.content}`,timestamp:x.timestamp,isStreaming:!1,toolName:R,toolArgs:"",toolOutput:x.content,...Array.isArray(x.images)&&x.images.length>0?{images:x.images}:{},isError:N,interrupted:S,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,R)=>x-R);const g=s&&_.length>0?_[_.length-1]:-1;for(const x of _)x===g?o[x]={...o[x],isStreaming:!0}:o[x]={...o[x],interrupted:!0};if(s&&o.length>0){const x=o.length-1,R=o[x];(R.role==="assistant"||R.role==="thinking")&&(o[x]={...R,isStreaming:!0})}return o}loadMoreHistory(){const e=Qt(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=Qt(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=Qt(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=Qt(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=Qt(this.stateStore);e.sessionId&&this.send({type:"abort",sessionId:e.sessionId})}joinSession(e,r,s){this.stateStore.update(o=>({...o,folderConflict: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=Qt(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,folderConflict: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,folderConflict: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=Qt(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}continueFolderConflict(){const e=Qt(this.stateStore);!e.folderConflict||!e.sessionId||(this.send({type:"folder_conflict_continue",sessionId:e.sessionId}),this.stateStore.update(r=>({...r,readOnly:!1,folderConflict:r.folderConflict?{...r.folderConflict,continued:!0}:null})))}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=Qt(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=Qt(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 Ar=Nn({folders:[],activeSessions:[],currentSession:null,loading:!1}),Er=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,Co=0;const nl=150,rl=1e3;async function Io(){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();Ar.set({folders:o.folders||[],activeSessions:(o.activeSessions||[]).map(a=>a.sessionFile),currentSession:Vn(Ar).currentSession,loading:!1})}catch(n){Ar.update(e=>({...e,loading:!1})),console.error("Failed to fetch sessions:",n)}finally{Ls=!1}}function Br(){Ar.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)Co=e;else if(clearTimeout(Rr),e-Co>=rl)return Rr=null,Ro(),n;return Rr=setTimeout(()=>{Rr=null,Ro()},nl),n}async function Ro(){const n=[...Ps];Ps=[];try{for(await Io();Os;)Os=!1,await Io()}finally{for(const e of n)e()}}async function la(){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:Vn(Nr).currentSession,loading:!1})}catch(n){Nr.update(e=>({...e,loading:!1})),console.error("Failed to fetch read-only sessions:",n)}}async function sl(){Er.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();Er.set({models:o.models||[],loading:!1})}catch(n){Er.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 Zs=Nn(!1),ca=Nn("websocket"),Xs=Nn(null),da=Nn(!1),ua=Nn(null);async function fa(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();Zs.set(!!o.gitInitDefault),ca.set(o.uploadMethod||"websocket"),Xs.set(o.searchFolder||null),da.set(!!o.searchCreateRemote),ua.set(o.searchDefaultModel||null)}catch(n){console.error("Failed to fetch config:",n)}}function Hr(n){Ar.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 er(){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(!!er().beepDefault),pa="wherever-beep-overrides";function ll(){try{const n=localStorage.getItem(pa);if(n){const e=JSON.parse(n);if(e&&typeof e=="object")return e}}catch{}return{}}function cl(n){try{localStorage.setItem(pa,JSON.stringify(n))}catch{}}const ha=Nn(typeof localStorage<"u"?ll():{}),Qs=Nn("");function dl(){return Vn(cs)}function ba(){const n=er().beepSoundUrl;return typeof n=="string"?n:""}function ul(n){const e=er();Vr({...e,beepSoundUrl:n})}const Js=Gt([Qs,ha],([n,e])=>n&&n in e?e[n]:void 0),eo=Gt([Js,cs],([n,e])=>n===void 0?e:n);function fl(n){const e=er();Vr({...e,beepDefault:n}),cs.set(n)}function ts(n){const e=Vn(Qs);e&&ha.update(r=>{const s={...r};return n===void 0?delete s[e]:s[e]=n,cl(s),s})}function va(n){Qs.set(n??"")}const $r=er(),dt=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=dt.stateStore;let As=!1,$o=null;ds.subscribe(n=>{const e=n.sessionId??n.activeSessionFile??null;if(e!==$o){$o=e,va(e),As=n.isStreaming;return}As&&!n.isStreaming&&e&&Vn(eo)&&ia(ba()),As=n.isStreaming});let Fr=null;dt.onMessage(n=>{switch(n.type){case"session_created":if(Hr(n.sessionFile),Fr!==null){const r=Fr;Fr=null,queueMicrotask(()=>dt.sendMessage(r))}break;case"session_error":Fr=null;break;case"session_destroyed":Vn(ds).sessionId===n.sessionId&&Hr(null);break;case"sessions_updated":Br();break;case"session_interrupted":Hr(null);break}});function vr(){const n=er();Vr(n);const e=typeof window<"u"&&window.location&&window.location.protocol==="https:";dt.connect({host:n.host,port:n.port,token:n.token,secure:e,hideThinking:!!n.hideThinking,hideTools:!!n.hideTools})}function jr(){dt.disconnect(!0),Hr(null)}function ma(){dt.suspend()}function Ns(){dt.resume()}function pl(){return dt.hasSuspendedSession()}function Fs(){return dt.hasActiveSession()}let to=0;const hl=300*1e3;function ga(){to=Date.now()+hl}function no(){to=0}function xa(){return Date.now()<to}function Us(n){return dt.sendMessage(n)}function _a(n){return dt.resendMessage(n)}function ya(n){dt.discardMessage(n)}function wa(){dt.abort()}function ka(n,e,r){dt.joinSession(n,e,r)}function ro(n,e,r){dt.switchSession(n,e,r)}function jn(n,e,r,s,o,a){dt.createSession(n,e,r,s,o,a)}function Sa(n,e){const r=n.trim();if(!r)return!1;const s=Vn(Xs);if(!s)return!1;const o=Vn(da);return Fr=r,dt.createSession(s,e||void 0,o,o,o?"private":void 0),!0}function Dn(){dt.leaveSession(),Hr(null)}function Ta(){dt.loadMoreHistory()}function Aa(){dt.continueFolderConflict()}function bl(){dt.ping()}function Ea(){dt.clearMessages()}function zs(n){Vr(n);const{host:e,port:r,token:s,hideThinking:o,hideTools:a}=n;dt.setConfig({host:e,port:r,token:s,hideThinking:o,hideTools:a}),n.beepDefault!==void 0&&cs.set(!!n.beepDefault)}function Ca(n){const r={...er(),...n};Vr(r),dt.setConfig(r)}function mr(){dt.dismissSessionError()}function Ia(){dt.dismissNotice()}function Ra(n){dt.sendSudoPassword(n)}function $a(){dt.cancelSudoPrompt()}function Ma(n){dt.changeModel(n)}const Lt=Gt(ds,n=>n),Kr=Gt(Lt,n=>n.connected),so=Gt(Lt,n=>n.isStreaming),Da=Gt(Lt,n=>n.messages),vl=Gt(Lt,n=>n.error),ml=Gt(Lt,n=>n.session),Pa=Gt(Lt,n=>n.folderConflict),La=Gt(Lt,n=>n.isInterrupted),oo=Gt(Lt,n=>n.sessionError),Oa=Gt(Lt,n=>n.notice),Na=Gt(Lt,n=>n.sudoPrompt),us=Gt(Lt,n=>n.readOnly),Yr=Gt(Lt,n=>({sessionFile:n.activeSessionFile,cwd:n.activeCwd,model:n.activeModel,sessionId:n.sessionId})),gl=Gt(Lt,n=>n.contextUsage),Fa=Gt(Lt,n=>n.creatingSession),fs=Gt(Lt,n=>n.loadingSession),ao=Gt(Lt,n=>n.resyncing),Ua=Gt(Lt,n=>n.agentPending),za=Gt(Lt,n=>n.historyOffset>0),Ba=Gt(Lt,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]||"";dt.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=Vn(Lt).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 Vn(ca)==="post"?xl(n,e):_l(n,e)}async function Bs(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:wa,activeSessionInfo:Yr,beepEnabled:eo,beepSessionOverride:Js,beginFilePicker:ga,cancelSudoPrompt:$a,changeModel:Ma,clearMessages:Ea,client:dt,connect:vr,connectionError:vl,contextUsage:gl,continueFolderConflict:Aa,createSession:jn,currentSession:ml,deleteSession:Bs,discardMessage:ya,disconnect:jr,dismissNotice:Ia,dismissSessionError:mr,downloadFileUrl:Ha,endFilePicker:no,folderConflict:Pa,getBeepDefault:dl,getBeepSoundUrl:ba,getConfig:er,hasActiveSession:Fs,hasMoreHistory:za,hasSuspendedSession:pl,isAgentPending:Ua,isConnected:Kr,isCreatingSession:Fa,isFilePickerActive:xa,isInterrupted:La,isLoadingMoreHistory:Ba,isLoadingSession:fs,isReadOnly:us,isResyncing:ao,isStreaming:so,joinSession:ka,leaveSession:Dn,loadMoreHistory:Ta,messages:Da,piState:Lt,ping:bl,resendMessage:_a,resume:Ns,runSearch:Sa,sendMessage:Us,sendSudoPassword:Ra,sessionError:oo,sessionNotice:Oa,setBeepDefault:fl,setBeepSessionKey:va,setBeepSessionOverride:ts,setBeepSoundUrl:ul,setConfig:zs,state:ds,sudoPrompt:Na,suspend:ma,switchSession:ro,updateConfig:Ca,uploadFile:Wa},Symbol.toStringTag,{value:"Module"}));var wl=m('<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=m('<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=m('<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){lr(e,!0);const r=()=>$e(Kr,"$isConnected",s),[s,o]=Cr();let a=G(""),l=G(0),c=G(""),_=G(!1),g=G(!1),x=G(""),R=!1,O=V(r);qr(()=>{const Ee=er();p(a,Ee.host,!0),p(l,Ee.port,!0),p(c,Ee.token||"",!0),p(_,!!Ee.hideThinking),p(g,!!Ee.beepDefault),p(x,Ee.beepSoundUrl||"",!0)});function N(){ia(t(x).trim()||void 0)}function S(){zs({host:t(a),port:t(l),token:t(c),hideThinking:t(_),hideTools:!1,beepDefault:t(g),beepSoundUrl:t(x).trim()})}function Y(){zs({host:t(a),port:t(l),token:t(c),hideThinking:t(_),hideTools:!1,beepDefault:t(g),beepSoundUrl:t(x).trim()}),jr(),setTimeout(()=>vr(),100)}function ke(){jr()}function J(){window.location.reload()}var ue=Sl(),Le=u(ue),_e=u(Le),Ce=f(u(_e),2);nt(Ce),d(_e);var fe=f(_e,2),Me=f(u(fe),2);nt(Me),d(fe);var Ie=f(fe,2),St=f(u(Ie),2);nt(St),d(Ie);var ut=f(Ie,2),Ge=u(ut);nt(Ge),lt(2),d(ut);var we=f(ut,2),Tt=u(we);nt(Tt),lt(2),d(we);var qe=f(we,2),Xe=f(u(qe),2),yt=u(Xe);nt(yt);var rt=f(yt,2);d(Xe),d(qe);var ft=f(qe,2),wt=u(ft);{var st=Ee=>{var ot=wl();W("click",ot,ke),h(Ee,ot)},te=Ee=>{var ot=kl();ot.disabled=R,ot.textContent="Connect",W("click",ot,Y),h(Ee,ot)};E(wt,Ee=>{t(O)?Ee(st):Ee(te,-1)})}d(ft);var xt=f(ft,2);d(Le),d(ue),Ln(Ce,()=>t(a),Ee=>p(a,Ee)),Ln(Me,()=>t(l),Ee=>p(l,Ee)),Ln(St,()=>t(c),Ee=>p(c,Ee)),W("change",Ge,S),On(Ge,()=>t(_),Ee=>p(_,Ee)),W("change",Tt,S),On(Tt,()=>t(g),Ee=>p(g,Ee)),W("change",yt,S),Ln(yt,()=>t(x),Ee=>p(x,Ee)),W("click",rt,N),W("click",xt,J),h(n,ue),cr(),o()}xr(["change","click"]);function io(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var _r=io();function Ga(n){_r=n}var Wr={exec:()=>null};function ht(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(mn.caret,"$1"),r=r.replace(o,l),s},getRegex:()=>new RegExp(r,e)};return s}var mn={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+|$)/,lo=/(?:[*+-]|\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=ht(ja).replace(/bull/g,lo).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=ht(ja).replace(/bull/g,lo).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(),co=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,$l=/^[^\n]+/,uo=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ml=ht(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",uo).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Dl=ht(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,lo).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",fo=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Pl=ht("^ {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",fo).replace("tag",ps).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Va=ht(co).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=ht(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Va).getRegex(),po={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},Mo=ht("^ *([^\\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={...po,lheading:Rl,table:Mo,paragraph:ht(co).replace("hr",Zr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Mo).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={...po,html:ht(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fo).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:ht(co).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,ho=/[\s\p{P}\p{S}]/u,Ya=/[^\s\p{P}\p{S}]/u,Bl=ht(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ho).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=ht(Xa,"u").replace(/punct/g,hs).getRegex(),ql=ht(Xa,"u").replace(/punct/g,Za).getRegex(),
|
|
6
|
+
${s}`,I={id:this.generateId(),role:"tool",content:x,timestamp:m,isStreaming:!1,toolName:e.toolName,toolArgs:"",toolOutput:s,...l?{images:l}:{},isError:a,interrupted:o,endedAt:m};return{...c,messages:[...c.messages,I]}}});break}case"aborted":{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)}));break}case"session_created":this.stateStore.update(s=>({...s,session:e.sessionFile,sessionId:e.sessionId,activeSessionFile:e.sessionFile,activeCwd:e.cwd,activeModel:e.model,isStreaming:e.isStreaming??!1,creatingSession:!1,readOnly:e.readOnly??!1,folderConflict:e.folderConflict?{cwd:e.cwd,active:!0,continued:!1}:null,agentPending:e.pending===!0,contextUsage:e.contextUsage??null}));break;case"session_ready":this.stateStore.update(s=>e.sessionFile&&s.activeSessionFile&&e.sessionFile!==s.activeSessionFile?s:{...s,agentPending:!1,activeModel:e.model??s.activeModel,isStreaming:e.isStreaming??s.isStreaming,contextUsage:e.contextUsage??s.contextUsage});break;case"context_usage":this.stateStore.update(s=>({...s,contextUsage:e.contextUsage??null}));break;case"session_notice":this.stateStore.update(s=>s.sessionId&&e.sessionId&&s.sessionId!==e.sessionId?s:{...s,notice:{level:e.level,message:e.message}});break;case"bash_sudo_prompt":this.stateStore.update(s=>s.sessionId&&e.sessionId&&s.sessionId!==e.sessionId?s:{...s,sudoPrompt:{promptId:e.promptId,command:e.command,sessionId:e.sessionId}});break;case"session_destroyed":this.stateStore.update(s=>s.sessionId===e.sessionId?{...s,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,loadingSession:!1,agentPending:!1,notice:null,sudoPrompt:null}:s);break;case"session_error":this.stateStore.update(s=>({...s,sessionError:e.error,isStreaming:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1}));break;case"folder_conflict":this.stateStore.update(s=>!s.sessionId||s.activeCwd&&e.cwd!==s.activeCwd?s:e.active?s.folderConflict?{...s,folderConflict:{...s.folderConflict,cwd:e.cwd,active:!0}}:{...s,folderConflict:{cwd:e.cwd,active:!0,continued:!0}}:s.folderConflict?{...s,folderConflict:null}:s);break;case"session_interrupted":this.stateStore.update(s=>({...s,isInterrupted:!0,readOnly:!0,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,creatingSession:!1,loadingSession:!1,agentPending:!1,notice:null,sudoPrompt:null}));break;case"message_history":{const s=e.sessionId,o=Jt(this.stateStore).messages.filter(c=>c.role==="user"&&c.delivery!==void 0),l=[...this.loadPersistedPending(s),...o];this.stateStore.update(c=>{const _=this.mapHistory(e.messages,e.sessionId,c.isStreaming),m=typeof e.totalCount=="number"?e.totalCount:_.length,x=typeof e.offset=="number"?e.offset:0,I=new Set(_.filter(S=>S.role==="user").map(S=>S.content)),P=new Set,N=[];for(const S of l)I.has(S.content)||P.has(S.content)||(P.add(S.content),N.push({...S,sessionId:s,delivery:"failed"}));return{...c,messages:[..._,...N],historyTotalCount:m,historyOffset:x,loadingMoreHistory:!1,loadingSession:!1,resyncing:!1}});for(const c of l)this.clearConfirm(c.id);this.persistPending(s);break}case"message_history_prepend":this.stateStore.update(s=>{const o=this.mapHistory(e.messages,e.sessionId,!1),a=typeof e.offset=="number"?e.offset:0;return o.length===0?{...s,loadingMoreHistory:!1,historyOffset:a}:{...s,messages:[...o,...s.messages],historyOffset:a,loadingMoreHistory:!1}});break;case"model_changed":this.stateStore.update(s=>({...s,activeModel:e.model}));break}}isAbortedToolResult(e){if(!e)return!1;const r=e.trimEnd().split(`
|
|
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 N=P.indexOf(I);N!==-1&&P.splice(N,1)};for(const x of e)if(x.role==="tool_call"){const I=x.toolName||"unknown",P=x.content||"",N=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(N),typeof x.toolCallId=="string"&&x.toolCallId&&(l[x.toolCallId]=N)}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[Y,ke]of Object.entries(l))ke===P&&delete l[Y]}const N=x.isError&&!this.isAbortedToolResult(x.content),S=!!x.isError&&this.isAbortedToolResult(x.content);if(P!==void 0){const Y=o[P],ke=Y.toolArgs||"",Q=Y.startedAt;o[P]={...Y,content:ke?`$ ${I} ${ke}
|
|
8
|
+
${x.content}`:`$ ${I}
|
|
9
|
+
${x.content}`,isStreaming:!1,toolOutput:x.content,...Array.isArray(x.images)&&x.images.length>0?{images:x.images}:{},isError:N,interrupted:S,timestamp:x.timestamp,...Q!==void 0&&Number.isFinite(Q)&&Number.isFinite(x.timestamp)&&x.timestamp>=Q?{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:N,interrupted:S,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=Jt(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=Jt(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("!")){const a=e.trimStart(),c=(a.startsWith("!!")?a.slice(2):a.slice(1)).trim(),_=/^sudo(\s|$)/.test(c);if(c&&!_){const m=`command=${JSON.stringify(c)}`,x=Date.now(),I={id:this.generateId(),role:"tool",content:`$ bash ${m}`,timestamp:x,isStreaming:!0,toolName:"bash",toolArgs:m,toolOutput:"",startedAt:x,forceCommand:!0,optimistic:!0};return this.stateStore.update(P=>({...P,sessionError:null,messages:[...P.messages,I]})),!0}return this.stateStore.update(m=>({...m,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=Jt(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=Jt(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=Jt(this.stateStore);e.sessionId&&this.send({type:"abort",sessionId:e.sessionId})}joinSession(e,r,s){this.stateStore.update(o=>({...o,folderConflict: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=Jt(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,folderConflict: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,folderConflict: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=Jt(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}continueFolderConflict(){const e=Jt(this.stateStore);!e.folderConflict||!e.sessionId||(this.send({type:"folder_conflict_continue",sessionId:e.sessionId}),this.stateStore.update(r=>({...r,readOnly:!1,folderConflict:r.folderConflict?{...r.folderConflict,continued:!0}:null})))}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=Jt(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=Jt(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 Ar=Nn({folders:[],activeSessions:[],currentSession:null,loading:!1}),Er=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,Co=0;const nl=150,rl=1e3;async function Io(){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();Ar.set({folders:o.folders||[],activeSessions:(o.activeSessions||[]).map(a=>a.sessionFile),currentSession:Vn(Ar).currentSession,loading:!1})}catch(n){Ar.update(e=>({...e,loading:!1})),console.error("Failed to fetch sessions:",n)}finally{Ls=!1}}function Br(){Ar.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)Co=e;else if(clearTimeout(Rr),e-Co>=rl)return Rr=null,Ro(),n;return Rr=setTimeout(()=>{Rr=null,Ro()},nl),n}async function Ro(){const n=[...Ps];Ps=[];try{for(await Io();Os;)Os=!1,await Io()}finally{for(const e of n)e()}}async function la(){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:Vn(Nr).currentSession,loading:!1})}catch(n){Nr.update(e=>({...e,loading:!1})),console.error("Failed to fetch read-only sessions:",n)}}async function sl(){Er.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();Er.set({models:o.models||[],loading:!1})}catch(n){Er.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 Zs=Nn(!1),ca=Nn("websocket"),Xs=Nn(null),da=Nn(!1),ua=Nn(null);async function fa(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();Zs.set(!!o.gitInitDefault),ca.set(o.uploadMethod||"websocket"),Xs.set(o.searchFolder||null),da.set(!!o.searchCreateRemote),ua.set(o.searchDefaultModel||null)}catch(n){console.error("Failed to fetch config:",n)}}function Hr(n){Ar.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 er(){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(!!er().beepDefault),pa="wherever-beep-overrides";function ll(){try{const n=localStorage.getItem(pa);if(n){const e=JSON.parse(n);if(e&&typeof e=="object")return e}}catch{}return{}}function cl(n){try{localStorage.setItem(pa,JSON.stringify(n))}catch{}}const ha=Nn(typeof localStorage<"u"?ll():{}),Js=Nn("");function dl(){return Vn(cs)}function ba(){const n=er().beepSoundUrl;return typeof n=="string"?n:""}function ul(n){const e=er();Vr({...e,beepSoundUrl:n})}const Qs=Gt([Js,ha],([n,e])=>n&&n in e?e[n]:void 0),eo=Gt([Qs,cs],([n,e])=>n===void 0?e:n);function fl(n){const e=er();Vr({...e,beepDefault:n}),cs.set(n)}function ts(n){const e=Vn(Js);e&&ha.update(r=>{const s={...r};return n===void 0?delete s[e]:s[e]=n,cl(s),s})}function va(n){Js.set(n??"")}const $r=er(),dt=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=dt.stateStore;let As=!1,$o=null;ds.subscribe(n=>{const e=n.sessionId??n.activeSessionFile??null;if(e!==$o){$o=e,va(e),As=n.isStreaming;return}As&&!n.isStreaming&&e&&Vn(eo)&&ia(ba()),As=n.isStreaming});let Fr=null;dt.onMessage(n=>{switch(n.type){case"session_created":if(Hr(n.sessionFile),Fr!==null){const r=Fr;Fr=null,queueMicrotask(()=>dt.sendMessage(r))}break;case"session_error":Fr=null;break;case"session_destroyed":Vn(ds).sessionId===n.sessionId&&Hr(null);break;case"sessions_updated":Br();break;case"session_interrupted":Hr(null);break}});function vr(){const n=er();Vr(n);const e=typeof window<"u"&&window.location&&window.location.protocol==="https:";dt.connect({host:n.host,port:n.port,token:n.token,secure:e,hideThinking:!!n.hideThinking,hideTools:!!n.hideTools})}function jr(){dt.disconnect(!0),Hr(null)}function ma(){dt.suspend()}function Ns(){dt.resume()}function pl(){return dt.hasSuspendedSession()}function Fs(){return dt.hasActiveSession()}let to=0;const hl=300*1e3;function ga(){to=Date.now()+hl}function no(){to=0}function xa(){return Date.now()<to}function Us(n){return dt.sendMessage(n)}function _a(n){return dt.resendMessage(n)}function ya(n){dt.discardMessage(n)}function wa(){dt.abort()}function ka(n,e,r){dt.joinSession(n,e,r)}function ro(n,e,r){dt.switchSession(n,e,r)}function jn(n,e,r,s,o,a){dt.createSession(n,e,r,s,o,a)}function Sa(n,e){const r=n.trim();if(!r)return!1;const s=Vn(Xs);if(!s)return!1;const o=Vn(da);return Fr=r,dt.createSession(s,e||void 0,o,o,o?"private":void 0),!0}function Dn(){dt.leaveSession(),Hr(null)}function Ta(){dt.loadMoreHistory()}function Aa(){dt.continueFolderConflict()}function bl(){dt.ping()}function Ea(){dt.clearMessages()}function zs(n){Vr(n);const{host:e,port:r,token:s,hideThinking:o,hideTools:a}=n;dt.setConfig({host:e,port:r,token:s,hideThinking:o,hideTools:a}),n.beepDefault!==void 0&&cs.set(!!n.beepDefault)}function Ca(n){const r={...er(),...n};Vr(r),dt.setConfig(r)}function mr(){dt.dismissSessionError()}function Ia(){dt.dismissNotice()}function Ra(n){dt.sendSudoPassword(n)}function $a(){dt.cancelSudoPrompt()}function Ma(n){dt.changeModel(n)}const Lt=Gt(ds,n=>n),Kr=Gt(Lt,n=>n.connected),so=Gt(Lt,n=>n.isStreaming),Da=Gt(Lt,n=>n.messages),vl=Gt(Lt,n=>n.error),ml=Gt(Lt,n=>n.session),Pa=Gt(Lt,n=>n.folderConflict),La=Gt(Lt,n=>n.isInterrupted),oo=Gt(Lt,n=>n.sessionError),Oa=Gt(Lt,n=>n.notice),Na=Gt(Lt,n=>n.sudoPrompt),us=Gt(Lt,n=>n.readOnly),Yr=Gt(Lt,n=>({sessionFile:n.activeSessionFile,cwd:n.activeCwd,model:n.activeModel,sessionId:n.sessionId})),gl=Gt(Lt,n=>n.contextUsage),Fa=Gt(Lt,n=>n.creatingSession),fs=Gt(Lt,n=>n.loadingSession),ao=Gt(Lt,n=>n.resyncing),Ua=Gt(Lt,n=>n.agentPending),za=Gt(Lt,n=>n.historyOffset>0),Ba=Gt(Lt,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]||"";dt.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=Vn(Lt).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 Vn(ca)==="post"?xl(n,e):_l(n,e)}async function Bs(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:wa,activeSessionInfo:Yr,beepEnabled:eo,beepSessionOverride:Qs,beginFilePicker:ga,cancelSudoPrompt:$a,changeModel:Ma,clearMessages:Ea,client:dt,connect:vr,connectionError:vl,contextUsage:gl,continueFolderConflict:Aa,createSession:jn,currentSession:ml,deleteSession:Bs,discardMessage:ya,disconnect:jr,dismissNotice:Ia,dismissSessionError:mr,downloadFileUrl:Ha,endFilePicker:no,folderConflict:Pa,getBeepDefault:dl,getBeepSoundUrl:ba,getConfig:er,hasActiveSession:Fs,hasMoreHistory:za,hasSuspendedSession:pl,isAgentPending:Ua,isConnected:Kr,isCreatingSession:Fa,isFilePickerActive:xa,isInterrupted:La,isLoadingMoreHistory:Ba,isLoadingSession:fs,isReadOnly:us,isResyncing:ao,isStreaming:so,joinSession:ka,leaveSession:Dn,loadMoreHistory:Ta,messages:Da,piState:Lt,ping:bl,resendMessage:_a,resume:Ns,runSearch:Sa,sendMessage:Us,sendSudoPassword:Ra,sessionError:oo,sessionNotice:Oa,setBeepDefault:fl,setBeepSessionKey:va,setBeepSessionOverride:ts,setBeepSoundUrl:ul,setConfig:zs,state:ds,sudoPrompt:Na,suspend:ma,switchSession:ro,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){lr(e,!0);const r=()=>$e(Kr,"$isConnected",s),[s,o]=Cr();let a=G(""),l=G(0),c=G(""),_=G(!1),m=G(!1),x=G(""),I=!1,P=V(r);qr(()=>{const Ee=er();p(a,Ee.host,!0),p(l,Ee.port,!0),p(c,Ee.token||"",!0),p(_,!!Ee.hideThinking),p(m,!!Ee.beepDefault),p(x,Ee.beepSoundUrl||"",!0)});function N(){ia(t(x).trim()||void 0)}function S(){zs({host:t(a),port:t(l),token:t(c),hideThinking:t(_),hideTools:!1,beepDefault:t(m),beepSoundUrl:t(x).trim()})}function Y(){zs({host:t(a),port:t(l),token:t(c),hideThinking:t(_),hideTools:!1,beepDefault:t(m),beepSoundUrl:t(x).trim()}),jr(),setTimeout(()=>vr(),100)}function ke(){jr()}function Q(){window.location.reload()}var ue=Sl(),Le=u(ue),_e=u(Le),Ce=f(u(_e),2);nt(Ce),d(_e);var fe=f(_e,2),Me=f(u(fe),2);nt(Me),d(fe);var Ie=f(fe,2),St=f(u(Ie),2);nt(St),d(Ie);var ut=f(Ie,2),Ge=u(ut);nt(Ge),lt(2),d(ut);var we=f(ut,2),Tt=u(we);nt(Tt),lt(2),d(we);var qe=f(we,2),Xe=f(u(qe),2),yt=u(Xe);nt(yt);var rt=f(yt,2);d(Xe),d(qe);var ft=f(qe,2),wt=u(ft);{var st=Ee=>{var ot=wl();W("click",ot,ke),h(Ee,ot)},te=Ee=>{var ot=kl();ot.disabled=I,ot.textContent="Connect",W("click",ot,Y),h(Ee,ot)};E(wt,Ee=>{t(P)?Ee(st):Ee(te,-1)})}d(ft);var xt=f(ft,2);d(Le),d(ue),Ln(Ce,()=>t(a),Ee=>p(a,Ee)),Ln(Me,()=>t(l),Ee=>p(l,Ee)),Ln(St,()=>t(c),Ee=>p(c,Ee)),W("change",Ge,S),On(Ge,()=>t(_),Ee=>p(_,Ee)),W("change",Tt,S),On(Tt,()=>t(m),Ee=>p(m,Ee)),W("change",yt,S),Ln(yt,()=>t(x),Ee=>p(x,Ee)),W("click",rt,N),W("click",xt,Q),h(n,ue),cr(),o()}xr(["change","click"]);function io(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var _r=io();function Ga(n){_r=n}var Wr={exec:()=>null};function ht(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(mn.caret,"$1"),r=r.replace(o,l),s},getRegex:()=>new RegExp(r,e)};return s}var mn={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+|$)/,lo=/(?:[*+-]|\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=ht(ja).replace(/bull/g,lo).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=ht(ja).replace(/bull/g,lo).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(),co=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,$l=/^[^\n]+/,uo=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ml=ht(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",uo).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Dl=ht(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,lo).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",fo=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Pl=ht("^ {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",fo).replace("tag",ps).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Va=ht(co).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=ht(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Va).getRegex(),po={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},Mo=ht("^ *([^\\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={...po,lheading:Rl,table:Mo,paragraph:ht(co).replace("hr",Zr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Mo).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={...po,html:ht(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fo).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:ht(co).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,ho=/[\s\p{P}\p{S}]/u,Ya=/[^\s\p{P}\p{S}]/u,Bl=ht(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ho).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=ht(Xa,"u").replace(/punct/g,hs).getRegex(),ql=ht(Xa,"u").replace(/punct/g,Za).getRegex(),Ja="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Vl=ht(Ja,"gu").replace(/notPunctSpace/g,Ya).replace(/punctSpace/g,ho).replace(/punct/g,hs).getRegex(),Kl=ht(Ja,"gu").replace(/notPunctSpace/g,Wl).replace(/punctSpace/g,Hl).replace(/punct/g,Za).getRegex(),Yl=ht("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ya).replace(/punctSpace/g,ho).replace(/punct/g,hs).getRegex(),Zl=ht(/\\(punct)/,"gu").replace(/punct/g,hs).getRegex(),Xl=ht(/^<(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(),Jl=ht(fo).replace("(?:-->|$)","-->").getRegex(),Ql=ht("^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",Jl).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),os=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ec=ht(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",os).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Qa=ht(/^!?\[(label)\]\[(ref)\]/).replace("label",os).replace("ref",uo).getRegex(),ei=ht(/^!?\[(ref)\](?:\[\])?/).replace("ref",uo).getRegex(),tc=ht("reflink|nolink(?!\\()","g").replace("reflink",Qa).replace("nolink",ei).getRegex(),bo={_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:Qa,reflinkSearch:tc,tag:Ql,text:zl,url:Wr},nc={...bo,link:ht(/^!?\[(label)\]\((.*?)\)/).replace("label",os).getRegex(),reflink:ht(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",os).getRegex()},Hs={...bo,emStrongRDelimAst:Kl,emStrongLDelim:ql,url:ht(/^((?: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={...Hs,br:ht(Ka).replace("{2,}","*").getRegex(),text:ht(Hs.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Jr={normal:po,gfm:Ol,pedantic:Nl},Mr={normal:bo,gfm:Hs,breaks:rc,pedantic:nc},sc={"&":"&","<":"<",">":">",'"':""","'":"'"},Do=n=>sc[n];function Wn(n,e){if(e){if(mn.escapeTest.test(n))return n.replace(mn.escapeReplace,Do)}else if(mn.escapeTestNoEncode.test(n))return n.replace(mn.escapeReplaceNoEncode,Do);return n}function Po(n){try{n=encodeURI(n).replace(mn.percentDecode,"%")}catch{return null}return n}function Lo(n,e){const r=n.replace(mn.findPipe,(a,l,c)=>{let _=!1,m=l;for(;--m>=0&&c[m]==="\\";)_=!_;return _?"|":" |"}),s=r.split(mn.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(mn.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 Oo(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||_r}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],`
|
|
15
15
|
`)}}blockquote(n){const e=this.rules.block.blockquote.exec(n);if(e){let r=Dr(e[0],`
|
|
16
16
|
`).split(`
|
|
17
|
-
`),s="",o="";const a=[];for(;r.length>0;){let l=!1;const c=[];let _;for(_=0;_<r.length;_++)if(this.rules.other.blockquoteStart.test(r[_]))c.push(r[_]),l=!0;else if(!l)c.push(r[_]);else break;r=r.slice(_);const
|
|
18
|
-
`),x=
|
|
17
|
+
`),s="",o="";const a=[];for(;r.length>0;){let l=!1;const c=[];let _;for(_=0;_<r.length;_++)if(this.rules.other.blockquoteStart.test(r[_]))c.push(r[_]),l=!0;else if(!l)c.push(r[_]);else break;r=r.slice(_);const m=c.join(`
|
|
18
|
+
`),x=m.replace(this.rules.other.blockquoteSetextReplace,`
|
|
19
19
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
20
|
-
${
|
|
21
|
-
${x}`:x;const
|
|
20
|
+
${m}`:m,o=o?`${o}
|
|
21
|
+
${x}`:x;const I=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(x,a,!0),this.lexer.state.top=I,r.length===0)break;const P=a.at(-1);if(P?.type==="code")break;if(P?.type==="blockquote"){const N=P,S=N.raw+`
|
|
22
22
|
`+r.join(`
|
|
23
|
-
`),Y=this.blockquote(S);a[a.length-1]=Y,s=s.substring(0,s.length-N.raw.length)+Y.raw,o=o.substring(0,o.length-N.text.length)+Y.text;break}else if(
|
|
23
|
+
`),Y=this.blockquote(S);a[a.length-1]=Y,s=s.substring(0,s.length-N.raw.length)+Y.raw,o=o.substring(0,o.length-N.text.length)+Y.text;break}else if(P?.type==="list"){const N=P,S=N.raw+`
|
|
24
24
|
`+r.join(`
|
|
25
|
-
`),Y=this.list(S);a[a.length-1]=Y,s=s.substring(0,s.length-
|
|
26
|
-
`);continue}}return{type:"blockquote",raw:s,tokens:a,text:o}}}list(n){let e=this.rules.block.list.exec(n);if(e){let r=e[1].trim();const s=r.length>1,o={type:"list",raw:"",ordered:s,start:s?+r.slice(0,-1):"",loose:!1,items:[]};r=s?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=s?r:"[*+-]");const a=this.rules.other.listItemRegex(r);let l=!1;for(;n;){let _=!1,
|
|
27
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,
|
|
28
|
-
`,1)[0],N=!
|
|
29
|
-
`,n=n.substring(
|
|
30
|
-
`,1)[0];let Me;if(
|
|
31
|
-
`+Me.slice(S);else{if(N||
|
|
32
|
-
`+
|
|
33
|
-
`,n=n.substring(fe.length+1),
|
|
25
|
+
`),Y=this.list(S);a[a.length-1]=Y,s=s.substring(0,s.length-P.raw.length)+Y.raw,o=o.substring(0,o.length-N.raw.length)+Y.raw,r=S.substring(a.at(-1).raw.length).split(`
|
|
26
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:a,text:o}}}list(n){let e=this.rules.block.list.exec(n);if(e){let r=e[1].trim();const s=r.length>1,o={type:"list",raw:"",ordered:s,start:s?+r.slice(0,-1):"",loose:!1,items:[]};r=s?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=s?r:"[*+-]");const a=this.rules.other.listItemRegex(r);let l=!1;for(;n;){let _=!1,m="",x="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;m=e[0],n=n.substring(m.length);let I=e[2].split(`
|
|
27
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,Q=>" ".repeat(3*Q.length)),P=n.split(`
|
|
28
|
+
`,1)[0],N=!I.trim(),S=0;if(this.options.pedantic?(S=2,x=I.trimStart()):N?S=e[1].length+1:(S=e[2].search(this.rules.other.nonSpaceChar),S=S>4?1:S,x=I.slice(S),S+=e[1].length),N&&this.rules.other.blankLine.test(P)&&(m+=P+`
|
|
29
|
+
`,n=n.substring(P.length+1),_=!0),!_){const Q=this.rules.other.nextBulletRegex(S),ue=this.rules.other.hrRegex(S),Le=this.rules.other.fencesBeginRegex(S),_e=this.rules.other.headingBeginRegex(S),Ce=this.rules.other.htmlBeginRegex(S);for(;n;){const fe=n.split(`
|
|
30
|
+
`,1)[0];let Me;if(P=fe,this.options.pedantic?(P=P.replace(this.rules.other.listReplaceNesting," "),Me=P):Me=P.replace(this.rules.other.tabCharGlobal," "),Le.test(P)||_e.test(P)||Ce.test(P)||Q.test(P)||ue.test(P))break;if(Me.search(this.rules.other.nonSpaceChar)>=S||!P.trim())x+=`
|
|
31
|
+
`+Me.slice(S);else{if(N||I.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Le.test(I)||_e.test(I)||ue.test(I))break;x+=`
|
|
32
|
+
`+P}!N&&!P.trim()&&(N=!0),m+=fe+`
|
|
33
|
+
`,n=n.substring(fe.length+1),I=Me.slice(S)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(m)&&(l=!0));let Y=null,ke;this.options.gfm&&(Y=this.rules.other.listIsTask.exec(x),Y&&(ke=Y[0]!=="[ ] ",x=x.replace(this.rules.other.listReplaceTask,""))),o.items.push({type:"list_item",raw:m,task:!!Y,checked:ke,loose:!1,text:x,tokens:[]}),o.raw+=m}const c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let _=0;_<o.items.length;_++)if(this.lexer.state.top=!1,o.items[_].tokens=this.lexer.blockTokens(o.items[_].text,[]),!o.loose){const m=o.items[_].tokens.filter(I=>I.type==="space"),x=m.length>0&&m.some(I=>this.rules.other.anyLine.test(I.raw));o.loose=x}if(o.loose)for(let _=0;_<o.items.length;_++)o.items[_].loose=!0;return o}}html(n){const e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){const e=this.rules.block.def.exec(n);if(e){const r=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:r,raw:e[0],href:s,title:o}}}table(n){const e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const r=Lo(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
34
34
|
`):[],a={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===s.length){for(const l of s)this.rules.other.tableAlignRight.test(l)?a.align.push("right"):this.rules.other.tableAlignCenter.test(l)?a.align.push("center"):this.rules.other.tableAlignLeft.test(l)?a.align.push("left"):a.align.push(null);for(let l=0;l<r.length;l++)a.header.push({text:r[l],tokens:this.lexer.inline(r[l]),header:!0,align:a.align[l]});for(const l of o)a.rows.push(Lo(l,a.header.length).map((c,_)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:a.align[_]})));return a}}lheading(n){const e=this.rules.block.lheading.exec(n);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(n){const e=this.rules.block.paragraph.exec(n);if(e){const r=e[1].charAt(e[1].length-1)===`
|
|
35
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(n){const e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){const e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){const e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){const e=this.rules.inline.link.exec(n);if(e){const r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;const a=Dr(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{const a=oc(e[2],"()");if(a===-2)return;if(a>-1){const c=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,c).trim(),e[3]=""}}let s=e[2],o="";if(this.options.pedantic){const a=this.rules.other.pedanticHrefTitle.exec(s);a&&(s=a[1],o=a[3])}else o=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?s=s.slice(1):s=s.slice(1,-1)),Oo(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let r;if((r=this.rules.inline.reflink.exec(n))||(r=this.rules.inline.nolink.exec(n))){const s=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=e[s.toLowerCase()];if(!o){const a=r[0].charAt(0);return{type:"text",raw:a,text:a}}return Oo(r,o,r[0],this.lexer,this.rules)}}emStrong(n,e,r=""){let s=this.rules.inline.emStrongLDelim.exec(n);if(!s||s[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const a=[...s[0]].length-1;let l,c,_=a,
|
|
35
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(n){const e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){const e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){const e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){const e=this.rules.inline.link.exec(n);if(e){const r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;const a=Dr(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{const a=oc(e[2],"()");if(a===-2)return;if(a>-1){const c=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,c).trim(),e[3]=""}}let s=e[2],o="";if(this.options.pedantic){const a=this.rules.other.pedanticHrefTitle.exec(s);a&&(s=a[1],o=a[3])}else o=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?s=s.slice(1):s=s.slice(1,-1)),Oo(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let r;if((r=this.rules.inline.reflink.exec(n))||(r=this.rules.inline.nolink.exec(n))){const s=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=e[s.toLowerCase()];if(!o){const a=r[0].charAt(0);return{type:"text",raw:a,text:a}}return Oo(r,o,r[0],this.lexer,this.rules)}}emStrong(n,e,r=""){let s=this.rules.inline.emStrongLDelim.exec(n);if(!s||s[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const a=[...s[0]].length-1;let l,c,_=a,m=0;const x=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(x.lastIndex=0,e=e.slice(-1*n.length+a);(s=x.exec(e))!=null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(c=[...l].length,s[3]||s[4]){_+=c;continue}else if((s[5]||s[6])&&a%3&&!((a+c)%3)){m+=c;continue}if(_-=c,_>0)continue;c=Math.min(c,c+_+m);const I=[...s[0]][0].length,P=n.slice(0,a+s.index+I+c);if(Math.min(a,c)%2){const S=P.slice(1,-1);return{type:"em",raw:P,text:S,tokens:this.lexer.inlineTokens(S)}}const N=P.slice(2,-2);return{type:"strong",raw:P,text:N,tokens:this.lexer.inlineTokens(N)}}}}codespan(n){const e=this.rules.inline.code.exec(n);if(e){let r=e[2].replace(this.rules.other.newLineCharGlobal," ");const s=this.rules.other.nonSpaceChar.test(r),o=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return s&&o&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:e[0],text:r}}}br(n){const e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n){const e=this.rules.inline.del.exec(n);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(n){const e=this.rules.inline.autolink.exec(n);if(e){let r,s;return e[2]==="@"?(r=e[1],s="mailto:"+r):(r=e[1],s=r),{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}url(n){let e;if(e=this.rules.inline.url.exec(n)){let r,s;if(e[2]==="@")r=e[0],s="mailto:"+r;else{let o;do o=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(o!==e[0]);r=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){const e=this.rules.inline.text.exec(n);if(e){const r=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:r}}}},Jn=class Ws{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||_r,this.options.tokenizer=this.options.tokenizer||new as,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const r={other:mn,block:Jr.normal,inline:Mr.normal};this.options.pedantic?(r.block=Jr.pedantic,r.inline=Mr.pedantic):this.options.gfm&&(r.block=Jr.gfm,this.options.breaks?r.inline=Mr.breaks:r.inline=Mr.gfm),this.tokenizer.rules=r}static get rules(){return{block:Jr,inline:Mr}}static lex(e,r){return new Ws(r).lex(e)}static lexInline(e,r){return new Ws(r).inlineTokens(e)}lex(e){e=e.replace(mn.carriageReturn,`
|
|
36
36
|
`),this.blockTokens(e,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){const s=this.inlineQueue[r];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,r=[],s=!1){for(this.options.pedantic&&(e=e.replace(mn.tabCharGlobal," ").replace(mn.spaceLine,""));e;){let o;if(this.options.extensions?.block?.some(l=>(o=l.call({lexer:this},e,r))?(e=e.substring(o.raw.length),r.push(o),!0):!1))continue;if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length);const l=r.at(-1);o.raw.length===1&&l!==void 0?l.raw+=`
|
|
37
37
|
`:r.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length);const l=r.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=`
|
|
38
38
|
`+o.raw,l.text+=`
|
|
39
39
|
`+o.text,this.inlineQueue.at(-1).src=l.text):r.push(o);continue}if(o=this.tokenizer.fences(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.heading(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.hr(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.blockquote(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.list(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.html(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.def(e)){e=e.substring(o.raw.length);const l=r.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=`
|
|
40
40
|
`+o.raw,l.text+=`
|
|
41
|
-
`+o.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title});continue}if(o=this.tokenizer.table(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.lheading(e)){e=e.substring(o.raw.length),r.push(o);continue}let a=e;if(this.options.extensions?.startBlock){let l=1/0;const c=e.slice(1);let _;this.options.extensions.startBlock.forEach(
|
|
41
|
+
`+o.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title});continue}if(o=this.tokenizer.table(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.lheading(e)){e=e.substring(o.raw.length),r.push(o);continue}let a=e;if(this.options.extensions?.startBlock){let l=1/0;const c=e.slice(1);let _;this.options.extensions.startBlock.forEach(m=>{_=m.call({lexer:this},c),typeof _=="number"&&_>=0&&(l=Math.min(l,_))}),l<1/0&&l>=0&&(a=e.substring(0,l+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){const l=r.at(-1);s&&l?.type==="paragraph"?(l.raw+=`
|
|
42
42
|
`+o.raw,l.text+=`
|
|
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
|
-
`+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(
|
|
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||_r}space(n){return""}code({text:n,lang:e,escaped:r}){const s=(e||"").match(mn.notSpaceStart)?.[0],o=n.replace(mn.endingNewline,"")+`
|
|
46
46
|
`;return s?'<pre><code class="language-'+Wn(s)+'">'+(r?o:Wn(o,!0))+`</code></pre>
|
|
47
47
|
`:"<pre><code>"+(r?o:Wn(o,!0))+`</code></pre>
|
|
48
48
|
`}blockquote({tokens:n}){return`<blockquote>
|
|
@@ -60,28 +60,28 @@ ${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>${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=Po(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=Po(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)}},vo=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""}},
|
|
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||_r}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?
|
|
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}}},gr=new ic;function ct(n,e){return gr.parse(n,e)}ct.options=ct.setOptions=function(n){return gr.setOptions(n),ct.defaults=gr.defaults,Ga(ct.defaults),ct};ct.getDefaults=io;ct.defaults=_r;ct.use=function(...n){return gr.use(...n),ct.defaults=gr.defaults,Ga(ct.defaults),ct};ct.walkTokens=function(n,e){return gr.walkTokens(n,e)};ct.parseInline=gr.parseInline;ct.Parser=
|
|
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 No(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)?No(n,e):void 0}}const ti=Object.entries,Fo=Object.setPrototypeOf,pc=Object.isFrozen,hc=Object.getPrototypeOf,bc=Object.getOwnPropertyDescriptor;let un=Object.freeze,fn=Object.seal,Sr=Object.create,ni=typeof Reflect<"u"&&Reflect,js=ni.apply,qs=ni.construct;un||(un=function(e){return e});fn||(fn=function(e){return e});js||(js=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)});qs||(qs=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=Jt(Array.prototype.forEach),vc=Jt(Array.prototype.lastIndexOf),Uo=Jt(Array.prototype.pop),wr=Jt(Array.prototype.push),mc=Jt(Array.prototype.splice),or=Array.isArray,Ur=Jt(String.prototype.toLowerCase),Es=Jt(String.prototype.toString),zo=Jt(String.prototype.match),Lr=Jt(String.prototype.replace),Bo=Jt(String.prototype.indexOf),gc=Jt(String.prototype.trim),xc=Jt(Number.prototype.toString),_c=Jt(Boolean.prototype.toString),Ho=typeof BigInt>"u"?null:Jt(BigInt.prototype.toString),Wo=typeof Symbol>"u"?null:Jt(Symbol.prototype.toString),on=Jt(Object.prototype.hasOwnProperty),Or=Jt(Object.prototype.toString),dn=Jt(RegExp.prototype.test),hr=yc(TypeError);function Jt(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 js(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 qs(n,r)}}function Ze(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ur;if(Fo&&Fo(n,null),!or(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++)on(n,e)||(n[e]=null);return n}function vn(n){const e=Sr(null);for(const s of ti(n)){var r=uc(s,2);const o=r[0],a=r[1];on(n,o)&&(or(a)?e[o]=wc(a):a&&typeof a=="object"&&a.constructor===Object?e[o]=vn(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 Ho?Ho(n):"0";case"symbol":return Wo?Wo(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 Jt(s.get);if(typeof s.value=="function")return Jt(s.value)}n=hc(n)}function r(){return null}return r}function Sc(n){try{return dn(n,""),!0}catch{return!1}}const Go=un(["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=un(["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=un(["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=un(["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=un(["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=un(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),jo=un(["#text"]),qo=un(["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=un(["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"]),Vo=un(["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=un(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ec=fn(/{{[\w\W]*|^[\w\W]*}}/g),Cc=fn(/<%[\w\W]*|^[\w\W]*%>/g),Ic=fn(/\${[\w\W]*/g),Rc=fn(/^data-[\-\w.\u00B7-\uFFFF]+$/),$c=fn(/^aria-[\-\w]+$/),Ko=fn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Mc=fn(/^(?:\w+script|data):/i),Dc=fn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pc=fn(/^html$/i),Lc=fn(/^[a-z][.\w]*(-[.\w]+)+$/i),Yo=fn(/<[/\w!]/g),Oc=fn(/<[/\w]/g),Nc=fn(/<\/no(script|embed|frames)/i),Fc=fn(/\/>/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}},Zo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},rr=function(e,r,s,o){return on(e,r)&&or(e[r])?Ze(o.base?vn(o.base):{},e[r],o.transform):s};function ri(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Uc();const e=I=>ri(I);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,g=n.NamedNodeMap;g===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const x=n.DOMParser,R=n.trustedTypes,O=c.prototype,N=Gn(O,"cloneNode"),S=Gn(O,"remove"),Y=Gn(O,"nextSibling"),ke=Gn(O,"childNodes"),J=Gn(O,"parentNode"),ue=Gn(O,"shadowRoot"),Le=Gn(O,"attributes"),_e=l&&l.prototype?Gn(l.prototype,"nodeType"):null,Ce=l&&l.prototype?Gn(l.prototype,"nodeName"):null;if(typeof a=="function"){const I=r.createElement("template");I.content&&I.content.ownerDocument&&(r=I.content.ownerDocument)}let fe,Me="",Ie,St=!1,ut=0;const Ge=function(){if(ut>0)throw hr('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.')},we=function(i){Ge(),ut++;try{return fe.createHTML(i)}finally{ut--}},Tt=function(i){Ge(),ut++;try{return fe.createScriptURL(i)}finally{ut--}},qe=function(){return St||(Ie=zc(R,o),St=!0),Ie},Xe=r,yt=Xe.implementation,rt=Xe.createNodeIterator,ft=Xe.createDocumentFragment,wt=Xe.getElementsByTagName,st=s.importNode;let te=Zo();e.isSupported=typeof ti=="function"&&typeof J=="function"&&yt&&yt.createHTMLDocument!==void 0;const xt=Ec,Ee=Cc,ot=Ic,At=Rc,vt=$c,Te=Mc,an=Dc,ee=Lc;let ce=Ko,A=null;const U=Ze({},[...Go,...Cs,...Is,...Rs,...jo]);let T=null;const oe=Ze({},[...qo,...$s,...Vo,...Jr]);let z=Object.seal(Sr(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}})),me=null,be=null;const ze=Object.seal(Sr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ue=!0,at=!0,pt=!1,Ne=!0,Oe=!1,jt=!0,Vt=!1,hn=!1,bn=null,Dt=null,Et=!1,Ke=!1,en=!1,Kt=!1,tn=!0,Tn=!1;const ie="user-content-";let it=!0,Ot=!1,kt={},mt=null;const nn=Ze({},["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 Yt=null;const yn=Ze({},["audio","video","img","source","image","track"]);let wn=null;const Cn=Ze({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),M="http://www.w3.org/1998/Math/MathML",q="http://www.w3.org/2000/svg",K="http://www.w3.org/1999/xhtml";let Z=K,xe=!1,qt=null;const Ct=Ze({},[M,q,K],Es),Ut=un(["mi","mo","mn","ms","mtext"]);let It=Ze({},Ut);const Nt=un(["annotation-xml"]);let Ft=Ze({},Nt);const zt=Ze({},["title","style","font","a","script"]);let ln=null;const $=["application/xhtml+xml","text/html"],L="text/html";let B=null,le=null;const De=r.createElement("form"),ve=function(i){return i instanceof RegExp||i instanceof Function},ae=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(le&&le===i)return;(!i||typeof i!="object")&&(i={}),i=vn(i),ln=$.indexOf(i.PARSER_MEDIA_TYPE)===-1?L:i.PARSER_MEDIA_TYPE,B=ln==="application/xhtml+xml"?Es:Ur,A=rr(i,"ALLOWED_TAGS",U,{transform:B}),T=rr(i,"ALLOWED_ATTR",oe,{transform:B}),qt=rr(i,"ALLOWED_NAMESPACES",Ct,{transform:Es}),wn=rr(i,"ADD_URI_SAFE_ATTR",Cn,{transform:B,base:Cn}),Yt=rr(i,"ADD_DATA_URI_TAGS",yn,{transform:B,base:yn}),mt=rr(i,"FORBID_CONTENTS",nn,{transform:B}),me=rr(i,"FORBID_TAGS",vn({}),{transform:B}),be=rr(i,"FORBID_ATTR",vn({}),{transform:B}),kt=on(i,"USE_PROFILES")?i.USE_PROFILES&&typeof i.USE_PROFILES=="object"?vn(i.USE_PROFILES):i.USE_PROFILES:!1,Ue=i.ALLOW_ARIA_ATTR!==!1,at=i.ALLOW_DATA_ATTR!==!1,pt=i.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=i.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Oe=i.SAFE_FOR_TEMPLATES||!1,jt=i.SAFE_FOR_XML!==!1,Vt=i.WHOLE_DOCUMENT||!1,Ke=i.RETURN_DOM||!1,en=i.RETURN_DOM_FRAGMENT||!1,Kt=i.RETURN_TRUSTED_TYPE||!1,Et=i.FORCE_BODY||!1,tn=i.SANITIZE_DOM!==!1,Tn=i.SANITIZE_NAMED_PROPS||!1,it=i.KEEP_CONTENT!==!1,Ot=i.IN_PLACE||!1,ce=Sc(i.ALLOWED_URI_REGEXP)?i.ALLOWED_URI_REGEXP:Ko,Z=typeof i.NAMESPACE=="string"?i.NAMESPACE:K,It=on(i,"MATHML_TEXT_INTEGRATION_POINTS")&&i.MATHML_TEXT_INTEGRATION_POINTS&&typeof i.MATHML_TEXT_INTEGRATION_POINTS=="object"?vn(i.MATHML_TEXT_INTEGRATION_POINTS):Ze({},Ut),Ft=on(i,"HTML_INTEGRATION_POINTS")&&i.HTML_INTEGRATION_POINTS&&typeof i.HTML_INTEGRATION_POINTS=="object"?vn(i.HTML_INTEGRATION_POINTS):Ze({},Nt);const b=on(i,"CUSTOM_ELEMENT_HANDLING")&&i.CUSTOM_ELEMENT_HANDLING&&typeof i.CUSTOM_ELEMENT_HANDLING=="object"?vn(i.CUSTOM_ELEMENT_HANDLING):Sr(null);if(z=Sr(null),on(b,"tagNameCheck")&&ve(b.tagNameCheck)&&(z.tagNameCheck=b.tagNameCheck),on(b,"attributeNameCheck")&&ve(b.attributeNameCheck)&&(z.attributeNameCheck=b.attributeNameCheck),on(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(z.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),fn(z),Oe&&(at=!1),en&&(Ke=!0),kt&&(A=Ze({},jo),T=Sr(null),kt.html===!0&&(Ze(A,Go),Ze(T,qo)),kt.svg===!0&&(Ze(A,Cs),Ze(T,$s),Ze(T,Jr)),kt.svgFilters===!0&&(Ze(A,Is),Ze(T,$s),Ze(T,Jr)),kt.mathMl===!0&&(Ze(A,Rs),Ze(T,Vo),Ze(T,Jr))),ze.tagCheck=null,ze.attributeCheck=null,on(i,"ADD_TAGS")&&(typeof i.ADD_TAGS=="function"?ze.tagCheck=i.ADD_TAGS:or(i.ADD_TAGS)&&(A===U&&(A=vn(A)),Ze(A,i.ADD_TAGS,B))),on(i,"ADD_ATTR")&&(typeof i.ADD_ATTR=="function"?ze.attributeCheck=i.ADD_ATTR:or(i.ADD_ATTR)&&(T===oe&&(T=vn(T)),Ze(T,i.ADD_ATTR,B))),on(i,"ADD_URI_SAFE_ATTR")&&or(i.ADD_URI_SAFE_ATTR)&&Ze(wn,i.ADD_URI_SAFE_ATTR,B),on(i,"FORBID_CONTENTS")&&or(i.FORBID_CONTENTS)&&(mt===nn&&(mt=vn(mt)),Ze(mt,i.FORBID_CONTENTS,B)),on(i,"ADD_FORBID_CONTENTS")&&or(i.ADD_FORBID_CONTENTS)&&(mt===nn&&(mt=vn(mt)),Ze(mt,i.ADD_FORBID_CONTENTS,B)),it&&(A["#text"]=!0),Vt&&Ze(A,["html","head","body"]),A.table&&(Ze(A,["tbody"]),delete me.tbody),i.TRUSTED_TYPES_POLICY){if(typeof i.TRUSTED_TYPES_POLICY.createHTML!="function")throw hr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof i.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw hr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const y=fe;fe=i.TRUSTED_TYPES_POLICY;try{Me=we("")}catch(C){throw fe=y,C}}else i.TRUSTED_TYPES_POLICY===null?(fe=void 0,Me=""):(fe===void 0&&(fe=qe()),fe&&typeof Me=="string"&&(Me=we("")));un&&un(i),le=i},Re=Ze({},[...Cs,...Is,...Tc]),Pe=Ze({},[...Rs,...Ac]),_t=function(i,b,y){return b.namespaceURI===K?i==="svg":b.namespaceURI===M?i==="svg"&&(y==="annotation-xml"||It[y]):!!Re[i]},Bt=function(i,b,y){return b.namespaceURI===K?i==="math":b.namespaceURI===q?i==="math"&&Ft[y]:!!Pe[i]},bt=function(i,b,y){return b.namespaceURI===q&&!Ft[y]||b.namespaceURI===M&&!It[y]?!1:!Pe[i]&&(zt[i]||!Re[i])},pe=function(i){let b=J(i);(!b||!b.tagName)&&(b={namespaceURI:Z,tagName:"template"});const y=Ur(i.tagName),C=Ur(b.tagName);return qt[i.namespaceURI]?i.namespaceURI===q?_t(y,b,C):i.namespaceURI===M?Bt(y,b,C):i.namespaceURI===K?bt(y,b,C):!!(ln==="application/xhtml+xml"&&qt[i.namespaceURI]):!1},se=function(i){wr(e.removed,{element:i});try{J(i).removeChild(i)}catch{if(S(i),!J(i))throw hr("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Se=function(i){const b=ke(i);if(b){const C=[];Pr(b,j=>{wr(C,j)}),Pr(C,j=>{try{S(j)}catch{}})}const y=Le(i);if(y)for(let C=y.length-1;C>=0;--C){const j=y[C],F=j&&j.name;if(typeof F=="string")try{i.removeAttribute(F)}catch{}}},v=function(i,b){try{wr(e.removed,{attribute:b.getAttributeNode(i),from:b})}catch{wr(e.removed,{attribute:null,from:b})}if(b.removeAttribute(i),i==="is")if(Ke||en)try{se(b)}catch{}else try{b.setAttribute(i,"")}catch{}},w=function(i){const b=Le(i);if(b)for(let y=b.length-1;y>=0;--y){const C=b[y],j=C&&C.name;if(!(typeof j!="string"||T[B(j)]))try{i.removeAttribute(j)}catch{}}},D=function(i){const b=[i];for(;b.length>0;){const y=b.pop();(_e?_e(y):y.nodeType)===Hn.element&&w(y);const j=ke(y);if(j)for(let F=j.length-1;F>=0;--F)b.push(j[F])}},P=function(i){let b=null,y=null;if(Et)i="<remove></remove>"+i;else{const F=zo(i,/^[\r\n\t ]+/);y=F&&F[0]}ln==="application/xhtml+xml"&&Z===K&&(i='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+i+"</body></html>");const C=fe?we(i):i;if(Z===K)try{b=new x().parseFromString(C,ln)}catch{}if(!b||!b.documentElement){b=yt.createDocument(Z,"template",null);try{b.documentElement.innerHTML=xe?Me:C}catch{}}const j=b.body||b.documentElement;return i&&y&&j.insertBefore(r.createTextNode(y),j.childNodes[0]||null),Z===K?wt.call(b,Vt?"html":"body")[0]:Vt?b.documentElement:j},re=function(i){return rt.call(i.ownerDocument||i,i,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},X=function(i){return i=Lr(i,xt," "),i=Lr(i,Ee," "),i=Lr(i,ot," "),i},k=function(i){var b;i.normalize();const y=rt.call(i.ownerDocument||i,i,_.SHOW_TEXT|_.SHOW_COMMENT|_.SHOW_CDATA_SECTION|_.SHOW_PROCESSING_INSTRUCTION,null);let C=y.nextNode();for(;C;)C.data=X(C.data),C=y.nextNode();const j=(b=i.querySelectorAll)===null||b===void 0?void 0:b.call(i,"template");j&&Pr(j,F=>{ye(F.content)&&k(F.content)})},de=function(i){const b=Ce?Ce(i):null;return typeof b!="string"||B(b)!=="form"?!1:typeof i.nodeName!="string"||typeof i.textContent!="string"||typeof i.removeChild!="function"||i.attributes!==Le(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!==ke(i)},ye=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 et(I,i,b){I.length!==0&&Pr(I,y=>{y.call(e,i,b,le)})}const he=function(i,b){return!!(jt&&i.hasChildNodes()&&!Be(i.firstElementChild)&&dn(Yo,i.textContent)&&dn(Yo,i.innerHTML)||jt&&i.namespaceURI===K&&b==="style"&&Be(i.firstElementChild)||i.nodeType===Hn.processingInstruction||jt&&i.nodeType===Hn.comment&&dn(Oc,i.data))},He=function(i,b){if(!me[b]&&We(b)&&(z.tagNameCheck instanceof RegExp&&dn(z.tagNameCheck,b)||z.tagNameCheck instanceof Function&&z.tagNameCheck(b)))return!1;if(it&&!mt[b]){const y=J(i),C=ke(i);if(C&&y){const j=C.length;for(let F=j-1;F>=0;--F){const ne=Ot?C[F]:N(C[F],!0);y.insertBefore(ne,Y(i))}}}return se(i),!0},Zt=function(i){if(et(te.beforeSanitizeElements,i,null),de(i))return se(i),!0;const b=B(Ce?Ce(i):i.nodeName);if(et(te.uponSanitizeElement,i,{tagName:b,allowedTags:A}),he(i,b))return se(i),!0;if(me[b]||!(ze.tagCheck instanceof Function&&ze.tagCheck(b))&&!A[b])return He(i,b);if((_e?_e(i):i.nodeType)===Hn.element&&!pe(i)||(b==="noscript"||b==="noembed"||b==="noframes")&&dn(Nc,i.innerHTML))return se(i),!0;if(Oe&&i.nodeType===Hn.text){const C=X(i.textContent);i.textContent!==C&&(wr(e.removed,{element:i.cloneNode()}),i.textContent=C)}return et(te.afterSanitizeElements,i,null),!1},Xt=function(i,b,y){if(be[b]||tn&&(b==="id"||b==="name")&&(y in r||y in De))return!1;const C=T[b]||ze.attributeCheck instanceof Function&&ze.attributeCheck(b,i);if(!(at&&dn(At,b))){if(!(Ue&&dn(vt,b))){if(C){if(!wn[b]){if(!dn(ce,Lr(y,an,""))){if(!((b==="src"||b==="xlink:href"||b==="href")&&i!=="script"&&Bo(y,"data:")===0&&Yt[i])){if(!(pt&&!dn(Te,Lr(y,an,"")))){if(y)return!1}}}}}else if(!(We(i)&&(z.tagNameCheck instanceof RegExp&&dn(z.tagNameCheck,i)||z.tagNameCheck instanceof Function&&z.tagNameCheck(i))&&(z.attributeNameCheck instanceof RegExp&&dn(z.attributeNameCheck,b)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(b,i))||b==="is"&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&dn(z.tagNameCheck,y)||z.tagNameCheck instanceof Function&&z.tagNameCheck(y))))return!1}}return!0},Ht=Ze({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),We=function(i){return!Ht[Ur(i)]&&dn(ee,i)},Ye=function(i,b,y,C){if(fe&&typeof R=="object"&&typeof R.getAttributeType=="function"&&!y)switch(R.getAttributeType(i,b)){case"TrustedHTML":return we(C);case"TrustedScriptURL":return Tt(C)}return C},Ve=function(i,b,y,C){try{y?i.setAttributeNS(y,b,C):i.setAttribute(b,C),de(i)?se(i):Uo(e.removed)}catch{v(b,i)}},gt=function(i){et(te.beforeSanitizeAttributes,i,null);const b=i.attributes;if(!b||de(i))return;const y={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:T,forceKeepAttr:void 0};let C=b.length;const j=B(i.nodeName);for(;C--;){const F=b[C],ne=F.name,Ae=F.namespaceURI,Qe=F.value,tt=B(ne),Mt=Qe;let je=ne==="value"?Mt:gc(Mt);if(y.attrName=tt,y.attrValue=je,y.keepAttr=!0,y.forceKeepAttr=void 0,et(te.uponSanitizeAttribute,i,y),je=y.attrValue,Tn&&(tt==="id"||tt==="name")&&Bo(je,ie)!==0&&(v(ne,i),je=ie+je),jt&&dn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,je)){v(ne,i);continue}if(tt==="attributename"&&zo(je,"href")){v(ne,i);continue}if(!y.forceKeepAttr){if(!y.keepAttr){v(ne,i);continue}if(!Ne&&dn(Fc,je)){v(ne,i);continue}if(Oe&&(je=X(je)),!Xt(j,tt,je)){v(ne,i);continue}je=Ye(j,tt,Ae,je),je!==Mt&&Ve(i,ne,Ae,je)}}et(te.afterSanitizeAttributes,i,null)},Rt=function(i){let b=null;const y=re(i);for(et(te.beforeSanitizeShadowDOM,i,null);b=y.nextNode();)if(et(te.uponSanitizeShadowNode,b,null),Zt(b),gt(b),ye(b.content)&&Rt(b.content),(_e?_e(b):b.nodeType)===Hn.element){const j=ue(b);ye(j)&&($t(j),Rt(j))}et(te.afterSanitizeShadowDOM,i,null)},$t=function(i){const b=[{node:i,shadow:null}];for(;b.length>0;){const y=b.pop();if(y.shadow){Rt(y.shadow);continue}const C=y.node,F=(_e?_e(C):C.nodeType)===Hn.element,ne=ke(C);if(ne)for(let Ae=ne.length-1;Ae>=0;--Ae)b.push({node:ne[Ae],shadow:null});if(F){const Ae=Ce?Ce(C):null;if(typeof Ae=="string"&&B(Ae)==="template"){const Qe=C.content;ye(Qe)&&b.push({node:Qe,shadow:null})}}if(F){const Ae=ue(C);ye(Ae)&&b.push({node:null,shadow:Ae},{node:Ae,shadow:null})}}};return e.sanitize=function(I){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,y=null,C=null,j=null;if(xe=!I,xe&&(I="<!-->"),typeof I!="string"&&!Be(I)&&(I=kc(I),typeof I!="string"))throw hr("dirty is not a string, aborting");if(!e.isSupported)return I;hn?(A=bn,T=Dt):ae(i),(te.uponSanitizeElement.length>0||te.uponSanitizeAttribute.length>0)&&(A=vn(A)),te.uponSanitizeAttribute.length>0&&(T=vn(T)),e.removed=[];const F=Ot&&typeof I!="string"&&Be(I);if(F){const Qe=Ce?Ce(I):I.nodeName;if(typeof Qe=="string"){const tt=B(Qe);if(!A[tt]||me[tt])throw hr("root node is forbidden and cannot be sanitized in-place")}if(de(I))throw hr("root node is clobbered and cannot be sanitized in-place");try{$t(I)}catch(tt){throw Se(I),tt}}else if(Be(I))b=P("<!---->"),y=b.ownerDocument.importNode(I,!0),y.nodeType===Hn.element&&y.nodeName==="BODY"||y.nodeName==="HTML"?b=y:b.appendChild(y),$t(y);else{if(!Ke&&!Oe&&!Vt&&I.indexOf("<")===-1)return fe&&Kt?we(I):I;if(b=P(I),!b)return Ke?null:Kt?Me:""}b&&Et&&se(b.firstChild);const ne=re(F?I:b);try{for(;C=ne.nextNode();)Zt(C),gt(C),ye(C.content)&&Rt(C.content)}catch(Qe){throw F&&Se(I),Qe}if(F)return Pr(e.removed,Qe=>{Qe.element&&D(Qe.element)}),Oe&&k(I),I;if(Ke){if(Oe&&k(b),en)for(j=ft.call(b.ownerDocument);b.firstChild;)j.appendChild(b.firstChild);else j=b;return(T.shadowroot||T.shadowrootmode)&&(j=st.call(s,j,!0)),j}let Ae=Vt?b.outerHTML:b.innerHTML;return Vt&&A["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&dn(Pc,b.ownerDocument.doctype.name)&&(Ae="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
67
|
-
`+Ae),Oe&&(Ae=X(Ae)),fe&&Kt?we(Ae):Ae},e.setConfig=function(){let
|
|
68
|
-
`).filter(
|
|
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=
|
|
70
|
-
sidebar to open an existing session.</p></div> <form class="space-y-4"><div><label class="mb-1 block text-xs font-bold tracking-wider text-brand-text-muted uppercase" for="main-folder-path">Folder Path</label> <div class="relative"><input id="main-folder-path" type="text" autocomplete="off" spellcheck="false" placeholder="e.g. ~/projects/my-new-app"/> <!></div> <!></div> <div><label class="mb-1 block text-xs font-bold tracking-wider text-brand-text-muted uppercase" for="main-model-select">Model</label> <!></div> <!> <!> <button type="submit" class="w-full rounded bg-gradient-to-r from-brand-cyan to-brand-blue py-2.5 text-sm font-semibold text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50"> </button></form></div></div>`),id=
|
|
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=Po(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=Po(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)}},vo=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""}},Qn=class Gs{options;renderer;textRenderer;constructor(e){this.options=e||_r,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 vo}static parse(e,r){return new Gs(r).parse(e)}static parseInline(e,r){return new Gs(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
|
+
`+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||_r}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Jn.lex:Jn.lexInline}provideParser(){return this.block?Qn.parse:Qn.parseInline}},ic=class{defaults=io();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Qn;Renderer=is;TextRenderer=vo;Lexer=Jn;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 Jn.lex(n,e??this.defaults)}parser(n,e){return Qn.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?Jn.lex:Jn.lexInline,_=a.hooks?a.hooks.provideParser():n?Qn.parse:Qn.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>"+Wn(r.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(r);throw r}}},gr=new ic;function ct(n,e){return gr.parse(n,e)}ct.options=ct.setOptions=function(n){return gr.setOptions(n),ct.defaults=gr.defaults,Ga(ct.defaults),ct};ct.getDefaults=io;ct.defaults=_r;ct.use=function(...n){return gr.use(...n),ct.defaults=gr.defaults,Ga(ct.defaults),ct};ct.walkTokens=function(n,e){return gr.walkTokens(n,e)};ct.parseInline=gr.parseInline;ct.Parser=Qn;ct.parser=Qn.parse;ct.Renderer=is;ct.TextRenderer=vo;ct.Lexer=Jn;ct.lexer=Jn.lex;ct.Tokenizer=as;ct.Hooks=ns;ct.parse=ct;ct.options;ct.setOptions;ct.use;ct.walkTokens;ct.parseInline;Qn.parse;Jn.lex;function No(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 No(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)?No(n,e):void 0}}const ti=Object.entries,Fo=Object.setPrototypeOf,pc=Object.isFrozen,hc=Object.getPrototypeOf,bc=Object.getOwnPropertyDescriptor;let un=Object.freeze,fn=Object.seal,Sr=Object.create,ni=typeof Reflect<"u"&&Reflect,js=ni.apply,qs=ni.construct;un||(un=function(e){return e});fn||(fn=function(e){return e});js||(js=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)});qs||(qs=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=Qt(Array.prototype.forEach),vc=Qt(Array.prototype.lastIndexOf),Uo=Qt(Array.prototype.pop),wr=Qt(Array.prototype.push),mc=Qt(Array.prototype.splice),or=Array.isArray,Ur=Qt(String.prototype.toLowerCase),Es=Qt(String.prototype.toString),zo=Qt(String.prototype.match),Lr=Qt(String.prototype.replace),Bo=Qt(String.prototype.indexOf),gc=Qt(String.prototype.trim),xc=Qt(Number.prototype.toString),_c=Qt(Boolean.prototype.toString),Ho=typeof BigInt>"u"?null:Qt(BigInt.prototype.toString),Wo=typeof Symbol>"u"?null:Qt(Symbol.prototype.toString),on=Qt(Object.prototype.hasOwnProperty),Or=Qt(Object.prototype.toString),dn=Qt(RegExp.prototype.test),hr=yc(TypeError);function Qt(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 js(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 qs(n,r)}}function Ze(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ur;if(Fo&&Fo(n,null),!or(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++)on(n,e)||(n[e]=null);return n}function vn(n){const e=Sr(null);for(const s of ti(n)){var r=uc(s,2);const o=r[0],a=r[1];on(n,o)&&(or(a)?e[o]=wc(a):a&&typeof a=="object"&&a.constructor===Object?e[o]=vn(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 Ho?Ho(n):"0";case"symbol":return Wo?Wo(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 Qt(s.get);if(typeof s.value=="function")return Qt(s.value)}n=hc(n)}function r(){return null}return r}function Sc(n){try{return dn(n,""),!0}catch{return!1}}const Go=un(["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=un(["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=un(["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=un(["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=un(["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=un(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),jo=un(["#text"]),qo=un(["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=un(["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"]),Vo=un(["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"]),Qr=un(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ec=fn(/{{[\w\W]*|^[\w\W]*}}/g),Cc=fn(/<%[\w\W]*|^[\w\W]*%>/g),Ic=fn(/\${[\w\W]*/g),Rc=fn(/^data-[\-\w.\u00B7-\uFFFF]+$/),$c=fn(/^aria-[\-\w]+$/),Ko=fn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Mc=fn(/^(?:\w+script|data):/i),Dc=fn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pc=fn(/^html$/i),Lc=fn(/^[a-z][.\w]*(-[.\w]+)+$/i),Yo=fn(/<[/\w!]/g),Oc=fn(/<[/\w]/g),Nc=fn(/<\/no(script|embed|frames)/i),Fc=fn(/\/>/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}},Zo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},rr=function(e,r,s,o){return on(e,r)&&or(e[r])?Ze(o.base?vn(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,N=Gn(P,"cloneNode"),S=Gn(P,"remove"),Y=Gn(P,"nextSibling"),ke=Gn(P,"childNodes"),Q=Gn(P,"parentNode"),ue=Gn(P,"shadowRoot"),Le=Gn(P,"attributes"),_e=l&&l.prototype?Gn(l.prototype,"nodeType"):null,Ce=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,Me="",Ie,St=!1,ut=0;const Ge=function(){if(ut>0)throw hr('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.')},we=function(i){Ge(),ut++;try{return fe.createHTML(i)}finally{ut--}},Tt=function(i){Ge(),ut++;try{return fe.createScriptURL(i)}finally{ut--}},qe=function(){return St||(Ie=zc(I,o),St=!0),Ie},Xe=r,yt=Xe.implementation,rt=Xe.createNodeIterator,ft=Xe.createDocumentFragment,wt=Xe.getElementsByTagName,st=s.importNode;let te=Zo();e.isSupported=typeof ti=="function"&&typeof Q=="function"&&yt&&yt.createHTMLDocument!==void 0;const xt=Ec,Ee=Cc,ot=Ic,At=Rc,vt=$c,Te=Mc,an=Dc,ee=Lc;let ce=Ko,A=null;const U=Ze({},[...Go,...Cs,...Is,...Rs,...jo]);let T=null;const oe=Ze({},[...qo,...$s,...Vo,...Qr]);let z=Object.seal(Sr(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}})),me=null,be=null;const ze=Object.seal(Sr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ue=!0,at=!0,pt=!1,Ne=!0,Oe=!1,jt=!0,Vt=!1,hn=!1,bn=null,Dt=null,Et=!1,Ke=!1,en=!1,Kt=!1,tn=!0,Tn=!1;const ie="user-content-";let it=!0,Ot=!1,kt={},mt=null;const nn=Ze({},["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 Yt=null;const yn=Ze({},["audio","video","img","source","image","track"]);let wn=null;const Cn=Ze({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),M="http://www.w3.org/1998/Math/MathML",q="http://www.w3.org/2000/svg",K="http://www.w3.org/1999/xhtml";let Z=K,xe=!1,qt=null;const Ct=Ze({},[M,q,K],Es),Ut=un(["mi","mo","mn","ms","mtext"]);let It=Ze({},Ut);const Nt=un(["annotation-xml"]);let Ft=Ze({},Nt);const zt=Ze({},["title","style","font","a","script"]);let ln=null;const $=["application/xhtml+xml","text/html"],O="text/html";let B=null,le=null;const De=r.createElement("form"),ve=function(i){return i instanceof RegExp||i instanceof Function},ae=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(le&&le===i)return;(!i||typeof i!="object")&&(i={}),i=vn(i),ln=$.indexOf(i.PARSER_MEDIA_TYPE)===-1?O:i.PARSER_MEDIA_TYPE,B=ln==="application/xhtml+xml"?Es:Ur,A=rr(i,"ALLOWED_TAGS",U,{transform:B}),T=rr(i,"ALLOWED_ATTR",oe,{transform:B}),qt=rr(i,"ALLOWED_NAMESPACES",Ct,{transform:Es}),wn=rr(i,"ADD_URI_SAFE_ATTR",Cn,{transform:B,base:Cn}),Yt=rr(i,"ADD_DATA_URI_TAGS",yn,{transform:B,base:yn}),mt=rr(i,"FORBID_CONTENTS",nn,{transform:B}),me=rr(i,"FORBID_TAGS",vn({}),{transform:B}),be=rr(i,"FORBID_ATTR",vn({}),{transform:B}),kt=on(i,"USE_PROFILES")?i.USE_PROFILES&&typeof i.USE_PROFILES=="object"?vn(i.USE_PROFILES):i.USE_PROFILES:!1,Ue=i.ALLOW_ARIA_ATTR!==!1,at=i.ALLOW_DATA_ATTR!==!1,pt=i.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=i.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Oe=i.SAFE_FOR_TEMPLATES||!1,jt=i.SAFE_FOR_XML!==!1,Vt=i.WHOLE_DOCUMENT||!1,Ke=i.RETURN_DOM||!1,en=i.RETURN_DOM_FRAGMENT||!1,Kt=i.RETURN_TRUSTED_TYPE||!1,Et=i.FORCE_BODY||!1,tn=i.SANITIZE_DOM!==!1,Tn=i.SANITIZE_NAMED_PROPS||!1,it=i.KEEP_CONTENT!==!1,Ot=i.IN_PLACE||!1,ce=Sc(i.ALLOWED_URI_REGEXP)?i.ALLOWED_URI_REGEXP:Ko,Z=typeof i.NAMESPACE=="string"?i.NAMESPACE:K,It=on(i,"MATHML_TEXT_INTEGRATION_POINTS")&&i.MATHML_TEXT_INTEGRATION_POINTS&&typeof i.MATHML_TEXT_INTEGRATION_POINTS=="object"?vn(i.MATHML_TEXT_INTEGRATION_POINTS):Ze({},Ut),Ft=on(i,"HTML_INTEGRATION_POINTS")&&i.HTML_INTEGRATION_POINTS&&typeof i.HTML_INTEGRATION_POINTS=="object"?vn(i.HTML_INTEGRATION_POINTS):Ze({},Nt);const b=on(i,"CUSTOM_ELEMENT_HANDLING")&&i.CUSTOM_ELEMENT_HANDLING&&typeof i.CUSTOM_ELEMENT_HANDLING=="object"?vn(i.CUSTOM_ELEMENT_HANDLING):Sr(null);if(z=Sr(null),on(b,"tagNameCheck")&&ve(b.tagNameCheck)&&(z.tagNameCheck=b.tagNameCheck),on(b,"attributeNameCheck")&&ve(b.attributeNameCheck)&&(z.attributeNameCheck=b.attributeNameCheck),on(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(z.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),fn(z),Oe&&(at=!1),en&&(Ke=!0),kt&&(A=Ze({},jo),T=Sr(null),kt.html===!0&&(Ze(A,Go),Ze(T,qo)),kt.svg===!0&&(Ze(A,Cs),Ze(T,$s),Ze(T,Qr)),kt.svgFilters===!0&&(Ze(A,Is),Ze(T,$s),Ze(T,Qr)),kt.mathMl===!0&&(Ze(A,Rs),Ze(T,Vo),Ze(T,Qr))),ze.tagCheck=null,ze.attributeCheck=null,on(i,"ADD_TAGS")&&(typeof i.ADD_TAGS=="function"?ze.tagCheck=i.ADD_TAGS:or(i.ADD_TAGS)&&(A===U&&(A=vn(A)),Ze(A,i.ADD_TAGS,B))),on(i,"ADD_ATTR")&&(typeof i.ADD_ATTR=="function"?ze.attributeCheck=i.ADD_ATTR:or(i.ADD_ATTR)&&(T===oe&&(T=vn(T)),Ze(T,i.ADD_ATTR,B))),on(i,"ADD_URI_SAFE_ATTR")&&or(i.ADD_URI_SAFE_ATTR)&&Ze(wn,i.ADD_URI_SAFE_ATTR,B),on(i,"FORBID_CONTENTS")&&or(i.FORBID_CONTENTS)&&(mt===nn&&(mt=vn(mt)),Ze(mt,i.FORBID_CONTENTS,B)),on(i,"ADD_FORBID_CONTENTS")&&or(i.ADD_FORBID_CONTENTS)&&(mt===nn&&(mt=vn(mt)),Ze(mt,i.ADD_FORBID_CONTENTS,B)),it&&(A["#text"]=!0),Vt&&Ze(A,["html","head","body"]),A.table&&(Ze(A,["tbody"]),delete me.tbody),i.TRUSTED_TYPES_POLICY){if(typeof i.TRUSTED_TYPES_POLICY.createHTML!="function")throw hr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof i.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw hr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const y=fe;fe=i.TRUSTED_TYPES_POLICY;try{Me=we("")}catch(C){throw fe=y,C}}else i.TRUSTED_TYPES_POLICY===null?(fe=void 0,Me=""):(fe===void 0&&(fe=qe()),fe&&typeof Me=="string"&&(Me=we("")));un&&un(i),le=i},Re=Ze({},[...Cs,...Is,...Tc]),Pe=Ze({},[...Rs,...Ac]),_t=function(i,b,y){return b.namespaceURI===K?i==="svg":b.namespaceURI===M?i==="svg"&&(y==="annotation-xml"||It[y]):!!Re[i]},Bt=function(i,b,y){return b.namespaceURI===K?i==="math":b.namespaceURI===q?i==="math"&&Ft[y]:!!Pe[i]},bt=function(i,b,y){return b.namespaceURI===q&&!Ft[y]||b.namespaceURI===M&&!It[y]?!1:!Pe[i]&&(zt[i]||!Re[i])},pe=function(i){let b=Q(i);(!b||!b.tagName)&&(b={namespaceURI:Z,tagName:"template"});const y=Ur(i.tagName),C=Ur(b.tagName);return qt[i.namespaceURI]?i.namespaceURI===q?_t(y,b,C):i.namespaceURI===M?Bt(y,b,C):i.namespaceURI===K?bt(y,b,C):!!(ln==="application/xhtml+xml"&&qt[i.namespaceURI]):!1},se=function(i){wr(e.removed,{element:i});try{Q(i).removeChild(i)}catch{if(S(i),!Q(i))throw hr("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Se=function(i){const b=ke(i);if(b){const C=[];Pr(b,j=>{wr(C,j)}),Pr(C,j=>{try{S(j)}catch{}})}const y=Le(i);if(y)for(let C=y.length-1;C>=0;--C){const j=y[C],F=j&&j.name;if(typeof F=="string")try{i.removeAttribute(F)}catch{}}},v=function(i,b){try{wr(e.removed,{attribute:b.getAttributeNode(i),from:b})}catch{wr(e.removed,{attribute:null,from:b})}if(b.removeAttribute(i),i==="is")if(Ke||en)try{se(b)}catch{}else try{b.setAttribute(i,"")}catch{}},w=function(i){const b=Le(i);if(b)for(let y=b.length-1;y>=0;--y){const C=b[y],j=C&&C.name;if(!(typeof j!="string"||T[B(j)]))try{i.removeAttribute(j)}catch{}}},D=function(i){const b=[i];for(;b.length>0;){const y=b.pop();(_e?_e(y):y.nodeType)===Hn.element&&w(y);const j=ke(y);if(j)for(let F=j.length-1;F>=0;--F)b.push(j[F])}},L=function(i){let b=null,y=null;if(Et)i="<remove></remove>"+i;else{const F=zo(i,/^[\r\n\t ]+/);y=F&&F[0]}ln==="application/xhtml+xml"&&Z===K&&(i='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+i+"</body></html>");const C=fe?we(i):i;if(Z===K)try{b=new x().parseFromString(C,ln)}catch{}if(!b||!b.documentElement){b=yt.createDocument(Z,"template",null);try{b.documentElement.innerHTML=xe?Me:C}catch{}}const j=b.body||b.documentElement;return i&&y&&j.insertBefore(r.createTextNode(y),j.childNodes[0]||null),Z===K?wt.call(b,Vt?"html":"body")[0]:Vt?b.documentElement:j},re=function(i){return rt.call(i.ownerDocument||i,i,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},X=function(i){return i=Lr(i,xt," "),i=Lr(i,Ee," "),i=Lr(i,ot," "),i},k=function(i){var b;i.normalize();const y=rt.call(i.ownerDocument||i,i,_.SHOW_TEXT|_.SHOW_COMMENT|_.SHOW_CDATA_SECTION|_.SHOW_PROCESSING_INSTRUCTION,null);let C=y.nextNode();for(;C;)C.data=X(C.data),C=y.nextNode();const j=(b=i.querySelectorAll)===null||b===void 0?void 0:b.call(i,"template");j&&Pr(j,F=>{ye(F.content)&&k(F.content)})},de=function(i){const b=Ce?Ce(i):null;return typeof b!="string"||B(b)!=="form"?!1:typeof i.nodeName!="string"||typeof i.textContent!="string"||typeof i.removeChild!="function"||i.attributes!==Le(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!==ke(i)},ye=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 et(R,i,b){R.length!==0&&Pr(R,y=>{y.call(e,i,b,le)})}const he=function(i,b){return!!(jt&&i.hasChildNodes()&&!Be(i.firstElementChild)&&dn(Yo,i.textContent)&&dn(Yo,i.innerHTML)||jt&&i.namespaceURI===K&&b==="style"&&Be(i.firstElementChild)||i.nodeType===Hn.processingInstruction||jt&&i.nodeType===Hn.comment&&dn(Oc,i.data))},He=function(i,b){if(!me[b]&&We(b)&&(z.tagNameCheck instanceof RegExp&&dn(z.tagNameCheck,b)||z.tagNameCheck instanceof Function&&z.tagNameCheck(b)))return!1;if(it&&!mt[b]){const y=Q(i),C=ke(i);if(C&&y){const j=C.length;for(let F=j-1;F>=0;--F){const ne=Ot?C[F]:N(C[F],!0);y.insertBefore(ne,Y(i))}}}return se(i),!0},Zt=function(i){if(et(te.beforeSanitizeElements,i,null),de(i))return se(i),!0;const b=B(Ce?Ce(i):i.nodeName);if(et(te.uponSanitizeElement,i,{tagName:b,allowedTags:A}),he(i,b))return se(i),!0;if(me[b]||!(ze.tagCheck instanceof Function&&ze.tagCheck(b))&&!A[b])return He(i,b);if((_e?_e(i):i.nodeType)===Hn.element&&!pe(i)||(b==="noscript"||b==="noembed"||b==="noframes")&&dn(Nc,i.innerHTML))return se(i),!0;if(Oe&&i.nodeType===Hn.text){const C=X(i.textContent);i.textContent!==C&&(wr(e.removed,{element:i.cloneNode()}),i.textContent=C)}return et(te.afterSanitizeElements,i,null),!1},Xt=function(i,b,y){if(be[b]||tn&&(b==="id"||b==="name")&&(y in r||y in De))return!1;const C=T[b]||ze.attributeCheck instanceof Function&&ze.attributeCheck(b,i);if(!(at&&dn(At,b))){if(!(Ue&&dn(vt,b))){if(C){if(!wn[b]){if(!dn(ce,Lr(y,an,""))){if(!((b==="src"||b==="xlink:href"||b==="href")&&i!=="script"&&Bo(y,"data:")===0&&Yt[i])){if(!(pt&&!dn(Te,Lr(y,an,"")))){if(y)return!1}}}}}else if(!(We(i)&&(z.tagNameCheck instanceof RegExp&&dn(z.tagNameCheck,i)||z.tagNameCheck instanceof Function&&z.tagNameCheck(i))&&(z.attributeNameCheck instanceof RegExp&&dn(z.attributeNameCheck,b)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(b,i))||b==="is"&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&dn(z.tagNameCheck,y)||z.tagNameCheck instanceof Function&&z.tagNameCheck(y))))return!1}}return!0},Ht=Ze({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),We=function(i){return!Ht[Ur(i)]&&dn(ee,i)},Ye=function(i,b,y,C){if(fe&&typeof I=="object"&&typeof I.getAttributeType=="function"&&!y)switch(I.getAttributeType(i,b)){case"TrustedHTML":return we(C);case"TrustedScriptURL":return Tt(C)}return C},Ve=function(i,b,y,C){try{y?i.setAttributeNS(y,b,C):i.setAttribute(b,C),de(i)?se(i):Uo(e.removed)}catch{v(b,i)}},gt=function(i){et(te.beforeSanitizeAttributes,i,null);const b=i.attributes;if(!b||de(i))return;const y={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:T,forceKeepAttr:void 0};let C=b.length;const j=B(i.nodeName);for(;C--;){const F=b[C],ne=F.name,Ae=F.namespaceURI,Je=F.value,tt=B(ne),Mt=Je;let je=ne==="value"?Mt:gc(Mt);if(y.attrName=tt,y.attrValue=je,y.keepAttr=!0,y.forceKeepAttr=void 0,et(te.uponSanitizeAttribute,i,y),je=y.attrValue,Tn&&(tt==="id"||tt==="name")&&Bo(je,ie)!==0&&(v(ne,i),je=ie+je),jt&&dn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,je)){v(ne,i);continue}if(tt==="attributename"&&zo(je,"href")){v(ne,i);continue}if(!y.forceKeepAttr){if(!y.keepAttr){v(ne,i);continue}if(!Ne&&dn(Fc,je)){v(ne,i);continue}if(Oe&&(je=X(je)),!Xt(j,tt,je)){v(ne,i);continue}je=Ye(j,tt,Ae,je),je!==Mt&&Ve(i,ne,Ae,je)}}et(te.afterSanitizeAttributes,i,null)},Rt=function(i){let b=null;const y=re(i);for(et(te.beforeSanitizeShadowDOM,i,null);b=y.nextNode();)if(et(te.uponSanitizeShadowNode,b,null),Zt(b),gt(b),ye(b.content)&&Rt(b.content),(_e?_e(b):b.nodeType)===Hn.element){const j=ue(b);ye(j)&&($t(j),Rt(j))}et(te.afterSanitizeShadowDOM,i,null)},$t=function(i){const b=[{node:i,shadow:null}];for(;b.length>0;){const y=b.pop();if(y.shadow){Rt(y.shadow);continue}const C=y.node,F=(_e?_e(C):C.nodeType)===Hn.element,ne=ke(C);if(ne)for(let Ae=ne.length-1;Ae>=0;--Ae)b.push({node:ne[Ae],shadow:null});if(F){const Ae=Ce?Ce(C):null;if(typeof Ae=="string"&&B(Ae)==="template"){const Je=C.content;ye(Je)&&b.push({node:Je,shadow:null})}}if(F){const Ae=ue(C);ye(Ae)&&b.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]:{},b=null,y=null,C=null,j=null;if(xe=!R,xe&&(R="<!-->"),typeof R!="string"&&!Be(R)&&(R=kc(R),typeof R!="string"))throw hr("dirty is not a string, aborting");if(!e.isSupported)return R;hn?(A=bn,T=Dt):ae(i),(te.uponSanitizeElement.length>0||te.uponSanitizeAttribute.length>0)&&(A=vn(A)),te.uponSanitizeAttribute.length>0&&(T=vn(T)),e.removed=[];const F=Ot&&typeof R!="string"&&Be(R);if(F){const Je=Ce?Ce(R):R.nodeName;if(typeof Je=="string"){const tt=B(Je);if(!A[tt]||me[tt])throw hr("root node is forbidden and cannot be sanitized in-place")}if(de(R))throw hr("root node is clobbered and cannot be sanitized in-place");try{$t(R)}catch(tt){throw Se(R),tt}}else if(Be(R))b=L("<!---->"),y=b.ownerDocument.importNode(R,!0),y.nodeType===Hn.element&&y.nodeName==="BODY"||y.nodeName==="HTML"?b=y:b.appendChild(y),$t(y);else{if(!Ke&&!Oe&&!Vt&&R.indexOf("<")===-1)return fe&&Kt?we(R):R;if(b=L(R),!b)return Ke?null:Kt?Me:""}b&&Et&&se(b.firstChild);const ne=re(F?R:b);try{for(;C=ne.nextNode();)Zt(C),gt(C),ye(C.content)&&Rt(C.content)}catch(Je){throw F&&Se(R),Je}if(F)return Pr(e.removed,Je=>{Je.element&&D(Je.element)}),Oe&&k(R),R;if(Ke){if(Oe&&k(b),en)for(j=ft.call(b.ownerDocument);b.firstChild;)j.appendChild(b.firstChild);else j=b;return(T.shadowroot||T.shadowrootmode)&&(j=st.call(s,j,!0)),j}let Ae=Vt?b.outerHTML:b.innerHTML;return Vt&&A["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&dn(Pc,b.ownerDocument.doctype.name)&&(Ae="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
67
|
+
`+Ae),Oe&&(Ae=X(Ae)),fe&&Kt?we(Ae):Ae},e.setConfig=function(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ae(R),hn=!0,bn=A,Dt=T},e.clearConfig=function(){le=null,hn=!1,bn=null,Dt=null,fe=Ie,Me=""},e.isValidAttribute=function(R,i,b){le||ae({});const y=B(R),C=B(i);return Xt(y,C,b)},e.addHook=function(R,i){typeof i=="function"&&on(te,R)&&wr(te[R],i)},e.removeHook=function(R,i){if(on(te,R)){if(i!==void 0){const b=vc(te[R],i);return b===-1?void 0:mc(te[R],b,1)[0]}return Uo(te[R])}},e.removeHooks=function(R){on(te,R)&&(te[R]=[])},e.removeAllHooks=function(){te=Zo()},e}var mo=ri();ct.setOptions({gfm:!0,breaks:!0});const Xo=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
|
+
`).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>Xo?m=m.slice(0,Xo)+"…":a.length>1&&(m+=" …"),`<details class="code-collapsible"><summary>${s?`<span class="code-lang">${Xn(s)}</span> ${Xn(m)}`:Xn(m)}</summary>${c}</details>`}};ct.use({renderer:Bc});let Jo=!1;function si(){Jo||typeof window>"u"||(Jo=!0,mo.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))}))}function Hc(n){if(!n)return"";const e=ct.parse(n,{async:!1});return typeof window>"u"?"":(si(),mo.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(),mo.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
|
+
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>'),Jc=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>'),Qc=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
|
|
70
|
+
sidebar to open an existing session.</p></div> <form class="space-y-4"><div><label class="mb-1 block text-xs font-bold tracking-wider text-brand-text-muted uppercase" for="main-folder-path">Folder Path</label> <div class="relative"><input id="main-folder-path" type="text" autocomplete="off" spellcheck="false" placeholder="e.g. ~/projects/my-new-app"/> <!></div> <!></div> <div><label class="mb-1 block text-xs font-bold tracking-wider text-brand-text-muted uppercase" for="main-model-select">Model</label> <!></div> <!> <!> <button type="submit" class="w-full rounded bg-gradient-to-r from-brand-cyan to-brand-blue py-2.5 text-sm font-semibold text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50"> </button></form></div></div>`),id=g('<div class="flex flex-1 items-center justify-center text-brand-text-muted"><div class="text-center"><div class="mb-4 text-4xl">💬</div> <p class="mb-2 text-lg font-medium text-brand-text">New Session Started</p> <p class="text-sm">Type a message below to start building</p></div></div>'),ld=g('<div class="flex justify-center pb-2"><button class="rounded border border-brand-border bg-brand-surface-2 px-3 py-1.5 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text disabled:cursor-not-allowed disabled:opacity-50"><!></button></div>'),cd=g('<div class="flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none"><svg class="h-4 w-4 animate-spin text-brand-cyan" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Agent is thinking...</span></div>'),dd=g('<div class="flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none"><svg class="h-4 w-4 animate-spin text-brand-cyan" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Agent working...</span></div>'),ud=g('<div class="flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none"><svg class="h-4 w-4 animate-spin text-brand-cyan" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Agent is thinking...</span></div>'),fd=g('<div class="mb-1 flex items-center gap-1.5 text-[10px] font-bold tracking-wider text-brand-cyan uppercase select-none"><span class="inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-brand-cyan"></span> <span>Thinking</span></div>'),pd=g('<div class="flex flex-col gap-1"><!> <div class="font-mono text-sm whitespace-pre-wrap"> </div></div>'),hd=g('<span class="font-mono text-xs text-brand-text-muted tabular-nums"> </span>'),bd=g('<div class="flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none"><svg class="h-4 w-4 animate-spin text-amber-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Running tool: <span class="rounded bg-brand-surface-3 px-1 py-0.5 font-mono text-xs font-semibold"> </span>...</span> <!></div>'),vd=g('<div class="flex items-center gap-3 rounded-lg border border-brand-border bg-brand-surface-2 px-3 py-2.5 text-brand-text-muted"><span class="animate-pulse text-2xl leading-none">📎</span> <span class="truncate text-sm">Attaching file…</span></div>'),md=g('<span class="text-xs break-words text-brand-text-muted"> </span>'),gd=g('<div class="flex items-start gap-3 rounded-lg border border-rose-400/40 bg-rose-400/10 px-3 py-2.5 text-brand-text"><span class="text-2xl leading-none">📎</span> <span class="flex min-w-0 flex-1 flex-col gap-0.5"><span class="text-sm font-semibold text-rose-300">Could not attach file</span> <!></span></div>'),xd=g('<a class="flex items-center gap-3 rounded-lg border border-brand-cyan/40 bg-brand-cyan/10 px-3 py-2.5 text-brand-text no-underline transition-colors hover:bg-brand-cyan/20"><span class="text-2xl leading-none">📎</span> <span class="flex min-w-0 flex-1 flex-col"><span class="truncate text-sm font-semibold"> </span> <span class="truncate text-xs text-brand-text-muted"> </span></span> <span class="flex shrink-0 items-center gap-1 rounded-md bg-brand-cyan/20 px-2.5 py-1 text-xs font-medium text-brand-cyan">⬇️ Download</span></a>'),_d=g('<div class="flex items-center gap-3 rounded-lg border border-brand-border bg-brand-surface-2 px-3 py-2.5 text-brand-text-muted"><span class="text-2xl leading-none">📎</span> <span class="flex min-w-0 flex-1 flex-col"><span class="truncate text-sm font-semibold"> </span> <span class="truncate text-xs">No active session to download from</span></span></div>'),yd=g('<div class="flex max-w-full min-w-[240px] flex-col"><!></div>'),wd=g('<span class="inline-block animate-spin font-bold text-amber-400">⚡</span>'),kd=g('<span class="font-bold text-rose-400" title="Failed">❌</span>'),Sd=g('<span class="font-bold text-brand-text-muted" title="Interrupted, no result (the running tool was stopped, e.g. by a CLI takeover)">⊘</span>'),Td=g('<span class="font-bold text-emerald-400" title="Succeeded">✅</span>'),Ad=g('<span class="max-w-[180px] truncate font-mono text-xs text-brand-text-muted sm:max-w-[300px] md:max-w-[450px]"> </span>'),Ed=g("<span> </span>"),Cd=g('Collapse <span class="text-[10px]">▲</span>',1),Id=g('Expand <span class="text-[10px]">▼</span>',1),Rd=g('<a class="flex shrink-0 items-center gap-1 rounded px-1.5 py-1 text-xs text-brand-cyan transition-colors hover:bg-brand-cyan/15"><span class="text-sm">⬇️</span></a>'),$d=g('<span class="shrink-0 px-1.5 py-1 text-xs text-brand-text-muted opacity-40" title="No active session to download from">⬇️</span>'),Md=g('<a target="_blank" rel="noopener noreferrer" class="block"><img alt="Tool output" class="max-h-96 max-w-full rounded border border-brand-border/40 bg-brand-dark/60 object-contain"/></a>'),Dd=g('<div class="mt-2 flex flex-col gap-1"><div class="flex flex-wrap gap-2"></div></div>'),Pd=g('<div class="flex flex-col gap-1"><span class="font-sans text-[10px] font-bold tracking-wider text-brand-text-muted uppercase">Arguments</span> <pre class="max-h-40 overflow-x-auto rounded border border-brand-border/30 bg-brand-dark/60 p-1.5 font-mono text-[11px] whitespace-pre-wrap text-amber-400"> </pre></div>'),Ld=g('<pre class="max-h-96 overflow-x-auto rounded border border-brand-border/40 bg-brand-dark/60 p-2 font-mono text-xs whitespace-pre-wrap text-brand-text"> </pre>'),Od=g('<div class="animate-pulse p-1 text-xs text-brand-text-muted italic">Running and waiting for output...</div>'),Nd=g(`<div class="p-1 text-xs text-brand-text-muted italic">Interrupted before a result was returned (the
|
|
71
71
|
running tool was stopped, e.g. by a CLI takeover).
|
|
72
|
-
Its outcome is unknown.</div>`),Fd=
|
|
73
|
-
`),D=/^\[Uploaded file: (.+)\]$/,
|
|
74
|
-
`).trim();return X==="I have uploaded the following file(s) for you:"&&(X=""),{cleanContent:X,attachments:re}}let Ie=G(""),St=G(Mn([])),ut=G(!1),Ge=G(null),we=G(null),Tt="",qe=G(""),Xe=G(!1),yt=G(null),rt=G(!0),ft=G("private"),wt=G(!1),st=G(!1),te=G(!1),xt=G(null);function Ee(v){jn(t(Ie).trim(),t(qe)||void 0,v?!1:t(Xe),v?!1:t(Te).matchingRule?t(rt):void 0,v?void 0:t(Te).matchingRule?t(ft):void 0,v||void 0)}let ot=V(r),At=V(s),vt=V(o);Pt(()=>{t(yt)===null&&p(Xe,t(vt),!0)});let Te=G(Mn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),an=V(()=>t(Te).exists!==!0&&t(Te).matchingRule&&t(rt)),ee=null;async function ce(v,w=!1){if(ee&&clearTimeout(ee),v===Tt&&!w)return;if(Tt=v,!v.trim()){p(Te,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const
|
|
75
|
-
`),et=Be!==-1?ye.slice(0,Be):ye;
|
|
76
|
-
${pr??""}`)},[()=>mt(t(k))]),h(Fe,
|
|
77
|
-
the message.</p></div> <!></div>`,1),vu=
|
|
78
|
-
${t(
|
|
79
|
-
${t(
|
|
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"}`),ge(vt,"title",t(a)?"Recording (release/tap to stop)...":t(l)?"Processing speech...":"Hold to speak (walkie-talkie) or Tap to toggle recording"),Te.disabled=e.disabled&&!t(a)&&!t(l)||t(l),rn(an,0,`h-4 w-4 transition-transform duration-200 ${t(_)?"rotate-45 text-white":""}`)}),W("pointerdown",vt,wt),W("pointerup",vt,st),ir("pointercancel",vt,te),W("click",Te,()=>p(_,!t(_))),h(n,At),cr()}xr(["pointerdown","pointerup","click","change"]);var gu=
|
|
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),Jd=g("<div><div><!> <!></div></div>"),Qd=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){lr(e,!0);const r=()=>$e(Lt,"$piState",S),s=()=>$e(Er,"$availableModels",S),o=()=>$e(Zs,"$gitInitDefaultStore",S),a=()=>$e(Yr,"$activeSessionInfo",S),l=()=>$e(fs,"$isLoadingSession",S),c=()=>$e(Qs,"$beepSessionOverride",S),_=()=>$e(eo,"$beepEnabled",S),m=()=>$e(Da,"$messages",S),x=()=>$e(so,"$isStreaming",S),I=()=>$e(za,"$hasMoreHistory",S),P=()=>$e(Ba,"$isLoadingMoreHistory",S),N=()=>$e(us,"$isReadOnly",S),[S,Y]=Cr(),ke=[],Q=new Map;function ue(v,w){const D=`${v}:${w.length}`;let L=Q.get(D);return L===void 0&&(L=Hc(w),Q.set(D,L)),L}const Le=new Map;function _e(v){let w=Le.get(v);return w===void 0&&(w=Gc(v),Le.set(v,w)),w}function Ce(v){if(v>=1e6){const w=v/1e6;return(w>=10?Math.round(w).toString():w.toFixed(1))+"M"}return v>=1e3?Math.round(v/1e3)+"K":String(v)}let fe=V(()=>{const v=r().contextUsage;if(!v||!v.contextWindow)return null;const w=Ce(v.contextWindow);return v.percent==null?`– / ${w}`:`${v.percent.toFixed(1)}% / ${w}`});function Me(v){if(!v)return{cleanContent:"",attachments:[]};const w=v.split(`
|
|
73
|
+
`),D=/^\[Uploaded file: (.+)\]$/,L=[],re=[];for(const k of w){const de=k.match(D);de?re.push(de[1]):L.push(k)}let X=L.join(`
|
|
74
|
+
`).trim();return X==="I have uploaded the following file(s) for you:"&&(X=""),{cleanContent:X,attachments:re}}let Ie=G(""),St=G(Mn([])),ut=G(!1),Ge=G(null),we=G(null),Tt="",qe=G(""),Xe=G(!1),yt=G(null),rt=G(!0),ft=G("private"),wt=G(!1),st=G(!1),te=G(!1),xt=G(null);function Ee(v){jn(t(Ie).trim(),t(qe)||void 0,v?!1:t(Xe),v?!1:t(Te).matchingRule?t(rt):void 0,v?void 0:t(Te).matchingRule?t(ft):void 0,v||void 0)}let ot=V(r),At=V(s),vt=V(o);Pt(()=>{t(yt)===null&&p(Xe,t(vt),!0)});let Te=G(Mn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),an=V(()=>t(Te).exists!==!0&&t(Te).matchingRule&&t(rt)),ee=null;async function ce(v,w=!1){if(ee&&clearTimeout(ee),v===Tt&&!w)return;if(Tt=v,!v.trim()){p(Te,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const L=async()=>{const re=await ss("");p(St,re||[],!0)};w?await L():ee=setTimeout(L,300);return}const D=async()=>{const[L,re]=await Promise.all([fa(v),ss(v)]);p(St,re||[],!0),L?(p(Te,{exists:L.exists,isGit:L.isGit,resolvedPath:L.resolvedPath,matchingRule:L.matchingRule||null},!0),L.exists||(p(Xe,t(yt)!==null?t(yt):t(vt),!0),p(rt,!0),L.matchingRule&&p(ft,L.matchingRule.visibility,!0))):p(Te,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};w?await D():ee=setTimeout(D,300)}Pt(()=>{const v=t(Ie);ce(v,!1)}),Pt(()=>{if(t(At).models.length>0&&!t(qe)){const v=t(At).models.find(w=>w.isDefault);v?p(qe,`${v.provider}:${v.modelId}`):p(qe,`${t(At).models[0].provider}:${t(At).models[0].modelId}`)}});async function A(){if(t(Ie).trim()){if(t(Te).exists===!0){p(Xe,!1),p(rt,!1),t(Te).matchingRule&&p(ft,t(Te).matchingRule.visibility,!0),p(wt,!0);return}if(t(Te).matchingRule&&t(rt)){p(te,!0);try{const v=await ol(t(Ie).trim());if(v&&v.matched&&v.exists){p(xt,{provider:v.provider,sshUrl:v.sshUrl},!0),p(st,!0);return}}finally{p(te,!1)}}Ee(!1)}}let U=G(void 0),T=V(a),oe=V(l),z=V(c),me=V(_);function be(){t(z)===void 0?ts(!0):t(z)===!0?ts(!1):ts(void 0)}let ze=V(()=>!!t(T).sessionFile),Ue=G(!0),at=G(!1),pt=Mn({});function Ne(v,w){pt[v]=!w}function Oe(v){if(!v)return null;const w=v.trim();if(!w)return null;if(w.startsWith("{"))try{return JSON.parse(w)}catch{}const D={},L=/([a-zA-Z0-9_-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|(\S+))/g;let re;for(;(re=L.exec(w))!==null;){const X=re[1],k=re[2]!==void 0?re[2]:re[3]!==void 0?re[3]:re[4];D[X]=k}return Object.keys(D).length>0?D:null}function jt(v,w,D){if(!w)return D?D.trim():"";const L=v.toLowerCase();if(["read","write","edit","ls"].includes(L)){const X=w.path||w.filepath||w.file;if(X)return String(X)}if(L==="bash"){const X=w.command||w.cmd;if(X){const k=String(X).replace(/\s+/g," ").trim();return k.length>50?k.slice(0,47)+"...":k}}if(L==="grep"){const X=w.pattern,k=w.path;if(X)return k?`"${X}" in ${k}`:`"${X}"`}if(L==="find"){const X=w.pattern||w.path;if(X)return String(X)}const re=w.path||w.filepath||w.file||w.name||w.query;return re?String(re):Object.entries(w).filter(([X,k])=>k!==void 0&&k!=="").map(([X,k])=>`${X}=${typeof k=="object"?JSON.stringify(k):k}`).join(" ")}function Vt(v,w){return v?JSON.stringify(v,null,2):w?w.trim():""}function hn(v){let w=v.toolName||"tool",D=v.toolArgs!==void 0?v.toolArgs:"",L=v.toolOutput!==void 0?v.toolOutput:"",re=!!v.isError;if(!D&&!L&&v.content){let ye=v.content||"";ye.startsWith("Error: ")?(re=!0,ye=ye.slice(7)):ye.startsWith("Tool error: ")&&(re=!0,ye=ye.slice(12));const Be=ye.indexOf(`
|
|
75
|
+
`),et=Be!==-1?ye.slice(0,Be):ye;L=Be!==-1?ye.slice(Be+1):"";let he=et.trim();he.startsWith("$ ")&&(he=he.slice(2));const He=he.indexOf(" ");w=v.toolName||(He!==-1?he.slice(0,He):he)||"tool",D=He!==-1?he.slice(He+1):""}const X=Oe(D),k=jt(w,X,D),de=Vt(X,D);return{toolName:w,smartTitleArgs:k,fullArgs:de,toolOutput:L,isError:re,interrupted:!!v.interrupted,downloadPath:bn(w,X,re)}}function bn(v,w,D){if(D||!w)return null;const L=(v||"").toLowerCase();if(!["attach_file","read","write","edit"].includes(L))return null;const re=w.path||w.filepath||w.file;return!re||typeof re!="string"?null:re.trim()||null}function Dt(v){return v.scrollHeight-v.scrollTop-v.clientHeight<=20}function Et(){t(U)&&p(Ue,Dt(t(U)),!0)}function Ke(){t(U)&&(t(U).scrollTop=t(U).scrollHeight)}function en(){(t(Ue)||t(at))&&(Ke(),p(at,!1))}qr(Ke),Pt(()=>{if(t(U))return t(U).addEventListener("scroll",Et),()=>{t(U)&&t(U).removeEventListener("scroll",Et)}});let Kt=G(null),tn=G(!1);function Tn(){p(at,!0),Ke(),requestAnimationFrame(()=>{Ke(),requestAnimationFrame(Ke)}),setTimeout(Ke,60),setTimeout(Ke,150)}Pt(()=>{const v=t(T).sessionFile;v!==t(Kt)&&(p(Kt,v,!0),p(at,!0));const w=t(oe);t(tn)&&!w&&Tn(),p(tn,w,!0)});let ie=V(()=>{const v=m().filter(D=>D.role==="thinking"&&r().hideThinking?!1:D.role==="tool"&&r().hideTools&&D.toolName!=="attach_file"?Yt(D)||!!D.isStreaming:D.role!=="assistant"&&D.role!=="thinking"||D.isStreaming||D.content.trim()!==""),w=v.some(D=>D.isStreaming);if(t(it)&&!w){const D=m().some(L=>L.role==="thinking"&&L.isStreaming);v.push({id:"fallback-loader-message-id",role:"thinking",content:D?"FALLBACK_THINKING_LOADER":"FALLBACK_LOADER",timestamp:Date.now(),isStreaming:!0})}return v}),it=V(x),Ot=G(Mn(Date.now())),kt=V(()=>t(ie).some(v=>v.role==="tool"&&v.isStreaming));Pt(()=>{if(!t(kt))return;p(Ot,Date.now(),!0);const v=setInterval(()=>p(Ot,Date.now(),!0),100);return()=>clearInterval(v)});function mt(v){if(v.startedAt===void 0)return null;const w=v.endedAt??(v.isStreaming?t(Ot):void 0);return w===void 0?null:`${(Math.max(0,w-v.startedAt)/1e3).toFixed(1)}s`}Pi(()=>{const v=t(ie)[t(ie).length-1];v&&`${t(ie).length}${v.content.length}`,t(U)&&p(Ue,Dt(t(U)),!0)}),Pt(()=>{const v=t(ie)[t(ie).length-1];v&&`${t(ie).length}${v.content.length}`,en()});function nn(v){return new Date(v).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Yt(v){return v.role==="tool"&&v.forceCommand===!0}function yn(v,w){return Yt(v)}function wn(){p(at,!0),setTimeout(Ke,0)}let Cn=V(I),M=V(P);const q=64;let K=G(null),Z=G(null);function xe(){!t(U)||t(M)||!t(Cn)||(p(K,t(ie)[0]?.id??null,!0),p(Z,t(U).scrollHeight-t(U).scrollTop),Ta())}Pt(()=>{if(m().length,(t(K)!==null||t(Z)!==null)&&t(U)){const v=t(K),w=t(Z);p(K,null),p(Z,null),requestAnimationFrame(()=>{if(!t(U))return;const D=v?t(U).querySelector(`[data-msg-id="${CSS.escape(v)}"]`):null;if(D){const L=D.getBoundingClientRect().top-t(U).getBoundingClientRect().top;t(U).scrollTop=Math.max(0,t(U).scrollTop+L-q)}else w!==null&&(t(U).scrollTop=t(U).scrollHeight-w)})}});var qt={forceScrollToBottom:wn},Ct=cu(),Ut=u(Ct);{var It=v=>{var w=jc();h(v,w)},Nt=v=>{var w=Vc(),D=u(w),L=f(u(D),6);{var re=k=>{var de=qc(),ye=u(de,!0);d(de),H(()=>J(ye,t(ot).error)),h(k,de)};E(L,k=>{t(ot).error&&k(re)})}var X=f(L,2);d(D),d(w),W("click",X,()=>{Fi(()=>Promise.resolve().then(()=>yl),void 0,import.meta.url).then(k=>k.connect())}),h(v,w)},Ft=v=>{var w=Kc();h(v,w)},zt=v=>{var w=ad(),D=u(w),L=u(D),re=u(L),X=u(re);d(re),lt(6),d(L);var k=f(L,2),de=u(k),ye=f(u(de),2),Be=u(ye);nt(Be),qn(Be,y=>p(Ge,y),()=>t(Ge));var et=f(Be,2);{var he=y=>{var C=Zc();_n(C,21,()=>t(St),Pn,(j,F)=>{var ne=Yc(),Ae=u(ne,!0);d(ne),H(()=>J(Ae,t(F))),W("click",ne,()=>{p(Ie,t(F),!0),ce(t(F),!0),t(Ge)?.focus()}),h(j,ne)}),d(C),h(y,C)};E(et,y=>{t(ut)&&t(St).length>0&&y(he)})}d(ye),qn(ye,y=>p(we,y),()=>t(we));var He=f(ye,2);{var Zt=y=>{var C=Jc(),j=f(u(C));{var F=ne=>{var Ae=Xc();h(ne,Ae)};E(j,ne=>{t(Te).isGit&&ne(F)})}d(C),h(y,C)},Xt=y=>{var C=Qc();h(y,C)};E(He,y=>{t(Te).exists===!0?y(Zt):y(Xt,-1)})}d(de);var Ht=f(de,2),We=f(u(Ht),2);{var Ye=y=>{var C=td();_n(C,21,()=>t(At).models,Pn,(j,F)=>{var ne=ed(),Ae=u(ne);d(ne);var Je={};H(()=>{J(Ae,`${t(F).label??""}${t(F).isDefault?" (default)":""}`),Je!==(Je=`${t(F).provider}:${t(F).modelId}`)&&(ne.value=ne.__value=`${t(F).provider}:${t(F).modelId}`)}),h(j,ne)}),d(C),Gr(C,()=>t(qe),j=>p(qe,j)),h(y,C)},Ve=y=>{var C=nd();nt(C),Ln(C,()=>t(qe),j=>p(qe,j)),h(y,C)};E(We,y=>{t(At).models.length>0?y(Ye):y(Ve,-1)})}d(Ht);var gt=f(Ht,2);{var Rt=y=>{var C=sd(),j=u(C),F=u(j);nt(F);var ne=f(F,2),Ae=u(ne);d(ne),d(j);var Je=f(j,2);{var tt=Mt=>{var je=rd(),cn=f(u(je),2),zn=u(cn);nt(zn),zn.value=zn.__value="private",lt(),d(cn);var dr=f(cn,2),tr=u(dr);nt(tr),tr.value=tr.__value="public",lt(),d(dr),d(je),ar(ke,[],zn,()=>t(ft),ur=>p(ft,ur)),ar(ke,[],tr,()=>t(ft),ur=>p(ft,ur)),h(Mt,je)};E(Je,Mt=>{t(rt)&&Mt(tt)})}d(C),H(()=>J(Ae,`Create remote ${t(Te).matchingRule.provider??""} repository`)),On(F,()=>t(rt),Mt=>p(rt,Mt)),h(y,C)};E(gt,y=>{t(Te).exists!==!0&&t(Te).matchingRule&&y(Rt)})}var $t=f(gt,2);{var R=y=>{var C=od(),j=u(C);nt(j),lt(2),d(C),W("change",j,F=>{p(yt,F.currentTarget.checked,!0)}),On(j,()=>t(Xe),F=>p(Xe,F)),h(y,C)};E($t,y=>{t(Te).exists!==!0&&(!t(Te).matchingRule||!t(rt))&&y(R)})}var i=f($t,2),b=u(i,!0);d(i),d(k),d(D),d(w),H((y,C)=>{ge(X,"src",y),rn(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(an)?"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,J(b,t(te)?"Checking remote...":"Create & Start Session")},[()=>Tr("/logo.svg"),()=>!t(Ie).trim()||t(te)]),ir("submit",k,y=>{y.preventDefault(),A()}),ir("focus",Be,()=>{p(ut,!0),ce(t(Ie),!0)}),ir("blur",Be,y=>{t(we)&&t(we).contains(y.relatedTarget)||p(ut,!1)}),W("keydown",Be,y=>{y.key==="Escape"&&p(ut,!1)}),Ln(Be,()=>t(Ie),y=>p(Ie,y)),h(v,w)},ln=v=>{var w=id();h(v,w)},$=v=>{var w=Qd(),D=u(w);{var L=X=>{var k=ld(),de=u(k),ye=u(de);{var Be=he=>{var He=xn("Loading older messages...");h(he,He)},et=he=>{var He=xn("Load older messages");h(he,He)};E(ye,he=>{t(M)?he(Be):he(et,-1)})}d(de),d(k),H(()=>de.disabled=t(M)),W("click",de,xe),h(X,k)};E(D,X=>{t(Cn)&&X(L)})}var re=f(D,2);_n(re,17,()=>t(ie),X=>X.id,(X,k)=>{var de=Jd(),ye=u(de),Be=u(ye);{var et=We=>{var Ye=Zn(),Ve=Wt(Ye);{var gt=i=>{var b=cd();h(i,b)},Rt=i=>{var b=dd();h(i,b)},$t=i=>{var b=ud();h(i,b)},R=i=>{var b=pd(),y=u(b);{var C=ne=>{var Ae=fd();h(ne,Ae)};E(y,ne=>{t(k).isStreaming&&ne(C)})}var j=f(y,2),F=u(j,!0);d(j),d(b),H(()=>J(F,t(k).content)),h(i,b)};E(Ve,i=>{t(k).content==="FALLBACK_THINKING_LOADER"?i(gt):t(k).content==="FALLBACK_LOADER"?i(Rt,1):r().hideThinking?i($t,2):i(R,-1)})}h(We,Ye)},he=We=>{var Ye=Zn(),Ve=Wt(Ye);{var gt=R=>{var i=bd(),b=f(u(i),2),y=f(u(b)),C=u(y,!0);d(y),lt(),d(b);var j=f(b,2);{var F=Ae=>{var Je=hd(),tt=u(Je,!0);d(Je),H(Mt=>J(tt,Mt),[()=>mt(t(k))]),h(Ae,Je)},ne=V(()=>mt(t(k)));E(j,Ae=>{t(ne)&&Ae(F)})}d(i),H(()=>J(C,t(k).toolName||"agent")),h(R,i)},Rt=V(()=>r().hideTools&&t(k).toolName!=="attach_file"&&!Yt(t(k))),$t=R=>{const i=V(()=>hn(t(k))),b=V(()=>pt[t(k).id]!==void 0?pt[t(k).id]:yn(t(k),t(ie))),y=V(()=>t(i).downloadPath),C=V(()=>t(y)?Ha(t(y)):null),j=V(()=>t(i).toolName==="attach_file");var F=Zn(),ne=Wt(F);{var Ae=tt=>{const Mt=V(()=>t(y)?t(y).split("/").pop()||t(y):"");var je=yd(),cn=u(je);{var zn=gn=>{var sn=vd();h(gn,sn)},dr=gn=>{var sn=gd(),An=f(u(sn),2),Bn=f(u(An),2);{var nr=Kn=>{var fr=md(),bs=u(fr,!0);d(fr),H(()=>J(bs,t(i).toolOutput)),h(Kn,fr)};E(Bn,Kn=>{t(i).toolOutput&&Kn(nr)})}d(An),d(sn),h(gn,sn)},tr=gn=>{var sn=xd(),An=f(u(sn),2),Bn=u(An),nr=u(Bn,!0);d(Bn);var Kn=f(Bn,2),fr=u(Kn,!0);d(Kn),d(An),lt(2),d(sn),H(()=>{ge(sn,"href",t(C)),ge(sn,"download",t(Mt)),ge(sn,"title",`Download ${t(y)}`),J(nr,t(Mt)),ge(Kn,"title",t(y)),J(fr,t(y))}),h(gn,sn)},ur=gn=>{var sn=_d(),An=f(u(sn),2),Bn=u(An),nr=u(Bn,!0);d(Bn),lt(2),d(An),d(sn),H(()=>J(nr,t(Mt))),h(gn,sn)};E(cn,gn=>{t(k).isStreaming?gn(zn):t(i).isError?gn(dr,1):t(C)?gn(tr,2):gn(ur,-1)})}d(je),h(tt,je)},Je=tt=>{var Mt=zd(),je=u(Mt),cn=u(je),zn=u(cn),dr=u(zn);{var tr=Fe=>{var Qe=wd();h(Fe,Qe)},ur=Fe=>{var Qe=kd();h(Fe,Qe)},gn=Fe=>{var Qe=Sd();h(Fe,Qe)},sn=Fe=>{var Qe=Td();h(Fe,Qe)};E(dr,Fe=>{t(k).isStreaming?Fe(tr):t(i).isError?Fe(ur,1):t(i).interrupted?Fe(gn,2):Fe(sn,-1)})}var An=f(dr,2),Bn=u(An,!0);d(An);var nr=f(An,2);{var Kn=Fe=>{var Qe=Ad(),In=u(Qe,!0);d(Qe),H(()=>{ge(Qe,"title",t(i).smartTitleArgs),J(In,t(i).smartTitleArgs)}),h(Fe,Qe)};E(nr,Fe=>{t(i).smartTitleArgs&&Fe(Kn)})}var fr=f(nr,2);{var bs=Fe=>{var Qe=Ed(),In=u(Qe);d(Qe),H(pr=>{rn(Qe,1,`shrink-0 font-mono text-xs tabular-nums ${t(k).isStreaming?"text-amber-400":"text-brand-text-muted"}`),ge(Qe,"title",t(k).isStreaming?"Elapsed time":"Time taken"),J(In,`${t(k).isStreaming?"Elapsed":"Took"}
|
|
76
|
+
${pr??""}`)},[()=>mt(t(k))]),h(Fe,Qe)},oi=V(()=>mt(t(k)));E(fr,Fe=>{t(oi)&&Fe(bs)})}d(zn);var go=f(zn,2),ai=u(go);{var ii=Fe=>{var Qe=Cd();lt(),h(Fe,Qe)},li=Fe=>{var Qe=Id();lt(),h(Fe,Qe)};E(ai,Fe=>{t(b)?Fe(ii):Fe(li,-1)})}d(go),d(cn);var ci=f(cn,2);{var di=Fe=>{var Qe=Zn(),In=Wt(Qe);{var pr=kn=>{var Rn=Rd();H(vs=>{ge(Rn,"href",t(C)),ge(Rn,"download",vs),ge(Rn,"title",`Download ${t(y)}`),ge(Rn,"aria-label",`Download ${t(y)}`)},[()=>t(y).split("/").pop()||""]),h(kn,Rn)},Yn=kn=>{var Rn=$d();h(kn,Rn)};E(In,kn=>{t(C)?kn(pr):kn(Yn,-1)})}h(Fe,Qe)};E(ci,Fe=>{t(y)&&Fe(di)})}d(je);var xo=f(je,2);{var ui=Fe=>{var Qe=Dd(),In=u(Qe);_n(In,21,()=>t(k).images,Pn,(pr,Yn)=>{var kn=Md(),Rn=u(kn);d(kn),H(()=>{ge(kn,"href",`data:${t(Yn).mimeType};base64,${t(Yn).data}`),ge(Rn,"src",`data:${t(Yn).mimeType};base64,${t(Yn).data}`)}),h(pr,kn)}),d(In),d(Qe),h(Fe,Qe)};E(xo,Fe=>{t(k).images&&t(k).images.length>0&&Fe(ui)})}var fi=f(xo,2);{var pi=Fe=>{var Qe=Ud(),In=u(Qe);{var pr=pn=>{var Sn=Pd(),Xr=f(u(Sn),2),vi=u(Xr,!0);d(Xr),d(Sn),H(()=>J(vi,t(i).fullArgs)),h(pn,Sn)};E(In,pn=>{t(i).fullArgs&&t(i).fullArgs!=="{}"&&pn(pr)})}var Yn=f(In,2),kn=f(u(Yn),2);{var Rn=pn=>{var Sn=Ld(),Xr=u(Sn,!0);d(Sn),H(()=>J(Xr,t(i).toolOutput)),h(pn,Sn)},vs=pn=>{var Sn=Od();h(pn,Sn)},hi=pn=>{var Sn=Nd();h(pn,Sn)},bi=pn=>{var Sn=Fd();h(pn,Sn)};E(kn,pn=>{t(i).toolOutput?pn(Rn):t(k).isStreaming?pn(vs,1):t(i).interrupted?pn(hi,2):pn(bi,-1)})}d(Yn),d(Qe),h(Fe,Qe)};E(fi,Fe=>{t(b)&&Fe(pi)})}d(Mt),H(()=>J(Bn,t(i).toolName)),W("click",cn,()=>Ne(t(k).id,t(b))),h(tt,Mt)};E(ne,tt=>{t(j)?tt(Ae):tt(Je,-1)})}h(R,F)};E(Ve,R=>{t(Rt)?R(gt):R($t,-1)})}h(We,Ye)},He=We=>{var Ye=Zn(),Ve=Wt(Ye);{var gt=$t=>{var R=Bd(),i=u(R,!0);lt(),d(R),H(()=>J(i,t(k).content)),h($t,R)},Rt=$t=>{var R=Hd();So(R,()=>ue(t(k).id,t(k).content),!0),d(R),h($t,R)};E(Ve,$t=>{t(k).isStreaming?$t(gt):$t(Rt,-1)})}h(We,Ye)},Zt=We=>{const Ye=V(()=>Me(t(k).content));var Ve=Kd(),gt=Wt(Ve),Rt=u(gt);{var $t=F=>{const ne=V(()=>_e(t(Ye).cleanContent));var Ae=Zn(),Je=Wt(Ae);{var tt=je=>{var cn=Wd();So(cn,()=>t(ne),!0),d(cn),h(je,cn)},Mt=je=>{var cn=xn();H(()=>J(cn,t(Ye).cleanContent)),h(je,cn)};E(Je,je=>{t(ne)?je(tt):je(Mt,-1)})}h(F,Ae)},R=F=>{var ne=Gd(),Ae=u(ne);d(ne),H(()=>J(Ae,`Shared file${t(Ye).attachments.length>1?"s":""} with agent:`)),h(F,ne)},i=F=>{var ne=xn();H(()=>J(ne,t(k).content||(t(k).isStreaming?"Thinking...":""))),h(F,ne)};E(Rt,F=>{t(Ye).cleanContent?F($t):t(Ye).attachments.length>0?F(R,1):F(i,-1)})}var b=f(Rt,2);{var y=F=>{var ne=jd();h(F,ne)};E(b,F=>{t(k).isStreaming&&t(it)&&F(y)})}d(gt);var C=f(gt,2);{var j=F=>{var ne=Vd();_n(ne,21,()=>t(Ye).attachments,Pn,(Ae,Je)=>{var tt=qd(),Mt=f(u(tt),2),je=u(Mt,!0);d(Mt),d(tt),H(()=>{ge(Mt,"title",t(Je)),J(je,t(Je))}),h(Ae,tt)}),d(ne),h(F,ne)};E(C,F=>{t(Ye).attachments.length>0&&F(j)})}h(We,Ve)};E(Be,We=>{t(k).role==="thinking"?We(et):t(k).role==="tool"?We(he,1):t(k).role==="assistant"&&t(k).content!==""?We(He,2):We(Zt,-1)})}var Xt=f(Be,2);{var Ht=We=>{var Ye=Xd(),Ve=Wt(Ye),gt=u(Ve);{var Rt=b=>{var y=Yd();lt(2),h(b,y)};E(gt,b=>{t(k).role==="user"&&t(k).delivery==="sending"&&b(Rt)})}var $t=f(gt);d(Ve);var R=f(Ve,2);{var i=b=>{var y=Zd(),C=f(u(y),2),j=f(C,2);d(y),W("click",C,()=>_a(t(k).id)),W("click",j,()=>ya(t(k).id)),h(b,y)};E(R,b=>{t(k).role==="user"&&t(k).delivery==="failed"&&b(i)})}H(b=>{rn(Ve,1,`mt-1 flex items-center gap-1.5 text-xs opacity-50 ${t(k).role==="user"?"justify-end text-brand-text-muted":t(k).role==="assistant"?"text-brand-purple":"text-brand-text-muted"}`),J($t,` ${b??""}`)},[()=>nn(t(k).timestamp)]),h(We,Ye)};E(Xt,We=>{t(k).role!=="thinking"&&t(k).role!=="tool"&&We(Ht)})}d(ye),d(de),H(We=>{ge(de,"data-msg-id",t(k).id),rn(de,1,`flex ${t(k).role==="user"?"justify-end":"justify-start"}`),rn(ye,1,`max-w-[85%] rounded-lg px-4 py-3 ${We??""}`)},[()=>t(k).role==="user"?"bg-brand-blue/80 text-brand-text":t(k).role==="thinking"?"border-l-2 border-brand-border bg-brand-surface/30 text-sm text-brand-text-muted":t(k).role==="tool"&&t(k).toolName==="attach_file"?"bg-transparent p-0 text-brand-text":t(k).role==="tool"?r().hideTools&&!Yt(t(k))?"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(k).isStreaming?"border-amber-400":t(k).isError?"border-rose-400":t(k).interrupted?"border-brand-border":"border-emerald-400"}`:t(k).role==="assistant"?"border-l-2 border-brand-purple bg-brand-purple/10 text-brand-text":t(k).content===""&&t(k).isStreaming?"bg-brand-surface-3 text-brand-text-muted italic":"bg-brand-surface-2 text-brand-text"]),h(X,de)}),d(w),qn(w,X=>p(U,X),()=>t(U)),h(v,w)};E(Ut,v=>{t(ot).connecting&&!t(ze)?v(It):!t(ot).connected&&!t(ze)?v(Nt,1):!t(ze)&&(t(oe)||typeof window<"u"&&window.location.hash)?v(Ft,2):t(T).sessionFile?t(ie).length===0?v(ln,4):v($,-1):v(zt,3)})}var O=f(Ut,2),B=u(O),le=u(B),De=u(le);nt(De),lt(),d(le);var ve=f(le,2);{var ae=v=>{var w=eu(),D=u(w),L=u(D,!0);d(D);var re=f(D,2),X=u(re,!0);d(re),d(w),H(()=>{rn(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"}`),ge(w,"title",t(z)===void 0?`Beep when the agent is waiting: following the default (${t(me)?"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."),J(L,t(me)?"🔔":"🔕"),J(X,t(z)===void 0?`Beep: Default (${t(me)?"on":"off"})`:t(z)?"Beep: On":"Beep: Off")}),W("click",w,be),h(v,w)};E(ve,v=>{t(T).sessionFile&&!N()&&v(ae)})}var Re=f(ve,2);{var Pe=v=>{var w=tu(),D=f(u(w),2),L=u(D,!0);d(D),d(w),H(re=>{ge(w,"title",re),J(L,t(fe))},[()=>r().contextUsage?.tokens!=null?`${r().contextUsage.tokens.toLocaleString()} context tokens of ${r().contextUsage.contextWindow.toLocaleString()}`:"Context window size"]),h(v,w)};E(Re,v=>{t(fe)&&v(Pe)})}d(B);var _t=f(B,2);d(O);var Bt=f(O,2);{var bt=v=>{var w=au(),D=u(w),L=f(u(D),2),re=f(u(L)),X=u(re,!0);d(re),lt(),d(L);var k=f(L,2),de=u(k),ye=u(de);nt(ye);var Be=f(ye,2),et=f(u(Be));{var he=Ve=>{var gt=nu();h(Ve,gt)},He=Ve=>{var gt=ru();h(Ve,gt)};E(et,Ve=>{t(Te).isGit?Ve(he):Ve(He,-1)})}d(Be),d(de);var Zt=f(de,2);{var Xt=Ve=>{var gt=ou(),Rt=u(gt),$t=u(Rt);nt($t);var R=f($t,2),i=u(R);d(R),d(Rt);var b=f(Rt,2);{var y=C=>{var j=su(),F=f(u(j),2),ne=u(F);nt(ne),ne.value=ne.__value="private",lt(),d(F);var Ae=f(F,2),Je=u(Ae);nt(Je),Je.value=Je.__value="public",lt(),d(Ae),d(j),ar(ke,[],ne,()=>t(ft),tt=>p(ft,tt)),ar(ke,[],Je,()=>t(ft),tt=>p(ft,tt)),h(C,j)};E(b,C=>{t(rt)&&C(y)})}d(gt),H(()=>J(i,`Create remote ${t(Te).matchingRule.provider??""} repository`)),On($t,()=>t(rt),C=>p(rt,C)),h(Ve,gt)};E(Zt,Ve=>{t(Te).matchingRule&&Ve(Xt)})}d(k);var Ht=f(k,2),We=u(Ht),Ye=f(We,2);d(Ht),d(D),d(w),H(()=>{J(X,t(Ie)),ye.disabled=t(Te).isGit}),On(ye,()=>t(Xe),Ve=>p(Xe,Ve)),W("click",We,()=>p(wt,!1)),W("click",Ye,()=>{p(wt,!1),jn(t(Ie).trim(),t(qe)||void 0,t(Xe),t(Te).matchingRule?t(rt):void 0,t(Te).matchingRule?t(ft):void 0)}),h(v,w)};E(Bt,v=>{t(wt)&&v(bt)})}var pe=f(Bt,2);{var se=v=>{var w=lu(),D=u(w),L=f(u(D),2),re=u(L),X=f(re),k=u(X,!0);d(X),lt(),d(L);var de=f(L,2);{var ye=He=>{var Zt=iu(),Xt=u(Zt,!0);d(Zt),H(()=>J(Xt,t(xt).sshUrl)),h(He,Zt)};E(de,He=>{t(xt)?.sshUrl&&He(ye)})}var Be=f(de,2),et=u(Be),he=f(et,2);d(Be),d(D),d(w),H(()=>{J(re,`A ${t(xt)?.provider??"remote"??""} repository matching `),J(k,t(Ie))}),W("click",et,()=>{p(st,!1),p(xt,null),Ee(!1)}),W("click",he,()=>{p(st,!1),p(xt,null),Ee(!0)}),h(v,w)};E(pe,v=>{t(st)&&v(se)})}d(Ct),H(()=>{ra(De,r().hideThinking),_t.disabled=!t(it)}),W("change",De,v=>Ca({hideThinking:v.currentTarget.checked})),W("click",_t,function(...v){wa?.apply(this,v)}),h(n,Ct);var Se=cr(qt);return Y(),Se}xr(["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){lr(e,!0);let r=br(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),N=G(null),S=null,Y=null,ke=null,Q=null,ue=null,Le=[],_e="",Ce=!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 A=localStorage.getItem("wherever-speech-direct-send");A!==null&&p(m,A==="true");const U=localStorage.getItem("wherever-speech-locale");U!==null&&p(x,U,!0);const T=localStorage.getItem("wherever-speech-engine");return T!==null?p(I,T,!0):o||p(I,"cloud"),()=>{if(S)try{S.abort()}catch{}if(Q)try{Q.disconnect()}catch{}if(ke)try{ke.disconnect()}catch{}if(ue)try{ue.getTracks().forEach(oe=>oe.stop())}catch{}if(Y)try{Y.close()}catch{}t(N)&&clearTimeout(t(N))}});function Me(){localStorage.setItem("wherever-speech-direct-send",String(t(m))),localStorage.setItem("wherever-speech-locale",t(x)),localStorage.setItem("wherever-speech-engine",t(I))}function Ie(){const A=localStorage.getItem("wherever-config");if(A){const U=JSON.parse(A),T=window.location.protocol==="https:"?"https:":"http:",oe=U.host.startsWith("http")?U.host.replace(/^wss?:\/\//,""):U.host;return`${T}//${oe}:${U.port}`}return`${window.location.protocol}//${window.location.host}`}function St(){try{const A=localStorage.getItem("wherever-config");if(A)return JSON.parse(A).token||""}catch{}return""}function ut(){try{const A=window.AudioContext||window.webkitAudioContext;if(!A)return;const U=new A,T=U.createOscillator(),oe=U.createGain();T.type="sine",T.frequency.setValueAtTime(400,U.currentTime),oe.gain.setValueAtTime(.08,U.currentTime),oe.gain.exponentialRampToValueAtTime(.001,U.currentTime+.12),T.connect(oe),oe.connect(U.destination),T.start(),T.stop(U.currentTime+.12)}catch(A){console.warn("Could not play audio beep feedback:",A)}}function Ge(A,U,T){if(U===T)return A;const oe=U/T,z=Math.round(A.length/oe),me=new Float32Array(z);let be=0,ze=0;for(;be<me.length;){const Ue=Math.round((be+1)*oe);let at=0,pt=0;for(let Ne=ze;Ne<Ue&&Ne<A.length;Ne++)at+=A[Ne],pt++;me[be]=pt>0?at/pt:0,be++,ze=Ue}return me}function we(){if(o)try{S=new s,S.continuous=!0,S.interimResults=!0,S.lang=t(x),S.onstart=()=>{p(a,!0),p(l,!1),ut()},S.onresult=A=>{let U="",T="";for(let z=A.resultIndex;z<A.results.length;++z){const me=A.results[z];me.isFinal?U+=me[0].transcript:T+=me[0].transcript}const oe=(U+T).trim();oe&&(Ce=!0,r(_e+(_e?" ":"")+oe))},S.onerror=A=>{console.error("Browser speech recognition error:",A.error),A.error!=="no-speech"&&p(P,`Error: ${A.error}`),Tt()},S.onend=()=>{p(a,!1),t(m)&&Ce&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50)},S.start(),navigator.vibrate&&navigator.vibrate(40)}catch(A){console.error("Failed to start browser speech recognition:",A),p(P,"Failed to start browser recording"),p(a,!1)}}function Tt(){if(S)try{S.stop()}catch{}p(a,!1)}async function qe(){try{const A=await navigator.mediaDevices.getUserMedia({audio:!0});ue=A,Le=[];const U=window.AudioContext||window.webkitAudioContext;Y=new U,ke=Y.createMediaStreamSource(A),Q=Y.createScriptProcessor(4096,1,1),Q.onaudioprocess=T=>{const oe=T.inputBuffer.getChannelData(0);Le.push(new Float32Array(oe))},ke.connect(Q),Q.connect(Y.destination),p(a,!0),p(l,!1),ut(),navigator.vibrate&&navigator.vibrate(40)}catch(A){console.error("Failed to start cloud audio recording:",A),p(P,A.message||"Microphone access denied",!0),p(a,!1),p(l,!1)}}function Xe(){if(t(a)){if(p(a,!1),p(l,!0),Q){try{Q.disconnect()}catch{}Q.onaudioprocess=null}if(ke)try{ke.disconnect()}catch{}if(ue)try{ue.getTracks().forEach(A=>A.stop())}catch{}yt()}}async function yt(){try{if(Le.length===0){p(l,!1);return}p(P,null);let A=0;for(const jt of Le)A+=jt.length;const U=new Float32Array(A);let T=0;for(const jt of Le)U.set(jt,T),T+=jt.length;const oe=Y?Y.sampleRate:48e3,z=16e3,me=Ge(U,oe,z),be=xt(me,1,z,1,16),ze=new Blob([be],{type:"audio/wav"}),Ue=Ie(),at=St(),pt=`${Ue}/session/transcribe${at?`?token=${encodeURIComponent(at)}`:""}`,Ne=await fetch(pt,{method:"POST",body:ze,headers:{"Content-Type":"application/octet-stream"}}),Oe=await Ne.json();if(!Ne.ok)throw new Error(Oe.error||`HTTP ${Ne.status}`);Oe.text&&Oe.text.trim()&&(Ce=!0,r(_e+(_e?" ":"")+Oe.text.trim()),t(m)&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50))}catch(A){console.error("Cloud transcription request failed:",A),p(P,A.message||"Cloud API failed",!0)}finally{if(p(l,!1),Y){try{Y.close()}catch{}Y=null}}}function rt(){e.disabled||t(a)||t(l)||(p(P,null),Ce=!1,_e=r(),t(I)==="cloud"?qe():we())}function ft(){t(I)==="cloud"?Xe():Tt()}function wt(A){if(A.button===0&&!e.disabled){if(A.preventDefault(),t(a)){ft();return}p(c,!1),p(N,setTimeout(()=>{p(c,!0),rt()},350),!0)}}function st(A){t(N)&&(clearTimeout(t(N)),p(N,null)),t(c)?(p(c,!1),ft()):t(a)||rt()}function te(){t(N)&&(clearTimeout(t(N)),p(N,null)),t(c)&&(p(c,!1),ft())}function xt(A,U,T,oe,z){const me=new ArrayBuffer(44+A.length*2),be=new DataView(me);return ot(be,0,"RIFF"),be.setUint32(4,36+A.length*2,!0),ot(be,8,"WAVE"),ot(be,12,"fmt "),be.setUint32(16,16,!0),be.setUint16(20,oe,!0),be.setUint16(22,U,!0),be.setUint32(24,T,!0),be.setUint32(28,T*U*(z/8),!0),be.setUint16(32,U*(z/8),!0),be.setUint16(34,z,!0),ot(be,36,"data"),be.setUint32(40,A.length*2,!0),Ee(be,44,A),me}function Ee(A,U,T){for(let oe=0;oe<T.length;oe++,U+=2){let z=Math.max(-1,Math.min(1,T[oe]));A.setInt16(U,z<0?z*32768:z*32767,!0)}}function ot(A,U,T){for(let oe=0;oe<T.length;oe++)A.setUint8(U+oe,T.charCodeAt(oe))}var At=vu(),vt=u(At),Te=f(vt,2),an=u(Te);d(Te);var ee=f(Te,2);{var ce=A=>{var U=bu(),T=Wt(U),oe=f(T,2),z=f(u(oe),2),me=f(u(z),2),be=u(me),ze=f(be,2);d(me);var Ue=f(me,2),at=u(Ue,!0);d(Ue),d(z);var pt=f(z,2);{var Ne=Dt=>{var Et=pu(),Ke=f(u(Et),2);_n(Ke,21,()=>fe,Pn,(en,Kt)=>{var tn=fu(),Tn=u(tn,!0);d(tn);var ie={};H(()=>{J(Tn,t(Kt).label),ie!==(ie=t(Kt).code)&&(tn.value=(tn.__value=t(Kt).code)??"")}),h(en,tn)}),d(Ke),d(Et),W("change",Ke,Me),Gr(Ke,()=>t(x),en=>p(x,en)),h(Dt,Et)};E(pt,Dt=>{t(I)==="browser"&&Dt(Ne)})}var Oe=f(pt,2),jt=u(Oe),Vt=u(jt);nt(Vt),lt(2),d(jt),lt(2),d(Oe);var hn=f(Oe,2);{var bn=Dt=>{var Et=hu(),Ke=u(Et,!0);d(Et),H(()=>J(Ke,t(P))),h(Dt,Et)};E(hn,Dt=>{t(P)&&Dt(bn)})}d(oe),H(()=>{be.disabled=!o,rn(be,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors disabled:opacity-40
|
|
78
|
+
${t(I)==="browser"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),rn(ze,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"}`),J(at,t(I)==="browser"?"Uses free built-in browser dictation. Streaming, zero-latency.":"Uses server-side Z.ai / Groq / OpenAI keys. High accent tolerance.")}),W("click",T,()=>p(_,!1)),W("click",be,()=>{p(I,"browser"),Me()}),W("click",ze,()=>{p(I,"cloud"),Me()}),W("change",Vt,Me),On(Vt,()=>t(m),Dt=>p(m,Dt)),h(A,U)};E(ee,A=>{t(_)&&A(ce)})}d(At),H(()=>{vt.disabled=e.disabled&&!t(a)&&!t(l)||t(l),rn(vt,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"}`),ge(vt,"title",t(a)?"Recording (release/tap to stop)...":t(l)?"Processing speech...":"Hold to speak (walkie-talkie) or Tap to toggle recording"),Te.disabled=e.disabled&&!t(a)&&!t(l)||t(l),rn(an,0,`h-4 w-4 transition-transform duration-200 ${t(_)?"rotate-45 text-white":""}`)}),W("pointerdown",vt,wt),W("pointerup",vt,st),ir("pointercancel",vt,te),W("click",Te,()=>p(_,!t(_))),h(n,At),cr()}xr(["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){lr(e,!0);const r=()=>$e(so,"$isStreaming",c),s=()=>$e(us,"$isReadOnly",c),o=()=>$e(Yr,"$activeSessionInfo",c),a=()=>$e(Kr,"$isConnected",c),l=()=>$e(Lt,"$piState",c),[c,_]=Cr();let m=br(e,"showAttach",3,!0),x=br(e,"searchMode",3,!1),I=br(e,"searchConfigured",3,!1),P=br(e,"searchModels",19,()=>[]),N=br(e,"searchModel",15,""),S=G(""),Y=G(!0),ke=G(!1),Q=G(void 0),ue=G(Mn([])),Le=V(r),_e=V(s),Ce=V(o),fe=V(a),Me=V(l),Ie=V(()=>x()?e.disabled||!t(fe)||!I():e.disabled||!t(fe)||t(_e)||!t(Ce).sessionId),St=V(()=>t(ue).some(ee=>ee.uploading)),ut=V(()=>!t(Ie)&&!t(St)&&(t(S).trim().length>0||t(ue).length>0)),Ge=G(void 0);const we="wherever-draft:";let Tt=V(()=>we+(t(Ce).sessionId??"search")),qe=G(null);qr(()=>{const ee=localStorage.getItem("wherever-enter-to-send");ee!==null&&p(Y,ee==="true")}),Pt(()=>{const ee=t(Tt);ee!==t(qe)&&Vs(()=>{let ce=null;if(typeof localStorage<"u")try{ce=localStorage.getItem(ee)}catch{}p(S,ce??"",!0),p(qe,ee,!0)})}),Pt(()=>{const ee=t(S),ce=t(Tt);if(!(ce!==t(qe)||typeof localStorage>"u"))try{ee.trim().length>0?localStorage.setItem(ce,ee):localStorage.removeItem(ce)}catch{}});function Xe(){t(ke)&&p(ke,!1),t(Ge)?.focus()}function yt(){p(Y,!t(Y)),localStorage.setItem("wherever-enter-to-send",String(t(Y)))}Pt(()=>{t(Ge)&&(t(S),t(Ge).style.height="auto",t(Ge).style.height=`${t(Ge).scrollHeight}px`)}),Pt(()=>{!t(Ie)&&t(Ge)&&t(Ge).focus()});async function rt(ee){no();const ce=ee.target;if(!ce.files)return;const A=Array.from(ce.files);ce.value="";const U=t(ue).length;p(ue,[...t(ue),...A.map(T=>({name:T.name,uploading:!0}))],!0);for(let T=0;T<A.length;T++){const oe=A[T],z=U+T;try{if(!t(Ce).sessionId)throw new Error("No active session");const me=await Wa(t(Ce).sessionId,oe);p(ue,t(ue).map((be,ze)=>ze===z?{name:oe.name,path:me.savedPath,uploading:!1}:be),!0)}catch(me){const be=me.message||"Failed to upload";console.error("File upload error details:",me);let ze="";try{const Ue=Fn(),at=Un();ze=`${Ue}/health${at?`?token=${encodeURIComponent(at)}`:""}`}catch{}p(ue,t(ue).map((Ue,at)=>at===z?{name:oe.name,error:be,url:ze,uploading:!1}:Ue),!0)}}}function ft(ee){p(ue,t(ue).filter((ce,A)=>A!==ee),!0)}function wt(){const ee=t(S).trim();if(x()){if(!ee||t(Ie))return;e.onSubmit?.(ee),p(S,""),e.onSend?.();return}if(!ee&&t(ue).length===0)return;let ce=ee;if(t(ue).length>0){const T=t(ue).filter(oe=>oe.path);if(T.length>0){const oe=T.map(z=>`[Uploaded file: ${z.path}]`).join(`
|
|
81
81
|
`);ce?ce+=`
|
|
82
82
|
|
|
83
83
|
`+oe:ce=`I have uploaded the following file(s) for you:
|
|
84
|
-
${oe}`}}if(ee.startsWith("/")&&t(ue).length===0){const T=ee.toLowerCase();if(T==="/new"||T==="/reset"){if(t(Ce).cwd){jn(t(Ce).cwd,t(Ce).model||void 0),p(S,"");return}}else if(T==="/clear"){Ea(),p(S,"");return}else if(T==="/leave"||T==="/exit"){Dn(),p(S,"");return}}const A=uu({streaming:t(Le),connected:t(fe),agentPending:t(Me).agentPending,readOnly:t(_e),hasSession:!!t(Ce).sessionId});if(A.action!=="send"){(A.reason==="disconnected"||A.reason==="agent-pending")&&Us(ce);return}Us(ce)&&(p(S,""),p(ue,[],!0),e.onSend?.())}function st(ee){ee.key==="Enter"&&(t(Y)?ee.shiftKey||(ee.preventDefault(),wt()):ee.shiftKey&&(ee.preventDefault(),wt()))}var te={focusInput:Xe},xt=Pu(),Ee=u(xt);{var ot=ee=>{var ce=yu(),A=u(ce);{var U=z=>{var me=gu();lt(2),h(z,me)},T=z=>{var me=xu(),be=f(Wt(me),2),ze=u(be,!0);d(be),H(()=>Q(ze,t(Me).error)),h(z,me)},oe=z=>{var me=_u();lt(2),h(z,me)};E(A,z=>{t(Me).connecting?z(U):t(Me).error?z(T,1):t(fe)||z(oe,2)})}d(ce),h(ee,ce)};E(Ee,ee=>{(!t(fe)||t(Me).connecting||t(Me).error)&&ee(ot)})}var At=f(Ee,2);{var vt=ee=>{var ce=wu(),A=u(ce),U=u(A),T=u(U),oe=u(T,!0);d(T);var z=f(T,2),me=u(z);{var be=Ne=>{var Oe=xn();H(()=>Q(Oe,e.placeholder??"Search the web...")),h(Ne,Oe)},ze=Ne=>{var Oe=xn("Agent is working, tap to Steer...");h(Ne,Oe)},Ue=Ne=>{var Oe=xn("Read-only mode");h(Ne,Oe)},at=Ne=>{var Oe=xn("Select a session first...");h(Ne,Oe)},pt=Ne=>{var Oe=xn("Tap to type a message...");h(Ne,Oe)};E(me,Ne=>{x()?Ne(be):t(Le)?Ne(ze,1):t(_e)?Ne(Ue,2):t(Ce).sessionId?Ne(pt,-1):Ne(at,3)})}d(z),d(U),lt(2),d(A),d(ce),H(()=>Q(oe,x()?"🔍":"💬")),W("click",A,()=>{p(ke,!1),setTimeout(()=>t(Ge)?.focus(),50)}),h(ee,ce)},Te=ee=>{var ce=Du(),A=Wt(ce);{var U=ie=>{var it=Cu();_n(it,21,()=>t(ue),Pn,(Ot,kt,mt)=>{var nn=Eu(),Yt=u(nn),yn=u(Yt,!0);d(Yt);var wn=f(Yt,2);{var Cn=Z=>{var xe=ku();h(Z,xe)},M=Z=>{var xe=Tu(),qt=u(xe),Ct=u(qt);d(qt);var Ut=f(qt,2);{var It=Nt=>{var Ft=Su();H(()=>ge(Ft,"href",t(kt).url)),h(Nt,Ft)};E(Ut,Nt=>{t(kt).url&&Nt(It)})}d(xe),H(()=>{ge(xe,"title",t(kt).error),Q(Ct,`⚠️ ${t(kt).error??""}`)}),h(Z,xe)},q=Z=>{var xe=Au();h(Z,xe)};E(wn,Z=>{t(kt).uploading?Z(Cn):t(kt).error?Z(M,1):Z(q,-1)})}var K=f(wn,2);d(nn),H(()=>{ge(Yt,"title",t(kt).name),Q(yn,t(kt).name)}),W("click",K,()=>ft(mt)),h(Ot,nn)}),d(it),h(ie,it)};E(A,ie=>{t(ue).length>0&&ie(U)})}var T=f(A,2);{var oe=ie=>{var it=Ru(),Ot=f(u(it),2);_n(Ot,21,O,Pn,(kt,mt)=>{var nn=Iu(),Yt=u(nn,!0);d(nn);var yn={};H(()=>{Q(Yt,t(mt).label),yn!==(yn=t(mt).value)&&(nn.value=(nn.__value=t(mt).value)??"")}),h(kt,nn)}),d(Ot),d(it),H(()=>Ot.disabled=t(Ie)),Gr(Ot,N),h(ie,it)};E(T,ie=>{x()&&O().length>0&&ie(oe)})}var z=f(T,2),me=u(z),be=u(me);Li(be),ge(be,"rows",1),qn(be,ie=>p(Ge,ie),()=>t(Ge)),d(me);var ze=f(me,2),Ue=u(ze);{var at=ie=>{var it=$u(),Ot=Wt(it),kt=f(Ot,2);qn(kt,mt=>p(J,mt),()=>t(J)),H(()=>Ot.disabled=t(Ie)),W("click",Ot,()=>{ga(),t(J)?.click()}),W("change",kt,rt),h(ie,it)};E(Ue,ie=>{g()&&!x()&&ie(at)})}var pt=f(Ue,2),Ne=u(pt);mu(Ne,{get disabled(){return t(Ie)},onSend:wt,get text(){return t(S)},set text(ie){p(S,ie,!0)}}),d(pt);var Oe=f(pt,2),jt=u(Oe);{var Vt=ie=>{var it=xn();H(()=>Q(it,e.submitLabel??"Search")),h(ie,it)},hn=ie=>{var it=xn("Steer");h(ie,it)},bn=ie=>{var it=xn("Send");h(ie,it)};E(jt,ie=>{x()?ie(Vt):t(Le)?ie(hn,1):ie(bn,-1)})}d(Oe),d(ze),d(z);var Dt=f(z,2),Et=u(Dt),Ke=u(Et);nt(Ke),lt(2),d(Et);var en=f(Et,2),Kt=u(en),tn=f(Kt,2);{var Tn=ie=>{var it=Mu();h(ie,it)};E(tn,ie=>{t(Y)||ie(Tn)})}d(en),d(Dt),H(()=>{be.disabled=t(Ie),ge(be,"placeholder",x()?e.placeholder??"Search the web...":t(fe)?t(Le)?"Agent is working, Steer to interrupt...":t(_e)?"Read-only mode":t(Ce).sessionId?"Type a message...":"Select a session first...":t(Me).connecting?"Reconnecting to remote server...":"Disconnected - cannot send"),Oe.disabled=!t(ut),ge(Oe,"title",!x()&&t(Le)?"Steer the agent now (injected at the next step, before the next model call)":void 0),ra(Ke,t(Y))}),ir("submit",z,ie=>{ie.preventDefault(),wt()}),W("keydown",be,st),Ln(be,()=>t(S),ie=>p(S,ie)),W("change",Ke,yt),W("click",Kt,()=>p(ke,!0)),h(ee,ce)};E(At,ee=>{t(ke)?ee(vt):ee(Te,-1)})}d(xt),h(n,xt);var an=cr(te);return _(),an}xr(["click","keydown","change"]);var Ou=m('<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=m('<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=m('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),Uu=m('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),zu=m("<option> </option>"),Bu=m('<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=m('<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=m('<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=m('<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=m('<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=m('<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=m('<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=m('<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=m('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),Zu=m('<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=m('<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=m('<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=m('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),ef=m('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),tf=m('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),nf=m('<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=m('<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=m('<div class="flex-shrink-0"><!></div>'),of=m('<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=m('<div class="px-3 pb-2"><!> <!></div>'),lf=m('<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=m("<option> </option>"),df=m('<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=m('<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=m('<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=m('<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=m('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),bf=m('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),vf=m('<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=m('<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=m('<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=m('<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 Jo(n,e){lr(e,!0);const r=()=>$e(Nr,"$readOnlySessionFolders",R),s=()=>$e(Ar,"$sessionFolders",R),o=()=>$e(Yr,"$activeSessionInfo",R),a=()=>$e(Kr,"$isConnected",R),l=()=>$e(fs,"$isLoadingSession",R),c=()=>$e(ao,"$isResyncing",R),_=()=>$e(Er,"$availableModels",R),g=()=>$e(Zs,"$gitInitDefaultStore",R),x=()=>$e(oo,"$sessionError",R),[R,O]=Cr(),N=[];let S=br(e,"readOnly",3,!1),Y=V(()=>S()?r().folders:s().folders),ke=V(()=>S()?r().loading:s().loading);function J(){S()?la():Br()}let ue=V(()=>o().sessionFile),Le=V(a),_e=V(l),Ce=V(c),fe=V(()=>_().models),Me=Mn({}),Ie=G(Mn({})),St=G(null),ut=G(null),Ge=G(""),we=G(Mn([]));Pt(()=>{t(Le)&&(J(),S()||(sl(),al()))});function Tt(M,q,K){if(!K)return!0;const Z=K.toLowerCase();return(M.name||"").toLowerCase().includes(Z)||M.firstMessage.toLowerCase().includes(Z)||q.toLowerCase().includes(Z)}Pt(()=>{const M=t(Ge),q=t(Y);M?p(we,q.map(K=>({...K,sessions:K.sessions.filter(Z=>Tt(Z,K.name,M))})).filter(K=>K.sessions.length>0),!0):(p(we,q,!0),p(Ie,{},!0))});function qe(M){return t(Ge)?t(Ie)[M]!==void 0?t(Ie)[M]:!0:!!Me[M]}function Xe(M){t(Ge)?t(Ie)[M]=!qe(M):Me[M]=!qe(M)}async function yt(M){try{t(ue)===M&&(typeof window<"u"&&(window.location.hash=""),Dn()),await Bs(M),t(St)===M&&p(St,null),Br()}catch(q){console.error("Failed to delete session:",q)}}async function rt(M){try{const q=M.sessions.map(K=>K.path);t(ue)&&q.includes(t(ue))&&(typeof window<"u"&&(window.location.hash=""),Dn()),await Promise.all(M.sessions.map(K=>Bs(K.path))),t(ut)===M.path&&p(ut,null),Br()}catch(q){console.error("Failed to delete all sessions of folder:",q)}}function ft(M){t(ue)===M&&!t(_e)&&!t(Ce)||(mr(),ro(M))}let wt=G(!1),st=G(""),te=G(Mn([])),xt=G(!1),Ee=G(null),ot=G(null),At="",vt=G(""),Te=G(!1),an=G(null),ee=G(!0),ce=G("private"),A=G(!1),U=V(g);Pt(()=>{t(an)===null&&p(Te,t(U),!0)});let T=G(Mn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),oe=V(()=>t(T).exists!==!0&&t(T).matchingRule&&t(ee)),z=null;async function me(M,q=!1){if(z&&clearTimeout(z),M===At&&!q)return;if(At=M,!M.trim()){p(T,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const Z=async()=>{const xe=await ss("");p(te,xe||[],!0)};q?await Z():z=setTimeout(Z,300);return}const K=async()=>{const[Z,xe]=await Promise.all([fa(M),ss(M)]);p(te,xe||[],!0),Z?(p(T,{exists:Z.exists,isGit:Z.isGit,resolvedPath:Z.resolvedPath,matchingRule:Z.matchingRule||null},!0),Z.exists||(p(Te,t(an)!==null?t(an):t(U),!0),p(ee,!0),Z.matchingRule&&p(ce,Z.matchingRule.visibility,!0))):p(T,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};q?await K():z=setTimeout(K,300)}Pt(()=>{const M=t(st);me(M,!1)}),Pt(()=>{if(t(fe).length>0&&!t(vt)){const M=t(fe).find(q=>q.isDefault);M?p(vt,`${M.provider}:${M.modelId}`):p(vt,`${t(fe)[0].provider}:${t(fe)[0].modelId}`)}});function be(){if(t(st).trim())if(t(T).exists===!0)p(Te,!1),p(ee,!1),t(T).matchingRule&&p(ce,t(T).matchingRule.visibility,!0),p(A,!0);else{mr();const M=t(st).trim(),q=t(vt)||void 0,K=t(Te),Z=t(T).matchingRule?t(ee):void 0,xe=t(T).matchingRule?t(ce):void 0;p(st,""),p(wt,!1),t(ue)?(Dn(),setTimeout(()=>{jn(M,q,K,Z,xe)},100)):jn(M,q,K,Z,xe)}}function ze(){p(A,!1),mr();const M=t(st).trim(),q=t(vt)||void 0,K=t(Te),Z=t(T).matchingRule?t(ee):void 0,xe=t(T).matchingRule?t(ce):void 0;p(st,""),p(wt,!1),t(ue)?(Dn(),setTimeout(()=>{jn(M,q,K,Z,xe)},100)):jn(M,q,K,Z,xe)}let Ue=G(Mn({open:!1,folderPath:"",selected:""}));function at(M){const q=t(fe).find(K=>K.isDefault);p(Ue,{open:!0,folderPath:M,selected:q?`${q.provider}:${q.modelId}`:""},!0)}function pt(){t(Ue).open=!1}function Ne(){if(!t(Ue).open)return;mr();const M=t(Ue).folderPath,q=t(Ue).selected||void 0;pt(),t(ue)?(Dn(),setTimeout(()=>{jn(M,q)},100)):jn(M,q)}function Oe(M){const q=Date.now()-new Date(M).getTime(),K=Math.floor(q/6e4);if(K<1)return"just now";if(K<60)return`${K}m ago`;const Z=Math.floor(K/60);return Z<24?`${Z}h ago`:`${Math.floor(Z/24)}d ago`}function jt(M,q=40){return M.length>q?M.slice(0,q)+"...":M}var Vt=xf(),hn=Wt(Vt),bn=u(hn),Dt=u(bn),Et=u(Dt);nt(Et);var Ke=f(Et,2),en=u(Ke);d(Ke),d(Dt),d(bn);var Kt=f(bn,2),tn=u(Kt);{var Tn=M=>{var q=Vu(),K=u(q),Z=u(K),xe=u(Z,!0);d(Z),d(K);var qt=f(K,2);{var Ct=Ut=>{var It=qu(),Nt=u(It),Ft=f(u(Nt),2),zt=u(Ft);nt(zt),qn(zt,pe=>p(Ee,pe),()=>t(Ee));var ln=f(zt,2);{var $=pe=>{var se=Nu();_n(se,21,()=>t(te),Pn,(Se,v)=>{var w=Ou(),D=u(w,!0);d(w),H(()=>Q(D,t(v))),W("click",w,()=>{p(st,t(v),!0),me(t(v),!0),t(Ee)?.focus()}),h(Se,w)}),d(se),h(pe,se)};E(ln,pe=>{t(xt)&&t(te).length>0&&pe($)})}d(Ft),qn(Ft,pe=>p(ot,pe),()=>t(ot));var L=f(Ft,2);{var B=pe=>{var se=Uu(),Se=f(u(se));{var v=w=>{var D=Fu();h(w,D)};E(Se,w=>{t(T).isGit&&w(v)})}d(se),h(pe,se)};E(L,pe=>{t(T).exists===!0&&pe(B)})}d(Nt);var le=f(Nt,2),De=f(u(le),2);{var ve=pe=>{var se=Bu();_n(se,21,()=>t(fe),Pn,(Se,v)=>{var w=zu(),D=u(w);d(w);var P={};H(()=>{Q(D,`${t(v).label??""}${t(v).isDefault?" (default)":""}`),P!==(P=`${t(v).provider}:${t(v).modelId}`)&&(w.value=w.__value=`${t(v).provider}:${t(v).modelId}`)}),h(Se,w)}),d(se),Gr(se,()=>t(vt),Se=>p(vt,Se)),h(pe,se)},ae=pe=>{var se=Hu();nt(se),Ln(se,()=>t(vt),Se=>p(vt,Se)),h(pe,se)};E(De,pe=>{t(fe).length>0?pe(ve):pe(ae,-1)})}d(le);var Re=f(le,2);{var Pe=pe=>{var se=Gu(),Se=u(se),v=u(Se);nt(v);var w=f(v,2),D=u(w);d(w),d(Se);var P=f(Se,2);{var re=X=>{var k=Wu(),de=f(u(k),2),ye=u(de);nt(ye),ye.value=ye.__value="private",lt(),d(de);var Be=f(de,2),et=u(Be);nt(et),et.value=et.__value="public",lt(),d(Be),d(k),ar(N,[],ye,()=>t(ce),he=>p(ce,he)),ar(N,[],et,()=>t(ce),he=>p(ce,he)),h(X,k)};E(P,X=>{t(ee)&&X(re)})}d(se),H(()=>Q(D,`Create remote ${t(T).matchingRule.provider??""} repository`)),On(v,()=>t(ee),X=>p(ee,X)),h(pe,se)};E(Re,pe=>{t(T).exists!==!0&&t(T).matchingRule&&pe(Pe)})}var _t=f(Re,2);{var Bt=pe=>{var se=ju(),Se=u(se);nt(Se),lt(2),d(se),W("change",Se,v=>{p(an,v.currentTarget.checked,!0)}),On(Se,()=>t(Te),v=>p(Te,v)),h(pe,se)};E(_t,pe=>{t(T).exists!==!0&&(!t(T).matchingRule||!t(ee))&&pe(Bt)})}var bt=f(_t,2);d(It),H(pe=>{rn(zt,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(oe)?"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"}`),bt.disabled=pe},[()=>!t(st).trim()]),ir("submit",It,pe=>{pe.preventDefault(),be()}),ir("focus",zt,()=>{p(xt,!0),me(t(st),!0)}),ir("blur",zt,pe=>{t(ot)&&t(ot).contains(pe.relatedTarget)||p(xt,!1)}),W("keydown",zt,pe=>{pe.key==="Escape"&&p(xt,!1)}),Ln(zt,()=>t(st),pe=>p(st,pe)),h(Ut,It)};E(qt,Ut=>{t(wt)&&Ut(Ct)})}d(q),H(()=>Q(xe,t(wt)?"▼ Close Create Session":"✚ Create New Session")),W("click",K,()=>p(wt,!t(wt))),h(M,q)};E(tn,M=>{S()||M(Tn)})}var ie=f(tn,2);{var it=M=>{var q=Ku();h(M,q)},Ot=M=>{var q=Yu(),K=u(q,!0);d(q),H(()=>Q(K,t(Ge)?"No sessions match your filter":"No sessions found")),h(M,q)},kt=M=>{var q=Zn(),K=Wt(q);_n(K,17,()=>t(we),Z=>Z.path,(Z,xe)=>{var qt=lf(),Ct=u(qt),Ut=u(Ct),It=f(Ut,2),Nt=u(It),Ft=u(Nt,!0);d(Nt);var zt=f(Nt,2),ln=u(zt,!0);d(zt),d(It);var $=f(It,2),L=u($,!0);d($),d(Ct);var B=f(Ct,2);{var le=ve=>{var ae=af(),Re=u(ae);{var Pe=Bt=>{var bt=Qu(),pe=u(bt),se=f(pe,2),Se=u(se);{var v=D=>{var P=Zu(),re=u(P),X=f(re,2);d(P),W("click",re,k=>{k.stopPropagation(),rt(t(xe))}),W("click",X,k=>{k.stopPropagation(),p(ut,null)}),h(D,P)},w=D=>{var P=Xu();W("click",P,re=>{re.stopPropagation(),p(ut,t(xe).path,!0)}),h(D,P)};E(Se,D=>{t(ut)===t(xe).path?D(v):D(w,-1)})}d(se),d(bt),W("click",pe,()=>at(t(xe).path)),h(Bt,bt)};E(Re,Bt=>{S()||Bt(Pe)})}var _t=f(Re,2);_n(_t,17,()=>t(xe).sessions,Bt=>Bt.path,(Bt,bt)=>{var pe=of(),se=u(pe),Se=u(se);{var v=he=>{var He=Ju();h(he,He)},w=he=>{var He=ef();h(he,He)};E(Se,he=>{t(bt).isActive?he(v):he(w,-1)})}var D=f(Se,2),P=u(D),re=u(P,!0);d(P);var X=f(P,2),k=u(X);d(X),d(D);var de=f(D,2);{var ye=he=>{var He=tf(),Zt=u(He,!0);d(He),H(()=>Q(Zt,t(bt).clientCount)),h(he,He)};E(de,he=>{t(bt).clientCount>0&&he(ye)})}d(se);var Be=f(se,2);{var et=he=>{var He=sf(),Zt=u(He);{var Xt=We=>{var Ye=nf(),Ve=u(Ye),gt=f(Ve,2);d(Ye),W("click",Ve,Rt=>{Rt.stopPropagation(),yt(t(bt).path)}),W("click",gt,Rt=>{Rt.stopPropagation(),p(St,null)}),h(We,Ye)},Ht=We=>{var Ye=rf();W("click",Ye,Ve=>{Ve.stopPropagation(),p(St,t(bt).path,!0)}),h(We,Ye)};E(Zt,We=>{t(St)===t(bt).path?We(Xt):We(Ht,-1)})}d(He),h(he,He)};E(Be,he=>{S()||he(et)})}d(pe),H((he,He,Zt)=>{rn(pe,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(ue)===t(bt).path?"bg-brand-surface-3":""}`),ge(se,"href",`#${he??""}`),Q(re,He),Q(k,`${Zt??""} · ${t(bt).messageCount??""}
|
|
85
|
-
msgs`)},[()=>encodeURIComponent(t(bt).id),()=>t(bt).name||jt(t(bt).firstMessage)||"Empty session",()=>Oe(t(bt).modified)]),W("click",se,he=>{he.button===0&&!he.ctrlKey&&!he.metaKey&&!he.altKey&&!he.shiftKey&&(he.preventDefault(),ft(t(bt).path))}),h(Bt,pe)}),d(ae),h(ve,ae)},De=V(()=>qe(t(xe).path));E(B,ve=>{t(De)&&ve(le)})}d(qt),H(ve=>{rn(Ut,1,`text-xs text-brand-text-muted transition-transform ${ve??""}`),
|
|
86
|
-
stored.</p> <pre class="mb-4 overflow-x-auto rounded-lg bg-brand-surface-3 px-3 py-2 font-mono text-xs text-brand-text"> </pre> <input type="password" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" placeholder="Password" class="mb-4 w-full rounded-lg border border-brand-border bg-brand-surface-3 px-3 py-2.5 text-sm text-brand-text outline-none focus:border-brand-blue"/> <div class="flex gap-3"><button class="flex-1 rounded-lg bg-brand-surface-3 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button class="flex-1 rounded-lg bg-brand-blue px-4 py-2.5 text-sm text-brand-text transition-colors hover:opacity-90">Run</button></div></div></div>`);function yf(n,e){lr(e,!0);const r=()=>$e(Na,"$sudoPrompt",s),[s,o]=Cr();let a=V(r),l=G(""),c=G(null),_=G(null);Pt(()=>{const Y=t(a)?.promptId??null;Y!==t(_)&&(p(_,Y,!0),p(l,""),Y&&queueMicrotask(()=>t(c)?.focus()))});function g(){t(a)&&(Ra(t(l)),p(l,""))}function x(){$a(),p(l,"")}function R(Y){Y.key==="Enter"?(Y.preventDefault(),g()):Y.key==="Escape"&&(Y.preventDefault(),x())}var O=Zn(),N=Wt(O);{var S=Y=>{var ke=_f(),J=u(ke),ue=f(u(J),4),Le=u(ue,!0);d(ue);var _e=f(ue,2);nt(_e),qn(_e,Ie=>p(c,Ie),()=>t(c));var Ce=f(_e,2),fe=u(Ce),Me=f(fe,2);d(Ce),d(J),d(ke),H(()=>Q(Le,t(a).command)),W("keydown",_e,R),Ln(_e,()=>t(l),Ie=>p(l,Ie)),W("click",fe,x),W("click",Me,g),h(Y,ke)};E(N,Y=>{t(a)&&Y(S)})}h(n,O),cr(),o()}xr(["keydown","click"]);function wf(n){return n.loading||n.resyncing||n.hasSessionHash}function kf(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!wf(n)}var Sf=m('<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>'),Tf=m('<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),Af=m('<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),Ef=m('<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>'),Cf=m('<div class="truncate text-xs text-brand-text-muted"> </div>'),If=m('<div class="truncate text-xs text-brand-text-muted"> </div>'),Rf=m('<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>'),$f=m('<div class="mt-2 text-xs text-rose-400"> </div>'),Mf=m('<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>'),Df=m('<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>'),Pf=m('<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),Lf=m('<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>'),Of=m('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Nf=m('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),Ff=m('<span class="text-sm text-brand-text-muted">Not connected</span>'),Uf=m('<div class="flex min-w-0 items-center gap-2"><!></div>'),zf=m('<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>'),Bf=m("<option> </option>"),Hf=m('<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>'),Wf=m('<span class="truncate text-brand-text-muted"> </span>'),Gf=m('<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>'),jf=m('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),qf=m('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),Vf=m('<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>'),Kf=m('<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>'),Yf=m('<button class="flex-shrink-0 rounded-md border border-yellow-500/40 bg-yellow-500/20 px-3 py-1 text-xs font-medium text-yellow-300 transition-colors hover:bg-yellow-500/30">Continue anyway</button>'),Zf=m('<div class="flex items-center justify-between gap-3 border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-sm text-yellow-400"><span class="min-w-0 flex-1 break-words">⚠️ Another client is active in this folder. <!></span> <!></div>'),Xf=m('<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=m('<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=m('<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=m('<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=m('<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=m("<!> <!>",1),rp=m('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),sp=m('<!> <!> <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){lr(e,!0);const r=()=>$e(Kr,"$isConnected",J),s=()=>$e(ao,"$isResyncing",J),o=()=>$e(Ua,"$isAgentPending",J),a=()=>$e(fs,"$isLoadingSession",J),l=()=>$e(La,"$isInterrupted",J),c=()=>$e(oo,"$sessionError",J),_=()=>$e(Oa,"$sessionNotice",J),g=()=>$e(Pa,"$folderConflict",J),x=()=>$e(us,"$isReadOnly",J),R=()=>$e(Yr,"$activeSessionInfo",J),O=()=>$e(Lt,"$piState",J),N=()=>$e(Er,"$availableModels",J),S=()=>$e(Fa,"$isCreatingSession",J),Y=()=>$e(Xs,"$searchFolderStore",J),ke=()=>$e(ua,"$searchDefaultModelStore",J),[J,ue]=Cr();let Le=G(!1),_e=G("main"),Ce=G(!1),fe;qr(()=>{setTimeout(()=>vr(),200);const $=()=>{if(t(we)){const ve=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";ve&&ve!==t(At)?ro(ve):!ve&&t(At)&&Dn()}};window.addEventListener("hashchange",$);let L=null;const B=8e3,le=()=>{if(document.visibilityState==="hidden"){if(xa())return;L&&clearTimeout(L),L=setTimeout(()=>{L=null,document.visibilityState==="hidden"&&t(we)&&ma()},B)}else no(),L&&(clearTimeout(L),L=null),t(we)||(Fs()?Ns():vr())},De=ve=>{L&&(clearTimeout(L),L=null),document.visibilityState!=="hidden"&&!t(we)&&(Fs()?Ns():vr())};return document.addEventListener("visibilitychange",le),window.addEventListener("pageshow",De),()=>{window.removeEventListener("hashchange",$),document.removeEventListener("visibilitychange",le),window.removeEventListener("pageshow",De),L&&clearTimeout(L)}});function Me(){vr()}function Ie(){Dn(),jr()}function St(){jr(),setTimeout(()=>vr(),100)}function ut(){Br()}function Ge(){typeof window<"u"&&(window.location.hash=""),Dn(),p(Le,!1)}let we=V(r),Tt=V(s),qe=V(o),Xe=V(a),yt=V(l),rt=V(c),ft=V(_),wt=V(g),st=V(x),te=V(R),xt=V(O),Ee=V(()=>N().models),ot=G(!1),At=V(()=>t(te).sessionId);Pt(()=>{typeof window<"u"&&t(we)&&(t(At)?(window.location.hash=encodeURIComponent(t(At)),p(ot,!0)):t(ot)&&(p(ot,!1),window.location.hash&&(window.location.hash="")))});let vt=null;Pt(()=>{if(!t(we)||typeof window>"u"||!window.location.hash)return;const $=decodeURIComponent(window.location.hash.slice(1));$&&(t(At)===$||t(Xe)||t(Tt)||vt||(vt=setTimeout(()=>{vt=null,!(t(At)===$||t(Xe)||t(Tt))&&ka($)},300)))}),Pt(()=>{t(we)||p(ot,!1)}),Pt(()=>{(t(At)||t(Xe)||t(Tt))&&p(Le,!1)});let Te=V(S),an=V(Y),ee=G(void 0),ce=V(()=>kf({connected:t(we),searchConfigured:!!t(an),hasSession:!!t(te).sessionFile,loading:t(Xe),resyncing:t(Tt),hasSessionHash:typeof window<"u"&&!!window.location.hash})),A=V(()=>t(Ee).map($=>({value:`${$.provider}:${$.modelId}`,label:`${$.label}${$.isDefault?" (default)":""}`}))),U=V(ke),T=G("");Pt(()=>{if(t(A).length===0||t(A).some(le=>le.value===t(T)))return;const L=t(A).find(le=>le.value===t(U)),B=t(Ee).find(le=>le.isDefault);p(T,L?L.value:B?`${B.provider}:${B.modelId}`:t(A)[0].value,!0)});let oe=G(!1);Pt(()=>{t(ce)&&!t(oe)&&t(ee)&&(p(oe,!0),t(ee).focusInput())});function z(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),Dn(),t(ee)?.focusInput()}var me=sp(),be=Wt(me);Zi(be,{title:"Wherever",description:"Create & maintain apps from wherever"});var ze=f(be,2);{var Ue=$=>{var L=Sf();h($,L)};E(ze,$=>{t(Te)&&$(Ue)})}var at=f(ze,2),pt=u(at),Ne=u(pt),Oe=u(Ne),jt=u(Oe);{var Vt=$=>{var L=Tf(),B=f(Wt(L),2);W("click",B,()=>p(Ce,!1)),h($,L)},hn=$=>{var L=Af(),B=Wt(L),le=u(B);lt(2),d(B);var De=f(B,2),ve=u(De),ae=f(ve,2);d(De),H(Re=>ge(le,"src",Re),[()=>Tr("/logo.svg")]),W("click",B,Ge),W("click",ve,()=>p(Ce,!0)),W("click",ae,()=>p(Le,!1)),h($,L)};E(jt,$=>{t(Ce)?$(Vt):$(hn,-1)})}d(Oe),d(Ne);var bn=f(Ne,2);{var Dt=$=>{var L=Ef(),B=u(L);{let Pe=V(()=>(t(xt).connected,"localhost"));Tl(B,{get host(){return t(Pe)},port:31415,token:"",onConnected:Me})}var le=f(B,2),De=f(u(le),2),ve=u(De),ae=f(ve,2),Re=f(ae,2);d(De),d(le),d(L),W("click",ve,ut),W("click",ae,St),W("click",Re,Ie),h($,L)},Et=$=>{var L=Pf(),B=Wt(L),le=u(B),De=u(le),ve=f(De,2),ae=u(ve,!0);d(ve);var Re=f(ve,2),Pe=u(Re);d(Re),d(le);var _t=f(le,2);{var Bt=k=>{var de=Rf(),ye=u(de);{var Be=Xt=>{var Ht=Cf(),We=u(Ht);d(Ht),H(Ye=>{ge(Ht,"title",t(te).cwd),Q(We,`📁 ${Ye??""}`)},[()=>t(te).cwd.split("/").pop()||t(te).cwd]),h(Xt,Ht)};E(ye,Xt=>{t(te).cwd&&Xt(Be)})}var et=f(ye,2);{var he=Xt=>{var Ht=If(),We=u(Ht);d(Ht),H(()=>{ge(Ht,"title",t(te).model),Q(We,`🤖 ${t(te).model??""}`)}),h(Xt,Ht)};E(et,Xt=>{t(te).model&&Xt(he)})}var He=f(et,2),Zt=u(He);d(He),d(de),W("click",Zt,Ge),h(k,de)};E(_t,k=>{t(te).sessionFile&&k(Bt)})}var bt=f(_t,2);{var pe=k=>{var de=$f(),ye=u(de,!0);d(de),H(()=>Q(ye,t(xt).error)),h(k,de)};E(bt,k=>{t(xt).error&&!t(we)&&k(pe)})}d(B);var se=f(B,2),Se=u(se);{var v=k=>{var de=Mf();W("click",de,()=>{p(_e,"readonly"),la()}),h(k,de)},w=k=>{var de=Df();W("click",de,()=>p(_e,"main")),h(k,de)};E(Se,k=>{t(_e)==="main"?k(v):k(w,-1)})}d(se);var D=f(se,2),P=u(D);{var re=k=>{Jo(k,{readOnly:!0})},X=k=>{Jo(k,{})};E(P,k=>{t(_e)==="readonly"?k(re):k(X,-1)})}d(D),H(()=>{rn(De,1,`h-2.5 w-2.5 rounded-full ${t(we)?"bg-emerald-500":"bg-rose-500"}`),rn(ve,1,`text-sm ${t(we)?"text-emerald-400":"text-rose-400"}`),Q(ae,t(we)?"Connected":"Disconnected"),Q(Pe,`v${sa}`)}),h($,L)};E(bn,$=>{t(Ce)?$(Dt):$(Et,-1)})}d(pt);var Ke=f(pt,2),en=u(Ke),Kt=u(en),tn=f(Kt,2);{var Tn=$=>{var L=Lf();W("click",L,z),h($,L)};E(tn,$=>{t(we)&&t(an)&&t(te).sessionFile&&$(Tn)})}var ie=f(tn,2);{var it=$=>{var L=Uf(),B=u(L);{var le=ae=>{var Re=Of();h(ae,Re)},De=ae=>{var Re=Nf();h(ae,Re)},ve=ae=>{var Re=Ff();h(ae,Re)};E(B,ae=>{t(we)&&t(ce)?ae(le):t(we)?ae(De,1):ae(ve,-1)})}d(L),h($,L)};E(ie,$=>{(!t(we)||!t(te).sessionFile)&&$(it)})}var Ot=f(ie,2);{var kt=$=>{var L=jf(),B=u(L);{var le=ae=>{var Re=zf(),Pe=f(u(Re),2),_t=u(Pe,!0);d(Pe),d(Re),H(Bt=>{ge(Pe,"title",t(te).cwd),Q(_t,Bt)},[()=>t(te).cwd.split("/").pop()||t(te).cwd]),h(ae,Re)};E(B,ae=>{t(te).cwd&&ae(le)})}var De=f(B,2);{var ve=ae=>{var Re=Gf(),Pe=u(Re),_t=f(u(Pe),2);d(Pe);var Bt=f(Pe,2);{var bt=se=>{var Se=Hf();_n(Se,21,()=>t(Ee),Pn,(w,D)=>{var P=Bf(),re=u(P,!0);d(P);var X={};H(()=>{Q(re,t(D).label),X!==(X=`${t(D).provider}:${t(D).modelId}`)&&(P.value=P.__value=`${t(D).provider}:${t(D).modelId}`)}),h(w,P)}),d(Se);var v;aa(Se),H(()=>{v!==(v=t(te).model)&&(Se.value=(Se.__value=t(te).model)??"",Ys(Se,t(te).model))}),W("input",Se,w=>Ma(w.currentTarget.value)),h(se,Se)},pe=se=>{var Se=Wf(),v=u(Se,!0);d(Se),H(()=>{ge(Se,"title",t(te).model),Q(v,t(te).model)}),h(se,Se)};E(Bt,se=>{t(Ee).length>0&&!t(st)?se(bt):se(pe,-1)})}d(Re),H(()=>{rn(_t,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(xt).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),ge(_t,"title",t(xt).isStreaming?"Agent working...":"Ready")}),h(ae,Re)};E(De,ae=>{t(te).model&&ae(ve)})}d(L),h($,L)};E(Ot,$=>{t(te).sessionFile&&$(kt)})}var mt=f(Ot,2);{var nn=$=>{var L=qf();h($,L)};E(mt,$=>{t(st)&&$(nn)})}d(en);var Yt=f(en,2);{var yn=$=>{var L=Vf();h($,L)};E(Yt,$=>{t(yt)&&$(yn)})}var wn=f(Yt,2);{var Cn=$=>{var L=Kf(),B=u(L),le=u(B,!0);d(B);var De=f(B,2);d(L),H(()=>{rn(L,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(ft).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),Q(le,t(ft).message)}),W("click",De,()=>Ia()),h($,L)};E(wn,$=>{t(ft)&&$(Cn)})}var M=f(wn,2);{var q=$=>{var L=Zf(),B=u(L),le=f(u(B));{var De=Pe=>{var _t=xn("You are both working in it — changes may conflict.");h(Pe,_t)},ve=Pe=>{var _t=xn("You are observing (read-only) to avoid clashing.");h(Pe,_t)};E(le,Pe=>{t(wt).continued?Pe(De):Pe(ve,-1)})}d(B);var ae=f(B,2);{var Re=Pe=>{var _t=Yf();W("click",_t,()=>Aa()),h(Pe,_t)};E(ae,Pe=>{t(wt).continued||Pe(Re)})}d(L),h($,L)};E(M,$=>{t(wt)?.active&&$(q)})}var K=f(M,2);{var Z=$=>{var L=Xf(),B=u(L),le=u(B,!0);d(B);var De=f(B,2);d(L),H(()=>Q(le,t(rt))),W("click",De,()=>mr()),h($,L)};E(K,$=>{t(rt)&&$(Z)})}var xe=f(K,2);{var qt=$=>{var L=Qf();h($,L)};E(xe,$=>{t(st)&&!t(yt)&&$(qt)})}var Ct=f(xe,2);qn(du(Ct,{onMessageSent:()=>{}}),$=>fe=$,()=>fe);var Ut=f(Ct,2);{var It=$=>{var L=Jf();h($,L)},Nt=$=>{var L=np(),B=Wt(L);{var le=ae=>{var Re=ep();h(ae,Re)},De=ae=>{var Re=tp();h(ae,Re)};E(B,ae=>{t(te).sessionFile&&(t(Tt)||!t(we))?ae(le):t(te).sessionFile&&t(qe)&&ae(De,1)})}var ve=f(B,2);{let ae=V(()=>!!t(an)),Re=V(()=>t(ce)?!t(we):!t(we)||t(st)||!t(te).sessionFile||t(Tt)||t(qe));qn(Lu(ve,{get searchMode(){return t(ce)},get searchConfigured(){return t(ae)},get searchModels(){return t(A)},onSubmit:Pe=>Sa(Pe,t(T)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(Re)},onSend:()=>fe?.forceScrollToBottom(),get searchModel(){return t(T)},set searchModel(Pe){p(T,Pe,!0)}}),Pe=>p(ee,Pe,!0),()=>t(ee))}h($,L)};E(Ut,$=>{t(st)&&t(te).sessionFile?$(It):$(Nt,-1)})}d(Ke);var Ft=f(Ke,2);yf(Ft,{});var zt=f(Ft,2);{var ln=$=>{var L=rp();W("click",L,()=>p(Le,!1)),h($,L)};E(zt,$=>{t(Le)&&$(ln)})}d(at),H(()=>rn(pt,1,`app-chrome ${t(Le)?"translate-x-0":"-translate-x-full"} fixed z-20 flex h-full w-72 flex-col border-r border-brand-border bg-brand-surface transition-transform duration-200 md:relative md:translate-x-0`)),W("click",Kt,()=>p(Le,!t(Le))),h(n,me),cr(),ue()}xr(["click","input"]);export{pp as component,fp as universal};
|
|
87
|
-
//# sourceMappingURL=2.
|
|
84
|
+
${oe}`}}if(ee.startsWith("/")&&t(ue).length===0){const T=ee.toLowerCase();if(T==="/new"||T==="/reset"){if(t(Ce).cwd){jn(t(Ce).cwd,t(Ce).model||void 0),p(S,"");return}}else if(T==="/clear"){Ea(),p(S,"");return}else if(T==="/leave"||T==="/exit"){Dn(),p(S,"");return}}const A=uu({streaming:t(Le),connected:t(fe),agentPending:t(Me).agentPending,readOnly:t(_e),hasSession:!!t(Ce).sessionId});if(A.action!=="send"){(A.reason==="disconnected"||A.reason==="agent-pending")&&Us(ce);return}Us(ce)&&(p(S,""),p(ue,[],!0),e.onSend?.())}function st(ee){ee.key==="Enter"&&(t(Y)?ee.shiftKey||(ee.preventDefault(),wt()):ee.shiftKey&&(ee.preventDefault(),wt()))}var te={focusInput:Xe},xt=Pu(),Ee=u(xt);{var ot=ee=>{var ce=yu(),A=u(ce);{var U=z=>{var me=gu();lt(2),h(z,me)},T=z=>{var me=xu(),be=f(Wt(me),2),ze=u(be,!0);d(be),H(()=>J(ze,t(Me).error)),h(z,me)},oe=z=>{var me=_u();lt(2),h(z,me)};E(A,z=>{t(Me).connecting?z(U):t(Me).error?z(T,1):t(fe)||z(oe,2)})}d(ce),h(ee,ce)};E(Ee,ee=>{(!t(fe)||t(Me).connecting||t(Me).error)&&ee(ot)})}var At=f(Ee,2);{var vt=ee=>{var ce=wu(),A=u(ce),U=u(A),T=u(U),oe=u(T,!0);d(T);var z=f(T,2),me=u(z);{var be=Ne=>{var Oe=xn();H(()=>J(Oe,e.placeholder??"Search the web...")),h(Ne,Oe)},ze=Ne=>{var Oe=xn("Agent is working, tap to Steer...");h(Ne,Oe)},Ue=Ne=>{var Oe=xn("Read-only mode");h(Ne,Oe)},at=Ne=>{var Oe=xn("Select a session first...");h(Ne,Oe)},pt=Ne=>{var Oe=xn("Tap to type a message...");h(Ne,Oe)};E(me,Ne=>{x()?Ne(be):t(Le)?Ne(ze,1):t(_e)?Ne(Ue,2):t(Ce).sessionId?Ne(pt,-1):Ne(at,3)})}d(z),d(U),lt(2),d(A),d(ce),H(()=>J(oe,x()?"🔍":"💬")),W("click",A,()=>{p(ke,!1),setTimeout(()=>t(Ge)?.focus(),50)}),h(ee,ce)},Te=ee=>{var ce=Du(),A=Wt(ce);{var U=ie=>{var it=Cu();_n(it,21,()=>t(ue),Pn,(Ot,kt,mt)=>{var nn=Eu(),Yt=u(nn),yn=u(Yt,!0);d(Yt);var wn=f(Yt,2);{var Cn=Z=>{var xe=ku();h(Z,xe)},M=Z=>{var xe=Tu(),qt=u(xe),Ct=u(qt);d(qt);var Ut=f(qt,2);{var It=Nt=>{var Ft=Su();H(()=>ge(Ft,"href",t(kt).url)),h(Nt,Ft)};E(Ut,Nt=>{t(kt).url&&Nt(It)})}d(xe),H(()=>{ge(xe,"title",t(kt).error),J(Ct,`⚠️ ${t(kt).error??""}`)}),h(Z,xe)},q=Z=>{var xe=Au();h(Z,xe)};E(wn,Z=>{t(kt).uploading?Z(Cn):t(kt).error?Z(M,1):Z(q,-1)})}var K=f(wn,2);d(nn),H(()=>{ge(Yt,"title",t(kt).name),J(yn,t(kt).name)}),W("click",K,()=>ft(mt)),h(Ot,nn)}),d(it),h(ie,it)};E(A,ie=>{t(ue).length>0&&ie(U)})}var T=f(A,2);{var oe=ie=>{var it=Ru(),Ot=f(u(it),2);_n(Ot,21,P,Pn,(kt,mt)=>{var nn=Iu(),Yt=u(nn,!0);d(nn);var yn={};H(()=>{J(Yt,t(mt).label),yn!==(yn=t(mt).value)&&(nn.value=(nn.__value=t(mt).value)??"")}),h(kt,nn)}),d(Ot),d(it),H(()=>Ot.disabled=t(Ie)),Gr(Ot,N),h(ie,it)};E(T,ie=>{x()&&P().length>0&&ie(oe)})}var z=f(T,2),me=u(z),be=u(me);Li(be),ge(be,"rows",1),qn(be,ie=>p(Ge,ie),()=>t(Ge)),d(me);var ze=f(me,2),Ue=u(ze);{var at=ie=>{var it=$u(),Ot=Wt(it),kt=f(Ot,2);qn(kt,mt=>p(Q,mt),()=>t(Q)),H(()=>Ot.disabled=t(Ie)),W("click",Ot,()=>{ga(),t(Q)?.click()}),W("change",kt,rt),h(ie,it)};E(Ue,ie=>{m()&&!x()&&ie(at)})}var pt=f(Ue,2),Ne=u(pt);mu(Ne,{get disabled(){return t(Ie)},onSend:wt,get text(){return t(S)},set text(ie){p(S,ie,!0)}}),d(pt);var Oe=f(pt,2),jt=u(Oe);{var Vt=ie=>{var it=xn();H(()=>J(it,e.submitLabel??"Search")),h(ie,it)},hn=ie=>{var it=xn("Steer");h(ie,it)},bn=ie=>{var it=xn("Send");h(ie,it)};E(jt,ie=>{x()?ie(Vt):t(Le)?ie(hn,1):ie(bn,-1)})}d(Oe),d(ze),d(z);var Dt=f(z,2),Et=u(Dt),Ke=u(Et);nt(Ke),lt(2),d(Et);var en=f(Et,2),Kt=u(en),tn=f(Kt,2);{var Tn=ie=>{var it=Mu();h(ie,it)};E(tn,ie=>{t(Y)||ie(Tn)})}d(en),d(Dt),H(()=>{be.disabled=t(Ie),ge(be,"placeholder",x()?e.placeholder??"Search the web...":t(fe)?t(Le)?"Agent is working, Steer to interrupt...":t(_e)?"Read-only mode":t(Ce).sessionId?"Type a message...":"Select a session first...":t(Me).connecting?"Reconnecting to remote server...":"Disconnected - cannot send"),Oe.disabled=!t(ut),ge(Oe,"title",!x()&&t(Le)?"Steer the agent now (injected at the next step, before the next model call)":void 0),ra(Ke,t(Y))}),ir("submit",z,ie=>{ie.preventDefault(),wt()}),W("keydown",be,st),Ln(be,()=>t(S),ie=>p(S,ie)),W("change",Ke,yt),W("click",Kt,()=>p(ke,!0)),h(ee,ce)};E(At,ee=>{t(ke)?ee(vt):ee(Te,-1)})}d(xt),h(n,xt);var an=cr(te);return _(),an}xr(["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>'),Ju=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>'),Qu=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 Qo(n,e){lr(e,!0);const r=()=>$e(Nr,"$readOnlySessionFolders",I),s=()=>$e(Ar,"$sessionFolders",I),o=()=>$e(Yr,"$activeSessionInfo",I),a=()=>$e(Kr,"$isConnected",I),l=()=>$e(fs,"$isLoadingSession",I),c=()=>$e(ao,"$isResyncing",I),_=()=>$e(Er,"$availableModels",I),m=()=>$e(Zs,"$gitInitDefaultStore",I),x=()=>$e(oo,"$sessionError",I),[I,P]=Cr(),N=[];let S=br(e,"readOnly",3,!1),Y=V(()=>S()?r().folders:s().folders),ke=V(()=>S()?r().loading:s().loading);function Q(){S()?la():Br()}let ue=V(()=>o().sessionFile),Le=V(a),_e=V(l),Ce=V(c),fe=V(()=>_().models),Me=Mn({}),Ie=G(Mn({})),St=G(null),ut=G(null),Ge=G(""),we=G(Mn([]));Pt(()=>{t(Le)&&(Q(),S()||(sl(),al()))});function Tt(M,q,K){if(!K)return!0;const Z=K.toLowerCase();return(M.name||"").toLowerCase().includes(Z)||M.firstMessage.toLowerCase().includes(Z)||q.toLowerCase().includes(Z)}Pt(()=>{const M=t(Ge),q=t(Y);M?p(we,q.map(K=>({...K,sessions:K.sessions.filter(Z=>Tt(Z,K.name,M))})).filter(K=>K.sessions.length>0),!0):(p(we,q,!0),p(Ie,{},!0))});function qe(M){return t(Ge)?t(Ie)[M]!==void 0?t(Ie)[M]:!0:!!Me[M]}function Xe(M){t(Ge)?t(Ie)[M]=!qe(M):Me[M]=!qe(M)}async function yt(M){try{t(ue)===M&&(typeof window<"u"&&(window.location.hash=""),Dn()),await Bs(M),t(St)===M&&p(St,null),Br()}catch(q){console.error("Failed to delete session:",q)}}async function rt(M){try{const q=M.sessions.map(K=>K.path);t(ue)&&q.includes(t(ue))&&(typeof window<"u"&&(window.location.hash=""),Dn()),await Promise.all(M.sessions.map(K=>Bs(K.path))),t(ut)===M.path&&p(ut,null),Br()}catch(q){console.error("Failed to delete all sessions of folder:",q)}}function ft(M){t(ue)===M&&!t(_e)&&!t(Ce)||(mr(),ro(M))}let wt=G(!1),st=G(""),te=G(Mn([])),xt=G(!1),Ee=G(null),ot=G(null),At="",vt=G(""),Te=G(!1),an=G(null),ee=G(!0),ce=G("private"),A=G(!1),U=V(m);Pt(()=>{t(an)===null&&p(Te,t(U),!0)});let T=G(Mn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),oe=V(()=>t(T).exists!==!0&&t(T).matchingRule&&t(ee)),z=null;async function me(M,q=!1){if(z&&clearTimeout(z),M===At&&!q)return;if(At=M,!M.trim()){p(T,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const Z=async()=>{const xe=await ss("");p(te,xe||[],!0)};q?await Z():z=setTimeout(Z,300);return}const K=async()=>{const[Z,xe]=await Promise.all([fa(M),ss(M)]);p(te,xe||[],!0),Z?(p(T,{exists:Z.exists,isGit:Z.isGit,resolvedPath:Z.resolvedPath,matchingRule:Z.matchingRule||null},!0),Z.exists||(p(Te,t(an)!==null?t(an):t(U),!0),p(ee,!0),Z.matchingRule&&p(ce,Z.matchingRule.visibility,!0))):p(T,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};q?await K():z=setTimeout(K,300)}Pt(()=>{const M=t(st);me(M,!1)}),Pt(()=>{if(t(fe).length>0&&!t(vt)){const M=t(fe).find(q=>q.isDefault);M?p(vt,`${M.provider}:${M.modelId}`):p(vt,`${t(fe)[0].provider}:${t(fe)[0].modelId}`)}});function be(){if(t(st).trim())if(t(T).exists===!0)p(Te,!1),p(ee,!1),t(T).matchingRule&&p(ce,t(T).matchingRule.visibility,!0),p(A,!0);else{mr();const M=t(st).trim(),q=t(vt)||void 0,K=t(Te),Z=t(T).matchingRule?t(ee):void 0,xe=t(T).matchingRule?t(ce):void 0;p(st,""),p(wt,!1),t(ue)?(Dn(),setTimeout(()=>{jn(M,q,K,Z,xe)},100)):jn(M,q,K,Z,xe)}}function ze(){p(A,!1),mr();const M=t(st).trim(),q=t(vt)||void 0,K=t(Te),Z=t(T).matchingRule?t(ee):void 0,xe=t(T).matchingRule?t(ce):void 0;p(st,""),p(wt,!1),t(ue)?(Dn(),setTimeout(()=>{jn(M,q,K,Z,xe)},100)):jn(M,q,K,Z,xe)}let Ue=G(Mn({open:!1,folderPath:"",selected:""}));function at(M){const q=t(fe).find(K=>K.isDefault);p(Ue,{open:!0,folderPath:M,selected:q?`${q.provider}:${q.modelId}`:""},!0)}function pt(){t(Ue).open=!1}function Ne(){if(!t(Ue).open)return;mr();const M=t(Ue).folderPath,q=t(Ue).selected||void 0;pt(),t(ue)?(Dn(),setTimeout(()=>{jn(M,q)},100)):jn(M,q)}function Oe(M){const q=Date.now()-new Date(M).getTime(),K=Math.floor(q/6e4);if(K<1)return"just now";if(K<60)return`${K}m ago`;const Z=Math.floor(K/60);return Z<24?`${Z}h ago`:`${Math.floor(Z/24)}d ago`}function jt(M,q=40){return M.length>q?M.slice(0,q)+"...":M}var Vt=xf(),hn=Wt(Vt),bn=u(hn),Dt=u(bn),Et=u(Dt);nt(Et);var Ke=f(Et,2),en=u(Ke);d(Ke),d(Dt),d(bn);var Kt=f(bn,2),tn=u(Kt);{var Tn=M=>{var q=Vu(),K=u(q),Z=u(K),xe=u(Z,!0);d(Z),d(K);var qt=f(K,2);{var Ct=Ut=>{var It=qu(),Nt=u(It),Ft=f(u(Nt),2),zt=u(Ft);nt(zt),qn(zt,pe=>p(Ee,pe),()=>t(Ee));var ln=f(zt,2);{var $=pe=>{var se=Nu();_n(se,21,()=>t(te),Pn,(Se,v)=>{var w=Ou(),D=u(w,!0);d(w),H(()=>J(D,t(v))),W("click",w,()=>{p(st,t(v),!0),me(t(v),!0),t(Ee)?.focus()}),h(Se,w)}),d(se),h(pe,se)};E(ln,pe=>{t(xt)&&t(te).length>0&&pe($)})}d(Ft),qn(Ft,pe=>p(ot,pe),()=>t(ot));var O=f(Ft,2);{var B=pe=>{var se=Uu(),Se=f(u(se));{var v=w=>{var D=Fu();h(w,D)};E(Se,w=>{t(T).isGit&&w(v)})}d(se),h(pe,se)};E(O,pe=>{t(T).exists===!0&&pe(B)})}d(Nt);var le=f(Nt,2),De=f(u(le),2);{var ve=pe=>{var se=Bu();_n(se,21,()=>t(fe),Pn,(Se,v)=>{var w=zu(),D=u(w);d(w);var L={};H(()=>{J(D,`${t(v).label??""}${t(v).isDefault?" (default)":""}`),L!==(L=`${t(v).provider}:${t(v).modelId}`)&&(w.value=w.__value=`${t(v).provider}:${t(v).modelId}`)}),h(Se,w)}),d(se),Gr(se,()=>t(vt),Se=>p(vt,Se)),h(pe,se)},ae=pe=>{var se=Hu();nt(se),Ln(se,()=>t(vt),Se=>p(vt,Se)),h(pe,se)};E(De,pe=>{t(fe).length>0?pe(ve):pe(ae,-1)})}d(le);var Re=f(le,2);{var Pe=pe=>{var se=Gu(),Se=u(se),v=u(Se);nt(v);var w=f(v,2),D=u(w);d(w),d(Se);var L=f(Se,2);{var re=X=>{var k=Wu(),de=f(u(k),2),ye=u(de);nt(ye),ye.value=ye.__value="private",lt(),d(de);var Be=f(de,2),et=u(Be);nt(et),et.value=et.__value="public",lt(),d(Be),d(k),ar(N,[],ye,()=>t(ce),he=>p(ce,he)),ar(N,[],et,()=>t(ce),he=>p(ce,he)),h(X,k)};E(L,X=>{t(ee)&&X(re)})}d(se),H(()=>J(D,`Create remote ${t(T).matchingRule.provider??""} repository`)),On(v,()=>t(ee),X=>p(ee,X)),h(pe,se)};E(Re,pe=>{t(T).exists!==!0&&t(T).matchingRule&&pe(Pe)})}var _t=f(Re,2);{var Bt=pe=>{var se=ju(),Se=u(se);nt(Se),lt(2),d(se),W("change",Se,v=>{p(an,v.currentTarget.checked,!0)}),On(Se,()=>t(Te),v=>p(Te,v)),h(pe,se)};E(_t,pe=>{t(T).exists!==!0&&(!t(T).matchingRule||!t(ee))&&pe(Bt)})}var bt=f(_t,2);d(It),H(pe=>{rn(zt,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(oe)?"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"}`),bt.disabled=pe},[()=>!t(st).trim()]),ir("submit",It,pe=>{pe.preventDefault(),be()}),ir("focus",zt,()=>{p(xt,!0),me(t(st),!0)}),ir("blur",zt,pe=>{t(ot)&&t(ot).contains(pe.relatedTarget)||p(xt,!1)}),W("keydown",zt,pe=>{pe.key==="Escape"&&p(xt,!1)}),Ln(zt,()=>t(st),pe=>p(st,pe)),h(Ut,It)};E(qt,Ut=>{t(wt)&&Ut(Ct)})}d(q),H(()=>J(xe,t(wt)?"▼ Close Create Session":"✚ Create New Session")),W("click",K,()=>p(wt,!t(wt))),h(M,q)};E(tn,M=>{S()||M(Tn)})}var ie=f(tn,2);{var it=M=>{var q=Ku();h(M,q)},Ot=M=>{var q=Yu(),K=u(q,!0);d(q),H(()=>J(K,t(Ge)?"No sessions match your filter":"No sessions found")),h(M,q)},kt=M=>{var q=Zn(),K=Wt(q);_n(K,17,()=>t(we),Z=>Z.path,(Z,xe)=>{var qt=lf(),Ct=u(qt),Ut=u(Ct),It=f(Ut,2),Nt=u(It),Ft=u(Nt,!0);d(Nt);var zt=f(Nt,2),ln=u(zt,!0);d(zt),d(It);var $=f(It,2),O=u($,!0);d($),d(Ct);var B=f(Ct,2);{var le=ve=>{var ae=af(),Re=u(ae);{var Pe=Bt=>{var bt=Ju(),pe=u(bt),se=f(pe,2),Se=u(se);{var v=D=>{var L=Zu(),re=u(L),X=f(re,2);d(L),W("click",re,k=>{k.stopPropagation(),rt(t(xe))}),W("click",X,k=>{k.stopPropagation(),p(ut,null)}),h(D,L)},w=D=>{var L=Xu();W("click",L,re=>{re.stopPropagation(),p(ut,t(xe).path,!0)}),h(D,L)};E(Se,D=>{t(ut)===t(xe).path?D(v):D(w,-1)})}d(se),d(bt),W("click",pe,()=>at(t(xe).path)),h(Bt,bt)};E(Re,Bt=>{S()||Bt(Pe)})}var _t=f(Re,2);_n(_t,17,()=>t(xe).sessions,Bt=>Bt.path,(Bt,bt)=>{var pe=of(),se=u(pe),Se=u(se);{var v=he=>{var He=Qu();h(he,He)},w=he=>{var He=ef();h(he,He)};E(Se,he=>{t(bt).isActive?he(v):he(w,-1)})}var D=f(Se,2),L=u(D),re=u(L,!0);d(L);var X=f(L,2),k=u(X);d(X),d(D);var de=f(D,2);{var ye=he=>{var He=tf(),Zt=u(He,!0);d(He),H(()=>J(Zt,t(bt).clientCount)),h(he,He)};E(de,he=>{t(bt).clientCount>0&&he(ye)})}d(se);var Be=f(se,2);{var et=he=>{var He=sf(),Zt=u(He);{var Xt=We=>{var Ye=nf(),Ve=u(Ye),gt=f(Ve,2);d(Ye),W("click",Ve,Rt=>{Rt.stopPropagation(),yt(t(bt).path)}),W("click",gt,Rt=>{Rt.stopPropagation(),p(St,null)}),h(We,Ye)},Ht=We=>{var Ye=rf();W("click",Ye,Ve=>{Ve.stopPropagation(),p(St,t(bt).path,!0)}),h(We,Ye)};E(Zt,We=>{t(St)===t(bt).path?We(Xt):We(Ht,-1)})}d(He),h(he,He)};E(Be,he=>{S()||he(et)})}d(pe),H((he,He,Zt)=>{rn(pe,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(ue)===t(bt).path?"bg-brand-surface-3":""}`),ge(se,"href",`#${he??""}`),J(re,He),J(k,`${Zt??""} · ${t(bt).messageCount??""}
|
|
85
|
+
msgs`)},[()=>encodeURIComponent(t(bt).id),()=>t(bt).name||jt(t(bt).firstMessage)||"Empty session",()=>Oe(t(bt).modified)]),W("click",se,he=>{he.button===0&&!he.ctrlKey&&!he.metaKey&&!he.altKey&&!he.shiftKey&&(he.preventDefault(),ft(t(bt).path))}),h(Bt,pe)}),d(ae),h(ve,ae)},De=V(()=>qe(t(xe).path));E(B,ve=>{t(De)&&ve(le)})}d(qt),H(ve=>{rn(Ut,1,`text-xs text-brand-text-muted transition-transform ${ve??""}`),J(Ft,t(xe).name),J(ln,t(xe).path),J(O,t(xe).sessions.length)},[()=>qe(t(xe).path)?"rotate-90":""]),W("click",Ct,()=>Xe(t(xe).path)),h(Z,qt)}),h(M,q)};E(ie,M=>{t(ke)&&t(we).length===0?M(it):t(we).length===0?M(Ot,1):M(kt,-1)})}d(Kt),d(hn);var mt=f(hn,2);{var nn=M=>{var q=ff(),K=u(q),Z=f(u(K),2),xe=f(u(Z),2),qt=u(xe,!0);d(xe),d(Z);var Ct=f(Z,2),Ut=f(u(Ct),2);{var It=$=>{var O=df();_n(O,21,()=>t(fe),Pn,(B,le)=>{var De=cf(),ve=u(De);d(De);var ae={};H(()=>{J(ve,`${t(le).label??""}${t(le).isDefault?" (default)":""}`),ae!==(ae=`${t(le).provider}:${t(le).modelId}`)&&(De.value=De.__value=`${t(le).provider}:${t(le).modelId}`)}),h(B,De)}),d(O),Gr(O,()=>t(Ue).selected,B=>t(Ue).selected=B),h($,O)},Nt=$=>{var O=uf();nt(O),Ln(O,()=>t(Ue).selected,B=>t(Ue).selected=B),h($,O)};E(Ut,$=>{t(fe).length>0?$(It):$(Nt,-1)})}d(Ct);var Ft=f(Ct,2),zt=u(Ft),ln=f(zt,2);d(Ft),d(K),d(q),H(()=>J(qt,t(Ue).folderPath)),W("click",q,pt),W("click",K,$=>$.stopPropagation()),W("click",zt,pt),W("click",ln,Ne),h(M,q)};E(mt,M=>{t(Ue).open&&M(nn)})}var Yt=f(mt,2);{var yn=M=>{var q=pf(),K=u(q),Z=u(K,!0);d(K);var xe=f(K,2);d(q),H(()=>J(Z,x())),W("click",xe,()=>mr()),h(M,q)};E(Yt,M=>{x()&&M(yn)})}var wn=f(Yt,2);{var Cn=M=>{var q=gf(),K=u(q),Z=f(u(K),2),xe=f(u(Z)),qt=u(xe,!0);d(xe),lt(),d(Z);var Ct=f(Z,2),Ut=u(Ct),It=u(Ut);nt(It);var Nt=f(It,2),Ft=f(u(Nt));{var zt=ve=>{var ae=hf();h(ve,ae)},ln=ve=>{var ae=bf();h(ve,ae)};E(Ft,ve=>{t(T).isGit?ve(zt):ve(ln,-1)})}d(Nt),d(Ut);var $=f(Ut,2);{var O=ve=>{var ae=mf(),Re=u(ae),Pe=u(Re);nt(Pe);var _t=f(Pe,2),Bt=u(_t);d(_t),d(Re);var bt=f(Re,2);{var pe=se=>{var Se=vf(),v=f(u(Se),2),w=u(v);nt(w),w.value=w.__value="private",lt(),d(v);var D=f(v,2),L=u(D);nt(L),L.value=L.__value="public",lt(),d(D),d(Se),ar(N,[],w,()=>t(ce),re=>p(ce,re)),ar(N,[],L,()=>t(ce),re=>p(ce,re)),h(se,Se)};E(bt,se=>{t(ee)&&se(pe)})}d(ae),H(()=>J(Bt,`Create remote ${t(T).matchingRule.provider??""} repository`)),On(Pe,()=>t(ee),se=>p(ee,se)),h(ve,ae)};E($,ve=>{t(T).matchingRule&&ve(O)})}d(Ct);var B=f(Ct,2),le=u(B),De=f(le,2);d(B),d(K),d(q),H(()=>{J(qt,t(st)),It.disabled=t(T).isGit}),On(It,()=>t(Te),ve=>p(Te,ve)),W("click",le,()=>p(A,!1)),W("click",De,ze),h(M,q)};E(wn,M=>{t(A)&&M(Cn)})}H(()=>{Ni(Et,t(Ge)),rn(en,1,Hi(t(ke)?"animate-spin":""))}),W("input",Et,M=>p(Ge,M.currentTarget.value,!0)),W("click",Ke,()=>Q()),h(n,Vt),cr(),P()}xr(["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">Sudo password</h2> <p class="mb-3 text-sm text-brand-text-muted">This command needs your sudo password to run. It is used once and never
|
|
86
|
+
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 yf(n,e){lr(e,!0);const r=()=>$e(Na,"$sudoPrompt",s),[s,o]=Cr();let a=V(r),l=G(""),c=G(null),_=G(null);Pt(()=>{const Y=t(a)?.promptId??null;Y!==t(_)&&(p(_,Y,!0),p(l,""),Y&&queueMicrotask(()=>t(c)?.focus()))});function m(){t(a)&&(Ra(t(l)),p(l,""))}function x(){$a(),p(l,"")}function I(Y){Y.key==="Enter"?(Y.preventDefault(),m()):Y.key==="Escape"&&(Y.preventDefault(),x())}var P=Zn(),N=Wt(P);{var S=Y=>{var ke=_f(),Q=u(ke),ue=f(u(Q),4),Le=u(ue,!0);d(ue);var _e=f(ue,2);nt(_e),qn(_e,Ie=>p(c,Ie),()=>t(c));var Ce=f(_e,2),fe=u(Ce),Me=f(fe,2);d(Ce),d(Q),d(ke),H(()=>J(Le,t(a).command)),W("keydown",_e,I),Ln(_e,()=>t(l),Ie=>p(l,Ie)),W("click",fe,x),W("click",Me,m),h(Y,ke)};E(N,Y=>{t(a)&&Y(S)})}h(n,P),cr(),o()}xr(["keydown","click"]);function wf(n){return n.loading||n.resyncing||n.hasSessionHash}function kf(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!wf(n)}var Sf=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>'),Tf=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),Af=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),Ef=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>'),Cf=g('<div class="truncate text-xs text-brand-text-muted"> </div>'),If=g('<div class="truncate text-xs text-brand-text-muted"> </div>'),Rf=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>'),$f=g('<div class="mt-2 text-xs text-rose-400"> </div>'),Mf=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>'),Df=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>'),Pf=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),Lf=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>'),Of=g('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Nf=g('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),Ff=g('<span class="text-sm text-brand-text-muted">Not connected</span>'),Uf=g('<div class="flex min-w-0 items-center gap-2"><!></div>'),zf=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>'),Bf=g("<option> </option>"),Hf=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>'),Wf=g('<span class="truncate text-brand-text-muted"> </span>'),Gf=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>'),jf=g('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),qf=g('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),Vf=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>'),Kf=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>'),Yf=g('<button class="flex-shrink-0 rounded-md border border-yellow-500/40 bg-yellow-500/20 px-3 py-1 text-xs font-medium text-yellow-300 transition-colors hover:bg-yellow-500/30">Continue anyway</button>'),Zf=g('<div class="flex items-center justify-between gap-3 border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-sm text-yellow-400"><span class="min-w-0 flex-1 break-words">⚠️ Another client is active in this folder. <!></span> <!></div>'),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>'),Jf=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>'),Qf=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){lr(e,!0);const r=()=>$e(Kr,"$isConnected",Q),s=()=>$e(ao,"$isResyncing",Q),o=()=>$e(Ua,"$isAgentPending",Q),a=()=>$e(fs,"$isLoadingSession",Q),l=()=>$e(La,"$isInterrupted",Q),c=()=>$e(oo,"$sessionError",Q),_=()=>$e(Oa,"$sessionNotice",Q),m=()=>$e(Pa,"$folderConflict",Q),x=()=>$e(us,"$isReadOnly",Q),I=()=>$e(Yr,"$activeSessionInfo",Q),P=()=>$e(Lt,"$piState",Q),N=()=>$e(Er,"$availableModels",Q),S=()=>$e(Fa,"$isCreatingSession",Q),Y=()=>$e(Xs,"$searchFolderStore",Q),ke=()=>$e(ua,"$searchDefaultModelStore",Q),[Q,ue]=Cr();let Le=G(!1),_e=G("main"),Ce=G(!1),fe;qr(()=>{setTimeout(()=>vr(),200);const $=()=>{if(t(we)){const ve=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";ve&&ve!==t(At)?ro(ve):!ve&&t(At)&&Dn()}};window.addEventListener("hashchange",$);let O=null;const B=8e3,le=()=>{if(document.visibilityState==="hidden"){if(xa())return;O&&clearTimeout(O),O=setTimeout(()=>{O=null,document.visibilityState==="hidden"&&t(we)&&ma()},B)}else no(),O&&(clearTimeout(O),O=null),t(we)||(Fs()?Ns():vr())},De=ve=>{O&&(clearTimeout(O),O=null),document.visibilityState!=="hidden"&&!t(we)&&(Fs()?Ns():vr())};return document.addEventListener("visibilitychange",le),window.addEventListener("pageshow",De),()=>{window.removeEventListener("hashchange",$),document.removeEventListener("visibilitychange",le),window.removeEventListener("pageshow",De),O&&clearTimeout(O)}});function Me(){vr()}function Ie(){Dn(),jr()}function St(){jr(),setTimeout(()=>vr(),100)}function ut(){Br()}function Ge(){typeof window<"u"&&(window.location.hash=""),Dn(),p(Le,!1)}let we=V(r),Tt=V(s),qe=V(o),Xe=V(a),yt=V(l),rt=V(c),ft=V(_),wt=V(m),st=V(x),te=V(I),xt=V(P),Ee=V(()=>N().models),ot=G(!1),At=V(()=>t(te).sessionId);Pt(()=>{typeof window<"u"&&t(we)&&(t(At)?(window.location.hash=encodeURIComponent(t(At)),p(ot,!0)):t(ot)&&(p(ot,!1),window.location.hash&&(window.location.hash="")))});let vt=null;Pt(()=>{if(!t(we)||typeof window>"u"||!window.location.hash)return;const $=decodeURIComponent(window.location.hash.slice(1));$&&(t(At)===$||t(Xe)||t(Tt)||vt||(vt=setTimeout(()=>{vt=null,!(t(At)===$||t(Xe)||t(Tt))&&ka($)},300)))}),Pt(()=>{t(we)||p(ot,!1)}),Pt(()=>{(t(At)||t(Xe)||t(Tt))&&p(Le,!1)});let Te=V(S),an=V(Y),ee=G(void 0),ce=V(()=>kf({connected:t(we),searchConfigured:!!t(an),hasSession:!!t(te).sessionFile,loading:t(Xe),resyncing:t(Tt),hasSessionHash:typeof window<"u"&&!!window.location.hash})),A=V(()=>t(Ee).map($=>({value:`${$.provider}:${$.modelId}`,label:`${$.label}${$.isDefault?" (default)":""}`}))),U=V(ke),T=G("");Pt(()=>{if(t(A).length===0||t(A).some(le=>le.value===t(T)))return;const O=t(A).find(le=>le.value===t(U)),B=t(Ee).find(le=>le.isDefault);p(T,O?O.value:B?`${B.provider}:${B.modelId}`:t(A)[0].value,!0)});let oe=G(!1);Pt(()=>{t(ce)&&!t(oe)&&t(ee)&&(p(oe,!0),t(ee).focusInput())});function z(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),Dn(),t(ee)?.focusInput()}var me=sp(),be=Wt(me);Zi(be,{title:"Wherever",description:"Create & maintain apps from wherever"});var ze=f(be,2);{var Ue=$=>{var O=Sf();h($,O)};E(ze,$=>{t(Te)&&$(Ue)})}var at=f(ze,2),pt=u(at),Ne=u(pt),Oe=u(Ne),jt=u(Oe);{var Vt=$=>{var O=Tf(),B=f(Wt(O),2);W("click",B,()=>p(Ce,!1)),h($,O)},hn=$=>{var O=Af(),B=Wt(O),le=u(B);lt(2),d(B);var De=f(B,2),ve=u(De),ae=f(ve,2);d(De),H(Re=>ge(le,"src",Re),[()=>Tr("/logo.svg")]),W("click",B,Ge),W("click",ve,()=>p(Ce,!0)),W("click",ae,()=>p(Le,!1)),h($,O)};E(jt,$=>{t(Ce)?$(Vt):$(hn,-1)})}d(Oe),d(Ne);var bn=f(Ne,2);{var Dt=$=>{var O=Ef(),B=u(O);{let Pe=V(()=>(t(xt).connected,"localhost"));Tl(B,{get host(){return t(Pe)},port:31415,token:"",onConnected:Me})}var le=f(B,2),De=f(u(le),2),ve=u(De),ae=f(ve,2),Re=f(ae,2);d(De),d(le),d(O),W("click",ve,ut),W("click",ae,St),W("click",Re,Ie),h($,O)},Et=$=>{var O=Pf(),B=Wt(O),le=u(B),De=u(le),ve=f(De,2),ae=u(ve,!0);d(ve);var Re=f(ve,2),Pe=u(Re);d(Re),d(le);var _t=f(le,2);{var Bt=k=>{var de=Rf(),ye=u(de);{var Be=Xt=>{var Ht=Cf(),We=u(Ht);d(Ht),H(Ye=>{ge(Ht,"title",t(te).cwd),J(We,`📁 ${Ye??""}`)},[()=>t(te).cwd.split("/").pop()||t(te).cwd]),h(Xt,Ht)};E(ye,Xt=>{t(te).cwd&&Xt(Be)})}var et=f(ye,2);{var he=Xt=>{var Ht=If(),We=u(Ht);d(Ht),H(()=>{ge(Ht,"title",t(te).model),J(We,`🤖 ${t(te).model??""}`)}),h(Xt,Ht)};E(et,Xt=>{t(te).model&&Xt(he)})}var He=f(et,2),Zt=u(He);d(He),d(de),W("click",Zt,Ge),h(k,de)};E(_t,k=>{t(te).sessionFile&&k(Bt)})}var bt=f(_t,2);{var pe=k=>{var de=$f(),ye=u(de,!0);d(de),H(()=>J(ye,t(xt).error)),h(k,de)};E(bt,k=>{t(xt).error&&!t(we)&&k(pe)})}d(B);var se=f(B,2),Se=u(se);{var v=k=>{var de=Mf();W("click",de,()=>{p(_e,"readonly"),la()}),h(k,de)},w=k=>{var de=Df();W("click",de,()=>p(_e,"main")),h(k,de)};E(Se,k=>{t(_e)==="main"?k(v):k(w,-1)})}d(se);var D=f(se,2),L=u(D);{var re=k=>{Qo(k,{readOnly:!0})},X=k=>{Qo(k,{})};E(L,k=>{t(_e)==="readonly"?k(re):k(X,-1)})}d(D),H(()=>{rn(De,1,`h-2.5 w-2.5 rounded-full ${t(we)?"bg-emerald-500":"bg-rose-500"}`),rn(ve,1,`text-sm ${t(we)?"text-emerald-400":"text-rose-400"}`),J(ae,t(we)?"Connected":"Disconnected"),J(Pe,`v${sa}`)}),h($,O)};E(bn,$=>{t(Ce)?$(Dt):$(Et,-1)})}d(pt);var Ke=f(pt,2),en=u(Ke),Kt=u(en),tn=f(Kt,2);{var Tn=$=>{var O=Lf();W("click",O,z),h($,O)};E(tn,$=>{t(we)&&t(an)&&t(te).sessionFile&&$(Tn)})}var ie=f(tn,2);{var it=$=>{var O=Uf(),B=u(O);{var le=ae=>{var Re=Of();h(ae,Re)},De=ae=>{var Re=Nf();h(ae,Re)},ve=ae=>{var Re=Ff();h(ae,Re)};E(B,ae=>{t(we)&&t(ce)?ae(le):t(we)?ae(De,1):ae(ve,-1)})}d(O),h($,O)};E(ie,$=>{(!t(we)||!t(te).sessionFile)&&$(it)})}var Ot=f(ie,2);{var kt=$=>{var O=jf(),B=u(O);{var le=ae=>{var Re=zf(),Pe=f(u(Re),2),_t=u(Pe,!0);d(Pe),d(Re),H(Bt=>{ge(Pe,"title",t(te).cwd),J(_t,Bt)},[()=>t(te).cwd.split("/").pop()||t(te).cwd]),h(ae,Re)};E(B,ae=>{t(te).cwd&&ae(le)})}var De=f(B,2);{var ve=ae=>{var Re=Gf(),Pe=u(Re),_t=f(u(Pe),2);d(Pe);var Bt=f(Pe,2);{var bt=se=>{var Se=Hf();_n(Se,21,()=>t(Ee),Pn,(w,D)=>{var L=Bf(),re=u(L,!0);d(L);var X={};H(()=>{J(re,t(D).label),X!==(X=`${t(D).provider}:${t(D).modelId}`)&&(L.value=L.__value=`${t(D).provider}:${t(D).modelId}`)}),h(w,L)}),d(Se);var v;aa(Se),H(()=>{v!==(v=t(te).model)&&(Se.value=(Se.__value=t(te).model)??"",Ys(Se,t(te).model))}),W("input",Se,w=>Ma(w.currentTarget.value)),h(se,Se)},pe=se=>{var Se=Wf(),v=u(Se,!0);d(Se),H(()=>{ge(Se,"title",t(te).model),J(v,t(te).model)}),h(se,Se)};E(Bt,se=>{t(Ee).length>0&&!t(st)?se(bt):se(pe,-1)})}d(Re),H(()=>{rn(_t,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(xt).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),ge(_t,"title",t(xt).isStreaming?"Agent working...":"Ready")}),h(ae,Re)};E(De,ae=>{t(te).model&&ae(ve)})}d(O),h($,O)};E(Ot,$=>{t(te).sessionFile&&$(kt)})}var mt=f(Ot,2);{var nn=$=>{var O=qf();h($,O)};E(mt,$=>{t(st)&&$(nn)})}d(en);var Yt=f(en,2);{var yn=$=>{var O=Vf();h($,O)};E(Yt,$=>{t(yt)&&$(yn)})}var wn=f(Yt,2);{var Cn=$=>{var O=Kf(),B=u(O),le=u(B,!0);d(B);var De=f(B,2);d(O),H(()=>{rn(O,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(ft).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),J(le,t(ft).message)}),W("click",De,()=>Ia()),h($,O)};E(wn,$=>{t(ft)&&$(Cn)})}var M=f(wn,2);{var q=$=>{var O=Zf(),B=u(O),le=f(u(B));{var De=Pe=>{var _t=xn("You are both working in it — changes may conflict.");h(Pe,_t)},ve=Pe=>{var _t=xn("You are observing (read-only) to avoid clashing.");h(Pe,_t)};E(le,Pe=>{t(wt).continued?Pe(De):Pe(ve,-1)})}d(B);var ae=f(B,2);{var Re=Pe=>{var _t=Yf();W("click",_t,()=>Aa()),h(Pe,_t)};E(ae,Pe=>{t(wt).continued||Pe(Re)})}d(O),h($,O)};E(M,$=>{t(wt)?.active&&$(q)})}var K=f(M,2);{var Z=$=>{var O=Xf(),B=u(O),le=u(B,!0);d(B);var De=f(B,2);d(O),H(()=>J(le,t(rt))),W("click",De,()=>mr()),h($,O)};E(K,$=>{t(rt)&&$(Z)})}var xe=f(K,2);{var qt=$=>{var O=Jf();h($,O)};E(xe,$=>{t(st)&&!t(yt)&&$(qt)})}var Ct=f(xe,2);qn(du(Ct,{onMessageSent:()=>{}}),$=>fe=$,()=>fe);var Ut=f(Ct,2);{var It=$=>{var O=Qf();h($,O)},Nt=$=>{var O=np(),B=Wt(O);{var le=ae=>{var Re=ep();h(ae,Re)},De=ae=>{var Re=tp();h(ae,Re)};E(B,ae=>{t(te).sessionFile&&(t(Tt)||!t(we))?ae(le):t(te).sessionFile&&t(qe)&&ae(De,1)})}var ve=f(B,2);{let ae=V(()=>!!t(an)),Re=V(()=>t(ce)?!t(we):!t(we)||t(st)||!t(te).sessionFile||t(Tt)||t(qe));qn(Lu(ve,{get searchMode(){return t(ce)},get searchConfigured(){return t(ae)},get searchModels(){return t(A)},onSubmit:Pe=>Sa(Pe,t(T)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(Re)},onSend:()=>fe?.forceScrollToBottom(),get searchModel(){return t(T)},set searchModel(Pe){p(T,Pe,!0)}}),Pe=>p(ee,Pe,!0),()=>t(ee))}h($,O)};E(Ut,$=>{t(st)&&t(te).sessionFile?$(It):$(Nt,-1)})}d(Ke);var Ft=f(Ke,2);yf(Ft,{});var zt=f(Ft,2);{var ln=$=>{var O=rp();W("click",O,()=>p(Le,!1)),h($,O)};E(zt,$=>{t(Le)&&$(ln)})}d(at),H(()=>rn(pt,1,`app-chrome ${t(Le)?"translate-x-0":"-translate-x-full"} fixed z-20 flex h-full w-72 flex-col border-r border-brand-border bg-brand-surface transition-transform duration-200 md:relative md:translate-x-0`)),W("click",Kt,()=>p(Le,!t(Le))),h(n,me),cr(),ue()}xr(["click","input"]);export{pp as component,fp as universal};
|
|
87
|
+
//# sourceMappingURL=2.CKCpNIHO.js.map
|