litepaseo 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +1 -0
  3. package/dist/server/cli.mjs +2 -2
  4. package/dist/server/{worker-C0PSaDFz.mjs → worker-DFd8kCiy.mjs} +28 -0
  5. package/dist/web/assets/{ChangesPanel-D_Gc7lql.js → ChangesPanel-BcmK5kQw.js} +1 -1
  6. package/dist/web/assets/ChangesPanel-BcmK5kQw.js.br +0 -0
  7. package/dist/web/assets/ChangesPanel-BcmK5kQw.js.gz +0 -0
  8. package/dist/web/assets/{CodeBlockNode-BYeeAHZ5.js → CodeBlockNode-L2jfjRHi.js} +1 -1
  9. package/dist/web/assets/CodeBlockNode-L2jfjRHi.js.br +0 -0
  10. package/dist/web/assets/CodeBlockNode-L2jfjRHi.js.gz +0 -0
  11. package/dist/web/assets/{ConversationSearch-FrgBojJC.js → ConversationSearch-DRXClZic.js} +1 -1
  12. package/dist/web/assets/ConversationSearch-DRXClZic.js.br +0 -0
  13. package/dist/web/assets/ConversationSearch-DRXClZic.js.gz +0 -0
  14. package/dist/web/assets/{FileViewer-BJoCEEXY.js → FileViewer-Bs0locPm.js} +1 -1
  15. package/dist/web/assets/FileViewer-Bs0locPm.js.br +0 -0
  16. package/dist/web/assets/FileViewer-Bs0locPm.js.gz +0 -0
  17. package/dist/web/assets/{FilesPanel-ZVYE0rsS.js → FilesPanel-CIlBeef1.js} +1 -1
  18. package/dist/web/assets/FilesPanel-CIlBeef1.js.br +7 -0
  19. package/dist/web/assets/FilesPanel-CIlBeef1.js.gz +0 -0
  20. package/dist/web/assets/{MarkdownMessage-BcsVBZas.js → MarkdownMessage-10o_Q6Zw.js} +5 -5
  21. package/dist/web/assets/MarkdownMessage-10o_Q6Zw.js.br +0 -0
  22. package/dist/web/assets/MarkdownMessage-10o_Q6Zw.js.gz +0 -0
  23. package/dist/web/assets/{PreCodeBlock-BYiOSyIK.js → PreCodeBlock-BKQztVo1.js} +1 -1
  24. package/dist/web/assets/{PreCodeBlock.vue_vue_type_style_index_0_lang-DRPpyHNP.js → PreCodeBlock.vue_vue_type_style_index_0_lang-ydnV-qIc.js} +1 -1
  25. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-ydnV-qIc.js.br +0 -0
  26. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-ydnV-qIc.js.gz +0 -0
  27. package/dist/web/assets/{TerminalPanel-DdF49dfg.js → TerminalPanel-CCDC8FeR.js} +1 -1
  28. package/dist/web/assets/TerminalPanel-CCDC8FeR.js.br +0 -0
  29. package/dist/web/assets/TerminalPanel-CCDC8FeR.js.gz +0 -0
  30. package/dist/web/assets/{Tooltip-CBtAXEd9.js → Tooltip-CtoED8n4.js} +1 -1
  31. package/dist/web/assets/Tooltip-CtoED8n4.js.br +0 -0
  32. package/dist/web/assets/Tooltip-CtoED8n4.js.gz +0 -0
  33. package/dist/web/assets/index-B_dXJeM1.js +34 -0
  34. package/dist/web/assets/index-B_dXJeM1.js.br +0 -0
  35. package/dist/web/assets/index-B_dXJeM1.js.gz +0 -0
  36. package/dist/web/assets/{index-BgySs5Da.css → index-D6jrfbMg.css} +1 -1
  37. package/dist/web/assets/index-D6jrfbMg.css.br +0 -0
  38. package/dist/web/assets/index-D6jrfbMg.css.gz +0 -0
  39. package/dist/web/assets/{index10-Bf2-WO96.js → index10-C-1T2JwF.js} +1 -1
  40. package/dist/web/assets/index10-C-1T2JwF.js.br +0 -0
  41. package/dist/web/assets/index10-C-1T2JwF.js.gz +0 -0
  42. package/dist/web/assets/index3-BVfn0UY8.js +1 -0
  43. package/dist/web/assets/index4-0z_glOuz.js +1 -0
  44. package/dist/web/assets/{index5-RYzHOHr1.js → index5-BgjNmeuE.js} +1 -1
  45. package/dist/web/assets/index5-BgjNmeuE.js.br +0 -0
  46. package/dist/web/assets/index5-BgjNmeuE.js.gz +0 -0
  47. package/dist/web/assets/{index6-DbjQTELa.js → index6-CtKO3fgl.js} +1 -1
  48. package/dist/web/assets/index6-CtKO3fgl.js.br +0 -0
  49. package/dist/web/assets/index6-CtKO3fgl.js.gz +0 -0
  50. package/dist/web/assets/{index7-CaEorL43.js → index7-Ct2fZSl4.js} +1 -1
  51. package/dist/web/assets/index7-Ct2fZSl4.js.br +0 -0
  52. package/dist/web/assets/index7-Ct2fZSl4.js.gz +0 -0
  53. package/dist/web/assets/{index8-xlmmT8TD.js → index8-C0FDMNQ_.js} +1 -1
  54. package/dist/web/assets/index8-C0FDMNQ_.js.br +0 -0
  55. package/dist/web/assets/index8-C0FDMNQ_.js.gz +0 -0
  56. package/dist/web/assets/{index9-BF08Ra0y.js → index9-BgGcmJ2U.js} +1 -1
  57. package/dist/web/assets/index9-BgGcmJ2U.js.br +0 -0
  58. package/dist/web/assets/index9-BgGcmJ2U.js.gz +0 -0
  59. package/dist/web/index.html +2 -2
  60. package/dist/web/index.html.br +0 -0
  61. package/dist/web/index.html.gz +0 -0
  62. package/package.json +1 -1
  63. package/dist/web/assets/ChangesPanel-D_Gc7lql.js.br +0 -0
  64. package/dist/web/assets/ChangesPanel-D_Gc7lql.js.gz +0 -0
  65. package/dist/web/assets/CodeBlockNode-BYeeAHZ5.js.br +0 -0
  66. package/dist/web/assets/CodeBlockNode-BYeeAHZ5.js.gz +0 -0
  67. package/dist/web/assets/ConversationSearch-FrgBojJC.js.br +0 -0
  68. package/dist/web/assets/ConversationSearch-FrgBojJC.js.gz +0 -0
  69. package/dist/web/assets/FileViewer-BJoCEEXY.js.br +0 -0
  70. package/dist/web/assets/FileViewer-BJoCEEXY.js.gz +0 -0
  71. package/dist/web/assets/FilesPanel-ZVYE0rsS.js.br +0 -0
  72. package/dist/web/assets/FilesPanel-ZVYE0rsS.js.gz +0 -0
  73. package/dist/web/assets/MarkdownMessage-BcsVBZas.js.br +0 -0
  74. package/dist/web/assets/MarkdownMessage-BcsVBZas.js.gz +0 -0
  75. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-DRPpyHNP.js.br +0 -0
  76. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-DRPpyHNP.js.gz +0 -0
  77. package/dist/web/assets/TerminalPanel-DdF49dfg.js.br +0 -0
  78. package/dist/web/assets/TerminalPanel-DdF49dfg.js.gz +0 -0
  79. package/dist/web/assets/Tooltip-CBtAXEd9.js.br +0 -0
  80. package/dist/web/assets/Tooltip-CBtAXEd9.js.gz +0 -0
  81. package/dist/web/assets/index-BgySs5Da.css.br +0 -0
  82. package/dist/web/assets/index-BgySs5Da.css.gz +0 -0
  83. package/dist/web/assets/index-Ub0Ct8zc.js +0 -34
  84. package/dist/web/assets/index-Ub0Ct8zc.js.br +0 -0
  85. package/dist/web/assets/index-Ub0Ct8zc.js.gz +0 -0
  86. package/dist/web/assets/index10-Bf2-WO96.js.br +0 -0
  87. package/dist/web/assets/index10-Bf2-WO96.js.gz +0 -0
  88. package/dist/web/assets/index3-BOkZ-YzF.js +0 -1
  89. package/dist/web/assets/index4-DKRXIWnO.js +0 -1
  90. package/dist/web/assets/index5-RYzHOHr1.js.br +0 -0
  91. package/dist/web/assets/index5-RYzHOHr1.js.gz +0 -0
  92. package/dist/web/assets/index6-DbjQTELa.js.br +0 -0
  93. package/dist/web/assets/index6-DbjQTELa.js.gz +0 -0
  94. package/dist/web/assets/index7-CaEorL43.js.br +0 -0
  95. package/dist/web/assets/index7-CaEorL43.js.gz +0 -0
  96. package/dist/web/assets/index8-xlmmT8TD.js.br +0 -0
  97. package/dist/web/assets/index8-xlmmT8TD.js.gz +0 -0
  98. package/dist/web/assets/index9-BF08Ra0y.js.br +0 -0
  99. package/dist/web/assets/index9-BF08Ra0y.js.gz +0 -0
