@jmfederico/pi-web 1.202606.0 → 1.202606.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -7
- package/dist/client/assets/{CodeViewer-N88Bx8F6.js → CodeViewer-iYSv2-dg.js} +1 -1
- package/dist/client/assets/{TerminalPanel-DKiL51Xi.js → TerminalPanel-BpFW6j27.js} +4 -4
- package/dist/client/assets/index-D4dbiKXF.js +2210 -0
- package/dist/client/index.html +1 -1
- package/dist/config.js +63 -1
- package/dist/config.js.map +1 -1
- package/dist/pi-web-plugins/info/pi-web-plugin.js +8 -1
- package/dist/pi-web-plugins/updates/package.json +9 -0
- package/dist/pi-web-plugins/{pi-web → updates}/pi-web-plugin.js +38 -30
- package/dist/pi-web-plugins/workspace-tasks/config.js +91 -0
- package/dist/pi-web-plugins/workspace-tasks/package.json +9 -0
- package/dist/pi-web-plugins/workspace-tasks/pi-web-plugin.js +48 -0
- package/dist/pi-web-plugins/workspace-tasks/taskRunner.js +12 -0
- package/dist/pi-web-plugins/workspace-tasks/tasksPanelElement.js +292 -0
- package/dist/pi-web-plugins/workspace-tasks/workspaceTasksClient.js +47 -0
- package/dist/plugin-api/unstable.d.ts +22 -0
- package/dist/plugin-api.d.ts +169 -0
- package/dist/server/app.js +63 -26
- package/dist/server/app.js.map +1 -1
- package/dist/server/configRoutes.js +123 -0
- package/dist/server/configRoutes.js.map +1 -0
- package/dist/server/git/gitEnv.js +15 -0
- package/dist/server/git/gitEnv.js.map +1 -0
- package/dist/server/git/gitService.js +2 -1
- package/dist/server/git/gitService.js.map +1 -1
- package/dist/server/gitRoutes.js +3 -3
- package/dist/server/gitRoutes.js.map +1 -1
- package/dist/server/machines/machineClient.js +134 -0
- package/dist/server/machines/machineClient.js.map +1 -0
- package/dist/server/machines/machinePluginProxyRoutes.js +187 -0
- package/dist/server/machines/machinePluginProxyRoutes.js.map +1 -0
- package/dist/server/machines/machineProxyRoutes.js +92 -0
- package/dist/server/machines/machineProxyRoutes.js.map +1 -0
- package/dist/server/machines/machineRoutes.js +56 -0
- package/dist/server/machines/machineRoutes.js.map +1 -0
- package/dist/server/machines/machineService.js +260 -0
- package/dist/server/machines/machineService.js.map +1 -0
- package/dist/server/machines/machineStore.js +128 -0
- package/dist/server/machines/machineStore.js.map +1 -0
- package/dist/server/piWebPluginService.js +45 -15
- package/dist/server/piWebPluginService.js.map +1 -1
- package/dist/server/piWebStatus.js +127 -36
- package/dist/server/piWebStatus.js.map +1 -1
- package/dist/server/piWebStatusCache.js +32 -0
- package/dist/server/piWebStatusCache.js.map +1 -0
- package/dist/server/sessiond/sessionProxyRoutes.js +17 -14
- package/dist/server/sessiond/sessionProxyRoutes.js.map +1 -1
- package/dist/server/sessiond.js +18 -7
- package/dist/server/sessiond.js.map +1 -1
- package/dist/server/sessions/piSessionManagerGateway.js +87 -0
- package/dist/server/sessions/piSessionManagerGateway.js.map +1 -0
- package/dist/server/sessions/piSessionService.js +147 -66
- package/dist/server/sessions/piSessionService.js.map +1 -1
- package/dist/server/sessions/sessionArchiveStore.js +12 -0
- package/dist/server/sessions/sessionArchiveStore.js.map +1 -1
- package/dist/server/sessions/sessionNameGenerator.js +2 -0
- package/dist/server/sessions/sessionNameGenerator.js.map +1 -1
- package/dist/server/sessions/sessionRoutes.js +126 -43
- package/dist/server/sessions/sessionRoutes.js.map +1 -1
- package/dist/server/terminalProxyRoutes.js +20 -10
- package/dist/server/terminalProxyRoutes.js.map +1 -1
- package/dist/server/terminals/terminalRoutes.js +11 -0
- package/dist/server/terminals/terminalRoutes.js.map +1 -1
- package/dist/server/terminals/terminalService.js +6 -0
- package/dist/server/terminals/terminalService.js.map +1 -1
- package/dist/server/workspaceExplorerRoutes.js +4 -4
- package/dist/server/workspaceExplorerRoutes.js.map +1 -1
- package/dist/server/workspaces/fileSuggestions.js +98 -17
- package/dist/server/workspaces/fileSuggestions.js.map +1 -1
- package/dist/server/workspaces/gitWorktreeDiscovery.js +3 -2
- package/dist/server/workspaces/gitWorktreeDiscovery.js.map +1 -1
- package/dist/server/workspaces/workspaceDeletionRoutes.js +113 -0
- package/dist/server/workspaces/workspaceDeletionRoutes.js.map +1 -0
- package/dist/shared/apiTypes.d.ts +498 -0
- package/dist/shared/apiTypes.js +3 -1
- package/dist/shared/apiTypes.js.map +1 -1
- package/dist/shared/capabilities.js +25 -0
- package/dist/shared/capabilities.js.map +1 -0
- package/dist/shared/federatedRoutes.js +61 -0
- package/dist/shared/federatedRoutes.js.map +1 -0
- package/dist/shared/machinePluginIds.js +41 -0
- package/dist/shared/machinePluginIds.js.map +1 -0
- package/dist/shared/piWebStatusParsing.js +43 -0
- package/dist/shared/piWebStatusParsing.js.map +1 -1
- package/dist/shared/pluginIds.js +5 -0
- package/dist/shared/pluginIds.js.map +1 -0
- package/dist/shared/workspaceDeletion.js +12 -0
- package/dist/shared/workspaceDeletion.js.map +1 -0
- package/docs/plugins.md +278 -71
- package/package.json +8 -12
- package/plugin-api/unstable.d.ts +1 -0
- package/plugin-api.d.ts +1 -148
- package/dist/client/assets/index-DeSR1RUE.js +0 -1446
- package/dist/pi-web-plugins/pi-web/package.json +0 -9
|
@@ -1,1446 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CodeViewer-N88Bx8F6.js","assets/vendor-editor-core-B4Sq6exx.js","assets/vendor-editor-languages-DznYbTkJ.js","assets/vendor-editor-legacy-B4QLsWF8.js","assets/TerminalPanel-DKiL51Xi.js","assets/vendor-terminal-DjQ08hXu.js","assets/vendor-terminal-DDGTF8rc.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{Q as ti,w as De,J as Gt,R as vo,S as bo,G as wo,U as yo,V as xo,A as ko,W as So,X as $o,Y as Po,Z as si,x as ii,_ as To}from"./vendor-editor-core-B4Sq6exx.js";import{m as Co,i as Ao,d as Io}from"./vendor-editor-languages-DznYbTkJ.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const n of o.addedNodes)n.tagName==="LINK"&&n.rel==="modulepreload"&&i(n)}).observe(document,{childList:!0,subtree:!0});function s(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(r){if(r.ep)return;r.ep=!0;const o=s(r);fetch(r.href,o)}})();const bt=globalThis,bs=bt.ShadowRoot&&(bt.ShadyCSS===void 0||bt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ws=Symbol(),ri=new WeakMap;let dr=class{constructor(t,s,i){if(this._$cssResult$=!0,i!==ws)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=s}get styleSheet(){let t=this.o;const s=this.t;if(bs&&t===void 0){const i=s!==void 0&&s.length===1;i&&(t=ri.get(s)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&ri.set(s,t))}return t}toString(){return this.cssText}};const Ro=e=>new dr(typeof e=="string"?e:e+"",void 0,ws),j=(e,...t)=>{const s=e.length===1?e[0]:t.reduce((i,r,o)=>i+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+e[o+1],e[0]);return new dr(s,e,ws)},Mo=(e,t)=>{if(bs)e.adoptedStyleSheets=t.map(s=>s instanceof CSSStyleSheet?s:s.styleSheet);else for(const s of t){const i=document.createElement("style"),r=bt.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=s.cssText,e.appendChild(i)}},oi=bs?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let s="";for(const i of t.cssRules)s+=i.cssText;return Ro(s)})(e):e;const{is:Eo,defineProperty:Do,getOwnPropertyDescriptor:_o,getOwnPropertyNames:Lo,getOwnPropertySymbols:Oo,getPrototypeOf:Wo}=Object,Wt=globalThis,ni=Wt.trustedTypes,jo=ni?ni.emptyScript:"",No=Wt.reactiveElementPolyfillSupport,et=(e,t)=>e,St={toAttribute(e,t){switch(t){case Boolean:e=e?jo:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let s=e;switch(t){case Boolean:s=e!==null;break;case Number:s=e===null?null:Number(e);break;case Object:case Array:try{s=JSON.parse(e)}catch{s=null}}return s}},ys=(e,t)=>!Eo(e,t),ai={attribute:!0,type:String,converter:St,reflect:!1,useDefault:!1,hasChanged:ys};Symbol.metadata??=Symbol("metadata"),Wt.litPropertyMetadata??=new WeakMap;let Oe=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=ai){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(t,i,s);r!==void 0&&Do(this.prototype,t,r)}}static getPropertyDescriptor(t,s,i){const{get:r,set:o}=_o(this.prototype,t)??{get(){return this[s]},set(n){this[s]=n}};return{get:r,set(n){const a=r?.call(this);o?.call(this,n),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ai}static _$Ei(){if(this.hasOwnProperty(et("elementProperties")))return;const t=Wo(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(et("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(et("properties"))){const s=this.properties,i=[...Lo(s),...Oo(s)];for(const r of i)this.createProperty(r,s[r])}const t=this[Symbol.metadata];if(t!==null){const s=litPropertyMetadata.get(t);if(s!==void 0)for(const[i,r]of s)this.elementProperties.set(i,r)}this._$Eh=new Map;for(const[s,i]of this.elementProperties){const r=this._$Eu(s,i);r!==void 0&&this._$Eh.set(r,s)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const s=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const r of i)s.unshift(oi(r))}else t!==void 0&&s.push(oi(t));return s}static _$Eu(t,s){const i=s.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Mo(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,s,i){this._$AK(t,i)}_$ET(t,s){const i=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,i);if(r!==void 0&&i.reflect===!0){const o=(i.converter?.toAttribute!==void 0?i.converter:St).toAttribute(s,i.type);this._$Em=t,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(t,s){const i=this.constructor,r=i._$Eh.get(t);if(r!==void 0&&this._$Em!==r){const o=i.getPropertyOptions(r),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:St;this._$Em=r;const a=n.fromAttribute(s,o.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(t,s,i,r=!1,o){if(t!==void 0){const n=this.constructor;if(r===!1&&(o=this[t]),i??=n.getPropertyOptions(t),!((i.hasChanged??ys)(o,s)||i.useDefault&&i.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(n._$Eu(t,i))))return;this.C(t,s,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,s,{useDefault:i,reflect:r,wrapped:o},n){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,n??s??this[t]),o!==!0||n!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),r===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(s){Promise.reject(s)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[r,o]of i){const{wrapped:n}=o,a=this[r];n!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,o,a)}}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(s)):this._$EM()}catch(i){throw t=!1,this._$EM(),i}t&&this._$AE(s)}willUpdate(t){}_$AE(t){this._$EO?.forEach(s=>s.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(s=>this._$ET(s,this[s])),this._$EM()}updated(t){}firstUpdated(t){}};Oe.elementStyles=[],Oe.shadowRootOptions={mode:"open"},Oe[et("elementProperties")]=new Map,Oe[et("finalized")]=new Map,No?.({ReactiveElement:Oe}),(Wt.reactiveElementVersions??=[]).push("2.1.2");const xs=globalThis,li=e=>e,$t=xs.trustedTypes,ci=$t?$t.createPolicy("lit-html",{createHTML:e=>e}):void 0,pr="$lit$",ge=`lit$${Math.random().toFixed(9).slice(2)}$`,hr="?"+ge,Fo=`<${hr}>`,Pe=document,tt=()=>Pe.createComment(""),st=e=>e===null||typeof e!="object"&&typeof e!="function",ks=Array.isArray,Bo=e=>ks(e)||typeof e?.[Symbol.iterator]=="function",Kt=`[
|
|
3
|
-
\f\r]`,Ve=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,di=/-->/g,pi=/>/g,ye=RegExp(`>|${Kt}(?:([^\\s"'>=/]+)(${Kt}*=${Kt}*(?:[^
|
|
4
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),hi=/'/g,ui=/"/g,ur=/^(?:script|style|textarea|title)$/i,zo=e=>(t,...s)=>({_$litType$:e,strings:t,values:s}),c=zo(1),ve=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),fi=new WeakMap,Se=Pe.createTreeWalker(Pe,129);function fr(e,t){if(!ks(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return ci!==void 0?ci.createHTML(t):t}const qo=(e,t)=>{const s=e.length-1,i=[];let r,o=t===2?"<svg>":t===3?"<math>":"",n=Ve;for(let a=0;a<s;a++){const l=e[a];let d,u,h=-1,f=0;for(;f<l.length&&(n.lastIndex=f,u=n.exec(l),u!==null);)f=n.lastIndex,n===Ve?u[1]==="!--"?n=di:u[1]!==void 0?n=pi:u[2]!==void 0?(ur.test(u[2])&&(r=RegExp("</"+u[2],"g")),n=ye):u[3]!==void 0&&(n=ye):n===ye?u[0]===">"?(n=r??Ve,h=-1):u[1]===void 0?h=-2:(h=n.lastIndex-u[2].length,d=u[1],n=u[3]===void 0?ye:u[3]==='"'?ui:hi):n===ui||n===hi?n=ye:n===di||n===pi?n=Ve:(n=ye,r=void 0);const g=n===ye&&e[a+1].startsWith("/>")?" ":"";o+=n===Ve?l+Fo:h>=0?(i.push(d),l.slice(0,h)+pr+l.slice(h)+ge+g):l+ge+(h===-2?a:g)}return[fr(e,o+(e[s]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};class it{constructor({strings:t,_$litType$:s},i){let r;this.parts=[];let o=0,n=0;const a=t.length-1,l=this.parts,[d,u]=qo(t,s);if(this.el=it.createElement(d,i),Se.currentNode=this.el.content,s===2||s===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(r=Se.nextNode())!==null&&l.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(const h of r.getAttributeNames())if(h.endsWith(pr)){const f=u[n++],g=r.getAttribute(h).split(ge),b=/([.?@])?(.*)/.exec(f);l.push({type:1,index:o,name:b[2],strings:g,ctor:b[1]==="."?Uo:b[1]==="?"?Vo:b[1]==="@"?Go:jt}),r.removeAttribute(h)}else h.startsWith(ge)&&(l.push({type:6,index:o}),r.removeAttribute(h));if(ur.test(r.tagName)){const h=r.textContent.split(ge),f=h.length-1;if(f>0){r.textContent=$t?$t.emptyScript:"";for(let g=0;g<f;g++)r.append(h[g],tt()),Se.nextNode(),l.push({type:2,index:++o});r.append(h[f],tt())}}}else if(r.nodeType===8)if(r.data===hr)l.push({type:2,index:o});else{let h=-1;for(;(h=r.data.indexOf(ge,h+1))!==-1;)l.push({type:7,index:o}),h+=ge.length-1}o++}}static createElement(t,s){const i=Pe.createElement("template");return i.innerHTML=t,i}}function We(e,t,s=e,i){if(t===ve)return t;let r=i!==void 0?s._$Co?.[i]:s._$Cl;const o=st(t)?void 0:t._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),o===void 0?r=void 0:(r=new o(e),r._$AT(e,s,i)),i!==void 0?(s._$Co??=[])[i]=r:s._$Cl=r),r!==void 0&&(t=We(e,r._$AS(e,t.values),r,i)),t}class Ho{constructor(t,s){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=s}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:s},parts:i}=this._$AD,r=(t?.creationScope??Pe).importNode(s,!0);Se.currentNode=r;let o=Se.nextNode(),n=0,a=0,l=i[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new Fe(o,o.nextSibling,this,t):l.type===1?d=new l.ctor(o,l.name,l.strings,this,t):l.type===6&&(d=new Ko(o,this,t)),this._$AV.push(d),l=i[++a]}n!==l?.index&&(o=Se.nextNode(),n++)}return Se.currentNode=Pe,r}p(t){let s=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,s),s+=i.strings.length-2):i._$AI(t[s])),s++}}class Fe{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,s,i,r){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=s,this._$AM=i,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const s=this._$AM;return s!==void 0&&t?.nodeType===11&&(t=s.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,s=this){t=We(this,t,s),st(t)?t===E||t==null||t===""?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==ve&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Bo(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==E&&st(this._$AH)?this._$AA.nextSibling.data=t:this.T(Pe.createTextNode(t)),this._$AH=t}$(t){const{values:s,_$litType$:i}=t,r=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=it.createElement(fr(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===r)this._$AH.p(s);else{const o=new Ho(r,this),n=o.u(this.options);o.p(s),this.T(n),this._$AH=o}}_$AC(t){let s=fi.get(t.strings);return s===void 0&&fi.set(t.strings,s=new it(t)),s}k(t){ks(this._$AH)||(this._$AH=[],this._$AR());const s=this._$AH;let i,r=0;for(const o of t)r===s.length?s.push(i=new Fe(this.O(tt()),this.O(tt()),this,this.options)):i=s[r],i._$AI(o),r++;r<s.length&&(this._$AR(i&&i._$AB.nextSibling,r),s.length=r)}_$AR(t=this._$AA.nextSibling,s){for(this._$AP?.(!1,!0,s);t!==this._$AB;){const i=li(t).nextSibling;li(t).remove(),t=i}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}}let jt=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,s,i,r,o){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=s,this._$AM=r,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=E}_$AI(t,s=this,i,r){const o=this.strings;let n=!1;if(o===void 0)t=We(this,t,s,0),n=!st(t)||t!==this._$AH&&t!==ve,n&&(this._$AH=t);else{const a=t;let l,d;for(t=o[0],l=0;l<o.length-1;l++)d=We(this,a[i+l],s,l),d===ve&&(d=this._$AH[l]),n||=!st(d)||d!==this._$AH[l],d===E?t=E:t!==E&&(t+=(d??"")+o[l+1]),this._$AH[l]=d}n&&!r&&this.j(t)}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Uo=class extends jt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===E?void 0:t}},Vo=class extends jt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E)}},Go=class extends jt{constructor(t,s,i,r,o){super(t,s,i,r,o),this.type=5}_$AI(t,s=this){if((t=We(this,t,s,0)??E)===ve)return;const i=this._$AH,r=t===E&&i!==E||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==E&&(i===E||r);r&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}};class Ko{constructor(t,s,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=s,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){We(this,t)}}const Qo={I:Fe},Jo=xs.litHtmlPolyfillSupport;Jo?.(it,Fe),(xs.litHtmlVersions??=[]).push("3.3.2");const Zo=(e,t,s)=>{const i=s?.renderBefore??t;let r=i._$litPart$;if(r===void 0){const o=s?.renderBefore??null;i._$litPart$=r=new Fe(t.insertBefore(tt(),o),o,void 0,s??{})}return r._$AI(e),r};const Ss=globalThis;let C=class extends Oe{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Zo(s,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ve}};C._$litElement$=!0,C.finalized=!0,Ss.litElementHydrateSupport?.({LitElement:C});const Xo=Ss.litElementPolyfillSupport;Xo?.({LitElement:C});(Ss.litElementVersions??=[]).push("4.2.2");const M=e=>(t,s)=>{s!==void 0?s.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const Yo={attribute:!0,type:String,converter:St,reflect:!1,hasChanged:ys},en=(e=Yo,t,s)=>{const{kind:i,metadata:r}=s;let o=globalThis.litPropertyMetadata.get(r);if(o===void 0&&globalThis.litPropertyMetadata.set(r,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(s.name,e),i==="accessor"){const{name:n}=s;return{set(a){const l=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,l,e,!0,a)},init(a){return a!==void 0&&this.C(n,void 0,e,a),a}}}if(i==="setter"){const{name:n}=s;return function(a){const l=this[n];t.call(this,a),this.requestUpdate(n,l,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function p(e){return(t,s)=>typeof s=="object"?en(e,t,s):((i,r,o)=>{const n=r.hasOwnProperty(o);return r.constructor.createProperty(o,i),n?Object.getOwnPropertyDescriptor(r,o):void 0})(e,t,s)}function k(e){return p({...e,state:!0,attribute:!1})}const tn=(e,t,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(e,t,s),s);function ne(e,t){return(s,i,r)=>{const o=n=>n.renderRoot?.querySelector(e)??null;return tn(s,i,{get(){return o(this)}})}}async function w(e,t,s){const i=new Headers(s?.headers);s?.body!==void 0&&i.set("content-type","application/json");const r=await fetch(e,{...s,headers:i});if(!r.ok){const n=await r.json().catch(()=>({}));throw new Error(sn(n)??r.statusText)}const o=await r.json();return t(o)}function sn(e){if(rn(e))return typeof e.error=="string"?e.error:void 0}function rn(e){return typeof e=="object"&&e!==null}function on(e){return typeof e=="object"&&e!==null}function y(e){if(!on(e))throw new Error("Expected object response");return e}function m(e,t){const s=e[t];if(typeof s!="string")throw new Error(`Expected string field: ${t}`);return s}function x(e,t){const s=e[t];if(s!==void 0){if(typeof s!="string")throw new Error(`Expected optional string field: ${t}`);return s}}function K(e,t){const s=e[t];if(typeof s!="number")throw new Error(`Expected number field: ${t}`);return s}function O(e,t){const s=e[t];if(typeof s!="boolean")throw new Error(`Expected boolean field: ${t}`);return s}function W(e){return t=>{if(!Array.isArray(t))throw new Error("Expected array response");return t.map(e)}}function nn(e){if(!Array.isArray(e))throw new Error("Expected array response");return e}function an(e,t){if(!Array.isArray(e)||!e.every(s=>typeof s=="string"))throw new Error(`Expected string array field: ${t}`);return e}function ln(e){if(Array.isArray(e))return{messages:e,start:0,total:e.length};const t=y(e);return{messages:nn(t.messages),start:K(t,"start"),total:K(t,"total")}}function mi(e){const t=y(e);return{id:m(t,"id"),name:m(t,"name"),path:m(t,"path"),createdAt:m(t,"createdAt")}}function cn(e){const t=y(e),s=x(t,"branch");return{id:m(t,"id"),projectId:m(t,"projectId"),path:m(t,"path"),label:m(t,"label"),...s===void 0?{}:{branch:s},isMain:O(t,"isMain"),isGitRepo:O(t,"isGitRepo"),isGitWorktree:O(t,"isGitWorktree")}}function ns(e){const t=y(e),s=x(t,"name"),i=x(t,"parentSessionPath"),r=x(t,"archivedAt");return{id:m(t,"id"),path:m(t,"path"),cwd:m(t,"cwd"),...s===void 0?{}:{name:s},created:m(t,"created"),modified:m(t,"modified"),messageCount:K(t,"messageCount"),firstMessage:m(t,"firstMessage"),...i===void 0?{}:{parentSessionPath:i},...t.archived===!0?{archived:!0}:{},...r===void 0?{}:{archivedAt:r}}}function Ge(e){const t=y(e);return{sessionId:m(t,"sessionId"),isStreaming:O(t,"isStreaming"),isCompacting:O(t,"isCompacting"),isBashRunning:O(t,"isBashRunning"),pendingMessageCount:K(t,"pendingMessageCount"),queuedMessages:t.queuedMessages===void 0?[]:W(dn)(t.queuedMessages),...v("messageCount",le(t,"messageCount")),tokens:pn(t.tokens),cost:K(t,"cost"),...hn(t.model),...Pn(t.contextUsage),...v("thinkingLevel",x(t,"thinkingLevel"))}}function dn(e){const t=y(e),s=m(t,"kind");if(s!=="steer"&&s!=="followUp")throw new Error("Invalid queued message kind");return{kind:s,text:m(t,"text")}}function pn(e){const t=y(e);return{input:K(t,"input"),output:K(t,"output"),cacheRead:K(t,"cacheRead"),cacheWrite:K(t,"cacheWrite"),total:K(t,"total")}}function mr(e){const t=y(e);return{...v("provider",x(t,"provider")),...v("id",x(t,"id")),...v("name",x(t,"name")),...v("contextWindow",le(t,"contextWindow")),...v("reasoning",t.reasoning)}}function hn(e){return e===void 0?{}:{model:mr(e)}}function un(e){const t=y(e);return{models:W(mr)(t.models)}}function fn(e){if(e!=="off"&&e!=="minimal"&&e!=="low"&&e!=="medium"&&e!=="high"&&e!=="xhigh")throw new Error("Invalid thinking level");return e}function mn(e){const t=y(e);return{levels:W(fn)(t.levels)}}function gn(e){if(e!=="oauth"&&e!=="api_key")throw new Error("Invalid auth type");return e}function vn(e){if(e!=="stored"&&e!=="runtime"&&e!=="environment"&&e!=="fallback"&&e!=="models_json_key"&&e!=="models_json_command")throw new Error("Invalid auth status source");return e}function bn(e){const t=y(e),s=t.source===void 0?void 0:vn(t.source);return{configured:O(t,"configured"),...v("source",s),...v("label",x(t,"label"))}}function wn(e){const t=y(e);return{id:m(t,"id"),name:m(t,"name"),authType:gn(t.authType),status:bn(t.status)}}function yn(e){const t=y(e);return{providers:W(wn)(t.providers)}}function pt(e){const t=y(e);return{flowId:m(t,"flowId"),providerId:m(t,"providerId"),providerName:m(t,"providerName"),status:xn(t.status),progress:W(i=>{if(typeof i!="string")throw new Error("Expected progress item string");return i})(t.progress),...v("error",x(t,"error")),...v("auth",kn(t.auth)),...v("prompt",Sn(t.prompt)),...v("select",$n(t.select))}}function xn(e){if(e!=="running"&&e!=="complete"&&e!=="error"&&e!=="cancelled")throw new Error("Invalid OAuth flow status");return e}function kn(e){if(e===void 0)return;const t=y(e);return{url:m(t,"url"),...v("instructions",x(t,"instructions"))}}function Sn(e){if(e===void 0)return;const t=y(e),s=m(t,"kind");if(s!=="prompt"&&s!=="manual")throw new Error("Invalid OAuth prompt kind");return{requestId:m(t,"requestId"),message:m(t,"message"),kind:s,...v("placeholder",x(t,"placeholder")),...t.allowEmpty===!0?{allowEmpty:!0}:{}}}function $n(e){if(e===void 0)return;const t=y(e);return{requestId:m(t,"requestId"),message:m(t,"message"),options:W(vr)(t.options)}}function Pn(e){if(e===void 0)return{};const t=y(e);return{contextUsage:{tokens:yi(t,"tokens"),contextWindow:K(t,"contextWindow"),percent:yi(t,"percent")}}}function Tn(e){const t=y(e),s=m(t,"source");if(s!=="extension"&&s!=="prompt"&&s!=="skill"&&s!=="builtin")throw new Error("Invalid command source");return{name:m(t,"name"),source:s,...v("description",x(t,"description"))}}function gr(e){const t=y(e),s=m(t,"kind");if(s!=="tracked"&&s!=="untracked"&&s!=="other")throw new Error("Invalid file kind");return{path:m(t,"path"),kind:s}}function Cn(e){const t=y(e);return{path:m(t,"path"),entries:W(An)(t.entries),scannedAt:m(t,"scannedAt"),truncated:O(t,"truncated")}}function An(e){const t=y(e),s=m(t,"type");if(s!=="file"&&s!=="directory"&&s!=="symlink")throw new Error("Invalid file tree entry type");return{name:m(t,"name"),path:m(t,"path"),type:s,...v("size",le(t,"size")),...v("modifiedAt",x(t,"modifiedAt"))}}function In(e){const t=y(e),s=m(t,"encoding");if(s!=="utf8")throw new Error("Invalid file encoding");return{path:m(t,"path"),...v("language",x(t,"language")),...v("mediaType",Rn(t.mediaType)),...v("mimeType",x(t,"mimeType")),encoding:s,size:K(t,"size"),modifiedAt:m(t,"modifiedAt"),content:m(t,"content"),truncated:O(t,"truncated"),binary:O(t,"binary")}}function Rn(e){if(e!==void 0){if(e!=="image")throw new Error("Invalid file media type");return e}}function Mn(e){const t=y(e);return{isGitRepo:O(t,"isGitRepo"),hash:m(t,"hash"),...v("branch",x(t,"branch")),...v("upstream",x(t,"upstream")),...v("ahead",le(t,"ahead")),...v("behind",le(t,"behind")),files:W(En)(t.files)}}function En(e){const t=y(e);return{path:m(t,"path"),...v("oldPath",x(t,"oldPath")),index:gi(t.index),workingTree:gi(t.workingTree)}}function gi(e){switch(e){case"unmodified":case"modified":case"added":case"deleted":case"renamed":case"copied":case"untracked":case"ignored":case"conflicted":return e;default:throw new Error("Invalid git file state")}}function Dn(e){const t=y(e);return{...v("path",x(t,"path")),staged:O(t,"staged"),hash:m(t,"hash"),diff:m(t,"diff"),truncated:O(t,"truncated")}}function Qt(e){const t=y(e);return{id:m(t,"id"),cwd:m(t,"cwd"),name:m(t,"name"),createdAt:m(t,"createdAt"),exited:O(t,"exited"),...v("exitCode",le(t,"exitCode")),...v("commandRunId",x(t,"commandRunId"))}}function wt(e){const t=y(e);return{id:m(t,"id"),origin:m(t,"origin"),projectId:m(t,"projectId"),workspaceId:m(t,"workspaceId"),terminalId:m(t,"terminalId"),title:m(t,"title"),command:m(t,"command"),status:_n(t.status),...v("exitCode",le(t,"exitCode")),createdAt:m(t,"createdAt"),...v("startedAt",x(t,"startedAt")),...v("completedAt",x(t,"completedAt")),metadata:Ln(t.metadata,"metadata")}}function _n(e){if(e!=="queued"&&e!=="running"&&e!=="succeeded"&&e!=="failed")throw new Error("Invalid terminal command run status");return e}function Ln(e,t){const s=y(e);return Object.fromEntries(Object.entries(s).map(([i,r])=>{if(typeof r!="string")throw new Error(`Expected string record field: ${t}.${i}`);return[i,r]}))}function On(e){const t=y(e);return{cwd:m(t,"cwd"),hasSessionActivity:O(t,"hasSessionActivity"),hasTerminalActivity:O(t,"hasTerminalActivity"),updatedAt:m(t,"updatedAt")}}function Wn(e){const t=y(e);return{workspaces:W(On)(t.workspaces),generatedAt:m(t,"generatedAt")}}function jn(e){const t=y(e);return{packageName:m(t,"packageName"),generatedAt:m(t,"generatedAt"),components:Nn(t.components),release:Bn(t.release),commands:zn(t.commands),messages:W(qn)(t.messages)}}function Nn(e){const t=y(e);return{web:vi(t.web),sessiond:vi(t.sessiond)}}function vi(e){const t=y(e);return{component:Hn(t.component),label:m(t,"label"),...v("runtimeVersion",x(t,"runtimeVersion")),...v("installedVersion",x(t,"installedVersion")),stale:O(t,"stale"),available:O(t,"available"),...v("installation",Fn(t.installation)),...v("error",x(t,"error"))}}function Fn(e){if(e===void 0)return;const t=y(e),s=m(t,"kind");if(s!=="pi-package"&&s!=="npm-global"&&s!=="local"&&s!=="unknown")throw new Error("Invalid PI WEB installation kind");const i=t.scope;if(i!==void 0&&i!=="user"&&i!=="project")throw new Error("Invalid PI WEB installation scope");return{kind:s,...v("path",x(t,"path")),...v("source",x(t,"source")),...i===void 0?{}:{scope:i},...v("npmRoot",x(t,"npmRoot"))}}function Bn(e){const t=y(e);return{packageName:m(t,"packageName"),...v("latestVersion",x(t,"latestVersion")),updateAvailable:O(t,"updateAvailable"),...v("checkedAt",x(t,"checkedAt")),...t.skipped===!0?{skipped:!0}:{},...v("error",x(t,"error"))}}function zn(e){const t=y(e);return{...v("update",x(t,"update")),...v("restart",x(t,"restart")),...v("restartWeb",x(t,"restartWeb")),...v("restartSessiond",x(t,"restartSessiond")),...v("status",x(t,"status"))}}function qn(e){const t=y(e);return{id:m(t,"id"),severity:Un(t.severity),title:m(t,"title"),body:m(t,"body"),...v("command",x(t,"command"))}}function Hn(e){if(e!=="web"&&e!=="sessiond")throw new Error("Invalid PI WEB service component");return e}function Un(e){if(e!=="info"&&e!=="warning"&&e!=="error")throw new Error("Invalid PI WEB status severity");return e}function bi(e){const t=y(e),s=m(t,"type");if(s==="unsupported")return{type:s,message:m(t,"message")};if(s==="select")return{type:s,requestId:m(t,"requestId"),title:m(t,"title"),options:W(vr)(t.options)};if(s==="done")return{type:s,...v("message",x(t,"message")),...Vn(t.session),...v("promptDraft",x(t,"promptDraft"))};throw new Error("Invalid command result type")}function vr(e){const t=y(e);return{value:m(t,"value"),label:m(t,"label"),...v("description",x(t,"description"))}}function Vn(e){return e===void 0?{}:{session:ns(e)}}function ht(e){if(y(e).accepted!==!0)throw new Error("Expected accepted response");return{accepted:!0}}function br(e){if(y(e).closed!==!0)throw new Error("Expected closed response");return{closed:!0}}function Gn(e){if(y(e).aborted!==!0)throw new Error("Expected aborted response");return{aborted:!0}}function Kn(e){if(y(e).stopped!==!0)throw new Error("Expected stopped response");return{stopped:!0}}function wi(e){const t=y(e);if(t.archived!==!0)throw new Error("Expected archived response");const s=t.sessionIds===void 0?void 0:an(t.sessionIds,"sessionIds"),i=le(t,"archivedCount"),r=le(t,"skippedAlreadyArchivedCount");return{archived:!0,...s===void 0?{}:{sessionIds:s},...i===void 0?{}:{archivedCount:i},...r===void 0?{}:{skippedAlreadyArchivedCount:r}}}function Qn(e){if(y(e).restored!==!0)throw new Error("Expected restored response");return{restored:!0}}function Jn(e){if(y(e).detached!==!0)throw new Error("Expected detached response");return{detached:!0}}function le(e,t){const s=e[t];if(s!==void 0){if(typeof s!="number")throw new Error(`Expected optional number field: ${t}`);return s}}function yi(e,t){const s=e[t];if(s===null)return null;if(typeof s!="number")throw new Error(`Expected number|null field: ${t}`);return s}function v(e,t){return t===void 0?{}:{[e]:t}}function Zn(e,t,s){const i=new URLSearchParams;s?.path!==void 0&&i.set("path",s.path),s?.staged===!0&&i.set("staged","true");const r=i.toString();return`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/git/diff${r?`?${r}`:""}`}function Xn(e,t){const s=new URLSearchParams;t?.limit!==void 0&&s.set("limit",String(t.limit)),t?.before!==void 0&&s.set("before",String(t.before));const i=s.toString();return`/api/sessions/${e}/messages${i?`?${i}`:""}`}function Yn(e,t,s,i){const r=new URLSearchParams;return r.set("path",s),i?.modifiedAt!==void 0&&r.set("v",i.modifiedAt),`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/preview?${r.toString()}`}const wr={piWebStatus:()=>w("/api/pi-web/status",jn)},yr={workspaceActivity:()=>w("/api/activity",Wn)},ea={projects:()=>w("/api/projects",W(mi)),addProject:(e,t,s)=>w("/api/projects",mi,{method:"POST",body:JSON.stringify({path:e,name:t,create:s})}),closeProject:e=>w(`/api/projects/${encodeURIComponent(e)}`,br,{method:"DELETE"}),projectDirectories:e=>w(`/api/project-directories?q=${encodeURIComponent(e)}`,W(gr))},ta={workspaces:e=>w(`/api/projects/${e}/workspaces`,W(cn)),workspaceTree:(e,t,s="")=>w(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/tree?path=${encodeURIComponent(s)}`,Cn),workspaceFile:(e,t,s)=>w(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(s)}`,In)},sa={sessions:e=>w(`/api/sessions?cwd=${encodeURIComponent(e)}`,W(ns)),startSession:e=>w("/api/sessions",ns,{method:"POST",body:JSON.stringify({cwd:e})}),messages:(e,t)=>w(Xn(e,t),ln),status:e=>w(`/api/sessions/${e}/status`,Ge),models:e=>w(`/api/sessions/${e}/models`,un),setModel:(e,t,s)=>w(`/api/sessions/${e}/model`,Ge,{method:"POST",body:JSON.stringify({provider:t,modelId:s})}),cycleModel:(e,t)=>w(`/api/sessions/${e}/model/cycle`,Ge,{method:"POST",body:JSON.stringify({direction:t})}),thinkingLevels:e=>w(`/api/sessions/${e}/thinking-levels`,mn),setThinkingLevel:(e,t)=>w(`/api/sessions/${e}/thinking-level`,Ge,{method:"POST",body:JSON.stringify({level:t})}),cycleThinkingLevel:e=>w(`/api/sessions/${e}/thinking-level/cycle`,Ge,{method:"POST"}),commands:e=>w(`/api/sessions/${e}/commands`,W(Tn)),prompt:(e,t,s)=>w(`/api/sessions/${e}/prompt`,ht,{method:"POST",body:JSON.stringify(s===void 0?{text:t}:{text:t,streamingBehavior:s})}),shell:(e,t)=>w(`/api/sessions/${e}/shell`,ht,{method:"POST",body:JSON.stringify({text:t})}),runCommand:(e,t)=>w(`/api/sessions/${e}/commands/run`,bi,{method:"POST",body:JSON.stringify({text:t})}),respondToCommand:(e,t,s)=>w(`/api/sessions/${e}/commands/respond`,bi,{method:"POST",body:JSON.stringify({requestId:t,value:s})}),abort:e=>w(`/api/sessions/${e}/abort`,Gn,{method:"POST"}),stop:e=>w(`/api/sessions/${e}/stop`,Kn,{method:"POST"}),archive:e=>w(`/api/sessions/${e}/archive`,wi,{method:"POST"}),archiveWithDescendants:e=>w(`/api/sessions/${e}/archive-tree`,wi,{method:"POST"}),restore:e=>w(`/api/sessions/${e}/restore`,Qn,{method:"POST"}),detachParent:e=>w(`/api/sessions/${e}/detach-parent`,Jn,{method:"POST"}),authProviders:e=>{const t=new URLSearchParams;e?.mode!==void 0&&t.set("mode",e.mode),e?.authType!==void 0&&t.set("authType",e.authType);const s=t.toString();return w(`/api/auth/providers${s===""?"":`?${s}`}`,yn)},saveApiKey:(e,t)=>w("/api/auth/api-key",ht,{method:"POST",body:JSON.stringify({providerId:e,key:t})}),logoutProvider:e=>w("/api/auth/logout",ht,{method:"POST",body:JSON.stringify({providerId:e})}),startOAuthLogin:e=>w("/api/auth/oauth",pt,{method:"POST",body:JSON.stringify({providerId:e})}),oauthFlow:e=>w(`/api/auth/oauth/${encodeURIComponent(e)}`,pt),respondOAuthFlow:(e,t,s)=>w(`/api/auth/oauth/${encodeURIComponent(e)}/respond`,pt,{method:"POST",body:JSON.stringify({requestId:t,value:s})}),cancelOAuthFlow:e=>w(`/api/auth/oauth/${encodeURIComponent(e)}/cancel`,pt,{method:"POST"})},$s={terminals:(e,t)=>w(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,W(Qt)),startTerminal:(e,t,s)=>w(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,Qt,{method:"POST",body:JSON.stringify(s??{})}),closeTerminal:(e,t,s)=>w(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(s)}`,br,{method:"DELETE"}),continueTerminal:(e,t,s)=>w(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(s)}/continue`,Qt,{method:"POST"}),runTerminalCommand:(e,t)=>w(`/api/projects/${encodeURIComponent(t.workspace.projectId)}/workspaces/${encodeURIComponent(t.workspace.id)}/terminal-command-runs`,wt,{method:"POST",body:JSON.stringify({origin:e,title:t.title,command:t.command,metadata:t.metadata??{}})}),listCommandRuns:e=>w(`/api/terminal-command-runs${ra(e)}`,W(wt)),getCommandRun:e=>ia(e),cancelCommandRun:e=>w(`/api/terminal-command-runs/${encodeURIComponent(e)}/cancel`,wt,{method:"POST"})};async function ia(e){const t=await fetch(`/api/terminal-command-runs/${encodeURIComponent(e)}`);if(t.status!==404){if(!t.ok){const s=await t.json().catch(()=>({}));throw new Error(oa(s)??t.statusText)}return wt(await t.json())}}function ra(e){if(e===void 0)return"";const t=new URLSearchParams;e.projectId!==void 0&&t.set("projectId",e.projectId),e.workspaceId!==void 0&&t.set("workspaceId",e.workspaceId),e.terminalId!==void 0&&t.set("terminalId",e.terminalId),e.statuses!==void 0&&e.statuses.length>0&&t.set("statuses",e.statuses.join(",")),e.metadata!==void 0&&Object.keys(e.metadata).length>0&&t.set("metadata",JSON.stringify(e.metadata));const s=t.toString();return s===""?"":`?${s}`}function oa(e){if(!na(e))return;const t=e.error;return typeof t=="string"?t:void 0}function na(e){return typeof e=="object"&&e!==null}const aa={files:(e,t,s={})=>{const i=new URLSearchParams({cwd:e,q:t});return s.kind!==void 0&&i.set("kind",s.kind),s.mode!==void 0&&i.set("mode",s.mode),s.scope!==void 0&&i.set("scope",s.scope),w(`/api/files?${i.toString()}`,W(gr))}},la={gitStatus:(e,t)=>w(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/git/status`,Mn),gitDiff:(e,t,s)=>w(Zn(e,t,s),Dn)},F={...wr,...yr,...ea,...ta,...sa,...$s,...aa,...la};function ca(e){return new WebSocket(`${Ps()}/api/sessions/${e}/events`)}function cf(e,t,s,i){const r=i===void 0?"":`?cols=${encodeURIComponent(String(i.cols))}&rows=${encodeURIComponent(String(i.rows))}`;return new WebSocket(`${Ps()}/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(s)}/socket${r}`)}function da(){return new WebSocket(`${Ps()}/api/events`)}function Ps(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}`}function Jt(){return{sessions:[],fileTree:[],expandedDirs:{},selectedFilePath:void 0,selectedFileContent:void 0,fileTreeStale:!1,gitStatus:void 0,selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0,gitStale:!1,selectedTerminalId:void 0,error:""}}function pa(){return{projects:[],workspaces:[],sessions:[],messages:[],messagePageStart:0,messagePageEnd:0,messagePageTotal:0,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,isLoadingProjects:!1,isLoadingWorkspaces:!1,selectedProject:void 0,selectedWorkspace:void 0,selectedSession:void 0,status:void 0,activity:void 0,sessionStatuses:{},sessionActivities:{},workspaceActivities:{},workspacesByProjectId:{},workspaceDeletionRuns:{},commandDialog:void 0,modelDialog:void 0,thinkingDialog:void 0,themeDialog:void 0,authDialog:void 0,actionPaletteOpen:!1,projectDialogOpen:!1,workspaceTool:"core:workspace.files",mainView:"chat",fileTree:[],expandedDirs:{},selectedFilePath:void 0,selectedFileContent:void 0,fileTreeStale:!1,gitStatus:void 0,selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0,gitStale:!1,activeTerminalCount:0,selectedTerminalId:void 0,piWebStatus:void 0,error:""}}function Nt(e,t){return t?.phase==="active"||e?.isStreaming===!0||e?.isBashRunning===!0||e?.isCompacting===!0||(e?.pendingMessageCount??0)>0}function xr(e){return e!==void 0&&(e.hasSessionActivity||e.hasTerminalActivity)}class ha{constructor(t,s,i={}){this.getState=t,this.setState=s,this.api=i.api??yr}async refresh(){const t=await this.api.workspaceActivity();this.setState({workspaceActivities:ua(t)})}applyWorkspaceActivity(t){this.setState({workspaceActivities:fa(this.getState().workspaceActivities,t)})}}function ua(e){const t={};for(const s of e.workspaces)xr(s)&&(t[s.cwd]=s);return t}function fa(e,t){const s={...e};return xr(t)?(s[t.cwd]=t,s):Object.fromEntries(Object.entries(s).filter(([i])=>i!==t.cwd))}class ma{constructor(t,s,i,r={}){this.getState=t,this.setState=s,this.applyStatus=i,this.api=r.api??F,this.pollIntervalMs=r.pollIntervalMs??1e3}dispose(){this.stopPolling()}handleSlashCommand(t){const s=ga(t);return s===void 0?!1:(s.command==="login"?this.openLogin(s.providerId):this.openLogout(s.providerId),!0)}async openLogin(t){if(t!==void 0&&t!==""){await this.openLoginProvider(t);return}this.setState({authDialog:{step:"method"}})}async chooseLoginMethod(t){try{const{providers:s}=await this.api.authProviders({mode:"login",authType:t});this.setState({authDialog:{step:"providers",mode:"login",authType:t,providers:s}})}catch(s){this.setState({error:String(s)})}}async selectLoginProvider(t,s){const i=this.getState().authDialog;if(i?.step!=="providers")return;const r=i.providers.find(o=>o.id===t&&(s===void 0||o.authType===s));r!==void 0&&(r.authType==="oauth"?await this.startOAuth(r):this.setState({authDialog:{step:"apiKey",provider:r,value:""}}))}updateApiKey(t){const s=this.getState().authDialog;if(s?.step!=="apiKey")return;const i={...s};delete i.error,this.setState({authDialog:{...i,value:t}})}async saveApiKey(){const t=this.getState().authDialog;if(t?.step!=="apiKey")return;const s=t.value.trim();if(s===""){this.setState({authDialog:{...t,error:"API key is required"}});return}const i={...t};delete i.error,this.setState({authDialog:{...i,saving:!0}});try{await this.api.saveApiKey(t.provider.id,s),this.closeDialog(),this.refreshStatus()}catch(r){this.setState({authDialog:{...t,saving:!1,error:String(r)}})}}async openLogout(t){try{const{providers:s}=await this.api.authProviders({mode:"logout"});if(t!==void 0&&t!==""){const i=s.find(r=>r.id===t);i!==void 0?await this.logoutProvider(i.id):this.setState({error:`No stored credentials for ${t}`});return}this.setState({authDialog:{step:"logout",providers:s}})}catch(s){this.setState({error:String(s)})}}async logoutProvider(t){try{await this.api.logoutProvider(t),this.closeDialog(),this.refreshStatus()}catch(s){this.setState({error:String(s)})}}updateOAuthInput(t){const s=this.getState().authDialog;if(s?.step!=="oauth")return;const i={...s};delete i.error,this.setState({authDialog:{...i,inputValue:t}})}async respondOAuth(t){const s=this.getState().authDialog;if(s?.step!=="oauth")return;const i=s.flow.prompt??s.flow.select;if(i===void 0)return;const r=t??s.inputValue??"",o={...s};delete o.error,this.setState({authDialog:{...o,responding:!0}});try{const n=await this.api.respondOAuthFlow(s.flow.flowId,i.requestId,r);this.updateOAuthFlow(n)}catch(n){this.setState({authDialog:{...s,responding:!1,error:String(n)}})}}async cancelOAuth(){const t=this.getState().authDialog;if(t?.step!=="oauth"){this.closeDialog();return}this.stopPolling();try{await this.api.cancelOAuthFlow(t.flow.flowId)}catch{}this.closeDialog()}closeDialog(){this.stopPolling(),this.setState({authDialog:void 0})}async openLoginProvider(t){try{const{providers:s}=await this.api.authProviders({mode:"login"}),i=s.filter(o=>o.id===t);if(i.length===0){this.setState({error:`Auth provider not found: ${t}`});return}if(i.length>1){this.setState({authDialog:{step:"providers",mode:"login",providers:i}});return}const r=i[0];if(r===void 0)return;r.authType==="oauth"?await this.startOAuth(r):this.setState({authDialog:{step:"apiKey",provider:r,value:""}})}catch(s){this.setState({error:String(s)})}}async startOAuth(t){try{const s=await this.api.startOAuthLogin(t.id);this.updateOAuthFlow(s),this.startPolling(s.flowId)}catch(s){this.setState({error:String(s)})}}updateOAuthFlow(t){if(t.status==="complete"){this.stopPolling(),this.closeDialog(),this.refreshStatus();return}(t.status==="error"||t.status==="cancelled")&&this.stopPolling();const s=this.getState().authDialog,i=s?.step==="oauth"&&s.flow.flowId===t.flowId?s.inputValue??"":"",r=s?.step==="oauth"?s.flow.prompt?.requestId??s.flow.select?.requestId:void 0,o=t.prompt?.requestId??t.select?.requestId,n=r!==void 0&&r===o,a=n?i:"",l=n&&s?.step==="oauth"?s.responding===!0:!1;this.setState({authDialog:{step:"oauth",flow:t,inputValue:a,responding:l}})}startPolling(t){this.stopPolling(),this.pollTimer=window.setInterval(()=>{this.poll(t)},this.pollIntervalMs)}stopPolling(){this.pollTimer!==void 0&&(window.clearInterval(this.pollTimer),this.pollTimer=void 0)}async poll(t){const s=this.getState().authDialog;if(s?.step!=="oauth"||s.flow.flowId!==t){this.stopPolling();return}try{this.updateOAuthFlow(await this.api.oauthFlow(t))}catch(i){this.stopPolling(),this.setState({authDialog:{...s,error:String(i)}})}}async refreshStatus(){const t=this.sessionId();if(t!==void 0)try{this.applyStatus(await this.api.status(t))}catch{}}sessionId(){const t=this.getState().selectedSession;if(!(t===void 0||t.archived===!0))return t.id}}function ga(e){const t=e.trim(),s=/^\/(login|logout)(?:\s+(\S+))?\s*$/u.exec(t);if(s===null)return;const i=s[1];if(i!=="login"&&i!=="logout")return;const r=s[2];return r===void 0||r===""?{command:i}:{command:i,providerId:r}}function rt(e){return e.replaceAll(":",".")}function va(e){const t=new URLSearchParams(window.location.search),s=`${e}--`,i={};for(const[r,o]of t.entries()){if(!r.startsWith(s))continue;const n=r.slice(s.length),a=i[n];a===void 0?i[n]=o:Array.isArray(a)?a.push(o):i[n]=[a,o]}return i}function Zt(e,t){const s=va(e)[t];return Array.isArray(s)?s[0]:s===""?void 0:s}function ot(e,t,s,i){const r=new URL(window.location.href),o=`${e}--${t}`;if(r.searchParams.delete(o),s!=null&&s!=="")if(Array.isArray(s))for(const n of s)r.searchParams.append(o,String(n));else r.searchParams.set(o,String(s));ba(r,i)}function ba(e,t){const s=`${e.pathname}${e.search}${e.hash}`,i=`${window.location.pathname}${window.location.search}${window.location.hash}`;s!==i&&(t?.replace===!0?window.history.replaceState({},"",e):window.history.pushState({},"",e))}const xi=rt("core:workspace.files");class wa{constructor(t,s,i){this.getState=t,this.setState=s,this.updateUrl=i}async refreshFiles(){const t=this.getState().selectedProject,s=this.getState().selectedWorkspace;if(!(t===void 0||s===void 0))try{const i=await F.workspaceTree(t.id,s.id),r={...this.getState().expandedDirs};await Promise.all(Object.keys(r).map(async o=>{r[o]=(await F.workspaceTree(t.id,s.id,o)).entries})),this.setState({fileTree:i.entries,expandedDirs:r,fileTreeStale:!1,error:""})}catch(i){this.setState({error:String(i)})}}async expandDir(t){const s=this.getState().selectedProject,i=this.getState().selectedWorkspace;if(!(s===void 0||i===void 0)){if(this.getState().expandedDirs[t]!==void 0){this.setState({expandedDirs:xa(this.getState().expandedDirs,t)});return}try{const r=await F.workspaceTree(s.id,i.id,t);this.setState({expandedDirs:{...this.getState().expandedDirs,[t]:r.entries},error:""})}catch(r){this.setState({error:String(r)})}}}async selectFile(t){this.setState({selectedFilePath:t,selectedFileContent:void 0,workspaceTool:"core:workspace.files",mainView:this.getState().mainView==="chat"?"chat":"core:workspace.files"}),ot(xi,"file",t),this.updateUrl({replace:!0}),await this.restoreFile(t)}async restoreFile(t){const s=this.getState().selectedProject,i=this.getState().selectedWorkspace;if(!(s===void 0||i===void 0)){this.setState({selectedFilePath:t,selectedFileContent:void 0});try{const r=await F.workspaceFile(s.id,i.id,t);this.getState().selectedFilePath===t&&this.setState({selectedFileContent:r,error:""})}catch(r){if(this.getState().selectedFilePath!==t)return;if(ya(r)){this.setState({selectedFilePath:void 0,selectedFileContent:void 0,error:""}),ot(xi,"file",void 0,{replace:!0}),this.updateUrl({replace:!0});return}this.setState({error:String(r)})}}}}function ya(e){const t=String(e);return t.includes("Path does not exist")||t.includes("ENOENT")||t.includes("no such file or directory")}function xa(e,t){return Object.fromEntries(Object.entries(e).filter(([s])=>s!==t))}const ki=rt("core:workspace.git");class ka{constructor(t,s,i){this.getState=t,this.setState=s,this.updateUrl=i}dispose(){this.pollTimer!==void 0&&window.clearInterval(this.pollTimer),this.pollTimer=void 0}async refreshGit(){const t=this.getState().selectedProject,s=this.getState().selectedWorkspace;if(!(t===void 0||s===void 0))try{const i=await F.gitStatus(t.id,s.id);this.setState({gitStatus:i,gitStale:!1,error:""});const r=this.getState().selectedDiffPath;r!==void 0&&(i.files.some(o=>o.path===r)?await this.refreshDiff(r):(this.setState({selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0}),ot(ki,"diff",void 0,{replace:!0})))}catch(i){this.setState({error:String(i)})}}async selectDiff(t){this.setState({selectedDiffPath:t,selectedDiff:void 0,selectedStagedDiff:void 0,workspaceTool:"core:workspace.git",mainView:this.getState().mainView==="chat"?"chat":"core:workspace.git"}),ot(ki,"diff",t),this.updateUrl({replace:!0}),await this.refreshDiff(t)}async restoreDiff(t){this.setState({selectedDiffPath:t,selectedDiff:void 0,selectedStagedDiff:void 0}),await this.refreshDiff(t)}async refreshDiff(t){const s=this.getState().selectedProject,i=this.getState().selectedWorkspace;if(!(s===void 0||i===void 0))try{const[r,o]=await Promise.all([F.gitDiff(s.id,i.id,{path:t}),F.gitDiff(s.id,i.id,{path:t,staged:!0})]);this.setState({selectedDiff:r,selectedStagedDiff:o,error:""})}catch(r){this.setState({error:String(r)})}}updatePolling(){this.dispose();const t=this.getState();(t.workspaceTool==="core:workspace.git"||t.mainView==="core:workspace.git")&&(this.pollTimer=window.setInterval(()=>{this.refreshGit()},8e3))}}class Sa{constructor(t,s,i){this.getState=t,this.setState=s,this.workspaces=i}async loadProjects(){this.setState({error:"",isLoadingProjects:!0});try{const t=await F.projects(),s=new Set(t.map(r=>r.id)),i=Object.fromEntries(Object.entries(this.getState().workspacesByProjectId).filter(([r])=>s.has(r)));this.setState({projects:t,workspacesByProjectId:i})}catch(t){this.setState({error:String(t)})}finally{this.setState({isLoadingProjects:!1})}}async addProject(t,s){if(t.trim()!=="")try{const i=await F.addProject(t.trim(),void 0,s),r=this.getState().projects;this.setState({projects:[...r.filter(o=>o.id!==i.id),i],projectDialogOpen:!1}),await this.workspaces.selectProject(i)}catch(i){this.setState({error:String(i)})}}async closeProject(t){try{await F.closeProject(t),this.workspaces.forgetProject(t);const s=this.getState();this.setState({projects:s.projects.filter(i=>i.id!==t)}),s.selectedProject?.id===t&&this.workspaces.clearSelection()}catch(s){this.setState({error:String(s)})}}}const as="pi-web:cached-new-sessions:v1",$a="browserCachedNew";function at(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function Si(e,t=at()){if(e.messageCount!==0||e.archived===!0)return;const s=Ts(t).filter(i=>i.id!==e.id);Cs([ls(e),...s],t)}function ls(e){return{...e,browserCachedNew:!0}}function $i(e,t=at()){const s=Ts(t).filter(i=>i.id!==e);Cs(s,t)}function Pa(e,t,s=at()){const i=new Set(t.map(a=>a.id)),r=Ts(s),o=r.filter(a=>!i.has(a.id));return o.length!==r.length&&Cs(o,s),[...o.filter(a=>a.cwd===e),...t]}function ae(e){return e===void 0?!1:Aa(e)&&e.browserCachedNew===!0}function Ta(e){return{id:e.id,path:e.path,cwd:e.cwd,...e.name===void 0?{}:{name:e.name},created:e.created,modified:e.modified,messageCount:e.messageCount,firstMessage:e.firstMessage,...e.parentSessionPath===void 0?{}:{parentSessionPath:e.parentSessionPath},...e.archived===!0?{archived:!0}:{},...e.archivedAt===void 0?{}:{archivedAt:e.archivedAt}}}function Ts(e=at()){try{const t=e?.getItem(as);if(t==null||t==="")return[];const s=JSON.parse(t);return Array.isArray(s)?s.flatMap(i=>Ca(i)):[]}catch{return[]}}function Cs(e,t=at()){try{e.length===0?t?.removeItem(as):t?.setItem(as,JSON.stringify(e))}catch{}}function Ca(e){if(!Ia(e))return[];const t=_e(e,"id"),s=_e(e,"path"),i=_e(e,"cwd"),r=_e(e,"created"),o=_e(e,"modified"),n=_e(e,"firstMessage"),a=Ra(e,"messageCount");if(t===void 0||s===void 0||i===void 0||r===void 0||o===void 0||n===void 0||a!==0)return[];const l=Pi(e,"name"),d=Pi(e,"parentSessionPath");return[{id:t,path:s,cwd:i,...l===void 0?{}:{name:l},created:r,modified:o,messageCount:a,firstMessage:n,...d===void 0?{}:{parentSessionPath:d},browserCachedNew:!0}]}function Aa(e){return $a in e}function Ia(e){return typeof e=="object"&&e!==null}function _e(e,t){const s=e[t];return typeof s=="string"?s:void 0}function Pi(e,t){const s=e[t];return s===void 0||typeof s!="string"?void 0:s}function Ra(e,t){const s=e[t];return typeof s=="number"?s:void 0}function Ma(e){return Va(e.flatMap(As)).filter(t=>t.parts.length>0)}function oe(e,t){return{role:e,parts:[{type:"text",text:t}]}}function ut(e,t){const s=ja(t);return s===void 0?e:{...e,meta:s}}function Ea(e,t,s){if(s==="")return e;const i=e.at(-1),r=i?.parts.at(-1);return i?.role===t&&r?.type==="text"?[...e.slice(0,-1),{...i,parts:[...i.parts.slice(0,-1),{...r,text:r.text+s}]}]:i?.role===t?[...e.slice(0,-1),{...i,parts:[...i.parts,{type:"text",text:s}]}]:[...e,oe(t,s)]}function Da(e,t){if(t==="")return e;const s=e.at(-1),i=s?.parts.at(-1);return s?.role==="assistant"&&i?.type==="thinking"?[...e.slice(0,-1),{...s,parts:[...s.parts.slice(0,-1),{...i,text:i.text+t}]}]:s?.role==="assistant"?[...e.slice(0,-1),{...s,parts:[...s.parts,{type:"thinking",text:t}]}]:[...e,{role:"assistant",parts:[{type:"thinking",text:t}]}]}function As(e){if(_a(e))return[e];if(A(e,"role")==="bashExecution")return[ut(Ba(e),e)];const t=za(A(e,"role")),s=qa(Q(e,"content"),e),i=t==="user"?La(s):void 0;if(i!==void 0)return i.map(a=>ut(a,e));const r=Wa(e);if(t==="tool")return[ut({role:t,parts:s,...r===void 0?{}:{source:r}},e)];const o=s.filter(a=>a.type!=="empty"),n=t==="assistant"&&o.length>0&&o.every(a=>a.type==="skillRead")?"skill":t;return o.length>0?[ut({role:n,parts:o,...r===void 0?{}:{source:r}},e)]:[]}function _a(e){const t=A(e,"role");return(t==="user"||t==="assistant"||t==="tool"||t==="system"||t==="bash"||t==="skill")&&Array.isArray(Q(e,"parts"))}function La(e){if(e.length!==1||e[0]?.type!=="text")return;const t=Oa(e[0].text);if(t!==void 0)return[{role:"user",parts:[{type:"skillInvocation",name:t.name,location:t.location,content:t.content}]},...t.userMessage===void 0?[]:[{role:"user",parts:[{type:"text",text:t.userMessage}]}]]}function Oa(e){const t=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/.exec(e);if(t===null)return;const s=t[4]?.trim();return{name:t[1]??"skill",location:t[2]??"",content:t[3]??"",...s===void 0||s===""?{}:{userMessage:s}}}function Wa(e){const t=A(e,"source");if(t==="compaction"||t==="branch_summary")return t}function ja(e){const t=Na(Q(e,"timestamp")),s=Fa(e);if(!(t===void 0&&s===void 0))return{...t===void 0?{}:{timestamp:t},...s===void 0?{}:{model:s}}}function Na(e){if(typeof e=="number"&&Number.isFinite(e))return new Date(e).toISOString();if(typeof e!="string"||e==="")return;const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():void 0}function Fa(e){if(A(e,"role")!=="assistant")return;const t=A(e,"provider"),s=A(e,"model"),i=A(e,"responseModel");if(!((t===void 0||t==="")&&(s===void 0||s==="")&&(i===void 0||i==="")))return{...t===void 0||t===""?{}:{provider:t},...s===void 0||s===""?{}:{id:s},...i===void 0||i===""?{}:{responseId:i}}}function Ba(e){const t=A(e,"command")??"",s=yt(e,"excludeFromContext")===!0?["excluded from context","",`$ ${t}`]:[`$ ${t}`],i=Q(e,"output");i!=null&&s.push("",Tt(i));const r=Q(e,"exitCode");r!=null&&s.push("",`exit ${Tt(r)}`),yt(e,"cancelled")===!0&&s.push("","cancelled"),yt(e,"truncated")===!0&&s.push("","output truncated");const o=A(e,"fullOutputPath");return o!==void 0&&o!==""&&s.push("",`full output: ${o}`),{role:"bash",parts:[{type:"text",text:s.join(`
|
|
5
|
-
`)}]}}function za(e){return e==="assistant"?"assistant":e==="user"?"user":e==="toolResult"?"tool":"system"}function qa(e,t){return typeof e=="string"?e!==""?[{type:"text",text:e}]:[]:Array.isArray(e)?e.flatMap(s=>{const i=A(s,"type"),r=A(s,"text");if(i==="text")return r!==void 0&&r!==""?[{type:"text",text:r}]:[];if(i==="thinking"){const o=A(s,"thinking")??r;return o!==void 0&&o!==""?[{type:"thinking",text:o}]:[]}if(i==="toolCall"){const o=A(s,"name")??"tool",n=Q(s,"arguments"),a=o==="read"?Ua(A(n,"path")):void 0;if(a!==void 0)return[{type:"skillRead",...a}];const l=A(s,"id");return[{type:"toolCall",...l===void 0?{}:{toolCallId:l},toolName:o,summary:lt(n),...n===void 0?{}:{args:n}}]}return i==="image"?[{type:"text",text:"[image]"}]:Ti(s)}).map(s=>s.type==="text"&&A(t,"role")==="toolResult"?Ha(s.text,t):s):Ti(e)}function Ha(e,t){const s=A(t,"toolCallId"),i=Q(t,"content"),r=Q(t,"details");return{type:"toolResult",...s===void 0?{}:{toolCallId:s},toolName:A(t,"toolName")??"tool",text:e,...i===void 0?{}:{content:i},...r===void 0?{}:{details:r},isError:yt(t,"isError")===!0}}function Ua(e){if(e===void 0||e==="")return;const t=e.replace(/\\/g,"/");if(!t.endsWith("/SKILL.md")&&t!=="SKILL.md")return;const s=t.split("/").at(-2);if(!(s===void 0||s===""))return{name:s,path:e}}function Va(e){const t=[],s=new Map;for(const i of e){let r=[];const o={...i.source===void 0?{}:{source:i.source},...i.meta===void 0?{}:{meta:i.meta}},n=()=>{r.length!==0&&(t.push({role:i.role,parts:r,...o}),r=[])};for(const a of i.parts){if(a.type==="toolCall"){n();const l=Ga(a),d=t.length;t.push({role:"tool",parts:[l],...o}),l.toolCallId!==void 0&&s.set(l.toolCallId,{lineIndex:d,partIndex:0});continue}if(a.type==="toolResult"){const l=a.toolCallId===void 0?void 0:s.get(a.toolCallId);if(l!==void 0&&Ka(t,l,a)){s.delete(a.toolCallId??"");continue}}r.push(a)}n()}return t}function Ga(e){return{type:"toolExecution",...e.toolCallId===void 0?{}:{toolCallId:e.toolCallId},toolName:e.toolName,summary:e.summary,...e.args===void 0?{}:{args:e.args},status:"pending"}}function Ka(e,t,s){const i=e[t.lineIndex],r=i?.parts[t.partIndex];if(i===void 0||r?.type!=="toolExecution")return!1;const o=Pt(s.details)??r.preview,n={...r,status:s.isError?"error":"success",resultText:s.text,...s.content===void 0?{}:{content:s.content},...s.details===void 0?{}:{details:s.details},...o===void 0?{}:{preview:o}};return e[t.lineIndex]={...i,parts:[...i.parts.slice(0,t.partIndex),n,...i.parts.slice(t.partIndex+1)]},!0}function Pt(e){const t=Q(e,"preview");if(!Is(t))return;const s=A(t,"diff"),i=A(t,"error"),r=Ja(t,"firstChangedLine");if(!(s===void 0&&i===void 0&&r===void 0))return{...s===void 0?{}:{diff:s},...i===void 0?{}:{error:i},...r===void 0?{}:{firstChangedLine:r}}}function Ti(e){return e==null?[]:typeof e=="object"?[{type:"text",text:lt(e)}]:[{type:"text",text:Tt(e)}]}function lt(e){if(!Is(e))return Tt(e);const t=A(e,"command");if(t!==void 0)return t;const s=A(e,"path");if(s!==void 0)return s;if(typeof e.oldText=="string"&&typeof e.newText=="string")return"edit text replacement";const i=e.edits;return Array.isArray(i)?`${String(i.length)} edit${i.length===1?"":"s"}`:Object.entries(e).filter(([,o])=>o!=null).slice(0,3).map(([o,n])=>`${o}: ${Qa(n)}`).join(" · ")}function Qa(e){return typeof e=="string"?e.length>80?`${e.slice(0,77)}…`:e:typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?`${String(e.length)} item${e.length===1?"":"s"}`:typeof e=="object"&&e!==null?"object":""}function Is(e){return typeof e=="object"&&e!==null}function Q(e,t){return Is(e)?e[t]:void 0}function A(e,t){const s=Q(e,t);return typeof s=="string"?s:void 0}function yt(e,t){const s=Q(e,t);return typeof s=="boolean"?s:void 0}function Ja(e,t){const s=Q(e,t);return typeof s=="number"&&Number.isFinite(s)?s:void 0}function Tt(e){return e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):""}const Za="pi-web:prompt-draft:";function Ct(e){return`${Za}${e}`}function Ft(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function kr(e,t=Ft()){try{return t?.getItem(Ct(e))??""}catch{return""}}function At(e,t,s=Ft()){try{t?s?.setItem(Ct(e),t):s?.removeItem(Ct(e))}catch{}}function Rs(e,t=Ft()){try{t?.removeItem(Ct(e))}catch{}}function Xa(e,t,s=Ft()){const i=kr(e,s);i!==""&&(At(t,i,s),Rs(e,s))}function Ya(e,t){return oe("bash",`${t===!0?`excluded from context
|
|
6
|
-
|
|
7
|
-
`:""}$ ${e}`)}function el(e,t){const s=e.at(-1),i=s?.parts.at(-1);if(s?.role!=="bash"||i?.type!=="text")return[...e,oe("bash",t)];const r=sl(i.text)?"":`
|
|
8
|
-
|
|
9
|
-
`;return[...e.slice(0,-1),{...s,parts:[...s.parts.slice(0,-1),{...i,text:i.text+r+t}]}]}function tl(e,t){const s=e.at(-1),i=s?.parts.at(-1);if(s?.role!=="bash"||i?.type!=="text")return e;const r=[];return!i.text.includes(`
|
|
10
|
-
|
|
11
|
-
`)&&(t.output===void 0||t.output==="")&&r.push("(no output)"),t.isError===!0&&r.push(t.output??"Bash command failed"),t.exitCode!=null&&r.push(`exit ${String(t.exitCode)}`),t.cancelled===!0&&r.push("cancelled"),t.truncated===!0&&r.push("output truncated"),t.fullOutputPath!==void 0&&t.fullOutputPath!==""&&r.push(`full output: ${t.fullOutputPath}`),r.length===0?e:[...e.slice(0,-1),{...s,parts:[...s.parts.slice(0,-1),{...i,text:`${i.text}
|
|
12
|
-
|
|
13
|
-
${r.join(`
|
|
14
|
-
`)}`}]}]}function sl(e){const t=e.lastIndexOf(`
|
|
15
|
-
|
|
16
|
-
`),s=e.lastIndexOf("$ ");return t>s}function il(e,t){if(t.type==="message.append")return ul(e,t.message);if(t.type==="assistant.delta")return Ea(e,"assistant",t.text);if(t.type==="assistant.thinking.delta")return Da(e,t.text);if(t.type==="tool.start")return al(e,t);if(t.type==="tool.update")return $r(e,t.toolCallId,s=>ll(s,t));if(t.type==="tool.end")return Sr(e,t.toolCallId,t.toolName,lt(t.content),t.text,t.isError,t.content,t.details);if(t.type==="shell.start")return[...e,Ya(t.command,t.excludeFromContext)];if(t.type==="shell.chunk")return el(e,t.chunk);if(t.type==="shell.end")return tl(e,t);if(t.type==="command.output")return[...e,oe(t.level==="error"?"system":"tool",t.message)];if(t.type==="session.error")return[...e,oe("system",t.message)];if(t.type==="message.end")return t.message===void 0?void 0:rl(e,t.message)}function rl(e,t){const s=cl(t);if(s!==void 0)return Sr(e,s.toolCallId,s.toolName,lt(s.content),s.text,s.isError,s.content,s.details);const i=As(t)[0];if(i===void 0)return;const r=i.role==="assistant"?ol(i):i;if(r.parts.length===0)return e;const o=dl(e,r);if(o>=0)return[...e.slice(0,o),r,...e.slice(o+1)];const n=e.at(-1);return n?.role!==r.role?[...e,r]:r.role==="assistant"||hl(n,r)?[...e.slice(0,-1),r]:[...e,r]}function ol(e){return{...e,parts:e.parts.filter(t=>t.type!=="toolCall")}}function nl(e){if(e===void 0||e==="")return;const t=e.replace(/\\/g,"/");if(!t.endsWith("/SKILL.md")&&t!=="SKILL.md")return;const s=t.split("/").at(-2);if(!(s===void 0||s===""))return{name:s,path:e}}function al(e,t){const s=t.toolName==="read"?nl($e(t.args,"path")):void 0;if(s!==void 0)return fl(e,{role:"skill",parts:[{type:"skillRead",...s}]});const i={type:"toolExecution",...t.toolCallId===""?{}:{toolCallId:t.toolCallId},toolName:t.toolName,summary:t.summary||lt(t.args),...t.args===void 0?{}:{args:t.args},status:"running"};return[...e,{role:"tool",parts:[i]}]}function ll(e,t){const s=Pt(t.details)??e.preview;return{...e,status:e.status==="pending"?"running":e.status,...t.text===""?{}:{resultText:t.text},...t.content===void 0?{}:{content:t.content},...t.details===void 0?{}:{details:t.details},...s===void 0?{}:{preview:s}}}function Sr(e,t,s,i,r,o,n,a){const l=$r(e,t,h=>{const f=Pt(a)??h.preview;return{...h,status:o?"error":"success",resultText:r,...n===void 0?{}:{content:n},...a===void 0?{}:{details:a},...f===void 0?{}:{preview:f}}});if(l!==e)return l;const d=Pt(a),u={type:"toolExecution",...t===void 0||t===""?{}:{toolCallId:t},toolName:s,summary:i,status:o?"error":"success",resultText:r,...n===void 0?{}:{content:n},...a===void 0?{}:{details:a},...d===void 0?{}:{preview:d}};return[...e,{role:"tool",parts:[u]}]}function $r(e,t,s){if(t===void 0||t==="")return e;for(let i=e.length-1;i>=0;i--){const r=e[i];if(r===void 0)continue;const o=r.parts.findIndex(l=>l.type==="toolExecution"&&l.toolCallId===t);if(o<0)continue;const n=r.parts[o];if(n?.type!=="toolExecution")continue;const a={...r,parts:[...r.parts.slice(0,o),s(n),...r.parts.slice(o+1)]};return[...e.slice(0,i),a,...e.slice(i+1)]}return e}function cl(e){if($e(e,"role")!=="toolResult")return;const t=$e(e,"toolCallId"),s=Rt(e,"content");return{...t===void 0?{}:{toolCallId:t},toolName:$e(e,"toolName")??"tool",text:Pr(s),isError:gl(e,"isError")===!0,content:s,details:Rt(e,"details")}}function Pr(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(Pr).filter(t=>t!=="").join(`
|
|
17
|
-
`);if(typeof e=="object"&&e!==null){const t=$e(e,"text")??$e(e,"content")??$e(e,"output");if(t!==void 0)return t}return""}function dl(e,t){const s=It(t);if(s.length===0)return-1;for(let i=e.length-1;i>=0;i--){const r=e[i];if(r?.role!=="skill")continue;const o=It(r);if(Tr(o,s))return i}return-1}function It(e){return e===void 0?[]:e.parts.filter(t=>t.type==="skillRead")}function Tr(e,t){return e.length===t.length&&e.every((s,i)=>pl(s,t[i]))}function pl(e,t){return t===void 0?!1:Ci(e.path)===Ci(t.path)||e.name===t.name}function Ci(e){return e.replace(/\\/g,"/")}function hl(e,t){return Ai(e)===Ai(t)}function Ai(e){return e.parts.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
18
|
-
|
|
19
|
-
`)}function ul(e,t){const s=As(t);return s.length===0?e:[...e,...s]}function fl(e,t){const s=e.at(-1);return t.role==="skill"&&Tr(It(s),It(t))?e:s?.role===t.role&&t.role!=="skill"?[...e.slice(0,-1),{...s,parts:[...s.parts,...t.parts]}]:[...e,t]}function ml(e){return typeof e=="object"&&e!==null}function Rt(e,t){return ml(e)?e[t]:void 0}function $e(e,t){const s=Rt(e,t);return typeof s=="string"?s:void 0}function gl(e,t){const s=Rt(e,t);return typeof s=="boolean"?s:void 0}const vl="pi-web:chat-history:v2:",bl=1800*1e3;function wl(e){try{const t=sessionStorage.getItem(cs(e));if(t===null||t==="")return;const s=JSON.parse(t);if(!$l(s))return;if(Date.now()-s.savedAt>bl){sessionStorage.removeItem(cs(e));return}return{messages:s.messages,start:s.start,total:s.total}}catch{return}}function yl(e,t){try{sessionStorage.setItem(cs(e),JSON.stringify({...t,savedAt:Date.now()}))}catch{}}function xl(e,t){if(e===void 0||!ds(e))return t;if(!ds(t))return e;if(kl(e,t))return t;const s=Math.min(e.start,t.start),i=Math.max(e.start+e.messages.length,t.start+t.messages.length),r=new Array(i-s);return Ii(r,s,e),Ii(r,s,t),Sl(r)?t:{start:s,total:Math.max(e.total,t.total),messages:r}}function kl(e,t){return e.total>t.total&&e.start===0&&t.start===0&&t.messages.length===t.total}function Sl(e){for(let t=0;t<e.length;t+=1)if(!(t in e)||e[t]===void 0)return!0;return!1}function Ii(e,t,s){s.messages.forEach((i,r)=>{e[s.start-t+r]=i})}function cs(e){return`${vl}${e}`}function $l(e){if(typeof e!="object"||e===null||!("messages"in e)||!("start"in e)||!("total"in e)||!("savedAt"in e))return!1;const{messages:t,start:s,total:i,savedAt:r}=e;return Array.isArray(t)&&typeof s=="number"&&typeof i=="number"&&typeof r=="number"&&ds({messages:t,start:s,total:i})}function ds(e){return Number.isInteger(e.start)&&Number.isInteger(e.total)&&e.start>=0&&e.total>=e.start&&e.messages.length<=e.total-e.start&&!e.messages.some(Pl)}function Pl(e){return typeof e=="object"&&e!==null&&"role"in e&&"parts"in e&&!("content"in e)&&typeof e.role=="string"&&Array.isArray(e.parts)}const Tl={read:wl,write:yl};class Cl{constructor(t=Tl){this.cache=t,this.rawHistoryPages=new Map}cachedView(t){return Ri(this.rawHistoryPage(t))}mergeHistory(t,s){const i=xl(this.rawHistoryPage(t),s);return this.rawHistoryPages.set(t,i),this.cache.write(t,i),Ri(i)}applyLiveEvent(t,s){return il(t,s)}rawHistoryPage(t){const s=this.rawHistoryPages.get(t)??this.cache.read(t);return s!==void 0&&this.rawHistoryPages.set(t,s),s}}function Ri(e){const t=e?.start??0;return{messages:Ma(e?.messages??[]),messagePageStart:t,messagePageEnd:t+(e?.messages.length??0),messagePageTotal:e?.total??0}}function Ms(e){const t=e.trimStart();return t.startsWith("!@")?{kind:"file"}:t.startsWith("!")?{kind:"shell",excludeFromContext:t.startsWith("!!")}:Cr(e).startsWith("/")?{kind:"command"}:Il(e)?{kind:"file"}:{kind:"normal"}}function Al(e){return Ms(e).kind==="shell"}function Cr(e){const t=Math.max(e.lastIndexOf(" "),e.lastIndexOf(`
|
|
20
|
-
`))+1;return e.slice(t)}function Il(e){const t=Cr(e);if(t.startsWith("@")||t.startsWith("!@"))return!0;const s=e.length-t.length;if(e.slice(0,s).endsWith("@ "))return!0;const i=e.lastIndexOf('"');if(i===-1)return!1;const r=e.slice(0,i);return r.endsWith("@")||r.endsWith("@ ")||r.endsWith("!@")}class Rl{constructor(){this.reconnectDelay=500,this.shouldReconnect=!1,this.hasOpened=!1}connect(t,s,i){this.close(),this.sessionId=t,this.onEvent=s,this.onReconnect=i,this.shouldReconnect=!0,this.open()}setHandler(t){this.onEvent=t}close(){this.shouldReconnect=!1,window.clearTimeout(this.reconnectTimer),Ir(this.socket),this.socket=void 0,this.sessionId=void 0,this.onEvent=void 0,this.onReconnect=void 0,this.hasOpened=!1}open(){if(this.sessionId===void 0||this.sessionId===""||!this.shouldReconnect)return;const t=ca(this.sessionId);this.socket=t,t.onopen=()=>{this.reconnectDelay=500,this.hasOpened&&this.onReconnect?.(),this.hasOpened=!0},t.onmessage=s=>{this.handleMessage(s.data)},t.onerror=()=>{t.close()},t.onclose=()=>{this.socket===t&&(this.socket=void 0),this.scheduleReconnect()}}scheduleReconnect(){if(!this.shouldReconnect)return;window.clearTimeout(this.reconnectTimer);const t=this.reconnectDelay;this.reconnectDelay=Math.min(this.reconnectDelay*1.6,5e3),this.reconnectTimer=window.setTimeout(()=>{this.open()},t)}async handleMessage(t){const s=await Ar(t);El(s)&&this.onEvent?.(s)}}class Ml{constructor(){this.reconnectDelay=500,this.shouldReconnect=!1}connect(t,s){this.close(),this.onEvent=t,this.onOpen=s,this.shouldReconnect=!0,this.open()}close(){this.shouldReconnect=!1,window.clearTimeout(this.reconnectTimer),Ir(this.socket),this.socket=void 0,this.onEvent=void 0,this.onOpen=void 0}open(){if(!this.shouldReconnect)return;const t=da();this.socket=t,t.onopen=()=>{this.reconnectDelay=500,this.onOpen?.()},t.onmessage=s=>{this.handleMessage(s.data)},t.onerror=()=>{t.close()},t.onclose=()=>{this.socket===t&&(this.socket=void 0),this.scheduleReconnect()}}scheduleReconnect(){if(!this.shouldReconnect)return;window.clearTimeout(this.reconnectTimer);const t=this.reconnectDelay;this.reconnectDelay=Math.min(this.reconnectDelay*1.6,5e3),this.reconnectTimer=window.setTimeout(()=>{this.open()},t)}async handleMessage(t){const s=await Ar(t);_l(s)&&this.onEvent?.(s)}}function El(e){const t=Es(e);return["message.append","assistant.delta","assistant.thinking.delta","tool.start","tool.update","tool.end","shell.start","shell.chunk","shell.end","agent.start","agent.end","message.end","status.update","activity.update","command.output","session.error","session.name","pi.event"].includes(t)}function Dl(e){const t=Es(e);return t==="status.update"||t==="activity.update"||t==="session.name"}function _l(e){const t=Es(e);return Dl(e)||t==="terminal.created"||t==="terminal.exited"||t==="terminal.closed"||t==="workspace.activity"}function Es(e){if(typeof e!="object"||e===null||!("type"in e))return"";const t=e.type;return typeof t=="string"?t:""}async function Ar(e){try{return typeof e=="string"?JSON.parse(e):e instanceof Blob?JSON.parse(await e.text()):e instanceof ArrayBuffer?JSON.parse(new TextDecoder().decode(e)):void 0}catch{return}}function Ir(e){if(e!==void 0){if(e.onmessage=null,e.onerror=null,e.onclose=null,e.readyState===WebSocket.CONNECTING){e.onopen=()=>{e.close()};return}e.close()}}class Ll{constructor(){this.sessionIdsByCwd=new Map}latestSessionId(t){return this.sessionIdsByCwd.get(t)}rememberSession(t){this.sessionIdsByCwd.set(t.cwd,t.id)}forgetWorkspace(t){this.sessionIdsByCwd.delete(t)}}function Ol(e,t){const s=t?.targetSessionId;if(s!==void 0&&s!=="")return jl(e,s);const i=t?.latestSessionId;return i!==void 0&&i!==""?e.find(r=>r.id===i)??e.find(r=>r.archived!==!0):e.find(r=>r.archived!==!0)}function Wl(e,t){return t?.archived!==!0?!1:!e.some(s=>s.archived!==!0)}function jl(e,t){return e.find(s=>s.id===t||s.id.startsWith(t))}function Nl(e,t,s){return Rr(e,[t],s)}function Rr(e,t,s){const i=new Set(t);return e.map(r=>i.has(r.id)?{...r,archived:!0,archivedAt:s}:r)}function Fl(e,t,s){return Mr(e,t,[s])}function Mr(e,t,s){if(t===void 0||!s.includes(t))return{type:"unchanged"};const i=new Set(s),r=e.find(o=>!i.has(o.id)&&o.archived!==!0);return r===void 0?{type:"clear"}:{type:"select",session:r}}const Ke=100;class Bl{constructor(t,s,i,r=new Ll,o={}){this.getState=t,this.setState=s,this.updateUrl=i,this.sessionSelection=r,this.selectionSeq=0,this.pendingTranscriptEvents=[],this.socket=o.socket??new Rl,this.api=o.api??F,this.transcripts=o.transcripts??new Cl}applyGlobalEvent(t){t.type==="status.update"?this.applyStatus(t.status):t.type==="activity.update"?this.applyActivity(t.activity):this.applySessionName(t.sessionId,t.name)}dispose(){this.socket.close(),this.clearPendingTranscriptEvents()}clearActiveSession(){this.selectionSeq+=1,this.socket.close(),this.catchupStreamSessionId=void 0,this.clearPendingTranscriptEvents(),this.setState({selectedSession:void 0,messages:[],messagePageStart:0,messagePageEnd:0,messagePageTotal:0,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,status:void 0,activity:void 0})}deselectSession(t){const s=this.getState(),i=s.selectedSession?.cwd??s.selectedWorkspace?.path;t?.forgetRememberedSelection===!0&&i!==void 0&&this.sessionSelection.forgetWorkspace(i),this.clearActiveSession(),t?.updateUrl!==!1&&this.updateUrl()}clearSelectionAfterArchivedCollapse(){const t=this.getState();Wl(t.sessions,t.selectedSession)&&this.deselectSession({forgetRememberedSelection:!0})}async startSession(){const t=this.getState().selectedWorkspace;if(t)try{const s=await this.api.startSession(t.path);Si(s);const i=ls(s);this.setState({sessions:[i,...this.getState().sessions]}),await this.selectSession(i)}catch(s){this.setState({error:String(s)})}}preferredSession(t,s,i){return Ol(s,{targetSessionId:i,latestSessionId:this.sessionSelection.latestSessionId(t)})}async selectSession(t,s){this.sessionSelection.rememberSession(t);const i=++this.selectionSeq;this.socket.close(),this.catchupStreamSessionId=void 0,this.clearPendingTranscriptEvents();const r=this.transcripts.cachedView(t.id);this.setState({selectedSession:t,...r,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,status:t.archived===!0?void 0:this.getState().sessionStatuses[t.id],activity:t.archived===!0?void 0:this.getState().sessionActivities[t.id]});try{if(t.archived===!0){const u=await this.api.messages(t.id,{limit:Ke});if(i!==this.selectionSeq||this.getState().selectedSession?.id!==t.id)return;const h=this.transcripts.mergeHistory(t.id,u);this.setState({...h,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,status:void 0,activity:void 0}),s?.updateUrl!==!1&&this.updateUrl();return}const o=[];this.socket.connect(t.id,u=>o.push(u),()=>{this.refreshSelectedSession(t.id)});const[n,a]=await Promise.all([this.api.messages(t.id,{limit:Ke}),this.api.status(t.id)]);if(i!==this.selectionSeq||this.getState().selectedSession?.id!==t.id)return;const l=this.transcripts.mergeHistory(t.id,n),d=a.isStreaming;this.catchupStreamSessionId=d?t.id:void 0,this.setState({...l,isLoadingEarlierMessages:!1,isReceivingPartialStream:d,status:a,activity:this.getState().sessionActivities[t.id]}),this.applyStatus(a);for(const u of o)this.applyEvent(u);this.socket.setHandler(u=>{this.applyEvent(u)}),s?.updateUrl!==!1&&this.updateUrl()}catch(o){if(i!==this.selectionSeq||this.getState().selectedSession?.id!==t.id)return;if(ae(t)&&Vl(o)){await this.recreateCachedNewSession(t,s);return}this.setState({error:String(o)})}}async loadEarlierMessages(){const t=this.getState(),s=t.selectedSession;if(!(!s||t.isLoadingEarlierMessages||t.messagePageStart<=0)){this.setState({isLoadingEarlierMessages:!0});try{const i=await this.api.messages(s.id,{before:t.messagePageStart,limit:Ke});if(this.getState().selectedSession?.id!==s.id)return;const r=this.transcripts.mergeHistory(s.id,i);this.setState(r)}catch(i){this.setState({error:String(i)})}finally{this.getState().selectedSession?.id===s.id&&this.setState({isLoadingEarlierMessages:!1})}}}async send(t,s){if(t.trim().startsWith("/"))return this.runCommand(t);if(Al(t))return this.runShell(t);const r=this.getState().selectedSession;if(!(!r||r.archived===!0))try{await this.api.prompt(r.id,t,s),this.markCachedNewSessionPersisted(r)}catch(o){this.setState({error:String(o)})}}async runShell(t){const s=this.getState().selectedSession;if(!(!s||s.archived===!0)){this.setState({messages:[...this.getState().messages,oe("user",t)]});try{await this.api.shell(s.id,t),this.markCachedNewSessionPersisted(s)}catch(i){this.setState({messages:[...this.getState().messages,oe("system",String(i))],error:String(i)})}}}async runCommand(t){const s=this.getState().selectedSession;if(!(!s||s.archived===!0)){this.setState({messages:[...this.getState().messages,oe("user",t)]});try{this.applyCommandResult(await this.api.runCommand(s.id,t)),this.markCachedNewSessionPersisted(s)}catch(i){this.setState({messages:[...this.getState().messages,oe("system",String(i))],error:String(i)})}}}async respondToCommand(t,s){const i=this.getState().selectedSession;if(i){this.setState({commandDialog:void 0});try{this.applyCommandResult(await this.api.respondToCommand(i.id,t,s))}catch(r){this.setState({error:String(r)})}}}cancelCommand(){this.setState({commandDialog:void 0})}applySessionStatus(t){this.applyStatus(t)}async archiveSession(t=this.getState().selectedSession){if(t){if(ae(t)){await this.deleteCachedNewSession(t);return}try{await this.api.archive(t.id);const s=this.getState(),i=Nl(s.sessions,t.id,new Date().toISOString()),r=Fl(i,s.selectedSession?.id,t.id);this.setState({sessions:i}),r.type==="select"?await this.selectSession(r.session):r.type==="clear"&&this.deselectSession({forgetRememberedSelection:!0})}catch(s){this.setState({error:String(s)})}}}async archiveSessionWithDescendants(t=this.getState().selectedSession){if(!(!t||ae(t)))try{const s=await this.api.archiveWithDescendants(t.id),i=s.sessionIds!==void 0&&s.sessionIds.length>0?s.sessionIds:[t.id],r=this.getState(),o=Rr(r.sessions,i,new Date().toISOString()),n=Mr(o,r.selectedSession?.id,i);this.setState({sessions:o}),n.type==="select"?await this.selectSession(n.session):n.type==="clear"&&this.deselectSession({forgetRememberedSelection:!0})}catch(s){this.setState({error:String(s)})}}async deleteCachedNewSession(t=this.getState().selectedSession){if(!ae(t))return;this.api.stop(t.id).catch(()=>{}),$i(t.id),Rs(t.id);const s=this.getState().sessions.filter(r=>r.id!==t.id);if(this.setState({sessions:s}),this.getState().selectedSession?.id!==t.id)return;const i=s.find(r=>r.archived!==!0)??s[0];i!==void 0?await this.selectSession(i):(this.clearActiveSession(),this.updateUrl())}async restoreSession(t=this.getState().selectedSession){if(t)try{await this.api.restore(t.id);const s={...t};delete s.archived,delete s.archivedAt,this.replaceSession(s),this.getState().selectedSession?.id===s.id&&await this.selectSession(s)}catch(s){this.setState({error:String(s)})}}async detachParent(t=this.getState().selectedSession){if(t?.parentSessionPath!==void 0)try{await this.api.detachParent(t.id);const s={...t};delete s.parentSessionPath,this.replaceSession(s)}catch(s){this.setState({error:String(s)})}}async listModels(){const t=this.getState().selectedSession;if(!t||t.archived===!0)return[];try{return(await this.api.models(t.id)).models}catch(s){return this.setState({error:String(s)}),[]}}async setModel(t,s){const i=this.getState().selectedSession;if(!(!i||i.archived===!0))try{this.applyStatus(await this.api.setModel(i.id,t,s))}catch(r){this.setState({error:String(r)})}}async cycleModel(t){const s=this.getState().selectedSession;if(!(!s||s.archived===!0))try{this.applyStatus(await this.api.cycleModel(s.id,t))}catch(i){this.setState({error:String(i)})}}async listThinkingLevels(){const t=this.getState().selectedSession;if(!t||t.archived===!0)return[];try{return(await this.api.thinkingLevels(t.id)).levels}catch(s){return this.setState({error:String(s)}),[]}}async setThinkingLevel(t){const s=this.getState().selectedSession;if(!(!s||s.archived===!0))try{this.applyStatus(await this.api.setThinkingLevel(s.id,t))}catch(i){this.setState({error:String(i)})}}async cycleThinkingLevel(){const t=this.getState().selectedSession;if(!(!t||t.archived===!0))try{this.applyStatus(await this.api.cycleThinkingLevel(t.id))}catch(s){this.setState({error:String(s)})}}async stopActiveWork(){const t=this.getState().selectedSession;if(t)try{await this.api.abort(t.id)}catch(s){this.setState({error:String(s)})}}async refreshSelectedSession(t=this.getState().selectedSession?.id){const s=this.getState().selectedSession;if(!(t===void 0||s?.id!==t||s.archived===!0))try{this.flushPendingTranscriptEvents();const[i,r]=await Promise.all([this.api.messages(t,{limit:Ke}),this.api.status(t)]);if(this.getState().selectedSession?.id!==t)return;const o=this.transcripts.mergeHistory(t,i);this.setState({...o,status:r,activity:this.getState().sessionActivities[t],isReceivingPartialStream:r.isStreaming}),this.applyStatus(r)}catch(i){this.getState().selectedSession?.id===t&&this.setState({error:String(i)})}}replaceSession(t){const s=this.getState().selectedSession;this.setState({sessions:this.getState().sessions.map(i=>i.id===t.id?t:i),selectedSession:s?.id===t.id?t:s})}async recreateCachedNewSession(t,s){try{const i=await this.api.startSession(t.cwd);Si(i),Xa(t.id,i.id),$i(t.id);const r=ls(i);this.setState({sessions:[r,...this.getState().sessions.filter(o=>o.id!==t.id)],error:""}),await this.selectSession(r,{updateUrl:!1}),this.updateUrl(s?.updateUrl===!1?{replace:!0}:void 0)}catch(i){this.setState({error:String(i)})}}markCachedNewSessionPersisted(t){if(!ae(t))return;const s=this.getState().sessions.find(i=>i.id===t.id)??t;this.replaceSession(Ta(s))}applyCommandResult(t){if(t.type==="select"){this.setState({commandDialog:t});return}const s=(t.type==="unsupported",t.message);if(s!==void 0&&s!==""&&this.setState({messages:[...this.getState().messages,oe(t.type==="unsupported"?"system":"tool",s)]}),t.type==="done"&&t.session){t.promptDraft!==void 0&&At(t.session.id,t.promptDraft);const i=this.getState().selectedSession,r=[t.session,...this.getState().sessions.filter(o=>o.id!==t.session?.id)];this.setState({sessions:r,selectedSession:i?.id===t.session.id?t.session:i}),i?.id!==t.session.id&&this.selectSession(t.session)}}applyActivity(t){this.setState({sessionActivities:{...this.getState().sessionActivities,[t.sessionId]:t},activity:this.getState().selectedSession?.id===t.sessionId?t:this.getState().activity})}applyStatus(t){const s=this.getState(),i=s.sessionActivities[t.sessionId]?.phase==="active"&&!Nt(t);this.setState({sessionStatuses:{...s.sessionStatuses,[t.sessionId]:t},...ql(s,t.sessionId,t.messageCount),...i?{sessionActivities:zl(s.sessionActivities,t.sessionId)}:{},status:s.selectedSession?.id===t.sessionId?t:s.status,activity:s.selectedSession?.id===t.sessionId&&i?void 0:s.activity}),this.catchupStreamSessionId===t.sessionId&&!t.isStreaming&&this.finishStreamCatchup(t.sessionId)}applySessionName(t,s){const i=o=>{if(o.id!==t)return o;const n={...o};return s===void 0||s===""?delete n.name:n.name=s,n},r=this.getState().selectedSession;this.setState({sessions:this.getState().sessions.map(i),selectedSession:r===void 0?void 0:i(r)})}applyEvent(t){const s=this.getState().selectedSession?.id;if(this.catchupStreamSessionId!==void 0&&this.catchupStreamSessionId===s){if(t.type==="message.end"||t.type==="agent.end"){this.finishStreamCatchup(this.catchupStreamSessionId);return}if(Hl(t))return}if(Ul(t)){this.queueTranscriptEvent(t);return}this.flushPendingTranscriptEvents();const i=this.transcripts.applyLiveEvent(this.getState().messages,t);i?this.setState({messages:i}):t.type==="status.update"?this.applyStatus(t.status):t.type==="activity.update"?this.applyActivity(t.activity):t.type==="session.name"&&this.applySessionName(t.sessionId,t.name)}queueTranscriptEvent(t){this.pendingTranscriptEvents.push(t),this.pendingTranscriptFrame===void 0&&(this.pendingTranscriptFrame=requestAnimationFrame(()=>{this.pendingTranscriptFrame=void 0,this.flushPendingTranscriptEvents()}))}flushPendingTranscriptEvents(){if(this.pendingTranscriptEvents.length===0)return;const t=this.pendingTranscriptEvents;this.pendingTranscriptEvents=[];let s=this.getState().messages;for(const i of t)s=this.transcripts.applyLiveEvent(s,i)??s;s!==this.getState().messages&&this.setState({messages:s})}clearPendingTranscriptEvents(){this.pendingTranscriptEvents=[],this.pendingTranscriptFrame!==void 0&&(cancelAnimationFrame(this.pendingTranscriptFrame),this.pendingTranscriptFrame=void 0)}finishStreamCatchup(t){this.catchupStreamSessionId===t&&(this.catchupStreamSessionId=void 0,this.getState().selectedSession?.id===t&&this.setState({isReceivingPartialStream:!1}),this.refreshMessages(t))}async refreshMessages(t){try{const s=await this.api.messages(t,{limit:Ke});if(this.getState().selectedSession?.id!==t)return;this.setState(this.transcripts.mergeHistory(t,s))}catch(s){this.getState().selectedSession?.id===t&&this.setState({error:String(s)})}}}function zl(e,t){return Object.fromEntries(Object.entries(e).filter(([s])=>s!==t))}function ql(e,t,s){if(s===void 0)return{};const r=e.sessions.some(n=>n.id===t&&n.messageCount!==s)?e.sessions.map(n=>n.id===t?{...n,messageCount:s}:n):void 0,o=e.selectedSession?.id===t&&e.selectedSession.messageCount!==s?{...e.selectedSession,messageCount:s}:e.selectedSession;return{...r===void 0?{}:{sessions:r},...o!==e.selectedSession?{selectedSession:o}:{}}}function Hl(e){return["message.append","assistant.delta","assistant.thinking.delta","tool.start","tool.update","tool.end","shell.start","shell.chunk","shell.end","command.output","session.error"].includes(e.type)}function Ul(e){return e.type==="assistant.delta"||e.type==="assistant.thinking.delta"||e.type==="shell.chunk"}function Vl(e){return e instanceof Error&&e.message.toLowerCase().includes("session not found")}class Gl{constructor(){this.workspaceIdsByProject=new Map}latestWorkspaceId(t){return this.workspaceIdsByProject.get(t)}rememberWorkspace(t){this.workspaceIdsByProject.set(t.projectId,t.id)}forgetProject(t){this.workspaceIdsByProject.delete(t)}}function Kl(e,t){const s=t?.targetWorkspaceId;if(s!==void 0&&s!=="")return e.find(r=>r.id===s);const i=t?.latestWorkspaceId;return i!==void 0&&i!==""?e.find(r=>r.id===i)??e[0]:e[0]}class Ql{constructor(t,s,i,r,o=new Gl,n={}){this.getState=t,this.setState=s,this.updateUrl=i,this.sessions=r,this.workspaceSelection=o,this.api=n.api??F}clearSelection(t){this.sessions.clearActiveSession(),this.setState({selectedProject:void 0,selectedWorkspace:void 0,workspaces:[],isLoadingWorkspaces:!1,...Jt()}),t?.updateUrl!==!1&&this.updateUrl()}forgetProject(t){this.workspaceSelection.forgetProject(t);const s=Object.fromEntries(Object.entries(this.getState().workspacesByProjectId).filter(([i])=>i!==t));this.setState({workspacesByProjectId:s})}async selectProject(t,s){this.sessions.clearActiveSession(),this.setState({selectedProject:t,selectedWorkspace:void 0,workspaces:[],isLoadingWorkspaces:!0,...Jt()});try{const i=await this.api.workspaces(t.id);this.setState({workspaces:i,workspacesByProjectId:{...this.getState().workspacesByProjectId,[t.id]:i},isLoadingWorkspaces:!1});const r=Kl(i,{targetWorkspaceId:s?.workspaceId,latestWorkspaceId:this.workspaceSelection.latestWorkspaceId(t.id)});r?await this.selectWorkspace(r,{sessionId:s?.sessionId,updateUrl:s?.updateUrl}):s?.updateUrl!==!1&&this.updateUrl()}catch(i){this.setState({error:String(i),isLoadingWorkspaces:!1})}}async selectWorkspace(t,s){this.workspaceSelection.rememberWorkspace(t),this.sessions.clearActiveSession(),this.setState({selectedWorkspace:t,isLoadingWorkspaces:!1,...Jt()});try{const i=Pa(t.path,await this.api.sessions(t.path));this.setState({sessions:i});const r=this.sessions.preferredSession(t.path,i,s?.sessionId);r?await this.sessions.selectSession(r,{updateUrl:s?.updateUrl}):s?.updateUrl!==!1&&this.updateUrl()}catch(i){this.setState({error:String(i)})}}async refreshProjectWorkspaces(t){const s=this.getState().projects.find(r=>r.id===t);if(s===void 0)throw new Error("Project not found");const i=await this.api.workspaces(s.id);return this.applyProjectWorkspaces(s.id,i),i}async refreshAfterWorkspaceDeleted(t,s){const i=await this.refreshProjectWorkspaces(t),r=this.getState();if(r.selectedProject?.id!==t||r.selectedWorkspace?.id!==s)return;const o=Zl(i);o!==void 0?await this.selectWorkspace(o):this.clearSelection()}applyProjectWorkspaces(t,s){const i=this.getState(),r={...i.workspacesByProjectId,[t]:s};i.selectedProject?.id===t?this.setState({workspaces:s,workspacesByProjectId:r}):this.setState({workspacesByProjectId:r})}}function Jl(e){return e!==void 0&&e.isGitWorktree&&!e.isMain}function Zl(e){return e.find(t=>t.isMain)??e[0]}class Xl{constructor(){this.terminalIdsByCwd=new Map}latestTerminalId(t){return this.terminalIdsByCwd.get(t)}rememberTerminal(t,s){this.terminalIdsByCwd.set(t,s)}forgetWorkspace(t){this.terminalIdsByCwd.delete(t)}forgetTerminal(t){for(const[s,i]of this.terminalIdsByCwd.entries())i===t&&this.terminalIdsByCwd.delete(s)}}function df(e,t){const s=t?.targetTerminalId;if(s!==void 0&&s!=="")return e.find(r=>r.id===s);const i=t?.latestTerminalId;return i!==void 0&&i!==""?e.find(r=>r.id===i)??e.find(r=>!r.exited)??e[0]:e.find(r=>!r.exited)??e[0]}function pf(e){return e.find(t=>!t.exited)??e[0]}const Yl=1200;class ec{constructor(){this.pendingTokens=[]}handle(t,s){const i=sc(t);if(i===void 0||!Mi(i))return!1;const r=s.filter(l=>l.shortcut!==void 0&&l.enabled!==!1).map(l=>({action:l,tokens:Er(l.shortcut??"")})).filter(l=>l.tokens.length>0),o=this.pendingTokens.length>0&&!Mi(i)?[...this.pendingTokens,i]:[i],n=r.find(l=>rc(l.tokens,o));return n!==void 0?(this.clearPending(),n.action.run(),!0):r.some(l=>Dr(l.tokens,o))?(this.setPending(o),!0):(this.clearPending(),!1)}reset(){this.clearPending()}setPending(t){this.clearPending(),this.pendingTokens=t,this.pendingTimer=window.setTimeout(()=>{this.pendingTokens=[],this.pendingTimer=void 0},Yl)}clearPending(){this.pendingTokens=[],this.pendingTimer!==void 0&&(window.clearTimeout(this.pendingTimer),this.pendingTimer=void 0)}}function tc(e){return Er(e).map(t=>t.split("+").map(s=>s==="mod"?Ei()?"⌘":"Ctrl":s==="shift"?"Shift":s==="alt"?Ei()?"⌥":"Alt":s==="ctrl"?"Ctrl":s==="enter"?"Enter":s==="escape"?"Esc":s==="."?".":s.length===1?s.toUpperCase():`${s.charAt(0).toUpperCase()}${s.slice(1)}`).join("+")).join(" ")}function sc(e){if(e.isComposing)return;const t=ic(e.key);if(t===void 0)return;const s=[];return(e.metaKey||e.ctrlKey)&&s.push("mod"),e.altKey&&s.push("alt"),e.shiftKey&&s.push("shift"),s.push(t),s.join("+")}function Er(e){return e.trim().toLowerCase().split(/\s+/u).filter(t=>t!=="").map(t=>t.split("+").filter(s=>s!=="").join("+"))}function ic(e){if(e===" ")return"space";if(e.length===1)return e.toLowerCase();const t=e.toLowerCase();if(["enter","escape","tab","arrowup","arrowdown","arrowleft","arrowright","backspace","delete"].includes(t))return t}function rc(e,t){return e.length===t.length&&Dr(e,t)}function Dr(e,t){return t.every((s,i)=>e[i]===s)}function Mi(e){return e.includes("+")}function Ei(){return navigator.userAgent.toLowerCase().includes("mac")}const Ds="themes:classic",oc="themes:pi-web-dark",nc={themeId:oc,auto:!0},_r="pi-web-app-theme",ac=["--pi-bg","--pi-surface","--pi-surface-hover","--pi-terminal-bg","--pi-terminal-text","--pi-border","--pi-border-muted","--pi-text","--pi-text-secondary","--pi-text-bright","--pi-muted","--pi-dim","--pi-accent","--pi-accent-border","--pi-selection-bg","--pi-success","--pi-success-border","--pi-success-bg","--pi-success-surface","--pi-success-ring","--pi-warning","--pi-warning-border","--pi-warning-surface","--pi-danger","--pi-purple","--pi-purple-border","--pi-purple-surface","--pi-overlay","--pi-shadow-soft","--pi-shadow","--pi-shadow-strong","--pi-bg-overlay-soft","--pi-bg-overlay","--pi-success-bg-overlay","--pi-terminal-selection"],lc=/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u;function cc(){try{const e=window.localStorage.getItem(_r);return e===null?void 0:fc(e)}catch{return}}function dc(e){try{window.localStorage.setItem(_r,JSON.stringify(e))}catch{}}function pc(e){const t=document.documentElement;t.dataset.piWebTheme=e.id,t.style.colorScheme=e.colorScheme;for(const s of ac){const i=e.tokens[s];typeof i=="string"&&i!==""?t.style.setProperty(s,i):t.style.removeProperty(s)}}function hc(e){const t=uc(e.themes,e.fallbackThemeId??Ds),s=e.themes.find(n=>n.id===e.preference.themeId)??t;if(s===void 0)return{selectedTheme:void 0,activeTheme:void 0,selectedThemePair:void 0,fallbackTheme:t};const i=Lr(e.themePairs,s.id);if(!e.preference.auto||i===void 0)return{selectedTheme:s,activeTheme:s,selectedThemePair:i,fallbackTheme:t};const r=e.prefersLight?i.light:i.dark,o=e.themes.find(n=>n.id===r)??s;return{selectedTheme:s,activeTheme:o,selectedThemePair:i,fallbackTheme:t}}function uc(e,t=Ds){return e.find(s=>s.id===t)??e[0]}function Lr(e,t){return e.find(s=>s.light===t||s.dark===t)}function fc(e){const t=e.trim();if(t!=="")try{const s=JSON.parse(t);return mc(s)?s:void 0}catch{return}}function mc(e){if(!gc(e))return!1;const t=e.themeId,s=e.auto;return vc(t)&&typeof s=="boolean"}function gc(e){return typeof e=="object"&&e!==null}function vc(e){return typeof e=="string"&&lc.test(e)}const Or="workspace.delete",Wr="pi.operation",jr="target.workspaceId",bc="target.workspacePath";function wc(e){return{[Wr]:Or,[jr]:e.id,[bc]:e.path}}function yc(e){return{...e===void 0?{}:{projectId:e},metadata:{[Wr]:Or}}}function xc(e){const t={};for(const s of e){const i=ps(s);if(i===void 0)continue;const r=t[i];(r===void 0||s.createdAt.localeCompare(r.createdAt)>=0)&&(t[i]=s)}return t}function kc(e){return Object.entries(e).filter(([,t])=>Mt(t)).map(([t])=>t)}function Nr(e,t){if(t===void 0)return!1;const s=e.workspaceDeletionRuns[t.id];return s!==void 0&&Mt(s)}function ps(e){return e.metadata[jr]}function Mt(e){return e.status==="queued"||e.status==="running"}function Sc(){return[{id:"actions.show",title:"Show Actions",description:"Open the command palette",shortcut:"mod+k",group:"General",run:e=>{e.openActionPalette()}},{id:"prompt.focus",title:"Focus Prompt",description:"Move keyboard focus to the message composer",group:"General",enabled:e=>e.state.selectedSession!==void 0,run:e=>{e.focusPrompt()}},{id:"project.add",title:"Add Project",group:"Project",run:e=>e.addProject()},{id:"auth.login",title:"Configure Provider Authentication",description:"Run /login without tying authentication to a session",group:"General",run:e=>e.configureAuth()},{id:"auth.logout",title:"Remove Provider Authentication",description:"Run /logout for stored pi credentials",group:"General",run:e=>e.logoutAuth()},{id:"theme.select",title:"Select Theme",description:"Choose the PI WEB color theme",group:"Preferences",run:e=>{e.openThemePicker()}},{id:"app.refresh-data",title:"Refresh App Data",description:"Refresh session, status, activity, and the current workspace surface without reloading the page",group:"General",run:e=>e.refreshAppData()},{id:"app.reload-page",title:"Full Page Reload",description:"Reload the PI WEB browser page",group:"General",run:e=>{e.reloadPage()}},{id:"view.chat",title:"Go to Chat",shortcut:"mod+1",group:"Navigation",run:e=>{e.selectMainView("chat")}},{id:"view.files",title:"Go to Files",shortcut:"mod+2",group:"Navigation",enabled:Qe,run:e=>{e.selectMainView("core:workspace.files")}},{id:"view.git",title:"Go to Git",shortcut:"mod+3",group:"Navigation",enabled:Di,run:e=>{e.selectMainView("core:workspace.git")}},{id:"view.terminal",title:"Go to Terminal",shortcut:"mod+4",group:"Navigation",enabled:Qe,run:e=>{e.selectMainView("core:workspace.terminal")}},{id:"workspace.refresh-files",title:"Refresh Files",shortcut:"mod+shift+f",group:"Workspace",enabled:Qe,run:e=>e.refreshFiles()},{id:"workspace.refresh-git",title:"Refresh Git",shortcut:"mod+shift+g",group:"Workspace",enabled:Di,run:e=>e.refreshGit()},{id:"workspace.refresh-current",title:"Refresh Current Panel",shortcut:"mod+shift+r",group:"Workspace",enabled:Qe,run:e=>e.state.workspaceTool==="core:workspace.git"&&e.state.selectedWorkspace?.isGitRepo===!0?e.refreshGit():e.refreshFiles()},{id:"workspace.delete",title:"Delete Workspace",description:"Remove the selected Git worktree",group:"Workspace",enabled:$c,run:e=>e.deleteWorkspace()},{id:"session.start",title:"Start Session",shortcut:"mod+enter",group:"Session",enabled:Qe,run:e=>e.startSession()},{id:"session.archive",title:"Archive Session",description:"Archive the selected session",group:"Session",enabled:Pc,run:e=>e.archiveSession()},{id:"session.delete",title:"Delete New Session",description:"Delete the selected browser-cached new session",group:"Session",enabled:Tc,run:e=>e.deleteCachedNewSession()},{id:"session.stop",title:"Stop Active Work",shortcut:"mod+.",group:"Session",enabled:e=>e.state.selectedSession!==void 0&&Nt(e.state.status,e.state.activity),run:e=>e.stopActiveWork()}]}function Qe(e){return e.state.selectedWorkspace!==void 0}function Di(e){return e.state.selectedWorkspace?.isGitRepo===!0}function $c(e){const t=e.state.selectedWorkspace;return t!==void 0&&t.isGitWorktree&&!t.isMain&&!Nr(e.state,t)}function Pc(e){const t=e.state.selectedSession;return t!==void 0&&t.archived!==!0&&!ae(t)}function Tc(e){return ae(e.state.selectedSession)}const Cc="modulepreload",Ac=function(e){return"/"+e},_i={},Fr=function(t,s,i){let r=Promise.resolve();if(s&&s.length>0){let l=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const n=document.querySelector("meta[property=csp-nonce]"),a=n?.nonce||n?.getAttribute("nonce");r=l(s.map(d=>{if(d=Ac(d),d in _i)return;_i[d]=!0;const u=d.endsWith(".css"),h=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${h}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Cc,u||(f.as="script"),f.crossOrigin="",f.href=d,a&&f.setAttribute("nonce",a),document.head.appendChild(f),u)return new Promise((g,b)=>{f.addEventListener("load",g),f.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${d}`)))})}))}function o(n){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=n,window.dispatchEvent(a),!a.defaultPrevented)throw n}return r.then(n=>{for(const a of n||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})},Ic=10*1024*1024,Rc="10 MB";function Mc(){return[{id:"workspace.files",title:"Files",order:10,render:Ec},{id:"workspace.git",title:"Git",order:20,visible:({workspace:e})=>e.isGitRepo,render:Wc},{id:"workspace.terminal",title:"Terminal",order:30,badge:e=>e.activeTerminalCount>0?e.activeTerminalCount:void 0,render:Oc}]}function Ec(e){return c`
|
|
21
|
-
<section class="toolbar">
|
|
22
|
-
<strong>Files</strong>
|
|
23
|
-
${e.fileTreeStale?c`<span class="stale">stale</span>`:null}
|
|
24
|
-
<button @click=${e.onRefreshFiles}>Refresh</button>
|
|
25
|
-
</section>
|
|
26
|
-
<section class="split">
|
|
27
|
-
<div class="list tree">
|
|
28
|
-
${e.fileTree.length===0?c`<p class="muted">No files loaded.</p>`:e.fileTree.map(t=>Br(e,t,0))}
|
|
29
|
-
</div>
|
|
30
|
-
<div class="viewer">
|
|
31
|
-
${_c(e)}
|
|
32
|
-
</div>
|
|
33
|
-
</section>
|
|
34
|
-
`}function Br(e,t,s){const i=e.expandedDirs[t.path],r=i!==void 0,o=t.type!=="directory"&&e.selectedFilePath===t.path;return c`
|
|
35
|
-
<button class=${o?"row selected":"row"} style=${`--depth:${String(s)}`} @click=${()=>{Dc(e,t)}}>
|
|
36
|
-
<span>${t.type==="directory"?r?"▾":"▸":"·"}</span>
|
|
37
|
-
<span>${t.name}</span>
|
|
38
|
-
</button>
|
|
39
|
-
${r?i.map(n=>Br(e,n,s+1)):null}
|
|
40
|
-
`}function Dc(e,t){t.type==="directory"?e.onExpandDir(t.path):e.onSelectFile(t.path)}function _c(e){const t=e.selectedFileContent;return e.selectedFilePath===void 0||e.selectedFilePath===""?c`<p class="muted">Select a file.</p>`:t===void 0?c`<p class="muted">Loading ${e.selectedFilePath}…</p>`:t.mediaType==="image"?Lc(e,t):t.binary?c`<p class="muted">Binary file: ${t.path} · ${hs(t.size)}</p>`:(zr(),c`
|
|
41
|
-
<div class="viewer-header"><strong>${t.path}</strong><small>${t.language??"text"}${t.truncated?" · truncated":""}</small></div>
|
|
42
|
-
<code-viewer .content=${t.content} .language=${t.language}></code-viewer>
|
|
43
|
-
`)}function Lc(e,t){const s=`${t.mimeType??"image"} · ${hs(t.size)}`;if(t.size>Ic)return c`
|
|
44
|
-
<div class="viewer-header"><strong>${t.path}</strong><small>${s}</small></div>
|
|
45
|
-
<p class="muted">Image too large to preview: ${hs(t.size)} · limit ${Rc}</p>
|
|
46
|
-
`;const i=Yn(e.workspace.projectId,e.workspace.id,t.path,{modifiedAt:t.modifiedAt});return c`
|
|
47
|
-
<div class="viewer-header"><strong>${t.path}</strong><small>${s}</small></div>
|
|
48
|
-
<div class="image-preview">
|
|
49
|
-
<img src=${i} alt=${t.path} decoding="async" />
|
|
50
|
-
</div>
|
|
51
|
-
`}function Oc(e){return Fc(),c`<terminal-panel .workspace=${e.workspace} .selectedTerminalId=${e.selectedTerminalId} .autoStart=${e.terminalAutoStart} .onSelectTerminal=${e.onSelectTerminal}></terminal-panel>`}function Wc(e){const t=e.gitStatus;return c`
|
|
52
|
-
<section class="toolbar">
|
|
53
|
-
<strong>Git</strong>
|
|
54
|
-
${e.gitStale?c`<span class="stale">stale</span>`:null}
|
|
55
|
-
<button @click=${e.onRefreshGit}>Refresh</button>
|
|
56
|
-
</section>
|
|
57
|
-
<section class="split">
|
|
58
|
-
<div class="list">
|
|
59
|
-
${t===void 0?c`<p class="muted">No status loaded.</p>`:t.isGitRepo?c`
|
|
60
|
-
<p class="summary">${Bc(t)}</p>
|
|
61
|
-
${t.files.length===0?c`<p class="muted">No changes.</p>`:t.files.map(s=>c`
|
|
62
|
-
<button class="row ${e.selectedDiffPath===s.path?"selected":""}" @click=${()=>{e.onSelectDiff(s.path)}}>
|
|
63
|
-
<span>${zc(s.index,s.workingTree)}</span>
|
|
64
|
-
<span>${s.path}</span>
|
|
65
|
-
</button>
|
|
66
|
-
`)}
|
|
67
|
-
`:c`<p class="muted">Not a git repository.</p>`}
|
|
68
|
-
</div>
|
|
69
|
-
<div class="viewer">
|
|
70
|
-
${jc(e)}
|
|
71
|
-
</div>
|
|
72
|
-
</section>
|
|
73
|
-
`}function jc(e){if(e.selectedDiffPath===void 0||e.selectedDiffPath==="")return c`<p class="muted">Select a changed file.</p>`;const t=e.selectedDiff,s=e.selectedStagedDiff;if(t===void 0||s===void 0)return c`<p class="muted">Loading diff…</p>`;const i=[s,t].filter(r=>r.diff!=="");return i.length===0?c`<p class="muted">No staged or unstaged diff.</p>`:c`
|
|
74
|
-
<div class=${i.length===1?"diffs single":"diffs"}>
|
|
75
|
-
${i.map(r=>Nc(r))}
|
|
76
|
-
</div>
|
|
77
|
-
`}function Nc(e){return zr(),c`
|
|
78
|
-
<section class="diff-section">
|
|
79
|
-
<div class="viewer-header"><strong>${e.path??"diff"}</strong><small>${e.staged?"staged":"unstaged"}${e.truncated?" · truncated":""}</small></div>
|
|
80
|
-
<code-viewer .content=${e.diff} .language=${"diff"}></code-viewer>
|
|
81
|
-
</section>
|
|
82
|
-
`}function zr(){Fr(()=>import("./CodeViewer-N88Bx8F6.js"),__vite__mapDeps([0,1,2,3]))}function Fc(){Fr(()=>import("./TerminalPanel-DKiL51Xi.js"),__vite__mapDeps([4,5,6,1,2]))}function Bc(e){const t=e.branch??"detached",s=e.ahead??0,i=e.behind??0;return s===0&&i===0?t:`${t} · ↑${String(s)} ↓${String(i)}`}function zc(e,t){return(t!=="unmodified"?t:e).slice(0,1).toUpperCase()}function hs(e){if(!Number.isFinite(e)||e<0)return"0 B";if(e<1024)return`${String(e)} B`;const t=e/1024;if(t<1024)return`${Xt(t)} KB`;const s=t/1024;return s<1024?`${Xt(s)} MB`:`${Xt(s/1024)} GB`}function Xt(e){return e>=10?String(Math.round(e)):e.toFixed(1)}const qc={apiVersion:1,name:"PI WEB Core",activate:()=>({contributions:{actions:Sc(),workspacePanels:Mc()}})},Hc={"--pi-bg":"#0d1117","--pi-surface":"#161b22","--pi-surface-hover":"#21262d","--pi-terminal-bg":"#05070a","--pi-terminal-text":"#e6edf3","--pi-border":"#30363d","--pi-border-muted":"#21262d","--pi-text":"#e6edf3","--pi-text-secondary":"#c9d1d9","--pi-text-bright":"#f0f6fc","--pi-muted":"#8b949e","--pi-dim":"#6e7681","--pi-accent":"#58a6ff","--pi-accent-border":"#2f81f7","--pi-selection-bg":"#0d2847","--pi-success":"#3fb950","--pi-success-border":"#238636","--pi-success-bg":"#0f1b12","--pi-success-surface":"#0f2a16","--pi-success-ring":"#3fb95055","--pi-warning":"#d29922","--pi-warning-border":"#6e5200","--pi-warning-surface":"#1f1a10","--pi-danger":"#ff7b72","--pi-purple":"#d2a8ff","--pi-purple-border":"#a371f7","--pi-purple-surface":"#21132f","--pi-overlay":"#0008","--pi-shadow-soft":"#0006","--pi-shadow":"#0008","--pi-shadow-strong":"#000b","--pi-bg-overlay-soft":"#0d1117dd","--pi-bg-overlay":"#0d1117e6","--pi-success-bg-overlay":"#0f1b12ee","--pi-terminal-selection":"#264f78"},Uc={"--pi-bg":"#070912","--pi-surface":"#101527","--pi-surface-hover":"#151b31","--pi-terminal-bg":"#050710","--pi-terminal-text":"#f7f4ff","--pi-border":"#26304f","--pi-border-muted":"#26304f","--pi-text":"#f7f4ff","--pi-text-secondary":"#aaa4bd","--pi-text-bright":"#ffffff","--pi-muted":"#aaa4bd","--pi-dim":"#817a99","--pi-accent":"#7c3cff","--pi-accent-border":"#3d4a78","--pi-selection-bg":"#151b31","--pi-success":"#00f0d8","--pi-success-border":"#00f0d8","--pi-success-bg":"#071e22","--pi-success-surface":"#092d31","--pi-success-ring":"#00f0d855","--pi-warning":"#ffb000","--pi-warning-border":"#ffb000","--pi-warning-surface":"#16140d","--pi-danger":"#ff4f7b","--pi-purple":"#b7a2ff","--pi-purple-border":"#7c3cff","--pi-purple-surface":"#181026","--pi-overlay":"#0008","--pi-shadow-soft":"#0006","--pi-shadow":"#0008","--pi-shadow-strong":"#000b","--pi-bg-overlay-soft":"#070912dd","--pi-bg-overlay":"#070912e6","--pi-success-bg-overlay":"#071e22ee","--pi-terminal-selection":"#3d4a78"},Vc={"--pi-bg":"#f7f1e6","--pi-surface":"#fff9ee","--pi-surface-hover":"#f0e6d6","--pi-terminal-bg":"#15131b","--pi-terminal-text":"#fff9ee","--pi-border":"#c9bca8","--pi-border-muted":"#d8cdbc","--pi-text":"#15131b","--pi-text-secondary":"#15131b","--pi-text-bright":"#15131b","--pi-muted":"#5f586a","--pi-dim":"#766f7e","--pi-accent":"#6430d8","--pi-accent-border":"#6430d8","--pi-selection-bg":"#eadff8","--pi-success":"#008c82","--pi-success-border":"#008c82","--pi-success-bg":"#e1f4ef","--pi-success-surface":"#d7f0ec","--pi-success-ring":"#008c8255","--pi-warning":"#b05f00","--pi-warning-border":"#b05f00","--pi-warning-surface":"#fff2d2","--pi-danger":"#b51d49","--pi-purple":"#6430d8","--pi-purple-border":"#6430d8","--pi-purple-surface":"#eadff8","--pi-overlay":"#15131b66","--pi-shadow-soft":"#15131b22","--pi-shadow":"#15131b33","--pi-shadow-strong":"#15131b44","--pi-bg-overlay-soft":"#f7f1e6dd","--pi-bg-overlay":"#f7f1e6e6","--pi-success-bg-overlay":"#e1f4efee","--pi-terminal-selection":"#8d7b64"},Gc={apiVersion:1,name:"PI WEB Themes",activate:()=>({contributions:{themes:[{id:"pi-web-dark",name:"PI WEB Dark",description:"Dark PI WEB palette.",order:10,colorScheme:"dark",tokens:Uc},{id:"pi-web-light",name:"PI WEB Light",description:"Light PI WEB palette.",order:20,colorScheme:"light",tokens:Vc},{id:"classic",name:"PI WEB Classic",description:"The original PI WEB dark palette.",order:30,colorScheme:"dark",tokens:Hc}],themePairs:[{id:"pi-web",name:"PI WEB",description:"Follow the system light/dark preference with PI WEB themes.",order:10,light:"pi-web-light",dark:"pi-web-dark"}]}})};async function Kc(e="/pi-web-plugins/manifest.json"){const t=await Qc(e);if(t===void 0)return[];const s=[];for(const i of t.plugins)try{const r=new URL(i.module,new URL(e,window.location.href)).toString(),o=await import(r),n=Zc(o,r);s.push({id:i.id,plugin:n})}catch(r){console.warn(`Failed to load PI WEB plugin ${i.module}`,r)}return s}async function Qc(e){const t=await fetch(e,{cache:"no-store"});if(t.status!==404){if(!t.ok)throw new Error(`Failed to load plugin manifest: ${t.statusText}`);return Jc(await t.json())}}function Jc(e){if(!Et(e)||!Array.isArray(e.plugins))throw new Error("Invalid plugin manifest");return{plugins:e.plugins.map(t=>{if(!Et(t)||typeof t.id!="string"||t.id===""||typeof t.module!="string"||t.module==="")throw new Error("Invalid plugin manifest entry");return{id:t.id,module:t.module}})}}function Zc(e,t){if(!Et(e))throw new Error(`Plugin module ${t} did not export an object`);const s=e.default;if(!Xc(s))throw new Error(`Plugin module ${t} default export is not a PiWebPlugin`);return s}function Xc(e){return Et(e)&&e.apiVersion===1&&typeof e.name=="string"&&typeof e.activate=="function"}function Et(e){return typeof e=="object"&&e!==null}const Yc=/^[a-z][a-z0-9.-]*$/u,ed=/^[a-z][a-z0-9.-]*$/u,qr=new WeakMap,Hr=new WeakMap;class td{constructor(){this.actions=[],this.workspacePanels=[],this.workspaceLabels=[],this.themes=[],this.themePairs=[],this.pluginIds=new Set,this.contributionIds=new Set}register(t){const{id:s,plugin:i}=t;if(this.validatePluginId(s),this.pluginIds.has(s))throw new Error(`Duplicate plugin id: ${s}`);this.pluginIds.add(s);const r=i.apiVersion;if(r!==1)throw new Error(`Unsupported plugin API version for ${s}: ${String(r)}`);const n=i.activate({apiVersion:1,pluginId:s,html:c}).contributions;for(const a of n.actions??[])this.actions.push(this.qualifyAction(s,a));for(const a of n.workspacePanels??[])this.workspacePanels.push(this.qualifyWorkspacePanel(s,a));for(const a of n.workspaceLabels??[])this.workspaceLabels.push(this.qualifyWorkspaceLabelContribution(s,a));for(const a of n.themes??[])this.themes.push(this.qualifyTheme(s,a));for(const a of n.themePairs??[])this.themePairs.push(this.qualifyThemePair(s,a))}getActions(t){return this.actions.map(s=>{const i=sd(t,s.pluginId),r=s.enabled?.(i),o={id:s.id,pluginId:s.pluginId,localId:s.localId,title:s.title,run:()=>s.run(i)};return s.description!==void 0&&(o.description=s.description),s.shortcut!==void 0&&(o.shortcut=s.shortcut),s.group!==void 0&&(o.group=s.group),r!==void 0&&(o.enabled=r),o})}getWorkspacePanels(){return[...this.workspacePanels].sort((t,s)=>(t.order??1e3)-(s.order??1e3)||t.title.localeCompare(s.title))}getThemes(){return[...this.themes].sort((t,s)=>(t.order??1e3)-(s.order??1e3)||t.name.localeCompare(s.name))}getThemePairs(){return[...this.themePairs].sort((t,s)=>(t.order??1e3)-(s.order??1e3)||t.name.localeCompare(s.name))}getWorkspaceLabelItems(t,s){const i={state:t,workspace:s};return[...this.workspaceLabels].sort((r,o)=>(r.order??1e3)-(o.order??1e3)||r.id.localeCompare(o.id)).flatMap(r=>r.visible?.(i)===!1?[]:r.items(i))}qualifyAction(t,s){const i=this.qualify(t,s.id);return{...s,id:i,pluginId:t,localId:s.id}}qualifyWorkspacePanel(t,s){const i=this.qualify(t,s.id),r=s.badge;return{...s,id:i,pluginId:t,localId:s.id,...r===void 0?{}:{badge:o=>r(Li(o,t))},render:o=>s.render(Li(o,t))}}qualifyWorkspaceLabelContribution(t,s){const i=this.qualify(t,s.id);return{...s,id:i,pluginId:t,localId:s.id}}qualifyTheme(t,s){const i=this.qualify(t,s.id);return{...s,id:i,pluginId:t,localId:s.id}}qualifyThemePair(t,s){const i=this.qualify(t,s.id);return{...s,id:i,pluginId:t,localId:s.id,light:this.qualifyReference(t,s.light),dark:this.qualifyReference(t,s.dark)}}qualify(t,s){this.validateLocalId(s);const i=`${t}:${s}`;if(this.contributionIds.has(i))throw new Error(`Duplicate contribution id: ${i}`);return this.contributionIds.add(i),i}qualifyReference(t,s){return this.validateLocalId(s),`${t}:${s}`}validatePluginId(t){if(!Yc.test(t))throw new Error(`Invalid plugin id: ${t}`)}validateLocalId(t){if(!ed.test(t))throw new Error(`Invalid contribution id: ${t}`)}}function sd(e,t){return qr.get(e)?.(t)??e}function Li(e,t){return Hr.get(e)?.(t)??e}function id(e,t){return qr.set(e,t),e}function rd(e,t){return Hr.set(e,t),e}const od=["(display-mode: standalone)","(display-mode: fullscreen)","(display-mode: minimal-ui)"];function nd(){return typeof window>"u"||!("matchMedia"in window)?[]:od.map(e=>window.matchMedia(e))}function Oi(e,t=ad()){return e.some(s=>s.matches)||ld(t)}function ad(){return typeof navigator>"u"?void 0:navigator}function ld(e){return e!==void 0&&"standalone"in e&&e.standalone===!0}const cd=250;class dd{constructor(t=pd()){this.scheduler=t}repair(t){if(!t){this.clear();return}this.resetViewportScroll(),this.repairFrame!==void 0&&this.scheduler.cancelAnimationFrame(this.repairFrame),this.repairFrame=this.scheduler.requestAnimationFrame(()=>{this.repairFrame=void 0,this.resetViewportScroll(),this.repairFrame=this.scheduler.requestAnimationFrame(()=>{this.repairFrame=void 0,this.resetViewportScroll()})}),this.repairTimer!==void 0&&this.scheduler.clearTimeout(this.repairTimer),this.repairTimer=this.scheduler.setTimeout(()=>{this.repairTimer=void 0,this.resetViewportScroll()},cd)}clear(){this.repairFrame!==void 0&&(this.scheduler.cancelAnimationFrame(this.repairFrame),this.repairFrame=void 0),this.repairTimer!==void 0&&(this.scheduler.clearTimeout(this.repairTimer),this.repairTimer=void 0)}resetViewportScroll(){this.scheduler.scrollTo(0,0);const t=this.scheduler.documentElement;t!==void 0&&(t.scrollTop=0);const s=this.scheduler.body;s!==void 0&&(s.scrollTop=0)}}function pd(){return{requestAnimationFrame(e){return window.requestAnimationFrame(e)},cancelAnimationFrame(e){window.cancelAnimationFrame(e)},setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)},scrollTo(e,t){window.scrollTo(e,t)},get documentElement(){return typeof document>"u"?void 0:document.documentElement},get body(){return typeof document>"u"?void 0:document.body}}}const hd="(max-width: 760px)";class ud{constructor(t,s={}){this.host=t,this.onMobileNavigationMediaChange=i=>{this.isMobileNavigationLayout!==i.matches&&(this.isMobileNavigationLayout=i.matches,this.host.requestUpdate())},this.onPwaDisplayModeChange=()=>{const i=Oi(this.pwaDisplayModeMedia);this.isPwaDisplayMode!==i&&(this.isPwaDisplayMode=i,this.host.requestUpdate())},t.addController(this),this.mobileNavigationMedia=s.mobileNavigationMedia??fd(),this.pwaDisplayModeMedia=s.pwaDisplayModeMedia??nd(),this.viewportPositionRepairer=s.viewportPositionRepairer??new dd,this.isMobileNavigationLayout=this.mobileNavigationMedia?.matches??!1,this.isPwaDisplayMode=Oi(this.pwaDisplayModeMedia)}hostConnected(){this.mobileNavigationMedia?.addEventListener("change",this.onMobileNavigationMediaChange);for(const t of this.pwaDisplayModeMedia)t.addEventListener("change",this.onPwaDisplayModeChange)}hostDisconnected(){this.mobileNavigationMedia?.removeEventListener("change",this.onMobileNavigationMediaChange);for(const t of this.pwaDisplayModeMedia)t.removeEventListener("change",this.onPwaDisplayModeChange);this.viewportPositionRepairer.clear()}shouldAutoFocusPrompt(){return!this.isMobileNavigationLayout&&!this.isPwaDisplayMode}shouldShowAppRefreshInHeader(){return this.isPwaDisplayMode&&!this.isMobileNavigationLayout}shouldShowAppRefreshInContextBar(){return this.isPwaDisplayMode&&this.isMobileNavigationLayout}defaultRouteView(){return this.isMobileNavigationLayout?"navigation":"chat"}repairViewportPosition(){this.viewportPositionRepairer.repair(this.shouldRepairViewportPosition())}shouldRepairViewportPosition(){return this.isMobileNavigationLayout||this.isPwaDisplayMode}}function fd(){if(!(typeof window>"u"||!("matchMedia"in window)))return window.matchMedia(hd)}function md(e){return e.selectedProject===void 0?"projects":e.selectedWorkspace===void 0?"workspaces":"sessions"}function _s(e,t){if(e!=="none")return e??md(t)}function gd(e,t){return t.isMobileLayout&&_s(t.expanded,t.state)!==e}function vd(e,t,s){return s.isMobileLayout?_s(e,s.state)===t?"none":t:e}function bd(e,t,s){return s?t:e}class wd{constructor(t,s,i){this.host=t,this.getState=s,this.isMobileLayout=i,t.addController(this)}hostConnected(){}expandedSection(){return _s(this.expanded,this.getState())}isCollapsed(t){return gd(t,{isMobileLayout:this.isMobileLayout(),expanded:this.expanded,state:this.getState()})}toggle(t){this.setExpanded(vd(this.expanded,t,{isMobileLayout:this.isMobileLayout(),state:this.getState()}))}expand(t){this.setExpanded(bd(this.expanded,t,this.isMobileLayout()))}open(t,s){this.isMobileLayout()&&(this.expand(t),s())}setExpanded(t){this.expanded!==t&&(this.expanded=t,this.host.requestUpdate())}}class yd{constructor(t){this.host=t,this.navigationPanelCollapsed=!1,this.workspacePanelCollapsed=!1,t.addController(this)}hostConnected(){}toggleNavigationPanel(){this.navigationPanelCollapsed=!this.navigationPanelCollapsed,this.host.requestUpdate()}toggleWorkspacePanel(){this.workspacePanelCollapsed=!this.workspacePanelCollapsed,this.host.requestUpdate()}shellClass(t){return["shell",Ur(t),...this.navigationPanelCollapsed?["navigation-panel-collapsed"]:[],...this.workspacePanelCollapsed?["workspace-panel-collapsed"]:[]].join(" ")}}function Ur(e){return e==="navigation"?"navigation-view":e==="chat"?"chat-view":"workspace-view"}function xd(){const e=new URLSearchParams(window.location.search);return{projectId:e.get("project")??void 0,workspaceId:e.get("workspace")??void 0,sessionId:e.get("session")??void 0,tool:Sd(e.get("tool")),view:$d(e.get("view"))}}function kd(e,t){const s=new URL(window.location.href);s.searchParams.delete("project"),s.searchParams.delete("workspace"),s.searchParams.delete("session"),s.searchParams.delete("tool"),s.searchParams.delete("view"),e.projectId!==void 0&&e.projectId!==""&&s.searchParams.set("project",e.projectId),e.workspaceId!==void 0&&e.workspaceId!==""&&s.searchParams.set("workspace",e.workspaceId),e.sessionId!==void 0&&e.sessionId!==""&&s.searchParams.set("session",e.sessionId),e.tool!==void 0&&s.searchParams.set("tool",e.tool),e.view!==void 0&&s.searchParams.set("view",e.view);const i=`${s.pathname}${s.search}${s.hash}`,r=`${window.location.pathname}${window.location.search}${window.location.hash}`;i!==r&&(t?.replace===!0?window.history.replaceState({},"",s):window.history.pushState({},"",s))}function Sd(e){return e==="files"?"core:workspace.files":e==="git"?"core:workspace.git":Vr(e)?e:void 0}function $d(e){return e==="chat"?"chat":e==="files"?"core:workspace.files":e==="git"?"core:workspace.git":Vr(e)?e:void 0}function Vr(e){return e!==null&&/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u.test(e)}function Pd(e,t){const s=t.api??$s,i=t.pollIntervalMs??1e3,r=t.setTimeout??Cd(),o=t.clearTimeout??Ad();return{async runCommand(n){const a=await s.runTerminalCommand(e,n);return n.open===!0&&t.openTerminal(n.workspace,{terminalId:a.terminalId}),{run:a,completed:Td(a,s,i,r,o)}},listCommandRuns:n=>s.listCommandRuns(n),getCommandRun:n=>s.getCommandRun(n),open:n=>{t.openTerminal(void 0,n)}}}function Td(e,t,s,i,r){return Wi(e)?Promise.resolve(e):new Promise((o,n)=>{let a,l=!1;const d=f=>{l||(l=!0,a!==void 0&&r(a),o(f))},u=f=>{l||(l=!0,a!==void 0&&r(a),n(f instanceof Error?f:new Error(String(f))))},h=()=>{t.getCommandRun(e.id).then(f=>{if(f!==void 0&&Wi(f)){d(f);return}a=i(h,s)}).catch(u)};a=i(h,s)})}function Wi(e){return e.status==="succeeded"||e.status==="failed"}function Cd(){return(e,t)=>globalThis.setTimeout(e,t)}function Ad(){return e=>{globalThis.clearTimeout(e)}}function Id(e,t){return t[e.path]}function Rd(e){if(e?.hasSessionActivity===!0)return"session";if(e?.hasTerminalActivity===!0)return"terminal"}function Md(e,t,s){const i=Ed(e,t,s);if(i.some(r=>r.hasSessionActivity))return"session";if(i.some(r=>r.hasTerminalActivity))return"terminal"}function Ed(e,t,s){const i=new Set(t.filter(o=>o.projectId===e.id).map(o=>o.path)),r=new Map;for(const o of i){const n=s[o];n!==void 0&&r.set(n.cwd,n)}for(const o of Object.values(s))(o.cwd===e.path||o.cwd.startsWith(`${e.path}/`))&&r.set(o.cwd,o);return[...r.values()]}const ft=0,Dd=120;function Bt(e){if(typeof HTMLElement>"u"||typeof window>"u"||!(e instanceof HTMLElement))return"";const t=e.getBoundingClientRect(),s=_d(e),i=window.innerWidth,r=window.innerHeight,o=Math.max(0,s.left),n=Math.min(i,s.right),a=Math.max(0,s.top),l=Math.min(r,s.bottom),d=Math.min(t.right,n),u=l-t.bottom-ft,h=t.top-a-ft;return[...u<Dd&&h>u?[`bottom: ${Le(r-t.top+ft)};`,`max-height: ${Le(Math.max(0,h))};`]:[`top: ${Le(t.bottom+ft)};`,`max-height: ${Le(Math.max(0,u))};`],`right: ${Le(Math.max(0,i-d))};`,`max-width: ${Le(Math.max(0,d-o))};`].join(" ")}function _d(e){const t=e.getRootNode();return typeof ShadowRoot<"u"&&t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host.getBoundingClientRect():{top:0,right:window.innerWidth,bottom:window.innerHeight,left:0}}function Le(e){return`${String(Math.round(e))}px`}function Ls(e,t="Active"){if(e!==void 0)return c`<span class=${`activity-indicator ${e}`} role="img" aria-label=${t} title=${t}></span>`}const Ld=["a[href]","button","input","select","textarea","summary","[role='button']","[role='link']","[contenteditable='true']"].join(",");function Gr(e){return e.composedPath().some(t=>Od(t,Ld))}function Od(e,t){if(typeof Element<"u"&&e instanceof Element)return e.matches(t);if(!("matches"in e))return!1;const{matches:s}=e;return typeof s=="function"&&s.call(e,t)===!0}function Os(e,t){Gr(e)||t()}function Ws(e,t){e.key!=="Enter"&&e.key!==" "||Gr(e)||(e.preventDefault(),t())}const Wd=j`
|
|
83
|
-
/* Mobile browsers already subtract browser controls from 100dvh; reserve bottom safe area only in standalone PWA modes. */
|
|
84
|
-
:host { --pi-app-safe-area-bottom: 0px; position: fixed; top: 0; right: 0; left: 0; display: block; height: 100dvh; box-sizing: border-box; overflow: hidden; padding: env(safe-area-inset-top) env(safe-area-inset-right) var(--pi-app-safe-area-bottom) env(safe-area-inset-left); color: var(--pi-text); background: var(--pi-bg); font: 14px system-ui, sans-serif; }
|
|
85
|
-
:host([pwa-display-mode]) { --pi-app-safe-area-bottom: env(safe-area-inset-bottom); }
|
|
86
|
-
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
|
|
87
|
-
:host { --pi-app-safe-area-bottom: env(safe-area-inset-bottom); }
|
|
88
|
-
}
|
|
89
|
-
.shell { --navigation-panel-width: 340px; --workspace-panel-width: minmax(360px, 42vw); display: grid; grid-template-columns: var(--navigation-panel-width) 1px minmax(420px, 1fr) 1px var(--workspace-panel-width); height: 100%; min-height: 0; }
|
|
90
|
-
aside { grid-column: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
|
|
91
|
-
aside app-navigation-panel { flex: 1 1 auto; min-height: 0; }
|
|
92
|
-
header { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
93
|
-
.header-actions { display: flex; align-items: center; gap: 8px; }
|
|
94
|
-
project-list, workspace-list { flex: 0 0 auto; max-height: 26%; min-height: 0; overflow: hidden; border-bottom: 1px solid var(--pi-border-muted); }
|
|
95
|
-
session-list { flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
|
96
|
-
main { grid-column: 3; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
|
|
97
|
-
.context-bar { position: relative; flex: 0 0 auto; min-width: 0; display: none; align-items: center; gap: 0; padding: 6px 0; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); }
|
|
98
|
-
.context-bar::before, .context-bar::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 20px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
99
|
-
.context-bar::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
100
|
-
.context-bar::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
101
|
-
.context-bar.can-scroll-left::before, .context-bar.can-scroll-right::after { opacity: 1; }
|
|
102
|
-
.context-bar-label { display: none; }
|
|
103
|
-
.context-items { flex: 1 1 auto; min-width: 0; display: flex; align-items: stretch; gap: 5px; margin: 0; padding: 0 8px; list-style: none; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-padding-inline: 8px; scrollbar-width: thin; }
|
|
104
|
-
.context-bar.has-context-actions .context-items { padding-right: 52px; scroll-padding-inline: 8px 52px; }
|
|
105
|
-
.context-item { flex: 0 0 auto; min-width: 0; display: flex; }
|
|
106
|
-
.context-actions { position: absolute; top: 6px; right: 0; bottom: 6px; z-index: 3; display: flex; align-items: center; padding: 0 8px 0 0; pointer-events: none; }
|
|
107
|
-
.context-actions::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; z-index: 0; width: 26px; background: var(--pi-bg); pointer-events: none; }
|
|
108
|
-
.app-refresh { position: relative; z-index: 1; display: flex; align-items: center; pointer-events: auto; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
|
|
109
|
-
.app-refresh, .app-refresh * { -webkit-user-select: none; user-select: none; }
|
|
110
|
-
.app-refresh-button { box-sizing: border-box; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 999px; padding: 0; line-height: 1; touch-action: manipulation; -webkit-touch-callout: none; }
|
|
111
|
-
.app-refresh-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
112
|
-
.app-refresh-button.refreshing .app-refresh-icon { animation: app-refresh-spin .8s linear infinite; }
|
|
113
|
-
.app-refresh-menu { position: fixed; z-index: 10000; box-sizing: border-box; min-width: min(170px, calc(100vw - 16px)); overflow: auto; padding: 4px; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); box-shadow: 0 8px 24px var(--pi-shadow); overflow-wrap: anywhere; }
|
|
114
|
-
.app-refresh-menu button { display: block; width: 100%; border: 0; background: transparent; color: var(--pi-text); text-align: left; white-space: normal; overflow-wrap: anywhere; }
|
|
115
|
-
.app-refresh-menu button:hover, .app-refresh-menu button:focus { background: var(--pi-selection-bg); }
|
|
116
|
-
.context-chip { flex: 0 0 auto; min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; border: 1px solid var(--pi-border-muted); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text); padding: 4px 8px; font: inherit; text-align: left; }
|
|
117
|
-
.context-chip:hover { background: var(--pi-surface-hover); }
|
|
118
|
-
.context-chip:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 2px; }
|
|
119
|
-
.context-chip.empty { border-style: dashed; color: var(--pi-muted); }
|
|
120
|
-
.context-kind { display: none; }
|
|
121
|
-
.context-value { min-width: 0; overflow: visible; text-overflow: clip; white-space: nowrap; }
|
|
122
|
-
app-mobile-main-tabs { display: none; }
|
|
123
|
-
.mobile-tabs-frame { position: relative; display: none; flex: 0 0 auto; min-width: 0; border-bottom: 1px solid var(--pi-border); background: var(--pi-bg); }
|
|
124
|
-
.mobile-tabs-frame::before, .mobile-tabs-frame::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 20px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
125
|
-
.mobile-tabs-frame::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
126
|
-
.mobile-tabs-frame::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
127
|
-
.mobile-tabs-frame.can-scroll-left::before, .mobile-tabs-frame.can-scroll-right::after { opacity: 1; }
|
|
128
|
-
.mobile-tabs { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; }
|
|
129
|
-
.mobile-tabs button { flex: 0 0 auto; white-space: nowrap; }
|
|
130
|
-
.mobile-navigation-tab, .mobile-navigation-panel { display: none; }
|
|
131
|
-
.mobile-tabs button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
132
|
-
.tab-badge { display: inline-block; min-width: 14px; margin-left: 4px; border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 0 5px; font-size: 11px; line-height: 16px; text-align: center; }
|
|
133
|
-
.navigation-panel-edge, .workspace-panel-edge { min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: visible; background: var(--pi-border-muted); z-index: 2; }
|
|
134
|
-
.navigation-panel-edge { grid-column: 2; }
|
|
135
|
-
.workspace-panel-edge { grid-column: 4; }
|
|
136
|
-
.navigation-panel-edge-button, .workspace-panel-edge-button { position: relative; z-index: 1; box-sizing: border-box; display: grid; place-items: center; width: 18px; height: 48px; padding: 0; border: 1px solid var(--pi-border-muted); border-radius: 999px; background: var(--pi-bg); color: var(--pi-muted); opacity: .75; cursor: pointer; }
|
|
137
|
-
.navigation-panel-edge-button:hover, .navigation-panel-edge-button:focus-visible, .workspace-panel-edge-button:hover, .workspace-panel-edge-button:focus-visible { color: var(--pi-text); background: var(--pi-surface-hover); opacity: 1; }
|
|
138
|
-
.shell.navigation-panel-collapsed .navigation-panel-edge-button { transform: translateX(calc(50% - .5px)); }
|
|
139
|
-
.shell.workspace-panel-collapsed .workspace-panel-edge-button { transform: translateX(calc(-50% + .5px)); }
|
|
140
|
-
.navigation-panel-edge-icon, .workspace-panel-edge-icon { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
141
|
-
workspace-panel { grid-column: 5; min-width: 0; min-height: 0; overflow: hidden; }
|
|
142
|
-
@media (min-width: 1181px) {
|
|
143
|
-
.shell.navigation-panel-collapsed { --navigation-panel-width: 0px; }
|
|
144
|
-
.shell.navigation-panel-collapsed > aside { display: none; }
|
|
145
|
-
.shell.workspace-panel-collapsed { --workspace-panel-width: 0px; }
|
|
146
|
-
.shell.workspace-panel-collapsed > workspace-panel { display: none; }
|
|
147
|
-
}
|
|
148
|
-
@media (max-width: 1180px) {
|
|
149
|
-
.shell { grid-template-columns: var(--navigation-panel-width) 1px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
|
|
150
|
-
.shell.navigation-panel-collapsed { --navigation-panel-width: 0px; }
|
|
151
|
-
.shell.navigation-panel-collapsed > aside { display: none; }
|
|
152
|
-
aside { grid-row: 1 / 3; }
|
|
153
|
-
.navigation-panel-edge { grid-row: 1 / 3; }
|
|
154
|
-
main { grid-column: 3; grid-row: 1 / 3; }
|
|
155
|
-
app-mobile-main-tabs { display: block; flex: 0 0 auto; min-width: 0; }
|
|
156
|
-
.mobile-tabs-frame { display: flex; }
|
|
157
|
-
.shell.workspace-view main { grid-row: 1; min-height: auto; }
|
|
158
|
-
.shell.workspace-view > workspace-panel { grid-column: 3; grid-row: 2; display: flex; border-left: 0; }
|
|
159
|
-
.shell:not(.workspace-view) > workspace-panel { display: none; }
|
|
160
|
-
.workspace-panel-edge { display: none; }
|
|
161
|
-
main.workspace-view chat-view, main.workspace-view prompt-editor, main.workspace-view status-bar,
|
|
162
|
-
main.workspace-view .empty { display: none; }
|
|
163
|
-
main.workspace-view { overflow: hidden; }
|
|
164
|
-
}
|
|
165
|
-
@media (max-width: 760px) {
|
|
166
|
-
.shell { grid-template-columns: minmax(0, 1fr); }
|
|
167
|
-
aside, .navigation-panel-edge { display: none; }
|
|
168
|
-
main, .shell.workspace-view > workspace-panel { grid-column: 1; }
|
|
169
|
-
.context-bar { display: flex; }
|
|
170
|
-
.mobile-navigation-tab { display: block; }
|
|
171
|
-
main.navigation-view chat-view, main.navigation-view prompt-editor, main.navigation-view status-bar,
|
|
172
|
-
main.navigation-view .empty { display: none; }
|
|
173
|
-
main.navigation-view .mobile-navigation-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
|
|
174
|
-
main.navigation-view .mobile-navigation-panel app-navigation-panel { flex: 1 1 auto; min-height: 0; }
|
|
175
|
-
main.navigation-view .mobile-navigation-panel project-list,
|
|
176
|
-
main.navigation-view .mobile-navigation-panel workspace-list,
|
|
177
|
-
main.navigation-view .mobile-navigation-panel session-list { flex: 1 1 auto; max-height: none; min-height: 0; overflow: hidden; }
|
|
178
|
-
main.navigation-view .mobile-navigation-panel project-list[collapsed],
|
|
179
|
-
main.navigation-view .mobile-navigation-panel workspace-list[collapsed],
|
|
180
|
-
main.navigation-view .mobile-navigation-panel session-list[collapsed] { flex: 0 0 auto; min-height: auto; overflow: hidden; }
|
|
181
|
-
}
|
|
182
|
-
status-bar { flex: 0 0 auto; }
|
|
183
|
-
chat-view { flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
|
184
|
-
prompt-editor, chat-composer { flex: 0 0 auto; }
|
|
185
|
-
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
186
|
-
.empty { margin: auto; color: var(--pi-muted); }
|
|
187
|
-
.error { padding: 10px 16px; border-bottom: 1px solid var(--pi-border); color: var(--pi-danger); }
|
|
188
|
-
@keyframes app-refresh-spin { to { transform: rotate(360deg); } }
|
|
189
|
-
`,jd=j`
|
|
190
|
-
:host { display: flex; flex-direction: column; min-height: 0; color: var(--pi-text); background: var(--pi-bg); font: 13px system-ui, sans-serif; }
|
|
191
|
-
header { flex: 0 0 auto; min-width: 0; border-bottom: 1px solid var(--pi-border); }
|
|
192
|
-
.workspace-header-scroll-frame { position: relative; min-width: 0; background: var(--pi-bg); }
|
|
193
|
-
.workspace-header-scroll-frame::before, .workspace-header-scroll-frame::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 18px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
194
|
-
.workspace-header-scroll-frame::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
195
|
-
.workspace-header-scroll-frame::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
196
|
-
.workspace-header-scroll-frame.can-scroll-left::before, .workspace-header-scroll-frame.can-scroll-right::after { opacity: 1; }
|
|
197
|
-
.workspace-header-strip { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; padding: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; }
|
|
198
|
-
.tabs { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; }
|
|
199
|
-
.tabs button { flex: 0 0 auto; white-space: nowrap; }
|
|
200
|
-
button { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--pi-border); border-radius: 7px; background: var(--pi-surface); color: var(--pi-text); padding: 5px 7px; cursor: pointer; }
|
|
201
|
-
button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
202
|
-
.tab-badge { display: inline-block; min-width: 14px; border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 0 5px; font-size: 11px; line-height: 16px; text-align: center; }
|
|
203
|
-
.panel-content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
|
|
204
|
-
.empty-state { box-sizing: border-box; width: min(100%, 380px); margin: auto; padding: 24px; display: grid; gap: 8px; color: var(--pi-muted); text-align: center; }
|
|
205
|
-
.empty-state h2 { margin: 0; color: var(--pi-text); font-size: 15px; line-height: 1.3; }
|
|
206
|
-
.empty-state p { margin: 0; line-height: 1.45; }
|
|
207
|
-
small, .muted { color: var(--pi-muted); }
|
|
208
|
-
header small { flex: 0 0 auto; min-width: max-content; overflow: visible; text-overflow: clip; white-space: nowrap; }
|
|
209
|
-
header .workspace-label { width: max-content; max-width: none; overflow: visible; }
|
|
210
|
-
header .workspace-label-base, header .workspace-label-item, header .workspace-label-render { overflow: visible; text-overflow: clip; }
|
|
211
|
-
@media (max-width: 1180px) { .tabs { display: none; } }
|
|
212
|
-
.workspace-label { min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; max-width: 100%; overflow: hidden; white-space: nowrap; }
|
|
213
|
-
.workspace-label-base, .workspace-label-item, .workspace-label-render { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
214
|
-
.workspace-label-item, .workspace-label-render, .workspace-label-separator { color: var(--pi-muted); }
|
|
215
|
-
.workspace-label-link { color: var(--pi-accent); text-decoration: none; }
|
|
216
|
-
.workspace-label-link:hover, .workspace-label-link:focus { text-decoration: underline; }
|
|
217
|
-
.toolbar { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 1px solid var(--pi-border-muted); }
|
|
218
|
-
.toolbar button { margin-left: auto; }
|
|
219
|
-
.stale { border: 1px solid var(--pi-warning-border); border-radius: 999px; color: var(--pi-warning); padding: 1px 6px; font-size: 12px; }
|
|
220
|
-
.split { flex: 1 1 auto; min-height: 0; display: grid; grid-template-rows: minmax(160px, 34%) minmax(0, 1fr); }
|
|
221
|
-
.list { min-height: 0; overflow: auto; border-bottom: 1px solid var(--pi-border); padding: 6px; }
|
|
222
|
-
.row { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 4px; width: 100%; border: 0; border-radius: 5px; background: transparent; text-align: left; padding: 4px 6px 4px calc(6px + var(--depth, 0) * 14px); }
|
|
223
|
-
.row:hover, .row.selected { background: var(--pi-selection-bg); }
|
|
224
|
-
.row span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
225
|
-
.summary { margin: 4px 6px 8px; color: var(--pi-muted); }
|
|
226
|
-
.viewer { min-height: 0; overflow: auto; display: flex; flex-direction: column; }
|
|
227
|
-
.diffs { flex: 1 1 auto; min-height: 0; overflow: auto; display: grid; grid-template-rows: minmax(120px, 1fr) minmax(120px, 1fr); }
|
|
228
|
-
.diffs.single { grid-template-rows: minmax(0, 1fr); }
|
|
229
|
-
.diff-section { min-height: 0; display: flex; flex-direction: column; border-bottom: 1px solid var(--pi-border); }
|
|
230
|
-
.diff-section:last-child { border-bottom: 0; }
|
|
231
|
-
.viewer-header { position: sticky; top: 0; display: flex; justify-content: space-between; gap: 8px; padding: 8px; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); }
|
|
232
|
-
.viewer-header strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
233
|
-
code-viewer { flex: 1 1 auto; min-height: 0; }
|
|
234
|
-
.image-preview { flex: 1 1 auto; min-height: 0; box-sizing: border-box; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 16px; }
|
|
235
|
-
.image-preview img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; border: 1px solid var(--pi-border-muted); border-radius: 8px; background-color: var(--pi-surface); background-image: linear-gradient(45deg, color-mix(in srgb, var(--pi-border-muted) 45%, transparent) 25%, transparent 25%), linear-gradient(-45deg, color-mix(in srgb, var(--pi-border-muted) 45%, transparent) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--pi-border-muted) 45%, transparent) 75%), linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--pi-border-muted) 45%, transparent) 75%); background-position: 0 0, 0 8px, 8px -8px, -8px 0; background-size: 16px 16px; box-shadow: 0 8px 24px var(--pi-shadow-soft); }
|
|
236
|
-
pre { margin: 0; padding: 10px; overflow: auto; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
237
|
-
p { margin: 10px; }
|
|
238
|
-
`,js=j`
|
|
239
|
-
:host { display: flex; flex-direction: column; min-height: 0; overflow: hidden; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
240
|
-
:host([collapsed]) { flex: 0 0 auto; min-height: auto; overflow: hidden; }
|
|
241
|
-
section { box-sizing: border-box; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 10px; }
|
|
242
|
-
h2 { flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--pi-muted); font-size: 12px; text-transform: uppercase; }
|
|
243
|
-
.list-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
|
244
|
-
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
245
|
-
section > button { display: block; width: 100%; text-align: left; margin: 6px 0; }
|
|
246
|
-
.subheading { margin-top: 14px; }
|
|
247
|
-
.section-toggle { display: flex; flex: 1 1 auto; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; width: 100%; border: 0; background: transparent; color: inherit; padding: 0; font: inherit; text-align: left; text-transform: inherit; }
|
|
248
|
-
.section-toggle span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
249
|
-
.section-title { display: grid; gap: 2px; min-width: 0; }
|
|
250
|
-
.section-toggle .section-selected { display: block; color: var(--pi-text); font-size: 12px; font-weight: 600; line-height: 1.25; text-transform: none; }
|
|
251
|
-
.section-toggle .section-count { flex: 0 0 auto; display: inline; color: var(--pi-muted); font-size: inherit; }
|
|
252
|
-
.section-toggle small { display: inline; color: inherit; font-size: inherit; }
|
|
253
|
-
.action-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; margin: 6px 0; cursor: pointer; }
|
|
254
|
-
.action-row:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 2px; border-radius: 8px; }
|
|
255
|
-
.action-row.selected .action-main, .action-row.selected .action-menu-toggle { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
256
|
-
.action-row.archived .action-main { color: var(--pi-muted); }
|
|
257
|
-
.action-main { box-sizing: border-box; min-width: 0; width: 100%; border: 1px solid var(--pi-border); border-top-right-radius: 0; border-bottom-right-radius: 0; border-top-left-radius: 8px; border-bottom-left-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px 7px calc(9px + var(--depth, 0) * 16px); text-align: left; }
|
|
258
|
-
.action-name { display: -webkit-box; max-height: 2.5em; overflow: hidden; overflow-wrap: anywhere; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
|
|
259
|
-
.action-row:not(.selected):hover .action-main { background: var(--pi-surface-hover); }
|
|
260
|
-
.workspace-row .action-main { border-radius: 8px 0 0 8px; }
|
|
261
|
-
.workspace-primary { min-width: 0; display: flex; align-items: baseline; gap: 6px; }
|
|
262
|
-
.workspace-primary .activity-indicator { flex: 0 0 auto; margin-right: 0; }
|
|
263
|
-
.workspace-primary-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
264
|
-
.workspace-status { flex: 0 0 auto; color: var(--pi-warning); font-size: 12px; }
|
|
265
|
-
.workspace-secondary { margin-top: 3px; }
|
|
266
|
-
.workspace-menu-panel { width: max-content; min-width: min(120px, calc(100vw - 16px)); padding: 8px; }
|
|
267
|
-
.workspace-menu-actions { margin: 0 0 8px; padding-bottom: 8px; border-bottom: 1px solid var(--pi-border-muted); }
|
|
268
|
-
.workspace-menu-actions button.danger { color: var(--pi-danger); }
|
|
269
|
-
.workspace-menu-actions button.danger:hover, .workspace-menu-actions button.danger:focus { background: color-mix(in srgb, var(--pi-danger) 14%, transparent); }
|
|
270
|
-
.workspace-menu-details { display: grid; gap: 6px; margin: 0; }
|
|
271
|
-
.workspace-detail-row { display: grid; grid-template-columns: minmax(58px, max-content) minmax(0, 1fr); gap: 8px; align-items: baseline; }
|
|
272
|
-
.workspace-detail-row dt { color: var(--pi-muted); font-size: 12px; white-space: normal; }
|
|
273
|
-
.workspace-detail-row dd { min-width: 0; margin: 0; overflow-wrap: anywhere; white-space: normal; }
|
|
274
|
-
.tree-marker { color: var(--pi-dim); margin-right: 5px; }
|
|
275
|
-
.badge { display: inline-block; margin-left: 5px; border: 1px solid var(--pi-border); border-radius: 999px; color: var(--pi-muted); padding: 0 5px; font-size: 11px; font-weight: 400; }
|
|
276
|
-
.activity-indicator { display: inline-block; width: 7px; height: 7px; margin-right: 6px; background: var(--pi-success); animation: pulse 1s ease-in-out infinite; vertical-align: 1px; }
|
|
277
|
-
.activity-indicator.session { border-radius: 50%; background: var(--pi-success); }
|
|
278
|
-
.activity-indicator.terminal { border-radius: 2px; background: var(--pi-accent); }
|
|
279
|
-
.action-menu { position: relative; align-self: stretch; }
|
|
280
|
-
.action-menu-toggle { display: grid; place-items: center; height: 100%; min-width: 32px; padding: 0; color: var(--pi-muted); border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
|
|
281
|
-
.action-menu-toggle:hover { color: var(--pi-text); background: var(--pi-surface-hover); }
|
|
282
|
-
.action-menu-panel { position: fixed; z-index: 50; box-sizing: border-box; min-width: min(120px, calc(100vw - 16px)); overflow: auto; padding: 4px; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); box-shadow: 0 8px 24px var(--pi-shadow); overflow-wrap: anywhere; }
|
|
283
|
-
.action-menu-panel button { display: block; width: 100%; text-align: left; white-space: normal; overflow-wrap: anywhere; border: 0; background: transparent; color: var(--pi-text); }
|
|
284
|
-
.action-menu-panel button:hover { background: var(--pi-selection-bg); }
|
|
285
|
-
button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
286
|
-
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
287
|
-
small { display: block; color: var(--pi-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
288
|
-
.workspace-label { min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; max-width: 100%; overflow: hidden; white-space: nowrap; }
|
|
289
|
-
.workspace-label-base, .workspace-label-item, .workspace-label-render { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
290
|
-
.workspace-label-item, .workspace-label-render, .workspace-label-separator { color: var(--pi-muted); }
|
|
291
|
-
.workspace-label-link { color: var(--pi-accent); text-decoration: none; }
|
|
292
|
-
.workspace-label-link:hover, .workspace-label-link:focus { text-decoration: underline; }
|
|
293
|
-
.workspace-detail-row .workspace-label { overflow: visible; white-space: normal; flex-wrap: wrap; }
|
|
294
|
-
.workspace-detail-row .workspace-label-base, .workspace-detail-row .workspace-label-item, .workspace-detail-row .workspace-label-render { overflow: visible; text-overflow: clip; overflow-wrap: anywhere; white-space: normal; }
|
|
295
|
-
@keyframes pulse { 0%, 100% { transform: scale(.75); opacity: .55; } 50% { transform: scale(1.2); opacity: 1; } }
|
|
296
|
-
`,Nd=j`
|
|
297
|
-
:host { position: relative; z-index: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
298
|
-
.chat-wrap { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
|
299
|
-
.chat { height: 100%; min-height: 0; overflow: auto; overflow-anchor: none; padding: 26px 16px 64px; box-sizing: border-box; }
|
|
300
|
-
.scroll-marker { display: block; height: 0; overflow: hidden; pointer-events: none; }
|
|
301
|
-
.activity-dock { position: absolute; left: 16px; right: 16px; bottom: 12px; z-index: 20; display: flex; align-items: center; gap: 8px; min-width: 0; box-sizing: border-box; border: 1px solid var(--pi-border); border-radius: 999px; background: var(--pi-bg-overlay); color: var(--pi-muted); padding: 8px 12px; font-size: 13px; pointer-events: none; box-shadow: 0 8px 28px var(--pi-shadow); backdrop-filter: blur(6px); }
|
|
302
|
-
.activity-dock.active { border-color: var(--pi-success-border); color: var(--pi-success); background: var(--pi-success-bg-overlay); }
|
|
303
|
-
.activity-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
304
|
-
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .45; flex: 0 0 auto; }
|
|
305
|
-
.activity-dock.active .dot { animation: pulse 1s ease-in-out infinite; opacity: 1; }
|
|
306
|
-
.msg { max-width: 100%; min-width: 0; box-sizing: border-box; margin: 0 0 14px; padding: 12px; border: 1px solid var(--pi-border); border-radius: 10px; background: var(--pi-surface); overflow: visible; }
|
|
307
|
-
.msg.user { border-color: var(--pi-accent-border); background: var(--pi-selection-bg); }
|
|
308
|
-
.msg.tool { border-color: var(--pi-warning-border); background: var(--pi-warning-surface); color: var(--pi-warning); }
|
|
309
|
-
.msg.tool-execution-shell { padding: 0; border: 0; background: transparent; color: var(--pi-text); }
|
|
310
|
-
.msg.system { color: var(--pi-danger); }
|
|
311
|
-
.msg.bash { border-color: var(--pi-success); background: var(--pi-success-bg); }
|
|
312
|
-
.msg.skill { border-color: var(--pi-purple-border); background: var(--pi-purple-surface); }
|
|
313
|
-
.msg.event-group { padding: 0; border-color: var(--pi-border); background: var(--pi-bg); color: var(--pi-muted); }
|
|
314
|
-
.msg.event-group.live { border-color: var(--pi-success-border); background: var(--pi-success-bg); }
|
|
315
|
-
.msg.event-group > summary { position: sticky; top: -26px; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px 9px 0 0; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); color: var(--pi-muted); }
|
|
316
|
-
.msg.event-group.live > summary { border-bottom-color: var(--pi-success-border); background: var(--pi-success-bg); color: var(--pi-success); }
|
|
317
|
-
.msg.event-group > summary .label { margin: 0; }
|
|
318
|
-
.group-body { padding: 0 12px 12px; }
|
|
319
|
-
.group-msg { max-width: 100%; min-width: 0; box-sizing: border-box; padding: 10px 0; border-top: 1px solid var(--pi-border-muted); color: var(--pi-text); overflow: visible; }
|
|
320
|
-
.group-msg.tool { color: var(--pi-warning); }
|
|
321
|
-
.group-msg.tool-execution-shell { color: var(--pi-text); }
|
|
322
|
-
.group-msg.system { color: var(--pi-danger); }
|
|
323
|
-
.group-msg.bash { color: var(--pi-success); }
|
|
324
|
-
.history-boundary { position: relative; z-index: 5; display: grid; gap: 3px; justify-items: center; margin: 0 0 14px; color: var(--pi-muted); font-size: 12px; text-align: center; }
|
|
325
|
-
.history-load-button { border: 1px solid var(--pi-border); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text-secondary); padding: 5px 12px; font: 12px system-ui, sans-serif; cursor: pointer; }
|
|
326
|
-
.history-load-button:hover, .history-load-button:focus { border-color: var(--pi-accent); color: var(--pi-text-bright); }
|
|
327
|
-
.history-load-button:disabled { cursor: default; opacity: .55; }
|
|
328
|
-
.queued-messages { max-width: 100%; min-width: 0; box-sizing: border-box; display: grid; gap: 8px; margin: 0 0 14px; padding: 12px; border: 1px solid var(--pi-warning-border); border-radius: 10px; background: var(--pi-warning-surface); color: var(--pi-text); overflow: hidden; }
|
|
329
|
-
.queued-header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
|
|
330
|
-
.queued-header strong { color: var(--pi-warning); }
|
|
331
|
-
.queued-header small { color: var(--pi-muted); }
|
|
332
|
-
.queued-message { display: grid; gap: 4px; padding-top: 8px; border-top: 1px solid var(--pi-border); }
|
|
333
|
-
.queued-message:first-of-type { padding-top: 0; border-top: 0; }
|
|
334
|
-
.queued-kind { color: var(--pi-muted); font-size: 12px; text-transform: uppercase; }
|
|
335
|
-
.session-activity { max-width: 100%; min-width: 0; box-sizing: border-box; display: grid; gap: 4px; margin: 0 0 14px; padding: 12px; border: 1px solid var(--pi-border); border-radius: 10px; background: var(--pi-surface); color: var(--pi-text); overflow: hidden; }
|
|
336
|
-
.session-activity.compacting { border-color: var(--pi-purple-border); background: var(--pi-purple-surface); }
|
|
337
|
-
.session-activity.receiving { border-color: var(--pi-success-border); background: var(--pi-success-bg); }
|
|
338
|
-
.session-activity strong { color: var(--pi-purple); }
|
|
339
|
-
.session-activity.receiving strong { color: var(--pi-success); }
|
|
340
|
-
.session-activity span, .session-activity small { color: var(--pi-muted); }
|
|
341
|
-
.history-boundary small { color: var(--pi-dim); }
|
|
342
|
-
.msg-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 22px; margin-bottom: 8px; }
|
|
343
|
-
.msg > .msg-header { position: sticky; top: -26px; z-index: 4; margin: -12px -12px 8px; padding: 7px 10px 6px; border-radius: 9px 9px 0 0; border-bottom: 1px solid color-mix(in srgb, var(--pi-border-muted) 35%, transparent); background: var(--pi-surface); box-shadow: 0 8px 18px var(--pi-shadow-soft); }
|
|
344
|
-
.msg.user > .msg-header { border-bottom-color: color-mix(in srgb, var(--pi-accent-border) 35%, transparent); background: var(--pi-selection-bg); }
|
|
345
|
-
.msg.tool > .msg-header { border-bottom-color: color-mix(in srgb, var(--pi-warning-border) 35%, transparent); background: var(--pi-warning-surface); }
|
|
346
|
-
.msg.bash > .msg-header { border-bottom-color: color-mix(in srgb, var(--pi-success) 35%, transparent); background: var(--pi-success-bg); }
|
|
347
|
-
.msg.skill > .msg-header { border-bottom-color: color-mix(in srgb, var(--pi-purple-border) 35%, transparent); background: var(--pi-purple-surface); }
|
|
348
|
-
.group-msg > .msg-header { position: sticky; top: -26px; z-index: 4; margin: -10px 0 8px; padding: 7px 0 6px; border-bottom: 1px solid color-mix(in srgb, var(--pi-border-muted) 35%, transparent); background: var(--pi-bg); }
|
|
349
|
-
.msg-header-trailing { min-width: 0; display: inline-flex; align-items: baseline; justify-content: flex-end; gap: 8px; }
|
|
350
|
-
.msg-actions { display: inline-flex; gap: 6px; opacity: 0; transition: opacity .12s ease; }
|
|
351
|
-
.msg-action { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-muted); padding: 0; font: 14px system-ui, sans-serif; line-height: 1; cursor: pointer; }
|
|
352
|
-
.msg-action:hover, .msg-action:focus { color: var(--pi-text); border-color: var(--pi-accent); }
|
|
353
|
-
.msg:hover > .msg-header .msg-actions, .msg:focus-within > .msg-header .msg-actions, .group-msg:hover > .msg-header .msg-actions, .group-msg:focus-within > .msg-header .msg-actions { opacity: 1; }
|
|
354
|
-
.label { display: block; color: var(--pi-muted); font-size: 12px; text-transform: uppercase; }
|
|
355
|
-
.msg-header .label { margin: 0; }
|
|
356
|
-
.msg-meta { min-width: 0; opacity: .28; border: 0; background: transparent; color: var(--pi-dim); padding: 0; font: 11px system-ui, sans-serif; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .12s ease, max-width .12s ease; cursor: pointer; user-select: text; -webkit-user-select: text; }
|
|
357
|
-
.msg:hover > .msg-header .msg-meta, .msg:focus-within > .msg-header .msg-meta, .group-msg:hover > .msg-header .msg-meta, .group-msg:focus-within > .msg-header .msg-meta, .msg-meta:focus, .msg-meta.expanded { opacity: 1; }
|
|
358
|
-
.msg-meta:focus { outline: 1px solid var(--pi-border); outline-offset: 3px; border-radius: 4px; }
|
|
359
|
-
@media (hover: none) {
|
|
360
|
-
.msg-actions { opacity: 1; }
|
|
361
|
-
.msg-meta { opacity: .75; max-width: 26px; }
|
|
362
|
-
.msg-meta::before { content: "ⓘ"; font-size: 13px; }
|
|
363
|
-
.msg-meta:focus, .msg-meta.expanded { opacity: 1; max-width: 75%; }
|
|
364
|
-
.msg-meta:focus::before, .msg-meta.expanded::before { content: ""; }
|
|
365
|
-
}
|
|
366
|
-
formatted-text.part { display: block; }
|
|
367
|
-
.part { max-width: 100%; min-width: 0; box-sizing: border-box; overflow: visible; }
|
|
368
|
-
.part + .part { margin-top: 10px; }
|
|
369
|
-
.tool-line { color: var(--pi-warning); }
|
|
370
|
-
.summary { color: var(--pi-muted); margin-left: 6px; }
|
|
371
|
-
.part:is(details) { border-top: 1px solid var(--pi-border); padding-top: 8px; }
|
|
372
|
-
.part > formatted-text { display: block; max-width: 100%; min-width: 0; overflow: visible; }
|
|
373
|
-
.skill-invocation, .skill-read { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); padding: 8px 10px; }
|
|
374
|
-
.skill-invocation > summary, .skill-read > strong { color: var(--pi-purple); }
|
|
375
|
-
.skill-invocation > small, .skill-read > small { display: block; margin: 6px 0 0; color: var(--pi-muted); }
|
|
376
|
-
summary { cursor: pointer; color: var(--pi-muted); }
|
|
377
|
-
pre { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
|
|
378
|
-
.shell-output { color: var(--pi-text); font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.45; }
|
|
379
|
-
@keyframes pulse { 0%, 100% { transform: scale(.75); opacity: .55; } 50% { transform: scale(1.2); opacity: 1; } }
|
|
380
|
-
`,Fd=j`
|
|
381
|
-
:host { display: block; }
|
|
382
|
-
.formatted { white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
|
|
383
|
-
p, ul, ol, pre, blockquote, table, .code-block-wrapper { margin: 0 0 10px; }
|
|
384
|
-
:is(p, ul, ol, pre, blockquote, table, .code-block-wrapper):last-child { margin-bottom: 0; }
|
|
385
|
-
ul, ol { padding-left: 22px; }
|
|
386
|
-
li + li { margin-top: 3px; }
|
|
387
|
-
code { border: 1px solid var(--pi-border); border-radius: 4px; background: var(--pi-bg); padding: 1px 4px; font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
388
|
-
.code-block-wrapper { position: relative; }
|
|
389
|
-
.code-block-wrapper pre { margin: 0; padding-right: 40px; }
|
|
390
|
-
pre { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); padding: 10px; overflow-x: auto; overflow-y: hidden; }
|
|
391
|
-
pre code { border: 0; padding: 0; background: transparent; }
|
|
392
|
-
.code-copy-button { position: absolute; top: 6px; right: 6px; z-index: 1; display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-muted); padding: 0; font: 14px system-ui, sans-serif; line-height: 1; cursor: pointer; }
|
|
393
|
-
.code-copy-button:hover, .code-copy-button:focus { color: var(--pi-text); border-color: var(--pi-accent); }
|
|
394
|
-
blockquote { border-left: 3px solid var(--pi-border); padding-left: 10px; color: var(--pi-muted); }
|
|
395
|
-
a { color: var(--pi-accent); }
|
|
396
|
-
h1, h2, h3, h4 { margin: 14px 0 8px; line-height: 1.2; }
|
|
397
|
-
h1:first-child, h2:first-child, h3:first-child, h4:first-child { margin-top: 0; }
|
|
398
|
-
h1 { font-size: 20px; }
|
|
399
|
-
h2 { font-size: 17px; }
|
|
400
|
-
h3 { font-size: 15px; }
|
|
401
|
-
h4 { font-size: 14px; }
|
|
402
|
-
table { border-collapse: collapse; display: block; overflow-x: auto; overflow-y: hidden; }
|
|
403
|
-
th, td { border: 1px solid var(--pi-border); padding: 4px 8px; }
|
|
404
|
-
th { background: var(--pi-surface); }
|
|
405
|
-
`,Bd=j`
|
|
406
|
-
:host { display: block; color: var(--pi-muted); font: 12px system-ui, sans-serif; }
|
|
407
|
-
.bar { display: flex; gap: 12px; align-items: center; min-width: 0; padding: 7px 12px; border-top: 1px solid var(--pi-border); background: var(--pi-bg); white-space: nowrap; overflow: hidden; }
|
|
408
|
-
span { overflow: hidden; text-overflow: ellipsis; }
|
|
409
|
-
.workspace-label { min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; max-width: 100%; overflow: hidden; white-space: nowrap; }
|
|
410
|
-
.workspace-label-base, .workspace-label-item, .workspace-label-render { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
411
|
-
.workspace-label-item, .workspace-label-render, .workspace-label-separator { color: var(--pi-muted); }
|
|
412
|
-
.workspace-label-link { color: var(--pi-accent); text-decoration: none; }
|
|
413
|
-
.workspace-label-link:hover, .workspace-label-link:focus { text-decoration: underline; }
|
|
414
|
-
.bar > span:first-child { flex: 1 1 auto; min-width: 80px; }
|
|
415
|
-
.activity { display: inline-flex; align-items: center; gap: 6px; color: var(--pi-muted); }
|
|
416
|
-
.activity.active { color: var(--pi-success); }
|
|
417
|
-
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .45; flex: 0 0 auto; }
|
|
418
|
-
.activity.active .dot { animation: pulse 1s ease-in-out infinite; opacity: 1; }
|
|
419
|
-
.muted { color: var(--pi-dim); }
|
|
420
|
-
@keyframes pulse { 0%, 100% { transform: scale(.75); opacity: .55; } 50% { transform: scale(1.2); opacity: 1; } }
|
|
421
|
-
`,zd=j`
|
|
422
|
-
:host { display: block; }
|
|
423
|
-
.menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 10; max-height: 260px; overflow: auto; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); box-shadow: 0 10px 30px var(--pi-shadow); }
|
|
424
|
-
button { display: grid; grid-template-columns: minmax(120px, 1fr) auto; gap: 4px 10px; width: 100%; border: 0; border-bottom: 1px solid var(--pi-border); border-radius: 0; background: transparent; color: var(--pi-text); padding: 8px 10px; text-align: left; cursor: pointer; }
|
|
425
|
-
button:last-child { border-bottom: 0; }
|
|
426
|
-
button.selected, button:hover { background: var(--pi-selection-bg); }
|
|
427
|
-
span { color: var(--pi-muted); font-size: 12px; }
|
|
428
|
-
small { grid-column: 1 / -1; color: var(--pi-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
429
|
-
`,Kr=j`
|
|
430
|
-
:host { position: fixed; inset: 0; z-index: 10; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
431
|
-
.backdrop { display: grid; place-items: center; width: 100%; height: 100%; background: var(--pi-overlay); }
|
|
432
|
-
section { width: min(720px, calc(100vw - 40px)); max-height: min(640px, calc(100vh - 40px)); display: flex; flex-direction: column; border: 1px solid var(--pi-border); border-radius: 12px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); overflow: hidden; }
|
|
433
|
-
header { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
434
|
-
.options { min-height: 0; overflow: auto; outline: none; }
|
|
435
|
-
button { border: 0; background: transparent; color: var(--pi-text); cursor: pointer; }
|
|
436
|
-
header button { font-size: 20px; color: var(--pi-muted); }
|
|
437
|
-
input { margin: 10px 12px; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); color: var(--pi-text); font: 14px system-ui, sans-serif; padding: 8px 10px; outline: none; }
|
|
438
|
-
input:focus { border-color: var(--pi-accent); }
|
|
439
|
-
.options button { display: block; width: 100%; padding: 10px 12px; border-bottom: 1px solid var(--pi-border-muted); text-align: left; }
|
|
440
|
-
.options button.selected, .options button:hover { background: var(--pi-selection-bg); }
|
|
441
|
-
small { display: block; margin-top: 4px; color: var(--pi-muted); }
|
|
442
|
-
.empty { padding: 24px; color: var(--pi-muted); text-align: center; }
|
|
443
|
-
`,qd=j`
|
|
444
|
-
:host { position: fixed; inset: 0; z-index: 20; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
445
|
-
.backdrop { --palette-top: min(12dvh, 90px); --palette-bottom: max(20px, env(safe-area-inset-bottom)); display: grid; align-items: start; justify-items: center; width: 100%; height: 100dvh; background: var(--pi-overlay); padding: var(--palette-top) 20px var(--palette-bottom); box-sizing: border-box; overflow: hidden; }
|
|
446
|
-
section { width: min(720px, 100%); max-height: min(640px, calc(100dvh - var(--palette-top) - var(--palette-bottom))); display: flex; flex-direction: column; border: 1px solid var(--pi-border); border-radius: 12px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); overflow: hidden; }
|
|
447
|
-
header { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px; border-bottom: 1px solid var(--pi-border); }
|
|
448
|
-
input { min-width: 0; border: 0; outline: none; background: transparent; color: var(--pi-text); font: 16px system-ui, sans-serif; padding: 8px; }
|
|
449
|
-
input::placeholder { color: var(--pi-dim); }
|
|
450
|
-
button { border: 0; background: transparent; color: var(--pi-text); cursor: pointer; }
|
|
451
|
-
header button { color: var(--pi-muted); font-size: 22px; padding: 2px 8px; }
|
|
452
|
-
.options { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
|
453
|
-
.options button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; width: 100%; padding: 10px 12px; border-bottom: 1px solid var(--pi-border-muted); text-align: left; }
|
|
454
|
-
.options button.selected, .options button:hover { background: var(--pi-selection-bg); }
|
|
455
|
-
.main { min-width: 0; }
|
|
456
|
-
strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
457
|
-
small { display: block; color: var(--pi-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
458
|
-
.group { grid-column: 1 / -1; font-size: 12px; }
|
|
459
|
-
kbd { align-self: center; border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-muted); padding: 2px 6px; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
|
|
460
|
-
.empty { padding: 24px; color: var(--pi-muted); text-align: center; }
|
|
461
|
-
`,Hd=j`
|
|
462
|
-
:host { position: relative; z-index: 5; display: block; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
463
|
-
footer { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px; border-top: 1px solid var(--pi-border); }
|
|
464
|
-
footer.shell-mode { border-top-color: var(--pi-success); background: var(--pi-success-bg); }
|
|
465
|
-
.editor-wrap { position: relative; min-width: 0; }
|
|
466
|
-
.actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: nowrap; white-space: nowrap; }
|
|
467
|
-
.compact-status { display: flex; min-width: 0; align-items: center; gap: 6px; color: var(--pi-muted); font-size: 12px; flex: 1 1 0; }
|
|
468
|
-
.compact-status > button { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
469
|
-
.select-model { max-width: min(42vw, 320px); }
|
|
470
|
-
.select-thinking { max-width: 110px; }
|
|
471
|
-
textarea, .markdown-editor .cm-editor { box-sizing: border-box; width: 100%; min-height: 54px; max-height: 220px; resize: none; overflow: hidden; border-radius: 8px; border: 1px solid var(--pi-border); background: var(--pi-bg); color: var(--pi-text); font: 16px/1.4 system-ui, sans-serif; }
|
|
472
|
-
textarea { overflow-y: auto; padding: 8px; }
|
|
473
|
-
.markdown-editor .cm-scroller { max-height: 220px; overflow-y: auto; font-family: system-ui, sans-serif; line-height: 1.4; }
|
|
474
|
-
.markdown-editor .cm-content { min-height: 38px; padding: 8px; caret-color: var(--pi-text); }
|
|
475
|
-
.markdown-editor .cm-line { padding: 0; }
|
|
476
|
-
.markdown-editor .cm-placeholder { color: var(--pi-dim); }
|
|
477
|
-
.markdown-editor .cm-focused { outline: none; }
|
|
478
|
-
.shell-mode textarea, .shell-mode .markdown-editor .cm-editor { border-color: var(--pi-success); box-shadow: 0 0 0 1px var(--pi-success-ring); }
|
|
479
|
-
.mode-hint { position: absolute; right: 8px; bottom: 8px; max-width: calc(100% - 16px); border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 2px 8px; font-size: 12px; pointer-events: none; }
|
|
480
|
-
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
481
|
-
button:disabled, textarea:disabled, .markdown-editor-disabled .cm-editor { opacity: .5; cursor: not-allowed; }
|
|
482
|
-
@media (max-width: 640px) {
|
|
483
|
-
footer { gap: 8px; padding: 8px; }
|
|
484
|
-
.actions { gap: 6px; }
|
|
485
|
-
.compact-status { flex: 1 1 220px; gap: 4px; }
|
|
486
|
-
.select-model { max-width: min(58vw, 260px); }
|
|
487
|
-
button { padding: 6px 8px; }
|
|
488
|
-
}
|
|
489
|
-
@media (max-width: 430px) {
|
|
490
|
-
.compact-status { flex-basis: 170px; font-size: 11px; }
|
|
491
|
-
.select-model { max-width: 48vw; }
|
|
492
|
-
.select-thinking { max-width: 70px; }
|
|
493
|
-
button { padding: 5px 7px; }
|
|
494
|
-
}
|
|
495
|
-
`;var Ud=Object.defineProperty,Vd=Object.getOwnPropertyDescriptor,J=(e,t,s,i)=>{for(var r=i>1?void 0:i?Vd(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&Ud(t,s,r),r};let H=class extends C{constructor(){super(...arguments),this.projects=[],this.activities={},this.workspacesByProjectId={},this.collapsible=!1,this.collapsed=!1,this.menuStyle="",this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.openMenuProjectId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has("projects")&&this.openMenuProjectId!==void 0&&!this.projects.some(t=>t.id===this.openMenuProjectId)&&(this.openMenuProjectId=void 0),e.has("collapsed")&&this.collapsed&&(this.openMenuProjectId=void 0)}render(){return c`
|
|
496
|
-
<section>
|
|
497
|
-
<h2>${this.renderHeading()}</h2>
|
|
498
|
-
${this.collapsed?null:c`
|
|
499
|
-
<div class="list-body">
|
|
500
|
-
${this.projects.map(e=>c`
|
|
501
|
-
<div
|
|
502
|
-
class=${`action-row ${this.selected?.id===e.id?"selected":""}`}
|
|
503
|
-
tabindex="0"
|
|
504
|
-
title=${e.path}
|
|
505
|
-
@click=${t=>{Os(t,()=>this.onSelect?.(e))}}
|
|
506
|
-
@keydown=${t=>{Ws(t,()=>this.onSelect?.(e))}}
|
|
507
|
-
>
|
|
508
|
-
<div class="action-main">
|
|
509
|
-
<span class="action-name">${e.name}</span><small>${this.renderActivity(e)}${e.path}</small>
|
|
510
|
-
</div>
|
|
511
|
-
<div class="action-menu">
|
|
512
|
-
<button class="action-menu-toggle" title="Project actions" aria-label=${`Actions for ${e.name}`} @click=${t=>{t.stopPropagation(),this.toggleMenu(e.id,t.currentTarget)}}>⋯</button>
|
|
513
|
-
${this.openMenuProjectId===e.id?c`
|
|
514
|
-
<div class="action-menu-panel" style=${this.menuStyle}>
|
|
515
|
-
<button title="Close project" @click=${()=>{this.close(e)}}>Close</button>
|
|
516
|
-
</div>
|
|
517
|
-
`:null}
|
|
518
|
-
</div>
|
|
519
|
-
</div>
|
|
520
|
-
`)}
|
|
521
|
-
</div>
|
|
522
|
-
`}
|
|
523
|
-
</section>
|
|
524
|
-
`}renderHeading(){if(!this.collapsible)return"Projects";const e=this.selected?.name??"No project selected",t=this.selected?.path??e;return c`<button class="section-toggle" aria-expanded=${String(!this.collapsed)} @click=${()=>{this.onToggleCollapsed?.()}}><span class="section-title"><span class="section-name">${this.collapsed?"▸":"▾"} Projects</span><small class="section-selected" title=${t}>${e}</small></span><small class="section-count">${this.projects.length}</small></button>`}renderActivity(e){const t=Md(e,this.workspacesByProjectId[e.id]??[],this.activities);return Ls(t,t==="terminal"?"Project terminal active":"Project active")??""}toggleMenu(e,t){if(this.openMenuProjectId===e){this.openMenuProjectId=void 0;return}this.menuStyle=Bt(t),this.openMenuProjectId=e}close(e){this.openMenuProjectId=void 0,confirm(`Close ${e.name}?
|
|
525
|
-
|
|
526
|
-
This only removes it from PI WEB; it will not change the project folder.`)&&this.onClose?.(e)}};H.styles=js;J([p({attribute:!1})],H.prototype,"projects",2);J([p({attribute:!1})],H.prototype,"selected",2);J([p({attribute:!1})],H.prototype,"activities",2);J([p({attribute:!1})],H.prototype,"workspacesByProjectId",2);J([p({type:Boolean,reflect:!0})],H.prototype,"collapsible",2);J([p({type:Boolean,reflect:!0})],H.prototype,"collapsed",2);J([p({attribute:!1})],H.prototype,"onSelect",2);J([p({attribute:!1})],H.prototype,"onClose",2);J([p({attribute:!1})],H.prototype,"onToggleCollapsed",2);J([k()],H.prototype,"openMenuProjectId",2);J([k()],H.prototype,"menuStyle",2);H=J([M("project-list")],H);function Qr(e,t=[],s){return c`
|
|
527
|
-
<span class="workspace-label">
|
|
528
|
-
<span class="workspace-label-base" title=${s??e}>${e}</span>
|
|
529
|
-
${Gd(t)}
|
|
530
|
-
</span>
|
|
531
|
-
`}function Gd(e=[]){return e.map(t=>c`<span class="workspace-label-separator">·</span>${Jr(t)}`)}function ji(e=[]){return e.map((t,s)=>c`${s===0?null:c`<span class="workspace-label-separator">·</span>`}${Jr(t)}`)}function Jr(e){if(e.type==="render")return c`<span class="workspace-label-render">${e.render()}</span>`;if(e.type==="link"&&Kd(e.href)){const t=e.target??"_blank",s=t==="_blank"?"noopener noreferrer":void 0;return c`<a class="workspace-label-item workspace-label-link" href=${e.href} title=${e.title??e.text} target=${t} rel=${s??void 0}>${e.text}</a>`}return c`<span class="workspace-label-item" title=${e.title??e.text}>${e.text}</span>`}function Kd(e){const t=e.trim().toLowerCase();return t!==""&&!t.startsWith("javascript:")&&!t.startsWith("data:")}var Qd=Object.defineProperty,Jd=Object.getOwnPropertyDescriptor,G=(e,t,s,i)=>{for(var r=i>1?void 0:i?Jd(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&Qd(t,s,r),r};let q=class extends C{constructor(){super(...arguments),this.workspaces=[],this.collapsible=!1,this.collapsed=!1,this.workspaceLabelItems=()=>[],this.activities={},this.deletingWorkspaceIds=[],this.menuStyle="",this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.openMenuWorkspaceId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has("workspaces")&&this.openMenuWorkspaceId!==void 0&&!this.workspaces.some(t=>t.id===this.openMenuWorkspaceId)&&(this.openMenuWorkspaceId=void 0),e.has("collapsed")&&this.collapsed&&(this.openMenuWorkspaceId=void 0),(e.has("selected")||e.has("workspaces")||e.has("collapsed"))&&!this.collapsed&&this.scrollSelectedIntoView()}render(){return c`
|
|
532
|
-
<section>
|
|
533
|
-
<h2>${this.renderHeading()}</h2>
|
|
534
|
-
${this.collapsed?null:c`
|
|
535
|
-
<div class="list-body">
|
|
536
|
-
${this.workspaces.map(e=>{const t=Zd(e),s=this.workspaceLabelItems(e);return c`
|
|
537
|
-
<div
|
|
538
|
-
class=${`action-row workspace-row ${this.selected?.id===e.id?"selected":""}`}
|
|
539
|
-
tabindex="0"
|
|
540
|
-
title=${t}
|
|
541
|
-
@click=${i=>{Os(i,()=>this.onSelect?.(e))}}
|
|
542
|
-
@keydown=${i=>{this.handleWorkspaceKeydown(i,e)}}
|
|
543
|
-
>
|
|
544
|
-
<div class="action-main">
|
|
545
|
-
${this.renderWorkspaceMain(t,s,e)}
|
|
546
|
-
</div>
|
|
547
|
-
${this.renderWorkspaceMenu(t,s,e)}
|
|
548
|
-
</div>
|
|
549
|
-
`})}
|
|
550
|
-
</div>
|
|
551
|
-
`}
|
|
552
|
-
</section>
|
|
553
|
-
`}renderHeading(){if(!this.collapsible)return"Workspaces";const e=this.selected===void 0?"No workspace selected":`${this.selected.label}${this.selected.isMain?" · main":""} · ${this.selected.path}`,t=this.selected?.path??e;return c`<button class="section-toggle" aria-expanded=${String(!this.collapsed)} @click=${()=>{this.onToggleCollapsed?.()}}><span class="section-title"><span class="section-name">${this.collapsed?"▸":"▾"} Workspaces</span><small class="section-selected" title=${t}>${e}</small></span><small class="section-count">${this.workspaces.length}</small></button>`}renderActivity(e){const t=Rd(Id(e,this.activities));return Ls(t,t==="terminal"?"Workspace terminal active":"Workspace active")}renderWorkspaceMain(e,t,s){return c`
|
|
554
|
-
<span class="workspace-primary">
|
|
555
|
-
${this.renderActivity(s)}
|
|
556
|
-
<span class="workspace-primary-label">${e}</span>
|
|
557
|
-
${this.isDeleting(s)?c`<span class="workspace-status">Deleting…</span>`:null}
|
|
558
|
-
</span>
|
|
559
|
-
${t.length===0?null:c`
|
|
560
|
-
<small class="workspace-secondary">
|
|
561
|
-
<span class="workspace-label">${ji(t)}</span>
|
|
562
|
-
</small>
|
|
563
|
-
`}
|
|
564
|
-
`}renderWorkspaceMenu(e,t,s){const i=this.openMenuWorkspaceId===s.id,r=Yd(s.id);return c`
|
|
565
|
-
<div class="action-menu">
|
|
566
|
-
<button
|
|
567
|
-
class="action-menu-toggle"
|
|
568
|
-
title="Workspace actions and details"
|
|
569
|
-
aria-label=${`Actions and details for ${e}`}
|
|
570
|
-
aria-expanded=${String(i)}
|
|
571
|
-
aria-controls=${r}
|
|
572
|
-
@click=${o=>{o.stopPropagation(),this.toggleMenu(s.id,o.currentTarget)}}
|
|
573
|
-
>⋯</button>
|
|
574
|
-
${i?c`
|
|
575
|
-
<div class="action-menu-panel workspace-menu-panel" id=${r} style=${this.menuStyle} @click=${o=>{o.stopPropagation()}}>
|
|
576
|
-
${this.renderWorkspaceActions(s)}
|
|
577
|
-
${this.renderWorkspaceDetails(e,t,s)}
|
|
578
|
-
</div>
|
|
579
|
-
`:null}
|
|
580
|
-
</div>
|
|
581
|
-
`}renderWorkspaceActions(e){if(!Xd(e))return;const t=this.isDeleting(e);return c`
|
|
582
|
-
<div class="workspace-menu-actions">
|
|
583
|
-
<button class="danger" title=${t?"Workspace deletion in progress":"Delete workspace"} ?disabled=${t} @click=${()=>{this.delete(e)}}>${t?"Deleting…":"Delete workspace"}</button>
|
|
584
|
-
</div>
|
|
585
|
-
`}renderWorkspaceDetails(e,t,s){return c`
|
|
586
|
-
<dl class="workspace-menu-details">
|
|
587
|
-
<div class="workspace-detail-row">
|
|
588
|
-
<dt>${s.branch===void 0?"Workspace":"Branch"}</dt>
|
|
589
|
-
<dd>${e}</dd>
|
|
590
|
-
</div>
|
|
591
|
-
<div class="workspace-detail-row">
|
|
592
|
-
<dt>Path</dt>
|
|
593
|
-
<dd title=${s.path}>${s.path}</dd>
|
|
594
|
-
</div>
|
|
595
|
-
${t.length===0?null:c`
|
|
596
|
-
<div class="workspace-detail-row">
|
|
597
|
-
<dt>Details</dt>
|
|
598
|
-
<dd><span class="workspace-label">${ji(t)}</span></dd>
|
|
599
|
-
</div>
|
|
600
|
-
`}
|
|
601
|
-
</dl>
|
|
602
|
-
`}delete(e){this.isDeleting(e)||(this.openMenuWorkspaceId=void 0,this.onDelete?.(e))}isDeleting(e){return this.deletingWorkspaceIds.includes(e.id)}toggleMenu(e,t){if(this.openMenuWorkspaceId===e){this.openMenuWorkspaceId=void 0;return}this.menuStyle=Bt(t),this.openMenuWorkspaceId=e}handleWorkspaceKeydown(e,t){if(e.key==="Escape"&&this.openMenuWorkspaceId===t.id){e.preventDefault(),e.stopPropagation(),this.openMenuWorkspaceId=void 0;return}Ws(e,()=>this.onSelect?.(t))}scrollSelectedIntoView(){this.renderRoot.querySelector(".action-row.selected")?.scrollIntoView({block:"nearest"})}};q.styles=js;G([p({attribute:!1})],q.prototype,"workspaces",2);G([p({attribute:!1})],q.prototype,"selected",2);G([p({type:Boolean,reflect:!0})],q.prototype,"collapsible",2);G([p({type:Boolean,reflect:!0})],q.prototype,"collapsed",2);G([p({attribute:!1})],q.prototype,"workspaceLabelItems",2);G([p({attribute:!1})],q.prototype,"activities",2);G([p({attribute:!1})],q.prototype,"deletingWorkspaceIds",2);G([p({attribute:!1})],q.prototype,"onSelect",2);G([p({attribute:!1})],q.prototype,"onDelete",2);G([p({attribute:!1})],q.prototype,"onToggleCollapsed",2);G([k()],q.prototype,"openMenuWorkspaceId",2);G([k()],q.prototype,"menuStyle",2);q=G([M("workspace-list")],q);function Zd(e){return`${e.branch??e.label}${e.isMain?" · main":""}`}function Xd(e){return e.isGitWorktree&&!e.isMain}function Yd(e){return`workspace-menu-${e.replace(/[^a-zA-Z0-9_-]/g,"-")}`}var ep=Object.defineProperty,tp=Object.getOwnPropertyDescriptor,D=(e,t,s,i)=>{for(var r=i>1?void 0:i?tp(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&ep(t,s,r),r};function Yt(e){return e.name!==void 0&&e.name!==""?e.name:e.firstMessage!==""?e.firstMessage:e.id.slice(0,8)}let I=class extends C{constructor(){super(...arguments),this.sessions=[],this.statuses={},this.activities={},this.canStart=!1,this.collapsible=!1,this.collapsed=!1,this.menuStyle="",this.archivedExpanded=!1,this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.openMenuSessionId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has("sessions")&&this.openMenuSessionId!==void 0&&!this.sessions.some(s=>s.id===this.openMenuSessionId)&&(this.openMenuSessionId=void 0),e.has("collapsed")&&this.collapsed&&(this.openMenuSessionId=void 0),e.has("sessions")&&!this.sessions.some(s=>s.archived===!0)&&(this.archivedExpanded=!1);const t=e.get("selected");if(e.has("selected")&&this.selected?.archived===!0&&(t?.id!==this.selected.id||t.archived!==!0)&&!this.archivedExpanded){this.archivedExpanded=!0,this.updateComplete.then(()=>{this.scrollSelectedIntoView()});return}(e.has("selected")||e.has("sessions")||e.has("collapsed"))&&!this.collapsed&&this.scrollSelectedIntoView()}render(){const e=ip(this.sessions),t=new Set(e.map(r=>r.session.id)),s=Zr(this.sessions.filter(r=>r.archived===!0&&!t.has(r.id))),i=sp(this.sessions);return c`
|
|
603
|
-
<section>
|
|
604
|
-
${this.renderHeading(e.length+s.length)}
|
|
605
|
-
${this.collapsed?null:c`
|
|
606
|
-
<div class="list-body">
|
|
607
|
-
${e.map(r=>this.renderSession(r,i.get(r.session.id)??0))}
|
|
608
|
-
${s.length>0?c`
|
|
609
|
-
<h2 class="subheading"><button class="section-toggle" aria-expanded=${String(this.archivedExpanded)} @click=${()=>{this.toggleArchived()}}><span>${this.archivedExpanded?"▾":"▸"} Archived</span><small>${s.length}</small></button></h2>
|
|
610
|
-
${this.archivedExpanded?s.map(r=>this.renderSession(r,i.get(r.session.id)??0)):null}
|
|
611
|
-
`:null}
|
|
612
|
-
</div>
|
|
613
|
-
`}
|
|
614
|
-
</section>
|
|
615
|
-
`}renderHeading(e){if(!this.collapsible)return c`<h2>Sessions <button ?disabled=${!this.canStart} @click=${()=>this.onStart?.()}>+</button></h2>`;const t=this.selected===void 0?"No session selected":Yt(this.selected),s=this.selected?.path??t;return c`
|
|
616
|
-
<h2>
|
|
617
|
-
<button class="section-toggle" aria-expanded=${String(!this.collapsed)} @click=${()=>{this.onToggleCollapsed?.()}}><span class="section-title"><span class="section-name">${this.collapsed?"▸":"▾"} Sessions</span><small class="section-selected" title=${s}>${t}</small></span><small class="section-count">${e}</small></button>
|
|
618
|
-
<button ?disabled=${!this.canStart} @click=${i=>{i.stopPropagation(),this.onStart?.()}}>+</button>
|
|
619
|
-
</h2>
|
|
620
|
-
`}renderSession(e,t){const{session:s}=e,i=Math.min(e.depth,2);return c`
|
|
621
|
-
<div
|
|
622
|
-
class="action-row ${this.selected?.id===s.id?"selected":""} ${s.archived===!0?"archived":""}"
|
|
623
|
-
style=${`--depth:${String(i)}`}
|
|
624
|
-
tabindex="0"
|
|
625
|
-
title=${s.path}
|
|
626
|
-
@click=${r=>{Os(r,()=>this.onSelect?.(s))}}
|
|
627
|
-
@keydown=${r=>{Ws(r,()=>this.onSelect?.(s))}}
|
|
628
|
-
>
|
|
629
|
-
<div class="action-main">
|
|
630
|
-
<span class="action-name">${e.depth>0?c`<span class="tree-marker">↳</span>`:null}${Yt(s)}${e.depth>2?c` <span class="badge">depth ${e.depth}</span>`:null}${e.hasMissingParent?c` <span class="badge">parent unavailable</span>`:null}</span><small>${this.renderStatus(s)}${String(s.messageCount)} messages</small>
|
|
631
|
-
</div>
|
|
632
|
-
<div class="action-menu">
|
|
633
|
-
<button class="action-menu-toggle" title="Session actions" @click=${r=>{r.stopPropagation(),this.toggleMenu(s.id,r.currentTarget)}}>⋯</button>
|
|
634
|
-
${this.openMenuSessionId===s.id?c`
|
|
635
|
-
<div class="action-menu-panel" style=${this.menuStyle}>
|
|
636
|
-
${s.parentSessionPath!==void 0?c`<button title="Detach from parent" @click=${()=>{this.openMenuSessionId=void 0,this.onDetachParent?.(s)}}>Detach from parent</button>`:null}
|
|
637
|
-
${ae(s)?c`<button title="Delete browser-cached new session" @click=${()=>{this.openMenuSessionId=void 0,this.onDelete?.(s)}}>Delete</button>`:s.archived===!0?c`<button title="Restore session" @click=${()=>{this.openMenuSessionId=void 0,this.onRestore?.(s)}}>Restore</button>`:c`
|
|
638
|
-
<button title="Archive session" @click=${()=>{this.openMenuSessionId=void 0,this.onArchive?.(s)}}>Archive</button>
|
|
639
|
-
${t>0?c`<button title="Archive this session and its descendants" @click=${()=>{this.openMenuSessionId=void 0,this.confirmArchiveWithDescendants(s,t)}}>Archive with descendants (${t})</button>`:null}
|
|
640
|
-
`}
|
|
641
|
-
</div>
|
|
642
|
-
`:null}
|
|
643
|
-
</div>
|
|
644
|
-
</div>
|
|
645
|
-
`}confirmArchiveWithDescendants(e,t){const s=t===1?"descendant session":"descendant sessions";confirm(`Archive “${Yt(e)}” and ${String(t)} ${s}?`)&&this.onArchiveWithDescendants?.(e)}toggleMenu(e,t){if(this.openMenuSessionId===e){this.openMenuSessionId=void 0;return}this.menuStyle=Bt(t),this.openMenuSessionId=e}toggleArchived(){this.archivedExpanded=!this.archivedExpanded,this.archivedExpanded||(this.openMenuSessionId=void 0,this.onArchivedCollapsed?.())}scrollSelectedIntoView(){this.renderRoot.querySelector(".action-row.selected")?.scrollIntoView({block:"nearest"})}renderStatus(e){return ae(e)?"new · ":e.archived===!0?"read-only · ":Ls(Nt(this.statuses[e.id],this.activities[e.id])?"session":void 0,"Session active")??""}};I.styles=js;D([p({attribute:!1})],I.prototype,"sessions",2);D([p({attribute:!1})],I.prototype,"statuses",2);D([p({attribute:!1})],I.prototype,"activities",2);D([p({attribute:!1})],I.prototype,"selected",2);D([p({type:Boolean})],I.prototype,"canStart",2);D([p({type:Boolean,reflect:!0})],I.prototype,"collapsible",2);D([p({type:Boolean,reflect:!0})],I.prototype,"collapsed",2);D([p({attribute:!1})],I.prototype,"onSelect",2);D([p({attribute:!1})],I.prototype,"onStart",2);D([p({attribute:!1})],I.prototype,"onToggleCollapsed",2);D([p({attribute:!1})],I.prototype,"onArchivedCollapsed",2);D([k()],I.prototype,"openMenuSessionId",2);D([k()],I.prototype,"menuStyle",2);D([k()],I.prototype,"archivedExpanded",2);D([p({attribute:!1})],I.prototype,"onArchive",2);D([p({attribute:!1})],I.prototype,"onArchiveWithDescendants",2);D([p({attribute:!1})],I.prototype,"onRestore",2);D([p({attribute:!1})],I.prototype,"onDelete",2);D([p({attribute:!1})],I.prototype,"onDetachParent",2);I=D([M("session-list")],I);function sp(e){const t=new Map;for(const i of e){if(i.parentSessionPath===void 0)continue;const r=t.get(i.parentSessionPath)??[];r.push(i),t.set(i.parentSessionPath,r)}const s=(i,r)=>{if(r.has(i.path))return 0;const o=new Set(r);o.add(i.path);let n=0;for(const a of t.get(i.path)??[])o.has(a.path)||(a.archived!==!0&&(n+=1),n+=s(a,o));return n};return new Map(e.map(i=>[i.id,s(i,new Set)]))}function ip(e){const t=new Map(e.map(i=>[i.path,i])),s=new Set;for(const i of e){if(i.archived===!0)continue;s.add(i.id);let r=i.parentSessionPath;const o=new Set([i.path]);for(;r!==void 0&&!o.has(r);){o.add(r);const n=t.get(r);if(n===void 0)break;s.add(n.id),r=n.parentSessionPath}}return Zr(e.filter(i=>s.has(i.id)))}function Zr(e){const t=new Map(e.map(n=>[n.path,n])),s=new Map,i=[];for(const n of e){const a=n.parentSessionPath,l=a===void 0?void 0:t.get(a);if(l===void 0){i.push(n);continue}const d=s.get(l.path)??[];d.push(n),s.set(l.path,d)}const r=[],o=(n,a,l)=>{if(l.has(n.path))return;const d=n.parentSessionPath;r.push({session:n,depth:a,hasMissingParent:d!==void 0&&!t.has(d)});const u=new Set(l);u.add(n.path);for(const h of s.get(n.path)??[])o(h,a+1,u)};for(const n of i)o(n,0,new Set);return r}const Ns={CHILD:2,ELEMENT:6},Fs=e=>(...t)=>({_$litDirective$:e,values:t});let Bs=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,s,i){this._$Ct=t,this._$AM=s,this._$Ci=i}_$AS(t,s){return this.update(t,s)}update(t,s){return this.render(...s)}};const{I:rp}=Qo,Ni=e=>e,Fi=()=>document.createComment(""),Je=(e,t,s)=>{const i=e._$AA.parentNode,r=t===void 0?e._$AB:t._$AA;if(s===void 0){const o=i.insertBefore(Fi(),r),n=i.insertBefore(Fi(),r);s=new rp(o,n,e,e.options)}else{const o=s._$AB.nextSibling,n=s._$AM,a=n!==e;if(a){let l;s._$AQ?.(e),s._$AM=e,s._$AP!==void 0&&(l=e._$AU)!==n._$AU&&s._$AP(l)}if(o!==r||a){let l=s._$AA;for(;l!==o;){const d=Ni(l).nextSibling;Ni(i).insertBefore(l,r),l=d}}}return s},xe=(e,t,s=e)=>(e._$AI(t,s),e),op={},np=(e,t=op)=>e._$AH=t,ap=e=>e._$AH,es=e=>{e._$AR(),e._$AA.remove()};const Bi=(e,t,s)=>{const i=new Map;for(let r=t;r<=s;r++)i.set(e[r],r);return i},lp=Fs(class extends Bs{constructor(e){if(super(e),e.type!==Ns.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,s){let i;s===void 0?s=t:t!==void 0&&(i=t);const r=[],o=[];let n=0;for(const a of e)r[n]=i?i(a,n):n,o[n]=s(a,n),n++;return{values:o,keys:r}}render(e,t,s){return this.dt(e,t,s).values}update(e,[t,s,i]){const r=ap(e),{values:o,keys:n}=this.dt(t,s,i);if(!Array.isArray(r))return this.ut=n,o;const a=this.ut??=[],l=[];let d,u,h=0,f=r.length-1,g=0,b=o.length-1;for(;h<=f&&g<=b;)if(r[h]===null)h++;else if(r[f]===null)f--;else if(a[h]===n[g])l[g]=xe(r[h],o[g]),h++,g++;else if(a[f]===n[b])l[b]=xe(r[f],o[b]),f--,b--;else if(a[h]===n[b])l[b]=xe(r[h],o[b]),Je(e,l[b+1],r[h]),h++,b--;else if(a[f]===n[g])l[g]=xe(r[f],o[g]),Je(e,r[h],r[f]),f--,g++;else if(d===void 0&&(d=Bi(n,g,b),u=Bi(a,h,f)),d.has(a[h]))if(d.has(a[f])){const L=u.get(n[g]),Ee=L!==void 0?r[L]:null;if(Ee===null){const He=Je(e,r[h]);xe(He,o[g]),l[g]=He}else l[g]=xe(Ee,o[g]),Je(e,r[h],Ee),r[L]=null;g++}else es(r[f]),f--;else es(r[h]),h++;for(;g<=b;){const L=Je(e,l[b+1]);xe(L,o[g]),l[g++]=L}for(;h<=f;){const L=r[h++];L!==null&&es(L)}return this.ut=n,np(e,l),ve}}),cp="pi-web:chat-groups:",dp={read(e){try{if(typeof localStorage>"u")return;const t=localStorage.getItem(zi(e));return t===null||t===""?void 0:hp(JSON.parse(t))}catch{return}},write(e,t){try{if(typeof localStorage>"u")return;localStorage.setItem(zi(e),JSON.stringify(t))}catch{}}};class pp{constructor(t=dp){this.storage=t,this.sessionId="",this.openGroupKeys=new Set,this.closedDefaultOpenGroupKeys=new Set}syncSession(t){if(this.sessionId===t)return;this.sessionId=t;const s=t===""?void 0:this.storage.read(t);this.openGroupKeys=new Set(s?.open??[]),this.closedDefaultOpenGroupKeys=new Set(s?.closedDefaultOpen??[])}isOpen(t,s){return s?!this.closedDefaultOpenGroupKeys.has(t):this.openGroupKeys.has(t)}applyToggle(t,s,i){const r=this.isOpen(t,i),o=new Set(this.openGroupKeys),n=new Set(this.closedDefaultOpenGroupKeys);return i?(o.delete(t),s?n.delete(t):n.add(t)):(n.delete(t),s?o.add(t):o.delete(t)),(i?!n.has(t):o.has(t))===r&&qi(o,this.openGroupKeys)&&qi(n,this.closedDefaultOpenGroupKeys)?!1:(this.openGroupKeys=o,this.closedDefaultOpenGroupKeys=n,this.persist(),!0)}snapshot(){return{open:[...this.openGroupKeys],closedDefaultOpen:[...this.closedDefaultOpenGroupKeys]}}persist(){this.sessionId!==""&&this.storage.write(this.sessionId,this.snapshot())}}function zi(e){return`${cp}${e}`}function hp(e){if(Array.isArray(e))return{open:ts(e),closedDefaultOpen:[]};if(up(e))return{open:Array.isArray(e.open)?ts(e.open):[],closedDefaultOpen:Array.isArray(e.closedDefaultOpen)?ts(e.closedDefaultOpen):[]}}function ts(e){return e.filter(t=>typeof t=="string")}function qi(e,t){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}function up(e){return typeof e=="object"&&e!==null}function fp(e,t=0){const s=[];let i=[],r=0;const o=(a,l)=>{i.length||(r=l),i.push(a)},n=()=>{i.length&&(s.push({kind:"group",messages:i,startIndex:r,endIndex:r+i.length-1}),i=[])};return e.forEach((a,l)=>{const d=a.parts.filter(g=>Hi(a,g)),u=a.parts.filter(g=>!Hi(a,g)),h=t+l,f={...a.source===void 0?{}:{source:a.source},...a.meta===void 0?{}:{meta:a.meta}};if(u.length&&o({role:a.role,parts:u,...f},h),d.length){n();const g=d.every(b=>b.type==="skillRead")?"skill":a.role;s.push({kind:"message",message:{role:g,parts:d,...f},index:h})}}),n(),s}function mp(e){if(e.every(i=>i.source==="compaction"))return`${String(e.length)} history compaction ${e.length===1?"summary":"summaries"}`;if(e.every(i=>i.source==="branch_summary"))return`${String(e.length)} branch ${e.length===1?"summary":"summaries"}`;const t=e.reduce((i,r)=>(i[r.role]=(i[r.role]??0)+1,i),{}),s=Object.entries(t).map(([i,r])=>`${String(r)} ${i}`).join(" · ");return`${String(e.length)} ${e.length===1?"event":"events"}${s!==""?` · ${s}`:""}`}function Hi(e,t){return e.source==="compaction"||e.source==="branch_summary"?!1:t.type==="skillInvocation"||t.type==="skillRead"?!0:t.type==="text"&&(e.role==="user"||e.role==="assistant"||e.role==="system"||e.role==="bash")}const gp=30;function vp(e,t){const s=wp(kp(e,t)),i={distanceFromBottom:e.scrollHeight-e.scrollTop};return s===void 0?i:{...i,markerId:s.id,markerOffset:s.offset}}function bp(e,t,s){if(s!==void 0&&t.markerOffset!==void 0){const i=s.getBoundingClientRect().top-e.getBoundingClientRect().top;e.scrollTop+=yp(i,t.markerOffset);return}e.scrollTop=xp(e.scrollHeight,t.distanceFromBottom)}function wp(e){let t,s=Number.NEGATIVE_INFINITY,i,r=Number.POSITIVE_INFINITY;for(const o of e)o.offset<=0&&o.offset>=s?(t=o,s=o.offset):o.offset>0&&o.offset<r&&(i=o,r=o.offset);return t??i}function yp(e,t){return e-t}function xp(e,t){return Math.max(0,e-t)}function kp(e,t){const s=e.getBoundingClientRect().top;return t.flatMap(i=>{const r=i.dataset.markerId;return r===void 0?[]:[{id:r,offset:i.getBoundingClientRect().top-s}]})}const Sp=600,$p=1;function Pp(e){return!e.hasMore||e.loadingMore||!e.canRequest||e.clientHeight<=0?!1:Tp(e)||Cp(e)}function Tp(e){return e.scrollTop<(e.topThreshold??Math.max(Sp,e.clientHeight))}function Cp(e){return e.scrollHeight<=e.clientHeight+$p}const Ap="pi-web:chat-scroll:",Ip=180,Rp=48,Mp=2,Ep={getItem(e){return typeof localStorage>"u"?null:localStorage.getItem(e)},setItem(e,t){typeof localStorage>"u"||localStorage.setItem(e,t)},removeItem(e){typeof localStorage>"u"||localStorage.removeItem(e)}},Dp={setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)}};class _p{constructor(t=Ep,s=Dp){this.storage=t,this.scheduler=s}dispose(){this.clearScheduledSave()}clearScheduledSave(){this.saveTimer!==void 0&&(this.scheduler.clearTimeout(this.saveTimer),this.saveTimer=void 0)}scheduleSave(t,s,i=Ip){this.clearScheduledSave(),this.saveTimer=this.scheduler.setTimeout(()=>{this.saveTimer=void 0,s(t)},i)}savePosition(t,s,i,r=Mp){if(t===""||s===void 0||!is(s))return"skipped";try{if(Yr(s,r)){const a={mode:"bottom"};return this.storage.setItem(ss(t),JSON.stringify(a)),"saved"}const o=Wp(s,i);if(o===void 0)return"skipped";const n=Op(s,o);return this.storage.setItem(ss(t),JSON.stringify(n)),"saved"}catch{return"skipped"}}restorePosition(t,s,i,r){const o=this.readPosition(t);return o===void 0?this.scrollToBottom(s):this.restoreExplicitPosition(o,s,i,r)}restoreExplicitPosition(t,s,i,r){if(t.mode==="bottom")return this.scrollToBottom(s);if(s===void 0||!is(s))return{status:"skipped"};const o=jp(i,t.anchorId);if(o===void 0)return r?.fallbackToBottom===!1?{status:"missing",position:t}:this.scrollToBottom(s);const n=s.getBoundingClientRect().top,a=o.getBoundingClientRect().top-n;return s.scrollTop+=a-t.offset,{status:"restored"}}readPosition(t){if(t!=="")try{const s=this.storage.getItem(ss(t));if(s===null||s==="")return;const i=JSON.parse(s);return Lp(i)?i:void 0}catch{return}}scrollToBottom(t){return t===void 0||!is(t)?{status:"skipped"}:(t.scrollTop=t.scrollHeight,{status:"bottom"})}}function ss(e){return`${Ap}${e}`}function Lp(e){return typeof e!="object"||e===null||!("mode"in e)?!1:e.mode==="bottom"?!0:e.mode==="anchor"&&"anchorId"in e&&typeof e.anchorId=="string"&&e.anchorId!==""&&"offset"in e&&typeof e.offset=="number"}function is(e){return e.clientHeight>0&&e.scrollHeight>0}function Xr(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function Yr(e,t=Rp){return Xr(e)<t}function Op(e,t){const s=e.getBoundingClientRect().top;return{mode:"anchor",anchorId:zs(t)??"",offset:t.getBoundingClientRect().top-s}}function Wp(e,t){const s=e.getBoundingClientRect();let i,r=Number.NEGATIVE_INFINITY,o,n=Number.POSITIVE_INFINITY;for(const a of t){if(zs(a)===void 0)continue;const l=a.getBoundingClientRect();if(l.bottom<=l.top||l.bottom<s.top||l.top>s.bottom)continue;const d=l.top-s.top;d<=0&&d>=r?(i=a,r=d):d>0&&d<n&&(o=a,n=d)}return i??o}function Ui(e,t){const s=e.getBoundingClientRect();return t.find(i=>{const r=i.getBoundingClientRect();return r.bottom>=s.top&&r.top<=s.bottom})}function jp(e,t){return e.find(s=>zs(s)===t)}function zs(e){return e.dataset.scrollAnchorId!==void 0&&e.dataset.scrollAnchorId!==""?e.dataset.scrollAnchorId:void 0}var Np=Object.defineProperty,Fp=Object.getOwnPropertyDescriptor,qs=(e,t,s,i)=>{for(var r=i>1?void 0:i?Fp(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&Np(t,s,r),r};let nt=class extends C{constructor(){super(...arguments),this.positionPercent=0,this.loadedPercent=100}render(){const e=Vi(this.positionPercent),t=Vi(this.loadedPercent),s=`Message position: about ${String(Math.round(e))}% through conversation. ${String(Math.round(t))}% of messages loaded.`;return c`
|
|
646
|
-
<div
|
|
647
|
-
class="meter"
|
|
648
|
-
style=${`--position:${e.toFixed(2)}%;`}
|
|
649
|
-
role="meter"
|
|
650
|
-
aria-label=${s}
|
|
651
|
-
aria-valuemin="0"
|
|
652
|
-
aria-valuemax="100"
|
|
653
|
-
aria-valuenow=${String(Math.round(e))}
|
|
654
|
-
title=${s}
|
|
655
|
-
>
|
|
656
|
-
<div class="track" aria-hidden="true">
|
|
657
|
-
<div class="progress"></div>
|
|
658
|
-
<div class="marker"></div>
|
|
659
|
-
</div>
|
|
660
|
-
</div>
|
|
661
|
-
`}};nt.styles=j`
|
|
662
|
-
:host { position: absolute; top: -4px; left: 16px; right: 16px; z-index: 6; display: block; height: 12px; opacity: .58; transition: opacity .15s ease; }
|
|
663
|
-
:host(:hover), :host(:focus-within) { opacity: .92; }
|
|
664
|
-
.meter { height: 100%; }
|
|
665
|
-
.track { position: relative; height: 4px; margin-top: 4px; border-radius: 999px; background: color-mix(in srgb, var(--pi-border-muted) 34%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--pi-bg) 55%, transparent); }
|
|
666
|
-
.progress { position: absolute; left: 0; width: var(--position); top: 0; bottom: 0; border-radius: 999px; background: color-mix(in srgb, var(--pi-accent) 42%, var(--pi-border-muted)); }
|
|
667
|
-
.marker { position: absolute; left: var(--position); top: 50%; width: 10px; height: 10px; border: 2px solid var(--pi-bg); border-radius: 50%; background: var(--pi-accent); box-shadow: 0 2px 8px var(--pi-shadow); transform: translate(-50%, -50%); }
|
|
668
|
-
`;qs([p({type:Number})],nt.prototype,"positionPercent",2);qs([p({type:Number})],nt.prototype,"loadedPercent",2);nt=qs([M("conversation-meter")],nt);function Vi(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}class us extends Bs{constructor(t){if(super(t),this.it=E,t.type!==Ns.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===E||t==null)return this._t=void 0,this.it=t;if(t===ve)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const s=[t];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}us.directiveName="unsafeHTML",us.resultType=1;const Bp=Fs(us);function Hs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ae=Hs();function eo(e){Ae=e}var ke={exec:()=>null};function P(e,t=""){let s=typeof e=="string"?e:e.source,i={replace:(r,o)=>{let n=typeof o=="string"?o:o.source;return n=n.replace(B.caret,"$1"),s=s.replace(r,n),i},getRegex:()=>new RegExp(s,t)};return i}var zp=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),B={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,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ 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,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},qp=/^(?:[ \t]*(?:\n|$))+/,Hp=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Up=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ct=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Vp=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Us=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,to=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,so=P(to).replace(/bull/g,Us).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(),Gp=P(to).replace(/bull/g,Us).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(),Vs=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Kp=/^[^\n]+/,Gs=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Qp=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Gs).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Jp=P(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Us).getRegex(),zt="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",Ks=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Zp=P("^ {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",Ks).replace("tag",zt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),io=P(Vs).replace("hr",ct).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[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",zt).getRegex(),Xp=P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",io).getRegex(),Qs={blockquote:Xp,code:Hp,def:Qp,fences:Up,heading:Vp,hr:ct,html:Zp,lheading:so,list:Jp,newline:qp,paragraph:io,table:ke,text:Kp},Gi=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ct).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[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",zt).getRegex(),Yp={...Qs,lheading:Gp,table:Gi,paragraph:P(Vs).replace("hr",ct).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Gi).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",zt).getRegex()},eh={...Qs,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ks).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:ke,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(Vs).replace("hr",ct).replace("heading",` *#{1,6} *[^
|
|
669
|
-
]`).replace("lheading",so).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},th=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,sh=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ro=/^( {2,}|\\)\n(?!\s*$)/,ih=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Be=/[\p{P}\p{S}]/u,qt=/[\s\p{P}\p{S}]/u,Js=/[^\s\p{P}\p{S}]/u,rh=P(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,qt).getRegex(),oo=/(?!~)[\p{P}\p{S}]/u,oh=/(?!~)[\s\p{P}\p{S}]/u,nh=/(?:[^\s\p{P}\p{S}]|~)/u,ah=P(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",zp?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),no=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,lh=P(no,"u").replace(/punct/g,Be).getRegex(),ch=P(no,"u").replace(/punct/g,oo).getRegex(),ao="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",dh=P(ao,"gu").replace(/notPunctSpace/g,Js).replace(/punctSpace/g,qt).replace(/punct/g,Be).getRegex(),ph=P(ao,"gu").replace(/notPunctSpace/g,nh).replace(/punctSpace/g,oh).replace(/punct/g,oo).getRegex(),hh=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Js).replace(/punctSpace/g,qt).replace(/punct/g,Be).getRegex(),uh=P(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Be).getRegex(),fh="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",mh=P(fh,"gu").replace(/notPunctSpace/g,Js).replace(/punctSpace/g,qt).replace(/punct/g,Be).getRegex(),gh=P(/\\(punct)/,"gu").replace(/punct/g,Be).getRegex(),vh=P(/^<(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(),bh=P(Ks).replace("(?:-->|$)","-->").getRegex(),wh=P("^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",bh).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Dt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,yh=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Dt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),lo=P(/^!?\[(label)\]\[(ref)\]/).replace("label",Dt).replace("ref",Gs).getRegex(),co=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",Gs).getRegex(),xh=P("reflink|nolink(?!\\()","g").replace("reflink",lo).replace("nolink",co).getRegex(),Ki=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Zs={_backpedal:ke,anyPunctuation:gh,autolink:vh,blockSkip:ah,br:ro,code:sh,del:ke,delLDelim:ke,delRDelim:ke,emStrongLDelim:lh,emStrongRDelimAst:dh,emStrongRDelimUnd:hh,escape:th,link:yh,nolink:co,punctuation:rh,reflink:lo,reflinkSearch:xh,tag:wh,text:ih,url:ke},kh={...Zs,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",Dt).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Dt).getRegex()},fs={...Zs,emStrongRDelimAst:ph,emStrongLDelim:ch,delLDelim:uh,delRDelim:mh,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ki).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\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:P(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ki).getRegex()},Sh={...fs,br:P(ro).replace("{2,}","*").getRegex(),text:P(fs.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},mt={normal:Qs,gfm:Yp,pedantic:eh},Ze={normal:Zs,gfm:fs,breaks:Sh,pedantic:kh},$h={"&":"&","<":"<",">":">",'"':""","'":"'"},Qi=e=>$h[e];function re(e,t){if(t){if(B.escapeTest.test(e))return e.replace(B.escapeReplace,Qi)}else if(B.escapeTestNoEncode.test(e))return e.replace(B.escapeReplaceNoEncode,Qi);return e}function Ji(e){try{e=encodeURI(e).replace(B.percentDecode,"%")}catch{return null}return e}function Zi(e,t){let s=e.replace(B.findPipe,(o,n,a)=>{let l=!1,d=n;for(;--d>=0&&a[d]==="\\";)l=!l;return l?"|":" |"}),i=s.split(B.splitPipe),r=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(B.slashPipe,"|");return i}function me(e,t,s){let i=e.length;if(i===0)return"";let r=0;for(;r<i&&e.charAt(i-r-1)===t;)r++;return e.slice(0,i-r)}function Xi(e){let t=e.split(`
|
|
670
|
-
`),s=t.length-1;for(;s>=0&&B.blankLine.test(t[s]);)s--;return t.length-s<=2?e:t.slice(0,s+1).join(`
|
|
671
|
-
`)}function Ph(e,t){if(e.indexOf(t[1])===-1)return-1;let s=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])s++;else if(e[i]===t[1]&&(s--,s<0))return i;return s>0?-2:-1}function Th(e,t=0){let s=t,i="";for(let r of e)if(r===" "){let o=4-s%4;i+=" ".repeat(o),s+=o}else i+=r,s++;return i}function Yi(e,t,s,i,r){let o=t.href,n=t.title||null,a=e[1].replace(r.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:s,href:o,title:n,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,l}function Ch(e,t,s){let i=e.match(s.other.indentCodeCompensation);if(i===null)return t;let r=i[1];return t.split(`
|
|
672
|
-
`).map(o=>{let n=o.match(s.other.beginningSpace);if(n===null)return o;let[a]=n;return a.length>=r.length?o.slice(r.length):o}).join(`
|
|
673
|
-
`)}var _t=class{options;rules;lexer;constructor(e){this.options=e||Ae}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let s=this.options.pedantic?t[0]:Xi(t[0]),i=s.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:s,codeBlockStyle:"indented",text:i}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let s=t[0],i=Ch(s,t[3]||"",this.rules);return{type:"code",raw:s,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let s=t[2].trim();if(this.rules.other.endingHash.test(s)){let i=me(s,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(s=i.trim())}return{type:"heading",raw:me(t[0],`
|
|
674
|
-
`),depth:t[1].length,text:s,tokens:this.lexer.inline(s)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:me(t[0],`
|
|
675
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let s=me(t[0],`
|
|
676
|
-
`).split(`
|
|
677
|
-
`),i="",r="",o=[];for(;s.length>0;){let n=!1,a=[],l;for(l=0;l<s.length;l++)if(this.rules.other.blockquoteStart.test(s[l]))a.push(s[l]),n=!0;else if(!n)a.push(s[l]);else break;s=s.slice(l);let d=a.join(`
|
|
678
|
-
`),u=d.replace(this.rules.other.blockquoteSetextReplace,`
|
|
679
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
|
|
680
|
-
${d}`:d,r=r?`${r}
|
|
681
|
-
${u}`:u;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,o,!0),this.lexer.state.top=h,s.length===0)break;let f=o.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let g=f,b=g.raw+`
|
|
682
|
-
`+s.join(`
|
|
683
|
-
`),L=this.blockquote(b);o[o.length-1]=L,i=i.substring(0,i.length-g.raw.length)+L.raw,r=r.substring(0,r.length-g.text.length)+L.text;break}else if(f?.type==="list"){let g=f,b=g.raw+`
|
|
684
|
-
`+s.join(`
|
|
685
|
-
`),L=this.list(b);o[o.length-1]=L,i=i.substring(0,i.length-f.raw.length)+L.raw,r=r.substring(0,r.length-g.raw.length)+L.raw,s=b.substring(o.at(-1).raw.length).split(`
|
|
686
|
-
`);continue}}return{type:"blockquote",raw:i,tokens:o,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),i=s.length>1,r={type:"list",raw:"",ordered:i,start:i?+s.slice(0,-1):"",loose:!1,items:[]};s=i?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=i?s:"[*+-]");let o=this.rules.other.listItemRegex(s),n=!1;for(;e;){let l=!1,d="",u="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;d=t[0],e=e.substring(d.length);let h=Th(t[2].split(`
|
|
687
|
-
`,1)[0],t[1].length),f=e.split(`
|
|
688
|
-
`,1)[0],g=!h.trim(),b=0;if(this.options.pedantic?(b=2,u=h.trimStart()):g?b=t[1].length+1:(b=h.search(this.rules.other.nonSpaceChar),b=b>4?1:b,u=h.slice(b),b+=t[1].length),g&&this.rules.other.blankLine.test(f)&&(d+=f+`
|
|
689
|
-
`,e=e.substring(f.length+1),l=!0),!l){let L=this.rules.other.nextBulletRegex(b),Ee=this.rules.other.hrRegex(b),He=this.rules.other.fencesBeginRegex(b),ei=this.rules.other.headingBeginRegex(b),mo=this.rules.other.htmlBeginRegex(b),go=this.rules.other.blockquoteBeginRegex(b);for(;e;){let Vt=e.split(`
|
|
690
|
-
`,1)[0],Ue;if(f=Vt,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),Ue=f):Ue=f.replace(this.rules.other.tabCharGlobal," "),He.test(f)||ei.test(f)||mo.test(f)||go.test(f)||L.test(f)||Ee.test(f))break;if(Ue.search(this.rules.other.nonSpaceChar)>=b||!f.trim())u+=`
|
|
691
|
-
`+Ue.slice(b);else{if(g||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||He.test(h)||ei.test(h)||Ee.test(h))break;u+=`
|
|
692
|
-
`+f}g=!f.trim(),d+=Vt+`
|
|
693
|
-
`,e=e.substring(Vt.length+1),h=Ue.slice(b)}}r.loose||(n?r.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(n=!0)),r.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),r.raw+=d}let a=r.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let l of r.items){this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]);let d=l.tokens[0];if(l.task&&(d?.type==="text"||d?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),d.raw=d.raw.replace(this.rules.other.listReplaceTask,""),d.text=d.text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let h={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};l.checked=h.checked,r.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}else l.task&&(l.task=!1);if(!r.loose){let u=l.tokens.filter(f=>f.type==="space"),h=u.length>0&&u.some(f=>this.rules.other.anyLine.test(f.raw));r.loose=h}}if(r.loose)for(let l of r.items){l.loose=!0;for(let d of l.tokens)d.type==="text"&&(d.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t){let s=Xi(t[0]);return{type:"html",block:!0,raw:s,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:s}}}def(e){let t=this.rules.block.def.exec(e);if(t){let s=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:s,raw:me(t[0],`
|
|
694
|
-
`),href:i,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let s=Zi(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
695
|
-
`):[],o={type:"table",raw:me(t[0],`
|
|
696
|
-
`),header:[],align:[],rows:[]};if(s.length===i.length){for(let n of i)this.rules.other.tableAlignRight.test(n)?o.align.push("right"):this.rules.other.tableAlignCenter.test(n)?o.align.push("center"):this.rules.other.tableAlignLeft.test(n)?o.align.push("left"):o.align.push(null);for(let n=0;n<s.length;n++)o.header.push({text:s[n],tokens:this.lexer.inline(s[n]),header:!0,align:o.align[n]});for(let n of r)o.rows.push(Zi(n,o.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:o.align[l]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let s=t[1].trim();return{type:"heading",raw:me(t[0],`
|
|
697
|
-
`),depth:t[2].charAt(0)==="="?1:2,text:s,tokens:this.lexer.inline(s)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let s=t[1].charAt(t[1].length-1)===`
|
|
698
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:s,tokens:this.lexer.inline(s)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let s=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(s)){if(!this.rules.other.endAngleBracket.test(s))return;let o=me(s.slice(0,-1),"\\");if((s.length-o.length)%2===0)return}else{let o=Ph(t[2],"()");if(o===-2)return;if(o>-1){let n=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let i=t[2],r="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(i);o&&(i=o[1],r=o[3])}else r=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(s)?i=i.slice(1):i=i.slice(1,-1)),Yi(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let s;if((s=this.rules.inline.reflink.exec(e))||(s=this.rules.inline.nolink.exec(e))){let i=(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[i.toLowerCase()];if(!r){let o=s[0].charAt(0);return{type:"text",raw:o,text:o}}return Yi(s,r,s[0],this.lexer,this.rules)}}emStrong(e,t,s=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||!i[1]&&!i[2]&&!i[3]&&!i[4]||i[4]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[3])||!s||this.rules.inline.punctuation.exec(s))){let r=[...i[0]].length-1,o,n,a=r,l=0,d=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+r);(i=d.exec(t))!==null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(n=[...o].length,i[3]||i[4]){a+=n;continue}else if((i[5]||i[6])&&r%3&&!((r+n)%3)){l+=n;continue}if(a-=n,a>0)continue;n=Math.min(n,n+a+l);let u=[...i[0]][0].length,h=e.slice(0,r+i.index+u+n);if(Math.min(r,n)%2){let g=h.slice(1,-1);return{type:"em",raw:h,text:g,tokens:this.lexer.inlineTokens(g)}}let f=h.slice(2,-2);return{type:"strong",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let s=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(s),r=this.rules.other.startingSpaceChar.test(s)&&this.rules.other.endingSpaceChar.test(s);return i&&r&&(s=s.substring(1,s.length-1)),{type:"codespan",raw:t[0],text:s}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,s=""){let i=this.rules.inline.delLDelim.exec(e);if(i&&(!i[1]||!s||this.rules.inline.punctuation.exec(s))){let r=[...i[0]].length-1,o,n,a=r,l=this.rules.inline.delRDelim;for(l.lastIndex=0,t=t.slice(-1*e.length+r);(i=l.exec(t))!==null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o||(n=[...o].length,n!==r))continue;if(i[3]||i[4]){a+=n;continue}if(a-=n,a>0)continue;n=Math.min(n,n+a);let d=[...i[0]][0].length,u=e.slice(0,r+i.index+d+n),h=u.slice(r,-r);return{type:"del",raw:u,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let s,i;return t[2]==="@"?(s=t[1],i="mailto:"+s):(s=t[1],i=s),{type:"link",raw:t[0],text:s,href:i,tokens:[{type:"text",raw:s,text:s}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let s,i;if(t[2]==="@")s=t[0],i="mailto:"+s;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);s=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:s,href:i,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let s=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:s}}}},Y=class ms{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ae,this.options.tokenizer=this.options.tokenizer||new _t,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let s={other:B,block:mt.normal,inline:Ze.normal};this.options.pedantic?(s.block=mt.pedantic,s.inline=Ze.pedantic):this.options.gfm&&(s.block=mt.gfm,this.options.breaks?s.inline=Ze.breaks:s.inline=Ze.gfm),this.tokenizer.rules=s}static get rules(){return{block:mt,inline:Ze}}static lex(t,s){return new ms(s).lex(t)}static lexInline(t,s){return new ms(s).inlineTokens(t)}lex(t){t=t.replace(B.carriageReturn,`
|
|
699
|
-
`),this.blockTokens(t,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){let i=this.inlineQueue[s];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,s=[],i=!1){this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(B.tabCharGlobal," ").replace(B.spaceLine,""));let r=1/0;for(;t;){if(t.length<r)r=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(a=>(o=a.call({lexer:this},t,s))?(t=t.substring(o.raw.length),s.push(o),!0):!1))continue;if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length);let a=s.at(-1);o.raw.length===1&&a!==void 0?a.raw+=`
|
|
700
|
-
`:s.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length);let a=s.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
701
|
-
`)?"":`
|
|
702
|
-
`)+o.raw,a.text+=`
|
|
703
|
-
`+o.text,this.inlineQueue.at(-1).src=a.text):s.push(o);continue}if(o=this.tokenizer.fences(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.heading(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.hr(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.blockquote(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.list(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.html(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.def(t)){t=t.substring(o.raw.length);let a=s.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
704
|
-
`)?"":`
|
|
705
|
-
`)+o.raw,a.text+=`
|
|
706
|
-
`+o.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},s.push(o));continue}if(o=this.tokenizer.table(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),s.push(o);continue}let n=t;if(this.options.extensions?.startBlock){let a=1/0,l=t.slice(1),d;this.options.extensions.startBlock.forEach(u=>{d=u.call({lexer:this},l),typeof d=="number"&&d>=0&&(a=Math.min(a,d))}),a<1/0&&a>=0&&(n=t.substring(0,a+1))}if(this.state.top&&(o=this.tokenizer.paragraph(n))){let a=s.at(-1);i&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
|
|
707
|
-
`)?"":`
|
|
708
|
-
`)+o.raw,a.text+=`
|
|
709
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):s.push(o),i=n.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length);let a=s.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
710
|
-
`)?"":`
|
|
711
|
-
`)+o.raw,a.text+=`
|
|
712
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):s.push(o);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,s}inline(t,s=[]){return this.inlineQueue.push({src:t,tokens:s}),s}inlineTokens(t,s=[]){this.tokenizer.lexer=this;let i=t,r=null;if(this.tokens.links){let d=Object.keys(this.tokens.links);if(d.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(i))!==null;)d.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(i))!==null;)i=i.slice(0,r.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(i))!==null;)o=r[2]?r[2].length:0,i=i.slice(0,r.index+o)+"["+"a".repeat(r[0].length-o-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let n=!1,a="",l=1/0;for(;t;){if(t.length<l)l=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}n||(a=""),n=!1;let d;if(this.options.extensions?.inline?.some(h=>(d=h.call({lexer:this},t,s))?(t=t.substring(d.raw.length),s.push(d),!0):!1))continue;if(d=this.tokenizer.escape(t)){t=t.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.tag(t)){t=t.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.link(t)){t=t.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(d.raw.length);let h=s.at(-1);d.type==="text"&&h?.type==="text"?(h.raw+=d.raw,h.text+=d.text):s.push(d);continue}if(d=this.tokenizer.emStrong(t,i,a)){t=t.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.codespan(t)){t=t.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.br(t)){t=t.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.del(t,i,a)){t=t.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.autolink(t)){t=t.substring(d.raw.length),s.push(d);continue}if(!this.state.inLink&&(d=this.tokenizer.url(t))){t=t.substring(d.raw.length),s.push(d);continue}let u=t;if(this.options.extensions?.startInline){let h=1/0,f=t.slice(1),g;this.options.extensions.startInline.forEach(b=>{g=b.call({lexer:this},f),typeof g=="number"&&g>=0&&(h=Math.min(h,g))}),h<1/0&&h>=0&&(u=t.substring(0,h+1))}if(d=this.tokenizer.inlineText(u)){t=t.substring(d.raw.length),d.raw.slice(-1)!=="_"&&(a=d.raw.slice(-1)),n=!0;let h=s.at(-1);h?.type==="text"?(h.raw+=d.raw,h.text+=d.text):s.push(d);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return s}infiniteLoopError(t){let s="Infinite loop on byte: "+t;if(this.options.silent)console.error(s);else throw new Error(s)}},Lt=class{options;parser;constructor(e){this.options=e||Ae}space(e){return""}code({text:e,lang:t,escaped:s}){let i=(t||"").match(B.notSpaceStart)?.[0],r=e.replace(B.endingNewline,"")+`
|
|
713
|
-
`;return i?'<pre><code class="language-'+re(i)+'">'+(s?r:re(r,!0))+`</code></pre>
|
|
714
|
-
`:"<pre><code>"+(s?r:re(r,!0))+`</code></pre>
|
|
715
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
716
|
-
${this.parser.parse(e)}</blockquote>
|
|
717
|
-
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
718
|
-
`}hr(e){return`<hr>
|
|
719
|
-
`}list(e){let t=e.ordered,s=e.start,i="";for(let n=0;n<e.items.length;n++){let a=e.items[n];i+=this.listitem(a)}let r=t?"ol":"ul",o=t&&s!==1?' start="'+s+'"':"";return"<"+r+o+`>
|
|
720
|
-
`+i+"</"+r+`>
|
|
721
|
-
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
722
|
-
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
723
|
-
`}table(e){let t="",s="";for(let r=0;r<e.header.length;r++)s+=this.tablecell(e.header[r]);t+=this.tablerow({text:s});let i="";for(let r=0;r<e.rows.length;r++){let o=e.rows[r];s="";for(let n=0;n<o.length;n++)s+=this.tablecell(o[n]);i+=this.tablerow({text:s})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
|
|
724
|
-
<thead>
|
|
725
|
-
`+t+`</thead>
|
|
726
|
-
`+i+`</table>
|
|
727
|
-
`}tablerow({text:e}){return`<tr>
|
|
728
|
-
${e}</tr>
|
|
729
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),s=e.header?"th":"td";return(e.align?`<${s} align="${e.align}">`:`<${s}>`)+t+`</${s}>
|
|
730
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${re(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:s}){let i=this.parser.parseInline(s),r=Ji(e);if(r===null)return i;e=r;let o='<a href="'+e+'"';return t&&(o+=' title="'+re(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:s,tokens:i}){i&&(s=this.parser.parseInline(i,this.parser.textRenderer));let r=Ji(e);if(r===null)return re(s);e=r;let o=`<img src="${e}" alt="${re(s)}"`;return t&&(o+=` title="${re(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:re(e.text)}},Xs=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ee=class gs{options;renderer;textRenderer;constructor(t){this.options=t||Ae,this.options.renderer=this.options.renderer||new Lt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Xs}static parse(t,s){return new gs(s).parse(t)}static parseInline(t,s){return new gs(s).parseInline(t)}parse(t){this.renderer.parser=this;let s="";for(let i=0;i<t.length;i++){let r=t[i];if(this.options.extensions?.renderers?.[r.type]){let n=r,a=this.options.extensions.renderers[n.type].call({parser:this},n);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(n.type)){s+=a||"";continue}}let o=r;switch(o.type){case"space":{s+=this.renderer.space(o);break}case"hr":{s+=this.renderer.hr(o);break}case"heading":{s+=this.renderer.heading(o);break}case"code":{s+=this.renderer.code(o);break}case"table":{s+=this.renderer.table(o);break}case"blockquote":{s+=this.renderer.blockquote(o);break}case"list":{s+=this.renderer.list(o);break}case"checkbox":{s+=this.renderer.checkbox(o);break}case"html":{s+=this.renderer.html(o);break}case"def":{s+=this.renderer.def(o);break}case"paragraph":{s+=this.renderer.paragraph(o);break}case"text":{s+=this.renderer.text(o);break}default:{let n='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(n),"";throw new Error(n)}}}return s}parseInline(t,s=this.renderer){this.renderer.parser=this;let i="";for(let r=0;r<t.length;r++){let o=t[r];if(this.options.extensions?.renderers?.[o.type]){let a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){i+=a||"";continue}}let n=o;switch(n.type){case"escape":{i+=s.text(n);break}case"html":{i+=s.html(n);break}case"link":{i+=s.link(n);break}case"image":{i+=s.image(n);break}case"checkbox":{i+=s.checkbox(n);break}case"strong":{i+=s.strong(n);break}case"em":{i+=s.em(n);break}case"codespan":{i+=s.codespan(n);break}case"br":{i+=s.br(n);break}case"del":{i+=s.del(n);break}case"text":{i+=s.text(n);break}default:{let a='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return i}},Ye=class{options;block;constructor(e){this.options=e||Ae}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Y.lex:Y.lexInline}provideParser(e=this.block){return e?ee.parse:ee.parseInline}},Ah=class{defaults=Hs();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ee;Renderer=Lt;TextRenderer=Xs;Lexer=Y;Tokenizer=_t;Hooks=Ye;constructor(...e){this.use(...e)}walkTokens(e,t){let s=[];for(let i of e)switch(s=s.concat(t.call(this,i)),i.type){case"table":{let r=i;for(let o of r.header)s=s.concat(this.walkTokens(o.tokens,t));for(let o of r.rows)for(let n of o)s=s.concat(this.walkTokens(n.tokens,t));break}case"list":{let r=i;s=s.concat(this.walkTokens(r.items,t));break}default:{let r=i;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(o=>{let n=r[o].flat(1/0);s=s.concat(this.walkTokens(n,t))}):r.tokens&&(s=s.concat(this.walkTokens(r.tokens,t)))}}return s}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(s=>{let i={...s};if(i.async=this.defaults.async||i.async||!1,s.extensions&&(s.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let o=t.renderers[r.name];o?t.renderers[r.name]=function(...n){let a=r.renderer.apply(this,n);return a===!1&&(a=o.apply(this,n)),a}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[r.level];o?o.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),i.extensions=t),s.renderer){let r=this.defaults.renderer||new Lt(this.defaults);for(let o in s.renderer){if(!(o in r))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let n=o,a=s.renderer[n],l=r[n];r[n]=(...d)=>{let u=a.apply(r,d);return u===!1&&(u=l.apply(r,d)),u||""}}i.renderer=r}if(s.tokenizer){let r=this.defaults.tokenizer||new _t(this.defaults);for(let o in s.tokenizer){if(!(o in r))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let n=o,a=s.tokenizer[n],l=r[n];r[n]=(...d)=>{let u=a.apply(r,d);return u===!1&&(u=l.apply(r,d)),u}}i.tokenizer=r}if(s.hooks){let r=this.defaults.hooks||new Ye;for(let o in s.hooks){if(!(o in r))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let n=o,a=s.hooks[n],l=r[n];Ye.passThroughHooks.has(o)?r[n]=d=>{if(this.defaults.async&&Ye.passThroughHooksRespectAsync.has(o))return(async()=>{let h=await a.call(r,d);return l.call(r,h)})();let u=a.call(r,d);return l.call(r,u)}:r[n]=(...d)=>{if(this.defaults.async)return(async()=>{let h=await a.apply(r,d);return h===!1&&(h=await l.apply(r,d)),h})();let u=a.apply(r,d);return u===!1&&(u=l.apply(r,d)),u}}i.hooks=r}if(s.walkTokens){let r=this.defaults.walkTokens,o=s.walkTokens;i.walkTokens=function(n){let a=[];return a.push(o.call(this,n)),r&&(a=a.concat(r.call(this,n))),a}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Y.lex(e,t??this.defaults)}parser(e,t){return ee.parse(e,t??this.defaults)}parseMarkdown(e){return(t,s)=>{let i={...s},r={...this.defaults,...i},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.async===!1)return o(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 t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let n=r.hooks?await r.hooks.preprocess(t):t,a=await(r.hooks?await r.hooks.provideLexer(e):e?Y.lex:Y.lexInline)(n,r),l=r.hooks?await r.hooks.processAllTokens(a):a;r.walkTokens&&await Promise.all(this.walkTokens(l,r.walkTokens));let d=await(r.hooks?await r.hooks.provideParser(e):e?ee.parse:ee.parseInline)(l,r);return r.hooks?await r.hooks.postprocess(d):d})().catch(o);try{r.hooks&&(t=r.hooks.preprocess(t));let n=(r.hooks?r.hooks.provideLexer(e):e?Y.lex:Y.lexInline)(t,r);r.hooks&&(n=r.hooks.processAllTokens(n)),r.walkTokens&&this.walkTokens(n,r.walkTokens);let a=(r.hooks?r.hooks.provideParser(e):e?ee.parse:ee.parseInline)(n,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(n){return o(n)}}}onError(e,t){return s=>{if(s.message+=`
|
|
731
|
-
Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+re(s.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(s);throw s}}},Te=new Ah;function T(e,t){return Te.parse(e,t)}T.options=T.setOptions=function(e){return Te.setOptions(e),T.defaults=Te.defaults,eo(T.defaults),T};T.getDefaults=Hs;T.defaults=Ae;T.use=function(...e){return Te.use(...e),T.defaults=Te.defaults,eo(T.defaults),T};T.walkTokens=function(e,t){return Te.walkTokens(e,t)};T.parseInline=Te.parseInline;T.Parser=ee;T.parser=ee.parse;T.Renderer=Lt;T.TextRenderer=Xs;T.Lexer=Y;T.lexer=Y.lex;T.Tokenizer=_t;T.Hooks=Ye;T.parse=T;T.options;T.setOptions;T.use;T.walkTokens;T.parseInline;ee.parse;Y.lex;const po=new T.Renderer;po.html=({text:e})=>Mh(e);const Ih=300,Xe=new Map;function Rh(e){const t=Xe.get(e);if(t!==void 0)return t;const s=T.parse(e,{async:!1,breaks:!0,gfm:!0,renderer:po}),i=Eh(s);if(Xe.set(e,i),Xe.size>Ih){const r=Xe.keys().next().value;r!==void 0&&Xe.delete(r)}return i}function Mh(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function Eh(e){const t=document.createElement("template");return t.innerHTML=e,t.content.querySelectorAll("script, style, iframe, object, embed").forEach(s=>{s.remove()}),t.content.querySelectorAll("*").forEach(s=>{for(const i of[...s.attributes]){const r=i.name.toLowerCase();r.startsWith("on")&&s.removeAttribute(i.name),(r==="href"||r==="src")&&!Dh(i.value)&&s.removeAttribute(i.name)}s.tagName==="A"&&(s.setAttribute("target","_blank"),s.setAttribute("rel","noreferrer noopener"))}),t.innerHTML}function Dh(e){if(e.startsWith("#")||e.startsWith("/"))return!0;try{return["http:","https:","mailto:"].includes(new URL(e).protocol)}catch{return!1}}var _h=Object.defineProperty,Lh=Object.getOwnPropertyDescriptor,ho=(e,t,s,i)=>{for(var r=i>1?void 0:i?Lh(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&_h(t,s,r),r};let Ot=class extends C{constructor(){super(...arguments),this.text="",this.onFormattedClick=e=>{if(!(e.target instanceof Element))return;const t=e.target.closest(".code-copy-button");if(!(t instanceof HTMLButtonElement))return;const s=t.closest(".code-block-wrapper");if(!(s instanceof HTMLElement))return;const i=s.querySelector("pre code");i instanceof HTMLElement&&this.copyCode(i.textContent,t)},this.onFormattedCopy=e=>{e.clipboardData===null||!jh(Oh(this))||(e.clipboardData.setData("text/plain",this.text),e.preventDefault(),e.stopPropagation())}}render(){return c`<div class="formatted" @click=${this.onFormattedClick} @copy=${this.onFormattedCopy}>${Bp(Rh(this.text))}</div>`}updated(){this.enhanceCodeBlocks()}enhanceCodeBlocks(){this.renderRoot.querySelectorAll("pre").forEach(e=>{if(!(e instanceof HTMLPreElement)||e.parentElement?.classList.contains("code-block-wrapper")===!0||!(e.querySelector("code")instanceof HTMLElement))return;const s=document.createElement("div");s.className="code-block-wrapper";const i=document.createElement("button");i.type="button",i.className="code-copy-button",i.title="Copy code block",i.setAttribute("aria-label","Copy code block");const r=document.createElement("span");r.setAttribute("aria-hidden","true"),r.textContent="⧉",i.append(r),e.before(s),s.append(e,i)})}async copyCode(e,t){const s=await Nh(e);this.setCopyButtonState(t,s?"copied":"failed"),window.setTimeout(()=>{this.setCopyButtonState(t,"idle")},1200)}setCopyButtonState(e,t){const s=e.querySelector("span");s!==null&&(s.textContent=t==="copied"?"✓":"⧉");const i=t==="copied"?"Copied code block":t==="failed"?"Failed to copy code block":"Copy code block";e.title=i,e.setAttribute("aria-label",i)}};Ot.styles=Fd;ho([p()],Ot.prototype,"text",2);Ot=ho([M("formatted-text")],Ot);function Oh(e){const t=e.getRootNode();return typeof ShadowRoot<"u"&&t instanceof ShadowRoot&&Wh(t)?t.getSelection():e.ownerDocument.getSelection()}function Wh(e){return"getSelection"in e&&typeof e.getSelection=="function"}function jh(e){return e!==null&&!e.isCollapsed&&e.toString()!==""}async function Nh(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}var Fh=Object.defineProperty,Bh=Object.getOwnPropertyDescriptor,dt=(e,t,s,i)=>{for(var r=i>1?void 0:i?Bh(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&Fh(t,s,r),r};const er=180;let Ce=class extends C{constructor(){super(...arguments),this.showFullDiff=!1,this.copied=!1,this.diffOpen=!0}render(){const e=this.execution;if(e===void 0)return null;const t=e.toolName==="edit",s=zh(e.args),i=qh(e.details),r=e.preview,o=i??r?.diff,n=o===void 0?void 0:Hh(o),a=i!==void 0&&r?.diff!==void 0&&i!==r.diff,l=e.status==="error"?e.resultText:r?.error,d=o===void 0?e.resultText:void 0;return c`
|
|
732
|
-
<section class=${`tool-card ${e.status}`}>
|
|
733
|
-
<div class="tool-header">
|
|
734
|
-
<div class="tool-title">
|
|
735
|
-
<span class="status-icon" aria-hidden="true">${Vh(e.status)}</span>
|
|
736
|
-
<strong>${e.toolName}</strong>
|
|
737
|
-
${s===void 0?c`<span class="summary">${e.summary}</span>`:c`<span class="path">${s}</span>`}
|
|
738
|
-
</div>
|
|
739
|
-
<div class="tool-meta">
|
|
740
|
-
${tr(e)===void 0?null:c`<span>${tr(e)}</span>`}
|
|
741
|
-
${n===void 0?null:c`<span class="diff-stats"><b class="added">+${n.added}</b><span>/</span><b class="removed">-${n.removed}</b></span>`}
|
|
742
|
-
<span class="status-label">${Gh(e.status)}</span>
|
|
743
|
-
</div>
|
|
744
|
-
</div>
|
|
745
|
-
|
|
746
|
-
${a?c`<p class="notice">Applied diff differs from the preview.</p>`:null}
|
|
747
|
-
${l===void 0||l===""?null:c`<pre class="error-text">${l}</pre>`}
|
|
748
|
-
${o===void 0?this.renderTextBody(d,e.status==="error"):this.renderDiffBody(o,i===void 0?"Preview diff":"Applied diff")}
|
|
749
|
-
${!t&&o===void 0&&(d===void 0||d==="")?c`<p class="muted">${e.summary}</p>`:null}
|
|
750
|
-
</section>
|
|
751
|
-
`}renderTextBody(e,t){return e===void 0||e===""?null:c`
|
|
752
|
-
<details class="text-body" ?open=${t}>
|
|
753
|
-
<summary>Result</summary>
|
|
754
|
-
<pre>${e}</pre>
|
|
755
|
-
</details>
|
|
756
|
-
`}renderDiffBody(e,t){const s=e.split(`
|
|
757
|
-
`),i=!this.showFullDiff&&s.length>er,r=i?s.slice(0,er):s;return c`
|
|
758
|
-
<details class="diff-details" ?open=${this.diffOpen} @toggle=${o=>{this.onDiffToggle(o)}}>
|
|
759
|
-
<summary>
|
|
760
|
-
<span>${t}</span>
|
|
761
|
-
<small>${String(s.length)} ${s.length===1?"line":"lines"}</small>
|
|
762
|
-
</summary>
|
|
763
|
-
<div class="diff-toolbar">
|
|
764
|
-
<span>${i?`Showing ${String(r.length)} of ${String(s.length)} lines`:"Full diff"}</span>
|
|
765
|
-
<button type="button" @click=${()=>{this.copyDiff(e)}}>${this.copied?"Copied":"Copy diff"}</button>
|
|
766
|
-
</div>
|
|
767
|
-
<pre class="diff" aria-label=${t}><code class="diff-content">${r.map(o=>c`<span class=${Uh(o)}>${o}</span>`)}</code></pre>
|
|
768
|
-
${i?c`
|
|
769
|
-
<button class="show-more" type="button" @click=${()=>{this.showFullDiff=!0}}>
|
|
770
|
-
Show all ${String(s.length)} diff lines
|
|
771
|
-
</button>
|
|
772
|
-
`:null}
|
|
773
|
-
</details>
|
|
774
|
-
`}onDiffToggle(e){const t=e.currentTarget;t instanceof HTMLDetailsElement&&(this.diffOpen=t.open)}async copyDiff(e){try{await navigator.clipboard.writeText(e),this.copied=!0,window.setTimeout(()=>{this.copied=!1},1200)}catch{this.copied=!1}}};Ce.styles=j`
|
|
775
|
-
:host { display: block; width: 100%; max-width: 100%; min-width: 0; color: var(--pi-text); }
|
|
776
|
-
.tool-card { display: grid; gap: 8px; width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; overflow: hidden; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); padding: 9px; color: var(--pi-text); }
|
|
777
|
-
.tool-card.running, .tool-card.pending { border-color: var(--pi-warning-border); background: var(--pi-warning-surface); }
|
|
778
|
-
.tool-card.success { border-color: var(--pi-success-border); background: var(--pi-success-bg); }
|
|
779
|
-
.tool-card.error { border-color: var(--pi-danger); background: color-mix(in srgb, var(--pi-danger) 10%, var(--pi-bg)); }
|
|
780
|
-
.tool-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; }
|
|
781
|
-
.tool-title { display: inline-flex; align-items: baseline; gap: 7px; min-width: 0; }
|
|
782
|
-
.status-icon { flex: 0 0 auto; color: var(--pi-muted); }
|
|
783
|
-
strong { color: var(--pi-text); }
|
|
784
|
-
.path, .summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--pi-accent); font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
785
|
-
.summary { color: var(--pi-muted); font-family: inherit; }
|
|
786
|
-
.tool-meta { flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: 8px; color: var(--pi-muted); font-size: 12px; }
|
|
787
|
-
.diff-stats { display: inline-flex; gap: 3px; }
|
|
788
|
-
.added, .diff .added { color: var(--pi-success); }
|
|
789
|
-
.removed, .diff .removed { color: var(--pi-danger); }
|
|
790
|
-
.status-label { text-transform: uppercase; letter-spacing: .04em; color: var(--pi-muted); }
|
|
791
|
-
.notice { margin: 0; color: var(--pi-warning); }
|
|
792
|
-
.muted { margin: 0; color: var(--pi-muted); }
|
|
793
|
-
.error-text { margin: 0; border: 1px solid var(--pi-danger); border-radius: 7px; background: color-mix(in srgb, var(--pi-danger) 10%, var(--pi-bg)); color: var(--pi-danger); padding: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
794
|
-
.text-body { border-top: 1px solid var(--pi-border-muted); padding-top: 6px; }
|
|
795
|
-
.text-body pre { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--pi-text); }
|
|
796
|
-
.diff-details { min-width: 0; max-width: 100%; border-top: 1px solid var(--pi-border-muted); padding-top: 6px; }
|
|
797
|
-
.diff-details > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; color: var(--pi-muted); cursor: pointer; }
|
|
798
|
-
.diff-details > summary span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
799
|
-
.diff-details > summary small { flex: 0 0 auto; color: var(--pi-dim); }
|
|
800
|
-
.diff-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; margin-top: 8px; color: var(--pi-muted); font-size: 12px; }
|
|
801
|
-
.diff-toolbar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
802
|
-
button { border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-text); padding: 3px 7px; font: 12px system-ui, sans-serif; cursor: pointer; }
|
|
803
|
-
button:hover, button:focus { border-color: var(--pi-accent); }
|
|
804
|
-
.diff { box-sizing: border-box; width: 100%; max-width: 100%; min-width: 0; margin: 0; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; border: 1px solid var(--pi-border-muted); border-radius: 7px; background: var(--pi-bg); padding: 8px 0; color: var(--pi-muted); font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.45; }
|
|
805
|
-
.diff-content { display: block; width: max-content; min-width: 100%; }
|
|
806
|
-
.diff span { display: block; min-height: 1.45em; padding: 0 8px; white-space: pre; }
|
|
807
|
-
.diff .context { color: var(--pi-muted); }
|
|
808
|
-
.diff .hunk { color: var(--pi-accent); }
|
|
809
|
-
.diff .file { color: var(--pi-dim); }
|
|
810
|
-
.diff .meta { color: var(--pi-dim); }
|
|
811
|
-
.diff .added { background: color-mix(in srgb, var(--pi-success) 12%, transparent); }
|
|
812
|
-
.diff .removed { background: color-mix(in srgb, var(--pi-danger) 12%, transparent); }
|
|
813
|
-
.show-more { justify-self: start; }
|
|
814
|
-
`;dt([p({attribute:!1})],Ce.prototype,"execution",2);dt([k()],Ce.prototype,"showFullDiff",2);dt([k()],Ce.prototype,"copied",2);dt([k()],Ce.prototype,"diffOpen",2);Ce=dt([M("tool-execution-view")],Ce);function zh(e){return vs(e,"path")??vs(e,"file_path")}function tr(e){if(e.toolName!=="edit")return;const t=xt(e.args,"edits");if(Array.isArray(t))return`${String(t.length)} edit${t.length===1?"":"s"}`;if(typeof xt(e.args,"oldText")=="string"&&typeof xt(e.args,"newText")=="string")return"1 edit"}function qh(e){return vs(e,"diff")}function Hh(e){let t=0,s=0;for(const i of e.split(`
|
|
815
|
-
`))uo(i)?t++:fo(i)&&s++;return{added:t,removed:s}}function Uh(e){return uo(e)?"added":fo(e)?"removed":e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")?"file":e.startsWith("diff ")||e.startsWith("index ")?"meta":"context"}function uo(e){return e.startsWith("+")&&!e.startsWith("+++")}function fo(e){return e.startsWith("-")&&!e.startsWith("---")}function Vh(e){return e==="success"?"✓":e==="error"?"✖":e==="running"?"●":"○"}function Gh(e){return e==="success"?"done":e==="error"?"failed":e==="running"?"running":"pending"}function Kh(e){return typeof e=="object"&&e!==null}function xt(e,t){return Kh(e)?e[t]:void 0}function vs(e,t){const s=xt(e,t);return typeof s=="string"?s:void 0}var Qh=Object.defineProperty,Jh=Object.getOwnPropertyDescriptor,_=(e,t,s,i)=>{for(var r=i>1?void 0:i?Jh(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&Qh(t,s,r),r};const Zh=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),Xh=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"medium"}),rs=["You opened this chat while the assistant was already replying. The complete answer will appear shortly.","We joined mid-sentence. Holding the curtain until the full reply is ready.","The assistant started before this tab arrived. We’ll show the full answer when it lands.","Catching the reply in one piece — no spoilers, no half-answers.","The tokens are still assembling themselves. Full answer incoming.","We arrived fashionably late to this response. The complete version will appear soon."];function sr(){return rs[Math.floor(Math.random()*rs.length)]??rs[0]}function ir(e){return kt(e,0,100)}function kt(e,t,s){return Number.isFinite(e)?Math.min(s,Math.max(t,e)):t}let R=class extends C{constructor(){super(...arguments),this.messages=[],this.sessionId="",this.messageStart=0,this.messageEnd=0,this.messageTotal=0,this.hasMore=!1,this.loadingMore=!1,this.isReceivingPartialStream=!1,this.isCompacting=!1,this.pendingMessageCount=0,this.pinnedToBottom=!0,this.disclosures=new pp,this.scrollController=new _p,this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1,this.groupedMessagesStart=0,this.groupedMessagesCache=[],this.messageMetaCache=new WeakMap,this.messageCopyTextCache=new WeakMap,this.lastScrollTop=0,this.lastClientHeight=0,this.prependRestoreToken=0,this.loadMoreRequested=!1,this.onViewportResize=()=>{this.pinnedToBottom?this.scrollToBottom():this.lastClientHeight=this.chat?.clientHeight??0},this.onPageHide=()=>{this.saveScrollPosition()}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.onViewportResize),window.addEventListener("pagehide",this.onPageHide),window.visualViewport?.addEventListener("resize",this.onViewportResize)}firstUpdated(){this.lastClientHeight=this.chat?.clientHeight??0}disconnectedCallback(){this.saveScrollPosition(),this.scrollController.dispose(),this.prependRestoreToken+=1,this.restoreScrollFrame!==void 0&&cancelAnimationFrame(this.restoreScrollFrame),this.loadMoreCheckFrame!==void 0&&cancelAnimationFrame(this.loadMoreCheckFrame),this.scrollToBottomFrame!==void 0&&cancelAnimationFrame(this.scrollToBottomFrame),this.conversationRailFrame!==void 0&&cancelAnimationFrame(this.conversationRailFrame),window.removeEventListener("resize",this.onViewportResize),window.removeEventListener("pagehide",this.onPageHide),window.visualViewport?.removeEventListener("resize",this.onViewportResize),super.disconnectedCallback()}savePreviousSessionScrollPosition(e){typeof e!="string"||e===""||e===this.sessionId||this.saveScrollPosition(e)}prepareSessionUiState(){this.disclosures.syncSession(this.sessionId),this.scrollController.clearScheduledSave(),this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1,this.pendingScrollRestoreSessionId=void 0,this.pendingScrollRestorePosition=void 0,this.prependRestoreToken+=1,this.restoreScrollFrame!==void 0&&(cancelAnimationFrame(this.restoreScrollFrame),this.restoreScrollFrame=void 0)}willUpdate(e){e.has("sessionId")&&(this.savePreviousSessionScrollPosition(e.get("sessionId")),this.prepareSessionUiState()),(e.has("isReceivingPartialStream")||e.has("sessionId")&&this.isReceivingPartialStream)&&this.syncPartialStreamNoticeBody(),e.has("messages")&&(this.pinnedToBottom=this.pinnedToBottom&&(this.didChatHeightChange()||this.isNearBottom()))}update(e){const t=this.isPrependingMessages(e)?this.capturePrependScrollAnchor():void 0;super.update(e),t!==void 0&&this.restorePrependScrollAnchor(t)}updated(e){e.has("loadingMore")&&!this.loadingMore&&(this.loadMoreRequested=!1),e.has("hasMore")&&!this.hasMore&&(this.loadMoreRequested=!1),e.has("sessionId")&&this.restoreScrollPosition(),!e.has("sessionId")&&e.has("messages")&&this.pinnedToBottom&&this.scrollToBottom(),(e.has("messages")||e.has("messageStart")||e.has("messageTotal")||e.has("hasMore")||e.has("loadingMore"))&&this.scheduleConversationRailUpdate(),(e.has("messages")||e.has("messageStart")||e.has("hasMore")||e.has("loadingMore"))&&this.continuePendingScrollRestore(),(e.has("messages")||e.has("hasMore")||e.has("loadingMore"))&&this.requestLoadMoreIfNeeded()}render(){const e=this.groupedMessages();return c`
|
|
816
|
-
<div class="chat-wrap">
|
|
817
|
-
${this.renderConversationRail()}
|
|
818
|
-
<div class="chat" @scroll=${()=>{this.onScroll()}} @wheel=${t=>{this.onWheel(t)}} @touchstart=${t=>{this.onTouchStart(t)}} @touchmove=${t=>{this.onTouchMove(t)}}>
|
|
819
|
-
${this.renderHistoryBoundary()}
|
|
820
|
-
${lp(e,t=>t.kind==="message"?this.messageAnchorKey(t.index):this.groupRenderKey(t.startIndex),(t,s)=>t.kind==="message"?this.renderMessage(t.message,t.index):this.renderMessageGroup(t.messages,t.startIndex,t.endIndex,this.isLiveTailGroup(e,s)))}
|
|
821
|
-
${this.renderQueuedMessages()}
|
|
822
|
-
${this.renderSessionActivity()}
|
|
823
|
-
</div>
|
|
824
|
-
${this.renderActivityDock()}
|
|
825
|
-
</div>
|
|
826
|
-
`}groupedMessages(){return this.groupedMessagesInput===this.messages&&this.groupedMessagesStart===this.messageStart?this.groupedMessagesCache:(this.groupedMessagesInput=this.messages,this.groupedMessagesStart=this.messageStart,this.groupedMessagesCache=fp(this.messages,this.messageStart),this.groupedMessagesCache)}isLiveTailGroup(e,t){return t===e.length-1&&this.isSessionLive()}isSessionLive(){return this.status?.isStreaming===!0||this.status?.isCompacting===!0||this.status?.isBashRunning===!0||this.activity?.phase==="active"}renderActivityDock(){const e=this.activityState();if(e===void 0)return null;const t=e!=="idle"||this.activity?.phase==="active";return c`
|
|
827
|
-
<div class=${t?"activity-dock active":"activity-dock"} aria-live="polite">
|
|
828
|
-
<span class="dot"></span>
|
|
829
|
-
<span class="activity-text">${this.activityText(e)}</span>
|
|
830
|
-
</div>
|
|
831
|
-
`}renderQueuedMessages(){const e=this.status?.queuedMessages??[];return e.length===0?null:c`
|
|
832
|
-
<aside class="queued-messages" aria-live="polite">
|
|
833
|
-
<div class="queued-header">
|
|
834
|
-
<strong>Queued messages</strong>
|
|
835
|
-
<small>${e.length} pending · Stop clears the queue</small>
|
|
836
|
-
</div>
|
|
837
|
-
${e.map((t,s)=>c`
|
|
838
|
-
<div class="queued-message">
|
|
839
|
-
<span class="queued-kind">${t.kind==="steer"?"Steer":"Follow-up"} ${String(s+1)}</span>
|
|
840
|
-
<formatted-text .text=${t.text}></formatted-text>
|
|
841
|
-
</div>
|
|
842
|
-
`)}
|
|
843
|
-
</aside>
|
|
844
|
-
`}renderSessionActivity(){return this.isReceivingPartialStream?c`
|
|
845
|
-
<aside class="session-activity receiving" aria-live="polite">
|
|
846
|
-
<strong>Catching up…</strong>
|
|
847
|
-
<span>${this.currentPartialStreamNoticeBody()}</span>
|
|
848
|
-
</aside>
|
|
849
|
-
`:this.isCompacting?c`
|
|
850
|
-
<aside class="session-activity compacting" aria-live="polite">
|
|
851
|
-
<strong>Compacting history…</strong>
|
|
852
|
-
<span>The agent is summarizing earlier context. New prompts will be queued until compaction finishes.</span>
|
|
853
|
-
${this.pendingMessageCount>0?c`<small>${this.pendingMessageCount} queued ${this.pendingMessageCount===1?"message":"messages"}</small>`:null}
|
|
854
|
-
</aside>
|
|
855
|
-
`:null}syncPartialStreamNoticeBody(){this.partialStreamNoticeBody=this.isReceivingPartialStream?sr():void 0}currentPartialStreamNoticeBody(){return this.partialStreamNoticeBody??=sr(),this.partialStreamNoticeBody}activityState(){const e=this.status;return e===void 0?this.activity?.label:e.isCompacting?"compacting":e.isBashRunning?"bash":e.isStreaming?"running":e.pendingMessageCount>0?"queued":"idle"}activityText(e){const t=this.activity;return t===void 0||e!=="idle"&&t.phase==="idle"?e:t.detail!==void 0&&t.detail!==""?`${t.label}: ${t.detail}`:t.label}renderConversationRail(){if(!this.messages.length||this.messageTotal<=0)return null;const e=this.conversationDisplayTotal(),t=this.conversationPositionPercent(e),s=this.hasMore?ir(this.messages.length/e*100):100;return c`<conversation-meter .positionPercent=${t} .loadedPercent=${s}></conversation-meter>`}conversationDisplayTotal(){return!this.hasMore&&this.messageStart===0?Math.max(1,this.messages.length):Math.max(1,this.messageTotal,this.messageStart+this.messages.length)}conversationPositionPercent(e=this.conversationDisplayTotal()){if(e<=1)return 100;const t=this.pinnedToBottom?this.messageStart+this.messages.length-1:this.messageStart,s=kt(this.currentConversationIndex??t,0,e-1);return ir(s/(e-1)*100)}renderHistoryBoundary(){const e=this.historyRangeLabel();return this.loadingMore?c`<div class="history-boundary"><span>Loading earlier messages…</span>${e}</div>`:this.hasMore?c`
|
|
856
|
-
<div class="history-boundary">
|
|
857
|
-
<button type="button" class="history-load-button" ?disabled=${this.loadMoreRequested} @click=${()=>{this.requestLoadMore()}}>Load earlier messages</button>
|
|
858
|
-
<span>Scroll up to load earlier messages</span>
|
|
859
|
-
${e}
|
|
860
|
-
</div>
|
|
861
|
-
`:this.messages.length?c`<div class="history-boundary"><span>Beginning of session</span>${e}</div>`:null}historyRangeLabel(){if(!this.messages.length||this.messageTotal<=0)return null;const e=this.messageStart+1,t=this.loadedRawMessageEnd(),s=Math.max(this.messageTotal,t);return c`<small>Showing messages ${e}–${t} of ${s}</small>`}loadedRawMessageEnd(){return Math.max(this.messageEnd,this.messageStart+this.messages.length)}renderMessage(e,t){const s=this.isToolExecutionOnlyMessage(e);return c`
|
|
862
|
-
${this.renderScrollMarker(this.messageScrollMarkerId(t))}
|
|
863
|
-
<article class=${s?"msg tool-execution-shell":`msg ${e.role}`} data-index=${t} data-scroll-anchor-id=${this.messageAnchorKey(t)}>
|
|
864
|
-
${s?null:this.renderMessageHeader(e,String(t))}
|
|
865
|
-
${e.parts.map(i=>this.renderPart(i,e))}
|
|
866
|
-
</article>
|
|
867
|
-
`}isToolExecutionOnlyMessage(e){return e.role==="tool"&&e.parts.length>0&&e.parts.every(t=>t.type==="toolExecution")}renderMessageGroup(e,t,s,i){const r=this.groupDisclosureKey(t,s,i),o=this.disclosures.isOpen(r,i);return c`
|
|
868
|
-
${this.renderScrollMarker(this.groupScrollMarkerId(s))}
|
|
869
|
-
<details class=${i?"msg event-group live":"msg event-group"} data-index=${t} data-scroll-anchor-id=${this.groupAnchorKey(t)} ?open=${o} @toggle=${n=>{this.onGroupToggle(r,n,i)}}>
|
|
870
|
-
<summary>
|
|
871
|
-
<b class="label">${i?"live events":"events"}</b>
|
|
872
|
-
<span>${mp(e)}</span>
|
|
873
|
-
</summary>
|
|
874
|
-
<div class="group-body">
|
|
875
|
-
${e.map((n,a)=>{const l=this.isToolExecutionOnlyMessage(n);return c`
|
|
876
|
-
<section class=${l?"group-msg tool-execution-shell":`group-msg ${n.role}`} data-index=${t+a} data-scroll-anchor-id=${this.eventAnchorKey(t+a)}>
|
|
877
|
-
${l?null:this.renderMessageHeader(n,`${String(t)}:${String(a)}`)}
|
|
878
|
-
${n.parts.map(d=>this.renderPart(d,n))}
|
|
879
|
-
</section>
|
|
880
|
-
`})}
|
|
881
|
-
</div>
|
|
882
|
-
</details>
|
|
883
|
-
`}renderScrollMarker(e){return c`<span class="scroll-marker" data-marker-id=${e} aria-hidden="true"></span>`}renderMessageHeader(e,t){const s=this.messageMetaLabel(e),i=this.expandedMetaKey===t;return c`
|
|
884
|
-
<div class="msg-header">
|
|
885
|
-
<b class="label">${e.role}</b>
|
|
886
|
-
<div class="msg-header-trailing">
|
|
887
|
-
${this.renderMessageActions(e,t)}
|
|
888
|
-
<span class=${i?"msg-meta expanded":"msg-meta"} role="button" tabindex="0" title=${s.full} aria-label=${s.full} aria-expanded=${String(i)} @click=${()=>{this.expandedMetaKey=i?void 0:t}} @keydown=${r=>{this.onMetaKeydown(r,t,i)}}>${s.short}</span>
|
|
889
|
-
</div>
|
|
890
|
-
</div>
|
|
891
|
-
`}renderMessageActions(e,t){if(!this.isCopyableMessage(e))return null;const s=this.copiedMessageKey===t;return c`
|
|
892
|
-
<div class="msg-actions" aria-label="Message actions">
|
|
893
|
-
<button type="button" class="msg-action" title=${s?"Copied":"Copy message"} aria-label=${`${s?"Copied":"Copy"} ${e.role} message`} @click=${i=>{this.copyMessage(e,t,i)}}>
|
|
894
|
-
<span aria-hidden="true">${s?"✓":"⧉"}</span>
|
|
895
|
-
</button>
|
|
896
|
-
</div>
|
|
897
|
-
`}onMetaKeydown(e,t,s){e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.expandedMetaKey=s?void 0:t)}isCopyableMessage(e){return(e.role==="user"||e.role==="assistant")&&this.messageCopyText(e)!==""}messageCopyText(e){const t=this.messageCopyTextCache.get(e);if(t!==void 0)return t;const s=e.parts.filter(i=>i.type==="text").map(i=>i.text.trim()).filter(i=>i!=="").join(`
|
|
898
|
-
|
|
899
|
-
`);return this.messageCopyTextCache.set(e,s),s}async copyMessage(e,t,s){s.stopPropagation(),await this.writeClipboard(this.messageCopyText(e))&&(this.copiedMessageKey=t,window.setTimeout(()=>{this.copiedMessageKey===t&&(this.copiedMessageKey=void 0)},1200))}async writeClipboard(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}messageMetaLabel(e){const t=this.messageMetaCache.get(e);if(t!==void 0)return t;const s=e.meta?.timestamp,i=this.modelLabel(e);if(s===void 0&&i===void 0){const l={short:"no info",full:"No Pi message metadata available"};return this.messageMetaCache.set(e,l),l}const r=s===void 0?void 0:this.formatTimestamp(s),o=[r?.short,i].filter(l=>l!==void 0&&l!==""),n=[r?.full,i===void 0?void 0:`Model: ${i}`].filter(l=>l!==void 0&&l!==""),a={short:o.join(" · "),full:n.join(" · ")};return this.messageMetaCache.set(e,a),a}formatTimestamp(e){const t=new Date(e);if(Number.isFinite(t.getTime()))return{short:Zh.format(t),full:Xh.format(t)}}modelLabel(e){const t=e.meta?.model;if(t===void 0)return;const s=t.responseId??t.id;return s===void 0||s===""?t.provider:t.provider!==void 0&&t.provider!==""?`${t.provider}/${s}`:s}renderPart(e,t){return e.type==="text"&&t?.role==="bash"?c`<pre class="part shell-output">${e.text}</pre>`:e.type==="text"?c`<formatted-text class="part" .text=${e.text}></formatted-text>`:e.type==="thinking"?c`<details class="part"><summary>thinking</summary><formatted-text .text=${e.text}></formatted-text></details>`:e.type==="skillInvocation"?c`
|
|
900
|
-
<details class="part skill-invocation">
|
|
901
|
-
<summary><b>[skill]</b> ${e.name}</summary>
|
|
902
|
-
<small>${e.location}</small>
|
|
903
|
-
<formatted-text .text=${e.content}></formatted-text>
|
|
904
|
-
</details>
|
|
905
|
-
`:e.type==="skillRead"?c`
|
|
906
|
-
<div class="part skill-read">
|
|
907
|
-
<strong>Loaded ${e.name}</strong>
|
|
908
|
-
<small>read ${e.path}</small>
|
|
909
|
-
</div>
|
|
910
|
-
`:e.type==="toolCall"?c`<div class="part tool-line">▶ ${e.toolName}<span class="summary">${e.summary}</span></div>`:e.type==="toolExecution"?c`<tool-execution-view class="part" .execution=${e}></tool-execution-view>`:e.type==="toolResult"?c`
|
|
911
|
-
<details class="part" ?open=${e.isError}>
|
|
912
|
-
<summary>${e.isError?"✖":"✓"} ${e.toolName} result</summary>
|
|
913
|
-
<formatted-text .text=${e.text}></formatted-text>
|
|
914
|
-
</details>
|
|
915
|
-
`:null}onGroupToggle(e,t,s){const i=t.currentTarget;i instanceof HTMLDetailsElement&&this.disclosures.applyToggle(e,i.open,s)&&this.requestUpdate()}onScroll(){this.requestLoadMoreIfNeeded(),this.updatePinnedToBottomFromScroll(),this.scheduleConversationRailUpdate(),this.suppressScrollSave||this.scheduleScrollPositionSave()}onWheel(e){e.deltaY<0&&this.canScrollUp()&&(this.pinnedToBottom=!1)}onTouchStart(e){this.touchStartY=e.touches[0]?.clientY}onTouchMove(e){const t=e.touches[0]?.clientY;this.touchStartY!==void 0&&t!==void 0&&t>this.touchStartY&&this.canScrollUp()&&(this.pinnedToBottom=!1)}updatePinnedToBottomFromScroll(){const e=this.chat;if(!e)return;const t=this.didChatHeightChange(),s=this.pinnedToBottom,i=e.scrollTop<this.lastScrollTop;if(t&&s){this.lastClientHeight=e.clientHeight,this.scrollToBottom();return}this.isAtBottom()?this.pinnedToBottom=!0:i?this.pinnedToBottom=!1:this.pinnedToBottom=this.isNearBottom(),this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight}didChatHeightChange(){const e=this.chat;return e!==void 0&&this.lastClientHeight!==0&&e.clientHeight!==this.lastClientHeight}isPrependingMessages(e){const t=e.get("messageStart");return typeof t=="number"&&this.messageStart<t}requestLoadMoreIfNeeded(){this.loadMoreCheckFrame===void 0&&(this.loadMoreCheckFrame=requestAnimationFrame(()=>{if(this.loadMoreCheckFrame=void 0,this.suppressLoadMoreRequests)return;const e=this.chat;e&&Pp({hasMore:this.hasMore,loadingMore:this.loadingMore||this.loadMoreRequested,canRequest:this.onLoadMore!==void 0,scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight})&&this.requestLoadMore()}))}requestLoadMore(){this.loadMoreRequested||!this.hasMore||this.loadingMore||this.onLoadMore===void 0||(this.loadMoreRequested=!0,this.onLoadMore())}isNearBottom(){const e=this.chat;return e?Yr(e):!0}isAtBottom(){const e=this.chat;return e?Xr(e)<2:!0}canScrollUp(){const e=this.chat;return e!==void 0&&e.scrollTop>0}scrollToBottom(){this.scrollToBottomFrame===void 0&&(this.scrollToBottomFrame=requestAnimationFrame(()=>{this.scrollToBottomFrame=void 0;const e=this.chat;e&&this.withSuppressedScrollSave(()=>{e.scrollTop=e.scrollHeight,this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight})}))}restoreScrollPosition(){const e=this.sessionId;this.restoreScrollFrame!==void 0&&cancelAnimationFrame(this.restoreScrollFrame),this.restoreScrollFrame=requestAnimationFrame(()=>{this.restoreScrollFrame=void 0,this.sessionId===e&&this.withSuppressedScrollSave(()=>{const t=this.scrollController.restorePosition(e,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,t)})})}continuePendingScrollRestore(){const e=this.pendingScrollRestoreSessionId,t=this.pendingScrollRestorePosition;e===void 0||t===void 0||e!==this.sessionId||this.restoreScrollFrame!==void 0||(this.restoreScrollFrame=requestAnimationFrame(()=>{this.restoreScrollFrame=void 0,this.sessionId===e&&this.withSuppressedScrollSave(()=>{const s=this.scrollController.restoreExplicitPosition(t,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,s)})}))}handleScrollRestoreResult(e,t){if(this.syncScrollMetrics(),t.status!=="missing"){this.updatePinnedToBottomAfterRestore(t.status),(t.status==="restored"||t.status==="bottom")&&this.cancelPrependRestore(),this.pendingScrollRestoreSessionId=void 0,this.pendingScrollRestorePosition=void 0;return}this.pinnedToBottom=!1,this.pendingScrollRestoreSessionId=e,this.pendingScrollRestorePosition=t.position;const s=this.chat;s===void 0||!this.hasMore||this.loadingMore||(s.scrollTop=0,this.syncScrollMetrics(),this.requestLoadMore())}shouldFallbackToBottomForMissingAnchor(){return!this.hasMore&&!this.isReceivingPartialStream}updatePinnedToBottomAfterRestore(e){e==="bottom"?this.pinnedToBottom=!0:e==="restored"&&(this.pinnedToBottom=this.isNearBottom())}syncScrollMetrics(){const e=this.chat;e!==void 0&&(this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight)}cancelPrependRestore(){this.prependRestoreToken+=1,this.suppressLoadMoreRequests=!1}capturePrependScrollAnchor(){const e=this.chat;if(e)return vp(e,this.scrollMarkers())}restorePrependScrollAnchor(e){if(!this.chat||!e)return;this.suppressLoadMoreRequests=!0,this.suppressScrollSave=!0;const t=this.prependRestoreToken+1;this.prependRestoreToken=t;let s=0;const i=()=>{const r=this.chat;if(!(!r||t!==this.prependRestoreToken)){if(bp(r,e,e.markerId===void 0?void 0:this.scrollMarkerAt(e.markerId)),this.lastScrollTop=r.scrollTop,s+=1,s<gp){requestAnimationFrame(i);return}requestAnimationFrame(()=>{t===this.prependRestoreToken&&(this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1)})}};i()}saveScrollPosition(e=this.sessionId){e&&this.scrollController.savePosition(e,this.chat,this.scrollAnchorElements())}scheduleScrollPositionSave(){const e=this.sessionId;this.scrollController.scheduleSave(e,t=>{this.sessionId===t&&this.saveScrollPosition(t)})}scheduleConversationRailUpdate(){this.conversationRailFrame===void 0&&(this.conversationRailFrame=requestAnimationFrame(()=>{this.conversationRailFrame=void 0,this.updateConversationRailPosition()}))}updateConversationRailPosition(){if(!this.messages.length||this.messageTotal<=0){this.currentConversationIndex=void 0;return}const e=this.conversationDisplayTotal(),t=this.firstVisibleArticle(),s=Number(t?.dataset.index);if(Number.isFinite(s)){this.currentConversationIndex=kt(s,0,Math.max(0,e-1));return}this.currentConversationIndex=kt(this.pinnedToBottom?this.messageStart+this.messages.length-1:this.messageStart,0,Math.max(0,e-1))}scrollMarkers(){return Array.from(this.renderRoot.querySelectorAll(".scroll-marker"))}scrollMarkerAt(e){return this.scrollMarkers().find(t=>t.dataset.markerId===e)}firstVisibleArticle(){const e=this.chat;if(e===void 0)return;const t=Array.from(this.renderRoot.querySelectorAll("article.msg"));return Ui(e,t)??Ui(e,this.articles())}articles(){return Array.from(this.renderRoot.querySelectorAll("article.msg, details.msg"))}scrollAnchorElements(){return Array.from(this.renderRoot.querySelectorAll("[data-scroll-anchor-id]"))}withSuppressedScrollSave(e){this.suppressScrollSave=!0,e(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.suppressScrollSave=!1})})}groupDisclosureKey(e,t,s){return s?`${this.sessionId}:live:${String(e)}`:`${this.sessionId}:${String(t)}`}messageAnchorKey(e){return`m:${String(e)}`}groupRenderKey(e){return`g:${String(e)}`}groupAnchorKey(e){return`g:${String(e)}`}eventAnchorKey(e){return`e:${String(e)}`}messageScrollMarkerId(e){return`m:${String(e)}`}groupScrollMarkerId(e){return`g:${String(e)}`}};R.styles=Nd;_([p({attribute:!1})],R.prototype,"messages",2);_([p()],R.prototype,"sessionId",2);_([p({type:Number})],R.prototype,"messageStart",2);_([p({type:Number})],R.prototype,"messageEnd",2);_([p({type:Number})],R.prototype,"messageTotal",2);_([p({type:Boolean})],R.prototype,"hasMore",2);_([p({type:Boolean})],R.prototype,"loadingMore",2);_([p({type:Boolean})],R.prototype,"isReceivingPartialStream",2);_([p({type:Boolean})],R.prototype,"isCompacting",2);_([p({type:Number})],R.prototype,"pendingMessageCount",2);_([p({attribute:!1})],R.prototype,"status",2);_([p({attribute:!1})],R.prototype,"activity",2);_([p({attribute:!1})],R.prototype,"onLoadMore",2);_([ne(".chat")],R.prototype,"chat",2);_([k()],R.prototype,"pinnedToBottom",2);_([k()],R.prototype,"expandedMetaKey",2);_([k()],R.prototype,"copiedMessageKey",2);_([k()],R.prototype,"currentConversationIndex",2);_([k()],R.prototype,"loadMoreRequested",2);R=_([M("chat-view")],R);class Yh extends Bs{constructor(t){super(t),this.wasSelected=!1,this.isElementPart=t.type===Ns.ELEMENT}update(t,[s,i]){if(!this.isElementPart)throw new Error("scrollWhenSelected must be used on an element");if(s&&(!this.wasSelected||i!==this.previousKey)){const r="element"in t?t.element:void 0;requestAnimationFrame(()=>{r instanceof HTMLElement&&r.scrollIntoView({block:"nearest"})})}this.wasSelected=s,this.previousKey=i}render(t,s){}}const Ys=Fs(Yh);var eu=Object.defineProperty,tu=Object.getOwnPropertyDescriptor,Ht=(e,t,s,i)=>{for(var r=i>1?void 0:i?tu(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&eu(t,s,r),r};let je=class extends C{constructor(){super(...arguments),this.items=[],this.selectedIndex=0}render(){return this.items.length?c`
|
|
916
|
-
<div class="menu">
|
|
917
|
-
${this.items.map((e,t)=>c`
|
|
918
|
-
<button class=${t===this.selectedIndex?"selected":""} ${Ys(t===this.selectedIndex,e)} @mousedown=${s=>{s.preventDefault(),this.onPick?.(e)}}>
|
|
919
|
-
<strong>${e.insertText}</strong>
|
|
920
|
-
<span>${e.detail}</span>
|
|
921
|
-
${e.description!==void 0&&e.description!==""?c`<small>${e.description}</small>`:null}
|
|
922
|
-
</button>
|
|
923
|
-
`)}
|
|
924
|
-
</div>
|
|
925
|
-
`:null}};je.styles=zd;Ht([p({attribute:!1})],je.prototype,"items",2);Ht([p({type:Number})],je.prototype,"selectedIndex",2);Ht([p({attribute:!1})],je.prototype,"onPick",2);je=Ht([M("autocomplete-menu")],je);var su=Object.defineProperty,iu=Object.getOwnPropertyDescriptor,z=(e,t,s,i)=>{for(var r=i>1?void 0:i?iu(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&su(t,s,r),r};let N=class extends C{constructor(){super(...arguments),this.disabled=!1,this.canSteer=!1,this.isCompacting=!1,this.canStop=!1,this.draft="",this.completions=[],this.selectedIndex=0,this.requestVersion=0,this.editableCompartment=new ti,this.readOnlyCompartment=new ti}willUpdate(e){if(!e.has("sessionId"))return;const t=e.get("sessionId");t!==void 0&&t!==""&&At(t,this.draft),this.draft=this.sessionId!==void 0&&this.sessionId!==""?kr(this.sessionId):"",this.completions=[],this.selectedIndex=0}firstUpdated(){this.createEditor()}updated(e){e.has("disabled")&&this.updateEditorDisabledState(),(e.has("draft")||e.has("sessionId"))&&this.syncEditorDoc()}disconnectedCallback(){this.editor?.destroy(),this.editor=void 0,super.disconnectedCallback()}render(){const e=Ms(this.draft),t=e.kind==="shell",s=this.canSteer||this.isCompacting;return c`
|
|
926
|
-
<footer class=${t?"shell-mode":""}>
|
|
927
|
-
<div class="editor-wrap">
|
|
928
|
-
<div class=${`markdown-editor${this.disabled?" markdown-editor-disabled":""}`} aria-label="Message pi" aria-disabled=${this.disabled?"true":"false"}></div>
|
|
929
|
-
${t?c`<div class="mode-hint">Shell command${e.excludeFromContext?" · excluded from context":""}</div>`:null}
|
|
930
|
-
${this.isCompacting&&!t?c`<div class="mode-hint">Compacting history · message will be queued</div>`:null}
|
|
931
|
-
<autocomplete-menu .items=${this.completions} .selectedIndex=${this.selectedIndex} .onPick=${i=>{this.pick(i)}}></autocomplete-menu>
|
|
932
|
-
</div>
|
|
933
|
-
<div class="actions">
|
|
934
|
-
${this.renderCompactStatus()}
|
|
935
|
-
<button ?disabled=${this.disabled} title=${s?"Queue until the current activity finishes":"Send message"} @click=${()=>{this.send("followUp")}}>${s?"Queue":"Send"}</button>
|
|
936
|
-
${this.canSteer&&!this.isCompacting?c`<button ?disabled=${this.disabled} title="Steer the current response before the next model call" @click=${()=>{this.send("steer")}}>Steer</button>`:null}
|
|
937
|
-
<button ?disabled=${this.disabled||!this.canStop} title=${this.canStop?"Stop current work and clear queued messages":"Nothing running"} @click=${()=>this.onStop?.()}>Stop</button>
|
|
938
|
-
</div>
|
|
939
|
-
</footer>
|
|
940
|
-
`}focusInput(){this.editor?.focus()}renderCompactStatus(){const e=this.status;if(e===void 0)return null;const t=e.model?.id??"no model",s=e.model?.provider!==void 0&&e.model.provider!==""?`${e.model.provider}/`:"";return c`
|
|
941
|
-
<div class="compact-status" aria-label="Session status">
|
|
942
|
-
<button class="select-model" title="Select model" @click=${()=>this.onSelectModel?.()}>${s}${t}</button>
|
|
943
|
-
<button class="select-thinking" title="Select thinking level" @click=${()=>this.onSelectThinking?.()}>think ${e.thinkingLevel??"off"}</button>
|
|
944
|
-
</div>
|
|
945
|
-
`}createEditor(){!this.editorHost||this.editor!==void 0||(this.editor=new De({parent:this.editorHost,state:Gt.create({doc:this.draft,extensions:[vo(),Co(),bo(),wo.of(" "),yo(To,{fallback:!0}),De.lineWrapping,De.contentAttributes.of(e=>cu(e.state.sliceDoc(0,e.state.selection.main.head))),xo("Message pi... Use / for commands, @ for tracked files, @ space for all files"),this.editableCompartment.of(De.editable.of(!this.disabled)),this.readOnlyCompartment.of(Gt.readOnly.of(this.disabled)),De.updateListener.of(e=>{e.docChanged&&this.updateDraft(e.state.doc.toString())}),ko.of([{key:"ArrowDown",run:()=>this.moveCompletion(1)},{key:"ArrowUp",run:()=>this.moveCompletion(-1)},{key:"Escape",run:()=>this.closeCompletions()},{key:"Enter",run:()=>this.handleEditorEnter()},{key:"Shift-Enter",run:e=>Ao(e)||Po(e)},{key:"Tab",run:e=>this.handleEditorTab(e)},{key:"Shift-Tab",run:e=>si.shift?.(e)??!1},{key:"Backspace",run:e=>Io(e)},...So,...$o])]})}))}syncEditorDoc(){const e=this.editor;if(!e)return;const t=e.state.doc.toString();t!==this.draft&&e.dispatch({changes:{from:0,to:t.length,insert:this.draft},selection:ii.cursor(this.draft.length)})}updateEditorDisabledState(){this.editor?.dispatch({effects:[this.editableCompartment.reconfigure(De.editable.of(!this.disabled)),this.readOnlyCompartment.reconfigure(Gt.readOnly.of(this.disabled))]})}updateDraft(e){this.draft=e,this.sessionId!==void 0&&this.sessionId!==""&&At(this.sessionId,this.draft),this.refreshCompletions()}async refreshCompletions(){const e=this.currentTrigger(),t=++this.requestVersion;if(this.selectedIndex=0,e===void 0){this.completions=[];return}if(e.kind==="command"&&this.sessionId!==void 0&&this.sessionId!==""){const s=await F.commands(this.sessionId).catch(ou);if(t!==this.requestVersion)return;this.completions=s.filter(i=>i.name.toLowerCase().includes(e.query.toLowerCase())).slice(0,12).map(i=>({kind:"command",replaceFrom:e.from,replaceTo:e.to,insertText:`/${i.name}`,detail:i.source,...i.description===void 0?{}:{description:i.description}}))}else if(e.kind==="file"&&this.cwd!==void 0&&this.cwd!==""){const s=await F.files(this.cwd,e.query,{scope:e.fileScope}).catch(nu);if(t!==this.requestVersion)return;this.completions=s.slice(0,12).map(i=>{const r=ru(i.path,e.quoted===!0,i.path.endsWith("/")?e.allPrefix:void 0);return{kind:"file",replaceFrom:e.from,replaceTo:e.to,insertText:r,detail:i.kind,...i.path.endsWith("/")&&r.endsWith('"')?{cursorOffset:r.length-1}:{}}})}}currentTrigger(){const e=this.editor?.state.selection.main.head??this.draft.length,t=this.draft.slice(0,e),s=this.currentQuotedTrigger(t,e);if(s!==void 0)return s;const i=Math.max(t.lastIndexOf(" "),t.lastIndexOf(`
|
|
946
|
-
`))+1,r=t.slice(i);if(t.slice(0,i).endsWith("@ "))return{kind:"file",query:r,from:i-2,to:e,fileScope:"all",allPrefix:"@ "};if(r.startsWith("/")&&i===0)return{kind:"command",query:r.slice(1),from:i,to:e};if(r.startsWith("!@"))return{kind:"file",query:r.slice(2),from:i,to:e,fileScope:"all",allPrefix:"!@"};if(r.startsWith("@"))return{kind:"file",query:r.slice(1),from:i,to:e,fileScope:"tracked"}}currentQuotedTrigger(e,t){const s=e.lastIndexOf('"');if(s===-1)return;const i=e.slice(0,s);if(i.endsWith("!@"))return{kind:"file",query:e.slice(s+1),from:i.length-2,to:t,fileScope:"all",allPrefix:"!@",quoted:!0};if(i.endsWith("@"))return{kind:"file",query:e.slice(s+1),from:i.length-1,to:t,fileScope:"tracked",quoted:!0};if(i.endsWith("@ "))return{kind:"file",query:e.slice(s+1),from:i.length-2,to:t,fileScope:"all",allPrefix:"@ ",quoted:!0}}moveCompletion(e){return this.completions.length?(this.selectedIndex=(this.selectedIndex+e+this.completions.length)%this.completions.length,!0):!1}closeCompletions(){return this.completions.length?(this.completions=[],!0):!1}handleEditorEnter(){if(this.completions.length){const e=this.completions[this.selectedIndex];return e!==void 0&&this.pick(e),!0}return this.send(this.canSteer||this.isCompacting?"followUp":void 0),!0}handleEditorTab(e){if(this.completions.length){const s=this.completions[this.selectedIndex];return s!==void 0&&this.pick(s),!0}return this.currentTrigger()?.kind==="file"?(this.refreshCompletions(),!0):si.run?.(e)??!1}pick(e){const t=this.editor;if(!t)return;const s=e.kind==="file"&&(e.insertText.endsWith("/")||e.cursorOffset!==void 0)?"":" ",i=e.replaceFrom+(e.cursorOffset??e.insertText.length)+s.length,r=e.insertText.endsWith('"')&&this.draft.slice(e.replaceTo).startsWith('"')?e.replaceTo+1:e.replaceTo;t.dispatch({changes:{from:e.replaceFrom,to:r,insert:`${e.insertText}${s}`},selection:ii.cursor(i),scrollIntoView:!0}),this.completions=[]}send(e){const t=this.draft.trim();t===""||this.disabled||(this.draft="",this.sessionId!==void 0&&this.sessionId!==""&&Rs(this.sessionId),this.completions=[],this.onSend?.(t,this.canSteer||this.isCompacting?e:void 0))}};N.styles=Hd;z([p({type:Boolean})],N.prototype,"disabled",2);z([p()],N.prototype,"sessionId",2);z([p()],N.prototype,"cwd",2);z([p({type:Boolean})],N.prototype,"canSteer",2);z([p({type:Boolean})],N.prototype,"isCompacting",2);z([p({type:Boolean})],N.prototype,"canStop",2);z([p({attribute:!1})],N.prototype,"status",2);z([p({attribute:!1})],N.prototype,"onSend",2);z([p({attribute:!1})],N.prototype,"onStop",2);z([p({attribute:!1})],N.prototype,"onSelectModel",2);z([p({attribute:!1})],N.prototype,"onSelectThinking",2);z([ne(".markdown-editor")],N.prototype,"editorHost",2);z([k()],N.prototype,"draft",2);z([k()],N.prototype,"completions",2);z([k()],N.prototype,"selectedIndex",2);N=z([M("prompt-editor")],N);function ru(e,t,s){const i=s??"@";return!t&&!e.includes(" ")?`${i}${e}`:`${i}"${e}"`}function ou(){return[]}function nu(){return[]}const au={spellcheck:"true",autocorrect:"on",autocapitalize:"sentences",writingsuggestions:"true"},lu={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false"};function cu(e){return Ms(e).kind==="normal"?au:lu}function gt(e){return Number.isFinite(e)?e<1e3?Math.round(e).toString():e<1e4?`${(e/1e3).toFixed(1)}k`:e<1e6?`${String(Math.round(e/1e3))}k`:e<1e7?`${(e/1e6).toFixed(1)}M`:`${String(Math.round(e/1e6))}M`:"0"}function du(e){return!Number.isFinite(e)||e===0?"$0":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}var pu=Object.defineProperty,hu=Object.getOwnPropertyDescriptor,Ut=(e,t,s,i)=>{for(var r=i>1?void 0:i?hu(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&pu(t,s,r),r};let Ne=class extends C{constructor(){super(...arguments),this.workspaceLabelItems=[]}render(){const e=this.status;if(e===void 0)return c`<div class="bar muted">No session status yet</div>`;const t=e.contextUsage,s=t?t.percent==null?`context ${gt(t.contextWindow)}`:`${t.percent.toFixed(1)}%/${gt(t.contextWindow)}`:"context unknown",i=e.tokens;return c`
|
|
947
|
-
<div class="bar">
|
|
948
|
-
<span>${Qr(this.workspace?.label??"workspace",this.workspaceLabelItems,this.workspace?.path)}</span>
|
|
949
|
-
<span>↑${gt(i.input)}</span>
|
|
950
|
-
<span>↓${gt(i.output)}</span>
|
|
951
|
-
<span>${s}</span>
|
|
952
|
-
<span>${du(e.cost)}</span>
|
|
953
|
-
${e.pendingMessageCount>0?c`<span>${String(e.pendingMessageCount)} queued</span>`:null}
|
|
954
|
-
</div>
|
|
955
|
-
`}};Ne.styles=Bd;Ut([p({attribute:!1})],Ne.prototype,"status",2);Ut([p({attribute:!1})],Ne.prototype,"workspace",2);Ut([p({attribute:!1})],Ne.prototype,"workspaceLabelItems",2);Ne=Ut([M("status-bar")],Ne);var uu=Object.defineProperty,fu=Object.getOwnPropertyDescriptor,he=(e,t,s,i)=>{for(var r=i>1?void 0:i?fu(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&uu(t,s,r),r};let te=class extends C{constructor(){super(...arguments),this.title="Select",this.searchable=!1,this.options=[],this.selectedIndex=0,this.query=""}render(){const e=this.filteredOptions();return c`
|
|
956
|
-
<div class="backdrop" @mousedown=${()=>this.onCancel?.()}>
|
|
957
|
-
<section @mousedown=${t=>{t.stopPropagation()}}>
|
|
958
|
-
<header>
|
|
959
|
-
<strong>${this.title}</strong>
|
|
960
|
-
<button @click=${()=>this.onCancel?.()}>×</button>
|
|
961
|
-
</header>
|
|
962
|
-
${this.searchable?c`<input placeholder="Search" .value=${this.query} @input=${t=>{this.handleSearchInput(t)}} @keydown=${t=>{this.handleKeyDown(t)}}>`:null}
|
|
963
|
-
<div class="options" @keydown=${t=>{this.handleKeyDown(t)}} tabindex="0">
|
|
964
|
-
${e.map((t,s)=>c`
|
|
965
|
-
<button class=${s===this.selectedIndex?"selected":""} ${Ys(s===this.selectedIndex,t.value)} @click=${()=>this.onPick?.(t.value)}>
|
|
966
|
-
<span>${t.label}</span>
|
|
967
|
-
${t.description!==void 0&&t.description!==""?c`<small>${t.description}</small>`:null}
|
|
968
|
-
</button>
|
|
969
|
-
`)}
|
|
970
|
-
${e.length===0?c`<div class="empty">No matching options</div>`:null}
|
|
971
|
-
</div>
|
|
972
|
-
</section>
|
|
973
|
-
</div>
|
|
974
|
-
`}firstUpdated(){this.selectInitialValue(),this.renderRoot.querySelector(this.searchable?"input":".options")?.focus()}selectInitialValue(){if(this.selectedValue===void 0)return;const e=this.filteredOptions().findIndex(t=>t.value===this.selectedValue);e>=0&&(this.selectedIndex=e)}handleSearchInput(e){e.target instanceof HTMLInputElement&&(this.query=e.target.value,this.selectedIndex=0)}filteredOptions(){const e=this.query.trim().toLowerCase();return e===""?this.options:this.options.filter(t=>`${t.label} ${t.description??""} ${t.value}`.toLowerCase().includes(e))}handleKeyDown(e){const t=this.filteredOptions();if(e.key==="Escape")e.preventDefault(),this.onCancel?.();else if(e.key==="ArrowDown")e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex+1)%t.length);else if(e.key==="ArrowUp")e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex-1+t.length)%t.length);else if(e.key==="Enter"){e.preventDefault();const s=t[this.selectedIndex];s&&this.onPick?.(s.value)}}};te.styles=Kr;he([p()],te.prototype,"title",2);he([p({type:Boolean})],te.prototype,"searchable",2);he([p({attribute:!1})],te.prototype,"options",2);he([p({attribute:!1})],te.prototype,"selectedValue",2);he([p({attribute:!1})],te.prototype,"onPick",2);he([p({attribute:!1})],te.prototype,"onCancel",2);he([k()],te.prototype,"selectedIndex",2);he([k()],te.prototype,"query",2);te=he([M("command-picker")],te);var mu=Object.defineProperty,gu=Object.getOwnPropertyDescriptor,Ie=(e,t,s,i)=>{for(var r=i>1?void 0:i?gu(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&mu(t,s,r),r};let ce=class extends C{constructor(){super(...arguments),this.actions=[],this.queryText="",this.selectedIndex=0}render(){const e=this.filteredActions();return c`
|
|
975
|
-
<div class="backdrop" @mousedown=${()=>this.onCancel?.()}>
|
|
976
|
-
<section @mousedown=${t=>{t.stopPropagation()}} @keydown=${t=>{this.handleKeyDown(t)}}>
|
|
977
|
-
<header>
|
|
978
|
-
<input
|
|
979
|
-
.value=${this.queryText}
|
|
980
|
-
placeholder="Search actions..."
|
|
981
|
-
@input=${t=>{t.target instanceof HTMLInputElement&&(this.queryText=t.target.value,this.selectedIndex=0)}}
|
|
982
|
-
>
|
|
983
|
-
<button title="Close" @click=${()=>this.onCancel?.()}>×</button>
|
|
984
|
-
</header>
|
|
985
|
-
<div class="options">
|
|
986
|
-
${e.length===0?c`<div class="empty">No actions found.</div>`:e.map((t,s)=>c`
|
|
987
|
-
<button class=${s===this.selectedIndex?"selected":""} ${Ys(s===this.selectedIndex,t.id)} @click=${()=>{this.run(t)}}>
|
|
988
|
-
<span class="main">
|
|
989
|
-
<strong>${t.title}</strong>
|
|
990
|
-
${t.description!==void 0&&t.description!==""?c`<small>${t.description}</small>`:null}
|
|
991
|
-
</span>
|
|
992
|
-
${t.shortcut!==void 0?c`<kbd>${tc(t.shortcut)}</kbd>`:null}
|
|
993
|
-
${t.group!==void 0&&t.group!==""?c`<small class="group">${t.group}</small>`:null}
|
|
994
|
-
</button>
|
|
995
|
-
`)}
|
|
996
|
-
</div>
|
|
997
|
-
</section>
|
|
998
|
-
</div>
|
|
999
|
-
`}firstUpdated(){this.input?.focus()}updated(e){if(!e.has("actions")&&!e.has("queryText"))return;const t=Math.max(0,this.filteredActions().length-1);this.selectedIndex>t&&(this.selectedIndex=t)}filteredActions(){const e=this.queryText.trim().toLowerCase();return this.actions.filter(t=>t.enabled!==!1).filter(t=>e===""?!0:[t.title,t.description??"",t.group??"",t.shortcut??""].join(" ").toLowerCase().includes(e))}handleKeyDown(e){const t=this.filteredActions();if(e.key==="Escape")e.preventDefault(),this.onCancel?.();else if(e.key==="ArrowDown")e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex+1)%t.length);else if(e.key==="ArrowUp")e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex-1+t.length)%t.length);else if(e.key==="Enter"){e.preventDefault();const s=t[this.selectedIndex];s!==void 0&&this.run(s)}}run(e){this.onRun?.(e)}};ce.styles=qd;Ie([p({attribute:!1})],ce.prototype,"actions",2);Ie([p({attribute:!1})],ce.prototype,"onRun",2);Ie([p({attribute:!1})],ce.prototype,"onCancel",2);Ie([ne("input")],ce.prototype,"input",2);Ie([k()],ce.prototype,"queryText",2);Ie([k()],ce.prototype,"selectedIndex",2);ce=Ie([M("action-palette")],ce);var vu=Object.defineProperty,bu=Object.getOwnPropertyDescriptor,Z=(e,t,s,i)=>{for(var r=i>1?void 0:i?bu(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&vu(t,s,r),r};let U=class extends C{render(){const e=this.state;return e===void 0?null:c`
|
|
1000
|
-
<div class="backdrop" @mousedown=${()=>{this.cancel()}}>
|
|
1001
|
-
<section @mousedown=${t=>{t.stopPropagation()}} @keydown=${t=>{this.handleKeyDown(t)}}>
|
|
1002
|
-
<header>
|
|
1003
|
-
<strong>${this.dialogTitle(e)}</strong>
|
|
1004
|
-
<button title="Close" @click=${()=>{this.cancel()}}>×</button>
|
|
1005
|
-
</header>
|
|
1006
|
-
${this.renderBody(e)}
|
|
1007
|
-
</section>
|
|
1008
|
-
</div>
|
|
1009
|
-
`}updated(){this.focusInputIfNeeded()}dialogTitle(e){switch(e.step){case"method":return"Configure provider authentication";case"providers":return e.authType===void 0?"Select provider authentication":e.authType==="oauth"?"Select subscription provider":"Select API key provider";case"apiKey":return`API key for ${e.provider.name}`;case"oauth":return`Login to ${e.flow.providerName}`;case"logout":return"Remove stored provider authentication"}}renderBody(e){switch(e.step){case"method":return c`
|
|
1010
|
-
<div class="options">
|
|
1011
|
-
<button @click=${()=>{this.onChooseMethod?.("oauth")}}><span>Use a subscription</span><small>ChatGPT Plus/Pro, Claude Pro/Max, or GitHub Copilot</small></button>
|
|
1012
|
-
<button @click=${()=>{this.onChooseMethod?.("api_key")}}><span>Use an API key</span><small>Store an API key in pi auth.json</small></button>
|
|
1013
|
-
</div>
|
|
1014
|
-
`;case"providers":return c`<div class="options">${e.providers.length===0?c`<div class="empty">No providers available.</div>`:e.providers.map(t=>this.renderProviderButton(t))}</div>`;case"apiKey":return c`
|
|
1015
|
-
<div class="form">
|
|
1016
|
-
<p>Enter the API key for <strong>${e.provider.name}</strong>. It will be stored by pi in <code>auth.json</code>.</p>
|
|
1017
|
-
<input type="password" autocomplete="off" placeholder="API key" .value=${e.value} @input=${t=>{t.target instanceof HTMLInputElement&&this.onApiKeyInput?.(t.target.value)}}>
|
|
1018
|
-
${e.error!==void 0&&e.error!==""?c`<div class="error-text">${e.error}</div>`:null}
|
|
1019
|
-
<div class="actions"><button @click=${()=>{this.cancel()}}>Cancel</button><button class="primary" ?disabled=${e.saving===!0} @click=${()=>{this.onSaveApiKey?.()}}>${e.saving===!0?"Saving…":"Save API key"}</button></div>
|
|
1020
|
-
</div>
|
|
1021
|
-
`;case"oauth":return this.renderOAuth(e);case"logout":return c`<div class="options">${e.providers.length===0?c`<div class="empty">No stored credentials. Environment variables and models.json settings are unchanged.</div>`:e.providers.map(t=>c`
|
|
1022
|
-
<button @click=${()=>{this.onLogoutProvider?.(t.id)}}><span>${t.name}</span><small>${t.id} · ${rr(t.authType)}</small></button>
|
|
1023
|
-
`)}</div>`}}renderProviderButton(e){return c`
|
|
1024
|
-
<button @click=${()=>{this.onSelectProvider?.(e.id,e.authType)}}>
|
|
1025
|
-
<span>${e.name}${e.status.source!==void 0?c` <em>${yu(e)}</em>`:null}</span>
|
|
1026
|
-
<small>${e.id} · ${rr(e.authType)}</small>
|
|
1027
|
-
</button>
|
|
1028
|
-
`}renderOAuth(e){const t=e.flow,s=t.prompt,i=t.select;return c`
|
|
1029
|
-
<div class="form">
|
|
1030
|
-
${t.auth!==void 0?c`
|
|
1031
|
-
<p>Open this authorization link:</p>
|
|
1032
|
-
<p><a href=${t.auth.url} target="_blank" rel="noreferrer">${t.auth.url}</a></p>
|
|
1033
|
-
${t.auth.instructions!==void 0?c`<p class="warning">${t.auth.instructions}</p>`:null}
|
|
1034
|
-
`:c`<p>Starting login flow…</p>`}
|
|
1035
|
-
${t.progress.length>0?c`<ul class="progress">${t.progress.map(r=>c`<li>${r}</li>`)}</ul>`:null}
|
|
1036
|
-
${s!==void 0?c`
|
|
1037
|
-
<label>${s.message}</label>
|
|
1038
|
-
<input .value=${e.inputValue??""} placeholder=${s.placeholder??""} @input=${r=>{r.target instanceof HTMLInputElement&&this.onOAuthInput?.(r.target.value)}}>
|
|
1039
|
-
<div class="actions"><button @click=${()=>{this.onOAuthCancel?.()}}>Cancel</button><button class="primary" ?disabled=${e.responding===!0} @click=${()=>{this.onOAuthRespond?.()}}>Submit</button></div>
|
|
1040
|
-
`:null}
|
|
1041
|
-
${i!==void 0?c`
|
|
1042
|
-
<p>${i.message}</p>
|
|
1043
|
-
<div class="inline-options">${i.options.map(r=>c`<button @click=${()=>{this.onOAuthRespond?.(r.value)}}>${r.label}</button>`)}</div>
|
|
1044
|
-
`:null}
|
|
1045
|
-
${e.error!==void 0&&e.error!==""?c`<div class="error-text">${e.error}</div>`:null}
|
|
1046
|
-
${t.status==="error"||t.status==="cancelled"?c`<div class="error-text">${t.error??t.status}</div><div class="actions"><button @click=${()=>{this.cancel()}}>Close</button></div>`:null}
|
|
1047
|
-
${s===void 0&&i===void 0&&t.status==="running"?c`<div class="actions"><button @click=${()=>{this.onOAuthCancel?.()}}>Cancel</button></div>`:null}
|
|
1048
|
-
</div>
|
|
1049
|
-
`}focusInputIfNeeded(){const e=wu(this.state);if(e===void 0){this.lastFocusedInputKey=void 0;return}e!==this.lastFocusedInputKey&&(this.lastFocusedInputKey=e,this.input?.focus())}handleKeyDown(e){if(e.key==="Escape"){e.preventDefault(),this.cancel();return}if(e.key!=="Enter")return;const t=this.state;t?.step==="apiKey"?(e.preventDefault(),this.onSaveApiKey?.()):t?.step==="oauth"&&t.flow.prompt!==void 0&&(e.preventDefault(),this.onOAuthRespond?.())}cancel(){this.state?.step==="oauth"?this.onOAuthCancel?.():this.onCancel?.()}};U.styles=[Kr,j`
|
|
1050
|
-
.form { display: grid; gap: 12px; padding: 14px; overflow: auto; }
|
|
1051
|
-
.form p { margin: 0; color: var(--pi-text-secondary); overflow-wrap: anywhere; }
|
|
1052
|
-
.form a { color: var(--pi-accent); overflow-wrap: anywhere; }
|
|
1053
|
-
.form code { border: 1px solid var(--pi-border); border-radius: 4px; background: var(--pi-surface); padding: 1px 4px; }
|
|
1054
|
-
label { color: var(--pi-muted); }
|
|
1055
|
-
.actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
1056
|
-
.actions button, .inline-options button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; }
|
|
1057
|
-
.actions button.primary { border-color: var(--pi-success-border); background: var(--pi-success-surface); color: var(--pi-success); }
|
|
1058
|
-
.actions button:disabled { opacity: .6; cursor: wait; }
|
|
1059
|
-
.warning { color: var(--pi-warning); }
|
|
1060
|
-
.error-text { color: var(--pi-danger); }
|
|
1061
|
-
.progress { margin: 0; padding-left: 18px; color: var(--pi-muted); }
|
|
1062
|
-
.inline-options { display: grid; gap: 8px; }
|
|
1063
|
-
em { color: var(--pi-success); font-style: normal; font-size: 12px; }
|
|
1064
|
-
`];Z([p({attribute:!1})],U.prototype,"state",2);Z([p({attribute:!1})],U.prototype,"onChooseMethod",2);Z([p({attribute:!1})],U.prototype,"onSelectProvider",2);Z([p({attribute:!1})],U.prototype,"onApiKeyInput",2);Z([p({attribute:!1})],U.prototype,"onSaveApiKey",2);Z([p({attribute:!1})],U.prototype,"onLogoutProvider",2);Z([p({attribute:!1})],U.prototype,"onOAuthInput",2);Z([p({attribute:!1})],U.prototype,"onOAuthRespond",2);Z([p({attribute:!1})],U.prototype,"onOAuthCancel",2);Z([p({attribute:!1})],U.prototype,"onCancel",2);Z([ne("input")],U.prototype,"input",2);U=Z([M("auth-dialog")],U);function rr(e){return e==="oauth"?"subscription":"API key"}function wu(e){if(e?.step==="apiKey")return`api-key:${e.provider.authType}:${e.provider.id}`;if(e?.step==="oauth"&&e.flow.prompt!==void 0)return`oauth:${e.flow.flowId}:${e.flow.prompt.requestId}`}function yu(e){if(e.status.source===void 0)return"";switch(e.status.source){case"stored":return"✓ configured";case"environment":return`✓ env${e.status.label===void 0?"":`: ${e.status.label}`}`;case"runtime":return"✓ runtime";case"fallback":return"✓ custom key";case"models_json_key":return"✓ models.json key";case"models_json_command":return"✓ models.json command";default:return""}}var xu=Object.defineProperty,ku=Object.getOwnPropertyDescriptor,ue=(e,t,s,i)=>{for(var r=i>1?void 0:i?ku(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&xu(t,s,r),r};let se=class extends C{constructor(){super(...arguments),this.path="",this.createMissing=!0,this.suggestions=[],this.selected=0,this.loading=!1,this.requestId=0}connectedCallback(){super.connectedCallback(),this.loadSuggestions()}firstUpdated(){this.pathInput?.focus()}async loadSuggestions(){const e=++this.requestId;this.loading=!0;try{const t=await F.projectDirectories(this.path);if(e!==this.requestId)return;this.suggestions=t,this.selected=Math.min(this.selected,Math.max(0,t.length-1))}catch{e===this.requestId&&(this.suggestions=[])}finally{e===this.requestId&&(this.loading=!1)}}setPath(e){this.path=e,this.selected=0,this.loadSuggestions()}pick(e){this.setPath(e.path)}submit(){this.path.trim()!==""&&this.onSubmit?.(this.path,this.createMissing)}onPathInput(e){e.target instanceof HTMLInputElement&&this.setPath(e.target.value)}onCreateMissingChange(e){e.target instanceof HTMLInputElement&&(this.createMissing=e.target.checked)}onKeyDown(e){if(e.key==="Escape")e.preventDefault(),this.onCancel?.();else if(e.key==="Enter")e.preventDefault(),this.submit();else if(e.key==="ArrowDown")e.preventDefault(),this.selected=Math.min(this.selected+1,Math.max(0,this.suggestions.length-1));else if(e.key==="ArrowUp")e.preventDefault(),this.selected=Math.max(0,this.selected-1);else if(e.key==="Tab"){const t=this.suggestions[this.selected];if(t===void 0)return;e.preventDefault(),this.pick(t)}}render(){return c`
|
|
1065
|
-
<div class="backdrop" @click=${()=>this.onCancel?.()}>
|
|
1066
|
-
<section @click=${e=>{e.stopPropagation()}}>
|
|
1067
|
-
<header>
|
|
1068
|
-
<strong>Add project</strong>
|
|
1069
|
-
<button @click=${()=>{this.onCancel?.()}} aria-label="Close">×</button>
|
|
1070
|
-
</header>
|
|
1071
|
-
<div class="body">
|
|
1072
|
-
<label>
|
|
1073
|
-
Project folder
|
|
1074
|
-
<input .value=${this.path} @input=${e=>{this.onPathInput(e)}} @keydown=${e=>{this.onKeyDown(e)}} placeholder="/path/to/project or ~/code/project" autofocus />
|
|
1075
|
-
</label>
|
|
1076
|
-
<div class="suggestions">
|
|
1077
|
-
${this.loading?c`<div class="hint">Loading folders…</div>`:null}
|
|
1078
|
-
${this.suggestions.map((e,t)=>c`
|
|
1079
|
-
<button class=${t===this.selected?"selected":""} @click=${()=>{this.pick(e)}}>
|
|
1080
|
-
${e.path}
|
|
1081
|
-
</button>
|
|
1082
|
-
`)}
|
|
1083
|
-
${!this.loading&&this.suggestions.length===0?c`<div class="hint">No matching folders. Enter a new path to create it.</div>`:null}
|
|
1084
|
-
</div>
|
|
1085
|
-
<label class="check">
|
|
1086
|
-
<input type="checkbox" .checked=${this.createMissing} @change=${e=>{this.onCreateMissingChange(e)}} />
|
|
1087
|
-
Create the folder if it does not exist
|
|
1088
|
-
</label>
|
|
1089
|
-
</div>
|
|
1090
|
-
<footer>
|
|
1091
|
-
<button @click=${()=>{this.onCancel?.()}}>Cancel</button>
|
|
1092
|
-
<button class="primary" ?disabled=${this.path.trim()===""} @click=${()=>{this.submit()}}>Add project</button>
|
|
1093
|
-
</footer>
|
|
1094
|
-
</section>
|
|
1095
|
-
</div>
|
|
1096
|
-
`}};se.styles=j`
|
|
1097
|
-
:host { position: fixed; inset: 0; z-index: 30; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
1098
|
-
.backdrop { display: grid; place-items: start center; width: 100%; height: 100%; padding-top: min(12vh, 90px); box-sizing: border-box; background: var(--pi-overlay); }
|
|
1099
|
-
section { width: min(720px, calc(100vw - 40px)); max-height: min(700px, calc(100vh - 40px)); display: flex; flex-direction: column; border: 1px solid var(--pi-border); border-radius: 12px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); overflow: hidden; }
|
|
1100
|
-
header, footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
1101
|
-
footer { border-top: 1px solid var(--pi-border); border-bottom: 0; justify-content: end; }
|
|
1102
|
-
.body { display: grid; gap: 12px; padding: 12px; min-height: 0; }
|
|
1103
|
-
label { display: grid; gap: 6px; color: var(--pi-muted); }
|
|
1104
|
-
input[type="text"], input:not([type]) { box-sizing: border-box; width: 100%; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); color: var(--pi-text); padding: 9px; font: 14px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
1105
|
-
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; color: var(--pi-text); }
|
|
1106
|
-
.suggestions { min-height: 90px; max-height: 320px; overflow: auto; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); }
|
|
1107
|
-
.suggestions button { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; border-bottom: 1px solid var(--pi-border); border-radius: 0; background: transparent; color: var(--pi-text); padding: 8px 10px; text-align: left; font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
1108
|
-
.suggestions button.selected, .suggestions button:hover { background: var(--pi-selection-bg); }
|
|
1109
|
-
.hint { padding: 12px; color: var(--pi-muted); }
|
|
1110
|
-
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
1111
|
-
header button { border: 0; background: transparent; color: var(--pi-muted); font-size: 22px; padding: 0 8px; }
|
|
1112
|
-
.primary { border-color: var(--pi-success-border); background: var(--pi-success-border); }
|
|
1113
|
-
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
1114
|
-
`;ue([p({attribute:!1})],se.prototype,"onSubmit",2);ue([p({attribute:!1})],se.prototype,"onCancel",2);ue([k()],se.prototype,"path",2);ue([k()],se.prototype,"createMissing",2);ue([k()],se.prototype,"suggestions",2);ue([k()],se.prototype,"selected",2);ue([k()],se.prototype,"loading",2);ue([ne("input")],se.prototype,"pathInput",2);se=ue([M("project-dialog")],se);var Su=Object.defineProperty,$u=Object.getOwnPropertyDescriptor,X=(e,t,s,i)=>{for(var r=i>1?void 0:i?$u(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&Su(t,s,r),r};let V=class extends C{constructor(){super(...arguments),this.tool="core:workspace.files",this.panels=[],this.workspaceLabelItems=[],this.hideToolTabs=!1,this.onSelectTool=()=>{},this.workspaceHeaderCanScrollLeft=!1,this.workspaceHeaderCanScrollRight=!1,this.onWorkspaceHeaderScroll=()=>{this.updateWorkspaceHeaderScrollState()}}firstUpdated(){this.observeWorkspaceHeaderStrip(),this.updateWorkspaceHeaderScrollState()}updated(){this.observeWorkspaceHeaderStrip(),this.updateWorkspaceHeaderScrollState()}disconnectedCallback(){this.workspaceHeaderResizeObserver?.disconnect(),this.workspaceHeaderResizeObserver=void 0,this.observedWorkspaceHeaderStrip=void 0,super.disconnectedCallback()}render(){const e=this.workspace;if(e===void 0)return this.renderEmptyState(this.emptyState??{title:"Select a workspace",body:"Choose a workspace to inspect files, Git, or terminals."});const t=this.panelContext;if(t===void 0)return this.renderEmptyState({title:"Workspace tools unavailable",body:"Try selecting the workspace again."});const s=this.panels,i=s.find(r=>r.id===this.tool)??s[0];return c`
|
|
1115
|
-
<header>
|
|
1116
|
-
<div class=${this.workspaceHeaderFrameClass()}>
|
|
1117
|
-
<div class="workspace-header-strip" @scroll=${this.onWorkspaceHeaderScroll}>
|
|
1118
|
-
${this.hideToolTabs?null:c`
|
|
1119
|
-
<div class="tabs">
|
|
1120
|
-
${s.map(r=>c`
|
|
1121
|
-
<button class=${i?.id===r.id?"selected":""} @click=${()=>{this.onSelectTool(r.id)}}>${this.renderPanelTitle(r,t)}</button>
|
|
1122
|
-
`)}
|
|
1123
|
-
</div>
|
|
1124
|
-
`}
|
|
1125
|
-
<small>${Qr(e.label,this.workspaceLabelItems,e.path)}</small>
|
|
1126
|
-
</div>
|
|
1127
|
-
</div>
|
|
1128
|
-
</header>
|
|
1129
|
-
${i===void 0?this.renderEmptyState({title:"No workspace tools available",body:"No tools are available for this workspace."}):c`
|
|
1130
|
-
<div class="panel-content">
|
|
1131
|
-
${i.render(t)}
|
|
1132
|
-
</div>
|
|
1133
|
-
`}
|
|
1134
|
-
`}renderPanelTitle(e,t){const s=e.badge?.(t);return s===void 0||s===""?c`${e.title}`:c`${e.title} <span class="tab-badge">${s}</span>`}renderEmptyState(e){return c`
|
|
1135
|
-
<section class="empty-state" role="status">
|
|
1136
|
-
<h2>${e.title}</h2>
|
|
1137
|
-
${e.body===void 0?null:c`<p>${e.body}</p>`}
|
|
1138
|
-
</section>
|
|
1139
|
-
`}workspaceHeaderFrameClass(){return`workspace-header-scroll-frame${this.workspaceHeaderCanScrollLeft?" can-scroll-left":""}${this.workspaceHeaderCanScrollRight?" can-scroll-right":""}`}observeWorkspaceHeaderStrip(){const e=this.workspaceHeaderStripElement();this.observedWorkspaceHeaderStrip!==e&&(this.workspaceHeaderResizeObserver?.disconnect(),this.observedWorkspaceHeaderStrip=e,this.workspaceHeaderResizeObserver=void 0,!(e===void 0||typeof ResizeObserver>"u")&&(this.workspaceHeaderResizeObserver=new ResizeObserver(()=>{this.updateWorkspaceHeaderScrollState()}),this.workspaceHeaderResizeObserver.observe(e)))}updateWorkspaceHeaderScrollState(){const e=this.workspaceHeaderStripElement(),t=e===void 0?0:Math.max(0,e.scrollWidth-e.clientWidth),s=e!==void 0&&e.scrollLeft>1,i=e!==void 0&&t-e.scrollLeft>1;this.workspaceHeaderCanScrollLeft!==s&&(this.workspaceHeaderCanScrollLeft=s),this.workspaceHeaderCanScrollRight!==i&&(this.workspaceHeaderCanScrollRight=i)}workspaceHeaderStripElement(){const e=this.workspaceHeaderStrip;return e instanceof HTMLElement?e:void 0}};V.styles=jd;X([p({attribute:!1})],V.prototype,"workspace",2);X([p({attribute:!1})],V.prototype,"panelContext",2);X([p({attribute:!1})],V.prototype,"emptyState",2);X([p()],V.prototype,"tool",2);X([p({attribute:!1})],V.prototype,"panels",2);X([p({attribute:!1})],V.prototype,"workspaceLabelItems",2);X([p({type:Boolean})],V.prototype,"hideToolTabs",2);X([p({attribute:!1})],V.prototype,"onSelectTool",2);X([ne(".workspace-header-strip")],V.prototype,"workspaceHeaderStrip",2);X([k()],V.prototype,"workspaceHeaderCanScrollLeft",2);X([k()],V.prototype,"workspaceHeaderCanScrollRight",2);V=X([M("workspace-panel")],V);var Pu=Object.defineProperty,Tu=Object.getOwnPropertyDescriptor,fe=(e,t,s,i)=>{for(var r=i>1?void 0:i?Tu(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&Pu(t,s,r),r};let ie=class extends C{constructor(){super(...arguments),this.canScrollLeft=!1,this.canScrollRight=!1,this.onContextScroll=()=>{this.updateScrollState()}}disconnectedCallback(){this.contextItemsResizeObserver?.disconnect(),this.contextItemsResizeObserver=void 0,this.observedContextItems=void 0,super.disconnectedCallback()}firstUpdated(){this.observeContextItems(),this.updateScrollState()}updated(){this.observeContextItems(),this.updateScrollState()}render(){const e=Cu(this.project),t=Iu(this.workspace),s=Mu(this.session);return c`
|
|
1140
|
-
<nav class=${this.contextBarClass()} aria-label="Current location">
|
|
1141
|
-
<span class="context-bar-label">Location</span>
|
|
1142
|
-
<ol class="context-items" @scroll=${this.onContextScroll}>
|
|
1143
|
-
<li class="context-item">
|
|
1144
|
-
<button type="button" class=${this.project===void 0?"context-chip empty":"context-chip"} title=${Au(this.project)} aria-label=${`Project: ${e}. Open project selection.`} @click=${()=>{this.onOpenSection?.("projects")}}>
|
|
1145
|
-
<span class="context-kind">Project</span>
|
|
1146
|
-
<span class="context-value">${e}</span>
|
|
1147
|
-
</button>
|
|
1148
|
-
</li>
|
|
1149
|
-
<li class="context-item">
|
|
1150
|
-
<button type="button" class=${this.workspace===void 0?"context-chip empty":"context-chip"} title=${Ru(this.workspace)} aria-label=${`Workspace: ${t}. Open workspace selection.`} @click=${()=>{this.onOpenSection?.("workspaces")}}>
|
|
1151
|
-
<span class="context-kind">Workspace</span>
|
|
1152
|
-
<span class="context-value">${t}</span>
|
|
1153
|
-
</button>
|
|
1154
|
-
</li>
|
|
1155
|
-
<li class="context-item">
|
|
1156
|
-
<button type="button" class=${this.session===void 0?"context-chip empty":"context-chip"} title=${Eu(this.session)} aria-label=${`Session: ${s}. Open session selection.`} @click=${()=>{this.onOpenSection?.("sessions")}}>
|
|
1157
|
-
<span class="context-kind">Session</span>
|
|
1158
|
-
<span class="context-value">${s}</span>
|
|
1159
|
-
</button>
|
|
1160
|
-
</li>
|
|
1161
|
-
</ol>
|
|
1162
|
-
${this.refreshControl===void 0?null:c`<div class="context-actions">${this.refreshControl}</div>`}
|
|
1163
|
-
</nav>
|
|
1164
|
-
`}contextBarClass(){const e=["context-bar"];return this.refreshControl!==void 0&&e.push("has-context-actions"),this.canScrollLeft&&e.push("can-scroll-left"),this.canScrollRight&&e.push("can-scroll-right"),e.join(" ")}observeContextItems(){const e=this.contextItemsElement();this.observedContextItems!==e&&(this.contextItemsResizeObserver?.disconnect(),this.observedContextItems=e,this.contextItemsResizeObserver=void 0,!(e===void 0||typeof ResizeObserver>"u")&&(this.contextItemsResizeObserver=new ResizeObserver(()=>{this.updateScrollState()}),this.contextItemsResizeObserver.observe(e)))}updateScrollState(){const e=this.contextItemsElement(),t=e===void 0?0:Math.max(0,e.scrollWidth-e.clientWidth),s=e!==void 0&&e.scrollLeft>1,i=e!==void 0&&t-e.scrollLeft>1;this.canScrollLeft!==s&&(this.canScrollLeft=s),this.canScrollRight!==i&&(this.canScrollRight=i)}contextItemsElement(){const e=this.contextItems;return e instanceof HTMLElement?e:void 0}};ie.styles=j`
|
|
1165
|
-
:host { flex: 0 0 auto; min-width: 0; }
|
|
1166
|
-
.context-bar { position: relative; flex: 0 0 auto; min-width: 0; display: flex; align-items: center; gap: 0; padding: 6px 0; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); }
|
|
1167
|
-
.context-bar::before, .context-bar::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 20px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
1168
|
-
.context-bar::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
1169
|
-
.context-bar::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
1170
|
-
.context-bar.can-scroll-left::before, .context-bar.can-scroll-right::after { opacity: 1; }
|
|
1171
|
-
.context-bar-label { display: none; }
|
|
1172
|
-
.context-items { flex: 1 1 auto; min-width: 0; display: flex; align-items: stretch; gap: 5px; margin: 0; padding: 0 8px; list-style: none; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-padding-inline: 8px; scrollbar-width: thin; }
|
|
1173
|
-
.context-bar.has-context-actions .context-items { padding-right: 52px; scroll-padding-inline: 8px 52px; }
|
|
1174
|
-
.context-item { flex: 0 0 auto; min-width: 0; display: flex; }
|
|
1175
|
-
.context-actions { position: absolute; top: 6px; right: 0; bottom: 6px; z-index: 3; display: flex; align-items: center; padding: 0 8px 0 0; pointer-events: none; }
|
|
1176
|
-
.context-actions::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; z-index: 0; width: 26px; background: var(--pi-bg); pointer-events: none; }
|
|
1177
|
-
app-refresh-control { pointer-events: auto; }
|
|
1178
|
-
.context-chip { flex: 0 0 auto; min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; border: 1px solid var(--pi-border-muted); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text); padding: 4px 8px; font: inherit; text-align: left; }
|
|
1179
|
-
.context-chip:hover { background: var(--pi-surface-hover); }
|
|
1180
|
-
.context-chip:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 2px; }
|
|
1181
|
-
.context-chip.empty { border-style: dashed; color: var(--pi-muted); }
|
|
1182
|
-
.context-kind { display: none; }
|
|
1183
|
-
.context-value { min-width: 0; overflow: visible; text-overflow: clip; white-space: nowrap; }
|
|
1184
|
-
button { cursor: pointer; }
|
|
1185
|
-
`;fe([p({attribute:!1})],ie.prototype,"project",2);fe([p({attribute:!1})],ie.prototype,"workspace",2);fe([p({attribute:!1})],ie.prototype,"session",2);fe([p({attribute:!1})],ie.prototype,"refreshControl",2);fe([p({attribute:!1})],ie.prototype,"onOpenSection",2);fe([ne(".context-items")],ie.prototype,"contextItems",2);fe([k()],ie.prototype,"canScrollLeft",2);fe([k()],ie.prototype,"canScrollRight",2);ie=fe([M("app-context-bar")],ie);function Cu(e){return e?.name??"No project"}function Au(e){return e===void 0?"No project selected":`${e.name} — ${e.path}`}function Iu(e){return e===void 0?"No workspace":`${e.label}${e.isMain?" · main":""} · ${e.path}`}function Ru(e){return e===void 0?"No workspace selected":`${e.label}${e.isMain?" · main":""} — ${e.path}`}function Mu(e){const t=e?.name?.trim(),s=e?.firstMessage.trim();return t!==void 0&&t!==""?t:s!==void 0&&s!==""?s:e?.id.slice(0,8)??"No session"}function Eu(e){return e===void 0?"No session selected":e.path}var Du=Object.defineProperty,_u=Object.getOwnPropertyDescriptor,Re=(e,t,s,i)=>{for(var r=i>1?void 0:i?_u(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&Du(t,s,r),r};let de=class extends C{constructor(){super(...arguments),this.tabs=[],this.selectedView="chat",this.canScrollLeft=!1,this.canScrollRight=!1,this.onMobileTabsScroll=()=>{this.updateScrollState()}}disconnectedCallback(){this.mobileTabsResizeObserver?.disconnect(),this.mobileTabsResizeObserver=void 0,this.observedMobileTabs=void 0,super.disconnectedCallback()}firstUpdated(){this.observeMobileTabs(),this.updateScrollState()}updated(){this.observeMobileTabs(),this.updateScrollState()}render(){return c`
|
|
1186
|
-
<div class=${this.frameClass()}>
|
|
1187
|
-
<div class="mobile-tabs" @scroll=${this.onMobileTabsScroll}>
|
|
1188
|
-
${this.tabs.map(e=>c`
|
|
1189
|
-
<button class=${this.tabClass(e)} @click=${()=>{this.onSelect?.(e.id)}}>${e.label}</button>
|
|
1190
|
-
`)}
|
|
1191
|
-
</div>
|
|
1192
|
-
</div>
|
|
1193
|
-
`}frameClass(){return`mobile-tabs-frame${this.canScrollLeft?" can-scroll-left":""}${this.canScrollRight?" can-scroll-right":""}`}tabClass(e){return[...e.className===void 0?[]:[e.className],...this.selectedView===e.id?["selected"]:[]].join(" ")}observeMobileTabs(){const e=this.mobileTabsElement();this.observedMobileTabs!==e&&(this.mobileTabsResizeObserver?.disconnect(),this.observedMobileTabs=e,this.mobileTabsResizeObserver=void 0,!(e===void 0||typeof ResizeObserver>"u")&&(this.mobileTabsResizeObserver=new ResizeObserver(()=>{this.updateScrollState()}),this.mobileTabsResizeObserver.observe(e)))}updateScrollState(){const e=this.mobileTabsElement(),t=e===void 0?0:Math.max(0,e.scrollWidth-e.clientWidth),s=e!==void 0&&e.scrollLeft>1,i=e!==void 0&&t-e.scrollLeft>1;this.canScrollLeft!==s&&(this.canScrollLeft=s),this.canScrollRight!==i&&(this.canScrollRight=i)}mobileTabsElement(){const e=this.mobileTabs;return e instanceof HTMLElement?e:void 0}};de.styles=j`
|
|
1194
|
-
:host { flex: 0 0 auto; min-width: 0; }
|
|
1195
|
-
.mobile-tabs-frame { position: relative; display: flex; flex: 0 0 auto; min-width: 0; border-bottom: 1px solid var(--pi-border); background: var(--pi-bg); }
|
|
1196
|
-
.mobile-tabs-frame::before, .mobile-tabs-frame::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 20px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
1197
|
-
.mobile-tabs-frame::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
1198
|
-
.mobile-tabs-frame::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
1199
|
-
.mobile-tabs-frame.can-scroll-left::before, .mobile-tabs-frame.can-scroll-right::after { opacity: 1; }
|
|
1200
|
-
.mobile-tabs { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; }
|
|
1201
|
-
.mobile-tabs button { flex: 0 0 auto; white-space: nowrap; }
|
|
1202
|
-
.navigation-tab { display: none; }
|
|
1203
|
-
.mobile-tabs button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
1204
|
-
.tab-badge { display: inline-block; min-width: 14px; margin-left: 4px; border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 0 5px; font-size: 11px; line-height: 16px; text-align: center; }
|
|
1205
|
-
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
1206
|
-
@media (max-width: 760px) {
|
|
1207
|
-
.navigation-tab { display: block; }
|
|
1208
|
-
}
|
|
1209
|
-
`;Re([p({attribute:!1})],de.prototype,"tabs",2);Re([p({attribute:!1})],de.prototype,"selectedView",2);Re([p({attribute:!1})],de.prototype,"onSelect",2);Re([ne(".mobile-tabs")],de.prototype,"mobileTabs",2);Re([k()],de.prototype,"canScrollLeft",2);Re([k()],de.prototype,"canScrollRight",2);de=Re([M("app-mobile-main-tabs")],de);var Lu=Object.defineProperty,Ou=Object.getOwnPropertyDescriptor,$=(e,t,s,i)=>{for(var r=i>1?void 0:i?Ou(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&Lu(t,s,r),r};let S=class extends C{constructor(){super(...arguments),this.projects=[],this.workspaces=[],this.sessions=[],this.workspaceActivities={},this.sessionActivities={},this.sessionStatuses={},this.workspacesByProjectId={},this.deletingWorkspaceIds=[],this.workspaceLabelItems=()=>[],this.collapsible=!1,this.projectsCollapsed=!1,this.workspacesCollapsed=!1,this.sessionsCollapsed=!1,this.canStartSession=!1}render(){return c`
|
|
1210
|
-
<header>
|
|
1211
|
-
<strong>PI WEB</strong>
|
|
1212
|
-
<div class="header-actions">
|
|
1213
|
-
${this.refreshControl}
|
|
1214
|
-
<button title="Show Actions" aria-label="Show Actions" @click=${()=>{this.onShowActions?.()}}>Actions</button>
|
|
1215
|
-
</div>
|
|
1216
|
-
</header>
|
|
1217
|
-
<project-list
|
|
1218
|
-
.projects=${this.projects}
|
|
1219
|
-
.selected=${this.selectedProject}
|
|
1220
|
-
.activities=${this.workspaceActivities}
|
|
1221
|
-
.workspacesByProjectId=${this.workspacesByProjectId}
|
|
1222
|
-
.collapsible=${this.collapsible}
|
|
1223
|
-
.collapsed=${this.projectsCollapsed}
|
|
1224
|
-
.onToggleCollapsed=${()=>{this.onToggleProjects?.()}}
|
|
1225
|
-
.onSelect=${e=>this.onSelectProject?.(e)}
|
|
1226
|
-
.onClose=${e=>this.onCloseProject?.(e)}
|
|
1227
|
-
></project-list>
|
|
1228
|
-
<workspace-list
|
|
1229
|
-
.workspaces=${this.workspaces}
|
|
1230
|
-
.selected=${this.selectedWorkspace}
|
|
1231
|
-
.activities=${this.workspaceActivities}
|
|
1232
|
-
.deletingWorkspaceIds=${this.deletingWorkspaceIds}
|
|
1233
|
-
.collapsible=${this.collapsible}
|
|
1234
|
-
.collapsed=${this.workspacesCollapsed}
|
|
1235
|
-
.workspaceLabelItems=${this.workspaceLabelItems}
|
|
1236
|
-
.onToggleCollapsed=${()=>{this.onToggleWorkspaces?.()}}
|
|
1237
|
-
.onSelect=${e=>this.onSelectWorkspace?.(e)}
|
|
1238
|
-
.onDelete=${e=>this.onDeleteWorkspace?.(e)}
|
|
1239
|
-
></workspace-list>
|
|
1240
|
-
<session-list
|
|
1241
|
-
.sessions=${this.sessions}
|
|
1242
|
-
.statuses=${this.sessionStatuses}
|
|
1243
|
-
.activities=${this.sessionActivities}
|
|
1244
|
-
.selected=${this.selectedSession}
|
|
1245
|
-
.canStart=${this.canStartSession}
|
|
1246
|
-
.collapsible=${this.collapsible}
|
|
1247
|
-
.collapsed=${this.sessionsCollapsed}
|
|
1248
|
-
.onToggleCollapsed=${()=>{this.onToggleSessions?.()}}
|
|
1249
|
-
.onArchivedCollapsed=${()=>this.onArchivedCollapsed?.()}
|
|
1250
|
-
.onStart=${()=>this.onStartSession?.()}
|
|
1251
|
-
.onSelect=${e=>this.onSelectSession?.(e)}
|
|
1252
|
-
.onArchive=${e=>this.onArchiveSession?.(e)}
|
|
1253
|
-
.onArchiveWithDescendants=${e=>this.onArchiveSessionWithDescendants?.(e)}
|
|
1254
|
-
.onRestore=${e=>this.onRestoreSession?.(e)}
|
|
1255
|
-
.onDelete=${e=>this.onDeleteCachedNewSession?.(e)}
|
|
1256
|
-
.onDetachParent=${e=>this.onDetachParentSession?.(e)}
|
|
1257
|
-
></session-list>
|
|
1258
|
-
`}};S.styles=j`
|
|
1259
|
-
:host { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
|
|
1260
|
-
:host([collapsible]) { flex: 1 1 auto; }
|
|
1261
|
-
header { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
1262
|
-
.header-actions { display: flex; align-items: center; gap: 8px; }
|
|
1263
|
-
project-list, workspace-list { flex: 0 0 auto; max-height: 26%; min-height: 0; overflow: hidden; border-bottom: 1px solid var(--pi-border-muted); }
|
|
1264
|
-
session-list { flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
|
1265
|
-
:host([collapsible]) project-list,
|
|
1266
|
-
:host([collapsible]) workspace-list,
|
|
1267
|
-
:host([collapsible]) session-list { flex: 1 1 auto; max-height: none; min-height: 0; overflow: hidden; }
|
|
1268
|
-
:host([collapsible]) project-list[collapsed],
|
|
1269
|
-
:host([collapsible]) workspace-list[collapsed],
|
|
1270
|
-
:host([collapsible]) session-list[collapsed] { flex: 0 0 auto; min-height: auto; overflow: hidden; }
|
|
1271
|
-
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
1272
|
-
`;$([p({attribute:!1})],S.prototype,"projects",2);$([p({attribute:!1})],S.prototype,"selectedProject",2);$([p({attribute:!1})],S.prototype,"workspaces",2);$([p({attribute:!1})],S.prototype,"selectedWorkspace",2);$([p({attribute:!1})],S.prototype,"sessions",2);$([p({attribute:!1})],S.prototype,"selectedSession",2);$([p({attribute:!1})],S.prototype,"workspaceActivities",2);$([p({attribute:!1})],S.prototype,"sessionActivities",2);$([p({attribute:!1})],S.prototype,"sessionStatuses",2);$([p({attribute:!1})],S.prototype,"workspacesByProjectId",2);$([p({attribute:!1})],S.prototype,"deletingWorkspaceIds",2);$([p({attribute:!1})],S.prototype,"workspaceLabelItems",2);$([p({attribute:!1})],S.prototype,"refreshControl",2);$([p({type:Boolean,reflect:!0})],S.prototype,"collapsible",2);$([p({type:Boolean})],S.prototype,"projectsCollapsed",2);$([p({type:Boolean})],S.prototype,"workspacesCollapsed",2);$([p({type:Boolean})],S.prototype,"sessionsCollapsed",2);$([p({type:Boolean})],S.prototype,"canStartSession",2);$([p({attribute:!1})],S.prototype,"onShowActions",2);$([p({attribute:!1})],S.prototype,"onToggleProjects",2);$([p({attribute:!1})],S.prototype,"onToggleWorkspaces",2);$([p({attribute:!1})],S.prototype,"onToggleSessions",2);$([p({attribute:!1})],S.prototype,"onSelectProject",2);$([p({attribute:!1})],S.prototype,"onCloseProject",2);$([p({attribute:!1})],S.prototype,"onSelectWorkspace",2);$([p({attribute:!1})],S.prototype,"onDeleteWorkspace",2);$([p({attribute:!1})],S.prototype,"onStartSession",2);$([p({attribute:!1})],S.prototype,"onSelectSession",2);$([p({attribute:!1})],S.prototype,"onArchiveSession",2);$([p({attribute:!1})],S.prototype,"onArchiveSessionWithDescendants",2);$([p({attribute:!1})],S.prototype,"onRestoreSession",2);$([p({attribute:!1})],S.prototype,"onDeleteCachedNewSession",2);$([p({attribute:!1})],S.prototype,"onDetachParentSession",2);$([p({attribute:!1})],S.prototype,"onArchivedCollapsed",2);S=$([M("app-navigation-panel")],S);var Wu=Object.defineProperty,ju=Object.getOwnPropertyDescriptor,Me=(e,t,s,i)=>{for(var r=i>1?void 0:i?ju(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&Wu(t,s,r),r};let pe=class extends C{constructor(){super(...arguments),this.side="navigation",this.collapsed=!1,this.controls="",this.expandLabel="Expand panel",this.collapseLabel="Collapse panel"}render(){const e=this.collapsed?this.expandLabel:this.collapseLabel;return c`
|
|
1273
|
-
<button
|
|
1274
|
-
type="button"
|
|
1275
|
-
class="edge-button"
|
|
1276
|
-
title=${e}
|
|
1277
|
-
aria-label=${e}
|
|
1278
|
-
aria-controls=${this.controls}
|
|
1279
|
-
aria-expanded=${String(!this.collapsed)}
|
|
1280
|
-
@click=${()=>{this.onToggle?.()}}
|
|
1281
|
-
>${this.renderIcon()}</button>
|
|
1282
|
-
`}renderIcon(){const t=this.iconDirection()==="left"?"M15 18l-6-6 6-6":"M9 18l6-6-6-6";return c`<svg class="edge-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d=${t}/></svg>`}iconDirection(){return this.side==="navigation"?this.collapsed?"right":"left":this.collapsed?"left":"right"}};pe.styles=j`
|
|
1283
|
-
:host { min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: visible; background: var(--pi-border-muted); z-index: 2; }
|
|
1284
|
-
:host([side="navigation"]) { grid-column: 2; }
|
|
1285
|
-
:host([side="workspace"]) { grid-column: 4; }
|
|
1286
|
-
.edge-button { position: relative; z-index: 1; box-sizing: border-box; display: grid; place-items: center; width: 18px; height: 48px; padding: 0; border: 1px solid var(--pi-border-muted); border-radius: 999px; background: var(--pi-bg); color: var(--pi-muted); opacity: .75; cursor: pointer; }
|
|
1287
|
-
.edge-button:hover, .edge-button:focus-visible { color: var(--pi-text); background: var(--pi-surface-hover); opacity: 1; }
|
|
1288
|
-
:host([side="navigation"][collapsed]) .edge-button { transform: translateX(calc(50% - .5px)); }
|
|
1289
|
-
:host([side="workspace"][collapsed]) .edge-button { transform: translateX(calc(-50% + .5px)); }
|
|
1290
|
-
.edge-icon { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
1291
|
-
@media (max-width: 1180px) {
|
|
1292
|
-
:host([side="navigation"]) { grid-row: 1 / 3; }
|
|
1293
|
-
:host([side="workspace"]) { display: none; }
|
|
1294
|
-
}
|
|
1295
|
-
@media (max-width: 760px) {
|
|
1296
|
-
:host([side="navigation"]) { display: none; }
|
|
1297
|
-
}
|
|
1298
|
-
`;Me([p({reflect:!0})],pe.prototype,"side",2);Me([p({type:Boolean,reflect:!0})],pe.prototype,"collapsed",2);Me([p()],pe.prototype,"controls",2);Me([p()],pe.prototype,"expandLabel",2);Me([p()],pe.prototype,"collapseLabel",2);Me([p({attribute:!1})],pe.prototype,"onToggle",2);pe=Me([M("app-panel-edge-control")],pe);var Nu=Object.defineProperty,Fu=Object.getOwnPropertyDescriptor,ze=(e,t,s,i)=>{for(var r=i>1?void 0:i?Fu(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&Nu(t,s,r),r};const Bu=550;let be=class extends C{constructor(){super(...arguments),this.isRefreshing=!1,this.menuOpen=!1,this.menuStyle="",this.suppressNextClick=!1,this.onRefreshClick=e=>{if(e.stopPropagation(),this.suppressNextClick){this.suppressNextClick=!1;return}this.refresh()},this.onRefreshPointerDown=e=>{if(!e.isPrimary||e.button!==0)return;const t=e.currentTarget;t instanceof HTMLElement&&(this.clearLongPressTimer(),this.suppressNextClick=!1,this.longPressTimer=window.setTimeout(()=>{this.longPressTimer=void 0,this.suppressNextClick=!0,this.openMenu(t)},Bu))},this.onRefreshContextMenu=e=>{e.preventDefault(),e.stopPropagation(),this.clearLongPressTimer(),this.suppressNextClick=!0,this.openMenu(e.currentTarget)},this.onDocumentClick=e=>{e.composedPath().includes(this)||this.closeMenu()},this.onDocumentKeyDown=e=>{e.key!=="Escape"||!this.menuOpen||(e.preventDefault(),e.stopPropagation(),this.closeMenu())}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick),document.addEventListener("keydown",this.onDocumentKeyDown)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),document.removeEventListener("keydown",this.onDocumentKeyDown),this.clearLongPressTimer(),super.disconnectedCallback()}render(){const e=this.isRefreshing?"Refreshing app data. Long-press for reload options.":"Refresh app data. Long-press for reload options.";return c`
|
|
1299
|
-
<button
|
|
1300
|
-
class=${`app-refresh-button${this.isRefreshing?" refreshing":""}`}
|
|
1301
|
-
title=${e}
|
|
1302
|
-
aria-label=${e}
|
|
1303
|
-
aria-haspopup="menu"
|
|
1304
|
-
aria-expanded=${String(this.menuOpen)}
|
|
1305
|
-
aria-busy=${String(this.isRefreshing)}
|
|
1306
|
-
@click=${this.onRefreshClick}
|
|
1307
|
-
@contextmenu=${this.onRefreshContextMenu}
|
|
1308
|
-
@pointerdown=${this.onRefreshPointerDown}
|
|
1309
|
-
@pointerup=${()=>{this.clearLongPressTimer()}}
|
|
1310
|
-
@pointercancel=${()=>{this.clearLongPressTimer()}}
|
|
1311
|
-
@pointerleave=${()=>{this.clearLongPressTimer()}}
|
|
1312
|
-
>${this.renderRefreshIcon()}</button>
|
|
1313
|
-
${this.renderMenu()}
|
|
1314
|
-
`}renderMenu(){return this.menuOpen?c`
|
|
1315
|
-
<div class="app-refresh-menu" role="menu" style=${this.menuStyle} @click=${e=>{e.stopPropagation()}}>
|
|
1316
|
-
<button role="menuitem" @click=${()=>{this.refresh()}}>Refresh app data</button>
|
|
1317
|
-
<button role="menuitem" @click=${()=>{this.reload()}}>Full page reload</button>
|
|
1318
|
-
</div>
|
|
1319
|
-
`:null}renderRefreshIcon(){return c`
|
|
1320
|
-
<svg class="app-refresh-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
1321
|
-
<path d="M20 6v5h-5"></path>
|
|
1322
|
-
<path d="M4 18v-5h5"></path>
|
|
1323
|
-
<path d="M18.2 9A7 7 0 0 0 6.1 6.8L4 9"></path>
|
|
1324
|
-
<path d="M5.8 15a7 7 0 0 0 12.1 2.2L20 15"></path>
|
|
1325
|
-
</svg>
|
|
1326
|
-
`}openMenu(e){this.menuStyle=Bt(e),this.menuOpen=!0}closeMenu(){this.menuOpen=!1,this.suppressNextClick=!1}refresh(){this.closeMenu(),this.onRefresh?.()}reload(){this.closeMenu(),this.onReload?.()}clearLongPressTimer(){this.longPressTimer!==void 0&&(window.clearTimeout(this.longPressTimer),this.longPressTimer=void 0)}};be.styles=j`
|
|
1327
|
-
:host { position: relative; z-index: 1; display: flex; align-items: center; pointer-events: auto; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
|
|
1328
|
-
:host, :host * { -webkit-user-select: none; user-select: none; }
|
|
1329
|
-
.app-refresh-button { box-sizing: border-box; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--pi-border); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text); padding: 0; line-height: 1; cursor: pointer; touch-action: manipulation; -webkit-touch-callout: none; }
|
|
1330
|
-
.app-refresh-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
1331
|
-
.app-refresh-button.refreshing .app-refresh-icon { animation: app-refresh-spin .8s linear infinite; }
|
|
1332
|
-
.app-refresh-menu { position: fixed; z-index: 10000; box-sizing: border-box; min-width: min(170px, calc(100vw - 16px)); overflow: auto; padding: 4px; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); box-shadow: 0 8px 24px var(--pi-shadow); overflow-wrap: anywhere; }
|
|
1333
|
-
.app-refresh-menu button { display: block; width: 100%; border: 0; border-radius: 8px; background: transparent; color: var(--pi-text); padding: 7px 9px; text-align: left; white-space: normal; overflow-wrap: anywhere; cursor: pointer; }
|
|
1334
|
-
.app-refresh-menu button:hover, .app-refresh-menu button:focus { background: var(--pi-selection-bg); }
|
|
1335
|
-
@keyframes app-refresh-spin { to { transform: rotate(360deg); } }
|
|
1336
|
-
`;ze([p({type:Boolean})],be.prototype,"isRefreshing",2);ze([p({attribute:!1})],be.prototype,"onRefresh",2);ze([p({attribute:!1})],be.prototype,"onReload",2);ze([k()],be.prototype,"menuOpen",2);ze([k()],be.prototype,"menuStyle",2);be=ze([M("app-refresh-control")],be);var zu=Object.defineProperty,qu=Object.getOwnPropertyDescriptor,qe=(e,t,s,i)=>{for(var r=i>1?void 0:i?qu(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&zu(t,s,r),r};const Hu=900*1e3,or={capture:!0},os="auto:on",nr="auto:off",vt="theme:",ar=rt("core:workspace.terminal");let we=class extends C{constructor(){super(...arguments),this.state=pa(),this.sessions=new Bl(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.activity=new ha(()=>this.state,e=>{this.setState(e)}),this.auth=new ma(()=>this.state,e=>{this.setState(e)},e=>{this.sessions.applySessionStatus(e)}),this.workspaces=new Ql(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.sessions),this.projects=new Sa(()=>this.state,e=>{this.setState(e)},this.workspaces),this.files=new wa(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.git=new ka(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.keyboard=new ec,this.realtime=new Ml,this.activeTerminalIds=new Set,this.terminalSelection=new Xl,this.appShell=new ud(this),this.panelCollapse=new yd(this),this.mobileNavigation=new wd(this,()=>this.state,()=>this.appShell.isMobileNavigationLayout),this.systemLightThemeMedia=typeof window<"u"&&"matchMedia"in window?window.matchMedia("(prefers-color-scheme: light)"):void 0,this.refreshingWorkspaceDeletionRuns=!1,this.handledWorkspaceDeletionRunIds=new Set,this.terminalCommandRunRuntimes=new Map,this.routeRestoreInProgress=!1,this.plugins=Uu(),this.themePreference=cc()??nc,this.activeThemeId=Ds,this.isRefreshingApp=!1,this.onPopState=()=>{this.withChatScrollTransition(()=>this.restoreRoute(!1))},this.onPageShow=()=>{this.appShell.repairViewportPosition()},this.onFocus=()=>{this.appShell.repairViewportPosition(),this.sessions.refreshSelectedSession(),this.refreshPiWebStatus(),this.refreshWorkspaceActivity(),this.refreshWorkspaceDeletionRuns()},this.onVisibilityChange=()=>{document.visibilityState==="visible"&&(this.appShell.repairViewportPosition(),this.sessions.refreshSelectedSession(),this.refreshPiWebStatus(),this.refreshWorkspaceActivity(),this.refreshWorkspaceDeletionRuns())},this.onSystemLightThemeChange=()=>{this.themePreference.auto&&this.applyPreferredTheme(!1)},this.onKeyDown=e=>{this.keyboard.handle(e,this.getActions())&&(e.preventDefault(),e.stopPropagation())}}willUpdate(){this.toggleAttribute("pwa-display-mode",this.appShell.isPwaDisplayMode)}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this.onPopState),window.addEventListener("pageshow",this.onPageShow),window.addEventListener("focus",this.onFocus),document.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("keydown",this.onKeyDown,or),this.systemLightThemeMedia?.addEventListener("change",this.onSystemLightThemeChange),this.applyPreferredTheme(!1),this.connectRealtime(),this.piWebStatusTimer=window.setInterval(()=>{this.refreshPiWebStatus()},Hu),this.refreshPiWebStatus(),this.refreshWorkspaceActivity(),this.loadExternalPlugins(),this.loadProjectsAndRestoreRoute()}disconnectedCallback(){window.removeEventListener("popstate",this.onPopState),window.removeEventListener("pageshow",this.onPageShow),window.removeEventListener("focus",this.onFocus),document.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("keydown",this.onKeyDown,or),this.systemLightThemeMedia?.removeEventListener("change",this.onSystemLightThemeChange),this.keyboard.reset(),this.auth.dispose(),this.sessions.dispose(),this.realtime.close(),this.git.dispose(),this.piWebStatusTimer!==void 0&&window.clearInterval(this.piWebStatusTimer),this.piWebStatusTimer=void 0,this.workspaceDeletionPollTimer!==void 0&&window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0,super.disconnectedCallback()}setState(e){if(!Vu(this.state,e))return;const t=this.state;this.state={...this.state,...e},this.handleActivityTransition(t,this.state),this.handleWorkspaceChange(t,this.state)}async loadProjectsAndRestoreRoute(){await this.projects.loadProjects(),await this.withChatScrollTransition(()=>this.restoreRoute(!1)),await this.refreshWorkspaceDeletionRuns()}async refreshPiWebStatus(){try{this.setState({piWebStatus:await wr.piWebStatus()})}catch(e){console.warn("Failed to refresh PI WEB status",e)}}async refreshWorkspaceActivity(){try{await this.activity.refresh()}catch(e){console.warn("Failed to refresh workspace activity",e)}}async refreshAppData(){if(!this.isRefreshingApp){this.isRefreshingApp=!0;try{await Promise.all([this.sessions.refreshSelectedSession(),this.refreshPiWebStatus(),this.refreshWorkspaceActivity(),this.refreshWorkspaceDeletionRuns(),this.refreshCurrentWorkspaceSurface()])}finally{this.isRefreshingApp=!1}}}async refreshCurrentWorkspaceSurface(){const e=this.state.selectedWorkspace,t=this.state.mainView!=="chat"&&this.state.mainView!=="navigation"?this.state.mainView:this.state.workspaceTool;t==="core:workspace.files"?await this.files.refreshFiles():t==="core:workspace.git"?await this.git.refreshGit():t==="core:workspace.terminal"&&e!==void 0&&await this.refreshActiveTerminals(e)}hardReloadApp(){window.location.reload()}async restoreRoute(e){const t=xd(),s=Zt(rt("core:workspace.files"),"file"),i=Zt(rt("core:workspace.git"),"diff"),r=Zt(ar,"terminal");this.routeRestoreInProgress=!0,this.restoringRouteTerminalId=r;try{if(this.setState({workspaceTool:t.tool??this.state.workspaceTool,mainView:t.view??this.defaultRouteView(),selectedFilePath:s,selectedDiffPath:i,selectedTerminalId:r}),t.projectId===void 0||t.projectId==="")return;if(this.routeMatchesCurrentSelection(t)){r!==void 0&&this.rememberSelectedTerminal(r),await this.refreshRestoredWorkspaceTool(t.tool,s),this.git.updatePolling();return}const o=this.state.projects.find(n=>n.id===t.projectId);if(!o)return;await this.workspaces.selectProject(o,{workspaceId:t.workspaceId,sessionId:t.sessionId,updateUrl:e}),this.setState({selectedFilePath:s,selectedDiffPath:i,selectedTerminalId:r}),r!==void 0&&this.rememberSelectedTerminal(r),await this.refreshRestoredWorkspaceTool(t.tool,s),this.git.updatePolling()}finally{this.routeRestoreInProgress=!1,this.restoringRouteTerminalId=void 0}}routeMatchesCurrentSelection(e){return e.workspaceId!==void 0&&e.workspaceId!==""&&this.state.selectedProject?.id===e.projectId&&this.state.selectedWorkspace?.id===e.workspaceId&&this.state.selectedSession?.id===e.sessionId}async refreshRestoredWorkspaceTool(e,t){e==="core:workspace.files"&&await this.files.refreshFiles(),e==="core:workspace.files"&&t!==void 0&&await this.files.restoreFile(t),e==="core:workspace.git"&&await this.git.refreshGit()}async withChatScrollTransition(e){this.chatView?.saveScrollPosition(),await e(),await this.updateComplete,await this.chatView?.updateComplete,await Ju(),this.chatView?.restoreScrollPosition(),this.shouldAutoFocusPrompt()&&this.promptEditor?.focusInput()}shouldAutoFocusPrompt(){return this.appShell.shouldAutoFocusPrompt()}async withChatPrependTransition(e){await e(),await this.updateComplete,await this.chatView?.updateComplete}defaultRouteView(){return this.appShell.defaultRouteView()}updateUrl(e){kd({projectId:this.state.selectedProject?.id,workspaceId:this.state.selectedWorkspace?.id,sessionId:this.state.selectedSession?.id,tool:this.state.workspaceTool,view:this.state.mainView==="navigation"?void 0:this.state.mainView},e)}openWorkspaceTool(e){e==="core:workspace.terminal"&&(this.terminalAutoStartWorkspaceId=this.state.selectedWorkspace?.id),this.setState({workspaceTool:e,mainView:e}),this.updateUrl(),this.refreshSelectedWorkspaceTool(e),this.git.updatePolling()}openTerminal(e){e?.terminalId!==void 0&&this.selectTerminal(e.terminalId,{replace:!0}),this.openWorkspaceTool("core:workspace.terminal")}terminalCommandRunsForOrigin(e){const t=this.terminalCommandRunRuntimes.get(e);if(t!==void 0)return t;const s=Pd(e,{openTerminal:(i,r)=>{this.openRuntimeTerminal(i,r)}});return this.terminalCommandRunRuntimes.set(e,s),s}async openRuntimeTerminal(e,t){e!==void 0&&this.state.selectedWorkspace?.id!==e.id&&await this.workspaces.selectWorkspace(e),this.openTerminal(t)}selectTerminal(e,t){this.rememberSelectedTerminal(e),this.setState({selectedTerminalId:e}),this.writeSelectedTerminalToUrl(e,t)}rememberSelectedTerminal(e){const t=this.state.selectedWorkspace;t!==void 0&&(e===void 0?this.terminalSelection.forgetWorkspace(t.path):this.terminalSelection.rememberTerminal(t.path,e))}writeSelectedTerminalToUrl(e,t){ot(ar,"terminal",e,t)}selectMainView(e){if(e!=="navigation"&&e!=="chat"){this.openWorkspaceTool(e);return}this.setState({mainView:e}),this.updateUrl(),this.git.updatePolling()}handleWorkspaceChange(e,t){if(e.selectedWorkspace?.id===t.selectedWorkspace?.id)return;this.terminalAutoStartWorkspaceId=void 0,this.activeTerminalIds.clear();const s=this.routeRestoreInProgress?this.restoringRouteTerminalId:t.selectedWorkspace===void 0?void 0:this.terminalSelection.latestTerminalId(t.selectedWorkspace.path);this.setState({activeTerminalCount:0,selectedTerminalId:s}),this.routeRestoreInProgress||this.writeSelectedTerminalToUrl(s,{replace:!0}),t.selectedWorkspace!==void 0&&(this.refreshActiveTerminals(t.selectedWorkspace),this.refreshWorkspaceDeletionRuns(),this.refreshSelectedWorkspaceTool(t.workspaceTool),this.git.updatePolling())}connectRealtime(){this.realtime.connect(e=>{this.handleRealtimeEvent(e)},()=>{const e=this.state.selectedWorkspace;e!==void 0&&this.refreshActiveTerminals(e),this.refreshWorkspaceActivity()})}handleRealtimeEvent(e){e.type==="workspace.activity"?this.activity.applyWorkspaceActivity(e.activity):Gu(e)?(this.applyTerminalEvent(e),e.type==="terminal.exited"&&this.refreshWorkspaceDeletionRuns()):this.sessions.applyGlobalEvent(e)}applyTerminalEvent(e){const t=this.state.selectedWorkspace;t===void 0||(e.type==="terminal.closed"?e.cwd:e.terminal.cwd)!==t.path||(e.type==="terminal.created"&&!e.terminal.exited?this.activeTerminalIds.add(e.terminal.id):this.activeTerminalIds.delete(e.type==="terminal.closed"?e.terminalId:e.terminal.id),e.type==="terminal.closed"&&(this.terminalSelection.forgetTerminal(e.terminalId),this.state.selectedTerminalId===e.terminalId&&this.selectTerminal(void 0,{replace:!0})),this.setState({activeTerminalCount:this.activeTerminalIds.size}))}async refreshActiveTerminals(e){try{const t=await $s.terminals(e.projectId,e.id);if(this.state.selectedWorkspace?.id!==e.id)return;this.activeTerminalIds.clear();for(const s of t)s.exited||this.activeTerminalIds.add(s.id);this.setState({activeTerminalCount:this.activeTerminalIds.size})}catch(t){this.setState({error:String(t)})}}handleActivityTransition(e,t){const s=lr(e),i=lr(t);s&&!i&&(this.setState({fileTreeStale:!0,gitStale:!0}),this.refreshSelectedWorkspaceTool(this.state.workspaceTool))}refreshSelectedWorkspaceTool(e){e==="core:workspace.files"&&this.files.refreshFiles(),e==="core:workspace.git"&&this.git.refreshGit()}renderWorkspacePanel(){const e=this.state.selectedWorkspace,t=e===void 0?void 0:this.createWorkspacePanelContext(e),s=e===void 0?[]:this.plugins.getWorkspaceLabelItems(this.state,e),i=e===void 0?this.workspacePanelEmptyState():void 0;return c`
|
|
1337
|
-
<workspace-panel
|
|
1338
|
-
id="workspace-panel"
|
|
1339
|
-
.workspace=${e}
|
|
1340
|
-
.panelContext=${t}
|
|
1341
|
-
.emptyState=${i}
|
|
1342
|
-
.tool=${this.state.workspaceTool}
|
|
1343
|
-
.panels=${this.visibleWorkspacePanels()}
|
|
1344
|
-
.workspaceLabelItems=${s}
|
|
1345
|
-
.onSelectTool=${r=>{this.openWorkspaceTool(r)}}
|
|
1346
|
-
></workspace-panel>
|
|
1347
|
-
`}renderNavigationPanelEdgeControl(){return c`
|
|
1348
|
-
<app-panel-edge-control
|
|
1349
|
-
side="navigation"
|
|
1350
|
-
controls="navigation-panel"
|
|
1351
|
-
expandLabel="Expand navigation panel"
|
|
1352
|
-
collapseLabel="Collapse navigation panel"
|
|
1353
|
-
.collapsed=${this.panelCollapse.navigationPanelCollapsed}
|
|
1354
|
-
.onToggle=${()=>{this.panelCollapse.toggleNavigationPanel()}}
|
|
1355
|
-
></app-panel-edge-control>
|
|
1356
|
-
`}renderWorkspacePanelEdgeControl(){return c`
|
|
1357
|
-
<app-panel-edge-control
|
|
1358
|
-
side="workspace"
|
|
1359
|
-
controls="workspace-panel"
|
|
1360
|
-
expandLabel="Expand workspace panel"
|
|
1361
|
-
collapseLabel="Collapse workspace panel"
|
|
1362
|
-
.collapsed=${this.panelCollapse.workspacePanelCollapsed}
|
|
1363
|
-
.onToggle=${()=>{this.panelCollapse.toggleWorkspacePanel()}}
|
|
1364
|
-
></app-panel-edge-control>
|
|
1365
|
-
`}renderNavigationPanel(e){const t=s=>this.withChatScrollTransition(async()=>{await s(),e&&this.setState({mainView:"chat"}),e&&this.updateUrl()});return c`
|
|
1366
|
-
<app-navigation-panel
|
|
1367
|
-
.projects=${this.state.projects}
|
|
1368
|
-
.selectedProject=${this.state.selectedProject}
|
|
1369
|
-
.workspaceActivities=${this.state.workspaceActivities}
|
|
1370
|
-
.workspacesByProjectId=${this.state.workspacesByProjectId}
|
|
1371
|
-
.workspaces=${this.state.workspaces}
|
|
1372
|
-
.selectedWorkspace=${this.state.selectedWorkspace}
|
|
1373
|
-
.deletingWorkspaceIds=${kc(this.state.workspaceDeletionRuns)}
|
|
1374
|
-
.sessions=${this.state.sessions}
|
|
1375
|
-
.sessionStatuses=${this.state.sessionStatuses}
|
|
1376
|
-
.sessionActivities=${this.state.sessionActivities}
|
|
1377
|
-
.selectedSession=${this.state.selectedSession}
|
|
1378
|
-
.canStartSession=${!!this.state.selectedWorkspace}
|
|
1379
|
-
.collapsible=${this.appShell.isMobileNavigationLayout}
|
|
1380
|
-
.projectsCollapsed=${this.mobileNavigation.isCollapsed("projects")}
|
|
1381
|
-
.workspacesCollapsed=${this.mobileNavigation.isCollapsed("workspaces")}
|
|
1382
|
-
.sessionsCollapsed=${this.mobileNavigation.isCollapsed("sessions")}
|
|
1383
|
-
.workspaceLabelItems=${s=>this.plugins.getWorkspaceLabelItems(this.state,s)}
|
|
1384
|
-
.refreshControl=${this.appShell.shouldShowAppRefreshInHeader()?this.renderAppRefresh():void 0}
|
|
1385
|
-
.onShowActions=${()=>{this.setState({actionPaletteOpen:!0})}}
|
|
1386
|
-
.onToggleProjects=${()=>{this.mobileNavigation.toggle("projects")}}
|
|
1387
|
-
.onToggleWorkspaces=${()=>{this.mobileNavigation.toggle("workspaces")}}
|
|
1388
|
-
.onToggleSessions=${()=>{this.mobileNavigation.toggle("sessions")}}
|
|
1389
|
-
.onSelectProject=${s=>this.withChatScrollTransition(async()=>{this.mobileNavigation.expand("workspaces"),await this.workspaces.selectProject(s)})}
|
|
1390
|
-
.onCloseProject=${s=>this.projects.closeProject(s.id)}
|
|
1391
|
-
.onSelectWorkspace=${s=>this.withChatScrollTransition(async()=>{this.mobileNavigation.expand("sessions"),await this.workspaces.selectWorkspace(s)})}
|
|
1392
|
-
.onDeleteWorkspace=${s=>{this.deleteWorkspace(s)}}
|
|
1393
|
-
.onArchivedCollapsed=${()=>{this.sessions.clearSelectionAfterArchivedCollapse()}}
|
|
1394
|
-
.onStartSession=${()=>t(()=>this.sessions.startSession())}
|
|
1395
|
-
.onSelectSession=${s=>t(()=>this.sessions.selectSession(s))}
|
|
1396
|
-
.onArchiveSession=${s=>this.sessions.archiveSession(s)}
|
|
1397
|
-
.onArchiveSessionWithDescendants=${s=>this.sessions.archiveSessionWithDescendants(s)}
|
|
1398
|
-
.onRestoreSession=${s=>t(()=>this.sessions.restoreSession(s))}
|
|
1399
|
-
.onDeleteCachedNewSession=${s=>this.sessions.deleteCachedNewSession(s)}
|
|
1400
|
-
.onDetachParentSession=${s=>this.sessions.detachParent(s)}
|
|
1401
|
-
></app-navigation-panel>
|
|
1402
|
-
`}openNavigationSection(e){this.mobileNavigation.open(e,()=>{this.selectMainView("navigation")})}visibleWorkspacePanels(){const e=this.state.selectedWorkspace;return e===void 0?[]:this.plugins.getWorkspacePanels().filter(t=>t.visible?.({workspace:e,state:this.state})??!0)}workspacePanelEmptyState(){const e=this.state.selectedProject;return this.state.isLoadingProjects?{title:"Loading projects…",body:"Looking for projects you have added to PI WEB."}:e===void 0?this.state.projects.length===0?{title:"No projects yet",body:"Use Actions → Add Project to add a folder. Workspace tools will appear here after you choose a workspace."}:{title:"Select a project",body:"Choose a project from the sidebar, then select a workspace to inspect files, Git, or terminals."}:this.state.isLoadingWorkspaces?{title:"Loading workspaces…",body:`Preparing workspace tools for ${e.name}.`}:this.state.workspaces.length===0?{title:"No workspaces found",body:`${e.name} does not have any available workspaces. Try selecting the project again or re-adding it.`}:{title:"Select a workspace",body:`Choose a workspace in ${e.name} to inspect files, Git, or terminals.`}}sessionEmptyMessage(){return this.state.isLoadingProjects?"Loading projects…":this.state.selectedWorkspace!==void 0?"Select or start a session.":this.state.selectedProject!==void 0?"Select a workspace to start a session.":this.state.projects.length===0?"Add a project to start a session.":"Select a project and workspace to start a session."}renderMobilePanelTitle(e){const t=this.state.selectedWorkspace;if(t===void 0)return e.title;const s=e.badge?.(this.createWorkspacePanelContext(t));return s===void 0||s===""?e.title:c`${e.title} <span class="tab-badge">${s}</span>`}createWorkspacePanelContext(e){const t=s=>rd({workspace:e,state:this.state,piWebInternal:{terminalCommandRuns:this.terminalCommandRunsForOrigin(s)},fileTree:this.state.fileTree,expandedDirs:this.state.expandedDirs,selectedFilePath:this.state.selectedFilePath,selectedFileContent:this.state.selectedFileContent,fileTreeStale:this.state.fileTreeStale,gitStatus:this.state.gitStatus,selectedDiffPath:this.state.selectedDiffPath,selectedDiff:this.state.selectedDiff,selectedStagedDiff:this.state.selectedStagedDiff,gitStale:this.state.gitStale,activeTerminalCount:this.state.activeTerminalCount,selectedTerminalId:this.state.selectedTerminalId,terminalAutoStart:this.terminalAutoStartWorkspaceId===e.id,openTerminal:i=>{this.openTerminal(i)},onRefreshFiles:()=>{this.files.refreshFiles()},onExpandDir:i=>{this.files.expandDir(i)},onSelectFile:i=>{this.files.selectFile(i)},onRefreshGit:()=>{this.git.refreshGit()},onSelectDiff:i=>{this.git.selectDiff(i)},onSelectTerminal:(i,r)=>{this.selectTerminal(i,r)}},t);return t("core")}getActions(){return this.plugins.getActions(this.createPluginRuntimeContext())}async loadExternalPlugins(){try{const e=await Kc();for(const t of e)try{this.plugins.register(t)}catch(s){console.warn(`Failed to register PI WEB plugin ${t.id}`,s)}this.applyPreferredTheme(!1),this.requestUpdate()}catch(e){console.warn("Failed to load external PI WEB plugins",e)}}createPluginRuntimeContext(){const e=t=>id({state:this.state,piWebInternal:{terminalCommandRuns:this.terminalCommandRunsForOrigin(t)},openActionPalette:()=>{this.setState({actionPaletteOpen:!0})},focusPrompt:()=>{this.promptEditor?.focusInput()},addProject:()=>{this.setState({projectDialogOpen:!0})},configureAuth:()=>this.auth.openLogin(),logoutAuth:()=>this.auth.openLogout(),openThemePicker:()=>{this.openThemeDialog()},selectMainView:s=>{this.selectMainView(s)},selectWorkspaceTool:s=>{this.openWorkspaceTool(s)},openTerminal:s=>{this.openTerminal(s)},refreshFiles:()=>this.files.refreshFiles(),refreshGit:()=>this.git.refreshGit(),refreshAppData:()=>this.refreshAppData(),reloadPage:()=>{this.hardReloadApp()},deleteWorkspace:s=>this.deleteWorkspace(s),startSession:()=>this.withChatScrollTransition(()=>this.sessions.startSession()),archiveSession:()=>this.sessions.archiveSession(),deleteCachedNewSession:()=>this.sessions.deleteCachedNewSession(),stopActiveWork:()=>this.sessions.stopActiveWork()},e);return e("core")}async deleteWorkspace(e=this.state.selectedWorkspace){if(e===void 0)return;if(!Jl(e)){this.setState({error:"Only secondary Git worktrees can be deleted"});return}if(Nr(this.state,e))return;const t=e.branch??e.label;if(confirm(`Delete workspace ${t}?
|
|
1403
|
-
|
|
1404
|
-
This will run git worktree remove and delete:
|
|
1405
|
-
${e.path}
|
|
1406
|
-
|
|
1407
|
-
The Git branch will not be deleted.`))try{const i=await this.mainWorkspaceForProject(e.projectId);if(i===void 0){this.setState({error:"Project main workspace not found"});return}const r=await this.terminalCommandRunsForOrigin("core").runCommand({workspace:i,title:`Delete workspace: ${t}`,command:`git worktree remove ${Ku(e.path)}`,open:!0,metadata:wc(e)});this.recordWorkspaceDeletionRun(r.run),r.completed.then(o=>this.handleCompletedWorkspaceDeletionRun(o)).catch(o=>{this.setState({error:`Workspace deletion failed. See terminal output. ${cr(o)}`})})}catch(i){this.setState({error:`Failed to start workspace deletion: ${cr(i)}`})}}async mainWorkspaceForProject(e){let t=this.state.selectedProject?.id===e?this.state.workspaces:this.state.workspacesByProjectId[e];return(t===void 0||t.length===0)&&(t=await this.workspaces.refreshProjectWorkspaces(e)),t.find(s=>s.isMain)??t[0]}recordWorkspaceDeletionRun(e){const t=ps(e);t!==void 0&&(this.setState({workspaceDeletionRuns:{...this.state.workspaceDeletionRuns,[t]:e}}),this.updateWorkspaceDeletionPolling())}async refreshWorkspaceDeletionRuns(){if(this.refreshingWorkspaceDeletionRuns)return;const e=this.state.selectedProject;if(e===void 0){this.setState({workspaceDeletionRuns:{}}),this.updateWorkspaceDeletionPolling();return}this.refreshingWorkspaceDeletionRuns=!0;try{const t=await this.terminalCommandRunsForOrigin("core").listCommandRuns(yc(e.id)),s=xc(t);this.setState({workspaceDeletionRuns:s});for(const i of Object.values(s))Mt(i)||await this.handleCompletedWorkspaceDeletionRun(i)}catch(t){console.warn("Failed to refresh workspace deletion runs",t)}finally{this.refreshingWorkspaceDeletionRuns=!1,this.updateWorkspaceDeletionPolling()}}updateWorkspaceDeletionPolling(){const e=Object.values(this.state.workspaceDeletionRuns).some(Mt);if(e&&this.workspaceDeletionPollTimer===void 0){this.workspaceDeletionPollTimer=window.setInterval(()=>{this.refreshWorkspaceDeletionRuns()},1e3);return}!e&&this.workspaceDeletionPollTimer!==void 0&&(window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0)}async handleCompletedWorkspaceDeletionRun(e){if(this.handledWorkspaceDeletionRunIds.has(e.id))return;const t=ps(e);if(t!==void 0){if(this.handledWorkspaceDeletionRunIds.add(e.id),e.status==="succeeded"){await this.workspaces.refreshAfterWorkspaceDeleted(e.projectId,t),this.setState({workspaceDeletionRuns:Qu(this.state.workspaceDeletionRuns,t)}),this.updateWorkspaceDeletionPolling();return}e.status==="failed"&&(this.setState({error:"Workspace deletion failed. See terminal output."}),this.updateWorkspaceDeletionPolling())}}runAction(e){Promise.resolve().then(()=>e.run()).catch(t=>{const s=t instanceof Error?t.message:String(t);console.warn(`Action failed: ${e.id}`,t),this.setState({error:`Action failed: ${s}`})})}async openModelDialog(){const e=await this.sessions.listModels(),t=this.state.status?.model?.provider,s=this.state.status?.model?.id;this.setState({modelDialog:{title:"Select Model",...t!==void 0&&s!==void 0?{selectedValue:`${t}/${s}`}:{},options:e.map(i=>{const r=i.provider??"",o=i.id??"",n=r===t&&o===s;return{value:`${r}/${o}`,label:`${o}${n?" ✓ current":""}`,description:r}})}})}async pickModel(e){this.setState({modelDialog:void 0});const t=e.indexOf("/");t<=0||await this.sessions.setModel(e.slice(0,t),e.slice(t+1))}openThemeDialog(){const e=this.plugins.getThemes(),t=this.resolveCurrentThemePreference(e),s=t.selectedTheme?.id,i=this.themePreference.auto?nr:os;this.setState({themeDialog:{title:"Select Theme",selectedValue:s===void 0?i:`${vt}${s}`,options:[{value:i,label:`Auto ${this.themePreference.auto?"✓ on":"off"}`,description:this.autoThemeDescription(t)},...e.map(r=>({value:`${vt}${r.id}`,label:this.themeOptionLabel(r,s),description:this.themeOptionDescription(r)}))]}})}pickTheme(e){if(this.setState({themeDialog:void 0}),e===os||e===nr){const i=this.resolveCurrentThemePreference().selectedTheme?.id;if(i===void 0)return;this.themePreference={themeId:i,auto:e===os},this.applyPreferredTheme(!0);return}if(!e.startsWith(vt))return;const t=e.slice(vt.length),s=this.plugins.getThemes().find(i=>i.id===t);s!==void 0&&(this.themePreference={themeId:s.id,auto:this.themePreference.auto},this.applyPreferredTheme(!0))}applyPreferredTheme(e){const t=this.resolveCurrentThemePreference().activeTheme;t!==void 0&&(this.activeThemeId=t.id,pc(t),e&&dc(this.themePreference))}resolveCurrentThemePreference(e=this.plugins.getThemes()){return hc({themes:e,themePairs:this.plugins.getThemePairs(),preference:this.themePreference,prefersLight:this.systemPrefersLight()})}themePairForTheme(e){return Lr(this.plugins.getThemePairs(),e)}systemPrefersLight(){return this.systemLightThemeMedia?.matches??!1}autoThemeDescription(e){return!this.themePreference.auto||e.selectedTheme===void 0?"Follow the system light/dark preference when the selected theme has a pair.":e.selectedThemePair===void 0?"On, but the selected theme has no light/dark pair, so it will stay selected.":`On · ${e.selectedThemePair.name} follows the system ${this.systemPrefersLight()?"light":"dark"} preference.`}themeOptionLabel(e,t){const s=[...e.id===t?["selected"]:[],...e.id===this.activeThemeId&&e.id!==t?["active"]:[]];return s.length===0?e.name:`${e.name} ✓ ${s.join(" · ")}`}themeOptionDescription(e){const t=[e.colorScheme];return this.themePairForTheme(e.id)!==void 0&&t.push("auto pair"),e.description!==void 0&&t.push(e.description),t.join(" · ")}async openThinkingDialog(){const e=await this.sessions.listThinkingLevels(),t=this.state.status?.thinkingLevel??"off";this.setState({thinkingDialog:{title:"Select Thinking Level",selectedValue:t,options:e.map(s=>({value:s,label:`${s}${s===t?" ✓ current":""}`,description:Xu(s)}))}})}async pickThinking(e){this.setState({thinkingDialog:void 0}),Zu(e)&&await this.sessions.setThinkingLevel(e)}sendPrompt(e,t){t===void 0&&this.auth.handleSlashCommand(e)||this.sessions.send(e,t)}renderContextBar(){return this.appShell.isMobileNavigationLayout?c`
|
|
1408
|
-
<app-context-bar
|
|
1409
|
-
.project=${this.state.selectedProject}
|
|
1410
|
-
.workspace=${this.state.selectedWorkspace}
|
|
1411
|
-
.session=${this.state.selectedSession}
|
|
1412
|
-
.refreshControl=${this.appShell.shouldShowAppRefreshInContextBar()?this.renderAppRefresh():void 0}
|
|
1413
|
-
.onOpenSection=${e=>{this.openNavigationSection(e)}}
|
|
1414
|
-
></app-context-bar>
|
|
1415
|
-
`:null}renderMobileMainTabs(){return c`
|
|
1416
|
-
<app-mobile-main-tabs
|
|
1417
|
-
.tabs=${this.mobileMainTabs()}
|
|
1418
|
-
.selectedView=${this.state.mainView}
|
|
1419
|
-
.onSelect=${e=>{this.selectMainView(e)}}
|
|
1420
|
-
></app-mobile-main-tabs>
|
|
1421
|
-
`}mobileMainTabs(){return[{id:"navigation",label:"Sessions",className:"navigation-tab"},{id:"chat",label:"Chat"},...this.visibleWorkspacePanels().map(e=>({id:e.id,label:this.renderMobilePanelTitle(e)}))]}renderAppRefresh(){return c`<app-refresh-control .isRefreshing=${this.isRefreshingApp} .onRefresh=${()=>this.refreshAppData()} .onReload=${()=>{this.hardReloadApp()}}></app-refresh-control>`}render(){const e=this.state;return c`
|
|
1422
|
-
<div class=${this.panelCollapse.shellClass(e.mainView)}>
|
|
1423
|
-
<aside id="navigation-panel">${this.appShell.isMobileNavigationLayout?null:this.renderNavigationPanel(!1)}</aside>
|
|
1424
|
-
${this.renderNavigationPanelEdgeControl()}
|
|
1425
|
-
<main class=${Ur(e.mainView)}>
|
|
1426
|
-
${this.renderContextBar()}
|
|
1427
|
-
${this.renderMobileMainTabs()}
|
|
1428
|
-
${e.error?c`<div class="error">${e.error}</div>`:null}
|
|
1429
|
-
<div class="mobile-navigation-panel">${this.appShell.isMobileNavigationLayout?this.renderNavigationPanel(!0):null}</div>
|
|
1430
|
-
${e.selectedSession?c`
|
|
1431
|
-
<chat-view .sessionId=${e.selectedSession.id} .messages=${e.messages} .messageStart=${e.messagePageStart} .messageEnd=${e.messagePageEnd} .messageTotal=${e.messagePageTotal} .hasMore=${e.messagePageStart>0} .loadingMore=${e.isLoadingEarlierMessages} .isReceivingPartialStream=${e.isReceivingPartialStream} .isCompacting=${e.status?.isCompacting===!0} .pendingMessageCount=${e.status?.pendingMessageCount??0} .status=${e.status} .activity=${e.activity} .onLoadMore=${()=>this.withChatPrependTransition(()=>this.sessions.loadEarlierMessages())}></chat-view>
|
|
1432
|
-
<prompt-editor .sessionId=${e.selectedSession.id} .cwd=${e.selectedWorkspace?.path} .disabled=${e.selectedSession.archived===!0} .canSteer=${e.status?.isStreaming===!0} .isCompacting=${e.status?.isCompacting===!0} .canStop=${e.status?.isStreaming===!0||e.status?.isBashRunning===!0||e.status?.isCompacting===!0||(e.status?.pendingMessageCount??0)>0} .status=${e.status} .onSend=${(t,s)=>{this.sendPrompt(t,s)}} .onStop=${()=>this.sessions.stopActiveWork()} .onSelectModel=${()=>{this.openModelDialog()}} .onSelectThinking=${()=>{this.openThinkingDialog()}}></prompt-editor>
|
|
1433
|
-
<status-bar .status=${e.status} .workspace=${e.selectedWorkspace} .workspaceLabelItems=${e.selectedWorkspace===void 0?[]:this.plugins.getWorkspaceLabelItems(e,e.selectedWorkspace)}></status-bar>
|
|
1434
|
-
${e.commandDialog!==void 0?c`<command-picker .title=${e.commandDialog.title} .options=${e.commandDialog.options} .onPick=${t=>this.sessions.respondToCommand(e.commandDialog?.requestId??"",t)} .onCancel=${()=>{this.sessions.cancelCommand()}}></command-picker>`:null}
|
|
1435
|
-
${e.modelDialog!==void 0?c`<command-picker title=${e.modelDialog.title} .searchable=${!0} .options=${e.modelDialog.options} .selectedValue=${e.modelDialog.selectedValue} .onPick=${t=>{this.pickModel(t)}} .onCancel=${()=>{this.setState({modelDialog:void 0})}}></command-picker>`:null}
|
|
1436
|
-
${e.thinkingDialog!==void 0?c`<command-picker title=${e.thinkingDialog.title} .options=${e.thinkingDialog.options} .selectedValue=${e.thinkingDialog.selectedValue} .onPick=${t=>{this.pickThinking(t)}} .onCancel=${()=>{this.setState({thinkingDialog:void 0})}}></command-picker>`:null}
|
|
1437
|
-
${e.authDialog!==void 0?c`<auth-dialog .state=${e.authDialog} .onChooseMethod=${t=>{this.auth.chooseLoginMethod(t)}} .onSelectProvider=${(t,s)=>{this.auth.selectLoginProvider(t,s)}} .onApiKeyInput=${t=>{this.auth.updateApiKey(t)}} .onSaveApiKey=${()=>{this.auth.saveApiKey()}} .onLogoutProvider=${t=>{this.auth.logoutProvider(t)}} .onOAuthInput=${t=>{this.auth.updateOAuthInput(t)}} .onOAuthRespond=${t=>{this.auth.respondOAuth(t)}} .onOAuthCancel=${()=>{this.auth.cancelOAuth()}} .onCancel=${()=>{this.auth.closeDialog()}}></auth-dialog>`:null}
|
|
1438
|
-
`:c`<div class="empty">${this.sessionEmptyMessage()}</div>`}
|
|
1439
|
-
</main>
|
|
1440
|
-
${this.renderWorkspacePanelEdgeControl()}
|
|
1441
|
-
${this.renderWorkspacePanel()}
|
|
1442
|
-
${e.actionPaletteOpen?c`<action-palette .actions=${this.getActions()} .onRun=${t=>{this.setState({actionPaletteOpen:!1}),this.runAction(t)}} .onCancel=${()=>{this.setState({actionPaletteOpen:!1})}}></action-palette>`:null}
|
|
1443
|
-
${e.projectDialogOpen?c`<project-dialog .onSubmit=${(t,s)=>this.projects.addProject(t,s)} .onCancel=${()=>{this.setState({projectDialogOpen:!1})}}></project-dialog>`:null}
|
|
1444
|
-
${e.themeDialog!==void 0?c`<command-picker title=${e.themeDialog.title} .options=${e.themeDialog.options} .selectedValue=${e.themeDialog.selectedValue} .onPick=${t=>{this.pickTheme(t)}} .onCancel=${()=>{this.setState({themeDialog:void 0})}}></command-picker>`:null}
|
|
1445
|
-
</div>
|
|
1446
|
-
`}};we.styles=Wd;qe([k()],we.prototype,"state",2);qe([ne("chat-view")],we.prototype,"chatView",2);qe([ne("prompt-editor")],we.prototype,"promptEditor",2);qe([k()],we.prototype,"activeThemeId",2);qe([k()],we.prototype,"isRefreshingApp",2);we=qe([M("pi-web-app")],we);function Uu(){const e=new td;return e.register({id:"core",plugin:qc}),e.register({id:"themes",plugin:Gc}),e}function Vu(e,t){return Object.entries(t).some(([s,i])=>Reflect.get(e,s)!==i)}function lr(e){return Nt(e.status,e.activity)}function Gu(e){return e.type==="terminal.created"||e.type==="terminal.exited"||e.type==="terminal.closed"}function Ku(e){return`'${e.replaceAll("'","'\\''")}'`}function cr(e){return e instanceof Error?e.message:String(e)}function Qu(e,t){return Object.fromEntries(Object.entries(e).filter(([s])=>s!==t))}function Ju(){return new Promise(e=>requestAnimationFrame(()=>{e()}))}function Zu(e){return e==="off"||e==="minimal"||e==="low"||e==="medium"||e==="high"||e==="xhigh"}function Xu(e){switch(e){case"off":return"No reasoning";case"minimal":return"Very brief reasoning (~1k tokens)";case"low":return"Light reasoning (~2k tokens)";case"medium":return"Moderate reasoning (~8k tokens)";case"high":return"Deep reasoning (~16k tokens)";case"xhigh":return"Maximum reasoning (~32k tokens)"}}export{j as a,c as b,$s as c,pf as d,ne as e,cf as f,C as i,p as n,k as r,df as s,M as t};
|