wherever-dev 0.6.1 → 0.7.0
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/dist/attach-file-tool.d.ts +20 -0
- package/dist/attach-file-tool.d.ts.map +1 -0
- package/dist/attach-file-tool.js +104 -0
- package/dist/attach-file-tool.js.map +1 -0
- package/dist/index.js +187 -15
- package/dist/index.js.map +1 -1
- package/dist/session-pool.d.ts +14 -0
- package/dist/session-pool.d.ts.map +1 -1
- package/dist/session-pool.js +8 -0
- package/dist/session-pool.js.map +1 -1
- package/package.json +4 -3
- package/public/_app/immutable/assets/0.BfBppMSw.css +1 -0
- package/public/_app/immutable/chunks/{C2oprduI.js → DLYtFZbx.js} +2 -2
- package/public/_app/immutable/chunks/{C2oprduI.js.map → DLYtFZbx.js.map} +1 -1
- package/public/_app/immutable/chunks/{DXvc7DJA.js → Szzynr2Q.js} +2 -2
- package/public/_app/immutable/chunks/{DXvc7DJA.js.map → Szzynr2Q.js.map} +1 -1
- package/public/_app/immutable/chunks/{BxDc2a9S.js → wsEX3w4Q.js} +2 -2
- package/public/_app/immutable/chunks/{BxDc2a9S.js.map → wsEX3w4Q.js.map} +1 -1
- package/public/_app/immutable/entry/{app.yrkydP4x.js → app.BA6cZSa0.js} +3 -3
- package/public/_app/immutable/entry/{app.yrkydP4x.js.map → app.BA6cZSa0.js.map} +1 -1
- package/public/_app/immutable/entry/start.BVub8Izb.js +2 -0
- package/public/_app/immutable/entry/start.BVub8Izb.js.map +1 -0
- package/public/_app/immutable/nodes/{0.BR2ysPfV.js → 0.C5KzEipC.js} +2 -2
- package/public/_app/immutable/nodes/{0.BR2ysPfV.js.map → 0.C5KzEipC.js.map} +1 -1
- package/public/_app/immutable/nodes/{1.D4O7RJRM.js → 1.BpD60LtS.js} +2 -2
- package/public/_app/immutable/nodes/{1.D4O7RJRM.js.map → 1.BpD60LtS.js.map} +1 -1
- package/public/_app/immutable/nodes/2.Dm3S081E.js +88 -0
- package/public/_app/immutable/nodes/2.Dm3S081E.js.map +1 -0
- package/public/_app/version.json +1 -1
- package/public/index.html +11 -11
- package/public/service-worker.js +1 -1
- package/public/_app/immutable/assets/0.C2Vl85yD.css +0 -1
- package/public/_app/immutable/entry/start.BoFs4n_B.js +0 -2
- package/public/_app/immutable/entry/start.BoFs4n_B.js.map +0 -1
- package/public/_app/immutable/nodes/2.CkE0xTRs.js +0 -87
- package/public/_app/immutable/nodes/2.CkE0xTRs.js.map +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import{b as cs,a as p,c as Gn,g,d as ur,e as W,f as tr,s as te,t as wn}from"../chunks/vMsF8lo6.js";import{ar as kn,b2 as Yr,al as br,be as B,ap as da,M as si,aS as ai,aq as ws,d as Ga,am as ks,at as oi,n as ii,a0 as li,u as ci,t as di,a1 as ui,V as fi,W as pi,H as hi,b3 as ua,C as fa,aE as es,a2 as Qn,ac as bi,az as vi,aZ as gi,ay as ja,bd as qa,bf as mi,bg as Fs,aU as Us,aQ as pa,aP as nr,aM as rr,af as jt,b6 as f,ai as t,a5 as xi,bh as V,$ as _i,bl as In,ah as Un,a8 as Xt,aK as Fr,a_ as h,X as u,aV as d,aI as at,b9 as Z,aO as An,bi as Ft,bj as yi,aT as wi}from"../chunks/CEg8tgYI.js";import{i as A,s as _r,a as Me,p as ir}from"../chunks/MtE7VtNZ.js";import{a as ki,b as we,r as dt,c as Va,e as gn,i as Cn,d as Si}from"../chunks/Szzynr2Q.js";import{_ as Ti,b as Kn}from"../chunks/ylfInSZr.js";import{v as Ka}from"../chunks/wsEX3w4Q.js";import{p as Ai}from"../chunks/DLYtFZbx.js";function ha(n,e,r=!1,s=!1,a=!1,o=!1){var i=n,c="";if(r){var _=n;kn&&(i=Yr(br(_)))}B(()=>{var v=si;if(c===(c=e()??"")){kn&&da();return}if(r&&!kn){v.nodes=null,_.innerHTML=c,c!==""&&cs(br(_),_.lastChild);return}if(v.nodes!==null&&(ai(v.nodes.start,v.nodes.end),v.nodes=null),c!==""){if(kn){ws.data;for(var m=da(),E=m;m!==null&&(m.nodeType!==Ga||m.data!=="");)E=m,m=ks(m);if(m===null)throw oi(),ii;cs(ws,E),i=Yr(m);return}var L=s?ci:a?di:void 0,P=li(s?"svg":a?"math":"template",L);P.innerHTML=c;var S=s||a?P:P.content;if(cs(br(S),S.lastChild),s||a)for(;br(S);)i.before(br(S));else i.before(S)}})}function Ei(n,e){let r=null,s=kn;var a;if(kn){r=ws;for(var o=br(document.head);o!==null&&(o.nodeType!==Ga||o.data!==n);)o=ks(o);if(o===null)ua(!1);else{var i=ks(o);o.remove(),Yr(i)}}kn||(a=document.head.appendChild(ui()));try{fi(()=>{var c=pi(()=>e(a));c.f|=hi})}finally{s&&(ua(!0),Yr(r))}}function Ya(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var a=n.length;for(e=0;e<a;e++)n[e]&&(r=Ya(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function Ci(){for(var n,e,r=0,s="",a=arguments.length;r<a;r++)(n=arguments[r])&&(e=Ya(n))&&(s&&(s+=" "),s+=e);return s}function Ri(n){return typeof n=="object"?Ci(n):n??""}function Ii(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function rn(n,e,r,s,a,o){var i=n[fa];if(kn||i!==r||i===void 0){var c=Ii(r);(!kn||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[fa]=r}return o}function zs(n,e,r=!1){if(n.multiple){if(e==null)return;if(!vi(e))return gi();for(var s of n.options)s.selected=e.includes(Mr(s));return}for(s of n.options){var a=Mr(s);if(ja(a,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function Za(n){var e=new MutationObserver(()=>{zs(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),qa(()=>{e.disconnect()})}function Pr(n,e,r=e){var s=new WeakSet,a=!0;es(n,"change",o=>{var i=o?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(i),Mr);else{var _=n.querySelector(i)??n.querySelector("option:not([disabled])");c=_&&Mr(_)}r(c),n.__value=c,Qn!==null&&s.add(Qn)}),bi(()=>{var o=e();if(n===document.activeElement){var i=Qn;if(s.has(i))return}if(zs(n,o,a),a&&o===void 0){var c=n.querySelector(":checked");c!==null&&(o=Mr(c),r(o))}n.__value=o,a=!1}),Za(n)}function Mr(n){return"__value"in n?n.__value:n.value}function Fn(n,e,r=e){var s=new WeakSet;es(n,"input",async a=>{var o=a?n.defaultValue:n.value;if(o=us(n)?fs(o):o,r(o),Qn!==null&&s.add(Qn),await mi(),o!==(o=e())){var i=n.selectionStart,c=n.selectionEnd,_=n.value.length;if(n.value=o??"",c!==null){var v=n.value.length;i===c&&c===_&&v>_?(n.selectionStart=v,n.selectionEnd=v):(n.selectionStart=i,n.selectionEnd=Math.min(c,v))}}}),(kn&&n.defaultValue!==n.value||Fs(e)==null&&n.value)&&(r(us(n)?fs(n.value):n.value),Qn!==null&&s.add(Qn)),Us(()=>{var a=e();if(n===document.activeElement){var o=Qn;if(s.has(o))return}us(n)&&a===fs(n.value)||n.type==="date"&&!a&&!n.value||a!==n.value&&(n.value=a??"")})}const ds=new Set;function er(n,e,r,s,a=s){var o=r.getAttribute("type")==="checkbox",i=n;let c=!1;if(e!==null)for(var _ of e)i=i[_]??=[];i.push(r),es(r,"change",()=>{var v=r.__value;o&&(v=ba(i,v,r.checked)),a(v)},()=>a(o?[]:null)),Us(()=>{var v=s();if(kn&&r.defaultChecked!==r.checked){c=!0;return}o?(v=v||[],r.checked=v.includes(r.__value)):r.checked=ja(r.__value,v)}),qa(()=>{var v=i.indexOf(r);v!==-1&&i.splice(v,1)}),ds.has(i)||(ds.add(i),pa(()=>{i.sort((v,m)=>v.compareDocumentPosition(m)===4?-1:1),ds.delete(i)})),pa(()=>{if(c){var v;if(o)v=ba(i,v,r.checked);else{var m=i.find(E=>E.checked);v=m?.__value}a(v)}})}function Rn(n,e,r=e){es(n,"change",s=>{var a=s?n.defaultChecked:n.checked;r(a)}),(kn&&n.defaultChecked!==n.checked||Fs(e)==null)&&r(n.checked),Us(()=>{var s=e();n.checked=!!s})}function ba(n,e,r){for(var s=new Set,a=0;a<n.length;a+=1)n[a].checked&&s.add(n[a].__value);return r||s.delete(e),Array.from(s)}function us(n){var e=n.type;return e==="number"||e==="range"}function fs(n){return n===""?null:+n}const $i=!1,Mi=!0,Kf=Object.freeze(Object.defineProperty({__proto__:null,prerender:Mi,ssr:$i},Symbol.toStringTag,{value:"Module"})),ps="Wherever",Di="Create & maintain apps from wherever with a beautiful remote workspace.",hs="https://localhost",Li="#000000",Oi="black-translucent";function gr(n,e){return ki(n)}var Pi=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 Ni(n,e){nr(e,!0);const r=hs.endsWith("/")?hs.slice(0,-1):hs,s=r+"/preview.png";let a=V(()=>e.home||!1),o=V(()=>({type:e.type||"website",title:e.title||ps,description:e.description||Di,image:e.image||s,url:`${r}${Ai.url.pathname}`}));Ei("13n5pl5",i=>{var c=Pi(),_=jt(c),v=f(_,2),m=f(v,2);{var E=Ge=>{var it=Gn(),Et=jt(it);A(Et,lt=>{}),p(Ge,it)};A(m,Ge=>{t(a)&&Ge(E)})}var L=f(m,2),P=f(L,2),S=f(P,2),oe=f(S,2),ae=f(oe,2),me=f(ae,4),de=f(me,2),Je=f(de,2),Ie=f(Je,2),Oe=f(Ie,2),ke=f(Oe,2),Ue=f(ke,2),We=f(Ue,2),Lt=f(We,2),ot=f(Lt,4),be=f(ot,4),Ye=f(be,2),qt=f(Ye,2);B((Ge,it,Et,lt)=>{we(_,"content",t(o).title),we(v,"content",t(o).description),we(L,"content",t(o).type),we(P,"content",t(o).url),we(S,"content",t(o).title),we(oe,"content",t(o).description),we(ae,"content",t(o).image),we(me,"content",t(o).url),we(de,"content",t(o).title),we(Je,"content",t(o).description),we(Ie,"content",t(o).image),we(Oe,"href",Ge),we(ke,"href",it),we(Ue,"href",Et),we(We,"href",lt),we(Lt,"content",Li),we(ot,"content",ps),we(be,"content",Oi),we(Ye,"content",ps),we(qt,"content",Ka)},[()=>gr("/pwa/favicon.png"),()=>gr("/pwa/favicon.ico"),()=>gr("/pwa/apple-touch-icon.png"),()=>gr("/pwa/manifest.webmanifest")]),xi(()=>{_i.title=t(o).title??""}),p(i,c)}),rr()}let yr=null;function Fi(){if(typeof window>"u")return null;try{if(!yr){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;yr=new n}return yr.state==="suspended"&&yr.resume().catch(()=>{}),yr}catch{return null}}function va(n,e,r,s,a){const o=n.createOscillator(),i=n.createGain();o.type="sine",o.frequency.value=e;const c=.015;i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(a,r+c),i.gain.exponentialRampToValueAtTime(1e-4,r+s),o.connect(i),i.connect(n.destination),o.start(r),o.stop(r+s+.02)}const ga=new Map;function Ui(n){if(typeof Audio>"u")return!1;try{let e=ga.get(n);e||(e=new Audio(n),e.preload="auto",ga.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 Xa(n){if(n&&n.trim()&&Ui(n.trim()))return;const e=Fi();if(e)try{const r=e.currentTime;va(e,1046.5,r,.16,.12),va(e,1396.9,r+.13,.22,.12)}catch{}}function qr(){}function zi(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Bi(n,...e){if(n==null)return qr;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function sn(n){let e;return Bi(n,r=>e=r)(),e}var pr=[];function Hi(n,e=qr){let r;const s=new Set;function a(c){if(zi(n,c)&&(n=c,r)){const _=!pr.length;for(const v of s)v[1](),pr.push(v,n);if(_){for(let v=0;v<pr.length;v+=2)pr[v][0](pr[v+1]);pr.length=0}}}function o(c){a(c(n))}function i(c,_=qr){const v=[c,_];return s.add(v),s.size===1&&(r=e(a)||qr),c(n),()=>{s.delete(v),s.size===0&&(r(),r=null)}}return{set:a,update:o,subscribe:i}}const bs={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,conflict:null,isInterrupted:!1,notice:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null};class Pn{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;createWatchdog=null;static CREATE_WATCHDOG_MS=25e3;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;livenessTimer=null;heartbeatTimer=null;lastInboundAt=0;static STALE_SOCKET_MS=6e4;static TURN_STALL_MS=45e3;static HEARTBEAT_MS=25e3;isInitialConnect=!0;resumeSessionFile=null;resumeCwd;resumeModel;listeners=new Set;pendingUploads=new Map;confirmTimers=new Map;static CONFIRM_MS=12e3;static PENDING_PREFIX="wherever-pending:";constructor(e){this.config={secure:!0,...e},this.stateStore=Hi({...bs,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(P=>r?{...P,connecting:!0,error:null}:{...bs,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const s=this.config.secure?"wss":"ws",a=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,o=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",i=`${s}://${a}:${this.config.port}/ws${o}`,c=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!c){this.stateStore.update(P=>({...P,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const P=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=P?new c(i,P):new c(i)}catch(P){this.stateStore.update(S=>({...S,connecting:!1,error:`Failed to connect: ${P}`})),this.scheduleReconnect();return}const _=this.ws,v=()=>{if(this.ws!==_)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(me=>({...me,connected:!0,connecting:!1,error:null}));const P=sn(this.stateStore),S=this.resumeSessionFile??P.activeSessionFile,oe=this.resumeSessionFile!=null?this.resumeCwd:P.activeCwd??void 0,ae=this.resumeSessionFile!=null?this.resumeModel:P.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,S?(this.stateStore.update(me=>me.resyncing?me:{...me,resyncing:!0}),this.send({type:"session_load",sessionFile:S,cwd:oe,model:ae}),this.armLoadWatchdog()):this.stateStore.update(me=>me.resyncing?{...me,resyncing:!1}:me)},m=P=>{if(this.ws===_){this.lastInboundAt=Date.now();try{const S=typeof P.data=="string"?P.data:P.data.toString(),oe=JSON.parse(S);this.handleMessage(oe)}catch(S){console.error("Failed to parse WebSocket message:",S)}}},E=()=>{this.ws===_&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(P=>({...P,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:P.activeSessionFile?!0:P.resyncing})),this.scheduleReconnect())},L=P=>{this.ws===_&&this.stateStore.update(S=>({...S,error:S.error||"Connection error occurred"}))};typeof _.addEventListener=="function"?(_.addEventListener("open",v),_.addEventListener("message",m),_.addEventListener("close",E),_.addEventListener("error",L)):typeof _.on=="function"&&(_.on("open",v),_.on("message",P=>m({data:P})),_.on("close",E),_.on("error",L))}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({...bs,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=sn(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=sn(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||sn(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,Pn.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now()-this.lastInboundAt,a=sn(this.stateStore).isStreaming,o=a?Pn.TURN_STALL_MS:Pn.STALE_SOCKET_MS;if(s<o)return;console.warn(`[wherever] relay connection stale: no inbound frame for ${s}ms (threshold ${o}ms, ${a?"mid-turn":"idle"}); tearing down dead socket and reconnecting`),this.stopLivenessWatchdog();const i=this.ws;this.ws=null;try{typeof i.terminate=="function"?i.terminate():typeof i.close=="function"&&i.close()}catch{}this.stateStore.update(c=>({...c,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:a?"Connection to relay stalled mid-turn; reconnecting...":c.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,Pn.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=sn(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."})))},Pn.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,sn(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."})))},Pn.CREATE_WATCHDOG_MS)}clearCreateWatchdog(){this.createWatchdog&&(clearTimeout(this.createWatchdog),this.createWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`);const e=!!sn(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)},this.reconnectDelay))}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":case"session_error":case"session_conflict":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_conflict":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(e.uploadId);s&&(s.resolve({savedPath:e.savedPath,filename:e.filename}),this.pendingUploads.delete(e.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(e.uploadId);s&&(s.reject(new Error(e.error)),this.pendingUploads.delete(e.uploadId));break}case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let a=[...s.messages].reverse().find(o=>o.role==="thinking"&&o.isStreaming);if(!a){const o={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,o]}}return{...s,messages:s.messages.map(o=>o.id===a.id?{...o,content:o.content+e.delta,isStreaming:!0}:o)}});break;case"message_update":this.stateStore.update(s=>{let a=[...s.messages].reverse().find(o=>o.role==="assistant"&&o.isStreaming);if(!a){const o={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,o]}}return{...s,messages:s.messages.map(o=>o.id===a.id?{...o,content:o.content+e.delta,isStreaming:!0}:o)}});break;case"message_end":this.stateStore.update(s=>{let a=s.messages;const o=[...a].reverse().find(c=>c.role==="thinking"&&c.isStreaming);o&&(a=a.map(c=>c.id===o.id?{...c,isStreaming:!1}:c));const i=[...a].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(i)a=a.map(c=>c.id===i.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){if(e.role==="user"&&this.confirmDeliveredByContent(e.content))return sn(this.stateStore);const c=[...a].reverse().find(v=>v.role==="user");e.role==="user"&&c&&c.content===e.content||(a=[...a,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:a}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{const s=Date.now();this.stateStore.update(a=>({...a,isStreaming:!1,messages:a.messages.map(o=>o.isStreaming?{...o,isStreaming:!1,...o.role==="tool"?{interrupted:!0}:{},endedAt:o.role==="tool"&&o.endedAt===void 0?s:o.endedAt}:o)})),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,a])=>a!==void 0&&a!=="").map(([s,a])=>`${s}=${JSON.stringify(a)}`).join(" "):"";this.stateStore.update(s=>{const a=s.messages.map(c=>c.isStreaming&&(c.role==="assistant"||c.role==="thinking")?{...c,isStreaming:!1}:c),o=Date.now(),i={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:o,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:o};return{...s,messages:[...a,i]}});break;case"tool_update":{this.stateStore.update(s=>{const a=[...s.messages].reverse().find(o=>o.role==="tool"&&o.toolName===e.toolName&&o.isStreaming);return a?{...s,messages:s.messages.map(o=>o.id===a.id?{...o,content:o.content.includes(`
|
|
2
|
+
`)?o.content+e.delta:`${o.content}
|
|
3
|
+
${e.delta}`,toolOutput:`${o.toolOutput}${e.delta}`}:o)}:s});break}case"tool_end":{const s=e.result?`${e.result}`:"",a=!!e.isError&&this.isAbortedToolResult(s),o=!!e.isError&&!a,i=Array.isArray(e.images)&&e.images.length>0?e.images:void 0;this.stateStore.update(c=>{const _=c.messages.find(m=>m.role==="tool"&&m.toolName===e.toolName&&m.isStreaming)??[...c.messages].reverse().find(m=>m.role==="tool"&&m.toolName===e.toolName&&!m.content.startsWith("Tool error:")),v=Date.now();if(_){const m=o?"Error: ":"";return{...c,messages:c.messages.map(E=>E.id===_.id?{...E,content:`${m}${E.content}
|
|
4
|
+
${s}`,isStreaming:!1,isError:o,interrupted:a,toolOutput:s,...i?{images:i}:{},endedAt:v}:E)}}else{const m=o?`Tool error: ${e.toolName}
|
|
5
|
+
${s}`:`${e.toolName}
|
|
6
|
+
${s}`,E={id:this.generateId(),role:"tool",content:m,timestamp:v,isStreaming:!1,toolName:e.toolName,toolArgs:"",toolOutput:s,...i?{images:i}:{},isError:o,interrupted:a,endedAt:v};return{...c,messages:[...c.messages,E]}}});break}case"aborted":{const s=Date.now();this.stateStore.update(a=>({...a,isStreaming:!1,messages:a.messages.map(o=>o.isStreaming?{...o,isStreaming:!1,...o.role==="tool"?{interrupted:!0}:{},endedAt:o.role==="tool"&&o.endedAt===void 0?s:o.endedAt}:o)}));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,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"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}: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"session_conflict":this.stateStore.update(s=>({...s,conflict:{targetSessionId:e.sessionId,conflictingSessionId:e.conflictingSession,conflictingCwd:e.conflictingCwd},creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1}));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}));break;case"message_history":{const s=e.sessionId,a=sn(this.stateStore).messages.filter(c=>c.role==="user"&&c.delivery!==void 0),i=[...this.loadPersistedPending(s),...a];this.stateStore.update(c=>{const _=this.mapHistory(e.messages,e.sessionId,c.isStreaming),v=typeof e.totalCount=="number"?e.totalCount:_.length,m=typeof e.offset=="number"?e.offset:0,E=new Set(_.filter(S=>S.role==="user").map(S=>S.content)),L=new Set,P=[];for(const S of i)E.has(S.content)||L.has(S.content)||(L.add(S.content),P.push({...S,sessionId:s,delivery:"failed"}));return{...c,messages:[..._,...P],historyTotalCount:v,historyOffset:m,loadingMoreHistory:!1,loadingSession:!1,resyncing:!1}});for(const c of i)this.clearConfirm(c.id);this.persistPending(s);break}case"message_history_prepend":this.stateStore.update(s=>{const a=this.mapHistory(e.messages,e.sessionId,!1),o=typeof e.offset=="number"?e.offset:0;return a.length===0?{...s,loadingMoreHistory:!1,historyOffset:o}:{...s,messages:[...a,...s.messages],historyOffset:o,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 a=[],o={},i={},c=(m,E)=>{const L=o[m];if(!L)return;const P=L.indexOf(E);P!==-1&&L.splice(P,1)};for(const m of e)if(m.role==="tool_call"){const E=m.toolName||"unknown",L=m.content||"",P=a.length;a.push({id:this.generateId(),role:"tool",content:L?`$ ${E} ${L}`:`$ ${E}`,timestamp:m.timestamp,isStreaming:!1,toolName:E,toolArgs:L,toolOutput:"",sessionId:r,...Number.isFinite(m.timestamp)?{startedAt:m.timestamp}:{}}),o[E]||(o[E]=[]),o[E].push(P),typeof m.toolCallId=="string"&&m.toolCallId&&(i[m.toolCallId]=P)}else if(m.role==="tool_result"){const E=m.toolName||"unknown";let L;if(typeof m.toolCallId=="string"&&m.toolCallId&&i[m.toolCallId]!==void 0)L=i[m.toolCallId],delete i[m.toolCallId],c(E,L);else if(o[E]&&o[E].length>0){L=o[E].shift();for(const[oe,ae]of Object.entries(i))ae===L&&delete i[oe]}const P=m.isError&&!this.isAbortedToolResult(m.content),S=!!m.isError&&this.isAbortedToolResult(m.content);if(L!==void 0){const oe=a[L],ae=oe.toolArgs||"",me=oe.startedAt;a[L]={...oe,content:ae?`$ ${E} ${ae}
|
|
8
|
+
${m.content}`:`$ ${E}
|
|
9
|
+
${m.content}`,isStreaming:!1,toolOutput:m.content,...Array.isArray(m.images)&&m.images.length>0?{images:m.images}:{},isError:P,interrupted:S,timestamp:m.timestamp,...me!==void 0&&Number.isFinite(me)&&Number.isFinite(m.timestamp)&&m.timestamp>=me?{endedAt:m.timestamp}:{}}}else a.push({id:this.generateId(),role:"tool",content:`$ ${E}
|
|
10
|
+
${m.content}`,timestamp:m.timestamp,isStreaming:!1,toolName:E,toolArgs:"",toolOutput:m.content,...Array.isArray(m.images)&&m.images.length>0?{images:m.images}:{},isError:P,interrupted:S,sessionId:r})}else a.push({id:this.generateId(),role:m.role,content:m.content,timestamp:m.timestamp,isStreaming:!1,toolName:m.toolName,sessionId:r});const _=[];for(const m of Object.values(o))_.push(...m);_.sort((m,E)=>m-E);const v=s&&_.length>0?_[_.length-1]:-1;for(const m of _)m===v?a[m]={...a[m],isStreaming:!0}:a[m]={...a[m],interrupted:!0};if(s&&a.length>0){const m=a.length-1,E=a[m];(E.role==="assistant"||E.role==="thinking")&&(a[m]={...E,isStreaming:!0})}return a}loadMoreHistory(){const e=sn(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=sn(this.stateStore);if(!r.sessionId)return!1;if(r.agentPending)return this.stateStore.update(o=>({...o,sessionError:o.sessionError??"Preparing the session agent; please wait a moment, then resend."})),!1;if(!this.getIsConnected())return this.stateStore.update(o=>({...o,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(o=>({...o,sessionError:"Message failed to send (connection dropped). Please resend once reconnected."})),!1;const a={id:this.generateId(),role:"user",content:e,timestamp:Date.now(),isStreaming:!1,sessionId:r.sessionId,delivery:"sending"};return this.stateStore.update(o=>({...o,sessionError:null,messages:[...o.messages,a]})),this.armConfirm(a.id),this.persistPending(r.sessionId),!0}pendingKey(e){return Pn.PENDING_PREFIX+e}persistPending(e){if(!e||typeof localStorage>"u")return;const r=sn(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(a=>a&&typeof a.content=="string").map(a=>({id:typeof a.id=="string"?a.id:this.generateId(),role:"user",content:a.content,timestamp:typeof a.timestamp=="number"?a.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(a=>{const o=a.messages.find(i=>i.id===e);return!o||o.delivery!=="sending"?a:(s=a.sessionId,{...a,messages:a.messages.map(i=>i.id===e?{...i,delivery:"failed"}:i)})}),s&&this.persistPending(s)},Pn.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(a=>{const o=a.messages.find(i=>i.role==="user"&&i.delivery!==void 0&&i.content===e);return o?(r=o.id,s=a.sessionId,{...a,messages:a.messages.map(i=>i.id===o.id?{...i,delivery:void 0}:i)}):a}),r?(this.clearConfirm(r),this.persistPending(s),!0):!1}resendMessage(e){const r=sn(this.stateStore),s=r.messages.find(o=>o.id===e&&o.role==="user");return!s||!r.sessionId?!1:this.getIsConnected()?this.send({type:"message",message:s.content,sessionId:r.sessionId})?(this.stateStore.update(o=>({...o,sessionError:null,messages:o.messages.map(i=>i.id===e?{...i,delivery:"sending",timestamp:Date.now()}:i)})),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(a=>a.id!==e)})),r&&this.persistPending(r)}abort(){const e=sn(this.stateStore);e.sessionId&&this.send({type:"abort",sessionId:e.sessionId})}joinSession(e,r,s){this.stateStore.update(a=>({...a,conflict:null,sessionError:null,loadingSession:!0,agentPending:!1})),this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog()}switchSession(e,r,s){const a=sn(this.stateStore);a.activeSessionFile===e&&!a.loadingSession&&!a.resyncing||(a.sessionId&&this.send({type:"session_leave",sessionId:a.sessionId}),this.stateStore.update(o=>({...o,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,conflict:null,sessionError:null,notice: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,a,o){this.stateStore.update(i=>({...i,conflict:null,sessionError:null,creatingSession:!0,loadingSession:!1})),this.send({type:"session_new",cwd:e,model:r,gitInit:s,createRemote:a,repoVisibility:o}),this.armCreateWatchdog()}leaveSession(){const e=sn(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,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,contextUsage:null})),this.clearLoadWatchdog(),this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0}resolveConflict(e,r){const s=sn(this.stateStore);s.conflict&&(this.send({type:"session_resolve_conflict",action:e,sessionId:s.conflict.targetSessionId,cwd:r||s.conflict.conflictingCwd}),this.stateStore.update(a=>({...a,conflict:null,readOnly:e==="read_only"})))}ping(){this.send({type:"ping"})}clearMessages(){this.stateStore.update(e=>({...e,messages:[]}))}dismissSessionError(){this.stateStore.update(e=>({...e,sessionError:null}))}dismissNotice(){this.stateStore.update(e=>({...e,notice:null}))}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((a,o)=>{const i=this.generateId();this.pendingUploads.set(i,{resolve:a,reject:o}),this.send({type:"file_upload",uploadId:i,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 mr=In({folders:[],activeSessions:[],currentSession:null,loading:!1}),xr=In({models:[],loading:!1}),Rr=In({folders:[],activeSessions:[],currentSession:null,loading:!1});function zn(){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 a=r.host||e;return(a==="localhost"||a==="127.0.0.1")&&e&&e!=="localhost"&&e!=="127.0.0.1"&&(a=e),a=a.startsWith("http")?a.replace(/^wss?:\/\//,""):a,`${s}//${a}:${r.port||31415}`}return`${window.location.protocol}//${window.location.host}`}let wr=null,Ss=[],Ts=!1,As=!1,ma=0;const Wi=150,Gi=1e3;async function xa(){Ts=!0;try{const n=zn(),e=Bn(),r=`${n}/sessions${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const a=await s.json();mr.set({folders:a.folders||[],activeSessions:(a.activeSessions||[]).map(o=>o.sessionFile),currentSession:Un(mr).currentSession,loading:!1})}catch(n){mr.update(e=>({...e,loading:!1})),console.error("Failed to fetch sessions:",n)}finally{Ts=!1}}function Dr(){mr.update(r=>({...r,loading:!0}));const n=new Promise(r=>{Ss.push(r)});if(Ts)return As=!0,n;const e=Date.now();if(!wr)ma=e;else if(clearTimeout(wr),e-ma>=Gi)return wr=null,_a(),n;return wr=setTimeout(()=>{wr=null,_a()},Wi),n}async function _a(){const n=[...Ss];Ss=[];try{for(await xa();As;)As=!1,await xa()}finally{for(const e of n)e()}}async function Qa(){Rr.update(n=>({...n,loading:!0}));try{const n=zn(),e=Bn(),r=`${n}/sessions?view=readonly${e?`&token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const a=await s.json();Rr.set({folders:a.folders||[],activeSessions:(a.activeSessions||[]).map(o=>o.sessionFile),currentSession:Un(Rr).currentSession,loading:!1})}catch(n){Rr.update(e=>({...e,loading:!1})),console.error("Failed to fetch read-only sessions:",n)}}async function ji(){xr.update(n=>({...n,loading:!0}));try{const n=zn(),e=Bn(),r=`${n}/models${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const a=await s.json();xr.set({models:a.models||[],loading:!1})}catch(n){xr.update(e=>({...e,loading:!1})),console.error("Failed to fetch models:",n)}}function Bn(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n).token||""}catch{}return""}const Bs=In(!1),Ja=In("websocket"),Hs=In(null),eo=In(!1),to=In(null);async function no(n){if(!n.trim())return null;try{const e=zn(),r=Bn(),s=`${e}/check-path?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,a=await fetch(s);if(!a.ok)throw new Error(`HTTP ${a.status}`);return await a.json()}catch(e){return console.error("Failed to check path:",e),null}}async function Zr(n){try{const e=zn(),r=Bn(),s=`${e}/autocomplete-path?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,a=await fetch(s);if(!a.ok)throw new Error(`HTTP ${a.status}`);return(await a.json()).completions||[]}catch(e){return console.error("Failed to autocomplete path:",e),[]}}async function qi(){try{const n=zn(),e=Bn(),r=`${n}/config${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const a=await s.json();Bs.set(!!a.gitInitDefault),Ja.set(a.uploadMethod||"websocket"),Hs.set(a.searchFolder||null),eo.set(!!a.searchCreateRemote),to.set(a.searchDefaultModel||null)}catch(n){console.error("Failed to fetch config:",n)}}function Lr(n){mr.update(e=>({...e,currentSession:n}))}function Vi(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n)}catch{}return null}function Ur(n){localStorage.setItem("wherever-config",JSON.stringify(n))}function Yn(){const n=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost",e=Vi();return e?(!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:31415,token:"",hideThinking:!1,hideTools:!1,beepDefault:!1,beepSoundUrl:""}}const ts=In(!!Yn().beepDefault),ro="wherever-beep-overrides";function Ki(){try{const n=localStorage.getItem(ro);if(n){const e=JSON.parse(n);if(e&&typeof e=="object")return e}}catch{}return{}}function Yi(n){try{localStorage.setItem(ro,JSON.stringify(n))}catch{}}const so=In(typeof localStorage<"u"?Ki():{}),Ws=In("");function Zi(){return Un(ts)}function ao(){const n=Yn().beepSoundUrl;return typeof n=="string"?n:""}function Xi(n){const e=Yn();Ur({...e,beepSoundUrl:n})}const Gs=Xt([Ws,so],([n,e])=>n&&n in e?e[n]:void 0),js=Xt([Gs,ts],([n,e])=>n===void 0?e:n);function Qi(n){const e=Yn();Ur({...e,beepDefault:n}),ts.set(n)}function Vr(n){const e=Un(Ws);e&&so.update(r=>{const s={...r};return n===void 0?delete s[e]:s[e]=n,Yi(s),s})}function oo(n){Ws.set(n??"")}const kr=Yn(),vt=new Pn({host:kr.host,port:kr.port,token:kr.token,secure:typeof window<"u"&&window.location&&window.location.protocol==="https:",hideThinking:!!kr.hideThinking,hideTools:!!kr.hideTools}),ns=vt.stateStore;let vs=!1,ya=null;ns.subscribe(n=>{const e=n.sessionId??n.activeSessionFile??null;if(e!==ya){ya=e,oo(e),vs=n.isStreaming;return}vs&&!n.isStreaming&&e&&Un(js)&&Xa(ao()),vs=n.isStreaming});let Ir=null;vt.onMessage(n=>{switch(n.type){case"session_created":if(Lr(n.sessionFile),Ir!==null){const r=Ir;Ir=null,queueMicrotask(()=>vt.sendMessage(r))}break;case"session_error":Ir=null;break;case"session_destroyed":Un(ns).sessionId===n.sessionId&&Lr(null);break;case"sessions_updated":Dr();break;case"session_interrupted":Lr(null);break}});function lr(){const n=Yn();Ur(n);const e=typeof window<"u"&&window.location&&window.location.protocol==="https:";vt.connect({host:n.host,port:n.port,token:n.token,secure:e,hideThinking:!!n.hideThinking,hideTools:!!n.hideTools})}function Nr(){vt.disconnect(!0),Lr(null)}function io(){vt.suspend()}function Es(){vt.resume()}function Ji(){return vt.hasSuspendedSession()}function Cs(){return vt.hasActiveSession()}let qs=0;const el=300*1e3;function lo(){qs=Date.now()+el}function Vs(){qs=0}function co(){return Date.now()<qs}function Rs(n){return vt.sendMessage(n)}function uo(n){return vt.resendMessage(n)}function fo(n){vt.discardMessage(n)}function po(){vt.abort()}function ho(n,e,r){vt.joinSession(n,e,r)}function Ks(n,e,r){vt.switchSession(n,e,r)}function Nn(n,e,r,s,a){vt.createSession(n,e,r,s,a)}function bo(n,e){const r=n.trim();if(!r)return!1;const s=Un(Hs);if(!s)return!1;const a=Un(eo);return Ir=r,vt.createSession(s,e||void 0,a,a,a?"private":void 0),!0}function En(){vt.leaveSession(),Lr(null)}function vo(){vt.loadMoreHistory()}function Is(n,e){vt.resolveConflict(n,e)}function tl(){vt.ping()}function go(){vt.clearMessages()}function $s(n){Ur(n);const{host:e,port:r,token:s,hideThinking:a,hideTools:o}=n;vt.setConfig({host:e,port:r,token:s,hideThinking:a,hideTools:o}),n.beepDefault!==void 0&&ts.set(!!n.beepDefault)}function mo(n){const r={...Yn(),...n};Ur(r),vt.setConfig(r)}function cr(){vt.dismissSessionError()}function xo(){vt.dismissNotice()}function _o(n){vt.changeModel(n)}const Ut=Xt(ns,n=>n),zr=Xt(Ut,n=>n.connected),Ys=Xt(Ut,n=>n.isStreaming),yo=Xt(Ut,n=>n.messages),nl=Xt(Ut,n=>n.error),rl=Xt(Ut,n=>n.session),wo=Xt(Ut,n=>n.conflict),ko=Xt(Ut,n=>n.isInterrupted),Zs=Xt(Ut,n=>n.sessionError),So=Xt(Ut,n=>n.notice),rs=Xt(Ut,n=>n.readOnly),Br=Xt(Ut,n=>({sessionFile:n.activeSessionFile,cwd:n.activeCwd,model:n.activeModel,sessionId:n.sessionId})),sl=Xt(Ut,n=>n.contextUsage),To=Xt(Ut,n=>n.creatingSession),ss=Xt(Ut,n=>n.loadingSession),Xs=Xt(Ut,n=>n.resyncing),Ao=Xt(Ut,n=>n.agentPending),Eo=Xt(Ut,n=>n.historyOffset>0),Co=Xt(Ut,n=>n.loadingMoreHistory);async function al(n,e){const r=zn(),s=Bn(),a=`${r}/session/upload?sessionId=${encodeURIComponent(n)}&filename=${encodeURIComponent(e.name)}${s?`&token=${encodeURIComponent(s)}`:""}`,o=await e.arrayBuffer(),i=await fetch(a,{method:"POST",headers:{"Content-Type":"text/plain"},body:o});if(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(c.error||`Upload failed with status ${i.status}`)}return await i.json()}function ol(n,e){return new Promise((r,s)=>{try{const a=new FileReader;a.onload=()=>{try{const i=a.result.split(",")[1]||"";vt.uploadFileViaWebSocket(n,e.name,i).then(r).catch(s)}catch(o){s(new Error(`Failed to process file data: ${o.message}`))}},a.onerror=()=>{s(new Error("Failed to read file contents"))},a.readAsDataURL(e)}catch(a){s(a)}})}function Ro(n){const r=Un(Ut).sessionId;if(!r)return null;const s=zn(),a=Bn();return`${s}/session/download?sessionId=${encodeURIComponent(r)}&path=${encodeURIComponent(n)}`+(a?`&token=${encodeURIComponent(a)}`:"")}async function Io(n,e){return Un(Ja)==="post"?al(n,e):ol(n,e)}async function Ms(n){try{const e=zn(),r=Bn(),s=`${e}/session/delete${r?`?token=${encodeURIComponent(r)}`:""}`,a=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionFile:n})});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.error||`Delete failed with status ${a.status}`)}}catch(e){throw console.error("Failed to delete session:",e),e}}const il=Object.freeze(Object.defineProperty({__proto__:null,abort:po,activeSessionInfo:Br,beepEnabled:js,beepSessionOverride:Gs,beginFilePicker:lo,changeModel:_o,clearMessages:go,client:vt,conflict:wo,connect:lr,connectionError:nl,contextUsage:sl,createSession:Nn,currentSession:rl,deleteSession:Ms,discardMessage:fo,disconnect:Nr,dismissNotice:xo,dismissSessionError:cr,downloadFileUrl:Ro,endFilePicker:Vs,getBeepDefault:Zi,getBeepSoundUrl:ao,getConfig:Yn,hasActiveSession:Cs,hasMoreHistory:Eo,hasSuspendedSession:Ji,isAgentPending:Ao,isConnected:zr,isCreatingSession:To,isFilePickerActive:co,isInterrupted:ko,isLoadingMoreHistory:Co,isLoadingSession:ss,isReadOnly:rs,isResyncing:Xs,isStreaming:Ys,joinSession:ho,leaveSession:En,loadMoreHistory:vo,messages:yo,piState:Ut,ping:tl,resendMessage:uo,resolveConflict:Is,resume:Es,runSearch:bo,sendMessage:Rs,sessionError:Zs,sessionNotice:So,setBeepDefault:Qi,setBeepSessionKey:oo,setBeepSessionOverride:Vr,setBeepSoundUrl:Xi,setConfig:$s,state:ns,suspend:io,switchSession:Ks,updateConfig:mo,uploadFile:Io},Symbol.toStringTag,{value:"Module"}));var ll=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>'),cl=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>'),dl=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 ul(n,e){nr(e,!0);const r=()=>Me(zr,"$isConnected",s),[s,a]=_r();let o=Z(""),i=Z(0),c=Z(""),_=Z(!1),v=Z(!1),m=Z(""),E=!1,L=V(r);Fr(()=>{const K=Yn();h(o,K.host,!0),h(i,K.port,!0),h(c,K.token||"",!0),h(_,!!K.hideThinking),h(v,!!K.beepDefault),h(m,K.beepSoundUrl||"",!0)});function P(){Xa(t(m).trim()||void 0)}function S(){$s({host:t(o),port:t(i),token:t(c),hideThinking:t(_),hideTools:!1,beepDefault:t(v),beepSoundUrl:t(m).trim()})}function oe(){$s({host:t(o),port:t(i),token:t(c),hideThinking:t(_),hideTools:!1,beepDefault:t(v),beepSoundUrl:t(m).trim()}),Nr(),setTimeout(()=>lr(),100)}function ae(){Nr()}function me(){window.location.reload()}var de=dl(),Je=u(de),Ie=u(Je),Oe=f(u(Ie),2);dt(Oe),d(Ie);var ke=f(Ie,2),Ue=f(u(ke),2);dt(Ue),d(ke);var We=f(ke,2),Lt=f(u(We),2);dt(Lt),d(We);var ot=f(We,2),be=u(ot);dt(be),at(2),d(ot);var Ye=f(ot,2),qt=u(Ye);dt(qt),at(2),d(Ye);var Ge=f(Ye,2),it=f(u(Ge),2),Et=u(it);dt(Et);var lt=f(Et,2);d(it),d(Ge);var rt=f(Ge,2),ye=u(rt);{var ct=K=>{var wt=ll();W("click",wt,ae),p(K,wt)},Ee=K=>{var wt=cl();wt.disabled=E,wt.textContent="Connect",W("click",wt,oe),p(K,wt)};A(ye,K=>{t(L)?K(ct):K(Ee,-1)})}d(rt);var zt=f(rt,2);d(Je),d(de),Fn(Oe,()=>t(o),K=>h(o,K)),Fn(Ue,()=>t(i),K=>h(i,K)),Fn(Lt,()=>t(c),K=>h(c,K)),W("change",be,S),Rn(be,()=>t(_),K=>h(_,K)),W("change",qt,S),Rn(qt,()=>t(v),K=>h(v,K)),W("change",Et,S),Fn(Et,()=>t(m),K=>h(m,K)),W("click",lt,P),W("click",zt,me),p(n,de),rr(),a()}ur(["change","click"]);function Qs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var fr=Qs();function $o(n){fr=n}var Or={exec:()=>null};function pt(n,e=""){let r=typeof n=="string"?n:n.source;const s={replace:(a,o)=>{let i=typeof o=="string"?o:o.source;return i=i.replace(vn.caret,"$1"),r=r.replace(a,i),s},getRegex:()=>new RegExp(r,e)};return s}var vn={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")},fl=/^(?:[ \t]*(?:\n|$))+/,pl=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,hl=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Hr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,bl=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Js=/(?:[*+-]|\d{1,9}[.)])/,Mo=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Do=pt(Mo).replace(/bull/g,Js).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(),vl=pt(Mo).replace(/bull/g,Js).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(),ea=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,gl=/^[^\n]+/,ta=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ml=pt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ta).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),xl=pt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Js).getRegex(),as="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",na=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,_l=pt("^ {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",na).replace("tag",as).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Lo=pt(ea).replace("hr",Hr).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",as).getRegex(),yl=pt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Lo).getRegex(),ra={blockquote:yl,code:pl,def:ml,fences:hl,heading:bl,hr:Hr,html:_l,lheading:Do,list:xl,newline:fl,paragraph:Lo,table:Or,text:gl},wa=pt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Hr).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",as).getRegex(),wl={...ra,lheading:vl,table:wa,paragraph:pt(ea).replace("hr",Hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",wa).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",as).getRegex()},kl={...ra,html:pt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",na).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:Or,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:pt(ea).replace("hr",Hr).replace("heading",` *#{1,6} *[^
|
|
11
|
+
]`).replace("lheading",Do).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Sl=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Tl=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Oo=/^( {2,}|\\)\n(?!\s*$)/,Al=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,os=/[\p{P}\p{S}]/u,sa=/[\s\p{P}\p{S}]/u,Po=/[^\s\p{P}\p{S}]/u,El=pt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,sa).getRegex(),No=/(?!~)[\p{P}\p{S}]/u,Cl=/(?!~)[\s\p{P}\p{S}]/u,Rl=/(?:[^\s\p{P}\p{S}]|~)/u,Il=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Fo=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,$l=pt(Fo,"u").replace(/punct/g,os).getRegex(),Ml=pt(Fo,"u").replace(/punct/g,No).getRegex(),Uo="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Dl=pt(Uo,"gu").replace(/notPunctSpace/g,Po).replace(/punctSpace/g,sa).replace(/punct/g,os).getRegex(),Ll=pt(Uo,"gu").replace(/notPunctSpace/g,Rl).replace(/punctSpace/g,Cl).replace(/punct/g,No).getRegex(),Ol=pt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Po).replace(/punctSpace/g,sa).replace(/punct/g,os).getRegex(),Pl=pt(/\\(punct)/,"gu").replace(/punct/g,os).getRegex(),Nl=pt(/^<(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(),Fl=pt(na).replace("(?:-->|$)","-->").getRegex(),Ul=pt("^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",Fl).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Xr=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,zl=pt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Xr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),zo=pt(/^!?\[(label)\]\[(ref)\]/).replace("label",Xr).replace("ref",ta).getRegex(),Bo=pt(/^!?\[(ref)\](?:\[\])?/).replace("ref",ta).getRegex(),Bl=pt("reflink|nolink(?!\\()","g").replace("reflink",zo).replace("nolink",Bo).getRegex(),aa={_backpedal:Or,anyPunctuation:Pl,autolink:Nl,blockSkip:Il,br:Oo,code:Tl,del:Or,emStrongLDelim:$l,emStrongRDelimAst:Dl,emStrongRDelimUnd:Ol,escape:Sl,link:zl,nolink:Bo,punctuation:El,reflink:zo,reflinkSearch:Bl,tag:Ul,text:Al,url:Or},Hl={...aa,link:pt(/^!?\[(label)\]\((.*?)\)/).replace("label",Xr).getRegex(),reflink:pt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Xr).getRegex()},Ds={...aa,emStrongRDelimAst:Ll,emStrongLDelim:Ml,url:pt(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Wl={...Ds,br:pt(Oo).replace("{2,}","*").getRegex(),text:pt(Ds.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Gr={normal:ra,gfm:wl,pedantic:kl},Sr={normal:aa,gfm:Ds,breaks:Wl,pedantic:Hl},Gl={"&":"&","<":"<",">":">",'"':""","'":"'"},ka=n=>Gl[n];function Ln(n,e){if(e){if(vn.escapeTest.test(n))return n.replace(vn.escapeReplace,ka)}else if(vn.escapeTestNoEncode.test(n))return n.replace(vn.escapeReplaceNoEncode,ka);return n}function Sa(n){try{n=encodeURI(n).replace(vn.percentDecode,"%")}catch{return null}return n}function Ta(n,e){const r=n.replace(vn.findPipe,(o,i,c)=>{let _=!1,v=i;for(;--v>=0&&c[v]==="\\";)_=!_;return _?"|":" |"}),s=r.split(vn.splitPipe);let a=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(;a<s.length;a++)s[a]=s[a].trim().replace(vn.slashPipe,"|");return s}function Tr(n,e,r){const s=n.length;if(s===0)return"";let a=0;for(;a<s&&n.charAt(s-a-1)===e;)a++;return n.slice(0,s-a)}function jl(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 Aa(n,e,r,s,a){const o=e.href,i=e.title||null,c=n[1].replace(a.other.outputLinkReplace,"$1");s.state.inLink=!0;const _={type:n[0].charAt(0)==="!"?"image":"link",raw:r,href:o,title:i,text:c,tokens:s.inlineTokens(c)};return s.state.inLink=!1,_}function ql(n,e,r){const s=n.match(r.other.indentCodeCompensation);if(s===null)return e;const a=s[1];return e.split(`
|
|
12
|
+
`).map(o=>{const i=o.match(r.other.beginningSpace);if(i===null)return o;const[c]=i;return c.length>=a.length?o.slice(a.length):o}).join(`
|
|
13
|
+
`)}var Qr=class{options;rules;lexer;constructor(n){this.options=n||fr}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:Tr(r,`
|
|
14
|
+
`)}}}fences(n){const e=this.rules.block.fences.exec(n);if(e){const r=e[0],s=ql(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=Tr(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:Tr(e[0],`
|
|
15
|
+
`)}}blockquote(n){const e=this.rules.block.blockquote.exec(n);if(e){let r=Tr(e[0],`
|
|
16
|
+
`).split(`
|
|
17
|
+
`),s="",a="";const o=[];for(;r.length>0;){let i=!1;const c=[];let _;for(_=0;_<r.length;_++)if(this.rules.other.blockquoteStart.test(r[_]))c.push(r[_]),i=!0;else if(!i)c.push(r[_]);else break;r=r.slice(_);const v=c.join(`
|
|
18
|
+
`),m=v.replace(this.rules.other.blockquoteSetextReplace,`
|
|
19
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
20
|
+
${v}`:v,a=a?`${a}
|
|
21
|
+
${m}`:m;const E=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(m,o,!0),this.lexer.state.top=E,r.length===0)break;const L=o.at(-1);if(L?.type==="code")break;if(L?.type==="blockquote"){const P=L,S=P.raw+`
|
|
22
|
+
`+r.join(`
|
|
23
|
+
`),oe=this.blockquote(S);o[o.length-1]=oe,s=s.substring(0,s.length-P.raw.length)+oe.raw,a=a.substring(0,a.length-P.text.length)+oe.text;break}else if(L?.type==="list"){const P=L,S=P.raw+`
|
|
24
|
+
`+r.join(`
|
|
25
|
+
`),oe=this.list(S);o[o.length-1]=oe,s=s.substring(0,s.length-L.raw.length)+oe.raw,a=a.substring(0,a.length-P.raw.length)+oe.raw,r=S.substring(o.at(-1).raw.length).split(`
|
|
26
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:o,text:a}}}list(n){let e=this.rules.block.list.exec(n);if(e){let r=e[1].trim();const s=r.length>1,a={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 o=this.rules.other.listItemRegex(r);let i=!1;for(;n;){let _=!1,v="",m="";if(!(e=o.exec(n))||this.rules.block.hr.test(n))break;v=e[0],n=n.substring(v.length);let E=e[2].split(`
|
|
27
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,me=>" ".repeat(3*me.length)),L=n.split(`
|
|
28
|
+
`,1)[0],P=!E.trim(),S=0;if(this.options.pedantic?(S=2,m=E.trimStart()):P?S=e[1].length+1:(S=e[2].search(this.rules.other.nonSpaceChar),S=S>4?1:S,m=E.slice(S),S+=e[1].length),P&&this.rules.other.blankLine.test(L)&&(v+=L+`
|
|
29
|
+
`,n=n.substring(L.length+1),_=!0),!_){const me=this.rules.other.nextBulletRegex(S),de=this.rules.other.hrRegex(S),Je=this.rules.other.fencesBeginRegex(S),Ie=this.rules.other.headingBeginRegex(S),Oe=this.rules.other.htmlBeginRegex(S);for(;n;){const ke=n.split(`
|
|
30
|
+
`,1)[0];let Ue;if(L=ke,this.options.pedantic?(L=L.replace(this.rules.other.listReplaceNesting," "),Ue=L):Ue=L.replace(this.rules.other.tabCharGlobal," "),Je.test(L)||Ie.test(L)||Oe.test(L)||me.test(L)||de.test(L))break;if(Ue.search(this.rules.other.nonSpaceChar)>=S||!L.trim())m+=`
|
|
31
|
+
`+Ue.slice(S);else{if(P||E.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Je.test(E)||Ie.test(E)||de.test(E))break;m+=`
|
|
32
|
+
`+L}!P&&!L.trim()&&(P=!0),v+=ke+`
|
|
33
|
+
`,n=n.substring(ke.length+1),E=Ue.slice(S)}}a.loose||(i?a.loose=!0:this.rules.other.doubleBlankLine.test(v)&&(i=!0));let oe=null,ae;this.options.gfm&&(oe=this.rules.other.listIsTask.exec(m),oe&&(ae=oe[0]!=="[ ] ",m=m.replace(this.rules.other.listReplaceTask,""))),a.items.push({type:"list_item",raw:v,task:!!oe,checked:ae,loose:!1,text:m,tokens:[]}),a.raw+=v}const c=a.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;a.raw=a.raw.trimEnd();for(let _=0;_<a.items.length;_++)if(this.lexer.state.top=!1,a.items[_].tokens=this.lexer.blockTokens(a.items[_].text,[]),!a.loose){const v=a.items[_].tokens.filter(E=>E.type==="space"),m=v.length>0&&v.some(E=>this.rules.other.anyLine.test(E.raw));a.loose=m}if(a.loose)for(let _=0;_<a.items.length;_++)a.items[_].loose=!0;return a}}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"):"",a=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:a}}}table(n){const e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const r=Ta(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
34
|
+
`):[],o={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===s.length){for(const i of s)this.rules.other.tableAlignRight.test(i)?o.align.push("right"):this.rules.other.tableAlignCenter.test(i)?o.align.push("center"):this.rules.other.tableAlignLeft.test(i)?o.align.push("left"):o.align.push(null);for(let i=0;i<r.length;i++)o.header.push({text:r[i],tokens:this.lexer.inline(r[i]),header:!0,align:o.align[i]});for(const i of a)o.rows.push(Ta(i,o.header.length).map((c,_)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:o.align[_]})));return o}}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 o=Tr(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{const o=jl(e[2],"()");if(o===-2)return;if(o>-1){const c=(e[0].indexOf("!")===0?5:4)+e[1].length+o;e[2]=e[2].substring(0,o),e[0]=e[0].substring(0,c).trim(),e[3]=""}}let s=e[2],a="";if(this.options.pedantic){const o=this.rules.other.pedanticHrefTitle.exec(s);o&&(s=o[1],a=o[3])}else a=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)),Aa(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.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," "),a=e[s.toLowerCase()];if(!a){const o=r[0].charAt(0);return{type:"text",raw:o,text:o}}return Aa(r,a,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 o=[...s[0]].length-1;let i,c,_=o,v=0;const m=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(m.lastIndex=0,e=e.slice(-1*n.length+o);(s=m.exec(e))!=null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(c=[...i].length,s[3]||s[4]){_+=c;continue}else if((s[5]||s[6])&&o%3&&!((o+c)%3)){v+=c;continue}if(_-=c,_>0)continue;c=Math.min(c,c+_+v);const E=[...s[0]][0].length,L=n.slice(0,o+s.index+E+c);if(Math.min(o,c)%2){const S=L.slice(1,-1);return{type:"em",raw:L,text:S,tokens:this.lexer.inlineTokens(S)}}const P=L.slice(2,-2);return{type:"strong",raw:L,text:P,tokens:this.lexer.inlineTokens(P)}}}}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),a=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return s&&a&&(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 a;do a=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(a!==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}}}},qn=class Ls{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||fr,this.options.tokenizer=this.options.tokenizer||new Qr,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:vn,block:Gr.normal,inline:Sr.normal};this.options.pedantic?(r.block=Gr.pedantic,r.inline=Sr.pedantic):this.options.gfm&&(r.block=Gr.gfm,this.options.breaks?r.inline=Sr.breaks:r.inline=Sr.gfm),this.tokenizer.rules=r}static get rules(){return{block:Gr,inline:Sr}}static lex(e,r){return new Ls(r).lex(e)}static lexInline(e,r){return new Ls(r).inlineTokens(e)}lex(e){e=e.replace(vn.carriageReturn,`
|
|
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(vn.tabCharGlobal," ").replace(vn.spaceLine,""));e;){let a;if(this.options.extensions?.block?.some(i=>(a=i.call({lexer:this},e,r))?(e=e.substring(a.raw.length),r.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);const i=r.at(-1);a.raw.length===1&&i!==void 0?i.raw+=`
|
|
37
|
+
`:r.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);const i=r.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=`
|
|
38
|
+
`+a.raw,i.text+=`
|
|
39
|
+
`+a.text,this.inlineQueue.at(-1).src=i.text):r.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);const i=r.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=`
|
|
40
|
+
`+a.raw,i.text+=`
|
|
41
|
+
`+a.raw,this.inlineQueue.at(-1).src=i.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title});continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),r.push(a);continue}let o=e;if(this.options.extensions?.startBlock){let i=1/0;const c=e.slice(1);let _;this.options.extensions.startBlock.forEach(v=>{_=v.call({lexer:this},c),typeof _=="number"&&_>=0&&(i=Math.min(i,_))}),i<1/0&&i>=0&&(o=e.substring(0,i+1))}if(this.state.top&&(a=this.tokenizer.paragraph(o))){const i=r.at(-1);s&&i?.type==="paragraph"?(i.raw+=`
|
|
42
|
+
`+a.raw,i.text+=`
|
|
43
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):r.push(a),s=o.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);const i=r.at(-1);i?.type==="text"?(i.raw+=`
|
|
44
|
+
`+a.raw,i.text+=`
|
|
45
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):r.push(a);continue}if(e){const i="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}inlineTokens(e,r=[]){let s=e,a=null;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)c.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,a.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(a=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let o=!1,i="";for(;e;){o||(i=""),o=!1;let c;if(this.options.extensions?.inline?.some(v=>(c=v.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 v=r.at(-1);c.type==="text"&&v?.type==="text"?(v.raw+=c.raw,v.text+=c.text):r.push(c);continue}if(c=this.tokenizer.emStrong(e,s,i)){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 v=1/0;const m=e.slice(1);let E;this.options.extensions.startInline.forEach(L=>{E=L.call({lexer:this},m),typeof E=="number"&&E>=0&&(v=Math.min(v,E))}),v<1/0&&v>=0&&(_=e.substring(0,v+1))}if(c=this.tokenizer.inlineText(_)){e=e.substring(c.raw.length),c.raw.slice(-1)!=="_"&&(i=c.raw.slice(-1)),o=!0;const v=r.at(-1);v?.type==="text"?(v.raw+=c.raw,v.text+=c.text):r.push(c);continue}if(e){const v="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(v);break}else throw new Error(v)}}return r}},Jr=class{options;parser;constructor(n){this.options=n||fr}space(n){return""}code({text:n,lang:e,escaped:r}){const s=(e||"").match(vn.notSpaceStart)?.[0],a=n.replace(vn.endingNewline,"")+`
|
|
46
|
+
`;return s?'<pre><code class="language-'+Ln(s)+'">'+(r?a:Ln(a,!0))+`</code></pre>
|
|
47
|
+
`:"<pre><code>"+(r?a:Ln(a,!0))+`</code></pre>
|
|
48
|
+
`}blockquote({tokens:n}){return`<blockquote>
|
|
49
|
+
${this.parser.parse(n)}</blockquote>
|
|
50
|
+
`}html({text:n}){return n}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
|
|
51
|
+
`}hr(n){return`<hr>
|
|
52
|
+
`}list(n){const e=n.ordered,r=n.start;let s="";for(let i=0;i<n.items.length;i++){const c=n.items[i];s+=this.listitem(c)}const a=e?"ol":"ul",o=e&&r!==1?' start="'+r+'"':"";return"<"+a+o+`>
|
|
53
|
+
`+s+"</"+a+`>
|
|
54
|
+
`}listitem(n){let e="";if(n.task){const r=this.checkbox({checked:!!n.checked});n.loose?n.tokens[0]?.type==="paragraph"?(n.tokens[0].text=r+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type==="text"&&(n.tokens[0].tokens[0].text=r+" "+Ln(n.tokens[0].tokens[0].text),n.tokens[0].tokens[0].escaped=!0)):n.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):e+=r+" "}return e+=this.parser.parse(n.tokens,!!n.loose),`<li>${e}</li>
|
|
55
|
+
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
56
|
+
`}table(n){let e="",r="";for(let a=0;a<n.header.length;a++)r+=this.tablecell(n.header[a]);e+=this.tablerow({text:r});let s="";for(let a=0;a<n.rows.length;a++){const o=n.rows[a];r="";for(let i=0;i<o.length;i++)r+=this.tablecell(o[i]);s+=this.tablerow({text:r})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
57
|
+
<thead>
|
|
58
|
+
`+e+`</thead>
|
|
59
|
+
`+s+`</table>
|
|
60
|
+
`}tablerow({text:n}){return`<tr>
|
|
61
|
+
${n}</tr>
|
|
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>${Ln(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),a=Sa(n);if(a===null)return s;n=a;let o='<a href="'+n+'"';return e&&(o+=' title="'+Ln(e)+'"'),o+=">"+s+"</a>",o}image({href:n,title:e,text:r,tokens:s}){s&&(r=this.parser.parseInline(s,this.parser.textRenderer));const a=Sa(n);if(a===null)return Ln(r);n=a;let o=`<img src="${n}" alt="${r}"`;return e&&(o+=` title="${Ln(e)}"`),o+=">",o}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:Ln(n.text)}},oa=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""}},Vn=class Os{options;renderer;textRenderer;constructor(e){this.options=e||fr,this.options.renderer=this.options.renderer||new Jr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new oa}static parse(e,r){return new Os(r).parse(e)}static parseInline(e,r){return new Os(r).parseInline(e)}parse(e,r=!0){let s="";for(let a=0;a<e.length;a++){const o=e[a];if(this.options.extensions?.renderers?.[o.type]){const c=o,_=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 i=o;switch(i.type){case"space":{s+=this.renderer.space(i);continue}case"hr":{s+=this.renderer.hr(i);continue}case"heading":{s+=this.renderer.heading(i);continue}case"code":{s+=this.renderer.code(i);continue}case"table":{s+=this.renderer.table(i);continue}case"blockquote":{s+=this.renderer.blockquote(i);continue}case"list":{s+=this.renderer.list(i);continue}case"html":{s+=this.renderer.html(i);continue}case"paragraph":{s+=this.renderer.paragraph(i);continue}case"text":{let c=i,_=this.renderer.text(c);for(;a+1<e.length&&e[a+1].type==="text";)c=e[++a],_+=`
|
|
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 "'+i.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 a=0;a<e.length;a++){const o=e[a];if(this.options.extensions?.renderers?.[o.type]){const c=this.options.extensions.renderers[o.type].call({parser:this},o);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){s+=c||"";continue}}const i=o;switch(i.type){case"escape":{s+=r.text(i);break}case"html":{s+=r.html(i);break}case"link":{s+=r.link(i);break}case"image":{s+=r.image(i);break}case"strong":{s+=r.strong(i);break}case"em":{s+=r.em(i);break}case"codespan":{s+=r.codespan(i);break}case"br":{s+=r.br(i);break}case"del":{s+=r.del(i);break}case"text":{s+=r.text(i);break}default:{const c='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},Kr=class{options;block;constructor(n){this.options=n||fr}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?qn.lex:qn.lexInline}provideParser(){return this.block?Vn.parse:Vn.parseInline}},Vl=class{defaults=Qs();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Vn;Renderer=Jr;TextRenderer=oa;Lexer=qn;Tokenizer=Qr;Hooks=Kr;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 a=s;for(const o of a.header)r=r.concat(this.walkTokens(o.tokens,e));for(const o of a.rows)for(const i of o)r=r.concat(this.walkTokens(i.tokens,e));break}case"list":{const a=s;r=r.concat(this.walkTokens(a.items,e));break}default:{const a=s;this.defaults.extensions?.childTokens?.[a.type]?this.defaults.extensions.childTokens[a.type].forEach(o=>{const i=a[o].flat(1/0);r=r.concat(this.walkTokens(i,e))}):a.tokens&&(r=r.concat(this.walkTokens(a.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(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const o=e.renderers[a.name];o?e.renderers[a.name]=function(...i){let c=a.renderer.apply(this,i);return c===!1&&(c=o.apply(this,i)),c}:e.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const o=e[a.level];o?o.unshift(a.tokenizer):e[a.level]=[a.tokenizer],a.start&&(a.level==="block"?e.startBlock?e.startBlock.push(a.start):e.startBlock=[a.start]:a.level==="inline"&&(e.startInline?e.startInline.push(a.start):e.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(e.childTokens[a.name]=a.childTokens)}),s.extensions=e),r.renderer){const a=this.defaults.renderer||new Jr(this.defaults);for(const o in r.renderer){if(!(o in a))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;const i=o,c=r.renderer[i],_=a[i];a[i]=(...v)=>{let m=c.apply(a,v);return m===!1&&(m=_.apply(a,v)),m||""}}s.renderer=a}if(r.tokenizer){const a=this.defaults.tokenizer||new Qr(this.defaults);for(const o in r.tokenizer){if(!(o in a))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;const i=o,c=r.tokenizer[i],_=a[i];a[i]=(...v)=>{let m=c.apply(a,v);return m===!1&&(m=_.apply(a,v)),m}}s.tokenizer=a}if(r.hooks){const a=this.defaults.hooks||new Kr;for(const o in r.hooks){if(!(o in a))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;const i=o,c=r.hooks[i],_=a[i];Kr.passThroughHooks.has(o)?a[i]=v=>{if(this.defaults.async)return Promise.resolve(c.call(a,v)).then(E=>_.call(a,E));const m=c.call(a,v);return _.call(a,m)}:a[i]=(...v)=>{let m=c.apply(a,v);return m===!1&&(m=_.apply(a,v)),m}}s.hooks=a}if(r.walkTokens){const a=this.defaults.walkTokens,o=r.walkTokens;s.walkTokens=function(i){let c=[];return c.push(o.call(this,i)),a&&(c=c.concat(a.call(this,i))),c}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return qn.lex(n,e??this.defaults)}parser(n,e){return Vn.parse(n,e??this.defaults)}parseMarkdown(n){return(r,s)=>{const a={...s},o={...this.defaults,...a},i=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&a.async===!1)return i(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 i(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));o.hooks&&(o.hooks.options=o,o.hooks.block=n);const c=o.hooks?o.hooks.provideLexer():n?qn.lex:qn.lexInline,_=o.hooks?o.hooks.provideParser():n?Vn.parse:Vn.parseInline;if(o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(r):r).then(v=>c(v,o)).then(v=>o.hooks?o.hooks.processAllTokens(v):v).then(v=>o.walkTokens?Promise.all(this.walkTokens(v,o.walkTokens)).then(()=>v):v).then(v=>_(v,o)).then(v=>o.hooks?o.hooks.postprocess(v):v).catch(i);try{o.hooks&&(r=o.hooks.preprocess(r));let v=c(r,o);o.hooks&&(v=o.hooks.processAllTokens(v)),o.walkTokens&&this.walkTokens(v,o.walkTokens);let m=_(v,o);return o.hooks&&(m=o.hooks.postprocess(m)),m}catch(v){return i(v)}}}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>"+Ln(r.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(r);throw r}}},dr=new Vl;function ut(n,e){return dr.parse(n,e)}ut.options=ut.setOptions=function(n){return dr.setOptions(n),ut.defaults=dr.defaults,$o(ut.defaults),ut};ut.getDefaults=Qs;ut.defaults=fr;ut.use=function(...n){return dr.use(...n),ut.defaults=dr.defaults,$o(ut.defaults),ut};ut.walkTokens=function(n,e){return dr.walkTokens(n,e)};ut.parseInline=dr.parseInline;ut.Parser=Vn;ut.parser=Vn.parse;ut.Renderer=Jr;ut.TextRenderer=oa;ut.Lexer=qn;ut.lexer=qn.lex;ut.Tokenizer=Qr;ut.Hooks=Kr;ut.parse=ut;ut.options;ut.setOptions;ut.use;ut.walkTokens;ut.parseInline;Vn.parse;qn.lex;function Ea(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 Kl(n){if(Array.isArray(n))return n}function Yl(n,e){var r=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(r!=null){var s,a,o,i,c=[],_=!0,v=!1;try{if(o=(r=r.call(n)).next,e!==0)for(;!(_=(s=o.call(r)).done)&&(c.push(s.value),c.length!==e);_=!0);}catch(m){v=!0,a=m}finally{try{if(!_&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(v)throw a}}return c}}function Zl(){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 Xl(n,e){return Kl(n)||Yl(n,e)||Ql(n,e)||Zl()}function Ql(n,e){if(n){if(typeof n=="string")return Ea(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)?Ea(n,e):void 0}}const Ho=Object.entries,Ca=Object.setPrototypeOf,Jl=Object.isFrozen,ec=Object.getPrototypeOf,tc=Object.getOwnPropertyDescriptor;let cn=Object.freeze,dn=Object.seal,vr=Object.create,Wo=typeof Reflect<"u"&&Reflect,Ps=Wo.apply,Ns=Wo.construct;cn||(cn=function(e){return e});dn||(dn=function(e){return e});Ps||(Ps=function(e,r){for(var s=arguments.length,a=new Array(s>2?s-2:0),o=2;o<s;o++)a[o-2]=arguments[o];return e.apply(r,a)});Ns||(Ns=function(e){for(var r=arguments.length,s=new Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];return new e(...s)});const Ar=tn(Array.prototype.forEach),nc=tn(Array.prototype.lastIndexOf),Ra=tn(Array.prototype.pop),hr=tn(Array.prototype.push),rc=tn(Array.prototype.splice),Jn=Array.isArray,$r=tn(String.prototype.toLowerCase),gs=tn(String.prototype.toString),Ia=tn(String.prototype.match),Er=tn(String.prototype.replace),$a=tn(String.prototype.indexOf),sc=tn(String.prototype.trim),ac=tn(Number.prototype.toString),oc=tn(Boolean.prototype.toString),Ma=typeof BigInt>"u"?null:tn(BigInt.prototype.toString),Da=typeof Symbol>"u"?null:tn(Symbol.prototype.toString),an=tn(Object.prototype.hasOwnProperty),Cr=tn(Object.prototype.toString),ln=tn(RegExp.prototype.test),or=ic(TypeError);function tn(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var r=arguments.length,s=new Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];return Ps(n,e,s)}}function ic(n){return function(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return Ns(n,r)}}function et(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:$r;if(Ca&&Ca(n,null),!Jn(e))return n;let s=e.length;for(;s--;){let a=e[s];if(typeof a=="string"){const o=r(a);o!==a&&(Jl(e)||(e[s]=o),a=o)}n[a]=!0}return n}function lc(n){for(let e=0;e<n.length;e++)an(n,e)||(n[e]=null);return n}function bn(n){const e=vr(null);for(const s of Ho(n)){var r=Xl(s,2);const a=r[0],o=r[1];an(n,a)&&(Jn(o)?e[a]=lc(o):o&&typeof o=="object"&&o.constructor===Object?e[a]=bn(o):e[a]=o)}return e}function cc(n){switch(typeof n){case"string":return n;case"number":return ac(n);case"boolean":return oc(n);case"bigint":return Ma?Ma(n):"0";case"symbol":return Da?Da(n):"Symbol()";case"undefined":return Cr(n);case"function":case"object":{if(n===null)return Cr(n);const e=n,r=On(e,"toString");if(typeof r=="function"){const s=r(e);return typeof s=="string"?s:Cr(s)}return Cr(n)}default:return Cr(n)}}function On(n,e){for(;n!==null;){const s=tc(n,e);if(s){if(s.get)return tn(s.get);if(typeof s.value=="function")return tn(s.value)}n=ec(n)}function r(){return null}return r}function dc(n){try{return ln(n,""),!0}catch{return!1}}const La=cn(["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"]),ms=cn(["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"]),xs=cn(["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"]),uc=cn(["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"]),_s=cn(["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"]),fc=cn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Oa=cn(["#text"]),Pa=cn(["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"]),ys=cn(["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"]),Na=cn(["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=cn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),pc=dn(/{{[\w\W]*|^[\w\W]*}}/g),hc=dn(/<%[\w\W]*|^[\w\W]*%>/g),bc=dn(/\${[\w\W]*/g),vc=dn(/^data-[\-\w.\u00B7-\uFFFF]+$/),gc=dn(/^aria-[\-\w]+$/),Fa=dn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),mc=dn(/^(?:\w+script|data):/i),xc=dn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),_c=dn(/^html$/i),yc=dn(/^[a-z][.\w]*(-[.\w]+)+$/i),Ua=dn(/<[/\w!]/g),wc=dn(/<[/\w]/g),kc=dn(/<\/no(script|embed|frames)/i),Sc=dn(/\/>/i),Dn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Tc=function(){return typeof window>"u"?null:window},Ac=function(e,r){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let s=null;const a="data-tt-policy-suffix";r&&r.hasAttribute(a)&&(s=r.getAttribute(a));const o="dompurify"+(s?"#"+s:"");try{return e.createPolicy(o,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},za=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Xn=function(e,r,s,a){return an(e,r)&&Jn(e[r])?et(a.base?bn(a.base):{},e[r],a.transform):s};function Go(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Tc();const e=C=>Go(C);if(e.version="3.4.11",e.removed=[],!n||!n.document||n.document.nodeType!==Dn.document||!n.Element)return e.isSupported=!1,e;let r=n.document;const s=r,a=s.currentScript;n.DocumentFragment;const o=n.HTMLTemplateElement,i=n.Node,c=n.Element,_=n.NodeFilter,v=n.NamedNodeMap;v===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const m=n.DOMParser,E=n.trustedTypes,L=c.prototype,P=On(L,"cloneNode"),S=On(L,"remove"),oe=On(L,"nextSibling"),ae=On(L,"childNodes"),me=On(L,"parentNode"),de=On(L,"shadowRoot"),Je=On(L,"attributes"),Ie=i&&i.prototype?On(i.prototype,"nodeType"):null,Oe=i&&i.prototype?On(i.prototype,"nodeName"):null;if(typeof o=="function"){const C=r.createElement("template");C.content&&C.content.ownerDocument&&(r=C.content.ownerDocument)}let ke,Ue="",We,Lt=!1,ot=0;const be=function(){if(ot>0)throw or('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.')},Ye=function(l){be(),ot++;try{return ke.createHTML(l)}finally{ot--}},qt=function(l){be(),ot++;try{return ke.createScriptURL(l)}finally{ot--}},Ge=function(){return Lt||(We=Ac(E,a),Lt=!0),We},it=r,Et=it.implementation,lt=it.createNodeIterator,rt=it.createDocumentFragment,ye=it.getElementsByTagName,ct=s.importNode;let Ee=za();e.isSupported=typeof Ho=="function"&&typeof me=="function"&&Et&&Et.createHTMLDocument!==void 0;const zt=pc,K=hc,wt=bc,on=vc,ht=gc,kt=mc,je=xc,Y=yc;let _e=Fa,k=null;const re=et({},[...La,...ms,...xs,..._s,...Oa]);let T=null;const se=et({},[...Pa,...ys,...Na,...jr]);let z=Object.seal(vr(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}})),ve=null,he=null;const Ze=Object.seal(vr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ze=!0,gt=!0,Ct=!1,qe=!0,Be=!1,Bt=!0,Vt=!1,Ht=!1,hn=null,Rt=null,St=!1,It=!1,Tt=!1,Qt=!1,Jt=!0,yn=!1;const Se="user-content-";let bt=!0,Ot=!1,$t={},Mt=null;const en=et({},["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 nn=null;const un=et({},["audio","video","img","source","image","track"]);let mn=null;const $n=et({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),M="http://www.w3.org/1998/Math/MathML",G="http://www.w3.org/2000/svg",X="http://www.w3.org/1999/xhtml";let J=X,Te=!1,Kt=null;const Pt=et({},[M,G,X],gs),Yt=cn(["mi","mo","mn","ms","mtext"]);let At=et({},Yt);const I=cn(["annotation-xml"]);let O=et({},I);const ie=et({},["title","style","font","a","script"]);let Ce=null;const De=["application/xhtml+xml","text/html"],Le="text/html";let j=null,xe=null;const tt=r.createElement("form"),Xe=function(l){return l instanceof RegExp||l instanceof Function},mt=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(xe&&xe===l)return;(!l||typeof l!="object")&&(l={}),l=bn(l),Ce=De.indexOf(l.PARSER_MEDIA_TYPE)===-1?Le:l.PARSER_MEDIA_TYPE,j=Ce==="application/xhtml+xml"?gs:$r,k=Xn(l,"ALLOWED_TAGS",re,{transform:j}),T=Xn(l,"ALLOWED_ATTR",se,{transform:j}),Kt=Xn(l,"ALLOWED_NAMESPACES",Pt,{transform:gs}),mn=Xn(l,"ADD_URI_SAFE_ATTR",$n,{transform:j,base:$n}),nn=Xn(l,"ADD_DATA_URI_TAGS",un,{transform:j,base:un}),Mt=Xn(l,"FORBID_CONTENTS",en,{transform:j}),ve=Xn(l,"FORBID_TAGS",bn({}),{transform:j}),he=Xn(l,"FORBID_ATTR",bn({}),{transform:j}),$t=an(l,"USE_PROFILES")?l.USE_PROFILES&&typeof l.USE_PROFILES=="object"?bn(l.USE_PROFILES):l.USE_PROFILES:!1,ze=l.ALLOW_ARIA_ATTR!==!1,gt=l.ALLOW_DATA_ATTR!==!1,Ct=l.ALLOW_UNKNOWN_PROTOCOLS||!1,qe=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Be=l.SAFE_FOR_TEMPLATES||!1,Bt=l.SAFE_FOR_XML!==!1,Vt=l.WHOLE_DOCUMENT||!1,It=l.RETURN_DOM||!1,Tt=l.RETURN_DOM_FRAGMENT||!1,Qt=l.RETURN_TRUSTED_TYPE||!1,St=l.FORCE_BODY||!1,Jt=l.SANITIZE_DOM!==!1,yn=l.SANITIZE_NAMED_PROPS||!1,bt=l.KEEP_CONTENT!==!1,Ot=l.IN_PLACE||!1,_e=dc(l.ALLOWED_URI_REGEXP)?l.ALLOWED_URI_REGEXP:Fa,J=typeof l.NAMESPACE=="string"?l.NAMESPACE:X,At=an(l,"MATHML_TEXT_INTEGRATION_POINTS")&&l.MATHML_TEXT_INTEGRATION_POINTS&&typeof l.MATHML_TEXT_INTEGRATION_POINTS=="object"?bn(l.MATHML_TEXT_INTEGRATION_POINTS):et({},Yt),O=an(l,"HTML_INTEGRATION_POINTS")&&l.HTML_INTEGRATION_POINTS&&typeof l.HTML_INTEGRATION_POINTS=="object"?bn(l.HTML_INTEGRATION_POINTS):et({},I);const b=an(l,"CUSTOM_ELEMENT_HANDLING")&&l.CUSTOM_ELEMENT_HANDLING&&typeof l.CUSTOM_ELEMENT_HANDLING=="object"?bn(l.CUSTOM_ELEMENT_HANDLING):vr(null);if(z=vr(null),an(b,"tagNameCheck")&&Xe(b.tagNameCheck)&&(z.tagNameCheck=b.tagNameCheck),an(b,"attributeNameCheck")&&Xe(b.attributeNameCheck)&&(z.attributeNameCheck=b.attributeNameCheck),an(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(z.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),dn(z),Be&&(gt=!1),Tt&&(It=!0),$t&&(k=et({},Oa),T=vr(null),$t.html===!0&&(et(k,La),et(T,Pa)),$t.svg===!0&&(et(k,ms),et(T,ys),et(T,jr)),$t.svgFilters===!0&&(et(k,xs),et(T,ys),et(T,jr)),$t.mathMl===!0&&(et(k,_s),et(T,Na),et(T,jr))),Ze.tagCheck=null,Ze.attributeCheck=null,an(l,"ADD_TAGS")&&(typeof l.ADD_TAGS=="function"?Ze.tagCheck=l.ADD_TAGS:Jn(l.ADD_TAGS)&&(k===re&&(k=bn(k)),et(k,l.ADD_TAGS,j))),an(l,"ADD_ATTR")&&(typeof l.ADD_ATTR=="function"?Ze.attributeCheck=l.ADD_ATTR:Jn(l.ADD_ATTR)&&(T===se&&(T=bn(T)),et(T,l.ADD_ATTR,j))),an(l,"ADD_URI_SAFE_ATTR")&&Jn(l.ADD_URI_SAFE_ATTR)&&et(mn,l.ADD_URI_SAFE_ATTR,j),an(l,"FORBID_CONTENTS")&&Jn(l.FORBID_CONTENTS)&&(Mt===en&&(Mt=bn(Mt)),et(Mt,l.FORBID_CONTENTS,j)),an(l,"ADD_FORBID_CONTENTS")&&Jn(l.ADD_FORBID_CONTENTS)&&(Mt===en&&(Mt=bn(Mt)),et(Mt,l.ADD_FORBID_CONTENTS,j)),bt&&(k["#text"]=!0),Vt&&et(k,["html","head","body"]),k.table&&(et(k,["tbody"]),delete ve.tbody),l.TRUSTED_TYPES_POLICY){if(typeof l.TRUSTED_TYPES_POLICY.createHTML!="function")throw or('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw or('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const R=ke;ke=l.TRUSTED_TYPES_POLICY;try{Ue=Ye("")}catch(F){throw ke=R,F}}else l.TRUSTED_TYPES_POLICY===null?(ke=void 0,Ue=""):(ke===void 0&&(ke=Ge()),ke&&typeof Ue=="string"&&(Ue=Ye("")));cn&&cn(l),xe=l},y=et({},[...ms,...xs,...uc]),w=et({},[..._s,...fc]),U=function(l,b,R){return b.namespaceURI===X?l==="svg":b.namespaceURI===M?l==="svg"&&(R==="annotation-xml"||At[R]):!!y[l]},D=function(l,b,R){return b.namespaceURI===X?l==="math":b.namespaceURI===G?l==="math"&&O[R]:!!w[l]},H=function(l,b,R){return b.namespaceURI===G&&!O[R]||b.namespaceURI===M&&!At[R]?!1:!w[l]&&(ie[l]||!y[l])},$=function(l){let b=me(l);(!b||!b.tagName)&&(b={namespaceURI:J,tagName:"template"});const R=$r(l.tagName),F=$r(b.tagName);return Kt[l.namespaceURI]?l.namespaceURI===G?U(R,b,F):l.namespaceURI===M?D(R,b,F):l.namespaceURI===X?H(R,b,F):!!(Ce==="application/xhtml+xml"&&Kt[l.namespaceURI]):!1},x=function(l){hr(e.removed,{element:l});try{me(l).removeChild(l)}catch{if(S(l),!me(l))throw or("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ee=function(l){const b=ae(l);if(b){const F=[];Ar(b,ce=>{hr(F,ce)}),Ar(F,ce=>{try{S(ce)}catch{}})}const R=Je(l);if(R)for(let F=R.length-1;F>=0;--F){const ce=R[F],$e=ce&&ce.name;if(typeof $e=="string")try{l.removeAttribute($e)}catch{}}},q=function(l,b){try{hr(e.removed,{attribute:b.getAttributeNode(l),from:b})}catch{hr(e.removed,{attribute:null,from:b})}if(b.removeAttribute(l),l==="is")if(It||Tt)try{x(b)}catch{}else try{b.setAttribute(l,"")}catch{}},ue=function(l){const b=Je(l);if(b)for(let R=b.length-1;R>=0;--R){const F=b[R],ce=F&&F.name;if(!(typeof ce!="string"||T[j(ce)]))try{l.removeAttribute(ce)}catch{}}},fe=function(l){const b=[l];for(;b.length>0;){const R=b.pop();(Ie?Ie(R):R.nodeType)===Dn.element&&ue(R);const ce=ae(R);if(ce)for(let $e=ce.length-1;$e>=0;--$e)b.push(ce[$e])}},le=function(l){let b=null,R=null;if(St)l="<remove></remove>"+l;else{const $e=Ia(l,/^[\r\n\t ]+/);R=$e&&$e[0]}Ce==="application/xhtml+xml"&&J===X&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");const F=ke?Ye(l):l;if(J===X)try{b=new m().parseFromString(F,Ce)}catch{}if(!b||!b.documentElement){b=Et.createDocument(J,"template",null);try{b.documentElement.innerHTML=Te?Ue:F}catch{}}const ce=b.body||b.documentElement;return l&&R&&ce.insertBefore(r.createTextNode(R),ce.childNodes[0]||null),J===X?ye.call(b,Vt?"html":"body")[0]:Vt?b.documentElement:ce},Qe=function(l){return lt.call(l.ownerDocument||l,l,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},Nt=function(l){return l=Er(l,zt," "),l=Er(l,K," "),l=Er(l,wt," "),l},Wt=function(l){var b;l.normalize();const R=lt.call(l.ownerDocument||l,l,_.SHOW_TEXT|_.SHOW_COMMENT|_.SHOW_CDATA_SECTION|_.SHOW_PROCESSING_INSTRUCTION,null);let F=R.nextNode();for(;F;)F.data=Nt(F.data),F=R.nextNode();const ce=(b=l.querySelectorAll)===null||b===void 0?void 0:b.call(l,"template");ce&&Ar(ce,$e=>{Pe($e.content)&&Wt($e.content)})},Zt=function(l){const b=Oe?Oe(l):null;return typeof b!="string"||j(b)!=="form"?!1:typeof l.nodeName!="string"||typeof l.textContent!="string"||typeof l.removeChild!="function"||l.attributes!==Je(l)||typeof l.removeAttribute!="function"||typeof l.setAttribute!="function"||typeof l.namespaceURI!="string"||typeof l.insertBefore!="function"||typeof l.hasChildNodes!="function"||l.nodeType!==Ie(l)||l.childNodes!==ae(l)},Pe=function(l){if(!Ie||typeof l!="object"||l===null)return!1;try{return Ie(l)===Dn.documentFragment}catch{return!1}},Ve=function(l){if(!Ie||typeof l!="object"||l===null)return!1;try{return typeof Ie(l)=="number"}catch{return!1}};function ge(C,l,b){C.length!==0&&Ar(C,R=>{R.call(e,l,b,xe)})}const ne=function(l,b){return!!(Bt&&l.hasChildNodes()&&!Ve(l.firstElementChild)&&ln(Ua,l.textContent)&&ln(Ua,l.innerHTML)||Bt&&l.namespaceURI===X&&b==="style"&&Ve(l.firstElementChild)||l.nodeType===Dn.processingInstruction||Bt&&l.nodeType===Dn.comment&&ln(wc,l.data))},Ke=function(l,b){if(!ve[b]&&N(b)&&(z.tagNameCheck instanceof RegExp&&ln(z.tagNameCheck,b)||z.tagNameCheck instanceof Function&&z.tagNameCheck(b)))return!1;if(bt&&!Mt[b]){const R=me(l),F=ae(l);if(F&&R){const ce=F.length;for(let $e=ce-1;$e>=0;--$e){const xt=Ot?F[$e]:P(F[$e],!0);R.insertBefore(xt,oe(l))}}}return x(l),!0},st=function(l){if(ge(Ee.beforeSanitizeElements,l,null),Zt(l))return x(l),!0;const b=j(Oe?Oe(l):l.nodeName);if(ge(Ee.uponSanitizeElement,l,{tagName:b,allowedTags:k}),ne(l,b))return x(l),!0;if(ve[b]||!(Ze.tagCheck instanceof Function&&Ze.tagCheck(b))&&!k[b])return Ke(l,b);if((Ie?Ie(l):l.nodeType)===Dn.element&&!$(l)||(b==="noscript"||b==="noembed"||b==="noframes")&&ln(kc,l.innerHTML))return x(l),!0;if(Be&&l.nodeType===Dn.text){const F=Nt(l.textContent);l.textContent!==F&&(hr(e.removed,{element:l.cloneNode()}),l.textContent=F)}return ge(Ee.afterSanitizeElements,l,null),!1},ft=function(l,b,R){if(he[b]||Jt&&(b==="id"||b==="name")&&(R in r||R in tt))return!1;const F=T[b]||Ze.attributeCheck instanceof Function&&Ze.attributeCheck(b,l);if(!(gt&&ln(on,b))){if(!(ze&&ln(ht,b))){if(F){if(!mn[b]){if(!ln(_e,Er(R,je,""))){if(!((b==="src"||b==="xlink:href"||b==="href")&&l!=="script"&&$a(R,"data:")===0&&nn[l])){if(!(Ct&&!ln(kt,Er(R,je,"")))){if(R)return!1}}}}}else if(!(N(l)&&(z.tagNameCheck instanceof RegExp&&ln(z.tagNameCheck,l)||z.tagNameCheck instanceof Function&&z.tagNameCheck(l))&&(z.attributeNameCheck instanceof RegExp&&ln(z.attributeNameCheck,b)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(b,l))||b==="is"&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&ln(z.tagNameCheck,R)||z.tagNameCheck instanceof Function&&z.tagNameCheck(R))))return!1}}return!0},Ae=et({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),N=function(l){return!Ae[$r(l)]&&ln(Y,l)},Q=function(l,b,R,F){if(ke&&typeof E=="object"&&typeof E.getAttributeType=="function"&&!R)switch(E.getAttributeType(l,b)){case"TrustedHTML":return Ye(F);case"TrustedScriptURL":return qt(F)}return F},Re=function(l,b,R,F){try{R?l.setAttributeNS(R,b,F):l.setAttribute(b,F),Zt(l)?x(l):Ra(e.removed)}catch{q(b,l)}},Ne=function(l){ge(Ee.beforeSanitizeAttributes,l,null);const b=l.attributes;if(!b||Zt(l))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:T,forceKeepAttr:void 0};let F=b.length;const ce=j(l.nodeName);for(;F--;){const $e=b[F],xt=$e.name,_t=$e.namespaceURI,fn=$e.value,Dt=j(xt),Gt=fn;let yt=xt==="value"?Gt:sc(Gt);if(R.attrName=Dt,R.attrValue=yt,R.keepAttr=!0,R.forceKeepAttr=void 0,ge(Ee.uponSanitizeAttribute,l,R),yt=R.attrValue,yn&&(Dt==="id"||Dt==="name")&&$a(yt,Se)!==0&&(q(xt,l),yt=Se+yt),Bt&&ln(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,yt)){q(xt,l);continue}if(Dt==="attributename"&&Ia(yt,"href")){q(xt,l);continue}if(!R.forceKeepAttr){if(!R.keepAttr){q(xt,l);continue}if(!qe&&ln(Sc,yt)){q(xt,l);continue}if(Be&&(yt=Nt(yt)),!ft(ce,Dt,yt)){q(xt,l);continue}yt=Q(ce,Dt,_t,yt),yt!==Gt&&Re(l,xt,_t,yt)}}ge(Ee.afterSanitizeAttributes,l,null)},pe=function(l){let b=null;const R=Qe(l);for(ge(Ee.beforeSanitizeShadowDOM,l,null);b=R.nextNode();)if(ge(Ee.uponSanitizeShadowNode,b,null),st(b),Ne(b),Pe(b.content)&&pe(b.content),(Ie?Ie(b):b.nodeType)===Dn.element){const ce=de(b);Pe(ce)&&(Fe(ce),pe(ce))}ge(Ee.afterSanitizeShadowDOM,l,null)},Fe=function(l){const b=[{node:l,shadow:null}];for(;b.length>0;){const R=b.pop();if(R.shadow){pe(R.shadow);continue}const F=R.node,$e=(Ie?Ie(F):F.nodeType)===Dn.element,xt=ae(F);if(xt)for(let _t=xt.length-1;_t>=0;--_t)b.push({node:xt[_t],shadow:null});if($e){const _t=Oe?Oe(F):null;if(typeof _t=="string"&&j(_t)==="template"){const fn=F.content;Pe(fn)&&b.push({node:fn,shadow:null})}}if($e){const _t=de(F);Pe(_t)&&b.push({node:null,shadow:_t},{node:_t,shadow:null})}}};return e.sanitize=function(C){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,R=null,F=null,ce=null;if(Te=!C,Te&&(C="<!-->"),typeof C!="string"&&!Ve(C)&&(C=cc(C),typeof C!="string"))throw or("dirty is not a string, aborting");if(!e.isSupported)return C;Ht?(k=hn,T=Rt):mt(l),(Ee.uponSanitizeElement.length>0||Ee.uponSanitizeAttribute.length>0)&&(k=bn(k)),Ee.uponSanitizeAttribute.length>0&&(T=bn(T)),e.removed=[];const $e=Ot&&typeof C!="string"&&Ve(C);if($e){const fn=Oe?Oe(C):C.nodeName;if(typeof fn=="string"){const Dt=j(fn);if(!k[Dt]||ve[Dt])throw or("root node is forbidden and cannot be sanitized in-place")}if(Zt(C))throw or("root node is clobbered and cannot be sanitized in-place");try{Fe(C)}catch(Dt){throw ee(C),Dt}}else if(Ve(C))b=le("<!---->"),R=b.ownerDocument.importNode(C,!0),R.nodeType===Dn.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?b=R:b.appendChild(R),Fe(R);else{if(!It&&!Be&&!Vt&&C.indexOf("<")===-1)return ke&&Qt?Ye(C):C;if(b=le(C),!b)return It?null:Qt?Ue:""}b&&St&&x(b.firstChild);const xt=Qe($e?C:b);try{for(;F=xt.nextNode();)st(F),Ne(F),Pe(F.content)&&pe(F.content)}catch(fn){throw $e&&ee(C),fn}if($e)return Ar(e.removed,fn=>{fn.element&&fe(fn.element)}),Be&&Wt(C),C;if(It){if(Be&&Wt(b),Tt)for(ce=rt.call(b.ownerDocument);b.firstChild;)ce.appendChild(b.firstChild);else ce=b;return(T.shadowroot||T.shadowrootmode)&&(ce=ct.call(s,ce,!0)),ce}let _t=Vt?b.outerHTML:b.innerHTML;return Vt&&k["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&ln(_c,b.ownerDocument.doctype.name)&&(_t="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
67
|
+
`+_t),Be&&(_t=Nt(_t)),ke&&Qt?Ye(_t):_t},e.setConfig=function(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};mt(C),Ht=!0,hn=k,Rt=T},e.clearConfig=function(){xe=null,Ht=!1,hn=null,Rt=null,ke=We,Ue=""},e.isValidAttribute=function(C,l,b){xe||mt({});const R=j(C),F=j(l);return ft(R,F,b)},e.addHook=function(C,l){typeof l=="function"&&an(Ee,C)&&hr(Ee[C],l)},e.removeHook=function(C,l){if(an(Ee,C)){if(l!==void 0){const b=nc(Ee[C],l);return b===-1?void 0:rc(Ee[C],b,1)[0]}return Ra(Ee[C])}},e.removeHooks=function(C){an(Ee,C)&&(Ee[C]=[])},e.removeAllHooks=function(){Ee=za()},e}var ia=Go();ut.setOptions({gfm:!0,breaks:!0});const Ba=80;function jn(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Ec={code(n){const{text:e,lang:r}=n,s=(r??"").trim().split(/\s+/)[0]??"",o=e.split(`
|
|
68
|
+
`).filter(E=>E.trim()!==""),i=o.length>1,c=`<pre><code>${jn(e)}</code></pre>`;if(!i)return c;let v=o[0]??"";return v.length>Ba?v=v.slice(0,Ba)+"…":o.length>1&&(v+=" …"),`<details class="code-collapsible"><summary>${s?`<span class="code-lang">${jn(s)}</span> ${jn(v)}`:jn(v)}</summary>${c}</details>`}};ut.use({renderer:Ec});let Ha=!1;function jo(){Ha||typeof window>"u"||(Ha=!0,ia.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))}))}function Cc(n){if(!n)return"";const e=ut.parse(n,{async:!1});return typeof window>"u"?"":(jo(),ia.sanitize(e,{ADD_ATTR:["target","rel"],ADD_TAGS:["details","summary"]}))}const Rc=/\b(https?:\/\/[^\s<]+|www\.[^\s<]+)/gi;function Ic(n){if(!n||typeof window>"u")return"";let e="",r=0;for(const s of n.matchAll(Rc)){const a=s.index??0;e+=jn(n.slice(r,a));let o=s[0],i="";const c=o.match(/[.,;:!?)\]}'"]+$/);c&&(i=c[0],o=o.slice(0,o.length-i.length));const _=o.startsWith("www.")?`https://${o}`:o;e+=`<a href="${jn(_)}">${jn(o)}</a>`,e+=jn(i),r=a+s[0].length}return e+=jn(n.slice(r)),jo(),ia.sanitize(e,{ADD_ATTR:["target","rel"]})}var $c=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>'),Mc=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>'),Dc=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>`),Lc=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>'),Oc=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>'),Pc=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>'),Nc=g('<span class="ml-1 font-medium text-emerald-400">(Git repo detected)</span>'),Fc=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>'),Uc=g('<span class="mt-1 block text-[10px] text-brand-text-muted">Relative paths are created inside your home folder.</span>'),zc=g("<option> </option>"),Bc=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>'),Hc=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"/>'),Wc=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>'),Gc=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>'),jc=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>'),qc=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">Create & Start Session</button></form></div></div>`),Vc=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>'),Kc=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>'),Yc=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>'),Zc=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>'),Xc=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>'),Qc=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>'),Jc=g('<div class="flex flex-col gap-1"><!> <div class="font-mono text-sm whitespace-pre-wrap"> </div></div>'),ed=g('<span class="font-mono text-xs text-brand-text-muted tabular-nums"> </span>'),td=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>'),nd=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>'),rd=g('<span class="text-xs break-words text-brand-text-muted"> </span>'),sd=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>'),ad=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>'),od=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>'),id=g('<div class="flex max-w-full min-w-[240px] flex-col"><!></div>'),ld=g('<span class="inline-block animate-spin font-bold text-amber-400">⚡</span>'),cd=g('<span class="font-bold text-rose-400" title="Failed">❌</span>'),dd=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>'),ud=g('<span class="font-bold text-emerald-400" title="Succeeded">✅</span>'),fd=g('<span class="max-w-[180px] truncate font-mono text-xs text-brand-text-muted sm:max-w-[300px] md:max-w-[450px]"> </span>'),pd=g("<span> </span>"),hd=g('Collapse <span class="text-[10px]">▲</span>',1),bd=g('Expand <span class="text-[10px]">▼</span>',1),vd=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>'),gd=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>'),xd=g('<div class="mt-2 flex flex-col gap-1"><div class="flex flex-wrap gap-2"></div></div>'),_d=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>'),yd=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>'),wd=g('<div class="animate-pulse p-1 text-xs text-brand-text-muted italic">Running and waiting for output...</div>'),kd=g(`<div class="p-1 text-xs text-brand-text-muted italic">Interrupted before a result was returned (the
|
|
71
|
+
running tool was stopped, e.g. by a CLI takeover).
|
|
72
|
+
Its outcome is unknown.</div>`),Sd=g('<div class="p-1 text-xs text-brand-text-muted italic">No output returned</div>'),Td=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>'),Ad=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>'),Ed=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>'),Cd=g('<div class="chat-selectable markdown-body text-sm leading-relaxed"></div>'),Rd=g("<span></span>"),Id=g('<span class="text-brand-text-muted italic"> </span>'),$d=g('<span class="ml-1 inline-block h-4 w-1.5 animate-pulse bg-brand-cyan"></span>'),Md=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>'),Dd=g('<div class="mt-2 flex flex-col gap-1 border-t border-brand-blue/20 pt-2"></div>'),Ld=g('<div class="chat-selectable text-sm leading-relaxed whitespace-pre-wrap"><!> <!></div> <!>',1),Od=g('<span title="Sending, awaiting confirmation">Sending...</span> <span>·</span>',1),Pd=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>'),Nd=g("<div><!> </div> <!>",1),Fd=g("<div><div><!> <!></div></div>"),Ud=g('<div class="flex-1 space-y-4 overflow-y-auto overscroll-y-contain p-4"><!> <!></div>'),zd=g('<button type="button" aria-label="Cycle waiting-for-human beep for this session"><span> </span> <span> </span></button>'),Bd=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>'),Hd=g('<span class="ml-1 text-xs text-brand-text-muted">(already a Git repository)</span>'),Wd=g('<span class="ml-1 text-xs font-medium text-yellow-500">(folder not empty)</span>'),Gd=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>'),jd=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>'),qd=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>'),Vd=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 Kd(n,e){nr(e,!0);const r=()=>Me(Ut,"$piState",S),s=()=>Me(xr,"$availableModels",S),a=()=>Me(Bs,"$gitInitDefaultStore",S),o=()=>Me(Br,"$activeSessionInfo",S),i=()=>Me(ss,"$isLoadingSession",S),c=()=>Me(Gs,"$beepSessionOverride",S),_=()=>Me(js,"$beepEnabled",S),v=()=>Me(yo,"$messages",S),m=()=>Me(Ys,"$isStreaming",S),E=()=>Me(Eo,"$hasMoreHistory",S),L=()=>Me(Co,"$isLoadingMoreHistory",S),P=()=>Me(rs,"$isReadOnly",S),[S,oe]=_r(),ae=[],me=new Map;function de(y,w){const U=`${y}:${w.length}`;let D=me.get(U);return D===void 0&&(D=Cc(w),me.set(U,D)),D}const Je=new Map;function Ie(y){let w=Je.get(y);return w===void 0&&(w=Ic(y),Je.set(y,w)),w}function Oe(y){if(y>=1e6){const w=y/1e6;return(w>=10?Math.round(w).toString():w.toFixed(1))+"M"}return y>=1e3?Math.round(y/1e3)+"K":String(y)}let ke=V(()=>{const y=r().contextUsage;if(!y||!y.contextWindow)return null;const w=Oe(y.contextWindow);return y.percent==null?`– / ${w}`:`${y.percent.toFixed(1)}% / ${w}`});function Ue(y){if(!y)return{cleanContent:"",attachments:[]};const w=y.split(`
|
|
73
|
+
`),U=/^\[Uploaded file: (.+)\]$/,D=[],H=[];for(const x of w){const ee=x.match(U);ee?H.push(ee[1]):D.push(x)}let $=D.join(`
|
|
74
|
+
`).trim();return $==="I have uploaded the following file(s) for you:"&&($=""),{cleanContent:$,attachments:H}}let We=Z(""),Lt=Z(An([])),ot=Z(!1),be=Z(null),Ye=Z(null),qt="",Ge=Z(""),it=Z(!1),Et=Z(null),lt=Z(!0),rt=Z("private"),ye=Z(!1),ct=V(r),Ee=V(s),zt=V(a);Ft(()=>{t(Et)===null&&h(it,t(zt),!0)});let K=Z(An({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),wt=V(()=>t(K).exists!==!0&&t(K).matchingRule&&t(lt)),on=null;async function ht(y,w=!1){if(on&&clearTimeout(on),y===qt&&!w)return;if(qt=y,!y.trim()){h(K,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const D=async()=>{const H=await Zr("");h(Lt,H||[],!0)};w?await D():on=setTimeout(D,300);return}const U=async()=>{const[D,H]=await Promise.all([no(y),Zr(y)]);h(Lt,H||[],!0),D?(h(K,{exists:D.exists,isGit:D.isGit,resolvedPath:D.resolvedPath,matchingRule:D.matchingRule||null},!0),D.exists||(h(it,t(Et)!==null?t(Et):t(zt),!0),h(lt,!0),D.matchingRule&&h(rt,D.matchingRule.visibility,!0))):h(K,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};w?await U():on=setTimeout(U,300)}Ft(()=>{const y=t(We);ht(y,!1)}),Ft(()=>{if(t(Ee).models.length>0&&!t(Ge)){const y=t(Ee).models.find(w=>w.isDefault);y?h(Ge,`${y.provider}:${y.modelId}`):h(Ge,`${t(Ee).models[0].provider}:${t(Ee).models[0].modelId}`)}});function kt(){t(We).trim()&&(t(K).exists===!0?(h(it,!1),h(lt,!1),t(K).matchingRule&&h(rt,t(K).matchingRule.visibility,!0),h(ye,!0)):Nn(t(We).trim(),t(Ge)||void 0,t(it),t(K).matchingRule?t(lt):void 0,t(K).matchingRule?t(rt):void 0))}let je=Z(void 0),Y=V(o),_e=V(i),k=V(c),re=V(_);function T(){t(k)===void 0?Vr(!0):t(k)===!0?Vr(!1):Vr(void 0)}let se=V(()=>!!t(Y).sessionFile),z=Z(!0),ve=Z(!1),he=An({});function Ze(y,w){he[y]=!w}function ze(y){if(!y)return null;const w=y.trim();if(!w)return null;if(w.startsWith("{"))try{return JSON.parse(w)}catch{}const U={},D=/([a-zA-Z0-9_-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|(\S+))/g;let H;for(;(H=D.exec(w))!==null;){const $=H[1],x=H[2]!==void 0?H[2]:H[3]!==void 0?H[3]:H[4];U[$]=x}return Object.keys(U).length>0?U:null}function gt(y,w,U){if(!w)return U?U.trim():"";const D=y.toLowerCase();if(["read","write","edit","ls"].includes(D)){const $=w.path||w.filepath||w.file;if($)return String($)}if(D==="bash"){const $=w.command||w.cmd;if($){const x=String($).replace(/\s+/g," ").trim();return x.length>50?x.slice(0,47)+"...":x}}if(D==="grep"){const $=w.pattern,x=w.path;if($)return x?`"${$}" in ${x}`:`"${$}"`}if(D==="find"){const $=w.pattern||w.path;if($)return String($)}const H=w.path||w.filepath||w.file||w.name||w.query;return H?String(H):Object.entries(w).filter(([$,x])=>x!==void 0&&x!=="").map(([$,x])=>`${$}=${typeof x=="object"?JSON.stringify(x):x}`).join(" ")}function Ct(y,w){return y?JSON.stringify(y,null,2):w?w.trim():""}function qe(y){let w=y.toolName||"tool",U=y.toolArgs!==void 0?y.toolArgs:"",D=y.toolOutput!==void 0?y.toolOutput:"",H=!!y.isError;if(!U&&!D&&y.content){let q=y.content||"";q.startsWith("Error: ")?(H=!0,q=q.slice(7)):q.startsWith("Tool error: ")&&(H=!0,q=q.slice(12));const ue=q.indexOf(`
|
|
75
|
+
`),fe=ue!==-1?q.slice(0,ue):q;D=ue!==-1?q.slice(ue+1):"";let le=fe.trim();le.startsWith("$ ")&&(le=le.slice(2));const Qe=le.indexOf(" ");w=y.toolName||(Qe!==-1?le.slice(0,Qe):le)||"tool",U=Qe!==-1?le.slice(Qe+1):""}const $=ze(U),x=gt(w,$,U),ee=Ct($,U);return{toolName:w,smartTitleArgs:x,fullArgs:ee,toolOutput:D,isError:H,interrupted:!!y.interrupted,downloadPath:Be(w,$,H)}}function Be(y,w,U){if(U||!w)return null;const D=(y||"").toLowerCase();if(!["attach_file","read","write","edit"].includes(D))return null;const H=w.path||w.filepath||w.file;return!H||typeof H!="string"?null:H.trim()||null}function Bt(y){return y.scrollHeight-y.scrollTop-y.clientHeight<=20}function Vt(){t(je)&&h(z,Bt(t(je)),!0)}function Ht(){t(je)&&(t(je).scrollTop=t(je).scrollHeight)}function hn(){(t(z)||t(ve))&&(Ht(),h(ve,!1))}Fr(Ht),Ft(()=>{if(t(je))return t(je).addEventListener("scroll",Vt),()=>{t(je)&&t(je).removeEventListener("scroll",Vt)}});let Rt=Z(null),St=Z(!1);function It(){h(ve,!0),Ht(),requestAnimationFrame(()=>{Ht(),requestAnimationFrame(Ht)}),setTimeout(Ht,60),setTimeout(Ht,150)}Ft(()=>{const y=t(Y).sessionFile;y!==t(Rt)&&(h(Rt,y,!0),h(ve,!0));const w=t(_e);t(St)&&!w&&It(),h(St,w,!0)});let Tt=V(()=>{const y=v().filter(U=>U.role==="thinking"&&r().hideThinking?!1:U.role==="tool"&&r().hideTools&&U.toolName!=="attach_file"?Ot(U)||!!U.isStreaming:U.role!=="assistant"&&U.role!=="thinking"||U.isStreaming||U.content.trim()!==""),w=y.some(U=>U.isStreaming);if(t(Qt)&&!w){const U=v().some(D=>D.role==="thinking"&&D.isStreaming);y.push({id:"fallback-loader-message-id",role:"thinking",content:U?"FALLBACK_THINKING_LOADER":"FALLBACK_LOADER",timestamp:Date.now(),isStreaming:!0})}return y}),Qt=V(m),Jt=Z(An(Date.now())),yn=V(()=>t(Tt).some(y=>y.role==="tool"&&y.isStreaming));Ft(()=>{if(!t(yn))return;h(Jt,Date.now(),!0);const y=setInterval(()=>h(Jt,Date.now(),!0),100);return()=>clearInterval(y)});function Se(y){if(y.startedAt===void 0)return null;const w=y.endedAt??(y.isStreaming?t(Jt):void 0);return w===void 0?null:`${(Math.max(0,w-y.startedAt)/1e3).toFixed(1)}s`}yi(()=>{const y=t(Tt)[t(Tt).length-1];y&&`${t(Tt).length}${y.content.length}`,t(je)&&h(z,Bt(t(je)),!0)}),Ft(()=>{const y=t(Tt)[t(Tt).length-1];y&&`${t(Tt).length}${y.content.length}`,hn()});function bt(y){return new Date(y).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Ot(y){const w=v(),U=w.findIndex(D=>D.id===y.id);if(U===-1)return!1;for(let D=U-1;D>=0;D--)if(w[D].role==="user"){const H=w[D].content?w[D].content.trim():"";return H.startsWith("!")||H.startsWith("!!")}return!1}function $t(y,w){return Ot(y)}function Mt(){h(ve,!0),setTimeout(Ht,0)}let en=V(E),nn=V(L),un=Z(null);function mn(){!t(je)||t(nn)||!t(en)||(h(un,t(je).scrollHeight-t(je).scrollTop),vo())}Ft(()=>{if(v().length,t(un)!==null&&t(je)){const y=t(un);h(un,null),requestAnimationFrame(()=>{t(je)&&(t(je).scrollTop=t(je).scrollHeight-y)})}});var $n={forceScrollToBottom:Mt},M=Vd(),G=u(M);{var X=y=>{var w=$c();p(y,w)},J=y=>{var w=Dc(),U=u(w),D=f(u(U),6);{var H=x=>{var ee=Mc(),q=u(ee,!0);d(ee),B(()=>te(q,t(ct).error)),p(x,ee)};A(D,x=>{t(ct).error&&x(H)})}var $=f(D,2);d(U),d(w),W("click",$,()=>{Ti(()=>Promise.resolve().then(()=>il),void 0,import.meta.url).then(x=>x.connect())}),p(y,w)},Te=y=>{var w=Lc();p(y,w)},Kt=y=>{var w=qc(),U=u(w),D=u(U),H=u(D),$=u(H);d(H),at(6),d(D);var x=f(D,2),ee=u(x),q=f(u(ee),2),ue=u(q);dt(ue),Kn(ue,N=>h(be,N),()=>t(be));var fe=f(ue,2);{var le=N=>{var Q=Pc();gn(Q,21,()=>t(Lt),Cn,(Re,Ne)=>{var pe=Oc(),Fe=u(pe,!0);d(pe),B(()=>te(Fe,t(Ne))),W("click",pe,()=>{h(We,t(Ne),!0),ht(t(Ne),!0),t(be)?.focus()}),p(Re,pe)}),d(Q),p(N,Q)};A(fe,N=>{t(ot)&&t(Lt).length>0&&N(le)})}d(q),Kn(q,N=>h(Ye,N),()=>t(Ye));var Qe=f(q,2);{var Nt=N=>{var Q=Fc(),Re=f(u(Q));{var Ne=pe=>{var Fe=Nc();p(pe,Fe)};A(Re,pe=>{t(K).isGit&&pe(Ne)})}d(Q),p(N,Q)},Wt=N=>{var Q=Uc();p(N,Q)};A(Qe,N=>{t(K).exists===!0?N(Nt):N(Wt,-1)})}d(ee);var Zt=f(ee,2),Pe=f(u(Zt),2);{var Ve=N=>{var Q=Bc();gn(Q,21,()=>t(Ee).models,Cn,(Re,Ne)=>{var pe=zc(),Fe=u(pe);d(pe);var C={};B(()=>{te(Fe,`${t(Ne).label??""}${t(Ne).isDefault?" (default)":""}`),C!==(C=`${t(Ne).provider}:${t(Ne).modelId}`)&&(pe.value=pe.__value=`${t(Ne).provider}:${t(Ne).modelId}`)}),p(Re,pe)}),d(Q),Pr(Q,()=>t(Ge),Re=>h(Ge,Re)),p(N,Q)},ge=N=>{var Q=Hc();dt(Q),Fn(Q,()=>t(Ge),Re=>h(Ge,Re)),p(N,Q)};A(Pe,N=>{t(Ee).models.length>0?N(Ve):N(ge,-1)})}d(Zt);var ne=f(Zt,2);{var Ke=N=>{var Q=Gc(),Re=u(Q),Ne=u(Re);dt(Ne);var pe=f(Ne,2),Fe=u(pe);d(pe),d(Re);var C=f(Re,2);{var l=b=>{var R=Wc(),F=f(u(R),2),ce=u(F);dt(ce),ce.value=ce.__value="private",at(),d(F);var $e=f(F,2),xt=u($e);dt(xt),xt.value=xt.__value="public",at(),d($e),d(R),er(ae,[],ce,()=>t(rt),_t=>h(rt,_t)),er(ae,[],xt,()=>t(rt),_t=>h(rt,_t)),p(b,R)};A(C,b=>{t(lt)&&b(l)})}d(Q),B(()=>te(Fe,`Create remote ${t(K).matchingRule.provider??""} repository`)),Rn(Ne,()=>t(lt),b=>h(lt,b)),p(N,Q)};A(ne,N=>{t(K).exists!==!0&&t(K).matchingRule&&N(Ke)})}var st=f(ne,2);{var ft=N=>{var Q=jc(),Re=u(Q);dt(Re),at(2),d(Q),W("change",Re,Ne=>{h(Et,Ne.currentTarget.checked,!0)}),Rn(Re,()=>t(it),Ne=>h(it,Ne)),p(N,Q)};A(st,N=>{t(K).exists!==!0&&(!t(K).matchingRule||!t(lt))&&N(ft)})}var Ae=f(st,2);d(x),d(U),d(w),B((N,Q)=>{we($,"src",N),rn(ue,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(wt)?"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"}`),Ae.disabled=Q},[()=>gr("/logo.svg"),()=>!t(We).trim()]),tr("submit",x,N=>{N.preventDefault(),kt()}),tr("focus",ue,()=>{h(ot,!0),ht(t(We),!0)}),tr("blur",ue,N=>{t(Ye)&&t(Ye).contains(N.relatedTarget)||h(ot,!1)}),W("keydown",ue,N=>{N.key==="Escape"&&h(ot,!1)}),Fn(ue,()=>t(We),N=>h(We,N)),p(y,w)},Pt=y=>{var w=Vc();p(y,w)},Yt=y=>{var w=Ud(),U=u(w);{var D=$=>{var x=Kc(),ee=u(x),q=u(ee);{var ue=le=>{var Qe=wn("Loading older messages...");p(le,Qe)},fe=le=>{var Qe=wn("Load older messages");p(le,Qe)};A(q,le=>{t(nn)?le(ue):le(fe,-1)})}d(ee),d(x),B(()=>ee.disabled=t(nn)),W("click",ee,mn),p($,x)};A(U,$=>{t(en)&&$(D)})}var H=f(U,2);gn(H,17,()=>t(Tt),$=>$.id,($,x)=>{var ee=Fd(),q=u(ee),ue=u(q);{var fe=Pe=>{var Ve=Gn(),ge=jt(Ve);{var ne=Ae=>{var N=Yc();p(Ae,N)},Ke=Ae=>{var N=Zc();p(Ae,N)},st=Ae=>{var N=Xc();p(Ae,N)},ft=Ae=>{var N=Jc(),Q=u(N);{var Re=Fe=>{var C=Qc();p(Fe,C)};A(Q,Fe=>{t(x).isStreaming&&Fe(Re)})}var Ne=f(Q,2),pe=u(Ne,!0);d(Ne),d(N),B(()=>te(pe,t(x).content)),p(Ae,N)};A(ge,Ae=>{t(x).content==="FALLBACK_THINKING_LOADER"?Ae(ne):t(x).content==="FALLBACK_LOADER"?Ae(Ke,1):r().hideThinking?Ae(st,2):Ae(ft,-1)})}p(Pe,Ve)},le=Pe=>{var Ve=Gn(),ge=jt(Ve);{var ne=ft=>{var Ae=td(),N=f(u(Ae),2),Q=f(u(N)),Re=u(Q,!0);d(Q),at(),d(N);var Ne=f(N,2);{var pe=C=>{var l=ed(),b=u(l,!0);d(l),B(R=>te(b,R),[()=>Se(t(x))]),p(C,l)},Fe=V(()=>Se(t(x)));A(Ne,C=>{t(Fe)&&C(pe)})}d(Ae),B(()=>te(Re,t(x).toolName||"agent")),p(ft,Ae)},Ke=V(()=>r().hideTools&&t(x).toolName!=="attach_file"&&!Ot(t(x))),st=ft=>{const Ae=V(()=>qe(t(x))),N=V(()=>he[t(x).id]!==void 0?he[t(x).id]:$t(t(x),t(Tt))),Q=V(()=>t(Ae).downloadPath),Re=V(()=>t(Q)?Ro(t(Q)):null),Ne=V(()=>t(Ae).toolName==="attach_file");var pe=Gn(),Fe=jt(pe);{var C=b=>{const R=V(()=>t(Q)?t(Q).split("/").pop()||t(Q):"");var F=id(),ce=u(F);{var $e=Dt=>{var Gt=nd();p(Dt,Gt)},xt=Dt=>{var Gt=sd(),yt=f(u(Gt),2),Mn=f(u(yt),2);{var Zn=Hn=>{var sr=rd(),is=u(sr,!0);d(sr),B(()=>te(is,t(Ae).toolOutput)),p(Hn,sr)};A(Mn,Hn=>{t(Ae).toolOutput&&Hn(Zn)})}d(yt),d(Gt),p(Dt,Gt)},_t=Dt=>{var Gt=ad(),yt=f(u(Gt),2),Mn=u(yt),Zn=u(Mn,!0);d(Mn);var Hn=f(Mn,2),sr=u(Hn,!0);d(Hn),d(yt),at(2),d(Gt),B(()=>{we(Gt,"href",t(Re)),we(Gt,"download",t(R)),we(Gt,"title",`Download ${t(Q)}`),te(Zn,t(R)),we(Hn,"title",t(Q)),te(sr,t(Q))}),p(Dt,Gt)},fn=Dt=>{var Gt=od(),yt=f(u(Gt),2),Mn=u(yt),Zn=u(Mn,!0);d(Mn),at(2),d(yt),d(Gt),B(()=>te(Zn,t(R))),p(Dt,Gt)};A(ce,Dt=>{t(x).isStreaming?Dt($e):t(Ae).isError?Dt(xt,1):t(Re)?Dt(_t,2):Dt(fn,-1)})}d(F),p(b,F)},l=b=>{var R=Ad(),F=u(R),ce=u(F),$e=u(ce),xt=u($e);{var _t=He=>{var nt=ld();p(He,nt)},fn=He=>{var nt=cd();p(He,nt)},Dt=He=>{var nt=dd();p(He,nt)},Gt=He=>{var nt=ud();p(He,nt)};A(xt,He=>{t(x).isStreaming?He(_t):t(Ae).isError?He(fn,1):t(Ae).interrupted?He(Dt,2):He(Gt,-1)})}var yt=f(xt,2),Mn=u(yt,!0);d(yt);var Zn=f(yt,2);{var Hn=He=>{var nt=fd(),Sn=u(nt,!0);d(nt),B(()=>{we(nt,"title",t(Ae).smartTitleArgs),te(Sn,t(Ae).smartTitleArgs)}),p(He,nt)};A(Zn,He=>{t(Ae).smartTitleArgs&&He(Hn)})}var sr=f(Zn,2);{var is=He=>{var nt=pd(),Sn=u(nt);d(nt),B(ar=>{rn(nt,1,`shrink-0 font-mono text-xs tabular-nums ${t(x).isStreaming?"text-amber-400":"text-brand-text-muted"}`),we(nt,"title",t(x).isStreaming?"Elapsed time":"Time taken"),te(Sn,`${t(x).isStreaming?"Elapsed":"Took"}
|
|
76
|
+
${ar??""}`)},[()=>Se(t(x))]),p(He,nt)},qo=V(()=>Se(t(x)));A(sr,He=>{t(qo)&&He(is)})}d($e);var la=f($e,2),Vo=u(la);{var Ko=He=>{var nt=hd();at(),p(He,nt)},Yo=He=>{var nt=bd();at(),p(He,nt)};A(Vo,He=>{t(N)?He(Ko):He(Yo,-1)})}d(la),d(ce);var Zo=f(ce,2);{var Xo=He=>{var nt=Gn(),Sn=jt(nt);{var ar=xn=>{var Tn=vd();B(ls=>{we(Tn,"href",t(Re)),we(Tn,"download",ls),we(Tn,"title",`Download ${t(Q)}`),we(Tn,"aria-label",`Download ${t(Q)}`)},[()=>t(Q).split("/").pop()||""]),p(xn,Tn)},Wn=xn=>{var Tn=gd();p(xn,Tn)};A(Sn,xn=>{t(Re)?xn(ar):xn(Wn,-1)})}p(He,nt)};A(Zo,He=>{t(Q)&&He(Xo)})}d(F);var ca=f(F,2);{var Qo=He=>{var nt=xd(),Sn=u(nt);gn(Sn,21,()=>t(x).images,Cn,(ar,Wn)=>{var xn=md(),Tn=u(xn);d(xn),B(()=>{we(xn,"href",`data:${t(Wn).mimeType};base64,${t(Wn).data}`),we(Tn,"src",`data:${t(Wn).mimeType};base64,${t(Wn).data}`)}),p(ar,xn)}),d(Sn),d(nt),p(He,nt)};A(ca,He=>{t(x).images&&t(x).images.length>0&&He(Qo)})}var Jo=f(ca,2);{var ei=He=>{var nt=Td(),Sn=u(nt);{var ar=pn=>{var _n=_d(),Wr=f(u(_n),2),ri=u(Wr,!0);d(Wr),d(_n),B(()=>te(ri,t(Ae).fullArgs)),p(pn,_n)};A(Sn,pn=>{t(Ae).fullArgs&&t(Ae).fullArgs!=="{}"&&pn(ar)})}var Wn=f(Sn,2),xn=f(u(Wn),2);{var Tn=pn=>{var _n=yd(),Wr=u(_n,!0);d(_n),B(()=>te(Wr,t(Ae).toolOutput)),p(pn,_n)},ls=pn=>{var _n=wd();p(pn,_n)},ti=pn=>{var _n=kd();p(pn,_n)},ni=pn=>{var _n=Sd();p(pn,_n)};A(xn,pn=>{t(Ae).toolOutput?pn(Tn):t(x).isStreaming?pn(ls,1):t(Ae).interrupted?pn(ti,2):pn(ni,-1)})}d(Wn),d(nt),p(He,nt)};A(Jo,He=>{t(N)&&He(ei)})}d(R),B(()=>te(Mn,t(Ae).toolName)),W("click",ce,()=>Ze(t(x).id,t(N))),p(b,R)};A(Fe,b=>{t(Ne)?b(C):b(l,-1)})}p(ft,pe)};A(ge,ft=>{t(Ke)?ft(ne):ft(st,-1)})}p(Pe,Ve)},Qe=Pe=>{var Ve=Gn(),ge=jt(Ve);{var ne=st=>{var ft=Ed(),Ae=u(ft,!0);at(),d(ft),B(()=>te(Ae,t(x).content)),p(st,ft)},Ke=st=>{var ft=Cd();ha(ft,()=>de(t(x).id,t(x).content),!0),d(ft),p(st,ft)};A(ge,st=>{t(x).isStreaming?st(ne):st(Ke,-1)})}p(Pe,Ve)},Nt=Pe=>{const Ve=V(()=>Ue(t(x).content));var ge=Ld(),ne=jt(ge),Ke=u(ne);{var st=pe=>{const Fe=V(()=>Ie(t(Ve).cleanContent));var C=Gn(),l=jt(C);{var b=F=>{var ce=Rd();ha(ce,()=>t(Fe),!0),d(ce),p(F,ce)},R=F=>{var ce=wn();B(()=>te(ce,t(Ve).cleanContent)),p(F,ce)};A(l,F=>{t(Fe)?F(b):F(R,-1)})}p(pe,C)},ft=pe=>{var Fe=Id(),C=u(Fe);d(Fe),B(()=>te(C,`Shared file${t(Ve).attachments.length>1?"s":""} with agent:`)),p(pe,Fe)},Ae=pe=>{var Fe=wn();B(()=>te(Fe,t(x).content||(t(x).isStreaming?"Thinking...":""))),p(pe,Fe)};A(Ke,pe=>{t(Ve).cleanContent?pe(st):t(Ve).attachments.length>0?pe(ft,1):pe(Ae,-1)})}var N=f(Ke,2);{var Q=pe=>{var Fe=$d();p(pe,Fe)};A(N,pe=>{t(x).isStreaming&&t(Qt)&&pe(Q)})}d(ne);var Re=f(ne,2);{var Ne=pe=>{var Fe=Dd();gn(Fe,21,()=>t(Ve).attachments,Cn,(C,l)=>{var b=Md(),R=f(u(b),2),F=u(R,!0);d(R),d(b),B(()=>{we(R,"title",t(l)),te(F,t(l))}),p(C,b)}),d(Fe),p(pe,Fe)};A(Re,pe=>{t(Ve).attachments.length>0&&pe(Ne)})}p(Pe,ge)};A(ue,Pe=>{t(x).role==="thinking"?Pe(fe):t(x).role==="tool"?Pe(le,1):t(x).role==="assistant"&&t(x).content!==""?Pe(Qe,2):Pe(Nt,-1)})}var Wt=f(ue,2);{var Zt=Pe=>{var Ve=Nd(),ge=jt(Ve),ne=u(ge);{var Ke=N=>{var Q=Od();at(2),p(N,Q)};A(ne,N=>{t(x).role==="user"&&t(x).delivery==="sending"&&N(Ke)})}var st=f(ne);d(ge);var ft=f(ge,2);{var Ae=N=>{var Q=Pd(),Re=f(u(Q),2),Ne=f(Re,2);d(Q),W("click",Re,()=>uo(t(x).id)),W("click",Ne,()=>fo(t(x).id)),p(N,Q)};A(ft,N=>{t(x).role==="user"&&t(x).delivery==="failed"&&N(Ae)})}B(N=>{rn(ge,1,`mt-1 flex items-center gap-1.5 text-xs opacity-50 ${t(x).role==="user"?"justify-end text-brand-text-muted":t(x).role==="assistant"?"text-brand-purple":"text-brand-text-muted"}`),te(st,` ${N??""}`)},[()=>bt(t(x).timestamp)]),p(Pe,Ve)};A(Wt,Pe=>{t(x).role!=="thinking"&&t(x).role!=="tool"&&Pe(Zt)})}d(q),d(ee),B(Pe=>{rn(ee,1,`flex ${t(x).role==="user"?"justify-end":"justify-start"}`),rn(q,1,`max-w-[85%] rounded-lg px-4 py-3 ${Pe??""}`)},[()=>t(x).role==="user"?"bg-brand-blue/80 text-brand-text":t(x).role==="thinking"?"border-l-2 border-brand-border bg-brand-surface/30 text-sm text-brand-text-muted":t(x).role==="tool"&&t(x).toolName==="attach_file"?"bg-transparent p-0 text-brand-text":t(x).role==="tool"?r().hideTools&&!Ot(t(x))?"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(x).isStreaming?"border-amber-400":t(x).isError?"border-rose-400":t(x).interrupted?"border-brand-border":"border-emerald-400"}`:t(x).role==="assistant"?"border-l-2 border-brand-purple bg-brand-purple/10 text-brand-text":t(x).content===""&&t(x).isStreaming?"bg-brand-surface-3 text-brand-text-muted italic":"bg-brand-surface-2 text-brand-text"]),p($,ee)}),d(w),Kn(w,$=>h(je,$),()=>t(je)),p(y,w)};A(G,y=>{t(ct).connecting&&!t(se)?y(X):!t(ct).connected&&!t(se)?y(J,1):!t(se)&&(t(_e)||typeof window<"u"&&window.location.hash)?y(Te,2):t(Y).sessionFile?t(Tt).length===0?y(Pt,4):y(Yt,-1):y(Kt,3)})}var At=f(G,2),I=u(At),O=u(I),ie=u(O);dt(ie),at(),d(O);var Ce=f(O,2);{var De=y=>{var w=zd(),U=u(w),D=u(U,!0);d(U);var H=f(U,2),$=u(H,!0);d(H),d(w),B(()=>{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(k)===void 0?"text-brand-text-muted":"text-brand-blue"}`),we(w,"title",t(k)===void 0?`Beep when the agent is waiting: following the default (${t(re)?"on":"off"}). Click to set On for this session.`:t(k)===!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."),te(D,t(re)?"🔔":"🔕"),te($,t(k)===void 0?`Beep: Default (${t(re)?"on":"off"})`:t(k)?"Beep: On":"Beep: Off")}),W("click",w,T),p(y,w)};A(Ce,y=>{t(Y).sessionFile&&!P()&&y(De)})}var Le=f(Ce,2);{var j=y=>{var w=Bd(),U=f(u(w),2),D=u(U,!0);d(U),d(w),B(H=>{we(w,"title",H),te(D,t(ke))},[()=>r().contextUsage?.tokens!=null?`${r().contextUsage.tokens.toLocaleString()} context tokens of ${r().contextUsage.contextWindow.toLocaleString()}`:"Context window size"]),p(y,w)};A(Le,y=>{t(ke)&&y(j)})}d(I);var xe=f(I,2);d(At);var tt=f(At,2);{var Xe=y=>{var w=qd(),U=u(w),D=f(u(U),2),H=f(u(D)),$=u(H,!0);d(H),at(),d(D);var x=f(D,2),ee=u(x),q=u(ee);dt(q);var ue=f(q,2),fe=f(u(ue));{var le=ge=>{var ne=Hd();p(ge,ne)},Qe=ge=>{var ne=Wd();p(ge,ne)};A(fe,ge=>{t(K).isGit?ge(le):ge(Qe,-1)})}d(ue),d(ee);var Nt=f(ee,2);{var Wt=ge=>{var ne=jd(),Ke=u(ne),st=u(Ke);dt(st);var ft=f(st,2),Ae=u(ft);d(ft),d(Ke);var N=f(Ke,2);{var Q=Re=>{var Ne=Gd(),pe=f(u(Ne),2),Fe=u(pe);dt(Fe),Fe.value=Fe.__value="private",at(),d(pe);var C=f(pe,2),l=u(C);dt(l),l.value=l.__value="public",at(),d(C),d(Ne),er(ae,[],Fe,()=>t(rt),b=>h(rt,b)),er(ae,[],l,()=>t(rt),b=>h(rt,b)),p(Re,Ne)};A(N,Re=>{t(lt)&&Re(Q)})}d(ne),B(()=>te(Ae,`Create remote ${t(K).matchingRule.provider??""} repository`)),Rn(st,()=>t(lt),Re=>h(lt,Re)),p(ge,ne)};A(Nt,ge=>{t(K).matchingRule&&ge(Wt)})}d(x);var Zt=f(x,2),Pe=u(Zt),Ve=f(Pe,2);d(Zt),d(U),d(w),B(()=>{te($,t(We)),q.disabled=t(K).isGit}),Rn(q,()=>t(it),ge=>h(it,ge)),W("click",Pe,()=>h(ye,!1)),W("click",Ve,()=>{h(ye,!1),Nn(t(We).trim(),t(Ge)||void 0,t(it),t(K).matchingRule?t(lt):void 0,t(K).matchingRule?t(rt):void 0)}),p(y,w)};A(tt,y=>{t(ye)&&y(Xe)})}d(M),B(()=>{Va(ie,r().hideThinking),xe.disabled=!t(Qt)}),W("change",ie,y=>mo({hideThinking:y.currentTarget.checked})),W("click",xe,function(...y){po?.apply(this,y)}),p(n,M);var mt=rr($n);return oe(),mt}ur(["click","keydown","change"]);function Yd(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 Zd=g("<option> </option>"),Xd=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>'),Qd=g('<div class="mt-2 rounded border border-red-900/40 bg-red-950/40 p-2 leading-normal text-red-400"> </div>'),Jd=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),eu=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 tu(n,e){nr(e,!0);let r=ir(e,"text",15);const s=typeof window<"u"?window.SpeechRecognition||window.webkitSpeechRecognition:null,a=!!s;let o=Z(!1),i=Z(!1),c=Z(!1),_=Z(!1),v=Z(!1),m=Z("en-US"),E=Z("browser"),L=Z(null),P=Z(null),S=null,oe=null,ae=null,me=null,de=null,Je=[],Ie="",Oe=!1;const ke=[{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)"}];Fr(()=>{const k=localStorage.getItem("wherever-speech-direct-send");k!==null&&h(v,k==="true");const re=localStorage.getItem("wherever-speech-locale");re!==null&&h(m,re,!0);const T=localStorage.getItem("wherever-speech-engine");return T!==null?h(E,T,!0):a||h(E,"cloud"),()=>{if(S)try{S.abort()}catch{}if(me)try{me.disconnect()}catch{}if(ae)try{ae.disconnect()}catch{}if(de)try{de.getTracks().forEach(se=>se.stop())}catch{}if(oe)try{oe.close()}catch{}t(P)&&clearTimeout(t(P))}});function Ue(){localStorage.setItem("wherever-speech-direct-send",String(t(v))),localStorage.setItem("wherever-speech-locale",t(m)),localStorage.setItem("wherever-speech-engine",t(E))}function We(){const k=localStorage.getItem("wherever-config");if(k){const re=JSON.parse(k),T=window.location.protocol==="https:"?"https:":"http:",se=re.host.startsWith("http")?re.host.replace(/^wss?:\/\//,""):re.host;return`${T}//${se}:${re.port}`}return`${window.location.protocol}//${window.location.host}`}function Lt(){try{const k=localStorage.getItem("wherever-config");if(k)return JSON.parse(k).token||""}catch{}return""}function ot(){try{const k=window.AudioContext||window.webkitAudioContext;if(!k)return;const re=new k,T=re.createOscillator(),se=re.createGain();T.type="sine",T.frequency.setValueAtTime(400,re.currentTime),se.gain.setValueAtTime(.08,re.currentTime),se.gain.exponentialRampToValueAtTime(.001,re.currentTime+.12),T.connect(se),se.connect(re.destination),T.start(),T.stop(re.currentTime+.12)}catch(k){console.warn("Could not play audio beep feedback:",k)}}function be(k,re,T){if(re===T)return k;const se=re/T,z=Math.round(k.length/se),ve=new Float32Array(z);let he=0,Ze=0;for(;he<ve.length;){const ze=Math.round((he+1)*se);let gt=0,Ct=0;for(let qe=Ze;qe<ze&&qe<k.length;qe++)gt+=k[qe],Ct++;ve[he]=Ct>0?gt/Ct:0,he++,Ze=ze}return ve}function Ye(){if(a)try{S=new s,S.continuous=!0,S.interimResults=!0,S.lang=t(m),S.onstart=()=>{h(o,!0),h(i,!1),ot()},S.onresult=k=>{let re="",T="";for(let z=k.resultIndex;z<k.results.length;++z){const ve=k.results[z];ve.isFinal?re+=ve[0].transcript:T+=ve[0].transcript}const se=(re+T).trim();se&&(Oe=!0,r(Ie+(Ie?" ":"")+se))},S.onerror=k=>{console.error("Browser speech recognition error:",k.error),k.error!=="no-speech"&&h(L,`Error: ${k.error}`),qt()},S.onend=()=>{h(o,!1),t(v)&&Oe&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50)},S.start(),navigator.vibrate&&navigator.vibrate(40)}catch(k){console.error("Failed to start browser speech recognition:",k),h(L,"Failed to start browser recording"),h(o,!1)}}function qt(){if(S)try{S.stop()}catch{}h(o,!1)}async function Ge(){try{const k=await navigator.mediaDevices.getUserMedia({audio:!0});de=k,Je=[];const re=window.AudioContext||window.webkitAudioContext;oe=new re,ae=oe.createMediaStreamSource(k),me=oe.createScriptProcessor(4096,1,1),me.onaudioprocess=T=>{const se=T.inputBuffer.getChannelData(0);Je.push(new Float32Array(se))},ae.connect(me),me.connect(oe.destination),h(o,!0),h(i,!1),ot(),navigator.vibrate&&navigator.vibrate(40)}catch(k){console.error("Failed to start cloud audio recording:",k),h(L,k.message||"Microphone access denied",!0),h(o,!1),h(i,!1)}}function it(){if(t(o)){if(h(o,!1),h(i,!0),me){try{me.disconnect()}catch{}me.onaudioprocess=null}if(ae)try{ae.disconnect()}catch{}if(de)try{de.getTracks().forEach(k=>k.stop())}catch{}Et()}}async function Et(){try{if(Je.length===0){h(i,!1);return}h(L,null);let k=0;for(const Bt of Je)k+=Bt.length;const re=new Float32Array(k);let T=0;for(const Bt of Je)re.set(Bt,T),T+=Bt.length;const se=oe?oe.sampleRate:48e3,z=16e3,ve=be(re,se,z),he=zt(ve,1,z,1,16),Ze=new Blob([he],{type:"audio/wav"}),ze=We(),gt=Lt(),Ct=`${ze}/session/transcribe${gt?`?token=${encodeURIComponent(gt)}`:""}`,qe=await fetch(Ct,{method:"POST",body:Ze,headers:{"Content-Type":"application/octet-stream"}}),Be=await qe.json();if(!qe.ok)throw new Error(Be.error||`HTTP ${qe.status}`);Be.text&&Be.text.trim()&&(Oe=!0,r(Ie+(Ie?" ":"")+Be.text.trim()),t(v)&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50))}catch(k){console.error("Cloud transcription request failed:",k),h(L,k.message||"Cloud API failed",!0)}finally{if(h(i,!1),oe){try{oe.close()}catch{}oe=null}}}function lt(){e.disabled||t(o)||t(i)||(h(L,null),Oe=!1,Ie=r(),t(E)==="cloud"?Ge():Ye())}function rt(){t(E)==="cloud"?it():qt()}function ye(k){if(k.button===0&&!e.disabled){if(k.preventDefault(),t(o)){rt();return}h(c,!1),h(P,setTimeout(()=>{h(c,!0),lt()},350),!0)}}function ct(k){t(P)&&(clearTimeout(t(P)),h(P,null)),t(c)?(h(c,!1),rt()):t(o)||lt()}function Ee(){t(P)&&(clearTimeout(t(P)),h(P,null)),t(c)&&(h(c,!1),rt())}function zt(k,re,T,se,z){const ve=new ArrayBuffer(44+k.length*2),he=new DataView(ve);return wt(he,0,"RIFF"),he.setUint32(4,36+k.length*2,!0),wt(he,8,"WAVE"),wt(he,12,"fmt "),he.setUint32(16,16,!0),he.setUint16(20,se,!0),he.setUint16(22,re,!0),he.setUint32(24,T,!0),he.setUint32(28,T*re*(z/8),!0),he.setUint16(32,re*(z/8),!0),he.setUint16(34,z,!0),wt(he,36,"data"),he.setUint32(40,k.length*2,!0),K(he,44,k),ve}function K(k,re,T){for(let se=0;se<T.length;se++,re+=2){let z=Math.max(-1,Math.min(1,T[se]));k.setInt16(re,z<0?z*32768:z*32767,!0)}}function wt(k,re,T){for(let se=0;se<T.length;se++)k.setUint8(re+se,T.charCodeAt(se))}var on=eu(),ht=u(on),kt=f(ht,2),je=u(kt);d(kt);var Y=f(kt,2);{var _e=k=>{var re=Jd(),T=jt(re),se=f(T,2),z=f(u(se),2),ve=f(u(z),2),he=u(ve),Ze=f(he,2);d(ve);var ze=f(ve,2),gt=u(ze,!0);d(ze),d(z);var Ct=f(z,2);{var qe=Rt=>{var St=Xd(),It=f(u(St),2);gn(It,21,()=>ke,Cn,(Tt,Qt)=>{var Jt=Zd(),yn=u(Jt,!0);d(Jt);var Se={};B(()=>{te(yn,t(Qt).label),Se!==(Se=t(Qt).code)&&(Jt.value=(Jt.__value=t(Qt).code)??"")}),p(Tt,Jt)}),d(It),d(St),W("change",It,Ue),Pr(It,()=>t(m),Tt=>h(m,Tt)),p(Rt,St)};A(Ct,Rt=>{t(E)==="browser"&&Rt(qe)})}var Be=f(Ct,2),Bt=u(Be),Vt=u(Bt);dt(Vt),at(2),d(Bt),at(2),d(Be);var Ht=f(Be,2);{var hn=Rt=>{var St=Qd(),It=u(St,!0);d(St),B(()=>te(It,t(L))),p(Rt,St)};A(Ht,Rt=>{t(L)&&Rt(hn)})}d(se),B(()=>{he.disabled=!a,rn(he,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors disabled:opacity-40
|
|
78
|
+
${t(E)==="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(E)==="cloud"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),te(gt,t(E)==="browser"?"Uses free built-in browser dictation. Streaming, zero-latency.":"Uses server-side Z.ai / Groq / OpenAI keys. High accent tolerance.")}),W("click",T,()=>h(_,!1)),W("click",he,()=>{h(E,"browser"),Ue()}),W("click",Ze,()=>{h(E,"cloud"),Ue()}),W("change",Vt,Ue),Rn(Vt,()=>t(v),Rt=>h(v,Rt)),p(k,re)};A(Y,k=>{t(_)&&k(_e)})}d(on),B(()=>{ht.disabled=e.disabled&&!t(o)&&!t(i)||t(i),rn(ht,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(o)?"animate-pulse border-red-500 bg-red-600 text-white":t(i)?"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"}`),we(ht,"title",t(o)?"Recording (release/tap to stop)...":t(i)?"Processing speech...":"Hold to speak (walkie-talkie) or Tap to toggle recording"),kt.disabled=e.disabled&&!t(o)&&!t(i)||t(i),rn(je,0,`h-4 w-4 transition-transform duration-200 ${t(_)?"rotate-45 text-white":""}`)}),W("pointerdown",ht,ye),W("pointerup",ht,ct),tr("pointercancel",ht,Ee),W("click",kt,()=>h(_,!t(_))),p(n,on),rr()}ur(["pointerdown","pointerup","click","change"]);var nu=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),ru=g('<span class="text-rose-400">⚠️</span> <span class="text-rose-400/80"> </span>',1),su=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),au=g('<div class="mb-2.5 flex items-center gap-1.5 text-xs font-medium text-brand-text-muted select-none"><!></div>'),ou=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>'),iu=g('<span class="inline-block h-3 w-3 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span>'),lu=g('<a target="_blank" class="ml-1 shrink-0 font-semibold text-brand-blue underline hover:opacity-80">[Test Link]</a>'),cu=g('<span class="flex items-center gap-1 text-[10px] font-medium text-rose-400"><span class="max-w-[120px] truncate"> </span> <!></span>'),du=g('<span class="text-emerald-400">✓</span>'),uu=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>'),fu=g('<div class="mb-3 flex flex-wrap gap-2"></div>'),pu=g("<option> </option>"),hu=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>'),bu=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),vu=g('<span class="hidden font-mono opacity-60 sm:inline">Shift+Enter to send</span>'),gu=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),mu=g('<div class="border-t border-brand-border p-4"><!> <!></div>');function xu(n,e){nr(e,!0);const r=()=>Me(Ys,"$isStreaming",c),s=()=>Me(rs,"$isReadOnly",c),a=()=>Me(Br,"$activeSessionInfo",c),o=()=>Me(zr,"$isConnected",c),i=()=>Me(Ut,"$piState",c),[c,_]=_r();let v=ir(e,"showAttach",3,!0),m=ir(e,"searchMode",3,!1),E=ir(e,"searchConfigured",3,!1),L=ir(e,"searchModels",19,()=>[]),P=ir(e,"searchModel",15,""),S=Z(""),oe=Z(!0),ae=Z(!1),me=Z(void 0),de=Z(An([])),Je=V(r),Ie=V(s),Oe=V(a),ke=V(o),Ue=V(i),We=V(()=>m()?e.disabled||!t(ke)||!E():e.disabled||!t(ke)||t(Ie)||!t(Oe).sessionId),Lt=V(()=>t(de).some(Y=>Y.uploading)),ot=V(()=>!t(We)&&!t(Lt)&&(t(S).trim().length>0||t(de).length>0)),be=Z(void 0);const Ye="wherever-draft:";let qt=V(()=>Ye+(t(Oe).sessionId??"search")),Ge=Z(null);Fr(()=>{const Y=localStorage.getItem("wherever-enter-to-send");Y!==null&&h(oe,Y==="true")}),Ft(()=>{const Y=t(qt);Y!==t(Ge)&&Fs(()=>{let _e=null;if(typeof localStorage<"u")try{_e=localStorage.getItem(Y)}catch{}h(S,_e??"",!0),h(Ge,Y,!0)})}),Ft(()=>{const Y=t(S),_e=t(qt);if(!(_e!==t(Ge)||typeof localStorage>"u"))try{Y.trim().length>0?localStorage.setItem(_e,Y):localStorage.removeItem(_e)}catch{}});function it(){t(ae)&&h(ae,!1),t(be)?.focus()}function Et(){h(oe,!t(oe)),localStorage.setItem("wherever-enter-to-send",String(t(oe)))}Ft(()=>{t(be)&&(t(S),t(be).style.height="auto",t(be).style.height=`${t(be).scrollHeight}px`)}),Ft(()=>{!t(We)&&t(be)&&t(be).focus()});async function lt(Y){Vs();const _e=Y.target;if(!_e.files)return;const k=Array.from(_e.files);_e.value="";const re=t(de).length;h(de,[...t(de),...k.map(T=>({name:T.name,uploading:!0}))],!0);for(let T=0;T<k.length;T++){const se=k[T],z=re+T;try{if(!t(Oe).sessionId)throw new Error("No active session");const ve=await Io(t(Oe).sessionId,se);h(de,t(de).map((he,Ze)=>Ze===z?{name:se.name,path:ve.savedPath,uploading:!1}:he),!0)}catch(ve){const he=ve.message||"Failed to upload";console.error("File upload error details:",ve);let Ze="";try{const ze=zn(),gt=Bn();Ze=`${ze}/health${gt?`?token=${encodeURIComponent(gt)}`:""}`}catch{}h(de,t(de).map((ze,gt)=>gt===z?{name:se.name,error:he,url:Ze,uploading:!1}:ze),!0)}}}function rt(Y){h(de,t(de).filter((_e,k)=>k!==Y),!0)}function ye(){const Y=t(S).trim();if(m()){if(!Y||t(We))return;e.onSubmit?.(Y),h(S,""),e.onSend?.();return}if(!Y&&t(de).length===0)return;let _e=Y;if(t(de).length>0){const T=t(de).filter(se=>se.path);if(T.length>0){const se=T.map(z=>`[Uploaded file: ${z.path}]`).join(`
|
|
81
|
+
`);_e?_e+=`
|
|
82
|
+
|
|
83
|
+
`+se:_e=`I have uploaded the following file(s) for you:
|
|
84
|
+
${se}`}}if(Y.startsWith("/")&&t(de).length===0){const T=Y.toLowerCase();if(T==="/new"||T==="/reset"){if(t(Oe).cwd){Nn(t(Oe).cwd,t(Oe).model||void 0),h(S,"");return}}else if(T==="/clear"){go(),h(S,"");return}else if(T==="/leave"||T==="/exit"){En(),h(S,"");return}}const k=Yd({streaming:t(Je),connected:t(ke),agentPending:t(Ue).agentPending,readOnly:t(Ie),hasSession:!!t(Oe).sessionId});if(k.action!=="send"){(k.reason==="disconnected"||k.reason==="agent-pending")&&Rs(_e);return}Rs(_e)&&(h(S,""),h(de,[],!0),e.onSend?.())}function ct(Y){Y.key==="Enter"&&(t(oe)?Y.shiftKey||(Y.preventDefault(),ye()):Y.shiftKey&&(Y.preventDefault(),ye()))}var Ee={focusInput:it},zt=mu(),K=u(zt);{var wt=Y=>{var _e=au(),k=u(_e);{var re=z=>{var ve=nu();at(2),p(z,ve)},T=z=>{var ve=ru(),he=f(jt(ve),2),Ze=u(he,!0);d(he),B(()=>te(Ze,t(Ue).error)),p(z,ve)},se=z=>{var ve=su();at(2),p(z,ve)};A(k,z=>{t(Ue).connecting?z(re):t(Ue).error?z(T,1):t(ke)||z(se,2)})}d(_e),p(Y,_e)};A(K,Y=>{(!t(ke)||t(Ue).connecting||t(Ue).error)&&Y(wt)})}var on=f(K,2);{var ht=Y=>{var _e=ou(),k=u(_e),re=u(k),T=u(re),se=u(T,!0);d(T);var z=f(T,2),ve=u(z);{var he=qe=>{var Be=wn();B(()=>te(Be,e.placeholder??"Search the web...")),p(qe,Be)},Ze=qe=>{var Be=wn("Agent is working, tap to Steer...");p(qe,Be)},ze=qe=>{var Be=wn("Read-only mode");p(qe,Be)},gt=qe=>{var Be=wn("Select a session first...");p(qe,Be)},Ct=qe=>{var Be=wn("Tap to type a message...");p(qe,Be)};A(ve,qe=>{m()?qe(he):t(Je)?qe(Ze,1):t(Ie)?qe(ze,2):t(Oe).sessionId?qe(Ct,-1):qe(gt,3)})}d(z),d(re),at(2),d(k),d(_e),B(()=>te(se,m()?"🔍":"💬")),W("click",k,()=>{h(ae,!1),setTimeout(()=>t(be)?.focus(),50)}),p(Y,_e)},kt=Y=>{var _e=gu(),k=jt(_e);{var re=Se=>{var bt=fu();gn(bt,21,()=>t(de),Cn,(Ot,$t,Mt)=>{var en=uu(),nn=u(en),un=u(nn,!0);d(nn);var mn=f(nn,2);{var $n=J=>{var Te=iu();p(J,Te)},M=J=>{var Te=cu(),Kt=u(Te),Pt=u(Kt);d(Kt);var Yt=f(Kt,2);{var At=I=>{var O=lu();B(()=>we(O,"href",t($t).url)),p(I,O)};A(Yt,I=>{t($t).url&&I(At)})}d(Te),B(()=>{we(Te,"title",t($t).error),te(Pt,`⚠️ ${t($t).error??""}`)}),p(J,Te)},G=J=>{var Te=du();p(J,Te)};A(mn,J=>{t($t).uploading?J($n):t($t).error?J(M,1):J(G,-1)})}var X=f(mn,2);d(en),B(()=>{we(nn,"title",t($t).name),te(un,t($t).name)}),W("click",X,()=>rt(Mt)),p(Ot,en)}),d(bt),p(Se,bt)};A(k,Se=>{t(de).length>0&&Se(re)})}var T=f(k,2);{var se=Se=>{var bt=hu(),Ot=f(u(bt),2);gn(Ot,21,L,Cn,($t,Mt)=>{var en=pu(),nn=u(en,!0);d(en);var un={};B(()=>{te(nn,t(Mt).label),un!==(un=t(Mt).value)&&(en.value=(en.__value=t(Mt).value)??"")}),p($t,en)}),d(Ot),d(bt),B(()=>Ot.disabled=t(We)),Pr(Ot,P),p(Se,bt)};A(T,Se=>{m()&&L().length>0&&Se(se)})}var z=f(T,2),ve=u(z),he=u(ve);wi(he),we(he,"rows",1),Kn(he,Se=>h(be,Se),()=>t(be)),d(ve);var Ze=f(ve,2),ze=u(Ze);{var gt=Se=>{var bt=bu(),Ot=jt(bt),$t=f(Ot,2);Kn($t,Mt=>h(me,Mt),()=>t(me)),B(()=>Ot.disabled=t(We)),W("click",Ot,()=>{lo(),t(me)?.click()}),W("change",$t,lt),p(Se,bt)};A(ze,Se=>{v()&&!m()&&Se(gt)})}var Ct=f(ze,2),qe=u(Ct);tu(qe,{get disabled(){return t(We)},onSend:ye,get text(){return t(S)},set text(Se){h(S,Se,!0)}}),d(Ct);var Be=f(Ct,2),Bt=u(Be);{var Vt=Se=>{var bt=wn();B(()=>te(bt,e.submitLabel??"Search")),p(Se,bt)},Ht=Se=>{var bt=wn("Steer");p(Se,bt)},hn=Se=>{var bt=wn("Send");p(Se,bt)};A(Bt,Se=>{m()?Se(Vt):t(Je)?Se(Ht,1):Se(hn,-1)})}d(Be),d(Ze),d(z);var Rt=f(z,2),St=u(Rt),It=u(St);dt(It),at(2),d(St);var Tt=f(St,2),Qt=u(Tt),Jt=f(Qt,2);{var yn=Se=>{var bt=vu();p(Se,bt)};A(Jt,Se=>{t(oe)||Se(yn)})}d(Tt),d(Rt),B(()=>{he.disabled=t(We),we(he,"placeholder",m()?e.placeholder??"Search the web...":t(ke)?t(Je)?"Agent is working, Steer to interrupt...":t(Ie)?"Read-only mode":t(Oe).sessionId?"Type a message...":"Select a session first...":t(Ue).connecting?"Reconnecting to remote server...":"Disconnected - cannot send"),Be.disabled=!t(ot),we(Be,"title",!m()&&t(Je)?"Steer the agent now (injected at the next step, before the next model call)":void 0),Va(It,t(oe))}),tr("submit",z,Se=>{Se.preventDefault(),ye()}),W("keydown",he,ct),Fn(he,()=>t(S),Se=>h(S,Se)),W("change",It,Et),W("click",Qt,()=>h(ae,!0)),p(Y,_e)};A(on,Y=>{t(ae)?Y(ht):Y(kt,-1)})}d(zt),p(n,zt);var je=rr(Ee);return _(),je}ur(["click","keydown","change"]);var _u=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>'),yu=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>'),wu=g('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),ku=g('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),Su=g("<option> </option>"),Tu=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>'),Au=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"/>'),Eu=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>'),Cu=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>'),Ru=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>'),Iu=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>'),$u=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>'),Mu=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>'),Du=g('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),Lu=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>'),Ou=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>'),Pu=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>'),Nu=g('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),Fu=g('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),Uu=g('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),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">❓</button> <button class="px-1.5 text-[10px] text-brand-text-muted hover:text-brand-text focus:outline-none" title="Cancel">✕</button></div>'),Bu=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>'),Hu=g('<div class="flex-shrink-0"><!></div>'),Wu=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>'),Gu=g('<div class="px-3 pb-2"><!> <!></div>'),ju=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>'),qu=g("<option> </option>"),Vu=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>'),Ku=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"/>'),Yu=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>'),Zu=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>'),Xu=g('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),Qu=g('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),Ju=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>'),ef=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>'),tf=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>'),nf=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 Wa(n,e){nr(e,!0);const r=()=>Me(Rr,"$readOnlySessionFolders",E),s=()=>Me(mr,"$sessionFolders",E),a=()=>Me(Br,"$activeSessionInfo",E),o=()=>Me(zr,"$isConnected",E),i=()=>Me(ss,"$isLoadingSession",E),c=()=>Me(Xs,"$isResyncing",E),_=()=>Me(xr,"$availableModels",E),v=()=>Me(Bs,"$gitInitDefaultStore",E),m=()=>Me(Zs,"$sessionError",E),[E,L]=_r(),P=[];let S=ir(e,"readOnly",3,!1),oe=V(()=>S()?r().folders:s().folders),ae=V(()=>S()?r().loading:s().loading);function me(){S()?Qa():Dr()}let de=V(()=>a().sessionFile),Je=V(o),Ie=V(i),Oe=V(c),ke=V(()=>_().models),Ue=An({}),We=Z(An({})),Lt=Z(null),ot=Z(null),be=Z(""),Ye=Z(An([]));Ft(()=>{t(Je)&&(me(),S()||(ji(),qi()))});function qt(M,G,X){if(!X)return!0;const J=X.toLowerCase();return(M.name||"").toLowerCase().includes(J)||M.firstMessage.toLowerCase().includes(J)||G.toLowerCase().includes(J)}Ft(()=>{const M=t(be),G=t(oe);M?h(Ye,G.map(X=>({...X,sessions:X.sessions.filter(J=>qt(J,X.name,M))})).filter(X=>X.sessions.length>0),!0):(h(Ye,G,!0),h(We,{},!0))});function Ge(M){return t(be)?t(We)[M]!==void 0?t(We)[M]:!0:!!Ue[M]}function it(M){t(be)?t(We)[M]=!Ge(M):Ue[M]=!Ge(M)}async function Et(M){try{t(de)===M&&(typeof window<"u"&&(window.location.hash=""),En()),await Ms(M),t(Lt)===M&&h(Lt,null),Dr()}catch(G){console.error("Failed to delete session:",G)}}async function lt(M){try{const G=M.sessions.map(X=>X.path);t(de)&&G.includes(t(de))&&(typeof window<"u"&&(window.location.hash=""),En()),await Promise.all(M.sessions.map(X=>Ms(X.path))),t(ot)===M.path&&h(ot,null),Dr()}catch(G){console.error("Failed to delete all sessions of folder:",G)}}function rt(M){t(de)===M&&!t(Ie)&&!t(Oe)||(cr(),Ks(M))}let ye=Z(!1),ct=Z(""),Ee=Z(An([])),zt=Z(!1),K=Z(null),wt=Z(null),on="",ht=Z(""),kt=Z(!1),je=Z(null),Y=Z(!0),_e=Z("private"),k=Z(!1),re=V(v);Ft(()=>{t(je)===null&&h(kt,t(re),!0)});let T=Z(An({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),se=V(()=>t(T).exists!==!0&&t(T).matchingRule&&t(Y)),z=null;async function ve(M,G=!1){if(z&&clearTimeout(z),M===on&&!G)return;if(on=M,!M.trim()){h(T,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const J=async()=>{const Te=await Zr("");h(Ee,Te||[],!0)};G?await J():z=setTimeout(J,300);return}const X=async()=>{const[J,Te]=await Promise.all([no(M),Zr(M)]);h(Ee,Te||[],!0),J?(h(T,{exists:J.exists,isGit:J.isGit,resolvedPath:J.resolvedPath,matchingRule:J.matchingRule||null},!0),J.exists||(h(kt,t(je)!==null?t(je):t(re),!0),h(Y,!0),J.matchingRule&&h(_e,J.matchingRule.visibility,!0))):h(T,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};G?await X():z=setTimeout(X,300)}Ft(()=>{const M=t(ct);ve(M,!1)}),Ft(()=>{if(t(ke).length>0&&!t(ht)){const M=t(ke).find(G=>G.isDefault);M?h(ht,`${M.provider}:${M.modelId}`):h(ht,`${t(ke)[0].provider}:${t(ke)[0].modelId}`)}});function he(){if(t(ct).trim())if(t(T).exists===!0)h(kt,!1),h(Y,!1),t(T).matchingRule&&h(_e,t(T).matchingRule.visibility,!0),h(k,!0);else{cr();const M=t(ct).trim(),G=t(ht)||void 0,X=t(kt),J=t(T).matchingRule?t(Y):void 0,Te=t(T).matchingRule?t(_e):void 0;h(ct,""),h(ye,!1),t(de)?(En(),setTimeout(()=>{Nn(M,G,X,J,Te)},100)):Nn(M,G,X,J,Te)}}function Ze(){h(k,!1),cr();const M=t(ct).trim(),G=t(ht)||void 0,X=t(kt),J=t(T).matchingRule?t(Y):void 0,Te=t(T).matchingRule?t(_e):void 0;h(ct,""),h(ye,!1),t(de)?(En(),setTimeout(()=>{Nn(M,G,X,J,Te)},100)):Nn(M,G,X,J,Te)}let ze=Z(An({open:!1,folderPath:"",selected:""}));function gt(M){const G=t(ke).find(X=>X.isDefault);h(ze,{open:!0,folderPath:M,selected:G?`${G.provider}:${G.modelId}`:""},!0)}function Ct(){t(ze).open=!1}function qe(){if(!t(ze).open)return;cr();const M=t(ze).folderPath,G=t(ze).selected||void 0;Ct(),t(de)?(En(),setTimeout(()=>{Nn(M,G)},100)):Nn(M,G)}function Be(M){const G=Date.now()-new Date(M).getTime(),X=Math.floor(G/6e4);if(X<1)return"just now";if(X<60)return`${X}m ago`;const J=Math.floor(X/60);return J<24?`${J}h ago`:`${Math.floor(J/24)}d ago`}function Bt(M,G=40){return M.length>G?M.slice(0,G)+"...":M}var Vt=nf(),Ht=jt(Vt),hn=u(Ht),Rt=u(hn),St=u(Rt);dt(St);var It=f(St,2),Tt=u(It);d(It),d(Rt),d(hn);var Qt=f(hn,2),Jt=u(Qt);{var yn=M=>{var G=$u(),X=u(G),J=u(X),Te=u(J,!0);d(J),d(X);var Kt=f(X,2);{var Pt=Yt=>{var At=Iu(),I=u(At),O=f(u(I),2),ie=u(O);dt(ie),Kn(ie,$=>h(K,$),()=>t(K));var Ce=f(ie,2);{var De=$=>{var x=yu();gn(x,21,()=>t(Ee),Cn,(ee,q)=>{var ue=_u(),fe=u(ue,!0);d(ue),B(()=>te(fe,t(q))),W("click",ue,()=>{h(ct,t(q),!0),ve(t(q),!0),t(K)?.focus()}),p(ee,ue)}),d(x),p($,x)};A(Ce,$=>{t(zt)&&t(Ee).length>0&&$(De)})}d(O),Kn(O,$=>h(wt,$),()=>t(wt));var Le=f(O,2);{var j=$=>{var x=ku(),ee=f(u(x));{var q=ue=>{var fe=wu();p(ue,fe)};A(ee,ue=>{t(T).isGit&&ue(q)})}d(x),p($,x)};A(Le,$=>{t(T).exists===!0&&$(j)})}d(I);var xe=f(I,2),tt=f(u(xe),2);{var Xe=$=>{var x=Tu();gn(x,21,()=>t(ke),Cn,(ee,q)=>{var ue=Su(),fe=u(ue);d(ue);var le={};B(()=>{te(fe,`${t(q).label??""}${t(q).isDefault?" (default)":""}`),le!==(le=`${t(q).provider}:${t(q).modelId}`)&&(ue.value=ue.__value=`${t(q).provider}:${t(q).modelId}`)}),p(ee,ue)}),d(x),Pr(x,()=>t(ht),ee=>h(ht,ee)),p($,x)},mt=$=>{var x=Au();dt(x),Fn(x,()=>t(ht),ee=>h(ht,ee)),p($,x)};A(tt,$=>{t(ke).length>0?$(Xe):$(mt,-1)})}d(xe);var y=f(xe,2);{var w=$=>{var x=Cu(),ee=u(x),q=u(ee);dt(q);var ue=f(q,2),fe=u(ue);d(ue),d(ee);var le=f(ee,2);{var Qe=Nt=>{var Wt=Eu(),Zt=f(u(Wt),2),Pe=u(Zt);dt(Pe),Pe.value=Pe.__value="private",at(),d(Zt);var Ve=f(Zt,2),ge=u(Ve);dt(ge),ge.value=ge.__value="public",at(),d(Ve),d(Wt),er(P,[],Pe,()=>t(_e),ne=>h(_e,ne)),er(P,[],ge,()=>t(_e),ne=>h(_e,ne)),p(Nt,Wt)};A(le,Nt=>{t(Y)&&Nt(Qe)})}d(x),B(()=>te(fe,`Create remote ${t(T).matchingRule.provider??""} repository`)),Rn(q,()=>t(Y),Nt=>h(Y,Nt)),p($,x)};A(y,$=>{t(T).exists!==!0&&t(T).matchingRule&&$(w)})}var U=f(y,2);{var D=$=>{var x=Ru(),ee=u(x);dt(ee),at(2),d(x),W("change",ee,q=>{h(je,q.currentTarget.checked,!0)}),Rn(ee,()=>t(kt),q=>h(kt,q)),p($,x)};A(U,$=>{t(T).exists!==!0&&(!t(T).matchingRule||!t(Y))&&$(D)})}var H=f(U,2);d(At),B($=>{rn(ie,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(se)?"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"}`),H.disabled=$},[()=>!t(ct).trim()]),tr("submit",At,$=>{$.preventDefault(),he()}),tr("focus",ie,()=>{h(zt,!0),ve(t(ct),!0)}),tr("blur",ie,$=>{t(wt)&&t(wt).contains($.relatedTarget)||h(zt,!1)}),W("keydown",ie,$=>{$.key==="Escape"&&h(zt,!1)}),Fn(ie,()=>t(ct),$=>h(ct,$)),p(Yt,At)};A(Kt,Yt=>{t(ye)&&Yt(Pt)})}d(G),B(()=>te(Te,t(ye)?"▼ Close Create Session":"✚ Create New Session")),W("click",X,()=>h(ye,!t(ye))),p(M,G)};A(Jt,M=>{S()||M(yn)})}var Se=f(Jt,2);{var bt=M=>{var G=Mu();p(M,G)},Ot=M=>{var G=Du(),X=u(G,!0);d(G),B(()=>te(X,t(be)?"No sessions match your filter":"No sessions found")),p(M,G)},$t=M=>{var G=Gn(),X=jt(G);gn(X,17,()=>t(Ye),J=>J.path,(J,Te)=>{var Kt=ju(),Pt=u(Kt),Yt=u(Pt),At=f(Yt,2),I=u(At),O=u(I,!0);d(I);var ie=f(I,2),Ce=u(ie,!0);d(ie),d(At);var De=f(At,2),Le=u(De,!0);d(De),d(Pt);var j=f(Pt,2);{var xe=Xe=>{var mt=Gu(),y=u(mt);{var w=D=>{var H=Pu(),$=u(H),x=f($,2),ee=u(x);{var q=fe=>{var le=Lu(),Qe=u(le),Nt=f(Qe,2);d(le),W("click",Qe,Wt=>{Wt.stopPropagation(),lt(t(Te))}),W("click",Nt,Wt=>{Wt.stopPropagation(),h(ot,null)}),p(fe,le)},ue=fe=>{var le=Ou();W("click",le,Qe=>{Qe.stopPropagation(),h(ot,t(Te).path,!0)}),p(fe,le)};A(ee,fe=>{t(ot)===t(Te).path?fe(q):fe(ue,-1)})}d(x),d(H),W("click",$,()=>gt(t(Te).path)),p(D,H)};A(y,D=>{S()||D(w)})}var U=f(y,2);gn(U,17,()=>t(Te).sessions,D=>D.path,(D,H)=>{var $=Wu(),x=u($),ee=u(x);{var q=ne=>{var Ke=Nu();p(ne,Ke)},ue=ne=>{var Ke=Fu();p(ne,Ke)};A(ee,ne=>{t(H).isActive?ne(q):ne(ue,-1)})}var fe=f(ee,2),le=u(fe),Qe=u(le,!0);d(le);var Nt=f(le,2),Wt=u(Nt);d(Nt),d(fe);var Zt=f(fe,2);{var Pe=ne=>{var Ke=Uu(),st=u(Ke,!0);d(Ke),B(()=>te(st,t(H).clientCount)),p(ne,Ke)};A(Zt,ne=>{t(H).clientCount>0&&ne(Pe)})}d(x);var Ve=f(x,2);{var ge=ne=>{var Ke=Hu(),st=u(Ke);{var ft=N=>{var Q=zu(),Re=u(Q),Ne=f(Re,2);d(Q),W("click",Re,pe=>{pe.stopPropagation(),Et(t(H).path)}),W("click",Ne,pe=>{pe.stopPropagation(),h(Lt,null)}),p(N,Q)},Ae=N=>{var Q=Bu();W("click",Q,Re=>{Re.stopPropagation(),h(Lt,t(H).path,!0)}),p(N,Q)};A(st,N=>{t(Lt)===t(H).path?N(ft):N(Ae,-1)})}d(Ke),p(ne,Ke)};A(Ve,ne=>{S()||ne(ge)})}d($),B((ne,Ke,st)=>{rn($,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(de)===t(H).path?"bg-brand-surface-3":""}`),we(x,"href",`#${ne??""}`),te(Qe,Ke),te(Wt,`${st??""} · ${t(H).messageCount??""}
|
|
85
|
+
msgs`)},[()=>encodeURIComponent(t(H).id),()=>t(H).name||Bt(t(H).firstMessage)||"Empty session",()=>Be(t(H).modified)]),W("click",x,ne=>{ne.button===0&&!ne.ctrlKey&&!ne.metaKey&&!ne.altKey&&!ne.shiftKey&&(ne.preventDefault(),rt(t(H).path))}),p(D,$)}),d(mt),p(Xe,mt)},tt=V(()=>Ge(t(Te).path));A(j,Xe=>{t(tt)&&Xe(xe)})}d(Kt),B(Xe=>{rn(Yt,1,`text-xs text-brand-text-muted transition-transform ${Xe??""}`),te(O,t(Te).name),te(Ce,t(Te).path),te(Le,t(Te).sessions.length)},[()=>Ge(t(Te).path)?"rotate-90":""]),W("click",Pt,()=>it(t(Te).path)),p(J,Kt)}),p(M,G)};A(Se,M=>{t(ae)&&t(Ye).length===0?M(bt):t(Ye).length===0?M(Ot,1):M($t,-1)})}d(Qt),d(Ht);var Mt=f(Ht,2);{var en=M=>{var G=Yu(),X=u(G),J=f(u(X),2),Te=f(u(J),2),Kt=u(Te,!0);d(Te),d(J);var Pt=f(J,2),Yt=f(u(Pt),2);{var At=De=>{var Le=Vu();gn(Le,21,()=>t(ke),Cn,(j,xe)=>{var tt=qu(),Xe=u(tt);d(tt);var mt={};B(()=>{te(Xe,`${t(xe).label??""}${t(xe).isDefault?" (default)":""}`),mt!==(mt=`${t(xe).provider}:${t(xe).modelId}`)&&(tt.value=tt.__value=`${t(xe).provider}:${t(xe).modelId}`)}),p(j,tt)}),d(Le),Pr(Le,()=>t(ze).selected,j=>t(ze).selected=j),p(De,Le)},I=De=>{var Le=Ku();dt(Le),Fn(Le,()=>t(ze).selected,j=>t(ze).selected=j),p(De,Le)};A(Yt,De=>{t(ke).length>0?De(At):De(I,-1)})}d(Pt);var O=f(Pt,2),ie=u(O),Ce=f(ie,2);d(O),d(X),d(G),B(()=>te(Kt,t(ze).folderPath)),W("click",G,Ct),W("click",X,De=>De.stopPropagation()),W("click",ie,Ct),W("click",Ce,qe),p(M,G)};A(Mt,M=>{t(ze).open&&M(en)})}var nn=f(Mt,2);{var un=M=>{var G=Zu(),X=u(G),J=u(X,!0);d(X);var Te=f(X,2);d(G),B(()=>te(J,m())),W("click",Te,()=>cr()),p(M,G)};A(nn,M=>{m()&&M(un)})}var mn=f(nn,2);{var $n=M=>{var G=tf(),X=u(G),J=f(u(X),2),Te=f(u(J)),Kt=u(Te,!0);d(Te),at(),d(J);var Pt=f(J,2),Yt=u(Pt),At=u(Yt);dt(At);var I=f(At,2),O=f(u(I));{var ie=Xe=>{var mt=Xu();p(Xe,mt)},Ce=Xe=>{var mt=Qu();p(Xe,mt)};A(O,Xe=>{t(T).isGit?Xe(ie):Xe(Ce,-1)})}d(I),d(Yt);var De=f(Yt,2);{var Le=Xe=>{var mt=ef(),y=u(mt),w=u(y);dt(w);var U=f(w,2),D=u(U);d(U),d(y);var H=f(y,2);{var $=x=>{var ee=Ju(),q=f(u(ee),2),ue=u(q);dt(ue),ue.value=ue.__value="private",at(),d(q);var fe=f(q,2),le=u(fe);dt(le),le.value=le.__value="public",at(),d(fe),d(ee),er(P,[],ue,()=>t(_e),Qe=>h(_e,Qe)),er(P,[],le,()=>t(_e),Qe=>h(_e,Qe)),p(x,ee)};A(H,x=>{t(Y)&&x($)})}d(mt),B(()=>te(D,`Create remote ${t(T).matchingRule.provider??""} repository`)),Rn(w,()=>t(Y),x=>h(Y,x)),p(Xe,mt)};A(De,Xe=>{t(T).matchingRule&&Xe(Le)})}d(Pt);var j=f(Pt,2),xe=u(j),tt=f(xe,2);d(j),d(X),d(G),B(()=>{te(Kt,t(ct)),At.disabled=t(T).isGit}),Rn(At,()=>t(kt),Xe=>h(kt,Xe)),W("click",xe,()=>h(k,!1)),W("click",tt,Ze),p(M,G)};A(mn,M=>{t(k)&&M($n)})}B(()=>{Si(St,t(be)),rn(Tt,1,Ri(t(ae)?"animate-spin":""))}),W("input",St,M=>h(be,M.currentTarget.value,!0)),W("click",It,()=>me()),p(n,Vt),rr(),L()}ur(["input","click","keydown","change"]);var rf=g(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60"><div class="mx-4 w-full max-w-md rounded-xl border border-brand-border bg-brand-surface-2 p-6 shadow-xl"><h2 class="mb-2 text-lg font-bold text-brand-text">Session Conflict</h2> <p class="mb-6 text-sm text-brand-text-muted">Another client is active on a session in folder <span class="font-mono text-xs text-brand-text"> </span>. What would you like to do?</p> <div class="flex gap-3"><button class="flex-1 rounded-lg bg-brand-surface-3 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-brand-surface-2">Read Only</button> <button class="flex-1 rounded-lg bg-rose-500 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-rose-600">Take Over</button></div> <p class="mt-4 text-xs text-brand-text-muted"><strong class="text-brand-text">Read Only:</strong> Observe the session
|
|
86
|
+
live but cannot send messages.<br/> <strong class="text-brand-text">Take Over:</strong> Interrupt the other client
|
|
87
|
+
and gain control.</p></div></div>`);function sf(n,e){nr(e,!0);const r=()=>Me(wo,"$conflict",s),[s,a]=_r();let o=V(r);var i=Gn(),c=jt(i);{var _=v=>{var m=rf(),E=u(m),L=f(u(E),2),P=f(u(L)),S=u(P,!0);d(P),at(),d(L);var oe=f(L,2),ae=u(oe),me=f(ae,2);d(oe),at(2),d(E),d(m),B(()=>te(S,t(o).conflictingCwd)),W("click",ae,()=>Is("read_only")),W("click",me,()=>Is("take_over")),p(v,m)};A(c,v=>{t(o)&&v(_)})}p(n,i),rr(),a()}ur(["click"]);function af(n){return n.loading||n.resyncing||n.hasSessionHash}function of(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!af(n)}var lf=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>'),cf=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),df=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),uf=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>'),ff=g('<div class="truncate text-xs text-brand-text-muted"> </div>'),pf=g('<div class="truncate text-xs text-brand-text-muted"> </div>'),hf=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>'),bf=g('<div class="mt-2 text-xs text-rose-400"> </div>'),vf=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>'),gf=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>'),mf=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),xf=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>'),_f=g('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),yf=g('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),wf=g('<span class="text-sm text-brand-text-muted">Not connected</span>'),kf=g('<div class="flex min-w-0 items-center gap-2"><!></div>'),Sf=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>'),Tf=g("<option> </option>"),Af=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>'),Ef=g('<span class="truncate text-brand-text-muted"> </span>'),Cf=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>'),Rf=g('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),If=g('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),$f=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>'),Mf=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>'),Df=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>'),Lf=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>'),Of=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>'),Pf=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>'),Nf=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>'),Ff=g("<!> <!>",1),Uf=g('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),zf=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 Yf(n,e){nr(e,!0);const r=()=>Me(zr,"$isConnected",ae),s=()=>Me(Xs,"$isResyncing",ae),a=()=>Me(Ao,"$isAgentPending",ae),o=()=>Me(ss,"$isLoadingSession",ae),i=()=>Me(ko,"$isInterrupted",ae),c=()=>Me(Zs,"$sessionError",ae),_=()=>Me(So,"$sessionNotice",ae),v=()=>Me(rs,"$isReadOnly",ae),m=()=>Me(Br,"$activeSessionInfo",ae),E=()=>Me(Ut,"$piState",ae),L=()=>Me(xr,"$availableModels",ae),P=()=>Me(To,"$isCreatingSession",ae),S=()=>Me(Hs,"$searchFolderStore",ae),oe=()=>Me(to,"$searchDefaultModelStore",ae),[ae,me]=_r();let de=Z(!1),Je=Z("main"),Ie=Z(!1),Oe;Fr(()=>{setTimeout(()=>lr(),200);const I=()=>{if(t(be)){const Le=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";Le&&Le!==t(K)?Ks(Le):!Le&&t(K)&&En()}};window.addEventListener("hashchange",I);let O=null;const ie=8e3,Ce=()=>{if(document.visibilityState==="hidden"){if(co())return;O&&clearTimeout(O),O=setTimeout(()=>{O=null,document.visibilityState==="hidden"&&t(be)&&io()},ie)}else Vs(),O&&(clearTimeout(O),O=null),t(be)||(Cs()?Es():lr())},De=Le=>{O&&(clearTimeout(O),O=null),document.visibilityState!=="hidden"&&!t(be)&&(Cs()?Es():lr())};return document.addEventListener("visibilitychange",Ce),window.addEventListener("pageshow",De),()=>{window.removeEventListener("hashchange",I),document.removeEventListener("visibilitychange",Ce),window.removeEventListener("pageshow",De),O&&clearTimeout(O)}});function ke(){lr()}function Ue(){En(),Nr()}function We(){Nr(),setTimeout(()=>lr(),100)}function Lt(){Dr()}function ot(){typeof window<"u"&&(window.location.hash=""),En(),h(de,!1)}let be=V(r),Ye=V(s),qt=V(a),Ge=V(o),it=V(i),Et=V(c),lt=V(_),rt=V(v),ye=V(m),ct=V(E),Ee=V(()=>L().models),zt=Z(!1),K=V(()=>t(ye).sessionId);Ft(()=>{typeof window<"u"&&t(be)&&(t(K)?(window.location.hash=encodeURIComponent(t(K)),h(zt,!0)):t(zt)&&(h(zt,!1),window.location.hash&&(window.location.hash="")))});let wt=null;Ft(()=>{if(!t(be)||typeof window>"u"||!window.location.hash)return;const I=decodeURIComponent(window.location.hash.slice(1));I&&(t(K)===I||t(Ge)||t(Ye)||wt||(wt=setTimeout(()=>{wt=null,!(t(K)===I||t(Ge)||t(Ye))&&ho(I)},300)))}),Ft(()=>{t(be)||h(zt,!1)}),Ft(()=>{(t(K)||t(Ge)||t(Ye))&&h(de,!1)});let on=V(P),ht=V(S),kt=Z(void 0),je=V(()=>of({connected:t(be),searchConfigured:!!t(ht),hasSession:!!t(ye).sessionFile,loading:t(Ge),resyncing:t(Ye),hasSessionHash:typeof window<"u"&&!!window.location.hash})),Y=V(()=>t(Ee).map(I=>({value:`${I.provider}:${I.modelId}`,label:`${I.label}${I.isDefault?" (default)":""}`}))),_e=V(oe),k=Z("");Ft(()=>{if(t(Y).length===0||t(Y).some(Ce=>Ce.value===t(k)))return;const O=t(Y).find(Ce=>Ce.value===t(_e)),ie=t(Ee).find(Ce=>Ce.isDefault);h(k,O?O.value:ie?`${ie.provider}:${ie.modelId}`:t(Y)[0].value,!0)});let re=Z(!1);Ft(()=>{t(je)&&!t(re)&&t(kt)&&(h(re,!0),t(kt).focusInput())});function T(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),En(),t(kt)?.focusInput()}var se=zf(),z=jt(se);Ni(z,{title:"Wherever",description:"Create & maintain apps from wherever"});var ve=f(z,2);{var he=I=>{var O=lf();p(I,O)};A(ve,I=>{t(on)&&I(he)})}var Ze=f(ve,2),ze=u(Ze),gt=u(ze),Ct=u(gt),qe=u(Ct);{var Be=I=>{var O=cf(),ie=f(jt(O),2);W("click",ie,()=>h(Ie,!1)),p(I,O)},Bt=I=>{var O=df(),ie=jt(O),Ce=u(ie);at(2),d(ie);var De=f(ie,2),Le=u(De),j=f(Le,2);d(De),B(xe=>we(Ce,"src",xe),[()=>gr("/logo.svg")]),W("click",ie,ot),W("click",Le,()=>h(Ie,!0)),W("click",j,()=>h(de,!1)),p(I,O)};A(qe,I=>{t(Ie)?I(Be):I(Bt,-1)})}d(Ct),d(gt);var Vt=f(gt,2);{var Ht=I=>{var O=uf(),ie=u(O);{let tt=V(()=>(t(ct).connected,"localhost"));ul(ie,{get host(){return t(tt)},port:31415,token:"",onConnected:ke})}var Ce=f(ie,2),De=f(u(Ce),2),Le=u(De),j=f(Le,2),xe=f(j,2);d(De),d(Ce),d(O),W("click",Le,Lt),W("click",j,We),W("click",xe,Ue),p(I,O)},hn=I=>{var O=mf(),ie=jt(O),Ce=u(ie),De=u(Ce),Le=f(De,2),j=u(Le,!0);d(Le);var xe=f(Le,2),tt=u(xe);d(xe),d(Ce);var Xe=f(Ce,2);{var mt=fe=>{var le=hf(),Qe=u(le);{var Nt=ge=>{var ne=ff(),Ke=u(ne);d(ne),B(st=>{we(ne,"title",t(ye).cwd),te(Ke,`📁 ${st??""}`)},[()=>t(ye).cwd.split("/").pop()||t(ye).cwd]),p(ge,ne)};A(Qe,ge=>{t(ye).cwd&&ge(Nt)})}var Wt=f(Qe,2);{var Zt=ge=>{var ne=pf(),Ke=u(ne);d(ne),B(()=>{we(ne,"title",t(ye).model),te(Ke,`🤖 ${t(ye).model??""}`)}),p(ge,ne)};A(Wt,ge=>{t(ye).model&&ge(Zt)})}var Pe=f(Wt,2),Ve=u(Pe);d(Pe),d(le),W("click",Ve,ot),p(fe,le)};A(Xe,fe=>{t(ye).sessionFile&&fe(mt)})}var y=f(Xe,2);{var w=fe=>{var le=bf(),Qe=u(le,!0);d(le),B(()=>te(Qe,t(ct).error)),p(fe,le)};A(y,fe=>{t(ct).error&&!t(be)&&fe(w)})}d(ie);var U=f(ie,2),D=u(U);{var H=fe=>{var le=vf();W("click",le,()=>{h(Je,"readonly"),Qa()}),p(fe,le)},$=fe=>{var le=gf();W("click",le,()=>h(Je,"main")),p(fe,le)};A(D,fe=>{t(Je)==="main"?fe(H):fe($,-1)})}d(U);var x=f(U,2),ee=u(x);{var q=fe=>{Wa(fe,{readOnly:!0})},ue=fe=>{Wa(fe,{})};A(ee,fe=>{t(Je)==="readonly"?fe(q):fe(ue,-1)})}d(x),B(()=>{rn(De,1,`h-2.5 w-2.5 rounded-full ${t(be)?"bg-emerald-500":"bg-rose-500"}`),rn(Le,1,`text-sm ${t(be)?"text-emerald-400":"text-rose-400"}`),te(j,t(be)?"Connected":"Disconnected"),te(tt,`v${Ka}`)}),p(I,O)};A(Vt,I=>{t(Ie)?I(Ht):I(hn,-1)})}d(ze);var Rt=f(ze,2),St=u(Rt),It=u(St),Tt=f(It,2);{var Qt=I=>{var O=xf();W("click",O,T),p(I,O)};A(Tt,I=>{t(be)&&t(ht)&&t(ye).sessionFile&&I(Qt)})}var Jt=f(Tt,2);{var yn=I=>{var O=kf(),ie=u(O);{var Ce=j=>{var xe=_f();p(j,xe)},De=j=>{var xe=yf();p(j,xe)},Le=j=>{var xe=wf();p(j,xe)};A(ie,j=>{t(be)&&t(je)?j(Ce):t(be)?j(De,1):j(Le,-1)})}d(O),p(I,O)};A(Jt,I=>{(!t(be)||!t(ye).sessionFile)&&I(yn)})}var Se=f(Jt,2);{var bt=I=>{var O=Rf(),ie=u(O);{var Ce=j=>{var xe=Sf(),tt=f(u(xe),2),Xe=u(tt,!0);d(tt),d(xe),B(mt=>{we(tt,"title",t(ye).cwd),te(Xe,mt)},[()=>t(ye).cwd.split("/").pop()||t(ye).cwd]),p(j,xe)};A(ie,j=>{t(ye).cwd&&j(Ce)})}var De=f(ie,2);{var Le=j=>{var xe=Cf(),tt=u(xe),Xe=f(u(tt),2);d(tt);var mt=f(tt,2);{var y=U=>{var D=Af();gn(D,21,()=>t(Ee),Cn,($,x)=>{var ee=Tf(),q=u(ee,!0);d(ee);var ue={};B(()=>{te(q,t(x).label),ue!==(ue=`${t(x).provider}:${t(x).modelId}`)&&(ee.value=ee.__value=`${t(x).provider}:${t(x).modelId}`)}),p($,ee)}),d(D);var H;Za(D),B(()=>{H!==(H=t(ye).model)&&(D.value=(D.__value=t(ye).model)??"",zs(D,t(ye).model))}),W("input",D,$=>_o($.currentTarget.value)),p(U,D)},w=U=>{var D=Ef(),H=u(D,!0);d(D),B(()=>{we(D,"title",t(ye).model),te(H,t(ye).model)}),p(U,D)};A(mt,U=>{t(Ee).length>0&&!t(rt)?U(y):U(w,-1)})}d(xe),B(()=>{rn(Xe,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(ct).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),we(Xe,"title",t(ct).isStreaming?"Agent working...":"Ready")}),p(j,xe)};A(De,j=>{t(ye).model&&j(Le)})}d(O),p(I,O)};A(Se,I=>{t(ye).sessionFile&&I(bt)})}var Ot=f(Se,2);{var $t=I=>{var O=If();p(I,O)};A(Ot,I=>{t(rt)&&I($t)})}d(St);var Mt=f(St,2);{var en=I=>{var O=$f();p(I,O)};A(Mt,I=>{t(it)&&I(en)})}var nn=f(Mt,2);{var un=I=>{var O=Mf(),ie=u(O),Ce=u(ie,!0);d(ie);var De=f(ie,2);d(O),B(()=>{rn(O,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(lt).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),te(Ce,t(lt).message)}),W("click",De,()=>xo()),p(I,O)};A(nn,I=>{t(lt)&&I(un)})}var mn=f(nn,2);{var $n=I=>{var O=Df(),ie=u(O),Ce=u(ie,!0);d(ie);var De=f(ie,2);d(O),B(()=>te(Ce,t(Et))),W("click",De,()=>cr()),p(I,O)};A(mn,I=>{t(Et)&&I($n)})}var M=f(mn,2);{var G=I=>{var O=Lf();p(I,O)};A(M,I=>{t(rt)&&!t(it)&&I(G)})}var X=f(M,2);Kn(Kd(X,{onMessageSent:()=>{}}),I=>Oe=I,()=>Oe);var J=f(X,2);{var Te=I=>{var O=Of();p(I,O)},Kt=I=>{var O=Ff(),ie=jt(O);{var Ce=j=>{var xe=Pf();p(j,xe)},De=j=>{var xe=Nf();p(j,xe)};A(ie,j=>{t(ye).sessionFile&&(t(Ye)||!t(be))?j(Ce):t(ye).sessionFile&&t(qt)&&j(De,1)})}var Le=f(ie,2);{let j=V(()=>!!t(ht)),xe=V(()=>t(je)?!t(be):!t(be)||t(rt)||!t(ye).sessionFile||t(Ye)||t(qt));Kn(xu(Le,{get searchMode(){return t(je)},get searchConfigured(){return t(j)},get searchModels(){return t(Y)},onSubmit:tt=>bo(tt,t(k)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(xe)},onSend:()=>Oe?.forceScrollToBottom(),get searchModel(){return t(k)},set searchModel(tt){h(k,tt,!0)}}),tt=>h(kt,tt,!0),()=>t(kt))}p(I,O)};A(J,I=>{t(rt)&&t(ye).sessionFile?I(Te):I(Kt,-1)})}d(Rt);var Pt=f(Rt,2);sf(Pt,{});var Yt=f(Pt,2);{var At=I=>{var O=Uf();W("click",O,()=>h(de,!1)),p(I,O)};A(Yt,I=>{t(de)&&I(At)})}d(Ze),B(()=>rn(ze,1,`app-chrome ${t(de)?"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",It,()=>h(de,!t(de))),p(n,se),rr(),me()}ur(["click","input"]);export{Yf as component,Kf as universal};
|
|
88
|
+
//# sourceMappingURL=2.Dm3S081E.js.map
|