@@ -0,0 +1,34 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownMessage-10o_Q6Zw.js","assets/vue.runtime.esm-bundler-DwGo9CTz.js","assets/rolldown-runtime-XKyaHtl9.js","assets/highlight-BnTrj1LT.js","assets/MarkdownMessage-bqphU8I9.css","assets/ChangesPanel-BcmK5kQw.js","assets/ChangesPanel-BlAOBntI.css","assets/ConversationSearch-DRXClZic.js","assets/ConversationSearch-BD_oQkce.css","assets/FilesPanel-CIlBeef1.js","assets/FilesPanel-CY9yMixJ.css","assets/FileViewer-Bs0locPm.js","assets/FileViewer-T756VVq4.css","assets/TerminalPanel-CCDC8FeR.js","assets/TerminalPanel-mJ-uVP4H.css"])))=>i.map(i=>d[i]);
2
+ import{$ as e,C as t,G as n,H as r,I as i,J as a,L as o,M as s,N as c,P as l,Q as u,S as d,T as f,X as p,_ as m,a as h,at as g,c as _,d as v,et as y,f as b,g as x,h as S,j as C,k as w,l as T,m as E,nt as D,o as O,ot as k,p as A,r as j,rt as M,s as N,u as P,v as F,w as I,x as L,y as R,z}from"./vue.runtime.esm-bundler-DwGo9CTz.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var B=e=>e?e.size:0,V=e=>(e.size=1+B(e.left)+B(e.right),e),H=class{root=null;compare;constructor(e){this.compare=e}get size(){return B(this.root)}clear(){this.root=null}insert(e){let[t,n]=this.split(this.root,e,!1),r={item:e,priority:Math.random(),size:1,left:null,right:null};this.root=this.merge(this.merge(t,r),n)}remove(e){let[t,n]=this.split(this.root,e,!1),[r,i]=this.split(n,e,!0);return this.root=this.merge(t,i),r!==null}at(e){let t=this.root;for(;t;){let n=B(t.left);if(e<n)t=t.left;else if(e===n)return t.item;else e-=n+1,t=t.right}}rank(e){let t=this.root,n=0;for(;t;){let r=this.compare(e,t.item);if(r<0)t=t.left;else if(r>0)n+=B(t.left)+1,t=t.right;else return n+B(t.left)}return-1}range(e,t){let n=[],r=Math.min(this.size,e+t);if(e=Math.max(0,e),e>=r)return n;let i=[],a=this.root,o=e;for(;a;){let e=B(a.left);if(o<e)i.push(a),a=a.left;else if(o===e){i.push(a);break}else o-=e+1,a=a.right}for(;n.length<r-e&&i.length;){let e=i.pop();n.push(e.item);let t=e.right;for(;t;)i.push(t),t=t.left}return n}split(e,t,n){if(!e)return[null,null];let r=this.compare(e.item,t);if(r<0||n&&r===0){let[r,i]=this.split(e.right,t,n);return e.right=r,[V(e),i]}let[i,a]=this.split(e.left,t,n);return e.left=a,[i,V(e)]}merge(e,t){return e?t?e.priority>t.priority?(e.right=this.merge(e.right,t),V(e)):(t.left=this.merge(e,t.left),V(t)):e:t}},U=e=>e?e.size:0,W=e=>e?e.sum:0,ee=e=>(e.size=1+U(e.left)+U(e.right),e.sum=e.weight+W(e.left)+W(e.right),e),te=class{root=null;compare;constructor(e){this.compare=e}get size(){return U(this.root)}get total(){return W(this.root)}clear(){this.root=null}insert(e,t){let[n,r]=this.split(this.root,e,!1),i={item:e,weight:t,priority:Math.random(),size:1,sum:t,left:null,right:null};this.root=this.merge(this.merge(n,i),r)}remove(e){let[t,n]=this.split(this.root,e,!1),[r,i]=this.split(n,e,!0);return this.root=this.merge(t,i),r!==null}reweigh(e,t){this.remove(e)&&this.insert(e,t)}at(e){let t=this.root;for(;t;){let n=U(t.left);if(e<n)t=t.left;else if(e===n)return t.item;else e-=n+1,t=t.right}}locate(e){let t=this.root,n=0,r=0;if(!t)return null;for(e=Math.max(0,Math.min(e,this.total-1e-9));t;){let i=W(t.left);if(e<i)t=t.left;else if(e<i+t.weight||!t.right)return{item:t.item,rank:n+U(t.left),start:r+i};else e-=i+t.weight,r+=i+t.weight,n+=U(t.left)+1,t=t.right}return null}offsetOf(e){let t=this.root,n=0;for(;t;){let r=this.compare(e,t.item);if(r<0)t=t.left;else if(r>0)n+=W(t.left)+t.weight,t=t.right;else return n+W(t.left)}return-1}split(e,t,n){if(!e)return[null,null];let r=this.compare(e.item,t);if(r<0||n&&r===0){let[r,i]=this.split(e.right,t,n);return e.right=r,[ee(e),i]}let[i,a]=this.split(e.left,t,n);return e.left=a,[i,ee(e)]}merge(e,t){return e?t?e.priority>t.priority?(e.right=this.merge(e.right,t),ee(e)):(t.left=this.merge(e,t.left),ee(t)):e:t}},G=[`needs_input`,`running`,`review`,`done`],K=e=>e===`failed`||e===`unread`?`review`:e,ne=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e,q=typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches?44:36,re=(e,t)=>e.key<t.key?-1:+(e.key>t.key);function ie(e,t){return t.activityAt-e.activityAt||re(e,t)}function ae(e,t){let n=e.pinnedAt??0,r=t.pinnedAt??0;return n||r?n?r?n-r||re(e,t):-1:1:ie(e,t)}function oe(e){return e.attention?`needs_input`:e.failed?`failed`:e.running?`running`:e.unread?`unread`:`done`}var se=e=>`${e.hostId}\n${e.project.toLowerCase()}`,ce=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),le=(e,t)=>(e.pinnedAt||t.pinnedAt?e.pinnedAt?t.pinnedAt?e.pinnedAt-t.pinnedAt||ce.compare(e.key,t.key):-1:1:0)||t.recent-e.recent||ce.compare(e.name,t.name)||(e.key<t.key?-1:+(e.key>t.key)),ue=e=>e.state??(e.status===`running`?`running`:`done`),de=class{flat;groups=new Map;index=new te(le);lanes;waiting=0;compare;isCollapsed;pinRank;constructor(e,t,n){this.pinRank=n,this.compare=e,this.isCollapsed=t,this.flat=new H(e),this.lanes=new Map(G.map(e=>[e,new H(ie)]))}get size(){return this.flat.size}weight(e){return 36+(this.isCollapsed(e.key)?0:e.items.size*q)}add(e){this.flat.insert(e),this.lanes.get(K(ue(e))).insert(e);let t=se(e),n=this.groups.get(t);n?this.index.remove(n):(n={key:t,name:e.project,items:new H(this.compare),byRecency:this.compare===ie?null:new H(ie),recent:0,attention:0,failed:0,running:0,unread:0,hosts:new Map},this.groups.set(t,n)),n.items.insert(e),n.byRecency?.insert(e),this.count(n,e,1),this.reinsert(n)}remove(e){if(!this.flat.remove(e))return;this.lanes.get(K(ue(e))).remove(e);let t=this.groups.get(se(e));t&&(this.index.remove(t),t.items.remove(e),t.byRecency?.remove(e),this.count(t,e,-1),t.items.size?this.reinsert(t):this.groups.delete(t.key))}refresh(e){let t=this.groups.get(e);t&&this.index.reweigh(t,this.weight(t))}clear(){this.flat.clear(),this.groups.clear(),this.index.clear();for(let e of this.lanes.values())e.clear();this.waiting=0}rows(e,t){let n=[],r=e+t,i=this.index.locate(Math.max(0,e));if(!i)return n;let a=i.rank,o=i.start;for(;o<r;){let t=this.index.at(a++);if(!t)break;let i=this.isCollapsed(t.key);if(o+36>e&&n.push({kind:`group`,key:`g:`+t.key,top:o,group:t,collapsed:i}),!i){let i=o+36,a=Math.max(0,Math.floor((e-i)/q)),s=Math.min(t.items.size,Math.ceil((r-i)/q));s>a&&t.items.range(a,s-a).forEach((e,t)=>n.push({kind:`item`,key:e.key,top:i+(a+t)*q,item:e}))}o+=this.weight(t)}return n}reinsert(e){e.recent=(e.byRecency??e.items).at(0).activityAt,this.index.insert(e,this.weight(e))}count(e,t,n){let r=this.pinRank(t);if(r){let t=e.pinRanks??=new Map,i=(t.get(r)??0)+n;i>0?t.set(r,i):t.delete(r),e.pinnedAt=t.size?Math.min(...t.keys()):0}let i=(e.hosts.get(t.hostId)??0)+n;i>0?e.hosts.set(t.hostId,i):e.hosts.delete(t.hostId),t.attention&&(e.attention+=n,this.waiting+=n);let a=ue(t);a===`failed`?e.failed+=n:a===`running`?e.running+=n:a===`unread`&&(e.unread+=n)}},fe=class{generation=``;seq=-1;projectPins={};pinRank=e=>e.projectId?this.projectPins[JSON.stringify([e.hostId,e.projectId])]??0:0;setProjectPins(e){this.projectPins=e,this.all.clear();for(let e of this.byHost.values())e.clear();this.filtered=null;for(let e of this.byKey.values())this.all.add(e),this.hostView(e.hostId).add(e);this.predicate&&this.rebuildFiltered(),this.version.value++}byKey=new Map;collapsed;compare;all;byHost=new Map;host=null;filtered=null;predicate=null;persist;indexOf;buckets=new Map;version=y(0);constructor(e={}){this.collapsed=new Set(e.collapsed),this.persist=e.persist??(()=>{}),this.compare=e.compare??ie,this.indexOf=e.indexBy??null,this.all=new de(this.compare,this.collapsedFn,this.pinRank)}collapsedFn=e=>this.collapsed.has(e);get base(){return this.host===null?this.all:this.hostView(this.host)}get view(){return this.filtered??this.base}hostView(e){let t=this.byHost.get(e);return t||this.byHost.set(e,t=new de(this.compare,this.collapsedFn,this.pinRank)),t}get size(){return this.view.size}get total(){return this.byKey.size}get waiting(){return this.all.waiting}get projectCount(){return this.view.groups.size}get hostFilter(){return this.host}hostSize(e){return this.byHost.get(e)?.size??0}get(e){return e?this.byKey.get(e):void 0}indexed(e,t=1){return e?this.buckets.get(e)?.range(0,t)??[]:[]}indexedSize(e){return e?this.buckets.get(e)?.size??0:0}range(e,t){return this.view.flat.range(e,t)}allLaneSize(e){return this.all.lanes.get(e).size}laneSize(e){return this.view.lanes.get(e).size}laneRange(e,t,n){return this.view.lanes.get(e).range(t,n)}get groupedHeight(){return this.view.index.total}groupedRows(e,t){return this.view.rows(e,t)}isCollapsed(e){return!this.filtered&&this.collapsed.has(e)}toggleGroup(e){if(!this.filtered){this.collapsed.has(e)?this.collapsed.delete(e):this.collapsed.add(e),this.all.refresh(e);for(let t of this.byHost.values())t.refresh(e);this.persist([...this.collapsed]),this.version.value++}}setHost(e){e!==this.host&&(this.host=e,this.predicate&&this.rebuildFiltered(),this.version.value++)}setFilter(e){this.predicate=e,e?this.rebuildFiltered():this.filtered=null,this.version.value++}applyCollection(e){if(e.type===`snapshot`){this.byKey.clear(),this.all.clear();for(let e of this.byHost.values())e.clear();this.filtered?.clear(),this.buckets.clear();for(let t of e.items)this.put(t)}else{if(e.generation!==this.generation)return;for(let t of e.changes){let e=this.byKey.get(t.key);e&&(this.all.remove(e),this.byHost.get(e.hostId)?.remove(e),this.filtered?.remove(e),this.unbucket(e)),t.value?this.put(t.value):this.byKey.delete(t.key)}}this.generation=e.generation,this.seq=e.seq,this.version.value++}apply(e){e.type===`snapshot`?this.applyCollection({type:`snapshot`,generation:e.generation,seq:e.seq,items:e.agents}):e.type===`changes`&&this.applyCollection({type:`changes`,generation:e.generation,seq:e.seq,changes:e.changes})}matches(e){return(this.host===null||e.hostId===this.host)&&this.predicate(e)}rebuildFiltered(){let e=new de(this.compare,()=>!1,this.pinRank),t=this.base;for(let n of t.flat.range(0,t.size))this.predicate(n)&&e.add(n);this.filtered=e}bucketOf(e){return this.indexOf?this.indexOf(e):null}unbucket(e){let t=this.bucketOf(e);if(!t)return;let n=this.buckets.get(t);n&&(n.remove(e),n.size||this.buckets.delete(t))}put(e){this.byKey.set(e.key,e),this.all.add(e),this.hostView(e.hostId).add(e),this.filtered&&this.matches(e)&&this.filtered.add(e);let t=this.bucketOf(e);if(t){let n=this.buckets.get(t);n||this.buckets.set(t,n=new H(ie)),n.insert(e)}}},pe=[`width`,`height`],me=[`d`],J=f({__name:`Icon`,props:{name:{},size:{}},setup(e){let t={chat:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,board:`M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zM9 3v18M15 3v12`,server:`M4 3h16a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM4 13h16a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1zM7 7h.01M7 17h.01`,search:`M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM21 21l-4.35-4.35`,back:`M15 18l-6-6 6-6`,send:`M12 19V5M5 12l7-7 7 7`,stop:`M7.5 5h9A2.5 2.5 0 0 1 19 7.5v9a2.5 2.5 0 0 1-2.5 2.5h-9A2.5 2.5 0 0 1 5 16.5v-9A2.5 2.5 0 0 1 7.5 5z`,plus:`M12 5v14M5 12h14`,close:`M18 6 6 18M6 6l12 12`,check:`M20 6 9 17l-5-5`,mic:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3zM19 10v2a7 7 0 0 1-14 0v-2M12 19v3`,eye:`M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,bulb:`M9 18h6M10 21.5h4M12 2.5a6.5 6.5 0 0 0-3.9 11.7c.6.5.9 1.2.9 2V16h6v-.3c0-.8.3-1.5.9-2A6.5 6.5 0 0 0 12 2.5z`,npm:`M2 8.5h20v7H12v2H8v-2H2zM5.5 11v4.5M8.5 11h1.5v6M12.5 11h7v4.5M16 11v4.5`,js:`M12 2.5l8.5 4.75v9.5L12 21.5l-8.5-4.75v-9.5zM10.5 9v4.75a1.6 1.6 0 0 1-3 .75M16.6 9.6c-.5-.6-2.6-.9-2.6.6 0 1.6 2.8 1.1 2.8 2.7 0 1.5-2.2 1.4-3 .5`,clock:`M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3 2`,hourglass:`M5 22h14M5 2h14M17 22v-4.2a2 2 0 0 0-.6-1.4L12 12l-4.4 4.4a2 2 0 0 0-.6 1.4V22M7 2v4.2a2 2 0 0 0 .6 1.4L12 12l4.4-4.4a2 2 0 0 0 .6-1.4V2`,undo:`M9 14 4 9l5-5M4 9h10.5a5.5 5.5 0 0 1 0 11H11`,layers:`M12 2 2 7l10 5 10-5zM2 17l10 5 10-5M2 12l10 5 10-5`,sliders:`M4 7h9M17 7h3M4 17h3M11 17h9M15 5v4M9 15v4`,panel:`M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zM15 3v18`,play:`M7 4.5v15l12-7.5z`,pause:`M8 5v14M16 5v14`,copy:`M9 9h11a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V10a1 1 0 0 1 1-1zM5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1`,terminal:`M4 17l6-6-6-6M12 19h8`,file:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6`,edit:`M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z`,globe:`M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`,bot:`M12 8V4H8M4 8h16a0 0 0 0 1 0 0v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8zM2 14h2M20 14h2M9 13v2M15 13v2`,tool:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,brain:`M9 3a3 3 0 0 0-3 3 3 3 0 0 0-2 5 3 3 0 0 0 2 5 3 3 0 0 0 3 3 3 3 0 0 0 3-3V6a3 3 0 0 0-3-3zM15 3a3 3 0 0 1 3 3 3 3 0 0 1 2 5 3 3 0 0 1-2 5 3 3 0 0 1-3 3 3 3 0 0 1-3-3`,alert:`M12 9v4M12 17h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z`,"shield-off":`M2 2l20 20M9.5 3 12 2l8 3v7c0 1.2-.3 2.4-.8 3.5M4 5v7c0 6 8 10 8 10s2.5-1.2 4.7-3.4`,shield:`M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z`,trash:`M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6`,chevron:`M9 18l6-6-6-6`,folder:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.7-.9l-.8-1.2A2 2 0 0 0 7.9 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z`,list:`M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01`,sun:`M12 16a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41`,moon:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9z`,monitor:`M4 4h16a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2zM8 21h8M12 17v4`,bell:`M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10.3 21a1.94 1.94 0 0 0 3.4 0`,phone:`M7 2h10a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zM11 18h2`,gear:`M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z`,bolt:`M13 2 3 14h9l-1 8 10-12h-9l1-8z`,refresh:`M21 12a9 9 0 1 1-3-6.7L21 8M21 3v5h-5`,pin:`M12 17v5M9 10.76V6a3 3 0 0 1 6 0v4.76a2 2 0 0 0 1.11 1.79l1.78.9A2 2 0 0 1 19 15.24V16a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-.76a2 2 0 0 1 1.11-1.79l1.78-.9A2 2 0 0 0 9 10.76z`,more:`M12 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2zM19 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2zM5 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2z`,"more-v":`M12 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2zM12 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2zM12 20a1 1 0 1 0 0-2 1 1 0 0 0 0 2z`,archive:`M21 8v13H3V8M1 3h22v5H1zM10 12h4`,dot:`M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,branch:`M6 3v12M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM18 9a9 9 0 0 1-9 9`,sparkle:`M12 3l1.9 5.8L20 11l-6.1 2.2L12 19l-1.9-5.8L4 11l6.1-2.2z`};return(n,r)=>(i(),R(`svg`,{class:`icon`,width:e.size??16,height:e.size??16,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.75`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},[x(`path`,{d:t[e.name]??t.tool},null,8,me)],8,pe))}}),he=[`aria-label`],ge={class:`menu-title`},_e=f({__name:`ThreadMenu`,props:{thread:{},x:{},y:{}},emits:[`close`,`rename`,`pin`,`unread`,`read`,`archive`],setup(n,{emit:r}){let a=n,o=r,s=e(null),u=e({left:a.x,top:a.y});function f(e){e(),o(`close`)}function p(e){e.key===`Escape`&&o(`close`)}function m(e){s.value&&!s.value.contains(e.target)&&o(`close`)}return c(()=>{C(()=>{let e=s.value;if(!e)return;let{width:t,height:n}=e.getBoundingClientRect();u.value={left:Math.max(8,Math.min(a.x,innerWidth-t-8)),top:Math.max(8,Math.min(a.y,innerHeight-n-8))},e.querySelector(`button`)?.focus()}),window.addEventListener(`keydown`,p),setTimeout(()=>window.addEventListener(`pointerdown`,m),0)}),l(()=>{window.removeEventListener(`keydown`,p),window.removeEventListener(`pointerdown`,m)}),(e,r)=>(i(),R(`div`,{ref_key:`element`,ref:s,class:`menu`,role:`menu`,"aria-label":`Actions for `+n.thread.name,style:g({left:u.value.left+`px`,top:u.value.top+`px`})},[x(`div`,ge,k(n.thread.name),1),x(`button`,{role:`menuitem`,onClick:r[0]||=e=>f(()=>o(`rename`,n.thread))},[t(J,{name:`edit`,size:14}),r[5]||=d(`Rename…`,-1)]),x(`button`,{role:`menuitem`,onClick:r[1]||=e=>f(()=>o(`pin`,n.thread,!n.thread.pinnedAt))},[t(J,{name:`pin`,size:14}),d(k(n.thread.pinnedAt?`Unpin`:`Pin to top`),1)]),n.thread.unread?(i(),R(`button`,{key:0,role:`menuitem`,onClick:r[2]||=e=>f(()=>o(`read`,n.thread))},[t(J,{name:`check`,size:14}),r[6]||=d(`Mark as read `,-1)])):(i(),R(`button`,{key:1,role:`menuitem`,onClick:r[3]||=e=>f(()=>o(`unread`,n.thread))},[t(J,{name:`dot`,size:14}),r[7]||=d(`Mark as unread `,-1)])),r[9]||=x(`div`,{class:`menu-sep`},null,-1),x(`button`,{role:`menuitem`,class:`menu-danger`,onClick:r[4]||=e=>f(()=>o(`archive`,n.thread))},[t(J,{name:`archive`,size:14}),r[8]||=d(`Archive… `,-1)])],12,he))}}),ve={class:`sheet-head`},ye={class:`sheet-body`},be={class:`field`},xe=[`placeholder`],Se={class:`row-sub`},Y={class:`sheet-foot`},Ce=[`disabled`],we=[`disabled`],Te=[`disabled`],Ee=f({__name:`RenameThread`,props:{thread:{},busy:{type:Boolean}},emits:[`close`,`save`],setup(n,{emit:r}){let o=n,s=r,l=e(o.thread.title??o.thread.name),u=e(null);c(()=>C(()=>{u.value?.focus(),u.value?.select()}));function d(){let e=l.value.trim();s(`save`,e||null)}return(e,r)=>(i(),R(`div`,{class:`overlay`,onMousedown:r[4]||=v(e=>!n.busy&&s(`close`),[`self`]),onKeydown:r[5]||=P(e=>s(`close`),[`esc`])},[x(`form`,{class:`sheet sheet-small`,role:`dialog`,"aria-modal":`true`,"aria-label":`Rename thread`,onSubmit:v(d,[`prevent`])},[x(`header`,ve,[r[6]||=x(`h2`,null,`Rename thread`,-1),x(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close`,onClick:r[0]||=e=>s(`close`)},[t(J,{name:`close`,size:16})])]),x(`div`,ye,[x(`label`,be,[r[7]||=x(`span`,null,`Name`,-1),a(x(`input`,{ref_key:`input`,ref:u,"onUpdate:modelValue":r[1]||=e=>l.value=e,maxlength:`200`,placeholder:n.thread.name},null,8,xe),[[_,l.value]])]),x(`p`,Se,k(n.thread.project)+k(n.thread.branch?` · `+n.thread.branch:``),1)]),x(`footer`,Y,[n.thread.title?(i(),R(`button`,{key:0,type:`button`,class:`btn btn-ghost sheet-reset`,disabled:n.busy,onClick:r[2]||=e=>s(`save`,null)},` Reset to default `,8,Ce)):F(``,!0),x(`button`,{type:`button`,class:`btn btn-ghost`,disabled:n.busy,onClick:r[3]||=e=>s(`close`)},`Cancel`,8,we),x(`button`,{class:`btn btn-primary`,disabled:n.busy||!l.value.trim()},`Save`,8,Te)])],32)],32))}}),De=[`aria-label`],Oe={class:`menu-title`},ke=f({__name:`ProjectMenu`,props:{name:{},pinned:{type:Boolean},host:{},x:{},y:{}},emits:[`close`,`settings`,`remove`,`pin`],setup(n,{emit:r}){let a=n,o=r,s=e(null),u=e({left:a.x,top:a.y});function f(e){o(e===`settings`?`settings`:e===`pin`?`pin`:`remove`),o(`close`)}function p(e){e.key===`Escape`&&o(`close`)}function m(e){s.value&&!s.value.contains(e.target)&&o(`close`)}return c(()=>{C(()=>{let e=s.value;if(!e)return;let{width:t,height:n}=e.getBoundingClientRect();u.value={left:Math.max(8,Math.min(a.x,innerWidth-t-8)),top:Math.max(8,Math.min(a.y,innerHeight-n-8))},e.querySelector(`button`)?.focus()}),window.addEventListener(`keydown`,p),setTimeout(()=>window.addEventListener(`pointerdown`,m),0)}),l(()=>{window.removeEventListener(`keydown`,p),window.removeEventListener(`pointerdown`,m)}),(e,r)=>(i(),R(`div`,{ref_key:`element`,ref:s,class:`menu`,role:`menu`,"aria-label":`Actions for project `+n.name,style:g({left:u.value.left+`px`,top:u.value.top+`px`})},[x(`div`,Oe,k(n.name)+` · `+k(n.host),1),x(`button`,{role:`menuitem`,onClick:r[0]||=e=>f(`pin`)},[t(J,{name:`pin`,size:14}),d(k(n.pinned?`Unpin project`:`Pin project`),1)]),x(`button`,{role:`menuitem`,onClick:r[1]||=e=>f(`settings`)},[t(J,{name:`sliders`,size:14}),r[3]||=d(`Project settings…`,-1)]),r[5]||=x(`div`,{class:`menu-sep`},null,-1),x(`button`,{role:`menuitem`,class:`menu-danger`,onClick:r[2]||=e=>f(`remove`)},[t(J,{name:`trash`,size:14}),r[4]||=d(`Remove project…`,-1)])],12,De))}}),Ae=[`src`],X=e(new Set),je=[`#4f7cc2`,`#5a9e6f`,`#c27a4f`,`#9a6fc2`,`#c25a7a`,`#4fa7b0`,`#b09a3f`],Me=e=>{let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return je[t%je.length]},Ne=e=>(Array.from(e.trim())[0]??`?`).toUpperCase();function Pe(e){if(!e.rootPath)return null;let t=`/api/hosts/${encodeURIComponent(e.hostId)}/project-icon?cwd=${encodeURIComponent(e.rootPath)}`;return e.projectId&&(t+=`&project=${encodeURIComponent(e.projectId)}&v=${encodeURIComponent(e.projectIconRevision??``)}`),t}var Fe=f({__name:`ProjectIcon`,props:{name:{},source:{},src:{},size:{}},setup(e){let t=e,n=S(()=>{if(t.src!==void 0)return t.src;let e=t.source?Pe(t.source):null;return e&&!X.value.has(e)?e:null});function r(){let e=n.value;e&&t.src===void 0&&!X.value.has(e)&&(X.value=new Set(X.value).add(e))}return(t,a)=>(i(),R(`span`,{class:`group-icon`,style:g({...n.value?{}:{background:Me(e.name)},...e.size?{width:e.size+`px`,height:e.size+`px`,fontSize:Math.round(e.size*.55)+`px`,borderRadius:Math.round(e.size*.28)+`px`}:{}})},[n.value?(i(),R(`img`,{key:0,src:n.value,alt:``,loading:`lazy`,onError:r},null,40,Ae)):(i(),R(b,{key:1},[d(k(Ne(e.name)),1)],64))],4))}}),Ie=[`onKeydown`],Le={class:`sheet-head`},Re={class:`sheet-body`},ze={class:`field`},Be=[`value`,`placeholder`,`disabled`],Ve={key:0,class:`ps-field-error`,role:`alert`},He={key:1,class:`field`},Ue={class:`pe-icon-row`},We=[`disabled`],Ge=[`disabled`],Ke=[`value`,`disabled`],qe={key:0,class:`pe-hint`},Z={key:1,class:`ps-field-error pe-icon-error`,role:`alert`},Je={class:`sheet-foot`},Ye=[`disabled`],Xe=[`disabled`],Ze=524288,Qe=f({__name:`ProjectEdit`,props:{hostId:{},rootPath:{},project:{},customIcons:{type:Boolean},request:{type:Function}},emits:[`close`,`saved`],setup(n,{emit:r}){let a=n,o=r,s=e(a.project.customName??``),l=e(``),u=e(null),d=e(`unchanged`),f=e(null),p=e(!1),m=e(null),h=e(null),g=S(()=>!!a.project.iconRevision),_=S(()=>{let e=s.value.trim()||null;return e===a.project.customName?null:{customName:e}}),y=S(()=>d.value===`automatic`?g.value?{type:`automatic`}:null:d.value===`upload`&&u.value?{type:`upload`,data:u.value.data}:d.value===`url`&&l.value.trim()?{type:`url`,url:l.value.trim()}:null),b=S(()=>y.value?y.value.type!==`automatic`:g.value),w=S(()=>!p.value&&!!(_.value||y.value)),T=S(()=>d.value===`automatic`?null:d.value===`upload`&&u.value?`data:${u.value.mimeType};base64,${u.value.data}`:void 0);function E(e){s.value=e,f.value=null}function D(e){l.value=e,d.value=e.trim()?`url`:u.value?`upload`:`unchanged`,f.value=null}function O(){h.value?.click()}async function A(e){let t=e.target,n=t.files?.[0];if(t.value=``,!n)return;if(n.size>Ze){f.value={scope:`icon`,message:`Icon must be 512 KB or smaller`};return}let r=new Uint8Array(await n.arrayBuffer()),i=``;for(let e=0;e<r.length;e+=32768)i+=String.fromCharCode(...r.subarray(e,e+32768));u.value={fileName:n.name,mimeType:n.type||`image/png`,data:btoa(i)},d.value=`upload`,f.value=null}function j(){u.value=null,l.value=``,d.value=g.value?`automatic`:`unchanged`,f.value=null}async function M(){if(w.value){p.value=!0,f.value=null;try{await a.request(`/hosts/${encodeURIComponent(a.hostId)}/projects/${encodeURIComponent(a.project.projectId)}/edit`,`POST`,{rename:_.value,icon:y.value},4e4),o(`saved`),o(`close`)}catch(e){let t=e;f.value={scope:t.scope===`icon`?`icon`:`name`,message:t.message}}finally{p.value=!1}}}function N(){p.value||o(`close`)}return c(()=>C(()=>m.value?.focus())),(e,r)=>(i(),R(`div`,{class:`overlay ps-script-overlay`,onMousedown:v(N,[`self`]),onKeydown:P(v(N,[`stop`]),[`esc`])},[x(`form`,{class:`sheet sheet-small`,role:`dialog`,"aria-modal":`true`,"aria-label":`Edit project`,onSubmit:v(M,[`prevent`])},[x(`header`,Le,[r[2]||=x(`h2`,null,`Edit project`,-1),x(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close`,onClick:N},[t(J,{name:`close`,size:16})])]),x(`div`,Re,[x(`label`,ze,[r[3]||=x(`span`,null,`Name`,-1),x(`input`,{ref_key:`nameInput`,ref:m,value:s.value,placeholder:n.project.name,disabled:p.value,maxlength:`200`,autocapitalize:`off`,autocomplete:`off`,spellcheck:`false`,"aria-label":`Project name`,onInput:r[0]||=e=>E(e.target.value)},null,40,Be)]),f.value?.scope===`name`?(i(),R(`p`,Ve,k(f.value.message),1)):F(``,!0),n.customIcons?(i(),R(`div`,He,[r[4]||=x(`span`,null,`Icon`,-1),x(`div`,Ue,[t(Fe,{name:n.project.name,size:40,src:T.value,source:{hostId:n.hostId,rootPath:n.rootPath,projectId:n.project.projectId,projectIconRevision:n.project.iconRevision}},null,8,[`name`,`src`,`source`]),x(`button`,{type:`button`,class:`btn btn-outline`,disabled:p.value,onClick:O},`Choose image`,8,We),b.value?(i(),R(`button`,{key:0,type:`button`,class:`btn btn-ghost`,disabled:p.value,onClick:j},`Use automatic`,8,Ge)):F(``,!0),x(`input`,{ref_key:`fileInput`,ref:h,class:`pe-file`,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp,image/x-icon,.ico`,tabindex:`-1`,"aria-hidden":`true`,onChange:A},null,544)]),x(`input`,{class:`pe-url`,value:l.value,type:`url`,inputmode:`url`,placeholder:`Image or website URL`,"aria-label":`Image or website URL`,disabled:p.value,autocapitalize:`off`,autocomplete:`off`,spellcheck:`false`,onInput:r[1]||=e=>D(e.target.value)},null,40,Ke),d.value===`upload`&&u.value?(i(),R(`p`,qe,k(u.value.fileName),1)):F(``,!0),f.value?.scope===`icon`?(i(),R(`p`,Z,k(f.value.message),1)):F(``,!0)])):F(``,!0)]),x(`footer`,Je,[x(`button`,{type:`button`,class:`btn btn-ghost`,disabled:p.value,onClick:N},`Cancel`,8,Ye),x(`button`,{class:`btn btn-primary`,disabled:!w.value},k(p.value?`Saving…`:`Save changes`),9,Xe)])],32)],40,Ie))}}),$e=[`branchName`,`commitMessage`,`pullRequest`],et=`service`,tt=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function nt(e){return typeof e==`string`?{text:e,kind:`string`}:Array.isArray(e)?{text:e.filter(e=>typeof e==`string`).join(`
3
+ `),kind:`array`}:{text:``,kind:`missing`}}function rt(e,t){let n=e.split(`
4
+ `).filter(e=>e.trim());if(n.length)return t===`string`?n.join(`
5
+ `):t===`array`?n:n.length===1?n[0]:n}function it(e){return typeof e==`number`&&Number.isFinite(e)?String(e):typeof e==`string`?e:``}function at(e){let t=e.trim();if(t)return/^[0-9]+$/.test(t)?Number(t):t}var ot=0,st=()=>`script-${++ot}`;function ct(e){let t=tt(e?.worktree)?e.worktree:{},n=nt(t.setup),r=nt(t.teardown),i=Object.entries(tt(e?.scripts)?e.scripts:{}).map(([e,t])=>{let n=tt(t)?t:{},r=nt(n.command);return{id:st(),name:e,commandText:r.text,commandKind:r.kind,type:typeof n.type==`string`?n.type:``,portText:it(n.port),raw:n}}),a=tt(e?.metadataGeneration)?e.metadataGeneration:void 0,o={branchName:``,commitMessage:``,pullRequest:``};for(let e of $e){let t=a?.[e];tt(t)&&typeof t.instructions==`string`&&(o[e]=t.instructions)}return{setupText:n.text,setupKind:n.kind,teardownText:r.text,teardownKind:r.kind,scripts:i,prompts:o,metadataBase:a}}var lt=(e,t,n)=>{n===void 0?delete e[t]:e[t]=n};function ut(e,t){let n={...t??{}},r={...tt(n.worktree)?n.worktree:{}};lt(r,`setup`,rt(e.setupText,e.setupKind)),lt(r,`teardown`,rt(e.teardownText,e.teardownKind));let i={};for(let t of e.scripts){let e=t.name.trim();if(!e)continue;let n={...t.raw};lt(n,`command`,rt(t.commandText,t.commandKind)),lt(n,`type`,t.type.trim()||void 0),lt(n,`port`,at(t.portText)),i[e]=n}let a={...e.metadataBase??{}};for(let t of $e){let n=e.prompts[t],r={...tt(e.metadataBase?.[t])?e.metadataBase[t]:{}};n.trim()?r.instructions=n:delete r.instructions,lt(a,t,Object.keys(r).length?r:void 0)}return lt(n,`worktree`,Object.keys(r).length?r:void 0),lt(n,`scripts`,Object.keys(i).length?i:void 0),lt(n,`metadataGeneration`,Object.keys(a).length?a:void 0),n}function dt(e){return{name:e.name.trim()?``:`Name is required`,command:e.commandText.trim()?``:`Command is required`}}var ft=e=>{let t=dt(e);return!t.name&&!t.command};function pt(e){return[e.type,e.portText&&`port ${e.portText}`,e.commandText.split(`
6
+ `)[0]].filter(Boolean).join(` · `)}var mt={class:`sheet-head`},ht={class:`ps-title`},gt={class:`ps-title-row`},_t={class:`path-hint`},vt={key:0,class:`sheet-note`},yt={key:1,class:`ps-callout is-error`,role:`alert`},bt={class:`ps-group`,"aria-labelledby":`ps-worktree`},xt={class:`ps-section`},St={key:0,class:`ps-callout is-warn`},Ct={class:`ps-section`},wt={class:`ps-group`,"aria-labelledby":`ps-scripts`},Tt={class:`ps-group-head`},Et={class:`card ps-scripts`},Dt={key:0,class:`card-row row-sub`},Ot=[`onClick`],kt={class:`row-title`},At={class:`row-sub`},jt={class:`ps-script-more`},Mt=[`aria-label`,`onClick`],Nt=[`onClick`],Pt=[`onClick`],Q={class:`ps-group`,"aria-labelledby":`ps-metadata`},Ft={class:`ps-section-head`},It=[`for`],Lt=[`id`,`onUpdate:modelValue`,`placeholder`],Rt={key:0,class:`ps-callout is-error`,role:`alert`},zt={key:1,class:`ps-callout is-error`,role:`alert`},Bt={class:`sheet-foot`},Vt={key:0,class:`sheet-note sheet-reset ps-saved`},Ht={key:1,class:`sheet-note sheet-reset ps-saved`},Ut=[`disabled`],Wt=[`disabled`],Gt=[`onKeydown`],Kt=[`aria-label`],qt={class:`sheet-head`},Jt={class:`sheet-body`},Yt={class:`field`},Xt={key:0,class:`ps-field-error`},Zt={class:`field`},Qt={key:1,class:`ps-field-error`},$t={class:`switch-row ps-service`},en=[`checked`],tn=`https://paseo.sh/docs/worktrees`,nn=f({__name:`ProjectSettings`,props:{hostId:{},hostLabel:{},project:{},rootPath:{},customIcons:{type:Boolean},request:{type:Function}},emits:[`close`],setup(r,{emit:o}){let s=r,l=o,f={branchName:{title:`Branch names`,placeholder:`Prefix branches with feat/ or fix/, mb/ for personal branches`},commitMessage:{title:`Commit messages`,placeholder:`Use Conventional Commits with a scope`},pullRequest:{title:`Pull requests`,placeholder:`Lead with a one-paragraph summary, include a Test plan section`}},p=e(!0),h=e(!1),g=e(``),y=e(null),w=e(!1),T=e(!1),E=e(!1),O=e(null),A=e(ct(null)),j=e(``),N=S(()=>`/hosts/${encodeURIComponent(s.hostId)}/project-config`),I=e=>e.replace(/^\/(home|Users)\/[^/]+(?=\/|$)/,`~`),L=S(()=>JSON.stringify(ut(A.value,O.value?.config))),B=S(()=>!!O.value&&L.value!==j.value),V=S(()=>A.value.scripts.some(e=>!ft(e))),H=S(()=>y.value?.code===`stale_project_config`);n(L,()=>w.value=E.value=!1);function U(e){O.value=e,A.value=ct(e.config),j.value=JSON.stringify(ut(A.value,e.config))}async function W(){p.value=!0,g.value=``,y.value=null;try{U(await s.request(`${N.value}?root=${encodeURIComponent(s.rootPath)}`))}catch(e){g.value=String(e.message)}finally{p.value=!1}}async function ee(){if(!(!O.value||h.value||H.value||V.value)){h.value=!0,y.value=null;try{U(await s.request(N.value,`PUT`,{root:O.value.rootPath,config:ut(A.value,O.value.config),revision:O.value.revision})),w.value=!0}catch(e){let t=e;y.value={code:t.code??``,message:t.message}}finally{h.value=!1}}}function te(){if(!h.value){if(T.value)return void(T.value=!1);if(G.value)return se();(!B.value||confirm(`Discard your unsaved project settings?`))&&l(`close`)}}let G=e(null),K=u({name:!1,command:!1}),ne=e(null),q=e(null),re=S(()=>{let e=G.value;if(!e)return{name:``,command:``};let t=dt(e),n=e.name.trim();return!t.name&&A.value.scripts.some(t=>t.id!==e.id&&t.name.trim()===n)&&(t.name=`Another script already has this name`),t}),ie=null;function ae(e){ne.value=null,G.value=e,ie={name:e.name,commandText:e.commandText,type:e.type},K.name=K.command=!1,C(()=>q.value?.focus())}function oe(){let e={id:st(),name:``,commandText:``,commandKind:`missing`,type:``,portText:``,raw:{}};A.value.scripts.push(e),ae(A.value.scripts[A.value.scripts.length-1])}function se(){let e=G.value;e&&ie&&Object.assign(e,ie),!e||e.name.trim()||e.commandText.trim()||e.type.trim()||e.portText.trim()||(A.value.scripts=A.value.scripts.filter(t=>t.id!==e.id)),G.value=null}function ce(){re.value.name||re.value.command?K.name=K.command=!0:G.value=null}function le(e){ne.value=null,confirm(`Remove ${e.name||`this script`}?`)&&(A.value.scripts=A.value.scripts.filter(t=>t.id!==e.id))}function ue(e){G.value&&(G.value.type=e.target.checked?et:``)}function de(e){(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),!G.value&&!T.value&&ee())}return c(W),(e,n)=>(i(),R(`div`,{class:`overlay`,onMousedown:v(te,[`self`]),onKeydown:[P(te,[`esc`]),de]},[x(`form`,{class:`sheet project-settings`,role:`dialog`,"aria-modal":`true`,"aria-label":`Project settings`,onSubmit:v(ee,[`prevent`])},[x(`header`,mt,[x(`div`,ht,[x(`div`,gt,[t(Fe,{name:r.project.name,size:28,source:{hostId:r.hostId,rootPath:r.rootPath,projectId:r.project.projectId,projectIconRevision:r.project.iconRevision}},null,8,[`name`,`source`]),x(`h2`,null,k(r.project.name),1),r.project.projectId?(i(),R(`button`,{key:0,type:`button`,class:`icon-btn ps-edit`,"aria-label":`Edit project`,title:`Edit project`,onClick:n[0]||=e=>T.value=!0},[t(J,{name:`edit`,size:14})])):F(``,!0)]),x(`p`,_t,[t(J,{name:`server`,size:12}),d(k(r.hostLabel)+` · `+k(I(r.rootPath)),1)])]),x(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close`,onClick:te},[t(J,{name:`close`,size:16})])]),x(`div`,{class:`sheet-body ps-body`,onClick:n[4]||=e=>ne.value=null},[p.value?(i(),R(`p`,vt,[...n[11]||=[x(`span`,{class:`spinner`},null,-1),d(` Reading paseo.json…`,-1)]])):g.value?(i(),R(`div`,yt,[x(`p`,null,[t(J,{name:`alert`,size:14}),d(k(g.value),1)]),x(`button`,{type:`button`,class:`btn btn-outline`,onClick:W},`Reload`)])):(i(),R(b,{key:2},[x(`section`,bt,[n[16]||=x(`h3`,{id:`ps-worktree`},`Worktree lifecycle hooks`,-1),n[17]||=x(`p`,{class:`ps-info`},`Commands that run when a worktree is created or torn down for this project`,-1),x(`div`,xt,[x(`div`,{class:`ps-section-head`},[n[12]||=x(`label`,{for:`ps-setup`},`Setup`,-1),x(`a`,{href:tn,target:`_blank`,rel:`noopener`,title:`See docs for more details and the environment variables available to these commands`},`Docs`)]),O.value?.uncommittedSetup?(i(),R(`div`,St,[x(`p`,null,[t(J,{name:`alert`,size:14}),n[13]||=x(`b`,null,`Commit paseo.json changes`,-1)]),n[14]||=x(`p`,{class:`ps-callout-sub`},`New worktrees use the setup script from the base branch you select.`,-1)])):F(``,!0),a(x(`textarea`,{id:`ps-setup`,"onUpdate:modelValue":n[1]||=e=>A.value.setupText=e,class:`ps-code`,placeholder:`npm install`,spellcheck:`false`,"aria-label":`Worktree setup commands`},null,512),[[_,A.value.setupText]])]),x(`div`,Ct,[x(`div`,{class:`ps-section-head`},[n[15]||=x(`label`,{for:`ps-teardown`},`Teardown`,-1),x(`a`,{href:tn,target:`_blank`,rel:`noopener`,title:`See docs for more details and the environment variables available to these commands`},`Docs`)]),a(x(`textarea`,{id:`ps-teardown`,"onUpdate:modelValue":n[2]||=e=>A.value.teardownText=e,class:`ps-code`,placeholder:`docker compose down`,spellcheck:`false`,"aria-label":`Worktree teardown commands`},null,512),[[_,A.value.teardownText]])])]),x(`section`,wt,[x(`div`,Tt,[n[18]||=x(`h3`,{id:`ps-scripts`},`Scripts`,-1),x(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Add script`,title:`Add script`,onClick:oe},[t(J,{name:`plus`,size:15})])]),n[21]||=x(`p`,{class:`ps-info`},`Long-running services and one-off commands you can launch from any agent in this project`,-1),x(`div`,Et,[A.value.scripts.length?F(``,!0):(i(),R(`div`,Dt,`No scripts yet.`)),(i(!0),R(b,null,z(A.value.scripts,e=>(i(),R(`div`,{key:e.id,class:M([`card-row ps-script`,{invalid:!D(ft)(e)}])},[x(`button`,{type:`button`,class:`ps-script-main`,onClick:t=>ae(e)},[x(`span`,kt,k(e.name||`Untitled script`),1),x(`span`,At,k(D(pt)(e)||`No command`),1)],8,Ot),x(`div`,jt,[x(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Open script menu for `+(e.name||`untitled script`),onClick:v(t=>ne.value=ne.value===e.id?null:e.id,[`stop`])},[t(J,{name:`more-v`,size:15})],8,Mt),ne.value===e.id?(i(),R(`div`,{key:0,class:`menu ps-menu`,role:`menu`,onClick:n[3]||=v(()=>{},[`stop`])},[x(`button`,{type:`button`,role:`menuitem`,onClick:t=>ae(e)},[t(J,{name:`edit`,size:14}),n[19]||=d(`Edit`,-1)],8,Nt),x(`button`,{type:`button`,role:`menuitem`,class:`menu-danger`,onClick:t=>le(e)},[t(J,{name:`trash`,size:14}),n[20]||=d(`Remove`,-1)],8,Pt)])):F(``,!0)])],2))),128))])]),x(`section`,Q,[n[22]||=x(`h3`,{id:`ps-metadata`},`Metadata generation`,-1),n[23]||=x(`p`,{class:`ps-info`},` Project-specific instructions injected into the AI prompts Paseo uses to generate metadata — use them to enforce your team's conventions like branch naming, commit style, or PR format `,-1),(i(!0),R(b,null,z(D($e),e=>(i(),R(`div`,{key:e,class:`ps-section`},[x(`div`,Ft,[x(`label`,{for:`ps-prompt-`+e},k(f[e].title),9,It)]),a(x(`textarea`,{id:`ps-prompt-`+e,"onUpdate:modelValue":t=>A.value.prompts[e]=t,placeholder:f[e].placeholder},null,8,Lt),[[_,A.value.prompts[e]]])]))),128))]),H.value?(i(),R(`div`,Rt,[x(`p`,null,[t(J,{name:`alert`,size:14}),n[24]||=x(`b`,null,`Config changed on disk`,-1)]),n[25]||=x(`p`,{class:`ps-callout-sub`},`Reload to fetch the latest paseo.json before saving. Your unsaved edits will be replaced.`,-1),x(`button`,{type:`button`,class:`btn btn-outline`,onClick:W},`Reload`)])):y.value?(i(),R(`div`,zt,[x(`p`,null,[t(J,{name:`alert`,size:14}),d(k(y.value.message),1)]),x(`div`,{class:`ps-callout-actions`},[x(`button`,{type:`button`,class:`btn btn-outline`,onClick:ee},`Try again`),x(`button`,{type:`button`,class:`btn btn-outline`,onClick:W},`Reload`)])])):F(``,!0)],64))]),x(`footer`,Bt,[E.value&&!w.value?(i(),R(`span`,Vt,[t(J,{name:`check`,size:14}),n[26]||=d(`Project updated`,-1)])):F(``,!0),w.value&&!B.value?(i(),R(`span`,Ht,[t(J,{name:`check`,size:14}),n[27]||=d(`Project saved`,-1)])):F(``,!0),x(`button`,{type:`button`,class:`btn btn-ghost`,disabled:h.value,onClick:te},k(B.value?`Cancel`:`Close`),9,Ut),x(`button`,{class:`btn btn-primary`,disabled:p.value||!!g.value||h.value||!B.value||H.value||V.value},k(h.value?`Saving…`:`Save`),9,Wt)])],32),T.value?(i(),m(Qe,{key:0,"host-id":r.hostId,"root-path":r.rootPath,project:r.project,"custom-icons":r.customIcons,request:r.request,onSaved:n[5]||=e=>(E.value=!0,w.value=!1),onClose:n[6]||=e=>T.value=!1},null,8,[`host-id`,`root-path`,`project`,`custom-icons`,`request`])):F(``,!0),G.value?(i(),R(`div`,{key:1,class:`overlay ps-script-overlay`,onMousedown:v(se,[`self`]),onKeydown:P(v(se,[`stop`]),[`esc`])},[x(`form`,{class:`sheet sheet-small`,role:`dialog`,"aria-modal":`true`,"aria-label":G.value.name?`Edit `+G.value.name:`New script`,onSubmit:v(ce,[`prevent`])},[x(`header`,qt,[x(`h2`,null,k(G.value.name.trim()?`Edit `+G.value.name.trim():`New script`),1),x(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close`,onClick:se},[t(J,{name:`close`,size:16})])]),x(`div`,Jt,[x(`label`,Yt,[n[28]||=x(`span`,null,`Name`,-1),a(x(`input`,{ref_key:`nameInput`,ref:q,"onUpdate:modelValue":n[7]||=e=>G.value.name=e,placeholder:`dev`,spellcheck:`false`,autocapitalize:`off`,"aria-label":`Script name`,onBlur:n[8]||=e=>K.name=!0},null,544),[[_,G.value.name]])]),K.name&&re.value.name?(i(),R(`p`,Xt,k(re.value.name),1)):F(``,!0),x(`label`,Zt,[n[29]||=x(`span`,null,`Command`,-1),a(x(`textarea`,{"onUpdate:modelValue":n[9]||=e=>G.value.commandText=e,class:`ps-code`,placeholder:`npm run dev`,spellcheck:`false`,"aria-label":`Script command`,onBlur:n[10]||=e=>K.command=!0},null,544),[[_,G.value.commandText]])]),K.command&&re.value.command?(i(),R(`p`,Qt,k(re.value.command),1)):F(``,!0),x(`label`,$t,[n[30]||=x(`div`,{class:`grow`},[x(`div`,{class:`row-title`},`Run as a service`),x(`div`,{class:`row-sub`},`Paseo supervises the process and assigns a port via $PASEO_PORT`)],-1),x(`input`,{class:`switch`,type:`checkbox`,checked:G.value.type===D(et),"aria-label":`Run as a service`,onChange:ue},null,40,en)])]),x(`footer`,{class:`sheet-foot`},[x(`button`,{type:`button`,class:`btn btn-ghost`,onClick:se},`Cancel`),n[31]||=x(`button`,{class:`btn btn-primary`},`Save`,-1)])],40,Kt)],40,Gt)):F(``,!0)],32))}}),rn=`litepaseo-composer-v1:`,an=rn+`draft:`,on=rn+`message:`,sn=class{warning=e(``);revision=e(0);generation=0;drafts=u(new Map);pending=u(new Map);owner=crypto.randomUUID();storage;savedIndex=new Map;messageIndex=new Map;slotKey=new Map;constructor(e,t=Date.now()){try{this.storage=e()}catch{this.storage=null,this.unavailable()}this.rescan(t)}unavailable(){this.warning.value=`Draft storage is unavailable. Keep this tab open to retain your text.`}attempt(e,t){if(!this.storage)return t;try{return e(this.storage)}catch{return this.unavailable(),t}}decode(e){try{return JSON.parse(e)}catch{return null}}slot(e){return`${an}${this.owner}:${encodeURIComponent(e)}`}rescan(e=Date.now()){this.savedIndex.clear(),this.messageIndex.clear(),this.slotKey.clear();let t=this.attempt(e=>{let t=[];for(let n=0;n<e.length;n++){let r=e.key(n);r?.startsWith(rn)&&t.push([r,e.getItem(r)])}return t},[]),n=[];for(let[r,i]of t){let t=r.startsWith(an)?this.decode(i):null;t&&Number.isFinite(t.updated)&&e-t.updated>2592e6?n.push(r):this.apply(r,i)}for(let[e]of this.savedIndex)n.push(...this.excess(e));for(let e of n)this.remove(e);this.revision.value++}excess(e){let t=this.savedIndex.get(e);return!t||t.size<=8?[]:[...t].sort((e,t)=>t[1].updated-e[1].updated).slice(8).map(([e])=>e).filter(t=>t!==this.slot(e))}apply(e,t){let n=this.slotKey.get(e);if(n!==void 0){this.slotKey.delete(e);let t=this.savedIndex.get(n);t?.delete(e),t&&!t.size&&this.savedIndex.delete(n);let r=this.messageIndex.get(n);r?.delete(e),r&&!r.size&&this.messageIndex.delete(n)}if(t===null)return;let r=this.decode(t);if(typeof r?.key==`string`&&typeof r.text==`string`){if(e.startsWith(an)){if(!r.text||!Number.isFinite(r.updated))return;let n=this.savedIndex.get(r.key);n||this.savedIndex.set(r.key,n=new Map),n.set(e,{key:r.key,text:r.text,updated:r.updated,restoredFrom:r.restoredFrom,raw:t})}else if(e.startsWith(on)){if(typeof r.messageId!=`string`)return;let t=this.messageIndex.get(r.key);t||this.messageIndex.set(r.key,t=new Map),t.set(e,r)}else return;this.slotKey.set(e,r.key)}}write(e,t){this.storage.setItem(e,t),this.apply(e,t)}remove(e){this.attempt(t=>(t.removeItem(e),!0),!1),this.apply(e,null)}onStorage(e,t){if(e===null)return this.rescan();e.startsWith(rn)&&(this.apply(e,t),this.revision.value++)}saved(e){this.revision.value;let t=this.savedIndex.get(e);return t?[...t].map(([e,{raw:t,...n}])=>({...n,slot:e})).sort((e,t)=>t.updated-e.updated):[]}state(e){let t=this.drafts.get(e);if(!t){let n=this.saved(e)[0];this.drafts.set(e,{text:n?.text??``,restoredFrom:n?.restoredFrom,source:n?.slot,sourceValue:n?this.savedIndex.get(e)?.get(n.slot)?.raw:void 0}),t=this.drafts.get(e)}return t}setText(e,t,n){let r=this.state(e);r.text=t,r.restoredFrom=n,this.attempt(i=>(t&&this.write(this.slot(e),JSON.stringify({key:e,text:t,restoredFrom:n,updated:Date.now()})),r.source&&i.getItem(r.source)===r.sourceValue&&this.remove(r.source),r.source=r.sourceValue=void 0,t||this.remove(this.slot(e)),!0),!1),this.revision.value++}restore(e,t){let n=this.saved(e).find(e=>e.slot===t);if(!n)return;let r=this.state(e).text;r&&r!==n.text&&this.attempt(()=>{this.write(`${an}${crypto.randomUUID()}:${encodeURIComponent(e)}`,JSON.stringify({key:e,text:r,updated:Date.now()}));for(let t of this.excess(e))this.remove(t);return!0},!1),this.setText(e,n.text)}unresolved(e){this.revision.value;let t=new Map((this.pending.get(e)??[]).map(e=>[e.messageId,e]));for(let n of this.messageIndex.get(e)?.values()??[])t.set(n.messageId,n);return[...t.values()]}begin(e,t){this.attempt(()=>(this.write(on+t.messageId,JSON.stringify({key:e,...t})),!0),!1)||this.pending.set(e,[...this.unresolved(e),t]),this.revision.value++}resolve(e,t){this.pending.set(e,(this.pending.get(e)??[]).filter(e=>e.messageId!==t)),this.remove(on+t),this.revision.value++}restoreFailed(e,t){this.state(e).text||this.setText(e,t.text,t.messageId)}confirm(e,t){this.state(e).restoredFrom===t&&this.setText(e,``),this.resolve(e,t)}refresh(){this.rescan()}clear(){this.generation++;for(let e of[...this.slotKey.keys()])this.remove(e);this.attempt(e=>{let t=[];for(let n=0;n<e.length;n++){let r=e.key(n);r?.startsWith(rn)&&t.push(r)}for(let n of t)e.removeItem(n);return!0},!1),this.drafts.clear(),this.pending.clear(),this.revision.value++}},cn=3e3,ln=2500,un=class{rows=[];epoch=``;hasOlder=!1;startCursor=null;ready=!1;membership=y(0);apply(e){let t=!1;for(let n of e)if(n.type===`reset`)this.rows=n.rows.map(e=>({seqStart:e.seqStart,row:y(e)})),this.epoch=n.epoch,this.hasOlder=n.hasOlder,this.startCursor=n.startCursor,this.ready=!0,t=!0;else if(n.type===`upsert`){let e=this.find(n.row.seqStart);e>=0?this.rows[e].row.value=n.row:(this.insert({seqStart:n.row.seqStart,row:y(n.row)}),t=!0)}else if(n.type===`append`){let e=this.find(n.seqStart);if(e<0)continue;let t=this.rows[e].row,r=t.value;t.value={...r,seqEnd:n.seqEnd,timestamp:n.timestamp,item:{...r.item,text:(r.item.text??``)+n.text}}}this.rows.length>cn&&(this.rows=this.rows.slice(this.rows.length-ln),this.hasOlder=!0,this.startCursor={epoch:this.epoch,seq:this.rows[0].seqStart},t=!0),t&&this.membership.value++}find(e){let t=0,n=this.rows.length;if(n&&this.rows[n-1].seqStart===e)return n-1;for(;t<n;){let r=t+n>>>1;this.rows[r].seqStart<e?t=r+1:n=r}return this.rows[t]?.seqStart===e?t:-1}insert(e){let t=this.rows.at(-1);if(!t||t.seqStart<e.seqStart)return void this.rows.push(e);let n=0,r=this.rows.length;for(;n<r;){let t=n+r>>>1;this.rows[t].seqStart<e.seqStart?n=t+1:r=t}this.rows.splice(n,0,e)}};function dn(e,t,n){let r=n===`before`,i=r?e[0]?.seqStart:e.at(-1)?.seqStart,a=t.rows.filter(e=>i===void 0||(r?e.seqStart<i:e.seqStart>i)),o=(r?a.slice(-100):a.slice(0,100)).map(e=>({seqStart:e.seqStart,row:y(e)})),s=r?[...o,...e]:[...e,...o];return{rows:r?s.slice(0,150):s.slice(-150),hasOlder:!r||t.hasOlder||a.length>100,added:o.length}}var fn=[`onPointerenter`],pn=[`aria-label`,`aria-current`,`onClick`],mn={key:0,class:`outline-preview`,"aria-hidden":`true`},hn=150,gn=3,_n=f({__name:`ChatOutline`,props:{prompts:{},activeSeq:{}},emits:[`jump`],setup(t,{emit:n}){let r=t,a=n,o=e(null),c=e(!1),l;function u(e){o.value=e,c.value||l||(l=setTimeout(()=>{l=void 0,c.value=!0},hn))}function d(){clearTimeout(l),l=void 0,o.value=null,c.value=!1}s(d);function f(e){if(o.value===null)return 0;let t=Math.abs(e-o.value);return t>=gn?0:(1+Math.cos(Math.PI*t/gn))/2}let p=S(()=>{let e=r.activeSeq;if(e===null)return-1;let t=-1;for(let n=0;n<r.prompts.length&&r.prompts[n].seq<=e;n++)t=n;return t});function m(e){let t=e===p.value?18:10,n=f(e);return{width:`${t+n*(26-t)}px`,height:`${2+2*n}px`}}function h(e){a(`jump`,r.prompts[e].seq)}return(e,n)=>(i(),R(`nav`,{class:`outline-rail`,"aria-label":`Prompts in this conversation`,onPointerleave:d},[(i(!0),R(b,null,z(t.prompts,(e,n)=>(i(),R(`div`,{key:e.seq,class:`outline-slot`,onPointerenter:e=>u(n)},[x(`button`,{type:`button`,class:`outline-target`,"aria-label":`${n+1} of ${t.prompts.length}: ${e.preview}`,"aria-current":n===p.value?`location`:void 0,onClick:e=>h(n)},[x(`span`,{class:M([`outline-tick`,{"is-active":n===p.value,"is-pointed":c.value&&n===o.value}]),style:g(m(n))},null,6)],8,pn),c.value&&n===o.value?(i(),R(`div`,mn,k(e.preview||`(no text)`),1)):F(``,!0)],40,fn))),128))],32))}}),vn=1e3,yn=3e4;function bn(e){let t=!1,n=null,r,i=vn,a=t=>e.onState?.(t),o=async()=>{if(t||document.hidden||n)return;clearTimeout(r),r=void 0;let s=n=new AbortController;a(`connecting`);try{let n=await fetch(e.url(),{headers:{accept:`text/event-stream`},signal:s.signal});if(n.status===401){t=!0,a(`unauthorized`);return}if(!n.ok||!n.body)throw Error(`Stream unavailable`);a(`live`);let r=n.body.pipeThrough(new TextDecoderStream).getReader(),o=``;for(;;){let{value:t,done:n}=await r.read();if(n)break;o+=t;let a;for(;(a=o.indexOf(`
7
+
8
+ `))>=0;){let t=o.slice(0,a);o=o.slice(a+2);let n=``;for(let e of t.split(`
9
+ `))e.startsWith(`data: `)&&(n+=(n?`
10
+ `:``)+e.slice(6));n&&(i=vn,e.onMessage(JSON.parse(n)))}}}catch{}finally{n===s&&(n=null)}if(t)return a(`closed`);if(document.hidden)return a(`paused`);a(`connecting`),r=setTimeout(()=>void o(),i),i=Math.min(i*2,yn)},s=()=>{document.hidden?(n?.abort(),clearTimeout(r),a(`paused`)):(i=vn,o())};return document.addEventListener(`visibilitychange`,s),o(),{close(){t=!0,clearTimeout(r),document.removeEventListener(`visibilitychange`,s),n?.abort()}}}var xn=Symbol(`litepaseo-timeline`),Sn=e=>typeof e==`string`&&e.length>0?e:void 0;function Cn(e,t){if(!t||!e)return e;let n=t.replace(/\\/g,`/`).replace(/\/+$/,``),r=e.replace(/\\/g,`/`);return r.startsWith(n+`/`)?r.slice(n.length+1):r===n?`.`:e}var $=e=>{let t=e.trim();return!t||/[:./]/.test(t)||t.includes(`__`)?t||`Tool`:t.replace(/[._-]+/g,` `).split(` `).filter(Boolean).join(` `).toLowerCase().replace(/^./,e=>e.toUpperCase())};function wn(e){let t=e.split(/&&|\|\||;|\|/).map(e=>e.trim()).filter(Boolean);for(let e of t){let t=e.split(/\s+/).filter(e=>!/^[A-Z_][A-Z0-9_]*=/.test(e)),n=(t[0]??``).replace(/^.*\//,``);if(n&&n!==`cd`&&n!==`timeout`&&n!==`sudo`&&n!==`env`)return n;if(n===`timeout`||n===`sudo`||n===`env`){let e=t.slice(1).find(e=>!/^-|^\d+[smh]?$/.test(e));if(e)return e.replace(/^.*\//,``)}}return``}var Tn=[[/^(npm|npx|pnpm|yarn|bun|bunx)$/,`npm`],[/^(node|deno|tsx|ts-node|vitest|jest)$/,`js`],[/^(rg|grep|egrep|find|fd|ag|ls|tree|locate)$/,`search`],[/^git$/,`branch`],[/^(curl|wget|http)$/,`globe`],[/^(cat|head|tail|less|sed|awk|wc|jq)$/,`terminal`]],En=e=>{let t=wn(e);return Tn.find(([e])=>e.test(t))?.[1]??`terminal`};function Dn(e){return e.replace(/(?:~|\/)[^\s'"`]*\/[^\s'"`]*/g,e=>{let t=e.split(`/`);return t.length>5?[...t.slice(0,4),`…`,t[t.length-1]||t[t.length-2]+`/`].join(`/`):e})}var On=e=>{let t=typeof e==`string`?e:``;return t?t.split(`
11
+ `).length-+!!t.endsWith(`
12
+ `):0},kn=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function An(e){if(!e)return``;let t=0,n=0;for(let r of e.split(`
13
+ `))r.startsWith(`+`)&&!r.startsWith(`+++`)?t++:r.startsWith(`-`)&&!r.startsWith(`---`)&&n++;return t||n?`+${t} −${n}`:``}function jn(e,t){let n=e.detail??{},r=n.type===`unknown`&&n.input&&typeof n.input==`object`?n.input:{},i=e=>Cn(String(e??``),t),a=String(e.name??``),o=(e,t,n,r,i=!1,a=``)=>({kind:e,icon:t,name:n,summary:r,showName:i,meta:a}),s=e=>o(`shell`,En(e),`Run`,Dn(e.split(`
14
+ `)[0]));switch(n.type){case`shell`:return s(String(n.command??``));case`read`:return o(`read`,`eye`,`Read`,i(n.filePath));case`edit`:return o(`edit`,`edit`,`Edit`,i(n.filePath),!1,An(Pn(e)));case`write`:return o(`write`,`edit`,`Write`,i(n.filePath),!1,n.content?kn(On(n.content),`line`):``);case`search`:return o(`search`,n.toolName===`web_search`?`globe`:`search`,n.toolName===`web_search`?`Search web`:`Search`,String(n.query??``));case`fetch`:return o(`fetch`,`globe`,`Fetch`,String(n.url??``),!0);case`sub_agent`:return o(`sub_agent`,`bot`,Sn(n.subAgentType)??`Task`,Sn(n.description)??``,!0);case`worktree_setup`:return o(`worktree`,`branch`,`Worktree setup`,String(n.branchName??``),!0);case`plain_text`:return o(`plain`,`tool`,$(a),Sn(n.label)??``,!0);case`plan`:return o(`plan`,`list`,`Plan`,``,!0)}let c=a.toLowerCase(),l=Sn(r.path)??Sn(r.file_path)??Sn(r.filePath),u=Sn(r.command)??Sn(r.cmd)??l??Sn(r.pattern)??Sn(r.query)??Sn(r.url)??Sn(r.description)??``;return/^(bash|shell|exec|run|terminal)/.test(c)?s(u):/^(read|view|cat)/.test(c)?o(`read`,`eye`,`Read`,i(u)):/^(edit|patch|apply|multiedit|str_replace)/.test(c)?o(`edit`,`edit`,`Edit`,i(u),!1,An(Pn(e))):/^write/.test(c)?o(`write`,`edit`,`Write`,i(u),!1,r.content?kn(On(r.content),`line`):``):/(grep|glob|find|search|ls)$/.test(c)?o(`search`,`search`,`Search`,u):/fetch|browse|http/.test(c)?o(`fetch`,`globe`,`Fetch`,u,!0):c===`thinking`?o(`plain`,`bulb`,`Thinking`,``,!0):c===`task`||c===`subagent`||c===`subagents`?o(`sub_agent`,`bot`,`Task`,u,!0):o(`unknown`,`tool`,$(a),u,!0)}function Mn(e){return(e.split(`
15
+ `).map(e=>e.trim()).find(Boolean)??``).replace(/^#+\s*/,``).replace(/\*\*|__|`/g,``).slice(0,300)}function Nn(e){let t=e.detail??{};if(t.type===`shell`)return String(t.output??``);if(t.type===`read`||t.type===`write`)return String(t.content??``);if(t.type===`search`)return String(t.content??(t.filePaths??[]).join(`
16
+ `));if(t.type===`fetch`)return String(t.result??``);if(t.type===`sub_agent`)return String(t.log??``);if(t.type===`plain_text`||t.type===`plan`)return String(t.text??``);if(t.type===`worktree_setup`)return String(t.log??``);if(t.type===`unknown`){let e=t.output;if(typeof e==`string`)return e;let n=Array.isArray(e?.content)?e.content.filter(e=>e.type===`text`).map(e=>String(e.text)):[];return n.length?n.join(`
17
+ `):e==null?``:JSON.stringify(e,null,2)}return``}function Pn(e){let t=e.detail??{},n=(e,t)=>String(e??``).split(`
18
+ `).filter((e,t,n)=>t<n.length-1||n[t]!==``).map(e=>t+e),r=(e,t)=>[...n(e,`-`),...n(t,`+`)];if(t.type===`edit`)return Sn(t.unifiedDiff)?t.unifiedDiff:t.oldString===void 0&&t.newString===void 0?``:r(t.oldString,t.newString).join(`
19
+ `);let i=t.type===`unknown`&&t.input&&typeof t.input==`object`?t.input:null;if(!i)return``;let a=Array.isArray(i.edits)?i.edits:[i],o=[];for(let e of a){let t=e.oldText??e.old_string??e.oldString,n=e.newText??e.new_string??e.newString;(t!==void 0||n!==void 0)&&(o.length&&o.push(`@@`),o.push(...r(t,n)))}return o.join(`
20
+ `)}function Fn(e){if(!Number.isFinite(e)||e<0)return`0s`;let t=e/1e3;if(t<60)return`${Math.floor(t)}s`;let n=Math.floor(t/60);if(n<60){let e=Math.floor(t)%60;return e?`${n}m ${e}s`:`${n}m`}let r=Math.floor(n/60),i=n%60;return i?`${r}h ${i}m`:`${r}h`}var In=e=>e.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}),Ln=e=>Math.floor((e.getTime()-e.getTimezoneOffset()*6e4)/864e5);function Rn(e,t=new Date){let n=In(e),r=Ln(t)-Ln(e);return r===0?n:r===-1?`Tomorrow ${n}`:r<7&&r>-7?`${e.toLocaleDateString(void 0,{weekday:`long`})} ${n}`:`${e.toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`})}, ${n}`}function zn(e,t=Date.now()){if(!e)return``;let n=Math.max(0,(t-e)/1e3);return n<60?`now`:n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:n<604800?`${Math.floor(n/86400)}d`:n<3024e3?`${Math.floor(n/86400/7)}w`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Bn(e,t,n=new Date){let r=new Map,i=null,a=e=>{if(!i||!e)return;let t=Date.parse(i.last.timestamp);if(!Number.isFinite(t))return;let a=i.first.item.type===`user_message`?Date.parse(i.first.timestamp):NaN;r.set(i.last.seqStart,{at:Rn(new Date(t),n),took:Number.isFinite(a)&&t>=a?Fn(t-a):``,messages:i.messages})};for(let t of e)t.turnId&&(i&&i.id!==t.turnId&&(a(!0),i=null),i??={id:t.turnId,first:t,last:t,messages:[]},i.last=t,t.item.type===`assistant_message`&&i.messages.push(t.seqStart));return a(t),r}var Vn=/!\[([^\]\n]*)\]\(\s*<?([^)\s>]+)>?(\s+"[^"]*")?\s*\)/g,Hn=/\.(png|jpe?g|webp|gif|bmp|avif)$/i;function Un(e,t){return e.includes(`![`)?e.replace(Vn,(e,n,r,i=``)=>{if(/^(https?:|data:|blob:)/i.test(r))return e;let a=r;if(/^file:\/\//i.test(a))try{a=decodeURIComponent(new URL(a).pathname)}catch{return e}return Hn.test(a)?`![${n}](${t}/image?path=${encodeURIComponent(a)}${i})`:e}):e}var Wn=[`aria-expanded`,`onClick`,`onContextmenu`],Gn={class:`group-lead`},Kn={class:`group-name`},qn=[`title`],Jn=[`title`],Yn={key:0,class:`group-flag is-attention`},Xn={key:1,class:`status-dot is-error`},Zn={key:2,class:`status-dot is-running`},Qn={key:3,class:`status-dot is-unread`},$n={key:1,class:`group-count`},er=[`aria-label`,`title`,`onClick`],tr=[`aria-label`,`onClick`],nr=[`onClick`,`onContextmenu`,`onPointerdown`,`onMouseenter`],rr={class:`session-dot`},ir={class:`session-title`},ar=[`title`],or={key:0,class:`session-project`},sr={key:1,class:`pill pill-attention`},cr={key:2,class:`session-age`},lr=[`aria-label`,`onClick`],ur={class:`thread-card-title`},dr={key:0,class:`thread-card-off`},fr={key:0},pr={key:0,class:`list-empty`},mr=320,hr=500,gr=f({__name:`SessionList`,props:{store:{},mode:{},hostLabels:{},hostStates:{},selectedKey:{},searching:{type:Boolean},queues:{}},emits:[`select`,`new`,`menu`,`projectMenu`],setup(n,{emit:r}){let a=n,o=r,s=e(null),u=e(0),f=e(600),p=0,h,_=S(()=>(a.store.version.value,a.store.size)),y=S(()=>(a.store.version.value,a.mode===`projects`?a.store.groupedHeight:a.store.size*q)),C=S(()=>{a.store.version.value;let e=Math.max(0,u.value-mr),t=f.value+mr*2;if(a.mode===`projects`)return a.store.groupedRows(e,t);let n=Math.floor(e/q);return a.store.range(n,Math.ceil(t/q)+1).map((e,t)=>({kind:`item`,key:e.key,top:(n+t)*q,item:e}))}),w=e=>[e.attention&&`${e.attention} need you`,e.failed&&`${e.failed} failed`,e.running&&`${e.running} running`,e.unread&&`${e.unread} finished, not viewed`].filter(Boolean).join(` · `),T=e=>e.attention?`is-attention`:e.state===`failed`?`is-error`:e.state===`running`?`is-running`:e.unread||e.state===`unread`?`is-unread`:``,O=e(Date.now()),A,j=e=>{let t=[...e.hosts.keys()];return t.length===1?a.hostLabels.get(t[0])??`Unknown host`:`${t.length} hosts`},N=e=>[...e.hosts.keys()].map(e=>a.hostLabels.get(e)??`Unknown host`).join(`, `),P=e=>e.items.at(0)??null,I=matchMedia(`(hover: hover) and (pointer: fine)`).matches,L=e(null),B,V=e=>e.replace(/^\/(home|Users)\/[^/]+(?=\/|$)/,`~`);function H(e,t){if(!I)return;clearTimeout(B);let n=e.currentTarget.getBoundingClientRect();B=setTimeout(()=>{L.value={thread:t,top:Math.max(8,Math.min(n.top-4,window.innerHeight-170)),left:n.right+10}},L.value?120:550)}function U(){clearTimeout(B),B=setTimeout(()=>L.value=null,80)}let W,ee=!1;function te(e,t){if(e.pointerType===`mouse`)return;ee=!1,clearTimeout(W);let{clientX:n,clientY:r}=e;W=setTimeout(()=>{ee=!0,navigator.vibrate?.(10),o(`menu`,t,n,r)},hr)}function G(){clearTimeout(W)}function K(e){clearTimeout(B),L.value=null,ee?ee=!1:o(`select`,e.key)}function ne(e,t){let n=e.currentTarget.getBoundingClientRect();o(`menu`,t,n.left,n.bottom+4)}function re(e,t){let n=e.currentTarget.getBoundingClientRect();o(`projectMenu`,t,n.right-210,n.bottom+4)}function ie(){G(),L.value&&U(),p||=requestAnimationFrame(()=>{p=0,s.value&&(u.value=s.value.scrollTop)})}return c(()=>{let e=s.value;f.value=e.clientHeight||f.value,h=new ResizeObserver(()=>f.value=e.clientHeight||f.value),h.observe(e),A=setInterval(()=>O.value=Date.now(),6e4)}),l(()=>{h?.disconnect(),cancelAnimationFrame(p),clearTimeout(W),clearTimeout(B),clearInterval(A)}),(e,r)=>(i(),R(`div`,{ref_key:`element`,ref:s,class:`session-list`,style:g({"--row-h":D(q)+`px`}),onScrollPassive:ie},[x(`div`,{class:`session-spacer`,style:g({height:y.value+`px`})},[(i(!0),R(b,null,z(C.value,e=>(i(),R(b,{key:e.key},[e.kind===`group`?(i(),R(`div`,{key:0,class:M([`group-row`,{collapsed:e.collapsed}]),style:g({transform:`translateY(${e.top}px)`,height:D(36)-4+`px`})},[x(`button`,{class:`group-toggle`,"aria-expanded":!e.collapsed,onClick:t=>n.store.toggleGroup(e.group.key),onContextmenu:v(t=>o(`projectMenu`,e.group,t.clientX,t.clientY),[`prevent`])},[x(`span`,Gn,[t(Fe,{name:e.group.name,source:P(e.group)},null,8,[`name`,`source`]),t(J,{name:`chevron`,size:14,class:`group-chevron`})]),x(`span`,Kn,[e.group.pinnedAt?(i(),m(J,{key:0,name:`pin`,size:12,title:`Pinned project`})):F(``,!0),d(k(e.group.name),1)]),x(`span`,{class:`group-host`,title:N(e.group)},k(j(e.group)),9,qn),D(oe)(e.group)===`done`?F(``,!0):(i(),R(`span`,{key:0,class:`group-marks`,title:w(e.group)},[e.group.attention?(i(),R(`span`,Yn,k(e.group.attention),1)):F(``,!0),e.group.failed?(i(),R(`span`,Xn)):F(``,!0),e.group.running?(i(),R(`span`,Zn)):F(``,!0),e.group.unread?(i(),R(`span`,Qn)):F(``,!0)],8,Jn)),e.collapsed?(i(),R(`span`,$n,k(e.group.items.size),1)):F(``,!0)],40,Wn),x(`button`,{class:`group-add`,"aria-label":`New session in `+e.group.name+` on `+j(e.group),title:`New session in `+e.group.name+` on `+j(e.group),onClick:t=>o(`new`,e.group)},[t(J,{name:`plus`,size:14})],8,er),x(`button`,{class:`group-add group-more`,"aria-label":`Actions for project `+e.group.name,title:`Project settings, remove project`,onClick:t=>re(t,e.group)},[t(J,{name:`more-v`,size:15})],8,tr)],6)):(i(),R(`div`,{key:1,class:M([`session-row`,{chosen:n.selectedKey===e.item.key}]),style:g({transform:`translateY(${e.top}px)`})},[x(`button`,{class:M([`session`,{unread:e.item.unread,chosen:n.selectedKey===e.item.key,offline:n.hostStates.get(e.item.hostId)!==`connected`,nested:n.mode===`projects`}]),onClick:t=>K(e.item),onContextmenu:v(t=>o(`menu`,e.item,t.clientX,t.clientY),[`prevent`]),onPointerdown:t=>te(t,e.item),onPointerup:G,onPointercancel:G,onPointerleave:G,onMouseenter:t=>H(t,e.item),onMouseleave:U},[x(`span`,rr,[T(e.item)?(i(),R(`span`,{key:0,class:M([`status-dot`,T(e.item)])},null,2)):F(``,!0)]),x(`span`,ir,[e.item.pinnedAt?(i(),m(J,{key:0,name:`pin`,size:11,class:`pin-mark`})):F(``,!0),d(k(e.item.name)+` `,1),n.queues?.[e.item.key]?(i(),R(`small`,{key:1,title:n.queues[e.item.key].paused?`Queue paused`:`Queued messages`},` · `+k(n.queues[e.item.key].paused?`Paused`:`Queued`)+` `+k(n.queues[e.item.key].count),9,ar)):F(``,!0)]),n.mode===`recent`?(i(),R(`span`,or,k(e.item.project),1)):F(``,!0),e.item.attention?(i(),R(`span`,sr,`Needs you`)):(i(),R(`span`,cr,k(D(zn)(e.item.activityAt,O.value)),1))],42,nr),x(`button`,{class:`row-more`,"aria-label":`Actions for `+e.item.name,title:`Rename, pin, mark unread, archive`,onClick:v(t=>ne(t,e.item),[`stop`])},[t(J,{name:`more`,size:16})],8,lr)],6))],64))),128))],4),(i(),m(E,{to:`body`},[L.value?(i(),R(`div`,{key:0,class:`thread-card`,style:g({top:L.value.top+`px`,left:L.value.left+`px`}),role:`tooltip`},[x(`p`,ur,k(L.value.thread.name),1),x(`p`,null,[t(J,{name:`server`,size:14}),d(k(n.hostLabels.get(L.value.thread.hostId)??`Unknown host`)+` `,1),n.hostStates.get(L.value.thread.hostId)===`connected`?F(``,!0):(i(),R(`span`,dr,`offline`))]),L.value.thread.branch?(i(),R(`p`,fr,[t(J,{name:`branch`,size:14}),d(k(L.value.thread.branch),1)])):F(``,!0),x(`p`,null,[t(J,{name:`folder`,size:14}),d(k(V(L.value.thread.directory||L.value.thread.rootPath)),1)])],4)):F(``,!0)])),_.value?F(``,!0):(i(),R(`div`,pr,k(n.searching?`No threads match.`:`No threads yet. Add a host to get started.`),1))],36))}}),_r={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},vr=e=>e.replace(/[&<>"']/g,e=>_r[e]);function yr(e){let t=e.trim();return/^(https?:|mailto:)/i.test(t)?t:null}function br(e){let t=e.split(/(`+)([\s\S]*?[^`])\1(?!`)/),n=``;for(let e=0;e<t.length;e++){if(e%3==2){n+=`<code>${vr(t[e].replace(/^ (.*) $/,`$1`))}</code>`;continue}if(e%3==1)continue;let r=vr(t[e]);r=r.replace(/!\[([^\]]*)\]\((\/api\/hosts\/[^)\s]+)\)/g,(e,t,n)=>`<img src="${n}" alt="${t}" loading="lazy" decoding="async">`),r=r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(e,t,n)=>{let r=yr(n.replace(/&amp;/g,`&`));return r?`<a href="${vr(r)}" target="_blank" rel="noopener noreferrer">${t}</a>`:e}),r=r.replace(/(^|[\s(])(https?:\/\/[^\s<)]+[^\s<).,;:!?'"])/g,(e,t,n)=>`${t}<a href="${n}" target="_blank" rel="noopener noreferrer">${n}</a>`),r=r.replace(/\*\*([^*\n]+)\*\*/g,`<strong>$1</strong>`).replace(/__([^_\n]+)__/g,`<strong>$1</strong>`).replace(/(^|[^*\w])\*([^*\s][^*\n]*?)\*(?!\w)/g,`$1<em>$2</em>`).replace(/(^|[^_\w])_([^_\s][^_\n]*?)_(?!\w)/g,`$1<em>$2</em>`).replace(/~~([^~\n]+)~~/g,`<del>$1</del>`),n+=r}return n}var xr=e=>/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(e)&&e.includes(`|`),Sr=e=>e.trim().replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>br(e.trim()));function Cr(e){let t=e.replace(/\r\n?/g,`
21
+ `).split(`
22
+ `),n=[],r=[],i=()=>{r.length&&n.push(`<p>${r.map(br).join(`<br>`)}</p>`),r=[]};for(let e=0;e<t.length;e++){let a=t[e],o=/^(\s*)(```+|~~~+)\s*([\w+#.-]*)/.exec(a);if(o){i();let r=o[2],a=[];for(;++e<t.length&&!t[e].trimStart().startsWith(r);)a.push(t[e]);let s=o[3]?`<span class="code-lang">${vr(o[3])}</span>`:``;n.push(`<pre class="code">${s}<code>${vr(a.join(`
23
+ `))}</code></pre>`);continue}if(!a.trim()){i();continue}let s=/^(#{1,6})\s+(.*)$/.exec(a);if(s){i();let e=Math.min(s[1].length+2,6);n.push(`<h${e}>${br(s[2])}</h${e}>`);continue}if(/^\s*([-*_])(\s*\1){2,}\s*$/.test(a)){i(),n.push(`<hr>`);continue}if(/^\s*>/.test(a)){i();let r=[];for(;e<t.length&&/^\s*>/.test(t[e]);e++)r.push(t[e].replace(/^\s*>\s?/,``));e--,n.push(`<blockquote>${Cr(r.join(`
24
+ `))}</blockquote>`);continue}if(a.includes(`|`)&&e+1<t.length&&xr(t[e+1])){i();let r=Sr(a),o=[];for(e+=2;e<t.length&&t[e].includes(`|`)&&t[e].trim();e++)o.push(Sr(t[e]));e--,n.push(`<div class="table"><table><thead><tr>${r.map(e=>`<th>${e}</th>`).join(``)}</tr></thead><tbody>${o.map(e=>`<tr>${e.map(e=>`<td>${e}</td>`).join(``)}</tr>`).join(``)}</tbody></table></div>`);continue}let c=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/.exec(a);if(c){i();let r=/\d/.test(c[2]),a=[];for(;e<t.length;e++){let n=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/.exec(t[e]);if(n&&/\d/.test(n[2])===r){let e=/^\[([ xX])\]\s+(.*)$/.exec(n[3]),t=n[1].length>=2?` class="nested"`:``;a.push(e?`<li class="task${n[1].length>=2?` nested`:``}"><span class="check${e[1]===` `?``:` done`}"></span>${br(e[2])}</li>`:`<li${t}>${br(n[3])}</li>`)}else if(t[e].trim()&&/^\s{2,}/.test(t[e])&&a.length)a[a.length-1]=a[a.length-1].replace(/<\/li>$/,` ${br(t[e].trim())}</li>`);else break}e--,n.push(r?`<ol>${a.join(``)}</ol>`:`<ul>${a.join(``)}</ul>`)}else r.push(a)}return i(),n.join(``)}var wr=`modulepreload`,Tr=function(e){return`/`+e},Er={},Dr=function(e){return e.pathname.endsWith(`.css`)},Or=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},kr=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Tr(t,n);let r=s(t),i=Dr(r);return Or(Er,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:wr,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ar=y(null),jr=null;function Mr(){return jr??=kr(()=>import(`./MarkdownMessage-10o_Q6Zw.js`).then(e=>{Ar.value=p(e.default)}),__vite__mapDeps([0,1,2,3,4])).catch(()=>{jr=null}),jr}function Nr(){let e=window.requestIdleCallback;e?e(()=>void Mr(),{timeout:3e3}):setTimeout(()=>void Mr(),1500)}var Pr=Symbol(`litepaseo-suggestions`),Fr={key:0,class:`row row-plugin row-speed`,title:`Turn speed (turn-speed plugin)`},Ir={class:`suggestion-actions`},Lr={key:2,class:`suggestion-wait`},Rr={class:`line-icon`},zr={class:`line-name`},Br={class:`line-text`},Vr={key:0,class:`tool-body`},Hr={class:`tool-pre`},Ur=f({__name:`PluginRow`,props:{item:{},seqStart:{}},setup(r){let a=r,o=w(Pr,null),s=S(()=>`${a.item.pluginId}/${a.item.kind}`),l=S(()=>a.item.data??{}),u=S(()=>{let e=l.value;if(s.value!==`turn-speed/turn-speed`||typeof e.tokensPerSecond!=`number`)return null;let t=e.outputTokens>=1e3?`${(e.outputTokens/1e3).toFixed(1)}k`:String(e.outputTokens),n=e.generationMs>=6e4?`${Math.floor(e.generationMs/6e4)}m ${Math.round(e.generationMs%6e4/1e3)}s`:`${(e.generationMs/1e3).toFixed(1)}s`;return`${e.tokensPerSecond.toFixed(1)} tok/s · ${t} tokens · ${n} · ${e.requests} ${e.requests===1?`request`:`requests`}`}),d=S(()=>s.value===`next-input/next-input`&&typeof l.value.token==`string`),f=e(`idle`),p=e(``),m=S(()=>/[`$|<>]|(^|\s)[.~]?\/[\w.-]|https?:|www\.|\b(rm|sudo|delete|drop|remove|reset|force|push|deploy|publish|release|merge|token|password|passwd|secret|credential|api[ _-]?key|ssh)\b|删除|推送|部署|发布|密码|密钥|令牌/i.test(p.value));async function h(){if(o&&d.value){if(l.value.status===`ready`&&l.value.text)f.value=`ready`,p.value=l.value.text;else{f.value=`loading`;try{let e=await o.predict(l.value.token);e.status===`ready`&&e.text?(f.value=`ready`,p.value=e.text):f.value=e.status===`error`?`error`:`hidden`}catch{f.value=`error`}}f.value===`ready`&&o.offer(a.seqStart,p.value)}}c(()=>void h()),n(()=>l.value.token,()=>void h());let g=e(!1),_=S(()=>g.value?JSON.stringify(a.item.data??a.item,null,2):``);return(e,n)=>u.value?(i(),R(`div`,Fr,[t(J,{name:`bolt`,size:12}),x(`span`,null,k(u.value),1)])):d.value?(i(),R(`div`,{key:1,class:M([`row row-suggestion`,`is-`+f.value])},[f.value===`loading`?(i(),R(b,{key:0},[n[4]||=x(`span`,{class:`spinner spinner-sm`},null,-1),n[5]||=x(`span`,{class:`suggestion-wait`},`Thinking of a next message…`,-1)],64)):f.value===`ready`?(i(),R(b,{key:1},[x(`button`,{class:`suggestion-text`,title:`Put in the message box to edit`,onClick:n[0]||=e=>D(o)?.use(p.value)},k(p.value),1),x(`span`,Ir,[x(`button`,{class:`icon-btn`,title:`Edit in the message box`,"aria-label":`Edit suggestion`,onClick:n[1]||=e=>D(o)?.use(p.value)},[t(J,{name:`edit`,size:14})]),m.value?F(``,!0):(i(),R(`button`,{key:0,class:`icon-btn`,title:`Send this message`,"aria-label":`Send suggestion`,onClick:n[2]||=e=>D(o)?.send(p.value)},[t(J,{name:`send`,size:14})]))])],64)):f.value===`error`?(i(),R(`span`,Lr,`Suggestion unavailable`)):F(``,!0)],2)):(i(),R(`details`,{key:2,class:`row row-line row-tool row-plugin`,onToggle:n[3]||=e=>g.value=e.target.open},[x(`summary`,null,[x(`span`,Rr,[t(J,{name:`sparkle`,size:15})]),x(`span`,zr,k(r.item.pluginId),1),x(`span`,Br,k(r.item.kind),1)]),g.value?(i(),R(`div`,Vr,[x(`pre`,Hr,k(_.value),1)])):F(``,!0)],32))}}),Wr=[`aria-expanded`,`disabled`],Gr={key:0,class:`spinner`},Kr={key:0,class:`rewind-menu`,role:`menu`},qr={class:`rewind-warning`},Jr=[`onClick`],Yr=f({__name:`RewindMenu`,props:{modes:{},busy:{type:Boolean}},emits:[`rewind`],setup(r,{emit:a}){let o=r,c=a,l={conversation:`Rewind conversation`,files:`Rewind files`,both:`Rewind conversation and files`},u={conversation:`chat`,files:`file`,both:`layers`},f=e(!1),p=e(null);function h(e){(e instanceof KeyboardEvent?e.key===`Escape`:!p.value?.contains(e.target))&&(f.value=!1)}n(f,e=>{let t=e?`addEventListener`:`removeEventListener`;document[t](`pointerdown`,h,!0),document[t](`keydown`,h,!0)}),s(()=>f.value=!1);function g(e){f.value=!1,c(`rewind`,e)}return(e,n)=>(i(),R(`span`,{ref_key:`root`,ref:p,class:`rewind`},[x(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Rewind to this message`,title:`Rewind to this message`,"aria-expanded":f.value,disabled:r.busy,onClick:n[0]||=e=>f.value=!f.value},[r.busy?(i(),R(`span`,Gr)):(i(),m(J,{key:1,name:`undo`,size:14}))],8,Wr),f.value?(i(),R(`div`,Kr,[x(`p`,qr,[t(J,{name:`alert`,size:13}),n[1]||=d(`This action cannot be undone`,-1)]),(i(!0),R(b,null,z(o.modes,e=>(i(),R(`button`,{key:e,type:`button`,role:`menuitem`,class:`rewind-item`,onClick:t=>g(e)},[t(J,{name:u[e],size:15},null,8,[`name`]),d(k(l[e]),1)],8,Jr))),128))])):F(``,!0)],512))}}),Xr={key:0,class:`row row-user`},Zr={class:`bubble`,tabindex:`-1`},Qr={class:`user-actions`},$r={key:0,class:`user-time`},ei=[`aria-label`,`title`],ti=[`data-seq-end`],ni=[`innerHTML`],ri=[`tabindex`],ii={class:`line-icon`},ai={class:`line-text`},oi={key:0,class:`reasoning-text`},si=[`title`],ci={class:`line-icon`},li={key:0,class:`status-dot is-running`},ui={key:0,class:`line-name`},di={key:1,class:`line-meta`},fi={key:2,class:`line-meta`},pi={key:0,class:`tool-body`},mi={key:0,class:`tool-pre tool-command`},hi={key:1,class:`tool-pre tool-diff`},gi={key:0,class:`diff-hunk`},_i={key:2,class:`tool-pre`},vi={key:3,class:`tool-pre tool-output`},yi={key:4,class:`tool-pre tool-error`},bi={key:5,class:`tool-exit`},xi={key:6,class:`tool-exit`},Si={key:4,class:`row row-todo`},Ci={class:`todo-title`},wi={key:5,class:`row row-callout is-error`},Ti={key:7,class:`row row-divider`},Ei={class:`line-icon`},Di={class:`line-name`},Oi={key:0,class:`tool-body`},ki={class:`tool-pre`},Ai=2e4,ji=600,Mi=f({__name:`TimelineRowView`,props:{entry:{},final:{type:Boolean}},setup(n){let a=n,o=w(xn,null),s=S(()=>a.entry.value),c=S(()=>s.value.item),l=e(!1),u=S(()=>{let e=String(c.value.text??``);return o?.value?Un(e,o.value.base):e}),f=S(()=>!Ar.value&&c.value.type===`assistant_message`?Cr(u.value):``);!Ar.value&&c.value.type===`assistant_message`&&Mr();let p=S(()=>{let e=c.value;if(e.type!==`tool_call`)return null;let t=jn(e,o?.value.cwd);return{...t,summary:t.summary.split(`
25
+ `)[0],status:String(e.status??`running`)}}),h=S(()=>c.value.type===`reasoning`?Mn(String(c.value.text??``)):``),g=e(!1);function _(e){let t=e.currentTarget.querySelector(`.line-text`);g.value=!!t&&t.scrollWidth>t.clientWidth+1}function v(e){_(e),C.value||e.preventDefault()}let y=S(()=>String(c.value.text??``).trim().length>h.value.length+4),C=S(()=>y.value||g.value||l.value),T=e=>e.length>Ai?e.slice(0,Ai)+`
26
+ … (truncated)`:e,E=S(()=>{if(!l.value||!p.value)return null;let e=c.value,t=e.detail??{},n=Pn(e),r=n?n.split(`
27
+ `):[],i=T(Nn(e)),a=t.type===`unknown`&&t.input!==void 0?T(JSON.stringify(t.input,null,2)):``;return{command:t.type===`shell`||p.value.kind===`shell`?String(t.command??t.input?.command??p.value.summary):``,exitCode:typeof t.exitCode==`number`?t.exitCode:null,diff:r.slice(0,ji).map(e=>({text:e,kind:e.startsWith(`@@`)?`hunk`:e.startsWith(`+`)&&!e.startsWith(`+++`)?`add`:e.startsWith(`-`)&&!e.startsWith(`---`)?`del`:``})),diffMore:Math.max(0,r.length-ji),input:p.value.kind===`shell`?``:a,output:i,error:e.error?T(typeof e.error==`string`?e.error:JSON.stringify(e.error,null,2)):``}}),O=S(()=>c.value.type===`todo`?c.value.items:[]),A=S(()=>l.value?T(JSON.stringify(c.value,null,2)):``),j=S(()=>String(c.value.type).replaceAll(`_`,` `)),N=e=>l.value=e.target.open,P=S(()=>{if(c.value.type!==`user_message`)return``;let e=Date.parse(s.value.timestamp);return Number.isFinite(e)?Rn(new Date(e)):``}),I=S(()=>c.value.type===`user_message`&&typeof c.value.messageId==`string`?o?.value.rewindModes??[]:[]),L=S(()=>!!o?.value.rewinding?.value),B=e=>o?.value.rewind?.(String(c.value.messageId),String(c.value.text??``),e),V=e(!1);async function H(){try{await navigator.clipboard.writeText(String(c.value.text??``)),V.value=!0,setTimeout(()=>V.value=!1,1500)}catch{}}return(e,a)=>c.value.type===`user_message`?(i(),R(`div`,Xr,[x(`div`,Zr,k(c.value.text),1),x(`div`,Qr,[P.value?(i(),R(`span`,$r,k(P.value),1)):F(``,!0),I.value.length?(i(),m(Yr,{key:1,modes:I.value,busy:L.value,onRewind:B},null,8,[`modes`,`busy`])):F(``,!0),x(`button`,{type:`button`,class:`icon-btn`,"aria-label":V.value?`Copied`:`Copy message`,title:V.value?`Copied`:`Copy message`,onClick:H},[t(J,{name:V.value?`check`:`copy`,size:14},null,8,[`name`])],8,ei)])])):c.value.type===`assistant_message`?(i(),R(`div`,{key:1,class:`row row-assistant`,"data-seq-end":s.value.seqEnd},[D(Ar)?(i(),m(r(D(Ar)),{key:0,content:u.value,final:n.final},null,8,[`content`,`final`])):(i(),R(`div`,{key:1,class:`prose`,innerHTML:f.value},null,8,ni))],8,ti)):c.value.type===`reasoning`?(i(),R(`details`,{key:2,class:M([`row row-line row-reasoning`,{"is-static":!C.value}]),onToggle:N},[x(`summary`,{tabindex:C.value?void 0:-1,onPointerenter:_,onFocus:_,onClick:v},[x(`span`,ii,[t(J,{name:`bulb`,size:15})]),x(`span`,ai,k(h.value||`Thinking`),1)],40,ri),l.value?(i(),R(`div`,oi,k(c.value.text),1)):F(``,!0)],34)):p.value?(i(),R(`details`,{key:3,class:M([`row row-line row-tool`,[`is-`+p.value.status,`kind-`+p.value.kind]]),onToggle:N},[x(`summary`,{title:p.value.name+(p.value.status===`failed`?` · failed`:p.value.status===`canceled`?` · canceled`:``)},[x(`span`,ci,[p.value.status===`running`?(i(),R(`span`,li)):(i(),m(J,{key:1,name:p.value.status===`failed`?`close`:p.value.icon,size:15},null,8,[`name`]))]),p.value.showName||!p.value.summary?(i(),R(`span`,ui,k(p.value.name),1)):F(``,!0),x(`span`,{class:M([`line-text`,{mono:p.value.kind!==`sub_agent`&&p.value.kind!==`plain`&&p.value.kind!==`unknown`}])},k(p.value.summary),3),p.value.meta?(i(),R(`span`,di,k(p.value.meta),1)):p.value.status===`canceled`?(i(),R(`span`,fi,`canceled`)):F(``,!0)],8,si),E.value?(i(),R(`div`,pi,[E.value.command?(i(),R(`pre`,mi,[a[0]||=x(`span`,{class:`tool-prompt`},`$`,-1),d(` `+k(E.value.command),1)])):F(``,!0),E.value.diff.length?(i(),R(`pre`,hi,[(i(!0),R(b,null,z(E.value.diff,(e,t)=>(i(),R(`span`,{key:t,class:M(e.kind&&`diff-`+e.kind)},k(e.text)+`
28
+ `,3))),128)),E.value.diffMore?(i(),R(`span`,gi,`… `+k(E.value.diffMore)+` more lines`,1)):F(``,!0)])):F(``,!0),E.value.input?(i(),R(`pre`,_i,k(E.value.input),1)):F(``,!0),E.value.output?(i(),R(`pre`,vi,k(E.value.output),1)):F(``,!0),E.value.error?(i(),R(`pre`,yi,k(E.value.error),1)):F(``,!0),E.value.exitCode!==null&&E.value.exitCode!==0&&!E.value.error?(i(),R(`p`,bi,`exit `+k(E.value.exitCode),1)):F(``,!0),!E.value.command&&!E.value.diff.length&&!E.value.input&&!E.value.output&&!E.value.error?(i(),R(`p`,xi,`No output`)):F(``,!0)])):F(``,!0)],34)):c.value.type===`todo`?(i(),R(`div`,Si,[x(`div`,Ci,[t(J,{name:`list`,size:14}),a[1]||=d(` Plan`,-1)]),x(`ul`,null,[(i(!0),R(b,null,z(O.value,(e,t)=>(i(),R(`li`,{key:e.id??t,class:M({done:e.completed,active:e.status===`in_progress`})},[x(`span`,{class:M([`check`,{done:e.completed}])},null,2),d(k(e.text),1)],2))),128))])])):c.value.type===`error`?(i(),R(`div`,wi,[t(J,{name:`alert`,size:15}),a[2]||=d(),x(`span`,null,k(c.value.message),1)])):c.value.type===`notification`?(i(),R(`div`,{key:6,class:M([`row row-callout`,`is-`+c.value.level])},[t(J,{name:`alert`,size:15}),a[3]||=d(),x(`span`,null,k(c.value.message),1)],2)):c.value.type===`compaction`?(i(),R(`div`,Ti,[x(`span`,null,k(c.value.status===`loading`?`Compacting context…`:`Context compacted`),1)])):c.value.type===`plugin`?(i(),m(Ur,{key:8,item:c.value,"seq-start":s.value.seqStart},null,8,[`item`,`seq-start`])):(i(),R(`details`,{key:9,class:`row row-line row-tool`,onToggle:N},[x(`summary`,null,[x(`span`,Ei,[t(J,{name:`tool`,size:15})]),x(`span`,Di,k(j.value),1)]),l.value?(i(),R(`div`,Oi,[x(`pre`,ki,k(A.value),1)])):F(``,!0)],32))}}),Ni={class:`sheet-head`},Pi=[`disabled`],Fi={class:`sheet-body`},Ii={key:0,class:`sheet-note`},Li={class:`field-grid`},Ri={class:`field`},zi=[`disabled`],Bi=[`value`],Vi={class:`field`},Hi=[`disabled`],Ui={key:0,value:``},Wi=[`value`],Gi={key:0,class:`field`},Ki=[`title`],qi={class:`field`},Ji=[`placeholder`,`disabled`],Yi={class:`field-grid three`},Xi={class:`field field-agent`},Zi=[`disabled`],Qi={key:0,value:``},$i=[`value`,`disabled`],ea={class:`field field-model`},ta=[`disabled`],na={key:0,value:``},ra=[`value`],ia={class:`field field-thinking`},aa=[`disabled`],oa={key:0,value:``},sa=[`value`],ca={key:2,class:`field`},la=[`disabled`],ua=[`value`],da={class:`toggle`},fa=[`disabled`],pa={key:3,class:`field`},ma={key:4,class:`sheet-error`},ha={key:5,class:`sheet-error`},ga={key:6,class:`sheet-error`,role:`alert`},_a={class:`sheet-foot`},va=[`disabled`],ya=[`disabled`],ba={key:0,class:`spinner spinner-on-accent`},xa=`\0custom`,Sa=`litepaseo-new-session`,Ca=f({__name:`NewSession`,props:{hosts:{},initialHostId:{},initialCwd:{},initialProject:{},request:{type:Function}},emits:[`close`,`created`],setup(r,{emit:o}){let s=r,u=o,f=(()=>{try{return JSON.parse(localStorage.getItem(Sa)??`{}`)}catch{return{}}})(),p=S(()=>s.hosts.filter(e=>e.state===`connected`)),m=e(p.value.find(e=>e.id===s.initialHostId)?.id??p.value[0]?.id??``),g=e(null),y=e(null),w=e(``),T=e(``),E=e(``),D=e(``),O=e(``),A=e(``),j=e(``),M=e(!1),P=e(``),I=e(``),L=e(!1),B=e(``),V=e(null),H=crypto.randomUUID(),U=S(()=>g.value?.find(e=>e.id===D.value)),W=S(()=>U.value?.models??[]),ee=S(()=>W.value.find(e=>e.id===O.value)),te=S(()=>T.value===xa?E.value.trim():T.value),G=S(()=>y.value?.find(e=>e.rootPath===T.value)?.name??te.value.split(`/`).pop()??``),K=S(()=>!!m.value&&!!te.value&&!!D.value&&!L.value&&(!M.value||!!P.value.trim()));async function ne(e){if(g.value=y.value=null,w.value=``,e)try{let[t,n]=await Promise.all([s.request(`/hosts/${encodeURIComponent(e)}/providers`),s.request(`/hosts/${encodeURIComponent(e)}/projects`)]);if(e!==m.value)return;g.value=t,y.value=n.sort((e,t)=>e.name.localeCompare(t.name)),q();let r=y.value,i=e===s.initialHostId?s.initialProject:null,a=i?r.find(e=>i.key&&e.key===i.key)??r.find(e=>e.name.toLowerCase()===i.name.toLowerCase()):void 0;if(a)T.value=a.rootPath;else if(e===s.initialHostId&&s.initialCwd){let e=r.find(e=>e.rootPath===s.initialCwd);e?T.value=e.rootPath:(T.value=xa,E.value=s.initialCwd)}else T.value||=r[0]?.rootPath??xa}catch(t){e===m.value&&(w.value=t.message)}}function q(){let e=f[m.value]??{},t=g.value??[],n=t.find(t=>t.id===e.provider&&t.status!==`error`)??t.find(e=>e.status===`ready`)??t[0];D.value=n?.id??``,re(e.model,e.thinking),j.value=n?.modes.some(t=>t.id===e.mode)?e.mode:n?.defaultModeId??``}function re(e,t){let n=W.value,r=n.find(t=>t.id===e)??n.find(e=>e.isDefault)??n[0];O.value=r?.id??``,A.value=r?.thinking.some(e=>e.id===t)?t:r?.defaultThinkingId??``}n(m,e=>{T.value=``,ne(e)}),n(D,()=>{let e=f[m.value];re(e?.provider===D.value?e.model:void 0);let t=U.value;t&&!t.modes.some(e=>e.id===j.value)&&(j.value=t.defaultModeId??``)}),n(O,()=>{let e=ee.value;e&&!e.thinking.some(e=>e.id===A.value)&&(A.value=e.defaultThinkingId??``)}),n([m,T,E,D,O,A,j,M,P,I],()=>{B.value&&(H=crypto.randomUUID()),B.value=``});async function ie(){if(K.value){L.value=!0,B.value=``;try{let e=await s.request(`/hosts/${encodeURIComponent(m.value)}/agents`,`POST`,{idempotencyKey:H,cwd:te.value,provider:D.value,...O.value?{model:O.value}:{},...j.value?{modeId:j.value}:{},...A.value?{thinkingOptionId:A.value}:{},...I.value.trim()?{prompt:I.value}:{},...M.value?{worktreeBranch:P.value.trim()}:{}},12e4);f[m.value]={provider:D.value,model:O.value,thinking:A.value,mode:j.value},localStorage.setItem(Sa,JSON.stringify(f)),u(`created`,e.key)}catch(e){B.value=e.message}finally{L.value=!1}}}function ae(e){e.key===`Escape`&&!L.value&&u(`close`),e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),ie())}return c(()=>{window.addEventListener(`keydown`,ae),ne(m.value),C(()=>V.value?.focus())}),l(()=>window.removeEventListener(`keydown`,ae)),(e,n)=>(i(),R(`div`,{class:`overlay`,onMousedown:n[12]||=v(e=>!L.value&&u(`close`),[`self`])},[x(`form`,{class:`sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":`New session`,onSubmit:v(ie,[`prevent`])},[x(`header`,Ni,[n[13]||=x(`h2`,null,`New session`,-1),x(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close`,disabled:L.value,onClick:n[0]||=e=>u(`close`)},[t(J,{name:`close`,size:16})],8,Pi)]),x(`div`,Fi,[p.value.length?(i(),R(b,{key:1},[x(`div`,Li,[x(`label`,Ri,[n[14]||=x(`span`,null,`Host`,-1),a(x(`select`,{"onUpdate:modelValue":n[1]||=e=>m.value=e,disabled:L.value},[(i(!0),R(b,null,z(p.value,e=>(i(),R(`option`,{key:e.id,value:e.id},k(e.label),9,Bi))),128))],8,zi),[[N,m.value]])]),x(`label`,Vi,[n[15]||=x(`span`,null,`Project`,-1),a(x(`select`,{"onUpdate:modelValue":n[2]||=e=>T.value=e,disabled:L.value||!y.value},[y.value?F(``,!0):(i(),R(`option`,Ui,`Loading…`)),(i(!0),R(b,null,z(y.value??[],e=>(i(),R(`option`,{key:e.key,value:e.rootPath},k(e.name),9,Wi))),128)),x(`option`,{value:xa},`Another folder…`)],8,Hi),[[N,T.value]])])]),T.value===xa?(i(),R(`label`,Gi,[x(`span`,null,`Folder on `+k(p.value.find(e=>e.id===m.value)?.label),1),a(x(`input`,{"onUpdate:modelValue":n[3]||=e=>E.value=e,placeholder:`/home/me/code/project`,autocomplete:`off`,spellcheck:`false`},null,512),[[_,E.value]])])):te.value?(i(),R(`p`,{key:1,class:`path-hint`,title:te.value},[t(J,{name:`folder`,size:13}),d(k(te.value),1)],8,Ki)):F(``,!0),x(`label`,qi,[n[16]||=x(`span`,null,`First message`,-1),a(x(`textarea`,{ref_key:`promptElement`,ref:V,"onUpdate:modelValue":n[4]||=e=>I.value=e,rows:`5`,placeholder:G.value?`What should the agent do in ${G.value}?`:`What should the agent do?`,disabled:L.value},null,8,Ji),[[_,I.value]])]),x(`div`,Yi,[x(`label`,Xi,[n[17]||=x(`span`,null,`Agent`,-1),a(x(`select`,{"onUpdate:modelValue":n[5]||=e=>D.value=e,disabled:L.value||!g.value},[g.value?F(``,!0):(i(),R(`option`,Qi,`Loading…`)),(i(!0),R(b,null,z(g.value??[],e=>(i(),R(`option`,{key:e.id,value:e.id,disabled:e.status===`error`},k(e.label)+k(e.status===`loading`?` (starting)`:e.status===`error`?` (error)`:``),9,$i))),128))],8,Zi),[[N,D.value]])]),x(`label`,ea,[n[18]||=x(`span`,null,`Model`,-1),a(x(`select`,{"onUpdate:modelValue":n[6]||=e=>O.value=e,disabled:L.value||!W.value.length},[W.value.length?F(``,!0):(i(),R(`option`,na,`Default`)),(i(!0),R(b,null,z(W.value,e=>(i(),R(`option`,{key:e.id,value:e.id},k(e.label),9,ra))),128))],8,ta),[[N,O.value]])]),x(`label`,ia,[n[19]||=x(`span`,null,`Thinking`,-1),a(x(`select`,{"onUpdate:modelValue":n[7]||=e=>A.value=e,disabled:L.value||!ee.value?.thinking.length},[ee.value?.thinking.length?F(``,!0):(i(),R(`option`,oa,`Default`)),(i(!0),R(b,null,z(ee.value?.thinking??[],e=>(i(),R(`option`,{key:e.id,value:e.id},k(e.label),9,sa))),128))],8,aa),[[N,A.value]])])]),U.value?.modes.length?(i(),R(`label`,ca,[n[20]||=x(`span`,null,`Mode`,-1),a(x(`select`,{"onUpdate:modelValue":n[8]||=e=>j.value=e,disabled:L.value},[(i(!0),R(b,null,z(U.value.modes,e=>(i(),R(`option`,{key:e.id,value:e.id},k(e.label),9,ua))),128))],8,la),[[N,j.value]])])):F(``,!0),x(`label`,da,[a(x(`input`,{"onUpdate:modelValue":n[9]||=e=>M.value=e,type:`checkbox`,disabled:L.value},null,8,fa),[[h,M.value]]),n[21]||=x(`span`,null,`Work in a new git worktree`,-1)]),M.value?(i(),R(`label`,pa,[n[22]||=x(`span`,null,`New branch`,-1),a(x(`input`,{"onUpdate:modelValue":n[10]||=e=>P.value=e,placeholder:`feature/my-change`,autocomplete:`off`,spellcheck:`false`},null,512),[[_,P.value]])])):F(``,!0),w.value?(i(),R(`p`,ma,[t(J,{name:`alert`,size:14}),d(k(w.value),1)])):F(``,!0),U.value?.error?(i(),R(`p`,ha,[t(J,{name:`alert`,size:14}),d(k(U.value.error),1)])):F(``,!0),B.value?(i(),R(`p`,ga,[t(J,{name:`alert`,size:14}),x(`span`,null,k(B.value),1)])):F(``,!0)],64)):(i(),R(`p`,Ii,`No connected hosts. Connect a host first.`))]),x(`footer`,_a,[n[23]||=x(`span`,{class:`sheet-hint hide-sm`},`Ctrl/⌘ + Enter to start`,-1),x(`button`,{type:`button`,class:`btn btn-ghost`,disabled:L.value,onClick:n[11]||=e=>u(`close`)},`Cancel`,8,va),x(`button`,{class:`btn btn-primary`,disabled:!K.value},[L.value?(i(),R(`span`,ba)):F(``,!0),d(` `+k(L.value?`Starting…`:B.value?`Retry`:`Start session`),1)],8,ya)])],32)],32))}}),wa={key:0,class:`attachment-tray`},Ta=[`data-state`,`title`],Ea={class:`attachment-thumb`},Da=[`src`,`alt`],Oa={key:2,class:`spinner spinner-sm attachment-uploading`},ka={class:`attachment-text`},Aa={class:`attachment-name`},ja={class:`attachment-meta`},Ma=[`disabled`,`onClick`],Na=[`aria-label`,`title`,`disabled`,`onClick`],Pa={key:0,class:`attachment-error`,role:`alert`},Fa=[`disabled`],Ia=f({__name:`AttachmentPanel`,props:{store:{},agentKey:{},base:{},busy:{type:Boolean}},setup(r,{expose:a}){let o=r,s=e(null),c=e(``),l=e(0),u=e(null),f=S(()=>o.store.get(o.agentKey));n([()=>o.base,l],async([e],t,n)=>{let r=new AbortController;n(()=>r.abort()),s.value=null,c.value=``;try{let t=await fetch(e+`/attachments/capabilities`,{signal:r.signal});if(!t.ok)throw Error(`Attachment capabilities are unavailable while the host is disconnected.`);let n=await t.json();r.signal.aborted||(s.value=n)}catch(e){r.signal.aborted||(c.value=e.message)}},{immediate:!0});let p=new Set([`image/png`,`image/jpeg`,`image/webp`]);function h(e){if(!p.has(e.type)||!/^image\.(png|jpe?g|webp)$/i.test(e.name))return e;let t=new Date().toISOString().replace(/[-:]/g,``).replace(`T`,`-`).slice(0,15),n=e.type===`image/jpeg`?`jpg`:e.type.slice(6);return new File([e],`pasted-${t}-${Math.random().toString(36).slice(2,6)}.${n}`,{type:e.type,lastModified:e.lastModified})}async function g(e,t){if(!p.has(e.type)||e.size<=t||typeof createImageBitmap!=`function`)return e;let n=await createImageBitmap(e);try{for(let[r,i]of[[3072,.9],[2400,.85],[1800,.8]]){let a=Math.min(1,r/Math.max(n.width,n.height)),o=document.createElement(`canvas`);o.width=Math.round(n.width*a),o.height=Math.round(n.height*a),o.getContext(`2d`).drawImage(n,0,0,o.width,o.height);let s=await new Promise(e=>o.toBlob(e,`image/jpeg`,i));if(s&&s.size<=t)return new File([s],e.name.replace(/\.\w+$/,`.jpg`),{type:`image/jpeg`})}}finally{n.close()}return e}async function _(e){if(e?.length&&!o.busy){c.value=``;try{if(!s.value)throw Error(`Wait for attachment capabilities, then try again.`);let t=s.value.maxBytes,n=await Promise.all(Array.from(e).map(e=>g(h(e),t)));await o.store.add(o.agentKey,o.base,n,s.value)}catch(e){c.value=e.message}u.value&&(u.value.value=``)}}let v=S(()=>!!s.value&&(s.value.images||s.value.files)),y=S(()=>s.value?v.value?[`Attach files (up to 4 · 8 MiB each · 24 MiB total)`,s.value.note].filter(Boolean).join(`
29
+ `):`Attachments are unavailable for this agent`:c.value?`Attachments unavailable`:`Checking attachment support…`),C=()=>{v.value&&!o.busy&&u.value?.click()},w=e=>e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`;return a({addFiles:_,pick:C,available:v,hint:y}),(e,n)=>(i(),R(b,null,[x(`input`,{ref_key:`picker`,ref:u,type:`file`,multiple:``,hidden:``,"aria-label":`Choose attachments`,onChange:n[0]||=e=>_(u.value?.files)},null,544),f.value.length||c.value?(i(),R(`div`,wa,[(i(!0),R(b,null,z(f.value,e=>(i(),R(`div`,{key:e.localId,class:M([`attachment-item`,{"is-error":!!e.error}]),"data-state":e.uploading?`uploading`:e.error?`error`:`ready`,title:e.error||e.file.name},[x(`span`,Ea,[e.preview?(i(),R(`img`,{key:0,src:e.preview,alt:e.file.name},null,8,Da)):(i(),m(J,{key:1,name:`file`,size:16})),e.uploading?(i(),R(`span`,Oa)):F(``,!0)]),x(`span`,ka,[x(`span`,Aa,k(e.file.name),1),x(`span`,ja,k(e.error?`Upload failed`:e.uploading?`Uploading…`:w(e.file.size)),1)]),e.error?(i(),R(`button`,{key:0,type:`button`,class:`attachment-action`,"aria-label":`Retry upload`,title:`Retry upload`,disabled:r.busy,onClick:t=>r.store.upload(e)},[t(J,{name:`refresh`,size:13})],8,Ma)):F(``,!0),x(`button`,{type:`button`,class:`attachment-action`,"aria-label":e.uploading?`Cancel upload`:`Remove attachment`,title:e.uploading?`Cancel upload`:`Remove attachment`,disabled:r.busy,onClick:t=>r.store.remove(r.agentKey,e)},[t(J,{name:`close`,size:13})],8,Na)],10,Ta))),128)),c.value?(i(),R(`p`,Pa,[t(J,{name:`alert`,size:13}),d(k(c.value)+` `,1),s.value?F(``,!0):(i(),R(`button`,{key:0,type:`button`,class:`attachment-retry`,disabled:r.busy,onClick:n[1]||=e=>l.value++},`Retry`,8,Fa))])):F(``,!0)])):F(``,!0)],64))}}),La=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},Ra=La(Ia,[[`__scopeId`,`data-v-78817268`]]),za=class{entries=u(new Map);get(e){return this.entries.get(e)??[]}async add(e,t,n,r){for(let i of n){if(this.get(e).length>=4)throw Error(`Attach up to four files per message.`);if([...this.entries.values()].flat().reduce((e,t)=>e+t.file.size,0)+i.size>25165824)throw Error(`Attachments total more than 24 MiB. Remove files before adding more.`);if(!i.size||i.size>r.maxBytes)throw Error(`Files must be between 1 byte and 8 MiB.`);let n=[`image/png`,`image/jpeg`,`image/webp`,`image/gif`].includes(i.type);if(n?!r.images:!r.files)throw Error(n?`This provider does not support images.`:`This agent cannot read uploaded files.`);let a=u({localId:crypto.randomUUID(),file:i,preview:n?URL.createObjectURL(i):void 0,error:``,uploading:!1,cancelled:!1,base:t});this.entries.set(e,[...this.get(e),a]),this.upload(a)}}async upload(e){if(!(e.uploading||e.cancelled)){e.error=``,e.uploading=!0,e.controller=new AbortController;try{e.id&&await this.discardRemote(e);let t=await fetch(e.base+`/attachments`,{method:`POST`,body:e.file,headers:{"x-litepaseo":`1`,"x-file-name":encodeURIComponent(e.file.name),"content-type":e.file.type||`application/octet-stream`},signal:AbortSignal.any([e.controller.signal,AbortSignal.timeout(6e4)])}),n=await t.json();if(!t.ok)throw Error(n.error??`Upload failed`);e.id=n.id,e.cancelled&&await this.discardRemote(e)}catch(t){!e.cancelled&&!e.controller?.signal.aborted&&(e.error=t.message)}finally{e.uploading=!1}}}async discardRemote(e){let t=e.id;e.id=void 0,t&&await fetch(e.base+`/attachments/`+encodeURIComponent(t),{method:`DELETE`,headers:{"x-litepaseo":`1`},signal:AbortSignal.timeout(5e3)}).catch(()=>{})}remove(e,t,n=!1){t.cancelled=!0,t.controller?.abort(),t.preview&&URL.revokeObjectURL(t.preview),this.entries.set(e,this.get(e).filter(e=>e.localId!==t.localId)),n||this.discardRemote(t)}detach(e){let t=this.get(e);return this.entries.delete(e),t}reattach(e,t){let n=[...this.get(e),...t];for(let t of n.slice(4))this.remove(e,t);this.entries.set(e,n.slice(0,4))}consume(e,t){for(let n of this.get(e))n.id&&t.includes(n.id)&&this.remove(e,n,!0)}forgetRemote(e){for(let t of this.entries.values())for(let n of t)n.controller?.abort(),n.id=void 0,n.uploading=!1,n.error=e}clear(){for(let[e,t]of this.entries)for(let n of t)this.remove(e,n);this.entries.clear()}};function Ba(e){let t=e.input;if(e.kind!==`question`||!Array.isArray(t?.questions)||!t.questions.length)return null;let n=[],r=new Set;for(let i of t.questions){if(!i||typeof i!=`object`||typeof i.header!=`string`||!i.header.trim()||typeof i.question!=`string`||!i.question.trim()||r.has(i.header)||i.options!==void 0&&!Array.isArray(i.options))return null;let t=i.options??[];if(t.some(e=>!e||typeof e.label!=`string`||!e.label.trim()||e.description!==void 0&&typeof e.description!=`string`)||new Set(t.map(e=>e.label)).size!==t.length)return null;r.add(i.header),n.push({header:i.header,question:i.question,options:t,multiple:i.multiSelect===!0,other:i.isOther===!0||e.name===`AskUserQuestion`||!t.length,secret:i.isSecret===!0,required:i.required!==!1})}return n}function Va(e,t){let n=e.map((e,n)=>{let r=t[n]??{selected:[],text:``},i=r.selected.filter(t=>e.options.some(e=>e.label===t)),a=e.other?r.text.trim():``,o=e.multiple?[...i,...a?[a]:[]].join(`, `):a||i[0]||``;if(e.required&&!o)throw Error(`Answer ${e.header} before submitting.`);return[e.header,o]});return{answers:Object.fromEntries(n)}}var Ha={class:`permission-head`},Ua={class:`permission-icon`},Wa={class:`grow`},Ga={class:`row-title`},Ka={class:`row-sub`},qa={class:`permission-details`},Ja={key:0,class:`field`},Ya=[`value`],Xa=[`disabled`],Za=[`type`,`name`,`checked`,`onChange`],Qa={key:0,class:`row-sub`},$a={key:0,class:`field`},eo=[`onUpdate:modelValue`,`type`,`aria-label`],to={key:2,class:`field`},no={key:3,role:`alert`},ro={class:`permission-actions`},io=[`disabled`],ao=[`disabled`],oo=La(f({__name:`PermissionForm`,props:{permission:{},busy:{type:Boolean}},emits:[`respond`],setup(r,{emit:o}){let s=r,c=o,l=S(()=>Ba(s.permission)),u=e([]),f=e(``),p=e(``),m=e(``);n(()=>JSON.stringify(s.permission.input),()=>{u.value=(l.value??[]).map(()=>({selected:[],text:``})),f.value=``,m.value=``},{immediate:!0});function h(e,t,n){let r=u.value[e];n?r.selected=r.selected.includes(t)?r.selected.filter(e=>e!==t):[...r.selected,t]:(r.selected=[t],r.text=``)}function g(e){m.value=``;try{let t={behavior:e?`allow`:`deny`};if(p.value&&(t.selectedActionId=p.value),e&&s.permission.kind===`question`){if(l.value)t.updatedInput=Va(l.value,u.value);else{let e=JSON.parse(f.value);if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Enter a JSON object for the answer.`);t.updatedInput=e}}c(`respond`,t)}catch(e){m.value=e instanceof SyntaxError?`Enter a valid JSON object for the answer.`:e.message}}return(e,n)=>(i(),R(`form`,{class:`permission`,onSubmit:n[3]||=v(e=>g(!0),[`prevent`])},[x(`div`,Ha,[x(`span`,Ua,[t(J,{name:`shield`,size:16})]),x(`div`,Wa,[x(`div`,Ga,k(r.permission.title||r.permission.name),1),x(`div`,Ka,k(r.permission.kind===`question`?`Question`:`Permission request`)+` · `+k(r.permission.name),1)])]),x(`details`,qa,[n[4]||=x(`summary`,null,`Request details`,-1),x(`pre`,null,k(JSON.stringify(r.permission.input,null,2)),1)]),r.permission.actions?.length?(i(),R(`label`,Ja,[n[6]||=x(`span`,null,`Action`,-1),a(x(`select`,{"onUpdate:modelValue":n[0]||=e=>p.value=e},[n[5]||=x(`option`,{value:``},`Default`,-1),(i(!0),R(b,null,z(r.permission.actions,e=>(i(),R(`option`,{key:e.id,value:e.id},k(e.label||e.id),9,Ya))),128))],512),[[N,p.value]])])):F(``,!0),l.value?(i(!0),R(b,{key:1},z(l.value,(e,t)=>(i(),R(`fieldset`,{key:e.header,class:`question-field`,disabled:r.busy},[x(`legend`,null,k(e.header)+k(e.required?` *`:``)+`: `+k(e.question),1),(i(!0),R(b,null,z(e.options,n=>(i(),R(`label`,{key:n.label,class:`question-option`},[x(`input`,{type:e.multiple?`checkbox`:`radio`,name:r.permission.id+`:`+t,checked:u.value[t]?.selected.includes(n.label)&&(e.multiple||!u.value[t]?.text),onChange:r=>h(t,n.label,e.multiple)},null,40,Za),x(`span`,null,[d(k(n.label),1),n.description?(i(),R(`small`,Qa,` — `+k(n.description),1)):F(``,!0)])]))),128)),e.other?(i(),R(`label`,$a,[x(`span`,null,k(e.options.length?`Other answer`:`Your answer`),1),a(x(`input`,{"onUpdate:modelValue":e=>u.value[t].text=e,type:e.secret?`password`:`text`,"aria-label":e.header+`: `+(e.options.length?`Other answer`:`Your answer`),autocomplete:`off`},null,8,eo),[[O,u.value[t].text]])])):F(``,!0)],8,Xa))),128)):r.permission.kind===`question`?(i(),R(`label`,to,[n[7]||=x(`span`,null,`This question format needs a JSON answer.`,-1),a(x(`textarea`,{"onUpdate:modelValue":n[1]||=e=>f.value=e,"aria-label":`Answer (JSON)`,rows:`3`,placeholder:`{"answers": {}}`},null,512),[[_,f.value]])])):F(``,!0),m.value?(i(),R(`p`,no,k(m.value),1)):F(``,!0),x(`div`,ro,[x(`button`,{type:`button`,class:`btn btn-outline`,disabled:r.busy,onClick:n[2]||=e=>g(!1)},`Deny`,8,io),x(`button`,{class:`btn btn-primary`,disabled:r.busy},`Allow / submit`,8,ao)])],32))}}),[[`__scopeId`,`data-v-f1db1c0a`]]),so=`litepaseo-theme`,co=e((()=>{let e=localStorage.getItem(so);return e===`light`||e===`dark`?e:`system`})()),lo=matchMedia(`(prefers-color-scheme: dark)`),uo=e(lo.matches);lo.addEventListener(`change`,e=>{uo.value=e.matches});var fo=S(()=>co.value===`dark`||co.value===`system`&&uo.value);function po(e=co.value){co.value=e,e===`system`?(delete document.documentElement.dataset.theme,localStorage.removeItem(so)):(document.documentElement.dataset.theme=e,localStorage.setItem(so,e))}var mo=[`system`,`light`,`dark`];function ho(){po(mo[(mo.indexOf(co.value)+1)%mo.length])}var go=[{id:`graphite`,label:`Graphite`,note:`Monochrome, like Paseo`,swatch:[`#18181b`,`#e4e4e7`],light:{"--accent":`#18181b`,"--accent-hover":`#3f3f46`,"--accent-soft":`rgba(24, 24, 27, 0.07)`,"--accent-fg":`#ffffff`,"--accent-2":`#71717a`,"--link":`#2563eb`,"--unread":`#16a34a`},dark:{"--accent":`#e4e4e7`,"--accent-hover":`#ffffff`,"--accent-soft":`rgba(255, 255, 255, 0.08)`,"--accent-fg":`#18191c`,"--accent-2":`#a1a1aa`,"--link":`#8ab4f8`,"--unread":`#4ade80`,"--surface-0":`#18191c`,"--surface-1":`#1d1e22`,"--surface-2":`#232429`,"--surface-3":`#2d2e34`,"--sidebar":`#141517`,"--fg":`#e4e4e7`,"--fg-muted":`#a1a1aa`,"--fg-faint":`#6b6b74`,"--border":`#2a2b30`,"--border-strong":`#3a3b42`,"--user-bubble":`#27282d`,"--code-bg":`#141517`,"--seg-track":`#141517`,"--seg-thumb":`#2d2e34`}},{id:`indigo`,label:`Indigo`,note:`Calm blue-violet`,swatch:[`#4f46e5`,`#8b93ff`],light:{"--accent":`#4f46e5`,"--accent-hover":`#4338ca`,"--accent-soft":`rgba(79, 70, 229, 0.1)`,"--accent-fg":`#ffffff`,"--accent-2":`#818cf8`,"--link":`#4f46e5`,"--unread":`#16a34a`},dark:{"--accent":`#8b93ff`,"--accent-hover":`#a5abff`,"--accent-soft":`rgba(139, 147, 255, 0.15)`,"--accent-fg":`#15172b`,"--accent-2":`#c4b5fd`,"--link":`#a5abff`,"--unread":`#4ade80`}},{id:`ocean`,label:`Ocean`,note:`Deep teal`,swatch:[`#0e7490`,`#5cc8dc`],light:{"--accent":`#0e7490`,"--accent-hover":`#0b5f76`,"--accent-soft":`rgba(14, 116, 144, 0.1)`,"--accent-fg":`#ffffff`,"--accent-2":`#22a3c4`,"--link":`#0e7490`,"--unread":`#16a34a`},dark:{"--accent":`#5cc8dc`,"--accent-hover":`#7fd6e6`,"--accent-soft":`rgba(92, 200, 220, 0.14)`,"--accent-fg":`#0f2328`,"--accent-2":`#8be0ee`,"--link":`#7fd6e6`,"--unread":`#4ade80`}},{id:`ember`,label:`Ember`,note:`Warm terracotta`,swatch:[`#c2410c`,`#f59e5b`],light:{"--accent":`#c2410c`,"--accent-hover":`#9a3412`,"--accent-soft":`rgba(194, 65, 12, 0.09)`,"--accent-fg":`#ffffff`,"--accent-2":`#ea7a3c`,"--link":`#b4410f`,"--unread":`#16a34a`},dark:{"--accent":`#f59e5b`,"--accent-hover":`#f8b47e`,"--accent-soft":`rgba(245, 158, 91, 0.14)`,"--accent-fg":`#2a1a0e`,"--accent-2":`#fbc08f`,"--link":`#f8b47e`,"--unread":`#4ade80`}}],_o=`litepaseo-palette`,vo=e((()=>{let e=localStorage.getItem(_o);return go.some(t=>t.id===e)?e:`ocean`})()),yo=[];function bo(){let e=document.documentElement.style;for(let t of yo)e.removeProperty(t);let t=go.find(e=>e.id===vo.value)??go[0],n=fo.value?t.dark:t.light;for(let[t,r]of Object.entries(n))e.setProperty(t,r);yo=Object.keys(n),document.documentElement.dataset.palette=t.id}function xo(e=vo.value){vo.value=e,localStorage.setItem(_o,e),bo()}n(fo,bo);var So=`Brave turns push off by default. Open brave://settings/privacy, turn on “Use Google services for push messaging”, restart Brave, and try again.`,Co=`This browser could not reach its push service. A proxy, VPN or firewall may block it, or this browser build has no push service; Chrome, Edge or Firefox work.`;function wo(e){let{name:t,message:n}=e??{};return t===`AbortError`||/push service/i.test(String(n??``))}function To(e,t){return wo(e)?Error(t?So:Co,{cause:e}):e instanceof Error?e:Error(String(e))}async function Eo(e=globalThis.navigator){let t=e?.brave;try{return typeof t?.isBrave==`function`&&await t.isBrave()===!0}catch{return!1}}var Do=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,Oo=()=>matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0,ko=y(null),Ao=e(Oo());window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),ko.value=e}),window.addEventListener(`appinstalled`,()=>{ko.value=null,Ao.value=!0});async function jo(){let e=ko.value;if(!e)return!1;await e.prompt();let{outcome:t}=await e.userChoice;return ko.value=null,t===`accepted`}var Mo=null;function No(){return`serviceWorker`in navigator?(Mo??=navigator.serviceWorker.register(`/sw.js`,{scope:`/`}).catch(()=>null),Mo):Promise.resolve(null)}function Po(){return window.isSecureContext?`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window?`supported`:Do&&!Oo()?`needs-install`:`unsupported`:`insecure`}async function Fo(){let e=await No();return e?e.pushManager.getSubscription():null}function Io(e){let t=(e+`===`.slice((e.length+3)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t);return Uint8Array.from(n,e=>e.charCodeAt(0))}async function Lo(e,t){let n=await Notification.requestPermission();if(n!==`granted`)throw Error(n===`denied`?`Notifications are blocked for this site in your browser settings.`:`Permission was not granted.`);let r=await No();if(!r)throw Error(`Service worker unavailable.`);let{publicKey:i}=await e(`/push/key`),a=await r.pushManager.getSubscription();if(!a)try{a=await r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Io(i)})}catch(e){throw To(e,await Eo())}return await e(`/push/subscribe`,`POST`,{subscription:a.toJSON(),prefs:t}),a}async function Ro(e,t,n){await e(`/push/subscribe`,`POST`,{subscription:t.toJSON(),prefs:n})}async function zo(e){let t=await Fo();t&&(await e(`/push/unsubscribe`,`POST`,{endpoint:t.endpoint}).catch(()=>{}),await t.unsubscribe().catch(()=>{}))}function Bo(e){let t=navigator;t.setAppBadge&&(e>0?t.setAppBadge(e):t.clearAppBadge?.())?.catch(()=>{})}function Vo(e){let t=document.querySelector(`link[rel="icon"][data-status]`);t||(document.querySelectorAll(`link[rel="icon"]`).forEach(e=>e.remove()),t=document.createElement(`link`),t.rel=`icon`,t.type=`image/png`,t.dataset.status=``,document.head.appendChild(t));let n=`/icons/favicon${e?`-`+e:``}-64.png`;t.getAttribute(`href`)!==n&&t.setAttribute(`href`,n)}var Ho={class:`page`},Uo={class:`page-head`},Wo={class:`page-body`},Go={class:`card`},Ko={class:`card-row`},qo={class:`setting-icon`},Jo={class:`segmented segmented-sm`,role:`radiogroup`,"aria-label":`Theme`},Yo=[`aria-checked`,`onClick`],Xo={class:`card-row palette-row`},Zo={class:`setting-icon`},Qo={class:`grow`},$o={class:`palette-grid`,role:`radiogroup`,"aria-label":`Colour palette`},es=[`aria-checked`,`onClick`],ts={class:`palette-swatch`},ns={class:`palette-text`},rs={class:`palette-name`},is={class:`row-sub`},as={class:`card`},os={class:`card-row`},ss={class:`setting-icon`},cs={class:`grow`},ls={class:`row-sub`},us=[`disabled`],ds=[`disabled`],fs={class:`card-row switch-row`},ps=[`disabled`],ms={class:`card-row switch-row`},hs=[`disabled`],gs={class:`card-row`},_s=[`disabled`],vs={key:0,class:`setting-note`},ys={key:1,class:`setting-note is-error`},bs={class:`card`},xs={class:`card-row`},Ss={class:`setting-icon`},Cs={class:`grow`},ws={class:`row-sub`},Ts=[`disabled`],Es={class:`field`},Ds={class:`field`},Os=[`placeholder`,`required`],ks={class:`field-grid`},As={class:`field`},js={class:`field`},Ms={class:`field`},Ns={class:`form-actions`},Ps=[`disabled`],Fs=[`disabled`],Is=[`disabled`],Ls={key:2,class:`setting-note`},Rs={key:3,class:`setting-note is-error`},zs={class:`card`},Bs={class:`card-row`},Vs={class:`setting-icon`},Hs={class:`grow`},Us={class:`row-sub`},Ws=[`disabled`],Gs={class:`card`},Ks={class:`card-row`},qs={class:`setting-icon`},Js={class:`grow`},Ys={class:`row-sub`},Xs=[`disabled`],Zs={key:0,class:`card-row totp-setup`},Qs=[`src`],$s={class:`grow`},ec={class:`secret`},tc=[`disabled`],nc={key:1,class:`card-row`},rc=[`disabled`],ic={key:4,class:`setting-note is-error`},ac={class:`card`},oc={class:`setting-icon`},sc={class:`grow`},cc={class:`row-title`},lc={key:0,class:`pill pill-current`},uc={class:`row-sub`},dc=[`disabled`,`onClick`],fc={key:0,class:`card-row row-sub`},pc={class:`form-actions spaced`},mc=[`disabled`],hc=f({__name:`Settings`,props:{request:{type:Function},totpEnabled:{type:Boolean}},emits:[`back`,`signedOut`,`totpChanged`,`dictationChanged`],setup(n,{emit:r}){let o=n,s=r,l=e(null),u=e({baseUrl:``,apiKey:``,model:``,languages:``,keywords:``}),f=(e,t)=>e.split(t).map(e=>e.trim()).filter(Boolean),p=e(!1),m=e(!1),y=e(``),C=e(``);function w(e){l.value=e,u.value={baseUrl:e.baseUrl,apiKey:``,model:e.model,languages:e.languages.join(`, `),keywords:e.keywords.join(`
30
+ `)},s(`dictationChanged`,e.configured)}async function T(e){m.value=!0,y.value=C.value=``;try{await e()}catch(e){y.value=e.message}finally{m.value=!1}}let E=()=>T(async()=>{let e=u.value;w(await o.request(`/dictation`,`PUT`,{baseUrl:e.baseUrl,apiKey:e.apiKey,model:e.model,languages:f(e.languages,/[,\s]+/),keywords:f(e.keywords,/[,\n]+/)})),p.value=!1,C.value=`Saved. The microphone button is in the composer.`}),O=()=>T(async()=>{confirm(`Remove the transcription service? Voice input turns off on every device.`)&&(w(await o.request(`/dictation`,`DELETE`)),p.value=!1)});function A(){l.value&&w(l.value),p.value=!1,y.value=``}let j=Po(),N=e(null),P=e({attention:!0,turns:!0}),I=e(typeof Notification>`u`?`default`:Notification.permission),L=e(!1),B=e(``),V=e(``);async function H(){if(j!==`supported`||(N.value=await Fo(),!N.value))return;let e=await o.request(`/push/status`,`POST`,{endpoint:N.value.endpoint});e.subscribed?P.value=e.prefs:N.value=null}async function U(e){L.value=!0,V.value=B.value=``;try{await e()}catch(e){V.value=e.message}finally{L.value=!1,I.value=typeof Notification>`u`?`default`:Notification.permission}}let W=()=>U(async()=>{N.value=await Lo(o.request,P.value),B.value=`Notifications are on for this device.`}),ee=()=>U(async()=>{await zo(o.request),N.value=null}),te=()=>U(async()=>{N.value&&await Ro(o.request,N.value,P.value)}),G=()=>U(async()=>{let{sent:e}=await o.request(`/push/test`,`POST`,{});B.value=e?`Test sent. It should arrive in a few seconds.`:`This device is not registered.`}),K=e(!1);async function ne(){K.value=!0;try{await jo()}finally{K.value=!1}}let q=e([]),re=e(null),ie=e(``),ae=e(``),oe=e(!1);async function se(){q.value=await o.request(`/sessions`)}async function ce(e){oe.value=!0,ae.value=``;try{await e()}catch(e){ae.value=e.message}finally{oe.value=!1}}let le=()=>ce(async()=>{re.value=await o.request(`/totp/setup`,`POST`,{}),ie.value=``}),ue=()=>ce(async()=>{await o.request(`/totp/confirm`,`POST`,{code:ie.value.trim()}),re.value=null,ie.value=``,s(`totpChanged`,!0)}),de=()=>ce(async()=>{await o.request(`/totp/disable`,`POST`,{code:ie.value.trim()}),ie.value=``,s(`totpChanged`,!1)}),fe=e=>ce(async()=>{await o.request(`/sessions/`+e.id,`DELETE`),e.current?s(`signedOut`):await se()}),pe=()=>ce(async()=>{confirm(`Sign out every device, including this one? Their notifications stop too.`)&&(await o.request(`/sessions/revoke-all`,`POST`,{}),s(`signedOut`))}),me=e=>{let t=Math.max(0,(Date.now()-e)/1e3);return t<90?`just now`:t<5400?`${Math.round(t/60)} min ago`:t<129600?`${Math.round(t/3600)} h ago`:`${Math.round(t/86400)} days ago`},he=S(()=>I.value===`denied`);return c(()=>{H().catch(()=>{}),se().catch(()=>{}),o.request(`/dictation`).then(w).catch(()=>{})}),(e,r)=>(i(),R(`section`,Ho,[x(`header`,Uo,[x(`button`,{class:`icon-btn back`,"aria-label":`Back`,onClick:r[0]||=e=>s(`back`)},[t(J,{name:`back`,size:18})]),r[12]||=x(`div`,null,[x(`h1`,null,`Settings`),x(`p`,{class:`subtle`},`Appearance, notifications, the app on your phone, and who can sign in.`)],-1)]),x(`div`,Wo,[r[29]||=x(`h2`,{class:`section-label`},`Appearance`,-1),x(`div`,Go,[x(`div`,Ko,[x(`span`,qo,[t(J,{name:`sun`,size:16})]),r[13]||=x(`div`,{class:`grow`},[x(`div`,{class:`row-title`},`Theme`)],-1),x(`div`,Jo,[(i(),R(b,null,z([`system`,`light`,`dark`],e=>x(`button`,{key:e,role:`radio`,"aria-checked":D(co)===e,class:M({chosen:D(co)===e}),onClick:t=>D(po)(e)},k(e===`system`?`System`:e===`light`?`Light`:`Dark`),11,Yo)),64))])]),x(`div`,Xo,[x(`span`,Zo,[t(J,{name:`sparkle`,size:16})]),x(`div`,Qo,[r[14]||=x(`div`,{class:`row-title`},`Colour`,-1),x(`div`,$o,[(i(!0),R(b,null,z(D(go),e=>(i(),R(`button`,{key:e.id,type:`button`,role:`radio`,class:M([`palette-option`,{chosen:D(vo)===e.id}]),"aria-checked":D(vo)===e.id,onClick:t=>D(xo)(e.id)},[x(`span`,ts,[x(`span`,{style:g({background:e.swatch[0]})},null,4),x(`span`,{style:g({background:e.swatch[1]})},null,4)]),x(`span`,ns,[x(`span`,rs,k(e.label),1),x(`span`,is,k(e.note),1)])],10,es))),128))])])])]),r[30]||=x(`h2`,{class:`section-label`},`Notifications`,-1),x(`div`,as,[x(`div`,os,[x(`span`,ss,[t(J,{name:`bell`,size:16})]),x(`div`,cs,[r[15]||=x(`div`,{class:`row-title`},`Push notifications`,-1),x(`div`,ls,[D(j)===`insecure`?(i(),R(b,{key:0},[d(`Needs HTTPS. Open the console through your tunnel's https:// address.`)],64)):D(j)===`needs-install`?(i(),R(b,{key:1},[d(`On iPhone and iPad, add LitePaseo to your Home Screen first, then open it from there.`)],64)):D(j)===`unsupported`?(i(),R(b,{key:2},[d(`This browser cannot receive push notifications.`)],64)):he.value?(i(),R(b,{key:3},[d(`Blocked in this browser's site settings. Allow notifications there, then return.`)],64)):N.value?(i(),R(b,{key:4},[d(`On for this device. Arrives even when the app is closed.`)],64)):(i(),R(b,{key:5},[d(`Get told when an agent needs you or a turn finishes, even with the app closed.`)],64))])]),D(j)===`supported`&&!N.value&&!he.value?(i(),R(`button`,{key:0,class:`btn btn-primary`,disabled:L.value,onClick:W},` Turn on `,8,us)):N.value?(i(),R(`button`,{key:1,class:`btn btn-outline`,disabled:L.value,onClick:ee},`Turn off`,8,ds)):F(``,!0)]),N.value?(i(),R(b,{key:0},[x(`label`,fs,[r[16]||=x(`div`,{class:`grow`},[x(`div`,{class:`row-title`},`When an agent needs your input`),x(`div`,{class:`row-sub`},`Permission requests and questions`)],-1),a(x(`input`,{"onUpdate:modelValue":r[1]||=e=>P.value.attention=e,class:`switch`,type:`checkbox`,disabled:L.value,onChange:te},null,40,ps),[[h,P.value.attention]])]),x(`label`,ms,[r[17]||=x(`div`,{class:`grow`},[x(`div`,{class:`row-title`},`When a turn finishes`),x(`div`,{class:`row-sub`},`Including failed turns`)],-1),a(x(`input`,{"onUpdate:modelValue":r[2]||=e=>P.value.turns=e,class:`switch`,type:`checkbox`,disabled:L.value,onChange:te},null,40,hs),[[h,P.value.turns]])]),x(`div`,gs,[r[18]||=x(`div`,{class:`grow row-sub`},`Not sent while you are viewing that conversation.`,-1),x(`button`,{class:`btn btn-outline`,disabled:L.value,onClick:G},`Send a test`,8,_s)])],64)):F(``,!0)]),B.value?(i(),R(`p`,vs,k(B.value),1)):F(``,!0),V.value?(i(),R(`p`,ys,k(V.value),1)):F(``,!0),r[31]||=x(`h2`,{class:`section-label`},`Voice input`,-1),x(`div`,bs,[x(`div`,xs,[x(`span`,Ss,[t(J,{name:`mic`,size:16})]),x(`div`,Cs,[r[19]||=x(`div`,{class:`row-title`},`Transcription service`,-1),x(`div`,ws,[l.value?.configured?(i(),R(b,{key:0},[d(k(l.value.model)+` · `+k(l.value.baseUrl.replace(/^https?:\/\//,``))+` · key `+k(l.value.keyHint)+k(l.value.languages.length?` · `+l.value.languages.join(`, `):``)+k(l.value.keywords.length?` · ${l.value.keywords.length} terms`:``),1)],64)):(i(),R(b,{key:1},[d(`Any OpenAI-compatible speech-to-text API. Set it once here and the microphone works for every host.`)],64))])]),p.value?F(``,!0):(i(),R(`button`,{key:0,class:`btn btn-outline`,disabled:m.value||!l.value,onClick:r[3]||=e=>p.value=!0},k(l.value?.configured?`Edit`:`Set up`),9,Ts))]),p.value?(i(),R(`form`,{key:0,class:`card-row voice-form`,onSubmit:v(E,[`prevent`])},[x(`label`,Es,[r[20]||=x(`span`,null,`Base URL`,-1),a(x(`input`,{"onUpdate:modelValue":r[4]||=e=>u.value.baseUrl=e,placeholder:`https://api.openai.com/v1`,autocomplete:`off`,spellcheck:`false`},null,512),[[_,u.value.baseUrl]])]),x(`label`,Ds,[r[21]||=x(`span`,null,`API key`,-1),a(x(`input`,{"onUpdate:modelValue":r[5]||=e=>u.value.apiKey=e,type:`password`,autocomplete:`off`,placeholder:l.value?.configured?`Unchanged (`+l.value.keyHint+`)`:`sk-…`,required:!l.value?.configured},null,8,Os),[[_,u.value.apiKey]])]),x(`div`,ks,[x(`label`,As,[r[22]||=x(`span`,null,`Model`,-1),a(x(`input`,{"onUpdate:modelValue":r[6]||=e=>u.value.model=e,placeholder:`gpt-transcribe`,autocomplete:`off`,spellcheck:`false`},null,512),[[_,u.value.model]])]),x(`label`,js,[r[23]||=x(`span`,null,`Languages`,-1),a(x(`input`,{"onUpdate:modelValue":r[7]||=e=>u.value.languages=e,placeholder:`Detect (or zh, en)`,maxlength:`80`,autocomplete:`off`,spellcheck:`false`},null,512),[[_,u.value.languages]])])]),x(`label`,Ms,[r[24]||=x(`span`,null,`Vocabulary`,-1),a(x(`textarea`,{"onUpdate:modelValue":r[8]||=e=>u.value.keywords=e,rows:`3`,placeholder:`LitePaseo
31
+ Claude Code
32
+ pnpm`,spellcheck:`false`},null,512),[[_,u.value.keywords]])]),r[25]||=x(`p`,{class:`row-sub`},` The key stays on this server; browsers never see it. List every language you mix while speaking. Vocabulary is names and terms to spell right, one per line. gpt-transcribe gets both as hints; Whisper-style models get one language and the terms as a prompt. `,-1),x(`div`,Ns,[l.value?.configured?(i(),R(`button`,{key:0,type:`button`,class:`btn btn-ghost voice-remove`,disabled:m.value,onClick:O},`Remove`,8,Ps)):F(``,!0),x(`button`,{type:`button`,class:`btn btn-ghost`,disabled:m.value,onClick:A},`Cancel`,8,Fs),x(`button`,{class:`btn btn-primary`,disabled:m.value},`Save`,8,Is)])],32)):F(``,!0)]),C.value?(i(),R(`p`,Ls,k(C.value),1)):F(``,!0),y.value?(i(),R(`p`,Rs,k(y.value),1)):F(``,!0),r[32]||=x(`h2`,{class:`section-label`},`App`,-1),x(`div`,zs,[x(`div`,Bs,[x(`span`,Vs,[t(J,{name:`phone`,size:16})]),x(`div`,Hs,[r[26]||=x(`div`,{class:`row-title`},`Install LitePaseo`,-1),x(`div`,Us,[D(Ao)?(i(),R(b,{key:0},[d(`Installed. You are using the app.`)],64)):D(ko)?(i(),R(b,{key:1},[d(`Full screen, its own icon, and notifications.`)],64)):D(Do)?(i(),R(b,{key:2},[d(`In Safari, tap Share, then “Add to Home Screen”.`)],64)):(i(),R(b,{key:3},[d(`Use your browser's menu: “Install app” or “Add to Home screen”.`)],64))])]),D(ko)&&!D(Ao)?(i(),R(`button`,{key:0,class:`btn btn-primary`,disabled:K.value,onClick:ne},`Install`,8,Ws)):F(``,!0)])]),r[33]||=x(`h2`,{class:`section-label`},`Sign-in`,-1),x(`div`,Gs,[x(`div`,Ks,[x(`span`,qs,[t(J,{name:`shield`,size:16})]),x(`div`,Js,[r[27]||=x(`div`,{class:`row-title`},`Authenticator code`,-1),x(`div`,Ys,k(n.totpEnabled?`On. Sign in with your access token and a 6-digit authenticator code.`:`Require an authenticator code in addition to your access token. Other browsers will need to sign in again.`),1)]),!n.totpEnabled&&!re.value?(i(),R(`button`,{key:0,class:`btn btn-outline`,disabled:oe.value,onClick:le},`Set up`,8,Xs)):F(``,!0)]),re.value?(i(),R(`div`,Zs,[x(`img`,{src:re.value.qr,alt:`Authenticator QR code`,width:`164`,height:`164`},null,8,Qs),x(`div`,$s,[r[28]||=x(`p`,{class:`row-sub`},`Scan with Google Authenticator, 1Password, Authy or similar. Or enter this key:`,-1),x(`code`,ec,k(re.value.secret.match(/.{1,4}/g)?.join(` `)),1),x(`form`,{class:`code-form`,onSubmit:v(ue,[`prevent`])},[a(x(`input`,{"onUpdate:modelValue":r[9]||=e=>ie.value=e,inputmode:`numeric`,autocomplete:`one-time-code`,maxlength:`6`,placeholder:`123456`,"aria-label":`Code from your app`},null,512),[[_,ie.value]]),x(`button`,{class:`btn btn-primary`,disabled:oe.value||ie.value.trim().length!==6},`Turn on`,8,tc),x(`button`,{type:`button`,class:`btn btn-ghost`,onClick:r[10]||=e=>re.value=null},`Cancel`)],32)])])):F(``,!0),n.totpEnabled?(i(),R(`div`,nc,[x(`form`,{class:`code-form grow`,onSubmit:v(de,[`prevent`])},[a(x(`input`,{"onUpdate:modelValue":r[11]||=e=>ie.value=e,inputmode:`numeric`,autocomplete:`one-time-code`,maxlength:`6`,placeholder:`Current code`,"aria-label":`Current code`},null,512),[[_,ie.value]]),x(`button`,{class:`btn btn-outline`,disabled:oe.value||ie.value.trim().length!==6},`Turn off`,8,rc)],32)])):F(``,!0)]),ae.value?(i(),R(`p`,ic,k(ae.value),1)):F(``,!0),r[34]||=x(`h2`,{class:`section-label`},`Signed-in devices`,-1),x(`div`,ac,[(i(!0),R(b,null,z(q.value,e=>(i(),R(`div`,{key:e.id,class:`card-row`},[x(`span`,oc,[t(J,{name:/iOS|Android/.test(e.label)?`phone`:`monitor`,size:16},null,8,[`name`])]),x(`div`,sc,[x(`div`,cc,[d(k(e.label),1),e.current?(i(),R(`span`,lc,`This device`)):F(``,!0)]),x(`div`,uc,`Active `+k(me(e.lastSeen))+` · signed in `+k(new Date(e.created).toLocaleDateString()),1)]),x(`button`,{class:`btn btn-outline`,disabled:oe.value,onClick:t=>fe(e)},k(e.current?`Sign out`:`Revoke`),9,dc)]))),128)),q.value.length?F(``,!0):(i(),R(`div`,fc,`Signed in with the access token only.`))]),x(`div`,pc,[x(`button`,{class:`btn btn-ghost`,disabled:oe.value,onClick:pe},`Sign out everywhere`,8,mc)])])]))}}),gc={class:`agent-board`},_c=[`title`],vc={class:`count`},yc=[`onClick`,`onKeydown`],bc={class:`task-top`},xc={class:`task-title`},Sc={class:`task-meta`},Cc=[`onClick`],wc=[`disabled`,`onClick`],Tc=[`disabled`,`onClick`],Ec=[`disabled`,`onClick`],Dc=[`onClick`],Oc={key:1,class:`column-empty`},kc=40,Ac=f({__name:`AgentBoard`,props:{store:{},hostLabels:{},busy:{type:Boolean}},emits:[`open`,`stop`,`read`,`archive`],setup(e,{emit:n}){let r=e,a=n,o={needs_input:`Needs you`,running:`Running`,review:`To review`,done:`Done`},s={needs_input:`Waiting on a permission or an answer`,running:`Working right now`,review:`Finished or failed, not looked at yet`,done:`Seen and settled`},c=u({needs_input:kc,running:kc,review:kc,done:kc}),l=S(()=>(r.store.version.value,G.map(e=>({lane:e,size:r.store.laneSize(e),agents:r.store.laneRange(e,0,c[e])})))),f=e=>{if(!e||e<15778368e5)return``;let t=Math.max(0,(Date.now()-e)/1e3);return t<60?`just now`:t<3600?`${Math.round(t/60)} min ago`:t<86400?`${Math.round(t/3600)} h ago`:`${Math.round(t/86400)} d ago`},p=e=>{if(e.state===`needs_input`){let t=e.pendingPermissions[0];return t?`${t.kind===`question`?`Asks:`:`Wants to`} ${ne(t.title||t.name)}`:`Waiting for you`}return e.state===`failed`?e.lastError||`Turn failed`:e.state===`running`?`Working…`:e.state===`unread`?`Finished ${f(e.activityAt)}`:f(e.activityAt)};return(n,r)=>(i(),R(`div`,gc,[(i(!0),R(b,null,z(l.value,n=>(i(),R(`section`,{key:n.lane,class:M([`lane`,`lane-`+n.lane])},[x(`header`,{class:`lane-head`,title:s[n.lane]},[r[1]||=x(`span`,{class:`lane-dot`},null,-1),x(`h3`,null,k(o[n.lane]),1),x(`span`,vc,k(n.size),1)],8,_c),(i(!0),R(b,null,z(n.agents,n=>(i(),R(`article`,{key:n.key,class:M([`task-card`,`is-`+n.state]),tabindex:`0`,onClick:e=>a(`open`,n.key),onKeydown:P(e=>a(`open`,n.key),[`enter`])},[x(`div`,bc,[x(`span`,{class:M([`status-dot`,`is-`+(n.state===`needs_input`?`attention`:n.state===`failed`?`error`:n.state)])},null,2),x(`span`,xc,k(n.title||`Untitled session`),1)]),x(`div`,Sc,k(n.project)+` · `+k(e.hostLabels.get(n.hostId)??`?`)+` · `+k(n.provider),1),x(`div`,{class:M([`task-detail`,{"is-error":n.state===`failed`}])},k(p(n)),3),x(`div`,{class:`task-actions`,onClick:r[0]||=v(()=>{},[`stop`])},[n.state===`needs_input`?(i(),R(`button`,{key:0,class:`btn btn-primary btn-sm`,onClick:e=>a(`open`,n.key)},`Respond`,8,Cc)):F(``,!0),n.state===`running`?(i(),R(`button`,{key:1,class:`btn btn-outline btn-sm`,disabled:e.busy,onClick:e=>a(`stop`,n)},[t(J,{name:`stop`,size:11}),r[2]||=d(`Stop `,-1)],8,wc)):F(``,!0),n.unread?(i(),R(`button`,{key:2,class:`btn btn-outline btn-sm`,disabled:e.busy,onClick:e=>a(`read`,n)},[t(J,{name:`check`,size:12}),r[3]||=d(`Mark read `,-1)],8,Tc)):F(``,!0),n.state!==`running`&&n.state!==`needs_input`?(i(),R(`button`,{key:3,class:`btn btn-ghost btn-sm`,disabled:e.busy,onClick:e=>a(`archive`,n)},` Archive `,8,Ec)):F(``,!0)])],42,yc))),128)),n.size>c[n.lane]?(i(),R(`button`,{key:0,class:`btn btn-ghost lane-more`,onClick:e=>c[n.lane]+=kc},` Show `+k(Math.min(kc,n.size-c[n.lane]))+` more `,9,Dc)):F(``,!0),n.size?F(``,!0):(i(),R(`p`,Oc,`Nothing here`))],2))),128))]))}}),jc={key:0,class:`usage`},Mc=[`aria-expanded`],Nc={class:`usage-name`},Pc={key:0,class:`usage-card`,role:`dialog`,"aria-label":`Usage limits`},Fc=[`disabled`],Ic={key:0,class:`spinner spinner-sm`},Lc={class:`usage-account-head`},Rc={class:`row-title`},zc={class:`row-sub`},Bc={key:0,class:`row-sub is-error`},Vc={class:`usage-window-head`},Hc={class:`usage-bar`},Uc={class:`usage-window-foot`},Wc={class:`usage-foot`},Gc=f({__name:`UsagePanel`,props:{report:{},loading:{type:Boolean}},emits:[`refresh`],setup(n,{emit:r}){let a=n,o=r,s=e(!1);function c(e){let t=`${e.shortLabel??``} ${e.label}`.toLowerCase();return/5\s*h|5-hour|five/.test(t)?18e6:/wk|week/.test(t)?6048e5:/month|mo\b/.test(t)?2592e6:null}function l(e){let t=c(e);if(e.remainingPct===null||!e.resetsAt||!t)return null;let n=Date.parse(e.resetsAt)-Date.now(),r=t<=18e6?36e5:864e5;if(n<=r)return null;let i=e.remainingPct/(n/r),a=i/(100/(t/r));return{text:`${i.toFixed(+(i<10))}% per ${r===36e5?`hour`:`day`}`,tone:a>=.85?`ok`:a>=.5?`warning`:`danger`}}function u(e){return e.remainingPct===null?`default`:e.remainingPct<10?`danger`:e.remainingPct<30?`warning`:`ok`}function f(e){if(!e.resetsAt)return``;let t=new Date(e.resetsAt),n=t.getTime()-Date.now();if(n<=0)return`resetting`;let r=new Date,i=new Date(r.getTime()+864e5),a=t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),o=t.toDateString()===r.toDateString()?`today`:t.toDateString()===i.toDateString()?`tomorrow`:t.toLocaleDateString([],{weekday:`short`,month:`numeric`,day:`numeric`}),s=Math.floor(n/36e5),c=Math.round(n%36e5/6e4);return`${o} ${a} · in ${s>=24?`${Math.floor(s/24)}d ${s%24}h`:s?`${s}h ${c}m`:`${c}m`}`}let p=S(()=>a.report?.accounts.filter(e=>e.windows.length||e.error)??[]),h=e=>e.shortLabel??e.label;return(e,r)=>p.value.length?(i(),R(`div`,jc,[x(`button`,{class:`usage-summary`,"aria-expanded":s.value,onClick:r[0]||=e=>s.value=!s.value},[(i(!0),R(b,null,z(p.value,e=>(i(),R(`span`,{key:e.key,class:`usage-line`},[x(`span`,Nc,k(e.name),1),(i(!0),R(b,null,z(e.windows.slice(0,3),e=>(i(),R(`span`,{key:e.id,class:M([`usage-pct`,`tone-`+u(e)])},[d(k(e.remainingPct===null?`—`:Math.round(e.remainingPct)+`%`),1),x(`small`,null,k(h(e)),1)],2))),128))]))),128))],8,Mc),s.value?(i(),R(`div`,Pc,[x(`header`,null,[r[3]||=x(`strong`,null,`Usage left`,-1),x(`button`,{class:`icon-btn`,disabled:n.loading,title:`Refresh`,"aria-label":`Refresh usage`,onClick:r[1]||=e=>o(`refresh`)},[n.loading?(i(),R(`span`,Ic)):(i(),m(J,{key:1,name:`refresh`,size:14}))],8,Fc),x(`button`,{class:`icon-btn`,"aria-label":`Close`,onClick:r[2]||=e=>s.value=!1},[t(J,{name:`close`,size:14})])]),(i(!0),R(b,null,z(p.value,e=>(i(),R(`section`,{key:e.key,class:`usage-account`},[x(`div`,Lc,[x(`span`,Rc,k(e.name),1),x(`span`,zc,k([e.plan,e.hosts.join(`, `)].filter(Boolean).join(` · `)),1)]),e.error?(i(),R(`p`,Bc,k(e.error),1)):F(``,!0),(i(!0),R(b,null,z(e.windows,e=>(i(),R(`div`,{key:e.id,class:`usage-window`},[x(`div`,Vc,[x(`span`,null,k(e.label),1),x(`strong`,{class:M(`tone-`+u(e))},k(e.remainingPct===null?`—`:Math.round(e.remainingPct)+`% left`),3)]),x(`div`,Hc,[x(`span`,{class:M(`tone-`+u(e)),style:g({width:Math.max(0,Math.min(100,e.remainingPct??0))+`%`})},null,6)]),x(`div`,Uc,[x(`span`,null,k(f(e)),1),l(e)?(i(),R(`span`,{key:0,class:M(`tone-`+l(e).tone)},k(l(e).text),3)):F(``,!0)])]))),128))]))),128)),(i(!0),R(b,null,z(n.report?.unavailableHosts??[],e=>(i(),R(`p`,{key:e.hostId,class:`row-sub`},k(e.label)+`: `+k(e.error),1))),128)),x(`p`,Wc,` Updated `+k(n.report?.fetchedAt?new Date(n.report.fetchedAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):`—`)+` · hosts cache usage for 5 min `,1)])):F(``,!0)])):F(``,!0)}}),Kc=[`aria-label`],qc={class:`sheet-head task-head`},Jc={class:`sheet-body task-body`},Yc={class:`task-meta`},Xc=[`value`,`disabled`],Zc={class:`task-link`},Qc=[`title`],$c={class:`card-link-name`},el={key:1,class:`subtle small`},tl=[`value`,`disabled`],nl=[`value`],rl=[`value`],il={class:`task-section`},al={class:`task-actions`},ol=[`disabled`],sl=[`innerHTML`],cl={class:`task-section`},ll={key:0,class:`subtle`},ul={key:0,class:`task-comments`},dl={class:`task-comment-head`},fl={class:`subtle small`},pl=[`disabled`,`onClick`],ml=[`innerHTML`],hl={class:`task-actions`},gl=[`disabled`],_l={class:`sheet-foot task-foot`},vl={class:`subtle small`},yl=[`disabled`],bl=2e4,xl=5e3,Sl=f({__name:`TaskDialog`,props:{card:{},columns:{},links:{},linkedName:{},busy:{type:Boolean}},emits:[`close`,`patch`,`comment`,`uncomment`,`remove`,`open`],setup(r,{emit:o}){let s=r,c=o,l=e(s.card.title);n(()=>s.card.title,e=>l.value=e);function u(){let e=l.value.trim();e?e!==s.card.title&&c(`patch`,{title:e}):l.value=s.card.title}let f=e(!1),p=e(s.card.description??``),m=e(null);n(()=>s.card.description,e=>{f.value||(p.value=e??``)});let h=S(()=>Cr(s.card.description??``)),g=S(()=>f.value&&p.value!==(s.card.description??``));function y(){f.value=!0,C(()=>{M(m.value),m.value?.focus()})}function w(){g.value&&c(`patch`,{description:p.value}),f.value=!1}function T(){p.value=s.card.description??``,f.value=!1}let E=e(``),D=e(null);function O(){let e=E.value.trim();e&&!s.busy&&(c(`comment`,e),E.value=``,C(()=>M(D.value)))}function A(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),O())}function j(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),w()):e.key===`Escape`&&(e.stopPropagation(),T())}function M(e){e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,Math.round(window.innerHeight*.5))+`px`)}let N=S(()=>(s.card.comments??[]).map(e=>({...e,html:Cr(e.text),when:Rn(new Date(e.at))}))),I=S(()=>s.card.hostId&&s.card.agentId?`${s.card.hostId}:${s.card.agentId}`:``);function L(e){let[t,...n]=e.split(`:`);c(`patch`,{link:e?{hostId:t,agentId:n.join(`:`)}:null})}let B=S(()=>{let e=[];return s.card.createdAt&&e.push(`Created `+Rn(new Date(s.card.createdAt))),s.card.updatedAt&&e.push(`updated `+Rn(new Date(s.card.updatedAt))),e.join(` · `)});function V(){u(),g.value&&w(),(!E.value.trim()||confirm(`Discard the comment you started?`))&&c(`close`)}function H(){confirm(`Delete “${s.card.title}”? Its description and comments are deleted too.`)&&c(`remove`)}function U(e){confirm(`Delete this comment?`)&&c(`uncomment`,e)}return(e,n)=>(i(),R(`div`,{class:`overlay`,onMousedown:v(V,[`self`]),onKeydown:P(V,[`esc`])},[x(`section`,{class:`sheet task-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":`Task: `+r.card.title},[x(`header`,qc,[a(x(`input`,{"onUpdate:modelValue":n[0]||=e=>l.value=e,class:`task-title`,"aria-label":`Title`,maxlength:`300`,onBlur:u,onKeydown:n[1]||=P(v(e=>e.target.blur(),[`prevent`]),[`enter`])},null,544),[[_,l.value]]),x(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close`,onClick:V},[t(J,{name:`close`,size:16})])]),x(`div`,Jc,[x(`div`,Yc,[x(`select`,{value:r.card.column,"aria-label":`Column`,disabled:r.busy,onChange:n[2]||=e=>c(`patch`,{column:e.target.value})},[(i(!0),R(b,null,z(r.columns,e=>(i(),R(`option`,{key:e},k(e),1))),128))],40,Xc),x(`div`,Zc,[I.value&&r.linkedName?(i(),R(`button`,{key:0,type:`button`,class:`link-btn`,title:`Open `+r.linkedName,onClick:n[3]||=e=>c(`open`)},[t(J,{name:`chat`,size:13}),x(`span`,$c,k(r.linkedName),1)],8,Qc)):I.value?(i(),R(`span`,el,`Conversation unavailable`)):F(``,!0),x(`select`,{class:`card-link-select`,"aria-label":`Link to conversation`,value:I.value,disabled:r.busy,onChange:n[4]||=e=>L(e.target.value)},[n[10]||=x(`option`,{value:``},`No conversation`,-1),I.value&&!r.links.some(e=>e.key===I.value)?(i(),R(`option`,{key:0,value:I.value},k(r.linkedName??`Unavailable conversation`),9,nl)):F(``,!0),(i(!0),R(b,null,z(r.links,e=>(i(),R(`option`,{key:e.key,value:e.key},k(e.label),9,rl))),128))],40,tl)])]),x(`section`,il,[n[12]||=x(`h3`,null,`Description`,-1),f.value?(i(),R(b,{key:0},[a(x(`textarea`,{ref_key:`descriptionInput`,ref:m,"onUpdate:modelValue":n[5]||=e=>p.value=e,class:`task-textarea`,"aria-label":`Description`,maxlength:bl,placeholder:`Markdown: what this task is, notes, checklists…`,onInput:n[6]||=e=>M(e.target),onKeydown:j},null,544),[[_,p.value]]),x(`div`,al,[n[11]||=x(`span`,{class:`subtle small`},`Markdown · ⌘/Ctrl+Enter to save`,-1),x(`button`,{type:`button`,class:`btn btn-ghost`,onClick:T},`Cancel`),x(`button`,{type:`button`,class:`btn btn-primary`,disabled:r.busy,onClick:w},`Save`,8,ol)])],64)):r.card.description?(i(),R(`div`,{key:2,class:`prose task-description`,role:`button`,tabindex:`0`,title:`Click to edit`,onClick:n[7]||=e=>e.target.closest(`a`)||y(),onKeydown:P(y,[`enter`]),innerHTML:h.value},null,40,sl)):(i(),R(`button`,{key:1,type:`button`,class:`task-empty`,onClick:y},`Add a description…`))]),x(`section`,cl,[x(`h3`,null,[n[13]||=d(`Comments `,-1),N.value.length?(i(),R(`span`,ll,k(N.value.length),1)):F(``,!0)]),N.value.length?(i(),R(`ol`,ul,[(i(!0),R(b,null,z(N.value,e=>(i(),R(`li`,{key:e.id,class:`task-comment`},[x(`div`,dl,[x(`span`,fl,k(e.when),1),x(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Delete comment`,title:`Delete comment`,disabled:r.busy,onClick:t=>U(e.id)},[t(J,{name:`trash`,size:13})],8,pl)]),x(`div`,{class:`prose`,innerHTML:e.html},null,8,ml)]))),128))])):F(``,!0),x(`form`,{class:`task-new-comment`,onSubmit:v(O,[`prevent`])},[a(x(`textarea`,{ref_key:`commentInput`,ref:D,"onUpdate:modelValue":n[8]||=e=>E.value=e,class:`task-textarea`,rows:`2`,"aria-label":`New comment`,maxlength:xl,placeholder:`Write a comment… (Markdown, ⌘/Ctrl+Enter to post)`,onInput:n[9]||=e=>M(e.target),onKeydown:A},null,544),[[_,E.value]]),x(`div`,hl,[x(`button`,{class:`btn btn-primary`,disabled:r.busy||!E.value.trim()},`Comment`,8,gl)])],32)])]),x(`footer`,_l,[x(`span`,vl,k(B.value),1),x(`button`,{type:`button`,class:`btn btn-ghost task-delete`,disabled:r.busy,onClick:H},[t(J,{name:`trash`,size:14}),n[14]||=d(`Delete task`,-1)],8,yl)])],8,Kc)],32))}});function Cl(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=String(t%60).padStart(2,`0`);return n?`${n}:${String(r).padStart(2,`0`)}:${i}`:`${r}:${i}`}var wl={key:0,class:`icon provider-icon`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.25`,"stroke-linejoin":`round`,"aria-hidden":`true`},Tl=[`transform`],El={key:1,class:`icon provider-icon`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},Dl={key:2,class:`icon provider-icon`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"aria-hidden":`true`},Ol=[`transform`],kl=f({__name:`ProviderIcon`,props:{provider:{}},setup(e){let t=e,n=S(()=>t.provider.toLowerCase());return(e,t)=>n.value===`codex`||n.value===`openai`?(i(),R(`svg`,wl,[(i(),R(b,null,z([0,60,120,180,240,300],e=>x(`path`,{key:e,transform:`rotate(${e} 12 12)`,d:`M12 3.2C14.3 1.8 17.4 3 18.1 5.5L18.1 12.4L12 15.9L8.6 13.9V7.1L14.5 3.7`},null,8,Tl)),64))])):n.value===`pi`?(i(),R(`svg`,El,[...t[0]||=[x(`path`,{d:`M3 7c2-2 3-2 5-2h13M8 5v8c0 3-1 5-3 6M16 5v11c0 3 3 3 4 1`},null,-1)]])):n.value===`claude`||n.value===`anthropic`?(i(),R(`svg`,Dl,[(i(),R(b,null,z([0,30,60,90,120,150],e=>x(`path`,{key:e,transform:`rotate(${e} 12 12)`,d:`M12 3v18`},null,8,Ol)),64))])):(i(),m(J,{key:3,name:n.value===`gemini`?`sparkle`:`bot`,size:18,class:`provider-icon`},null,8,[`name`]))}}),Al={class:`agent-controls`},jl=[`title`],Ml={class:`chip-text`},Nl=[`disabled`,`value`],Pl=[`value`],Fl=[`value`],Il=[`title`],Ll={class:`chip-text`},Rl=[`disabled`,`value`],zl=[`value`],Bl=[`title`],Vl={class:`chip-text`},Hl=[`disabled`,`value`],Ul={key:0,value:``,disabled:``},Wl=[`value`,`title`],Gl=[`aria-label`,`aria-pressed`,`title`,`disabled`,`onClick`],Kl={key:0,class:`chip-text`},ql=[`title`],Jl={key:1,class:`chip-text`},Yl={class:`chip-key`},Xl=[`aria-label`,`disabled`,`value`,`onChange`],Zl=[`value`],Ql=[`title`,`aria-label`],$l={width:`18`,height:`18`,viewBox:`0 0 18 18`,"aria-hidden":`true`},eu=[`stroke-dasharray`],tu=3e5,nu=La(f({__name:`AgentControls`,props:{agent:{},path:{},api:{type:Function},disabled:{type:Boolean}},emits:[`notice`],setup(r,{expose:a,emit:o}){let s=r,c=o,l=new Map,u=e(null),f=e({});async function p(e=!1){let t=s.agent.key,n=l.get(t);if(!e&&n&&Date.now()-n.at<tu)u.value=n.options;else try{let e=await s.api(s.path+`/config`);l.set(t,{at:Date.now(),options:e}),s.agent.key===t&&(u.value=e)}catch{s.agent.key===t&&(u.value=n?.options??null)}}n(()=>s.agent.key,()=>{u.value=l.get(s.agent.key)?.options??null,f.value={},p()},{immediate:!0});let h=S(()=>f.value.model??s.agent.model??null),g=S(()=>u.value?.models.find(e=>e.id===h.value)??null),_=S(()=>g.value?.label??(h.value?h.value.split(`/`).pop():`Model`));a({modelLabel:_});let v=S(()=>f.value.thinking??s.agent.thinking??g.value?.defaultThinkingId??null),y=S(()=>g.value?.thinking??[]),C=S(()=>y.value.find(e=>e.id===v.value)?.label??v.value??``),w=S(()=>f.value.mode??s.agent.modeId??null),T=S(()=>u.value?.modes??[]),E=S(()=>T.value.find(e=>e.id===w.value)?.label??`Mode`),D=S(()=>/full|bypass|danger|unrestricted/i.test(`${w.value} ${E.value}`)),O=e=>/^(plan|plan[-_ ]?mode)$/i.test(e.id)||/^plan(?: mode)?$/i.test(e.label),A=e=>/fast|speed/i.test(`${e.id} ${e.label}`),j=S(()=>(u.value?.features??[]).filter(e=>!O(e)).map(e=>{let t=f.value[`feature:`+e.id]??e.value;return e.type===`toggle`?{...e,value:t}:{...e,value:t,current:e.options.find(e=>e.id===t)?.label??``}}));n(()=>[s.agent.model,s.agent.thinking,s.agent.modeId],()=>{let e={...f.value};e.model===s.agent.model&&delete e.model,e.thinking===s.agent.thinking&&delete e.thinking,e.mode===s.agent.modeId&&delete e.mode,f.value=e});async function N(e,t,n){let r=f.value[e];f.value={...f.value,[e]:n};try{let n=(await s.api(s.path+`/config`,`POST`,t))?.notice;if(n?.message&&c(`notice`,n.message),e.startsWith(`feature:`)){l.delete(s.agent.key),await p(!0);let t={...f.value};delete t[e],f.value=t}}catch(t){if(f.value={...f.value,[e]:r},r===void 0){let t={...f.value};delete t[e],f.value=t}c(`notice`,t.message)}}let P=e=>e.target.value,I=S(()=>{let e=s.agent.contextUsed??0,t=s.agent.contextMax??0;if(!e||!t)return null;let n=Math.min(1,e/t),r=e=>e>=1e6?`${(e/1e6).toFixed(e%1e6?1:0)}M`:`${Math.round(e/1e3)}k`;return{ratio:n,percent:Math.round(n*100),title:`Context window: ${r(e)} of ${r(t)} tokens used`}}),L=2*Math.PI*7;return(e,n)=>(i(),R(`div`,Al,[x(`label`,{class:M([`chip`,{"is-disabled":r.disabled||!u.value?.models.length}]),title:r.agent.provider+` · Model: `+_.value},[t(kl,{provider:r.agent.provider},null,8,[`provider`]),x(`span`,Ml,k(_.value),1),t(J,{name:`chevron`,size:11,class:`chip-caret`}),x(`select`,{"aria-label":`Model`,disabled:r.disabled||!u.value?.models.length,value:h.value??``,onChange:n[0]||=e=>N(`model`,{model:P(e)},P(e))},[h.value&&!g.value?(i(),R(`option`,{key:0,value:h.value},k(_.value),9,Pl)):F(``,!0),(i(!0),R(b,null,z(u.value?.models??[],e=>(i(),R(`option`,{key:e.id,value:e.id},k(e.label),9,Fl))),128))],40,Nl)],10,jl),y.value.length?(i(),R(`label`,{key:0,class:M([`chip`,{"is-disabled":r.disabled}]),title:`Thinking: `+C.value},[t(J,{name:`brain`,size:18}),x(`span`,Ll,k(C.value),1),t(J,{name:`chevron`,size:11,class:`chip-caret`}),x(`select`,{"aria-label":`Thinking`,disabled:r.disabled,value:v.value??``,onChange:n[1]||=e=>N(`thinking`,{thinkingOptionId:P(e)},P(e))},[(i(!0),R(b,null,z(y.value,e=>(i(),R(`option`,{key:e.id,value:e.id},k(e.label),9,zl))),128))],40,Rl)],10,Il)):F(``,!0),T.value.length?(i(),R(`label`,{key:1,class:M([`chip`,{"is-disabled":r.disabled}]),title:`Mode: `+E.value},[t(J,{name:D.value?`shield-off`:`shield`,size:18},null,8,[`name`]),x(`span`,Vl,k(E.value),1),t(J,{name:`chevron`,size:11,class:`chip-caret`}),x(`select`,{"aria-label":`Mode`,disabled:r.disabled,value:w.value??``,onChange:n[2]||=e=>N(`mode`,{modeId:P(e)},P(e))},[w.value?F(``,!0):(i(),R(`option`,Ul,`Mode`)),(i(!0),R(b,null,z(T.value,e=>(i(),R(`option`,{key:e.id,value:e.id,title:e.description},k(e.label),9,Wl))),128))],40,Hl)],10,Bl)):F(``,!0),(i(!0),R(b,null,z(j.value,e=>(i(),R(b,{key:e.id},[e.type===`toggle`?(i(),R(`button`,{key:0,type:`button`,class:M([`chip chip-toggle`,{chosen:e.value,"chip-icon-only":A(e)}]),"aria-label":e.label,"aria-pressed":e.value,title:e.tooltip??e.label,disabled:r.disabled,onClick:t=>N(`feature:`+e.id,{feature:{id:e.id,value:!e.value}},!e.value)},[t(J,{name:A(e)?`bolt`:`sliders`,size:18},null,8,[`name`]),A(e)?F(``,!0):(i(),R(`span`,Kl,k(e.label),1))],10,Gl)):(i(),R(`label`,{key:1,class:M([`chip`,{"is-disabled":r.disabled,"chip-icon-only":A(e),chosen:A(e)&&e.value===`fast`}]),title:[e.label,e.current,e.tooltip].filter(Boolean).join(` · `)},[A(e)?(i(),m(J,{key:0,name:`bolt`,size:18})):F(``,!0),A(e)?F(``,!0):(i(),R(`span`,Jl,[x(`span`,Yl,k(e.label)+`:`,1),d(` `+k(e.current||`Default`),1)])),A(e)?F(``,!0):(i(),m(J,{key:2,name:`chevron`,size:11,class:`chip-caret`})),x(`select`,{"aria-label":e.label,disabled:r.disabled,value:e.value??``,onChange:t=>N(`feature:`+e.id,{feature:{id:e.id,value:P(t)}},P(t))},[(i(!0),R(b,null,z(e.options,e=>(i(),R(`option`,{key:e.id,value:e.id},k(e.label),9,Zl))),128))],40,Xl)],10,ql))],64))),128)),I.value?(i(),R(`span`,{key:2,class:M([`context-gauge`,{"is-high":I.value.ratio>=.8}]),title:I.value.title,role:`img`,"aria-label":I.value.title},[(i(),R(`svg`,$l,[n[3]||=x(`circle`,{cx:`9`,cy:`9`,r:`7`,class:`context-track`},null,-1),x(`circle`,{cx:`9`,cy:`9`,r:`7`,class:`context-fill`,"stroke-dasharray":`${L*I.value.ratio} ${L}`,transform:`rotate(-90 9 9)`},null,8,eu)])),x(`span`,null,k(I.value.percent)+`%`,1)],10,Ql)):F(``,!0)]))}}),[[`__scopeId`,`data-v-d1984eb2`]]),ru={class:`page`},iu={class:`page-head`},au=[`disabled`],ou={class:`page-body`},su={key:0,class:`setting-note is-error`},cu={class:`row-title`},lu={key:0,class:`field-grid`},uu={class:`field`},du=[`disabled`,`title`],fu=[`value`],pu={class:`field`},mu=[`disabled`],hu=[`value`],gu={class:`field`},_u=[`disabled`],vu=[`value`],yu={class:`field`},bu=[`disabled`],xu=[`value`],Su={class:`field`},Cu={class:`field`},wu={class:`field-grid`},Tu={class:`field`},Eu={key:0,class:`field`},Du=[`value`],Ou={key:1,class:`field`},ku={key:2,class:`field`},Au={class:`subtle small`},ju={key:1,class:`check-row`},Mu={key:2,class:`check-row`},Nu={class:`form-actions`},Pu=[`disabled`],Fu={key:2,class:`timeline-empty`},Iu={key:3,class:`schedules-empty`},Lu={key:4,class:`card`},Ru={class:`card-row`},zu={class:`grow`},Bu={class:`row-title`},Vu={class:`row-sub`},Hu={class:`row-sub`},Uu={key:1,class:`schedule-status`},Wu={class:`schedule-actions`},Gu=[`disabled`,`onClick`],Ku=[`disabled`,`onClick`],qu=[`disabled`,`onClick`],Ju=[`disabled`,`onClick`],Yu=[`aria-expanded`,`onClick`],Xu=[`disabled`,`onClick`],Zu={key:0,class:`schedule-runs`},Qu={class:`schedule-prompt`},$u={key:0,class:`subtle small`},ed={class:`run-when`},td={class:`run-text`},nd=[`onClick`],rd=La(f({__name:`SchedulesPage`,props:{hosts:{},api:{type:Function}},emits:[`back`,`openAgent`],setup(r,{emit:o}){let s=r,l=o,u=e(null),f=e(``),p=e(null),m=e=>s.hosts.find(t=>t.id===e)?.label??`Unknown host`;async function g(){try{u.value=await s.api(`/schedules`),f.value=``}catch(e){f.value=e.message}}c(g);let y=S(()=>(u.value??[]).flatMap(e=>e.schedules.map(t=>({hostId:e.hostId,s:t})))),w=S(()=>(u.value??[]).filter(e=>e.error));async function T(e,t,n){if(n!==`delete`||confirm(`Delete the schedule “${t.name||t.prompt.slice(0,40)}”?`)){p.value=t.id;try{await s.api(`/hosts/${encodeURIComponent(e)}/schedules/${encodeURIComponent(t.id)}${n===`delete`?``:`/`+n}`,n===`delete`?`DELETE`:`POST`),await g()}catch(e){f.value=e.message}finally{p.value=null}}}let E=e(null),D=e([]);async function O(e,t){if(E.value===t.id)return E.value=null;E.value=t.id,D.value=[];try{D.value=(await s.api(`/hosts/${encodeURIComponent(e)}/schedules/${encodeURIComponent(t.id)}/logs`)).runs}catch(e){f.value=e.message}}let A=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`];function j(e){let[t,n,r,i,a]=e.trim().split(/\s+/),o=(e,t)=>`${e.padStart(2,`0`)}:${t.padStart(2,`0`)}`;if(/^\d+$/.test(t)&&/^\d+$/.test(n)&&r===`*`&&i===`*`){if(a===`*`)return`Every day at ${o(n,t)}`;if(a===`1-5`)return`Weekdays at ${o(n,t)}`;if(/^\d$/.test(a))return`Every ${A[Number(a)%7]} at ${o(n,t)}`}if(/^\d+$/.test(t)&&n===`*`&&r===`*`&&i===`*`&&a===`*`)return`Every hour at :${t.padStart(2,`0`)}`;let s=/^\*\/(\d+)$/.exec(t);return s&&n===`*`&&r===`*`&&i===`*`&&a===`*`?`Every ${s[1]} minutes`:e}let P=e=>e?Rn(new Date(e)):`—`,I=e(!1),B=e({hostId:``,cwd:``,provider:``,model:``,name:``,prompt:``,preset:`daily`,time:`09:00`,day:`1`,cron:`0 9 * * *`,archive:!0,runNow:!1}),V=e(null),H=e(null),U=S(()=>s.hosts.filter(e=>e.state===`connected`));n(()=>B.value.hostId,async e=>{if(V.value=H.value=null,e)try{let[t,n]=await Promise.all([s.api(`/hosts/${encodeURIComponent(e)}/providers`),s.api(`/hosts/${encodeURIComponent(e)}/projects`)]);V.value=t,H.value=n,B.value.provider||=t.find(e=>e.status===`ready`)?.id??t[0]?.id??``,B.value.cwd||=n[0]?.rootPath??``}catch(e){f.value=e.message}});let W=S(()=>{let e=H.value??[],t=B.value.cwd;return t&&!e.some(e=>e.rootPath===t)?[{key:t,name:t.split(`/`).pop()||t,rootPath:t,kind:`directory`},...e]:e}),ee=S(()=>V.value?.find(e=>e.id===B.value.provider)?.models??[]);n(ee,e=>{e.some(e=>e.id===B.value.model)||(B.value.model=e.find(e=>e.isDefault)?.id??e[0]?.id??``)});let te=S(()=>{let[e,t]=B.value.time.split(`:`).map(e=>String(Number(e)||0));return B.value.preset===`daily`?`${t} ${e} * * *`:B.value.preset===`weekdays`?`${t} ${e} * * 1-5`:B.value.preset===`weekly`?`${t} ${e} * * ${B.value.day}`:B.value.preset===`hourly`?`${t} * * * *`:B.value.cron.trim()}),G=e(null);function K(){G.value=null,I.value=!0,B.value.hostId||=U.value[0]?.id??``}function ne(e){let[t,n,r,i,a]=e.trim().split(/\s+/),o=(e,t)=>`${e.padStart(2,`0`)}:${t.padStart(2,`0`)}`,s=/^\d+$/.test(t)&&r===`*`&&i===`*`;return s&&/^\d+$/.test(n)&&a===`*`?{preset:`daily`,time:o(n,t)}:s&&/^\d+$/.test(n)&&a===`1-5`?{preset:`weekdays`,time:o(n,t)}:s&&/^\d+$/.test(n)&&/^\d$/.test(a)?{preset:`weekly`,time:o(n,t),day:String(Number(a)%7)}:s&&n===`*`&&a===`*`?{preset:`hourly`,time:o(`0`,t)}:{preset:`cron`,cron:e}}function q(e,t){let n=t.target.config??{};G.value={hostId:e,id:t.id,newAgent:t.target.type===`new-agent`},I.value=!0,B.value={...B.value,hostId:e,cwd:n.cwd??``,provider:n.provider??``,model:n.model??``,name:t.name??``,prompt:t.prompt,cron:t.cadence.expression,archive:n.archiveOnFinish??!0,runNow:!1,...ne(t.cadence.expression)},re.value=t.cadence.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone,E.value=null,C(()=>document.querySelector(`.schedule-form`)?.scrollIntoView({block:`nearest`}))}let re=e(Intl.DateTimeFormat().resolvedOptions().timeZone);function ie(){I.value=!1,G.value=null,re.value=Intl.DateTimeFormat().resolvedOptions().timeZone}async function ae(){if(!G.value)return oe();let{hostId:e,id:t,newAgent:n}=G.value;p.value=`create`;try{await s.api(`/hosts/${encodeURIComponent(e)}/schedules/${encodeURIComponent(t)}`,`PATCH`,{name:B.value.name||null,prompt:B.value.prompt,cron:te.value,timezone:re.value,...n?{cwd:B.value.cwd,provider:B.value.provider,model:B.value.model||null,archiveOnFinish:B.value.archive}:{}}),ie(),await g()}catch(e){f.value=e.message}finally{p.value=null}}async function oe(){p.value=`create`;try{await s.api(`/hosts/${encodeURIComponent(B.value.hostId)}/schedules`,`POST`,{name:B.value.name||void 0,prompt:B.value.prompt,cron:te.value,timezone:re.value,cwd:B.value.cwd,provider:B.value.provider,...B.value.model?{model:B.value.model}:{},archiveOnFinish:B.value.archive,runOnCreate:B.value.runNow}),I.value=!1,B.value.prompt=B.value.name=``,await g()}catch(e){f.value=e.message}finally{p.value=null}}return(e,n)=>(i(),R(`section`,ru,[x(`header`,iu,[x(`button`,{class:`icon-btn back`,"aria-label":`Back`,onClick:n[0]||=e=>l(`back`)},[t(J,{name:`back`,size:18})]),n[14]||=x(`div`,{class:`grow`},[x(`h1`,null,`Schedules`),x(`p`,{class:`subtle`},`Prompts that start an agent on a timetable, on each host.`)],-1),x(`button`,{class:`btn btn-primary`,disabled:!U.value.length,onClick:K},[t(J,{name:`plus`,size:15}),n[13]||=d(`New schedule`,-1)],8,au)]),x(`div`,ou,[f.value?(i(),R(`p`,su,k(f.value),1)):F(``,!0),(i(!0),R(b,null,z(w.value,e=>(i(),R(`p`,{key:e.hostId,class:`setting-note`},k(m(e.hostId))+`: `+k(e.error),1))),128)),I.value?(i(),R(`form`,{key:1,class:`card form-card schedule-form`,onSubmit:v(ae,[`prevent`])},[x(`div`,cu,k(G.value?`Edit schedule`:`New schedule`),1),!G.value||G.value.newAgent?(i(),R(`div`,lu,[x(`label`,uu,[n[15]||=x(`span`,null,`Host`,-1),a(x(`select`,{"onUpdate:modelValue":n[1]||=e=>B.value.hostId=e,required:``,disabled:!!G.value,title:G.value?`A schedule stays on its host`:void 0},[(i(!0),R(b,null,z(U.value,e=>(i(),R(`option`,{key:e.id,value:e.id},k(e.label),9,fu))),128))],8,du),[[N,B.value.hostId]])]),x(`label`,pu,[n[16]||=x(`span`,null,`Project`,-1),a(x(`select`,{"onUpdate:modelValue":n[2]||=e=>B.value.cwd=e,required:``,disabled:!H.value},[(i(!0),R(b,null,z(W.value,e=>(i(),R(`option`,{key:e.key,value:e.rootPath},k(e.name),9,hu))),128))],8,mu),[[N,B.value.cwd]])]),x(`label`,gu,[n[17]||=x(`span`,null,`Agent`,-1),a(x(`select`,{"onUpdate:modelValue":n[3]||=e=>B.value.provider=e,required:``,disabled:!V.value},[(i(!0),R(b,null,z(V.value??[],e=>(i(),R(`option`,{key:e.id,value:e.id},k(e.label),9,vu))),128))],8,_u),[[N,B.value.provider]])]),x(`label`,yu,[n[18]||=x(`span`,null,`Model`,-1),a(x(`select`,{"onUpdate:modelValue":n[4]||=e=>B.value.model=e,disabled:!ee.value.length},[(i(!0),R(b,null,z(ee.value,e=>(i(),R(`option`,{key:e.id,value:e.id},k(e.label),9,xu))),128))],8,bu),[[N,B.value.model]])])])):F(``,!0),x(`label`,Su,[n[19]||=x(`span`,null,`Name`,-1),a(x(`input`,{"onUpdate:modelValue":n[5]||=e=>B.value.name=e,placeholder:`Daily check-in`,maxlength:`120`},null,512),[[_,B.value.name]])]),x(`label`,Cu,[n[20]||=x(`span`,null,`Prompt`,-1),a(x(`textarea`,{"onUpdate:modelValue":n[6]||=e=>B.value.prompt=e,rows:`4`,required:``,placeholder:`What should the agent do each time?`},null,512),[[_,B.value.prompt]])]),x(`div`,wu,[x(`label`,Tu,[n[22]||=x(`span`,null,`Repeat`,-1),a(x(`select`,{"onUpdate:modelValue":n[7]||=e=>B.value.preset=e},[...n[21]||=[L(`<option value="daily" data-v-1a9bb929>Every day</option><option value="weekdays" data-v-1a9bb929>Weekdays</option><option value="weekly" data-v-1a9bb929>Every week</option><option value="hourly" data-v-1a9bb929>Every hour</option><option value="cron" data-v-1a9bb929>Custom (cron)</option>`,5)]],512),[[N,B.value.preset]])]),B.value.preset===`weekly`?(i(),R(`label`,Eu,[n[23]||=x(`span`,null,`Day`,-1),a(x(`select`,{"onUpdate:modelValue":n[8]||=e=>B.value.day=e},[(i(),R(b,null,z(A,(e,t)=>x(`option`,{key:e,value:String(t)},k(e),9,Du)),64))],512),[[N,B.value.day]])])):F(``,!0),B.value.preset===`cron`?(i(),R(`label`,ku,[n[24]||=x(`span`,null,`Cron`,-1),a(x(`input`,{"onUpdate:modelValue":n[10]||=e=>B.value.cron=e,placeholder:`0 9 * * 1-5`,required:``},null,512),[[_,B.value.cron]])])):(i(),R(`label`,Ou,[x(`span`,null,k(B.value.preset===`hourly`?`Minute`:`Time`),1),a(x(`input`,{"onUpdate:modelValue":n[9]||=e=>B.value.time=e,type:`time`,required:``},null,512),[[_,B.value.time]])]))]),x(`p`,Au,k(j(te.value))+` · `+k(re.value),1),!G.value||G.value.newAgent?(i(),R(`label`,ju,[a(x(`input`,{"onUpdate:modelValue":n[11]||=e=>B.value.archive=e,type:`checkbox`},null,512),[[h,B.value.archive]]),n[25]||=d(` Archive the agent when the run finishes`,-1)])):F(``,!0),G.value?F(``,!0):(i(),R(`label`,Mu,[a(x(`input`,{"onUpdate:modelValue":n[12]||=e=>B.value.runNow=e,type:`checkbox`},null,512),[[h,B.value.runNow]]),n[26]||=d(` Run once now`,-1)])),x(`div`,Nu,[x(`button`,{type:`button`,class:`btn btn-ghost`,onClick:ie},`Cancel`),x(`button`,{class:`btn btn-primary`,disabled:p.value===`create`||!B.value.prompt.trim()||(!G.value||G.value.newAgent)&&!B.value.cwd},k(G.value?`Save changes`:`Create schedule`),9,Pu)])],32)):F(``,!0),u.value?!y.value.length&&!I.value?(i(),R(`div`,Iu,[t(J,{name:`clock`,size:22}),n[28]||=x(`p`,null,`No schedules yet.`,-1)])):(i(),R(`div`,Lu,[(i(!0),R(b,null,z(y.value,({hostId:e,s:n})=>(i(),R(`div`,{key:e+n.id,class:`schedule`},[x(`div`,Ru,[x(`span`,{class:M([`setting-icon`,{paused:n.status!==`active`}])},[t(J,{name:`clock`,size:16})],2),x(`div`,zu,[x(`div`,Bu,k(n.name||n.target.config?.title||n.prompt.slice(0,60)),1),x(`div`,Vu,[d(k(j(n.cadence.expression))+` `,1),n.cadence.timezone?(i(),R(b,{key:0},[d(` · `+k(n.cadence.timezone),1)],64)):F(``,!0),d(` · `+k(m(e))+` `,1),n.target.config?.cwd?(i(),R(b,{key:1},[d(` · `+k(n.target.config.cwd.split(`/`).pop()),1)],64)):F(``,!0)]),x(`div`,Hu,[n.status===`active`?(i(),R(b,{key:0},[d(`Next `+k(P(n.nextRunAt)),1)],64)):(i(),R(`span`,Uu,k(n.status),1)),d(` · Last `+k(P(n.lastRunAt)),1)])]),x(`div`,Wu,[x(`button`,{class:`icon-btn`,title:`Run now`,"aria-label":`Run now`,disabled:p.value===n.id,onClick:t=>T(e,n,`run`)},[t(J,{name:`play`,size:14})],8,Gu),n.status===`active`?(i(),R(`button`,{key:0,class:`icon-btn`,title:`Pause`,"aria-label":`Pause`,disabled:p.value===n.id,onClick:t=>T(e,n,`pause`)},[t(J,{name:`pause`,size:14})],8,Ku)):(i(),R(`button`,{key:1,class:`icon-btn`,title:`Resume`,"aria-label":`Resume`,disabled:p.value===n.id,onClick:t=>T(e,n,`resume`)},[t(J,{name:`refresh`,size:14})],8,qu)),x(`button`,{class:`icon-btn`,title:`Edit`,"aria-label":`Edit schedule`,disabled:p.value===n.id,onClick:t=>q(e,n)},[t(J,{name:`edit`,size:14})],8,Ju),x(`button`,{class:`icon-btn`,title:`Run history`,"aria-label":`Run history`,"aria-expanded":E.value===n.id,onClick:t=>O(e,n)},[t(J,{name:`list`,size:14})],8,Yu),x(`button`,{class:`icon-btn`,title:`Delete`,"aria-label":`Delete schedule`,disabled:p.value===n.id,onClick:t=>T(e,n,`delete`)},[t(J,{name:`trash`,size:14})],8,Xu)])]),E.value===n.id?(i(),R(`div`,Zu,[x(`p`,Qu,k(n.prompt),1),D.value.length?F(``,!0):(i(),R(`p`,$u,`No runs yet.`)),(i(!0),R(b,null,z(D.value,t=>(i(),R(`div`,{key:t.id,class:M([`schedule-run`,`is-`+t.status])},[x(`span`,{class:M([`status-dot`,t.status===`failed`?`is-error`:t.status===`running`?`is-running`:`is-idle-ok`])},null,2),x(`span`,ed,k(P(t.startedAt)),1),x(`span`,td,k(t.error||t.output||t.status),1),t.agentId?(i(),R(`button`,{key:0,class:`btn btn-ghost btn-sm`,onClick:n=>l(`openAgent`,`${e}:${t.agentId}`)},`Open`,8,nd)):F(``,!0)],2))),128))])):F(``,!0)]))),128))])):(i(),R(`div`,Fu,[...n[27]||=[x(`span`,{class:`spinner`},null,-1),d(`Loading schedules…`,-1)]]))])]))}}),[[`__scopeId`,`data-v-1a9bb929`]]),id=[`disabled`,`aria-label`,`title`,`onKeydown`],ad={key:0,class:`spinner spinner-sm`},od={class:`rec-time`},sd=24e3,cd=300,ld=La(f({__name:`DictationButton`,props:{disabled:{type:Boolean}},emits:[`text`,`preview`,`notice`],setup(t,{expose:n,emit:r}){let a=r,o=e(`idle`),s=e(0),c=typeof window<`u`&&!!navigator.mediaDevices?.getUserMedia&&window.isSecureContext,u=null,d=null,f=null,p=null,h=[],g=0,_=0,y=!1,S=0,C,w,T=sd,E=``;function D(e){let t=T/sd,n=new Int16Array(Math.floor(e.length/t));for(let r=0;r<n.length;r++){let i=Math.max(-1,Math.min(1,e[Math.floor(r*t)]));n[r]=i<0?i*32768:i*32767}return n}function O(){f&&(f.onaudioprocess=null,f.disconnect()),f=null,d?.close().catch(()=>{}),d=null,u?.getTracks().forEach(e=>e.stop()),u=null}function A(){S++,O(),clearTimeout(w),C?.abort(),C=void 0,p&&(p.onopen=p.onmessage=p.onerror=p.onclose=null,p.close()),p=null,h=[],g=0,y=!1,o.value=`idle`,E=``,a(`preview`,``)}function j(e){let t=E.trim();A(),t&&a(`text`,t),a(`notice`,e+(t?` Recognized text was kept; the last phrase may be missing.`:``))}function N(){if(y&&p?.readyState===WebSocket.OPEN){if(p.bufferedAmount>sd*2*10)j(`Voice upload cannot keep up with recording. Please try again.`);else{for(let e of h)p.send(e.buffer);h=[],g=0,o.value===`transcribing`&&p.send(JSON.stringify({type:`stop`}))}}}async function I(){if(o.value!==`idle`)return;if(!c){a(`notice`,`Voice input needs HTTPS (or localhost) and microphone access.`);return}o.value=`starting`;let e=++S;try{let t=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}});if(e!==S){t.getTracks().forEach(e=>e.stop());return}u=t;try{d=new AudioContext({sampleRate:sd})}catch{d=new AudioContext}if(await d.resume(),e!==S)return;T=d.sampleRate;let n=d.createMediaStreamSource(u);f=d.createScriptProcessor(4096,1,1),_=0,h=[],g=0,f.onaudioprocess=t=>{if(e!==S||o.value!==`recording`)return;let n=D(t.inputBuffer.getChannelData(0)).subarray(0,cd*sd-_);h.push(n),g+=n.length,_+=n.length,g>sd*12?j(`Voice connection is taking too long. Please try again.`):(N(),s.value=Math.floor(_/sd),_>=cd*sd&&z())},n.connect(f),f.connect(d.destination),s.value=0,o.value=`recording`,w=setTimeout(()=>{e===S&&j(`Could not connect to the transcription service.`)},12e3),C=new AbortController;let r=await fetch(`/api/dictation/session`,{method:`POST`,headers:{"x-litepaseo":`1`},signal:C.signal}),i=await r.json();if(e!==S)return;if(!r.ok)throw Error(i.error??`Could not start voice input.`);let c=new URL(`/api/dictation/stream`,location.href);c.protocol=location.protocol===`https:`?`wss:`:`ws:`,c.searchParams.set(`ticket`,i.ticket),p=new WebSocket(c),p.onmessage=t=>{if(e===S)try{let n=JSON.parse(t.data);if(n.type===`ready`)y=!0,clearTimeout(w),o.value===`transcribing`&&L(e),N();else if(n.type===`partial`)E=String(n.text??``),a(`preview`,E);else if(n.type===`done`){let e=String(n.text??``).trim();A(),e?a(`text`,e):a(`notice`,`No speech recognized.`)}else if(n.type===`error`){let e=String(n.text??``).trim();A(),e&&a(`text`,e),a(`notice`,String(n.message??`Transcription failed.`)+(e?` Recognized text was kept; the last phrase may be missing.`:``))}}catch{j(`Invalid transcription response.`)}},p.onerror=()=>{e===S&&j(`Voice connection failed. Please try again.`)},p.onclose=()=>{e===S&&j(`Voice connection interrupted. Please try again.`)}}catch(t){if(e!==S)return;j(t.name===`NotAllowedError`?`Microphone access was denied.`:t.message)}}function L(e){clearTimeout(w),w=setTimeout(()=>{e===S&&j(`Timed out waiting for transcription.`)},125e3)}function z(){o.value===`recording`&&(O(),_<sd/5?j(`Recording too short.`):(o.value=`transcribing`,y&&(L(S),N())))}function B(){p?.readyState===WebSocket.OPEN&&p.send(JSON.stringify({type:`cancel`})),A()}let V=()=>o.value===`recording`?z():o.value===`idle`?void I():void 0,H=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`;return n({cancel:B}),l(B),(e,n)=>(i(),R(b,null,[x(`button`,{type:`button`,class:M([`dictation`,`is-`+o.value]),disabled:t.disabled&&o.value===`idle`||o.value===`transcribing`||o.value===`starting`,"aria-label":o.value===`recording`?`Stop recording and transcribe`:o.value===`transcribing`?`Transcribing`:o.value===`starting`?`Starting voice input`:`Voice input`,title:o.value===`recording`?`Stop recording (Esc cancels)`:o.value===`transcribing`?`Finishing transcription…`:`Voice input`,onClick:V,onKeydown:P(v(B,[`prevent`]),[`esc`])},[o.value===`transcribing`||o.value===`starting`?(i(),R(`span`,ad)):o.value===`recording`?(i(),R(b,{key:1},[n[0]||=x(`span`,{class:`rec-dot`},null,-1),x(`span`,od,k(H(s.value)),1)],64)):(i(),m(J,{key:2,name:`mic`,size:17}))],42,id),o.value===`idle`?F(``,!0):(i(),R(`button`,{key:0,type:`button`,class:`dictation`,"aria-label":`Cancel voice input`,title:`Cancel voice input`,onClick:B},`×`))],64))}}),[[`__scopeId`,`data-v-9ec56bd9`]]),ud={key:0,class:`login`},dd={class:`field`},fd={class:`field`},pd=[`disabled`],md={key:1,class:`form-error`},hd={class:`sidebar`},gd=[`aria-valuenow`],_d={class:`side-nav`,"aria-label":`Pages`},vd={class:`hide-sm`},yd={class:`side-section`},bd={class:`side-label`},xd={class:`list-summary`},Sd=[`aria-expanded`],Cd={key:0,class:`active-host-filter`,role:`group`,"aria-label":`Active host filter`},wd=[`title`],Td={key:1,class:`view-menu`},Ed={class:`segmented segmented-sm`,role:`radiogroup`,"aria-label":`Group sessions`},Dd=[`aria-checked`],Od=[`aria-checked`],kd={key:0,class:`host-filter`,role:`radiogroup`,"aria-label":`Filter by host`},Ad=[`aria-checked`],jd={class:`chip-count`},Md=[`aria-checked`,`title`,`onClick`],Nd={class:`chip-count`},Pd={class:`side-foot`},Fd=[`title`],Id=[`title`,`aria-label`],Ld={key:0,class:`foot-alert`,"aria-hidden":`true`},Rd=[`title`,`aria-label`],zd={class:`main`},Bd={key:0,class:`toast`,role:`alert`},Vd={key:2,class:`page`},Hd={class:`page-head`},Ud={class:`page-body`},Wd={class:`card`},Gd={class:`grow`},Kd={class:`row-title`},qd={class:`row-sub`},Jd={key:0,role:`status`},Yd={key:1,class:`row-sub`},Xd={key:2,class:`row-sub`},Zd={key:3,class:`row-sub`},Qd=[`disabled`,`onClick`],$d={key:0,class:`card-row muted-text`},ef={class:`field`},tf={class:`field`},nf={class:`form-actions`},rf=[`disabled`],af={key:4,class:`page`},of={class:`page-head`},sf={class:`subtle`},cf={class:`segmented head-toggle`,role:`radiogroup`,"aria-label":`Board`},lf={class:`page-body wide`},uf=[`value`],df=[`disabled`],ff={class:`board`},pf={class:`column-head`},mf={class:`count`},hf=[`aria-label`,`onClick`],gf={class:`row-title`},_f={key:0,class:`kanban-excerpt`},vf={key:0,class:`card-link`},yf=[`title`,`onClick`],bf={class:`card-link-name`},xf={key:1,class:`subtle small`},Sf=[`disabled`,`onClick`],Cf=[`disabled`,`onChange`],wf=[`value`],Tf={class:`kanban-actions`},Ef=[`value`,`onChange`],Df=[`title`,`onClick`],Of=[`onClick`],kf=[`onClick`],Af={key:0,class:`column-empty`},jf={class:`chat`},Mf={class:`chat-head`},Nf=[`title`],Pf=[`title`],Ff=[`title`],If={key:0,class:`agent-tabs`,"aria-label":`Tabs`},Lf=[`onClick`],Rf={class:`agent-tab-name`},zf=[`title`,`onClick`,`onAuxclick`],Bf={class:`agent-tab-name`},Vf=[`aria-label`,`onClick`],Hf={class:`timeline-wrap`},Uf={class:`timeline-inner`},Wf={key:0,class:`older`},Gf={key:0,class:`older-loading`,role:`status`},Kf={key:1,class:`notice`},qf={key:0,class:`turn-footer`},Jf=[`aria-label`,`title`,`onClick`],Yf=[`title`],Xf=[`title`],Zf=[`title`],Qf={key:2,class:`older`},$f={key:0,class:`older-loading`,role:`status`},ep={key:3,class:`timeline-working`,role:`status`,"aria-label":`Agent is working`},tp={key:0,class:`timeline-elapsed`,"aria-hidden":`true`},np={key:1},rp={key:4,class:`timeline-empty`},ip={key:0,class:`spinner`},ap={class:`dock`},op={class:`dock-inner`},sp={key:0,role:`status`},cp={key:1,role:`status`},lp={key:2,class:`composer-notice`,role:`status`},up={key:3},dp={style:{"white-space":`pre-wrap`}},fp=[`onClick`],pp={key:4,class:`uncertain`},mp={class:`grow`},hp=[`disabled`],gp={key:5,class:`send-queue`,role:`list`,"aria-label":`Queued messages`},_p={class:`queue-body`},vp=[`disabled`,`onClick`],yp=[`title`],bp={key:2,class:`queue-meta`},xp={class:`queue-meta`},Sp={key:3,class:`queue-meta queue-error`},Cp=[`disabled`,`onClick`],wp=[`disabled`,`onClick`],Tp=[`disabled`,`onClick`],Ep=[`disabled`,`title`,`onClick`],Dp=[`disabled`,`onClick`],Op=[`disabled`,`onClick`],kp=[`placeholder`,`required`],Ap={class:`composer-bar`},jp=[`title`,`disabled`],Mp={class:`composer-actions`},Np=[`aria-label`,`title`],Pp=[`disabled`],Fp=[`disabled`],Ip={key:0,class:`side-panel`,"aria-label":`Files`},Lp={class:`panel-tabs`},Rp={class:`panel-body`},zp={key:6,class:`empty`},Bp={key:7,class:`empty`},Vp={class:`empty-mark`},Hp=[`src`],Up=280,Wp=900,Gp=420,Kp=220,qp=520,Jp=300,Yp=f({__name:`App`,setup(r){let s=I(()=>kr(()=>import(`./ChangesPanel-BcmK5kQw.js`),__vite__mapDeps([5,1,2,6]))),c=I(()=>kr(()=>import(`./ConversationSearch-DRXClZic.js`),__vite__mapDeps([7,1,2,8]))),f=I(()=>kr(()=>import(`./FilesPanel-CIlBeef1.js`),__vite__mapDeps([9,1,2,10]))),p=I(()=>kr(()=>import(`./FileViewer-Bs0locPm.js`),__vite__mapDeps([11,1,2,3,12]))),h=I(()=>kr(()=>import(`./TerminalPanel-CCDC8FeR.js`),__vite__mapDeps([13,1,2,14]))),w=[`Todo`,`Doing`,`Done`],E=matchMedia(`(pointer: coarse)`).matches,O=/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),j=e(!1),B=e(localStorage.getItem(`litepaseo-panel`)===`files`?`files`:null);n(B,e=>e?localStorage.setItem(`litepaseo-panel`,e):localStorage.removeItem(`litepaseo-panel`));let V=e=>B.value=B.value===e?null:e,H=u(new Map),U=S(()=>H.has(K.value)),W=S(()=>H.get(K.value)===!0);function ee(){H.set(K.value,!0),q.value=null,Kn.matches&&(B.value=null)}function te(){H.has(K.value)&&H.set(K.value,!1),q.value=null}let G=u(new Map),K=S(()=>De.value??X.value??``),ne=S(()=>G.get(K.value)?.paths??[]),q=S({get:()=>G.get(K.value)?.active??null,set:e=>{let t=G.get(K.value);t&&(t.active=e),e&&H.has(K.value)&&H.set(K.value,!1)}});function re(e){let t=K.value;if(!t)return;let n=G.get(t)??{paths:[],active:null};n.paths.includes(e)||(n.paths=[...n.paths,e].slice(-12)),n.active=e,H.has(t)&&H.set(t,!1),G.set(t,n),Kn.matches&&(B.value=null)}function ie(e){let t=G.get(K.value);if(!t)return;let n=t.paths.indexOf(e);t.paths=t.paths.filter(t=>t!==e),t.active===e&&(t.active=t.paths[Math.min(n,t.paths.length-1)]??null)}let oe=e=>Math.round(Math.min(Wp,Math.max(Up,e))),se=e(oe(Number(localStorage.getItem(`litepaseo-panel-width`))||Gp));function ce(e){se.value=oe(e),localStorage.setItem(`litepaseo-panel-width`,String(se.value))}function le(e){if(e.button!==0)return;let t=e.currentTarget,n=e.clientX,r=se.value;t.setPointerCapture(e.pointerId),pe.value=!0;let i=e=>se.value=oe(r-(e.clientX-n)),a=()=>{pe.value=!1,ce(se.value),t.removeEventListener(`pointermove`,i),t.removeEventListener(`pointerup`,a),t.removeEventListener(`pointercancel`,a)};t.addEventListener(`pointermove`,i),t.addEventListener(`pointerup`,a),t.addEventListener(`pointercancel`,a)}let ue=e=>Math.round(Math.min(qp,Math.max(Kp,e))),de=e(ue(Number(localStorage.getItem(`litepaseo-sidebar-width`))||Jp)),pe=e(!1);function me(e){de.value=ue(e),localStorage.setItem(`litepaseo-sidebar-width`,String(de.value))}function he(e){if(e.button!==0)return;let t=e.currentTarget,n=e.clientX,r=de.value;t.setPointerCapture(e.pointerId),pe.value=!0;let i=0,a=e=>{i&&cancelAnimationFrame(i),i=requestAnimationFrame(()=>de.value=ue(r+e.clientX-n))},o=()=>{cancelAnimationFrame(i),pe.value=!1,me(de.value),t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}function ge(e,t){try{return JSON.parse(localStorage.getItem(e)??`null`)??t}catch{return t}}let ve=e(``),ye=e(``),be=e(null),xe=e(!1),Se=e(``),Y=e(!1),Ce=y([]),we=new fe({collapsed:ge(`litepaseo-collapsed-projects`,[]),persist:e=>localStorage.setItem(`litepaseo-collapsed-projects`,JSON.stringify(e)),compare:ae}),Te=new fe({indexBy:e=>e.workspaceId?`${e.hostId}:${e.workspaceId}`:null}),De=e(null),Oe=e(localStorage.getItem(`litepaseo-list-mode`)===`recent`?`recent`:`projects`),Ae=e(`closed`),X=e(null),je=y(new un),Me=e(``),Ne=y(null),Pe=e(!1),Fe=e([]),Ie=e(null),Le=e(null),Re=e(null),ze=e(``),Be=e(!1),Ve=e(``),He=e(``),Ue=e(`steer`),We=e(`chat`),Ge=e(``),Ke=e(``),qe=e({revision:0,cards:[]}),Z=new sn(()=>localStorage),Je=new za,Ye=e([]),Xe=new Map,Ze=e(null),Qe=e(``),$e=0;async function et(){let e=Q.value,t=++$e;if(!e||!xe.value)Ye.value=[];else try{let n=await $(Tn(e)+`/queue`);t===$e&&Q.value?.key===e.key&&(Ye.value=Array.isArray(n)?n:[])}catch{}}n(X,()=>{Ye.value=[],et()});let tt=e({}),nt=null;n(xe,e=>{nt?.close(),tt.value={},e&&(nt=bn({url:()=>`/api/queue/stream`,onMessage:e=>{tt.value=e}}))}),l(()=>nt?.close());let rt=null;n([X,xe],()=>{rt?.close(),rt=null,$e++,Ye.value=[];let e=Q.value;e&&xe.value&&(rt=bn({url:()=>`/api`+Tn(e)+`/queue/stream`,onMessage:t=>{xe.value&&Q.value?.key===e.key&&Array.isArray(t)&&($e++,Ye.value=t)}}))}),l(()=>rt?.close());async function it(e,t){let n=Q.value;n&&await wn(async()=>{await $(Tn(n)+`/queue/`+e.id+`/control`,`POST`,{action:t}),await et()})}async function at(e,t){je.value.epoch===t?(te(),Kn.matches&&(B.value=null),await ti(e,!0)):Se.value=`Conversation changed. Search again.`}let ot=e(null),st=e(null),ct=S(()=>{let e=st.value?.modelLabel;return e&&e!==`Model`?e:``}),lt=S(()=>X.value?Je.get(X.value):[]),ut=e(!1),dt=e(``),ft=e(null);n(dt,()=>{let e=ft.value;e&&(e.scrollTop=e.scrollHeight)},{flush:`post`});async function pt(){try{ut.value=!!(await $(`/dictation`)).configured}catch{}}let mt=e(``),ht;function gt(e){mt.value=e,clearTimeout(ht),ht=setTimeout(()=>mt.value=``,8e3)}function _t(e){let t=Re.value,n=Ct.value,r=t&&document.activeElement===t?t.selectionStart:n.length,i=t&&document.activeElement===t?t.selectionEnd:n.length,a=n.slice(0,r),o=n.slice(i),s=a&&!/\s$/.test(a)?` `:``;Ct.value=a+s+e+o,C(()=>{if(!t)return;t.focus();let n=(a+s+e).length;t.setSelectionRange(n,n),ni()})}let vt=S(()=>!!Ct.value.trim()||lt.value.length>0),yt=e(!1);function bt(e){e.currentTarget.contains(e.relatedTarget)||(yt.value=!1)}let xt=S(()=>lt.value.every(e=>!!e.id&&!e.uploading&&!e.error));function St(e){let t=e.clipboardData;if(!t)return;let n=Array.from(t.files);n.length||(n=Array.from(t.items).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)),n.length&&(e.preventDefault(),ot.value?.addFiles(n))}let Ct=S({get:()=>X.value?Z.state(X.value).text:``,set:e=>{X.value&&Z.setText(X.value,e)}}),wt=S(()=>X.value?Z.unresolved(X.value)[0]??null:null),Tt=S(()=>X.value?Z.saved(X.value).filter(e=>e.text!==Ct.value):[]),Et=e(!1),Dt=e(``);async function Ot(){let e=Q.value;if(!e||Y.value||Et.value||document.hidden)return;let t=Z.unresolved(e.key);if(!t.length)return;let n=Z.generation;Et.value=!0;try{let r=await $(Tn(e)+`/messages/status`,`POST`,{messageIds:t.slice(0,20).map(e=>e.messageId)});if(n!==Z.generation)return;for(let n of r.confirmed??[]){let r=t.find(e=>e.messageId===n);r&&(Je.consume(e.key,r.attachmentIds??[]),Z.confirm(e.key,n))}Q.value?.key===e.key&&(Dt.value=r.confirmed?.length?`Delivery confirmed from conversation history.`:`Not confirmed yet. No message has been resent.`)}catch{Q.value?.key===e.key&&(Dt.value=`Unable to check delivery. Your message remains saved.`)}finally{Et.value=!1}}let kt=setInterval(()=>void Ot(),15e3);n([X,Y],()=>{Dt.value=``,Ot()});function At(){X.value&&wt.value&&Z.resolve(X.value,wt.value.messageId)}function jt(e){e.storageArea===localStorage&&(e.key===`litepaseo-composer-signout`?Z.clear():Z.onStorage(e.key,e.newValue))}window.addEventListener(`storage`,jt);let Mt=S(()=>new Map(Ce.value.map(e=>[e.id,e.label]))),Nt=S(()=>new Map(Ce.value.map(e=>[e.id,e.state]))),Pt=S(()=>Ce.value.filter(e=>e.state===`connected`).length),Q=S(()=>(Te.version.value,Te.get(X.value)??null)),Ft=S(()=>(we.version.value,we.get(De.value)??null)),It=S(()=>(Te.version.value,Te.indexed(De.value,12))),Lt=S(()=>(we.version.value,we.total)),Rt=S(()=>(we.version.value,we.size)),zt=S(()=>(we.version.value,we.projectCount));n(Oe,e=>localStorage.setItem(`litepaseo-list-mode`,e));let Bt=e(localStorage.getItem(`litepaseo-host-filter`));n(Bt,e=>{we.setHost(e),Te.setHost(e),e?localStorage.setItem(`litepaseo-host-filter`,e):localStorage.removeItem(`litepaseo-host-filter`)},{immediate:!0}),n(Ce,e=>{Bt.value&&e.length&&!e.some(e=>e.id===Bt.value)&&(Bt.value=null)});let Vt=S(()=>(we.version.value,new Map(Ce.value.map(e=>[e.id,we.hostSize(e.id)])))),Ht=S(()=>Ft.value?.directory||Q.value?.cwd||``),Ut=S(()=>{let e=Q.value?.cwd??``;return e.replace(/\/+$/,``).split(`/`).pop()||e}),Wt=S(()=>Q.value?.status===`running`),Gt=S(()=>!Ne.value&&Q.value?.state===`running`),Kt=e(Date.now()),qt=S(()=>Gt.value?Q.value?.turnStartedAt??null:null),Jt=S(()=>qt.value?Cl(Kt.value-qt.value):``),Yt=S(()=>qt.value?Math.max(0,Math.floor((Kt.value-qt.value)/1e3)):0),Xt;function Zt(){clearTimeout(Xt),Xt=void 0;let e=qt.value;if(!e||document.hidden)return;let t=()=>{Kt.value=Date.now();let n=(Kt.value-e)%1e3;Xt=setTimeout(t,(n<0?-n:1e3-n)+10)};t()}n(qt,Zt,{immediate:!0}),document.addEventListener(`visibilitychange`,Zt);let Qt=S(()=>{if(Ne.value)return Ne.value;let e=je.value;return e.membership.value,e.rows.slice(-150)}),$t=S(()=>Ae.value===`live`&&Nt.value.get(Q.value?.hostId??``)===`connected`&&Q.value?.turnActive===!1),en=S(()=>{let e=Qt.value.map(e=>e.row.value),t=Q.value;return Bn(e,!!Ne.value&&Fe.value.length>0||!!t&&!(t.turnActive??t.state===`running`))}),tn=e(null),rn;async function an(e,t){let n=new Set(t),r=Qt.value.filter(e=>n.has(e.seqStart)).map(e=>String(e.row.value.item.text??``).trim()).filter(Boolean).join(`
33
+
34
+ `);if(r)try{await navigator.clipboard.writeText(r),tn.value=e,clearTimeout(rn),rn=setTimeout(()=>tn.value=null,1500)}catch{}}let on=e(!1);async function cn(e,t,n){let r=Q.value;if(r&&!on.value){on.value=!0,Se.value=``;try{await $(Tn(r)+`/rewind`,`POST`,{messageId:e,mode:n},12e4),n!==`files`&&X.value===r.key&&!Ct.value.trim()&&(Ct.value=t,C(ni)),X.value===r.key&&gt(n===`files`?`Files rewound.`:n===`both`?`Conversation and files rewound.`:`Conversation rewound.`)}catch(e){Se.value=String(e.message)}finally{on.value=!1}}}let ln=y({base:``,cwd:``});n(Q,e=>{let t=e?`/api`+Tn(e):``,n=e?.rewind??[],r=ln.value;(t!==r.base||(e?.cwd??``)!==r.cwd||n.join()!==(r.rewindModes??[]).join())&&(ln.value={base:t,cwd:e?.cwd??``,rewindModes:n,rewinding:on,rewind:(e,t,n)=>void cn(e,t,n)})},{immediate:!0}),o(xn,ln);let fn=e(null);function pn(e){let t=e.target;t instanceof HTMLImageElement&&t.closest(`.prose`)&&(fn.value=t.currentSrc||t.src)}let mn=S(()=>{let e=je.value;return e.membership.value,e.rows.at(-1)?.seqStart}),hn=S(()=>{if(Ne.value)return Pe.value;let e=je.value;return e.membership.value,e.rows.length>150||e.hasOlder}),gn=S(()=>{let e=new Map(w.map(e=>[e,[]]));for(let t of qe.value.cards)e.get(t.column)?.push(t);return e}),vn=S(()=>Ae.value===`live`?`Live`:Ae.value===`paused`?`Paused`:`Reconnecting`),yn=null,Sn=null,Cn;async function $(e,t=`GET`,n,r=2e4){let i=await fetch(`/api`+e,{method:t,headers:{"Content-Type":`application/json`,"x-litepaseo":`1`},body:n===void 0?void 0:JSON.stringify(n),signal:AbortSignal.timeout(r)}),a=await i.json().catch(()=>({}));if(i.status===401&&xe.value&&e!==`/login`&&En(`ended`),!i.ok)throw Object.assign(Error((a.error??`Request failed`)+(a.requestId?` (reference ${a.requestId})`:``)),{delivery:a.delivery,code:a.code,scope:a.scope});return a}async function wn(e){Y.value=!0,Se.value=``;try{await e()}catch(e){Se.value=String(e.message)}finally{Y.value=!1}}function Tn(e){return`/hosts/${encodeURIComponent(e.hostId)}/agents/${encodeURIComponent(e.id)}`}function En(e){if(xe.value=!1,e===`user`){Z.clear(),Ye.value=[],$e++,Je.clear();try{localStorage.setItem(`litepaseo-composer-signout`,crypto.randomUUID())}catch{}}else Je.forgetRemote(`Sign in again, then retry the upload.`);yn?.close(),Sn?.close(),yn=Sn=null,ve.value=ye.value=``,Dn(),Se.value=e===`ended`?`Your session ended. Sign in again; your drafts are kept.`:``}async function Dn(){try{be.value=await $(`/auth`)}catch{be.value={authenticated:!1,totp:!1};return}be.value.authenticated&&await kn()}async function On(){await wn(async()=>{await $(`/login`,`POST`,{token:ve.value.trim(),...be.value?.totp?{code:ye.value.trim()}:{}}),ve.value=ye.value=``,await kn()})}async function kn(){xe.value=!0,Se.value=``,qe.value=await $(`/board`),jn(),No(),Nr(),Rr(),pt(),clearInterval(Lr),Lr=setInterval(()=>void Rr(),3e5);let e=new URLSearchParams(location.search).get(`session`);e&&(history.replaceState(history.state,``,`/`),Wn(e))}function An(){ye.value=ye.value.replace(/\D/g,``).slice(0,6)}navigator.serviceWorker?.addEventListener(`message`,e=>{e.data?.type===`open-session`&&xe.value&&Wn(String(e.data.key))});function jn(){yn?.close(),yn=bn({url:()=>`/api/stream?generation=${encodeURIComponent(Te.generation)}&since=${Te.seq}&wgeneration=${encodeURIComponent(we.generation)}&wsince=${we.seq}`,onState:e=>{Ae.value=e,e===`unauthorized`&&En(`ended`)},onMessage:e=>{let t=e;t.type===`project-pins`?hr(t.pins):t.type===`hosts`?Ce.value=t.hosts:t.type===`workspaces-snapshot`?we.applyCollection({type:`snapshot`,generation:t.generation,seq:t.seq,items:t.workspaces}):t.type===`workspaces-changes`?we.applyCollection({type:`changes`,generation:t.generation,seq:t.seq,changes:t.changes}):Te.apply(t)}})}n(ze,e=>{clearTimeout(Cn),Cn=setTimeout(()=>{let t=e.trim().toLowerCase();if(!t){we.setFilter(null),Te.setFilter(null);return}let n=Mt.value;we.setFilter(e=>`${e.name}\n${e.project}\n${e.branch??``}\n${e.directory}\n${n.get(e.hostId)??``}`.toLowerCase().includes(t)),Te.setFilter(e=>`${e.title??``}\n${e.project}\n${e.cwd}\n${n.get(e.hostId)??``}\n${e.provider}`.toLowerCase().includes(t))},120)});let Mn=!0;n(Le,(e,t,n)=>{let r=e?.querySelector(`.timeline-inner`);if(!e||!r)return;let i=e.scrollTop,a=()=>{let t=e.scrollTop;Hn()?Mn=!0:t<i-1&&(Mn=!1),$r();let n=Fn!==null&&Math.abs(t-Fn)<2;n&&(Fn=null),!n&&performance.now()>=Pn&&(t<i-1?Nn=`up`:t>i+1&&(Nn=`down`),Ln()),i=t},o=new ResizeObserver(()=>{!Ne.value&&Mn&&Un()}),s=e=>{performance.now()<Pn||!e.deltaY||(Nn=e.deltaY<0?`up`:`down`,Ln())};e.addEventListener(`scroll`,a,{passive:!0}),e.addEventListener(`wheel`,s,{passive:!0}),o.observe(r),o.observe(e),n(()=>{o.disconnect(),e.removeEventListener(`scroll`,a),e.removeEventListener(`wheel`,s)})},{flush:`post`});let Nn=null,Pn=0,Fn=null;function In(e,t){e.scrollTop=t,Fn=e.scrollTop,Pn=performance.now()+40}function Ln(){let e=Le.value;if(!e||Ie.value||!Nn||e.offsetParent===null)return;let t=Math.max(600,e.clientHeight);Nn===`up`&&e.scrollTop<t&&hn.value?Wr(`before`):Nn===`down`&&Ne.value&&e.scrollHeight-e.scrollTop-e.clientHeight<t&&Wr(`after`)}function Rn(e){let t=Le.value;if(!t)return null;let n=t.getBoundingClientRect(),r=Array.from(t.querySelectorAll(`[data-seq-start]`)).filter(e=>{let t=e.getBoundingClientRect();return t.bottom>n.top&&t.top<n.bottom}),i=e===`first`?r[0]:r.at(-1);return i?{seq:i.dataset.seqStart,top:i.getBoundingClientRect().top}:null}function zn(e){let t=Le.value,n=e&&t?.querySelector(`[data-seq-start="${e.seq}"]`);return!t||!n?!1:(In(t,t.scrollTop+n.getBoundingClientRect().top-e.top),!0)}async function Vn(){let e=Rn(`last`);Ne.value=null,Fe.value=[],await C(),zn(e)?Hn()&&(Mn=!0):Un()}function Hn(){let e=Le.value;return!e||e.scrollHeight-e.scrollTop-e.clientHeight<120}function Un(){Mn=!0,C(()=>{let e=Le.value;e&&(e.scrollTop=e.scrollHeight)})}function Wn(e){We.value=`chat`,X.value=e;let t=Te.get(e);De.value=t?.workspaceId?`${t.hostId}:${t.workspaceId}`:null,qn()}function Gn(e){We.value=`chat`,De.value=e,X.value=Te.indexed(e,1)[0]?.key??null,qn()}n(Q,e=>{e?.workspaceId&&!De.value&&(De.value=`${e.hostId}:${e.workspaceId}`)}),n(It,e=>{De.value&&e.length&&!e.some(e=>e.key===X.value)&&(X.value=e[0].key)});let Kn=matchMedia(`(max-width: 760px)`);function qn(){!Be.value&&Kn.matches&&history.pushState({litepaseoDetail:!0},``),Be.value=!0}function Jn(){history.state?.litepaseoDetail?history.back():Be.value=!1}function Yn(){Be.value&&!history.state?.litepaseoDetail&&(Be.value=!1)}window.addEventListener(`popstate`,Yn);let Xn=e(null);function Zn(e){let t=e.target,n=!!t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName));e.key===`Escape`&&fn.value?fn.value=null:e.key===`k`&&(e.metaKey||e.ctrlKey)||e.key===`/`&&!n?(e.preventDefault(),Be.value&&Kn.matches&&Jn(),Xn.value?.focus(),Xn.value?.select()):e.key===`n`&&!n&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&xe.value&&!Qn.value?(e.preventDefault(),$n()):e.key===`Escape`&&t===Xn.value&&ze.value&&(ze.value=``)}window.addEventListener(`keydown`,Zn);let Qn=e(null);function $n(e){let t=e?e.items.at(0):we.range(0,1)[0];Qn.value={hostId:Bt.value??t?.hostId??Q.value?.hostId??null,cwd:t?.rootPath??null,project:t?{key:t.projectKey,name:t.project}:null}}function er(e){Qn.value=null,ze.value&&=``,Wn(e)}let tr=S(()=>(!!X.value||!!De.value)&&!Q.value),nr=y(null),rr=y(null);function ir(e){return`/hosts/${encodeURIComponent(e.hostId)}/workspaces/${encodeURIComponent(e.id)}`}function ar(e,t,n){nr.value={thread:e,x:t,y:n}}function or(e){let t=Ft.value;if(!t)return;let n=e.currentTarget.getBoundingClientRect();ar(t,n.right-200,n.bottom+6)}async function sr(e){let t=rr.value;t&&await wn(async()=>{await $(ir(t)+`/title`,`POST`,{title:e}),rr.value=null})}async function cr(e,t){await wn(async()=>void await $(ir(e)+`/pin`,`POST`,{pinned:t}))}async function lr(e){await wn(async()=>{await $(ir(e)+`/unread`,`POST`,{}),De.value===e.key&&(De.value=X.value=null,Jn())})}async function ur(e){await wn(async()=>void await $(ir(e)+`/read`,`POST`,{}))}async function dr(e){confirm(`Archive “${e.name}”? It leaves the sidebar; the host keeps its history.`)&&await wn(async()=>{await $(ir(e)+`/archive`,`POST`,{}),De.value===e.key&&(De.value=X.value=null)})}let fr=e({});function pr(e){return e.projectIds.some(t=>!!fr.value[JSON.stringify([e.hostId,t])])}let mr=0;function hr(e){mr++,fr.value=e,we.setProjectPins(e)}async function _r(e){let t=!pr(e),n=mr;await wn(async()=>{let r=await $(`/project-pins`,`POST`,{hostId:e.hostId,projectIds:e.projectIds,pinned:t});n===mr&&hr(r)})}let vr=y(null),yr=y(null),br=S(()=>{we.version.value;let e=yr.value;if(!e)return null;let t=e.threadKeys.map(e=>we.get(e)).find(Boolean);return{projectId:t?.projectId??e.projectIds[0]??``,name:t?.project??e.name,customName:t?.projectCustomName??null,iconRevision:t?.projectIconRevision??null}});function xr(e,t,n){let r=e.items.range(0,e.items.size),i=r[0];i&&(vr.value={project:{name:e.name,hostId:i.hostId,rootPath:i.rootPath,projectIds:[...new Set(r.map(e=>e.projectId).filter(Boolean))],threadKeys:r.map(e=>e.key)},x:t,y:n})}async function Sr(e){let t=Mt.value.get(e.hostId)??`its host`,n=e.threadKeys.length;confirm(`Remove “${e.name}” from ${t}? Its ${n===1?`thread is`:`${n} threads are`} archived and the project leaves the sidebar. Files on disk are not touched; the host keeps the history.`)&&await wn(async()=>{if(!e.projectIds.length)throw Error(`This host did not report a project id; update Paseo on it.`);for(let t of e.projectIds)await $(`/hosts/${encodeURIComponent(e.hostId)}/projects/${encodeURIComponent(t)}`,`DELETE`,void 0,6e4);De.value&&e.threadKeys.includes(De.value)&&(De.value=X.value=null)})}let Cr=``;n(()=>Ft.value?.unread&&je.value.membership.value>=0&&je.value.ready?Ft.value:null,e=>{if(!e||document.hidden)return;let t=`${e.key}@${e.activityAt}`;Cr!==t&&(Cr=t,$(ir(e)+`/read`,`POST`,{}).catch(()=>Cr=``))});let wr=e(localStorage.getItem(`litepaseo-board-mode`)===`plan`?`plan`:`agents`);n(wr,e=>localStorage.setItem(`litepaseo-board-mode`,e));async function Tr(e){await wn(async()=>void await $(Tn(e)+`/stop`,`POST`))}async function Er(e){await wn(async()=>void await $(Tn(e)+`/read`,`POST`,{}))}async function Dr(e){confirm(`Archive “${e.title||`this session`}”? It leaves the board and sidebar; the host keeps its history.`)&&await wn(async()=>void await $(Tn(e)+`/archive`,`POST`,{}))}let Or=``;n(()=>Q.value&&Q.value.unread&&je.value.membership.value>=0&&je.value.ready?Q.value:null,e=>{if(!e||document.hidden)return;let t=`${e.key}@${e.activityAt}`;Or!==t&&(Or=t,$(Tn(e)+`/read`,`POST`,{}).catch(()=>Or=``))});let Ar=e(null);o(Pr,{predict:e=>{let t=Q.value;return t?$(Tn(t)+`/suggestion`,`POST`,{token:e},65e3):Promise.resolve({status:`expired`,text:``})},use:e=>{Ct.value=e,C(()=>{ni(),Re.value?.focus()})},send:e=>void oi(e),offer:(e,t)=>{let n=Q.value;n&&(!Ar.value||Ar.value.key!==n.key||e>=Ar.value.seqStart)&&(Ar.value={key:n.key,seqStart:e,text:t})}});let jr=S(()=>Ar.value&&Ar.value.key===Q.value?.key&&!Ct.value?Ar.value.text:``),Mr=S(()=>jr.value&&!E?jr.value:Wt.value?Ue.value===`steer`?`Queue a message for when this turn ends`:`Interrupt and send a new message`:`Message this agent…`),Fr=y(null),Ir=e(!1),Lr;async function Rr(e=!1){if(xe.value&&!document.hidden){Ir.value=!0;try{Fr.value=await $(`/usage`+(e?`?refresh=1`:``))}catch{}finally{Ir.value=!1}}}n(X,()=>{Ar.value=null}),n(()=>Q.value?.key??null,e=>{Sn?.close(),Sn=null;let t=new un;je.value=t,Ne.value=null,Fe.value=[],Me.value=``;let n=Te.get(e);n&&(Sn=bn({url:()=>`/api`+Tn(n)+`/timeline/stream`,onState:e=>{e===`unauthorized`&&En(`ended`)},onMessage:e=>{if(je.value!==t)return;let r=!Ne.value&&(Hn()||!t.ready),i=e.ops,a=i.find(e=>e.type===`error`);Me.value=a?.type===`error`?a.message:``;let o=t.epoch;t.apply(i),t.epoch&&t.epoch!==qr&&Jr(n,t),o&&o!==t.epoch&&(Ne.value=null,Fe.value=[],Un()),r&&Un()}}))});function zr(){Ne.value=null,Fe.value=[],Un()}function Br(e,t,n){return $(Tn(e)+`/timeline?cursor=`+encodeURIComponent(JSON.stringify({epoch:t,seq:n})))}let Vr=new Set,Hr=4;async function Ur(e,t,n,r){let i=[],a=!1;for(let o=0;o<8&&i.length<100;){let s=i.at(-1)?.seqStart??r,c=Fe.value.at(-1);if(c===void 0){let e=t.rows;if(!e.length)break;if(e[0].seqStart<=s||a){let t=e.findIndex(e=>e.seqStart>s);t>=0&&i.push(...e.slice(t,t+100-i.length));break}Fe.value.push(e[0].seqStart);continue}o++;let l=Fe.value,u=e=>!e.hasOlder||e.rows.some(e=>e.seqStart<=s),d=Vr.has(c)?0:Math.min(Hr,l.length-1);if(d>0){let t=l.length-1-d,r=await Br(e,n,l[t]);if(r.epoch!==n)return`stale`;if(u(r)){let e=l[t],n=r.rows.filter(e=>e.seqStart>s),a=100-i.length;l.splice(t),n.length>a&&l.push(e),i.push(...n.slice(0,a).map(e=>({seqStart:e.seqStart,row:y(e)}))),Hr=Math.min(Hr*2,64);continue}Hr=d>>1;continue}let f=await Br(e,n,c);if(f.epoch!==n)return`stale`;let p=f.rows.filter(e=>e.seqStart>s),m=!0;for(;!Vr.has(c)&&p.length&&f.hasOlder&&!f.rows.some(e=>e.seqStart<=s)&&o<8;){o++;let t=p[0].seqStart,r=await Br(e,n,t);if(r.epoch!==n)return`stale`;let i=r.rows.filter(e=>e.seqStart>s&&e.seqStart<t);if(!i.length)break;f=r,p=i,m=!1}let h=100-i.length;if(!p.length&&c===t.rows[0]?.seqStart&&(a=!0),m&&p.length<=h&&Fe.value.pop(),i.push(...p.slice(0,h).map(e=>({seqStart:e.seqStart,row:y(e)}))),!m)break}return i.length?i:null}async function Wr(e){let t=je.value,n=Le.value,r=Qt.value.slice();e===`before`&&r.forEach((e,t)=>r[t]={seqStart:e.seqStart,row:y(e.row.value)});let i=e===`before`?r[0]:r.at(-1),a=Q.value;if(!a||!i||Ie.value)return;let o=t.epoch;Ie.value=e;try{let s=()=>je.value===t&&t.epoch===o&&Q.value?.key===a.key;if(e===`before`){let e=await Br(a,o,i.seqStart);if(!s())return;if(e.epoch!==o)return zr();let t=Rn(`first`),c=dn(r,e,`before`);c.added&&(Fe.value.push(r.at(-1).seqStart+1),Vr.add(r.at(-1).seqStart+1)),Ne.value=c.rows,Pe.value=c.hasOlder,await C(),!zn(t)&&n&&(n.scrollTop=0)}else{let e=await Ur(a,t,o,i.seqStart);if(!s())return;if(e===`stale`)return zr();let c=t.rows.at(-1)?.seqStart,l=[...r,...e??[]].slice(-150);if(!e||c!==void 0&&l.at(-1).seqStart>=c){Fe.value=[],await Vn();return}let u=Rn(`last`);Ne.value=l,Pe.value=!0,await C(),!zn(u)&&n&&(n.scrollTop=n.scrollHeight)}}catch(e){Se.value=String(e.message),Nn=null}finally{Ie.value=null}C(Ln)}let Gr=matchMedia(`(hover: hover) and (pointer: fine)`).matches,Kr=y(null),qr=``;async function Jr(e,t){qr=t.epoch;try{let n=await $(Tn(e)+`/timeline/prompts`);je.value===t&&n.epoch===t.epoch&&(Kr.value={key:e.key,prompts:n.prompts})}catch{je.value===t&&(Kr.value={key:e.key,prompts:[]})}}n(()=>Q.value?.key,()=>{Kr.value=null,qr=``,Vr.clear()});let Yr=e=>String(e.item.text??``).replace(/\s+/g,` `).trim().slice(0,240),Xr=S(()=>{let e=je.value;e.membership.value;let t=Kr.value?.key===Q.value?.key?Kr.value?.prompts??[]:[],n=t.at(-1)?.seq??-1,r=[];for(let t of e.rows)t.seqStart>n&&t.row.value.item.type===`user_message`&&r.push({seq:t.seqStart,preview:Yr(t.row.value)});return r.length?[...t,...r]:t}),Zr=e(null),Qr=0;function $r(){Qr||Xr.value.length<2||!Gr||(Qr=requestAnimationFrame(()=>{Qr=0;let e=Rn(`first`);Zr.value=e?Number(e.seq):null}))}n([Xr,Ne],()=>void C($r));function ei(e){let t=Le.value,n=t?.querySelector(`[data-seq-start="${e}"]`)??Array.from(t?.querySelectorAll(`[data-seq-start]`)??[]).find(t=>Number(t.dataset.seqStart)>=e||t.classList.contains(`row-assistant`)&&Number(t.dataset.seqEnd)>=e);t&&n&&(Mn=!1,In(t,t.scrollTop+n.getBoundingClientRect().top-t.getBoundingClientRect().top-12),$r())}async function ti(e,t=!1){let n=Q.value,r=je.value;if(!n||Ie.value)return;if(Le.value?.querySelector(`[data-seq-start="${e}"]`))return ei(e);let i=r.rows,a=i.length&&i[0].seqStart<=e?i.findIndex(t=>t.seqStart>=e||t.row.value.item.type===`assistant_message`&&t.row.value.seqEnd>=e):-1;if(a>=0){let t=a;return Fe.value=[],t>=i.length-150?Ne.value=null:(Ne.value=i.slice(t,t+150),Pe.value=t>0||r.hasOlder),await C(),ei(e)}let o=r.epoch,s=Xr.value.map(e=>e.seq).filter(t=>t>e&&(!i.length||t<i[0].seqStart));Ie.value=`before`;try{let a=t?e+1:s[0]??i[0]?.seqStart??2**53-1,c=[],l=!1;for(let t=0;t<8;t++){let t=await Br(n,o,a);if(je.value!==r||Q.value?.key!==n.key)return;if(t.epoch!==o)return zr();if(c=[...t.rows,...c],l=t.hasOlder,!t.rows.length||t.rows[0].seqStart<=e||!t.hasOlder)break;a=t.rows[0].seqStart}let u=Math.max(0,c.findIndex(t=>t.seqStart>=e||t.item.type===`assistant_message`&&t.seqEnd>=e)),d=c.slice(u,u+150).map(e=>({seqStart:e.seqStart,row:y(e)}));if(Fe.value=[...s].reverse(),Vr.clear(),Hr=4,d.length&&d.length<=50){let e=await Ur(n,r,o,d.at(-1).seqStart);if(je.value!==r||Q.value?.key!==n.key)return;if(e===`stale`)return zr();e&&(d=[...d,...e])}Ne.value=d,Pe.value=l||u>0,await C(),ei(e),Nn=`down`,requestAnimationFrame(Ln)}catch(e){Se.value=String(e.message)}finally{Ie.value=null}}function ni(){let e=Re.value;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,Math.round(window.innerHeight*.4))+`px`)}function ri(e){e.key===`Tab`&&!e.shiftKey&&jr.value?(e.preventDefault(),Ct.value=jr.value,C(ni)):e.key!==`Enter`||e.isComposing||(!E&&!e.shiftKey||e.metaKey||e.ctrlKey)&&(e.preventDefault(),ii())}async function ii(){await oi(Ct.value,!0)}function ai(e){return e.turnActive===!1||e.turnActive===void 0&&e.status!==`running`&&e.status!==`initializing`}async function oi(e,t=!1){let n=Q.value;if(!n||!e.trim()&&(!t||!lt.value.length)||wt.value||Y.value||t&&!xt.value)return;if(Ue.value===`steer`&&(!ai(n)||Ye.value.length>0)){let r=t?[...lt.value]:[];await wn(async()=>{let i=r.map(e=>e.id),a=JSON.stringify([n.key,e,i]),o=Xe.get(a)??crypto.randomUUID();Xe.set(a,o);try{await $(Tn(n)+`/queue`,`POST`,{id:o,text:e,attachmentIds:i})}catch(e){throw await et(),e}Xe.delete(a);for(let e of r)Je.remove(n.key,e,!0);t&&Z.state(n.key).text===e&&Z.setText(n.key,``),X.value===n.key&&(Ar.value=null),await et(),C(ni)});return}let r=t?[...lt.value]:[];t&&Z.setText(n.key,``),await si(n,e,r,Ue.value,{restore:t})}async function si(e,t,n,r,{restore:i}){let a=Z.state(e.key),o=Z.generation,s={text:t,messageId:crypto.randomUUID(),attachmentIds:n.map(e=>e.id),attachmentNames:n.map(e=>e.file.name)};Z.begin(e.key,s);let c=!1;return await wn(async()=>{try{if(await $(Tn(e)+`/messages`,`POST`,{...s,behavior:r}),c=!0,o!==Z.generation)return;Z.resolve(e.key,s.messageId);for(let t of n)Je.remove(e.key,t,!0);X.value===e.key&&(Ar.value=null),C(ni),X.value===e.key&&zr()}catch(t){if(o!==Z.generation)return;if(t.delivery===`not-sent`){Z.resolve(e.key,s.messageId);for(let e of n)e.error=`Not sent. Retry the upload or remove this attachment.`}throw i&&!a.text&&Z.restoreFailed(e.key,s),t}}),c}async function ci(e){let t=Q.value;t&&await wn(async()=>{await $(Tn(t)+`/queue/`+e.id,`DELETE`),await et()})}async function li(e){let t=Q.value;if(!t)return;let n=Qe.value;await wn(async()=>{await $(Tn(t)+`/queue/`+e.id,`PATCH`,{text:n}),Ze.value=null,await et()})}async function ui(e){let t=Q.value;!t||Y.value||wt.value||await wn(async()=>{await $(Tn(t)+`/queue/`+e.id+`/send`,`POST`),await et()})}async function di(){let e=Q.value;e&&await wn(async()=>void await $(Tn(e)+`/stop`,`POST`))}async function fi(e,t){let n=Q.value;n&&await wn(async()=>{await $(Tn(n)+`/permissions/`+encodeURIComponent(e.id),`POST`,t)})}async function pi(){await wn(async()=>{await $(`/hosts`,`POST`,{label:Ve.value,connection:He.value}),Ve.value=``,He.value=``})}async function mi(e){confirm(`Disconnect and remove ${e.label}? Its agents keep running on the host.`)&&await wn(async()=>void await $(`/hosts/`+e.id,`DELETE`))}async function hi(e){try{qe.value=await $(`/board`,`PUT`,{revision:qe.value.revision,cards:e})}catch(e){throw qe.value=await $(`/board`),e}}function gi(e){let t=Te.get(e);return t?{hostId:t.hostId,agentId:t.id}:{hostId:null,agentId:null}}async function _i(){await wn(async()=>{Ge.value.trim()&&(await hi([...qe.value.cards,{id:crypto.randomUUID(),title:Ge.value.trim(),column:`Todo`,...gi(Ke.value),createdAt:Date.now()}]),Ge.value=``,Ke.value=``)})}async function vi(e,t){await wn(async()=>{qe.value=await $(`/board/cards/${encodeURIComponent(e.id)}`,`PATCH`,t)})}async function yi(e,t){let n=gi(t);await vi(e,{link:n.hostId&&n.agentId?{hostId:n.hostId,agentId:n.agentId}:null})}async function bi(e,t){await wn(async()=>{qe.value=await $(`/board/cards/${encodeURIComponent(e.id)}/comments`,`POST`,{text:t})})}async function xi(e,t){await wn(async()=>{qe.value=await $(`/board/cards/${encodeURIComponent(e.id)}/comments/${encodeURIComponent(t)}`,`DELETE`)})}function Si(e){if(!e.description&&!e.comments?.length)return void Ci(e);confirm(`Delete “${e.title}”? Its description and comments are deleted too.`)&&Ci(e)}async function Ci(e){await wn(()=>hi(qe.value.cards.filter(t=>t.id!==e.id))),wi.value===e.id&&(wi.value=null)}let wi=e(null),Ti=S(()=>qe.value.cards.find(e=>e.id===wi.value)??null);function Ei(e){return(e.description??``).replace(/```[\s\S]*?```/g,` `).replace(/[#>*_`~\[\]()|-]+/g,` `).replace(/\s+/g,` `).trim().slice(0,160)}let Di=S(()=>{Te.version.value;let e=Te.range(0,30),t=Q.value,n=t?[t,...e.filter(e=>e.key!==t.key)]:e,r=Ce.value.length>1;return n.map(e=>({key:e.key,label:(e.title||`${e.provider} · ${e.project}`)+(r?` (${Mt.value.get(e.hostId)??e.hostId})`:``)}))});function Oi(e){return Te.version.value,e.hostId&&e.agentId?Te.get(`${e.hostId}:${e.agentId}`)??null:null}async function ki(e,t){await vi(e,{column:t})}function Ai(e){e.hostId&&e.agentId&&Wn(`${e.hostId}:${e.agentId}`)}function ji(e){We.value=e,e!==`chat`||X.value?qn():Jn()}Dn();let Ni=S(()=>(we.version.value,Te.waiting));n(Ni,e=>{Bo(e),document.title=e?`(${e}) LitePaseo`:`LitePaseo`});let Pi=S(()=>(Te.version.value,Te.waiting?`attention`:Te.allLaneSize(`running`)?`running`:Te.allLaneSize(`review`)?`unread`:``));return n(Pi,e=>Vo(e),{immediate:!0}),document.addEventListener(`visibilitychange`,()=>{document.hidden||Rr()}),l(()=>{clearInterval(Lr),clearInterval(kt),clearTimeout(Xt),document.removeEventListener(`visibilitychange`,Zt),Je.clear(),window.removeEventListener(`storage`,jt),window.removeEventListener(`popstate`,Yn),window.removeEventListener(`keydown`,Zn),yn?.close(),Sn?.close(),clearTimeout(Cn)}),(e,n)=>xe.value?(i(),R(`div`,{key:1,class:M([`shell`,{"detail-open":Be.value,"is-resizing":pe.value}]),style:g({"--sidebar-w":de.value+`px`})},[x(`aside`,hd,[x(`div`,{class:M([`sidebar-resize`,{"is-dragging":pe.value}]),role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":de.value,"aria-valuemin":Kp,"aria-valuemax":qp,tabindex:`0`,title:`Drag to resize · double-click to reset`,onPointerdown:he,onDblclick:n[2]||=e=>me(Jp),onKeydown:[n[3]||=P(v(e=>me(de.value-16),[`prevent`]),[`left`]),n[4]||=P(v(e=>me(de.value+16),[`prevent`]),[`right`])]},null,42,gd),x(`nav`,_d,[x(`label`,{class:M([`side-row side-search`,{active:!!ze.value}])},[t(J,{name:`search`,size:15}),a(x(`input`,{ref_key:`searchInput`,ref:Xn,"onUpdate:modelValue":n[5]||=e=>ze.value=e,type:`search`,placeholder:`Search`,"aria-label":`Search sessions, projects, hosts`,"aria-keyshortcuts":`/ Control+K Meta+K`},null,512),[[_,ze.value]]),x(`kbd`,vd,k(D(O)?`⌘K`:`Ctrl K`),1)],2),x(`button`,{class:M([`side-row`,{chosen:We.value===`board`}]),onClick:n[6]||=e=>ji(`board`)},[t(J,{name:`board`,size:15}),n[73]||=d(`Kanban `,-1)],2)]),x(`div`,yd,[x(`span`,bd,k(Oe.value===`projects`?`Workspaces`:`Recent`),1),x(`span`,xd,k(Oe.value===`projects`?zt.value:Rt.value),1),x(`button`,{class:M([`icon-btn side-tool`,{chosen:j.value||Bt.value!==null||Oe.value!==`projects`}]),"aria-label":`View options`,title:`Group and filter`,"aria-expanded":j.value,onClick:n[7]||=e=>j.value=!j.value},[t(J,{name:`sliders`,size:15})],10,Sd)]),Bt.value?(i(),R(`div`,Cd,[x(`button`,{class:`active-host-label`,title:`Filtered by host: `+(Mt.value.get(Bt.value)??Bt.value),onClick:n[8]||=e=>j.value=!0},[t(J,{name:`server`,size:13}),x(`span`,null,`Host: `+k(Mt.value.get(Bt.value)??Bt.value),1)],8,wd),x(`button`,{class:`icon-btn`,"aria-label":`Clear host filter`,title:`Show all hosts`,onClick:n[9]||=e=>Bt.value=null},[t(J,{name:`close`,size:13})])])):F(``,!0),j.value?(i(),R(`div`,Td,[x(`div`,Ed,[x(`button`,{role:`radio`,"aria-checked":Oe.value===`projects`,class:M({chosen:Oe.value===`projects`}),onClick:n[10]||=e=>Oe.value=`projects`},` By project `,10,Dd),x(`button`,{role:`radio`,"aria-checked":Oe.value===`recent`,class:M({chosen:Oe.value===`recent`}),onClick:n[11]||=e=>Oe.value=`recent`},`Recent`,10,Od)]),Ce.value.length>1?(i(),R(`div`,kd,[x(`button`,{role:`radio`,"aria-checked":Bt.value===null,class:M({chosen:Bt.value===null}),onClick:n[12]||=e=>Bt.value=null},[n[74]||=d(` All`,-1),x(`span`,jd,k(Lt.value),1)],10,Ad),(i(!0),R(b,null,z(Ce.value,e=>(i(),R(`button`,{key:e.id,role:`radio`,"aria-checked":Bt.value===e.id,class:M({chosen:Bt.value===e.id}),title:e.label+` · `+e.state,onClick:t=>Bt.value=e.id},[x(`span`,{class:M([`status-dot`,e.state===`connected`?`is-idle-ok`:`is-offline`])},null,2),d(k(e.label),1),x(`span`,Nd,k(Vt.value.get(e.id)),1)],10,Md))),128))])):F(``,!0)])):F(``,!0),t(gr,{queues:tt.value,mode:Oe.value,store:D(we),"host-labels":Mt.value,"host-states":Nt.value,"selected-key":De.value,searching:!!ze.value.trim(),onSelect:Gn,onNew:$n,onMenu:ar,onProjectMenu:xr},null,8,[`queues`,`mode`,`store`,`host-labels`,`host-states`,`selected-key`,`searching`]),t(Gc,{report:Fr.value,loading:Ir.value,onRefresh:n[13]||=e=>Rr(!0)},null,8,[`report`,`loading`]),x(`div`,Pd,[x(`span`,{class:M([`live`,`is-`+Ae.value]),title:`Directory stream: `+Ae.value},[n[75]||=x(`span`,{class:`live-dot`},null,-1),d(k(vn.value),1)],10,Fd),x(`button`,{class:M([`icon-btn`,{chosen:We.value===`schedules`}]),title:`Schedules`,"aria-label":`Schedules`,onClick:n[14]||=e=>ji(`schedules`)},[t(J,{name:`clock`,size:15})],2),x(`button`,{class:M([`icon-btn foot-hosts`,{chosen:We.value===`hosts`}]),title:`Hosts: ${Pt.value} of ${Ce.value.length} connected`,"aria-label":`Hosts, ${Pt.value} of ${Ce.value.length} connected`,onClick:n[15]||=e=>ji(`hosts`)},[t(J,{name:`server`,size:15}),Pt.value<Ce.value.length?(i(),R(`span`,Ld)):F(``,!0)],10,Id),x(`button`,{class:`icon-btn`,title:`Theme: `+D(co)+` (click to change)`,"aria-label":`Theme: `+D(co),onClick:n[16]||=(...e)=>D(ho)&&D(ho)(...e)},[t(J,{name:D(co)===`dark`?`moon`:D(co)===`light`?`sun`:`monitor`,size:15},null,8,[`name`])],8,Rd),x(`button`,{class:M([`icon-btn`,{chosen:We.value===`settings`}]),title:`Settings`,"aria-label":`Settings`,onClick:n[17]||=e=>ji(`settings`)},[t(J,{name:`gear`,size:15})],2)])]),x(`main`,zd,[Se.value?(i(),R(`div`,Bd,[t(J,{name:`alert`,size:15}),x(`span`,null,k(Se.value),1),x(`button`,{class:`icon-btn`,"aria-label":`Dismiss`,onClick:n[18]||=e=>Se.value=``},[t(J,{name:`close`,size:14})])])):F(``,!0),We.value===`settings`?(i(),m(hc,{key:1,request:$,"totp-enabled":!!be.value?.totp,onBack:Jn,onSignedOut:n[19]||=e=>En(`user`),onTotpChanged:n[20]||=e=>be.value&&(be.value.totp=e),onDictationChanged:n[21]||=e=>ut.value=e},null,8,[`totp-enabled`])):We.value===`hosts`?(i(),R(`section`,Vd,[x(`header`,Hd,[x(`button`,{class:`icon-btn back`,"aria-label":`Back`,onClick:Jn},[t(J,{name:`back`,size:18})]),n[76]||=x(`div`,null,[x(`h1`,null,`Hosts`),x(`p`,{class:`subtle`},`Paseo daemons this console connects to. Secrets stay on this server.`)],-1)]),x(`div`,Ud,[x(`div`,Wd,[(i(!0),R(b,null,z(Ce.value,e=>(i(),R(`div`,{key:e.id,class:`card-row`},[x(`span`,{class:M([`status-dot`,e.state===`connected`?`is-idle-ok`:`is-offline`])},null,2),x(`div`,Gd,[x(`div`,Kd,k(e.label),1),x(`div`,qd,k(e.state),1),e.diagnostic?.error?(i(),R(`p`,Jd,k(e.diagnostic.error.message),1)):F(``,!0),e.diagnostic?.lastConnectedAt?(i(),R(`div`,Yd,`Last connected: `+k(new Date(e.diagnostic.lastConnectedAt).toLocaleString()),1)):F(``,!0),e.diagnostic?.attempt?(i(),R(`div`,Xd,`Connection attempt `+k(e.diagnostic.attempt),1)):F(``,!0),e.diagnostic?.nextRetryAt?(i(),R(`div`,Zd,`Next retry: `+k(new Date(e.diagnostic.nextRetryAt).toLocaleString()),1)):F(``,!0)]),x(`button`,{class:`btn btn-outline`,disabled:Y.value,onClick:t=>mi(e)},`Remove`,8,Qd)]))),128)),Ce.value.length?F(``,!0):(i(),R(`div`,$d,`No hosts yet.`))]),n[80]||=x(`h2`,{class:`section-label`},`Add a host`,-1),x(`form`,{class:`card form-card`,onSubmit:v(pi,[`prevent`])},[x(`label`,ef,[n[77]||=x(`span`,null,`Name`,-1),a(x(`input`,{"onUpdate:modelValue":n[22]||=e=>Ve.value=e,placeholder:`Build server`,required:``},null,512),[[_,Ve.value]])]),x(`label`,tf,[n[78]||=x(`span`,null,`Connection`,-1),a(x(`input`,{"onUpdate:modelValue":n[23]||=e=>He.value=e,type:`password`,placeholder:`ws://host:port/ws, pairing offer or SSH target`,required:``,autocomplete:`off`,"aria-describedby":`host-connection-help`},null,512),[[_,He.value]])]),n[79]||=L(`<div id="host-connection-help" class="field-help"><p> The LitePaseo server connects to the daemon, so the address must be reachable from the server, not from this browser. The default daemon port is <code>6767</code>. </p><details><summary>Connection formats</summary><dl><dt>Same machine</dt><dd><code>6767</code> or <code>127.0.0.1:6767</code></dd><dt>Network address</dt><dd><code>192.168.1.10:6767</code>, <code>tcp://host:6767</code>, <code>ws://host:6767/ws</code> or <code>wss://host/ws</code></dd><dt>Daemon password</dt><dd><code>ws://host:6767/ws?password=…</code></dd><dt>SSH tunnel</dt><dd><code>ssh://user@host</code> or <code>ssh://user@host:2222?daemonPort=6767</code>. Key-based login only: the server&#39;s user must be able to run <code>ssh user@host</code> without a prompt. </dd><dt>Pairing / relay</dt><dd>Paste a pairing link from Paseo (containing <code>#connect=</code>) or a <code>relay://</code> URL.</dd><dt>Local socket</dt><dd><code>unix:///path/to/socket</code></dd></dl></details></div>`,1),x(`div`,nf,[x(`button`,{class:`btn btn-primary`,disabled:Y.value},`Add host`,8,rf)])],32)])])):We.value===`schedules`?(i(),m(rd,{key:3,hosts:Ce.value,api:$,onBack:Jn,onOpenAgent:Wn},null,8,[`hosts`])):We.value===`board`?(i(),R(`section`,af,[x(`header`,of,[x(`button`,{class:`icon-btn back`,"aria-label":`Back`,onClick:Jn},[t(J,{name:`back`,size:18})]),x(`div`,null,[n[81]||=x(`h1`,null,`Kanban`,-1),x(`p`,sf,k(wr.value===`agents`?`Every agent by state, live. Follows the host filter and search.`:`Your own plan. Moving a card never changes an agent.`),1)]),x(`div`,cf,[x(`button`,{class:M({chosen:wr.value===`agents`}),onClick:n[24]||=e=>wr.value=`agents`},`Agents`,2),x(`button`,{class:M({chosen:wr.value===`plan`}),onClick:n[25]||=e=>wr.value=`plan`},`Plan`,2)])]),x(`div`,lf,[wr.value===`agents`?(i(),m(Ac,{key:0,store:D(Te),"host-labels":Mt.value,busy:Y.value,onOpen:Wn,onStop:Tr,onRead:Er,onArchive:Dr},null,8,[`store`,`host-labels`,`busy`])):(i(),R(b,{key:1},[x(`form`,{class:`add-card`,onSubmit:v(_i,[`prevent`])},[a(x(`input`,{"onUpdate:modelValue":n[26]||=e=>Ge.value=e,placeholder:`New task`,required:``},null,512),[[_,Ge.value]]),a(x(`select`,{"onUpdate:modelValue":n[27]||=e=>Ke.value=e,class:`card-link-select`,"aria-label":`Link to conversation`},[n[82]||=x(`option`,{value:``},`No conversation`,-1),(i(!0),R(b,null,z(Di.value,e=>(i(),R(`option`,{key:e.key,value:e.key},k(e.label),9,uf))),128))],512),[[N,Ke.value]]),x(`button`,{class:`btn btn-primary`,disabled:Y.value},[t(J,{name:`plus`,size:15}),n[83]||=d(`Add task`,-1)],8,df)],32),x(`div`,ff,[(i(),R(b,null,z(w,e=>x(`div`,{key:e,class:`column`},[x(`div`,pf,[x(`h3`,null,k(e),1),x(`span`,mf,k(gn.value.get(e).length),1)]),(i(!0),R(b,null,z(gn.value.get(e),e=>(i(),R(`article`,{key:e.id,class:`card kanban-card`},[x(`button`,{type:`button`,class:`kanban-open`,"aria-label":`Open task `+e.title,onClick:t=>wi.value=e.id},[x(`span`,gf,k(e.title),1),Ei(e)?(i(),R(`span`,_f,k(Ei(e)),1)):F(``,!0)],8,hf),e.agentId?(i(),R(`div`,vf,[Oi(e)?(i(),R(`button`,{key:0,class:`link-btn`,title:`Open `+(Oi(e).title||Oi(e).id),onClick:t=>Ai(e)},[t(J,{name:`chat`,size:13}),x(`span`,bf,k(Oi(e).title||Oi(e).provider),1)],8,yf)):(i(),R(`span`,xf,`Conversation unavailable`)),x(`button`,{class:`icon-btn`,"aria-label":`Unlink conversation`,title:`Unlink conversation`,disabled:Y.value,onClick:t=>yi(e,``)},[t(J,{name:`close`,size:13})],8,Sf)])):(i(),R(`select`,{key:1,class:`card-link-select`,"aria-label":`Link to conversation`,disabled:Y.value,value:``,onChange:t=>yi(e,t.target.value)},[n[84]||=x(`option`,{value:``,disabled:``},`Link a conversation…`,-1),(i(!0),R(b,null,z(Di.value,e=>(i(),R(`option`,{key:e.key,value:e.key},k(e.label),9,wf))),128))],40,Cf)),x(`div`,Tf,[x(`select`,{value:e.column,"aria-label":`Column`,onChange:t=>ki(e,t.target.value)},[(i(),R(b,null,z(w,e=>x(`option`,{key:e},k(e),1)),64))],40,Ef),e.comments?.length?(i(),R(`button`,{key:0,type:`button`,class:`kanban-count`,title:e.comments.length+` comments`,onClick:t=>wi.value=e.id},[t(J,{name:`chat`,size:13}),d(k(e.comments.length),1)],8,Df)):F(``,!0),x(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Edit task`,title:`Edit`,onClick:t=>wi.value=e.id},[t(J,{name:`edit`,size:15})],8,Of),x(`button`,{class:`icon-btn`,"aria-label":`Remove`,onClick:t=>Si(e)},[t(J,{name:`trash`,size:15})],8,kf)])]))),128)),gn.value.get(e).length?F(``,!0):(i(),R(`p`,Af,`Nothing here`))])),64))]),Ti.value?(i(),m(Sl,{key:Ti.value.id,card:Ti.value,columns:w,links:Di.value,"linked-name":Oi(Ti.value)?Oi(Ti.value).title||Oi(Ti.value).provider:null,busy:Y.value,onClose:n[28]||=e=>wi.value=null,onPatch:n[29]||=e=>vi(Ti.value,e),onComment:n[30]||=e=>bi(Ti.value,e),onUncomment:n[31]||=e=>xi(Ti.value,e),onRemove:n[32]||=e=>Ci(Ti.value),onOpen:n[33]||=e=>{wi.value=null,Ai(Ti.value)}},null,8,[`card`,`links`,`linked-name`,`busy`])):F(``,!0)],64))])])):Q.value?(i(),R(`div`,{key:5,class:`chat-split`,style:g({"--panel-w":se.value+`px`})},[x(`section`,jf,[x(`header`,Mf,[x(`button`,{class:`icon-btn back`,"aria-label":`Back to sessions`,onClick:Jn},[t(J,{name:`back`,size:18})]),x(`span`,{class:M([`status-dot chat-status`,`is-`+(Q.value.attention?`attention`:Q.value.state===`failed`?`error`:Q.value.state===`running`?`running`:`idle`)]),title:Q.value.status},null,10,Nf),x(`h1`,{class:`chat-title`,title:Ft.value?.name||Q.value.title||``},[Ft.value?.pinnedAt?(i(),m(J,{key:0,name:`pin`,size:12,class:`title-pin`})):F(``,!0),d(k(Ft.value?.name||Q.value.title||`Untitled session`),1)],8,Pf),x(`span`,{class:`chat-context hide-sm`,title:[Ut.value,Mt.value.get(Q.value.hostId),Ft.value?.branch,Q.value.provider].filter(Boolean).join(` · `)},[d(k(Ut.value),1),Ce.value.length>1?(i(),R(b,{key:0},[d(` · `+k(Mt.value.get(Q.value.hostId)),1)],64)):F(``,!0),Ft.value?.branch?(i(),R(b,{key:1},[d(` · `+k(Ft.value.branch),1)],64)):F(``,!0)],8,Ff),n[85]||=x(`span`,{class:`grow`},null,-1),x(`button`,{class:`icon-btn head-tool`,"aria-label":`Changes`,title:`Workspace changes`,onClick:n[34]||=e=>V(`changes`)},[t(J,{name:`file`,size:16})]),x(`button`,{class:`icon-btn head-tool`,"aria-label":`Search conversation`,title:`Search conversation`,onClick:n[35]||=e=>V(`search`)},[t(J,{name:`search`,size:16})]),x(`button`,{class:M([`icon-btn head-tool`,{chosen:B.value===`files`}]),"aria-label":`Files`,title:`Files`,onClick:n[36]||=e=>V(`files`)},[t(J,{name:`folder`,size:16})],2),x(`button`,{class:M([`icon-btn head-tool`,{chosen:W.value}]),"aria-label":`Terminal`,title:`Terminal`,onClick:n[37]||=e=>ee()},[t(J,{name:`terminal`,size:16})],2),Ft.value?(i(),R(`button`,{key:0,class:`icon-btn head-tool`,"aria-label":`Thread actions`,title:`Rename, pin, mark unread, archive`,onClick:or},[t(J,{name:`more`,size:16})])):F(``,!0)]),It.value.length>1||ne.value.length||U.value?(i(),R(`nav`,If,[(i(!0),R(b,null,z(It.value.length?It.value:[Q.value],e=>(i(),R(`button`,{key:e.key,class:M({chosen:e.key===X.value&&!q.value&&!W.value}),onClick:t=>{X.value=e.key,te()}},[x(`span`,{class:M([`status-dot`,`is-`+(e.attention?`attention`:e.state===`failed`?`error`:e.state===`running`?`running`:e.unread?`unread`:`idle`)])},null,2),x(`span`,Rf,k(e.title||e.provider),1)],10,Lf))),128)),(i(!0),R(b,null,z(ne.value,e=>(i(),R(`button`,{key:`file:`+e,class:M([`file-tab`,{chosen:q.value===e}]),title:e,onClick:t=>q.value=e,onAuxclick:v(t=>t.button===1&&ie(e),[`prevent`])},[t(J,{name:`file`,size:13}),x(`span`,Bf,k(e.split(`/`).pop()),1),x(`span`,{class:`tab-close`,role:`button`,"aria-label":`Close `+e,onClick:v(t=>ie(e),[`stop`])},[t(J,{name:`close`,size:11})],8,Vf)],42,zf))),128)),U.value?(i(),R(`button`,{key:0,class:M([`file-tab`,{chosen:W.value}]),onClick:n[39]||=e=>ee()},[t(J,{name:`terminal`,size:13}),n[86]||=x(`span`,{class:`agent-tab-name`},`Terminal`,-1),x(`span`,{class:`tab-close`,role:`button`,"aria-label":`Close terminal tab`,onClick:n[38]||=v(e=>H.delete(K.value),[`stop`])},[t(J,{name:`close`,size:11})])],2)):F(``,!0)])):F(``,!0),U.value?a((i(),m(D(h),{key:`t:`+Q.value.hostId+Ht.value,"host-id":Q.value.hostId,cwd:Ht.value,api:$,visible:W.value},null,8,[`host-id`,`cwd`,`visible`])),[[T,W.value]]):F(``,!0),q.value?(i(),m(D(p),{key:Q.value.hostId+`:`+Ht.value+`:`+q.value,"host-id":Q.value.hostId,cwd:Ht.value,path:q.value,api:$},null,8,[`host-id`,`cwd`,`path`])):F(``,!0),a(x(`div`,Hf,[x(`div`,{ref_key:`timelineElement`,ref:Le,class:`timeline`,onClick:pn},[x(`div`,Uf,[hn.value?(i(),R(`div`,Wf,[Ie.value===`before`?(i(),R(`span`,Gf,[...n[87]||=[x(`span`,{class:`spinner`},null,-1),d(`Loading earlier messages…`,-1)]])):(i(),R(`button`,{key:1,class:`btn btn-ghost`,onClick:n[40]||=e=>Wr(`before`)},`Show earlier messages`))])):F(``,!0),Me.value?(i(),R(`p`,Kf,[t(J,{name:`alert`,size:14}),d(k(Me.value),1)])):F(``,!0),(i(!0),R(b,null,z(Qt.value,e=>(i(),R(b,{key:`${Q.value?.key}:${je.value.epoch}:${e.seqStart}`},[t(Mi,{entry:e.row,final:e.seqStart!==mn.value||$t.value,"data-seq-start":e.seqStart},null,8,[`entry`,`final`,`data-seq-start`]),en.value.get(e.seqStart)?(i(),R(`div`,qf,[en.value.get(e.seqStart).messages.length?(i(),R(`button`,{key:0,type:`button`,class:`turn-item turn-copy`,"aria-label":tn.value===e.seqStart?`Copied`:`Copy turn`,title:tn.value===e.seqStart?`Copied`:`Copy turn`,onClick:t=>an(e.seqStart,en.value.get(e.seqStart).messages)},[t(J,{name:tn.value===e.seqStart?`check`:`copy`,size:14},null,8,[`name`]),d(k(tn.value===e.seqStart?`Copied`:`Copy`),1)],8,Jf)):F(``,!0),ct.value&&e.row.value.provider===Q.value.provider?(i(),R(`span`,{key:1,class:`turn-item`,title:`Model: `+ct.value},[t(kl,{provider:e.row.value.provider},null,8,[`provider`]),d(k(ct.value),1)],8,Yf)):F(``,!0),x(`span`,{class:`turn-item`,title:`Finished `+en.value.get(e.seqStart).at},[t(J,{name:`clock`,size:14}),d(k(en.value.get(e.seqStart).at),1)],8,Xf),en.value.get(e.seqStart).took?(i(),R(`span`,{key:2,class:`turn-item`,title:`Worked for `+en.value.get(e.seqStart).took},[t(J,{name:`hourglass`,size:14}),d(k(en.value.get(e.seqStart).took),1)],8,Zf)):F(``,!0)])):F(``,!0)],64))),128)),Ne.value?(i(),R(`div`,Qf,[Ie.value===`after`?(i(),R(`span`,$f,[...n[88]||=[x(`span`,{class:`spinner`},null,-1),d(`Loading newer messages…`,-1)]])):(i(),R(`button`,{key:1,class:`btn btn-ghost`,onClick:zr},`Back to latest`))])):F(``,!0),Gt.value?(i(),R(`div`,ep,[x(`span`,{class:`spinner spinner-ticked`,style:g(Jt.value?{transform:`rotate(${Yt.value*90}deg)`}:void 0)},null,4),Jt.value?(i(),R(`span`,tp,k(Jt.value),1)):(i(),R(`span`,np,`Working…`))])):F(``,!0),Qt.value.length?F(``,!0):(i(),R(`div`,rp,[je.value.ready?F(``,!0):(i(),R(`span`,ip)),d(` `+k(je.value.ready?`No messages yet.`:`Loading conversation…`),1)]))])],512),Xr.value.length>=2&&D(Gr)?(i(),m(_n,{key:0,prompts:Xr.value,"active-seq":Zr.value,onJump:ti},null,8,[`prompts`,`active-seq`])):F(``,!0)],512),[[T,!q.value&&!W.value]]),a(x(`div`,ap,[x(`div`,op,[(i(!0),R(b,null,z(Q.value.pendingPermissions,e=>(i(),m(oo,{key:Q.value.key+`:`+e.id,permission:e,busy:Y.value,onRespond:t=>fi(e,t)},null,8,[`permission`,`busy`,`onRespond`]))),128)),Dt.value?(i(),R(`p`,sp,k(Dt.value),1)):F(``,!0),D(Z).warning.value?(i(),R(`p`,cp,k(D(Z).warning.value),1)):F(``,!0),mt.value?(i(),R(`p`,lp,[t(J,{name:`alert`,size:13}),d(k(mt.value)+` `,1),x(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Dismiss`,onClick:n[41]||=e=>mt.value=``},[t(J,{name:`close`,size:12})])])):F(``,!0),Tt.value.length?(i(),R(`details`,up,[x(`summary`,null,`Other saved drafts (`+k(Tt.value.length)+`)`,1),(i(!0),R(b,null,z(Tt.value,e=>(i(),R(`div`,{key:e.slot},[x(`p`,dp,k(e.text),1),x(`button`,{class:`btn btn-ghost`,onClick:t=>X.value&&D(Z).restore(X.value,e.slot)},`Restore draft`,8,fp)]))),128))])):F(``,!0),wt.value&&!Y.value?(i(),R(`div`,pp,[t(J,{name:`alert`,size:15}),x(`span`,mp,`Delivery unknown. Check the conversation before sending again. Message: `+k(wt.value.text)+` `+k(wt.value.attachmentNames?.join(`, `)),1),x(`button`,{class:`btn btn-ghost`,disabled:Et.value,onClick:Ot},k(Et.value?`Checking…`:`Check delivery`),9,hp),x(`button`,{class:`btn btn-ghost`,onClick:At},`I checked`)])):F(``,!0),Ye.value.length?(i(),R(`div`,gp,[(i(!0),R(b,null,z(Ye.value,e=>(i(),R(`div`,{key:e.id,class:M([`queue-item`,{"is-error":e.error}]),role:`listitem`},[t(J,{name:e.error?`alert`:`clock`,size:14,class:`queue-icon`},null,8,[`name`]),x(`div`,_p,[Ze.value===e.id?(i(),R(b,{key:0},[a(x(`textarea`,{"onUpdate:modelValue":n[42]||=e=>Qe.value=e,"aria-label":`Queued message text`,rows:`3`},null,512),[[_,Qe.value]]),x(`button`,{type:`button`,class:`btn btn-ghost`,disabled:Y.value,onClick:t=>li(e)},`Save`,8,vp),x(`button`,{type:`button`,class:`btn btn-ghost`,onClick:n[43]||=e=>Ze.value=null},`Cancel`)],64)):(i(),R(`span`,{key:1,class:`queue-text`,title:e.text},k(e.text||`(attachments only)`),9,yp)),e.attachmentNames.length?(i(),R(`span`,bp,k(e.attachmentNames.join(`, `)),1)):F(``,!0),x(`span`,xp,k(e.sending?`Sending…`:e.error?`Delivery unknown · queue paused`:e.paused?`Paused`:Nt.value.get(Q.value.hostId)===`connected`?`Waiting for turn to finish`:`Waiting for host`),1),e.error?(i(),R(`span`,Sp,k(e.error),1)):F(``,!0)]),x(`button`,{class:`btn btn-ghost`,disabled:Y.value||e.sending,onClick:t=>it(e,e.paused?`resume`:`pause`)},k(e.paused?`Resume`:`Pause`),9,Cp),x(`button`,{class:`btn btn-ghost`,disabled:Y.value||e.sending||Ye.value[0].id===e.id,onClick:t=>it(e,`up`),"aria-label":`Move queued message up`},`↑`,8,wp),e.error?(i(),R(`button`,{key:0,class:`btn btn-ghost`,disabled:Y.value,onClick:t=>it(e,`check`)},`Check delivery`,8,Tp)):F(``,!0),x(`button`,{type:`button`,class:`queue-send`,disabled:Y.value||!!wt.value||e.sending,title:Wt.value?`Send now: stops the running turn`:`Send now`,onClick:t=>ui(e)},k(Wt.value?`Interrupt`:`Send`),9,Ep),x(`button`,{type:`button`,class:`icon-btn`,disabled:Y.value||e.sending,"aria-label":`Edit queued message`,title:`Edit`,onClick:t=>{Ze.value=e.id,Qe.value=e.text}},[t(J,{name:`edit`,size:14})],8,Dp),x(`button`,{type:`button`,class:`icon-btn`,disabled:Y.value||e.sending,"aria-label":`Remove queued message`,title:`Remove`,onClick:t=>ci(e)},[t(J,{name:`close`,size:14})],8,Op)],2))),128))])):F(``,!0),x(`form`,{class:M([`composer`,{"is-dragging":yt.value}]),onSubmit:v(ii,[`prevent`]),onDragover:n[48]||=v(e=>yt.value=!0,[`prevent`]),onDragleave:bt,onDrop:n[49]||=v(e=>{yt.value=!1,ot.value?.addFiles(e.dataTransfer?.files)},[`prevent`]),onPaste:St},[t(Ra,{ref_key:`attachmentPanel`,ref:ot,store:D(Je),"agent-key":Q.value.key,base:`/api`+Tn(Q.value),busy:Y.value||!!wt.value},null,8,[`store`,`agent-key`,`base`,`busy`]),dt.value?(i(),R(`div`,{key:0,ref_key:`dictationPreviewElement`,ref:ft,class:`dictation-preview`,role:`status`,"aria-live":`polite`},k(dt.value),513)):F(``,!0),a(x(`textarea`,{ref_key:`composerElement`,ref:Re,"onUpdate:modelValue":n[44]||=e=>Ct.value=e,rows:`1`,placeholder:Mr.value,required:!lt.value.length,onInput:ni,onKeydown:ri},null,40,kp),[[_,Ct.value]]),x(`div`,Ap,[x(`button`,{type:`button`,class:`composer-tool`,"aria-label":`Attach files`,title:ot.value?.hint,disabled:Y.value||!!wt.value||!ot.value?.available,onClick:n[45]||=e=>ot.value?.pick()},[t(J,{name:`plus`,size:18})],8,jp),t(nu,{ref_key:`agentControls`,ref:st,agent:Q.value,path:Tn(Q.value),api:$,disabled:Y.value||Nt.value.get(Q.value.hostId)!==`connected`,onNotice:gt},null,8,[`agent`,`path`,`disabled`]),x(`div`,Mp,[Wt.value?(i(),R(`button`,{key:0,type:`button`,class:M([`chip-behavior`,`is-`+Ue.value]),"aria-label":Ue.value===`steer`?`Queue: your message waits until the running turn ends (click for interrupt)`:`Interrupt: your message stops the running turn (click for queue)`,title:Ue.value===`steer`?`Queue: your message waits above the composer and is sent when the running turn ends`:`Interrupt: your message stops the running turn and starts a new one`,onClick:n[46]||=e=>Ue.value=Ue.value===`steer`?`interrupt`:`steer`},k(Ue.value===`steer`?`Queue`:`Interrupt`),11,Np)):F(``,!0),ut.value?(i(),m(ld,{key:Q.value.key,disabled:Y.value,onText:_t,onPreview:n[47]||=e=>dt.value=e,onNotice:gt},null,8,[`disabled`])):F(``,!0),Wt.value?(i(),R(`button`,{key:2,type:`button`,class:M([`disc disc-stop`,{"is-primary":!vt.value}]),"aria-label":`Stop turn`,title:`Stop turn`,disabled:Y.value,onClick:di},[t(J,{name:`stop`,size:18})],10,Pp)):F(``,!0),!Wt.value||vt.value?(i(),R(`button`,{key:3,class:`disc disc-send`,"aria-label":`Send`,title:`Send (Enter) · Shift+Enter for a new line`,disabled:Y.value||!!wt.value||!xt.value||!vt.value},[t(J,{name:`send`,size:17})],8,Fp)):F(``,!0)])])],34)])],512),[[T,!q.value&&!W.value]])]),B.value?(i(),R(`aside`,Ip,[x(`div`,{class:`panel-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize panel`,tabindex:`0`,onPointerdown:le,onDblclick:n[50]||=e=>ce(Gp)},null,32),x(`div`,Lp,[x(`button`,{class:M({chosen:B.value===`files`}),onClick:n[51]||=e=>B.value=`files`},[t(J,{name:`folder`,size:14}),n[89]||=d(`Files`,-1)],2),x(`button`,{class:M({chosen:B.value===`changes`}),onClick:n[52]||=e=>B.value=`changes`},`Changes`,2),x(`button`,{class:M({chosen:B.value===`search`}),onClick:n[53]||=e=>B.value=`search`},`Search`,2),n[90]||=x(`span`,{class:`grow`},null,-1),x(`button`,{class:`icon-btn`,"aria-label":`Close panel`,title:`Close panel`,onClick:n[54]||=e=>B.value=null},[t(J,{name:`close`,size:14})])]),x(`div`,Rp,[B.value===`changes`?(i(),m(D(s),{key:0,"host-id":Q.value.hostId,cwd:Ht.value,api:$},null,8,[`host-id`,`cwd`])):F(``,!0),B.value===`search`?(i(),m(D(c),{key:1,base:Tn(Q.value),api:$,onJump:at},null,8,[`base`])):F(``,!0),(i(),m(A,null,[B.value===`files`?(i(),m(D(f),{key:`f:`+Q.value.hostId+Ht.value,"host-id":Q.value.hostId,cwd:Ht.value,api:$,"active-path":q.value,onOpen:re},null,8,[`host-id`,`cwd`,`active-path`])):F(``,!0)],1024))])])):F(``,!0)],4)):We.value===`chat`&&tr.value?(i(),R(`section`,zp,[...n[91]||=[x(`span`,{class:`spinner`},null,-1),x(`p`,null,`Starting session…`,-1)]])):(i(),R(`section`,Bp,[x(`div`,Vp,[t(J,{name:`chat`,size:26})]),x(`h2`,null,k(Lt.value?`Pick a session`:`Connect your first host`),1),x(`p`,null,k(Lt.value?Bt.value?`${Rt.value} sessions in ${zt.value} projects on ${Mt.value.get(Bt.value)??`this host`}.`:`${Lt.value} sessions in ${zt.value} projects across ${Ce.value.length} hosts.`:`Add a Paseo daemon and its agents show up here, live.`),1),Ce.value.length?(i(),R(`button`,{key:1,class:`btn btn-primary`,onClick:n[56]||=e=>$n()},[t(J,{name:`plus`,size:15}),n[92]||=d(`New session`,-1)])):(i(),R(`button`,{key:0,class:`btn btn-primary`,onClick:n[55]||=e=>ji(`hosts`)},`Add a host`))]))]),nr.value?(i(),m(_e,{key:0,thread:nr.value.thread,x:nr.value.x,y:nr.value.y,onClose:n[57]||=e=>nr.value=null,onRename:n[58]||=e=>rr.value=e,onPin:cr,onUnread:lr,onRead:ur,onArchive:dr},null,8,[`thread`,`x`,`y`])):F(``,!0),vr.value?(i(),m(ke,{key:1,name:vr.value.project.name,pinned:pr(vr.value.project),onPin:n[59]||=e=>_r(vr.value.project),host:Mt.value.get(vr.value.project.hostId)??`Unknown host`,x:vr.value.x,y:vr.value.y,onClose:n[60]||=e=>vr.value=null,onSettings:n[61]||=e=>yr.value=vr.value.project,onRemove:n[62]||=e=>Sr(vr.value.project)},null,8,[`name`,`pinned`,`host`,`x`,`y`])):F(``,!0),yr.value?(i(),m(nn,{key:2,"host-id":yr.value.hostId,"host-label":Mt.value.get(yr.value.hostId)??`Unknown host`,project:br.value,"root-path":yr.value.rootPath,"custom-icons":!!Ce.value.find(e=>e.id===yr.value.hostId)?.customIcons,request:$,onClose:n[63]||=e=>yr.value=null},null,8,[`host-id`,`host-label`,`project`,`root-path`,`custom-icons`])):F(``,!0),fn.value?(i(),R(`div`,{key:3,class:`lightbox`,role:`dialog`,"aria-label":`Image`,onClick:n[64]||=e=>fn.value=null},[x(`img`,{src:fn.value,alt:``},null,8,Hp)])):F(``,!0),rr.value?(i(),m(Ee,{key:4,thread:rr.value,busy:Y.value,onClose:n[65]||=e=>rr.value=null,onSave:sr},null,8,[`thread`,`busy`])):F(``,!0),Qn.value?(i(),m(Ca,{key:5,hosts:Ce.value,"initial-host-id":Qn.value.hostId,"initial-cwd":Qn.value.cwd,"initial-project":Qn.value.project,request:$,onClose:n[66]||=e=>Qn.value=null,onCreated:er},null,8,[`hosts`,`initial-host-id`,`initial-cwd`,`initial-project`])):F(``,!0)],6)):(i(),R(`div`,ud,[be.value?(i(),R(`form`,{key:0,class:`login-card`,onSubmit:v(On,[`prevent`])},[n[70]||=x(`div`,{class:`brand brand-large`},[x(`img`,{class:`brand-mark`,src:`/icons/mark.svg`,alt:``,width:`22`,height:`22`}),d(`LitePaseo`)],-1),n[71]||=x(`p`,{class:`login-lede`},`All your Paseo hosts, one fast console.`,-1),x(`label`,dd,[n[67]||=x(`span`,null,`Server access token`,-1),a(x(`input`,{"onUpdate:modelValue":n[0]||=e=>ve.value=e,type:`password`,autocomplete:`off`,required:``,autofocus:``},null,512),[[_,ve.value]])]),n[72]||=x(`p`,{class:`hint`},[d(`Run `),x(`code`,null,`litepaseo token`),d(` on the server to print it.`)],-1),be.value.totp?(i(),R(b,{key:0},[x(`label`,fd,[n[68]||=x(`span`,null,`Authenticator code`,-1),a(x(`input`,{"onUpdate:modelValue":n[1]||=e=>ye.value=e,class:`code-input`,inputmode:`numeric`,autocomplete:`one-time-code`,maxlength:`6`,pattern:`[0-9]{6}`,placeholder:`••••••`,required:``,onInput:An},null,544),[[_,ye.value]])]),n[69]||=x(`p`,{class:`hint`},`Both your access token and a code from your authenticator app are required.`,-1)],64)):F(``,!0),x(`button`,{class:`btn btn-primary btn-block`,disabled:Y.value},k(Y.value?`Signing in…`:`Connect`),9,pd),Se.value?(i(),R(`p`,md,k(Se.value),1)):F(``,!0)],32)):F(``,!0)]))}});function Xp(){let e=matchMedia(`(prefers-reduced-motion: reduce)`),t,n=!1,r=()=>Math.max(200,Number(getComputedStyle(document.documentElement).getPropertyValue(`--motion-step-ms`))||1e3),i=e=>e-performance.now()%e+10,a=()=>{clearTimeout(t),t=void 0},o=()=>{if(t=void 0,n||document.hidden||e.matches)return;let a=document.getAnimations().filter(e=>e instanceof CSSAnimation&&[`pulse`,`spin`].includes(e.animationName));if(!a.length)return;let s=r(),c=Math.floor(performance.now()/s)*s;for(let e of a)e.pause(),e.currentTime=c;t=setTimeout(o,i(s))},s=()=>{document.hidden||e.matches?a():!t&&!n&&(t=setTimeout(o,i(r())))},c=new MutationObserver(s);return c.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`,`open`]}),document.addEventListener(`visibilitychange`,s),window.addEventListener(`resize`,s),e.addEventListener(`change`,s),s(),()=>{n=!0,a(),c.disconnect(),document.removeEventListener(`visibilitychange`,s),window.removeEventListener(`resize`,s),e.removeEventListener(`change`,s)}}po(),xo();var Zp=j(Yp);Zp.mount(`#app`),Zp.onUnmount(Xp());export{kr as a,Ar as i,La as n,bn as o,Mr as r,J as s,fo as t};