spec-cat 0.1.60 → 0.1.61

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 (26) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/{oZWZjCpV.js → 8Elu-15_.js} +1 -1
  3. package/.output/public/_nuxt/{Bq8BNs4s.js → BeBeZcRQ.js} +1 -1
  4. package/.output/public/_nuxt/{hL590mW_.js → Bhr6Zo3T.js} +9 -9
  5. package/.output/public/_nuxt/{PyyEm6pa.js → BpYxF7v5.js} +1 -1
  6. package/.output/public/_nuxt/{Ritd1ZTh.js → C4M037xP.js} +1 -1
  7. package/.output/public/_nuxt/{CeUwIKdG.js → C7AMOFY8.js} +2 -2
  8. package/.output/public/_nuxt/{C7bEjS62.js → C8fQuSPf.js} +1 -1
  9. package/.output/public/_nuxt/C_6kiUg6.js +1 -0
  10. package/.output/public/_nuxt/{BBjCHYA6.js → CbE7c0sD.js} +1 -1
  11. package/.output/public/_nuxt/{CtkWRKR5.js → DCnFPBGM.js} +1 -1
  12. package/.output/public/_nuxt/{soqWbP5S.js → DTRKuZ1Z.js} +1 -1
  13. package/.output/public/_nuxt/{0b9erTT7.js → DVCRp6I2.js} +1 -1
  14. package/.output/public/_nuxt/builds/latest.json +1 -1
  15. package/.output/public/_nuxt/builds/meta/81746bdb-ce0f-42a7-9dd1-65c11a21de2d.json +1 -0
  16. package/.output/public/_nuxt/{fOeB-VHQ.js → qOn4ZFdM.js} +1 -1
  17. package/.output/server/chunks/_/conversationStore.mjs.map +1 -1
  18. package/.output/server/chunks/build/client.precomputed.mjs +1 -1
  19. package/.output/server/chunks/build/client.precomputed.mjs.map +1 -1
  20. package/.output/server/chunks/nitro/nitro.mjs +591 -591
  21. package/.output/server/chunks/routes/_ws.mjs +7 -6
  22. package/.output/server/chunks/routes/_ws.mjs.map +1 -1
  23. package/.output/server/package.json +1 -1
  24. package/package.json +1 -1
  25. package/.output/public/_nuxt/CvPsR12A.js +0 -1
  26. package/.output/public/_nuxt/builds/meta/9d41800a-a604-4f15-8938-30e3b775a2dc.json +0 -1
@@ -1,12 +1,12 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Bq8BNs4s.js","./CeUwIKdG.js","./entry.BUDfUMkE.css","./PyyEm6pa.js"])))=>i.map(i=>d[i]);
2
- import{y as v,z as y,A as d,d as Ve,C as ee,G as m,R as je,S as Je,U as Rt,I as we,E as Ie,B as A,K as F,g as P,J as Ne,V as hs,k as J,W as tr,L as _e,H as pe,o as gt,X as wt,Y as Gm,O as ze,Z as It,T as Pr,_ as ps,M as Mu,$ as Ae,a0 as ds,P as On,D as ut,Q as kr,a1 as Hm,a2 as Or,a3 as ks,a4 as Sc,a5 as z1,c as N1,a6 as zh,a7 as Km,a8 as W1,q as q1,a9 as j1,x as Y1,aa as Eo}from"./CeUwIKdG.js";import{r as St,c as vn,b as dl,a as gs}from"./fOeB-VHQ.js";import{g as Oo,m as F1,p as U1,h as Nh,i as G1,j as Wh,k as H1,l as K1,n as J1,w as ev,o as tv,q as Jm,s as qh,C as rv,_ as nv,t as Au,u as sv,r as jh,a as Yh}from"./CtkWRKR5.js";import{_ as ws}from"./DlAUqK2U.js";import{S as Ma,i as iv,b as ov,P as av,W as Fh,M as Uh,c as Gh,d as Hh,g as Kh,e as lv,D as ep,f as tp,h as cv,a as vo,j as Ht,u as bo,k as Zs,l as Do}from"./Bq8BNs4s.js";import{u as $c,_ as uv}from"./Ritd1ZTh.js";function hv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M10.5 6h9.75M10.5 6a1.5 1.5 0 1 1-3 0m3 0a1.5 1.5 0 1 0-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-9.75 0h9.75"})])}function dv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m20.25 7.5-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5m8.25 3v6.75m0 0-3-3m3 3 3-3M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z"})])}function fv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 8.25H7.5a2.25 2.25 0 0 0-2.25 2.25v9a2.25 2.25 0 0 0 2.25 2.25h9a2.25 2.25 0 0 0 2.25-2.25v-9a2.25 2.25 0 0 0-2.25-2.25H15M9 12l3 3m0 0 3-3m-3 3V2.25"})])}function mv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"})])}function pv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18"})])}function rp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M19.5 12c0-1.232-.046-2.453-.138-3.662a4.006 4.006 0 0 0-3.7-3.7 48.678 48.678 0 0 0-7.324 0 4.006 4.006 0 0 0-3.7 3.7c-.017.22-.032.441-.046.662M19.5 12l3-3m-3 3-3-3m-12 3c0 1.232.046 2.453.138 3.662a4.006 4.006 0 0 0 3.7 3.7 48.656 48.656 0 0 0 7.324 0 4.006 4.006 0 0 0 3.7-3.7c.017-.22.032-.441.046-.662M4.5 12l3 3m-3-3-3 3"})])}function np(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5m-13.5-9L12 3m0 0 4.5 4.5M12 3v13.5"})])}function sp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 15 3 9m0 0 6-6M3 9h12a6 6 0 0 1 0 12h-3"})])}function ip(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 9V4.5M9 9H4.5M9 9 3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5 5.25 5.25"})])}function op(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"})])}function ap(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"})])}function gv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.75 3.104v5.714a2.25 2.25 0 0 1-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 0 1 4.5 0m0 0v5.714c0 .597.237 1.17.659 1.591L19.8 15.3M14.25 3.104c.251.023.501.05.75.082M19.8 15.3l-1.57.393A9.065 9.065 0 0 1 12 15a9.065 9.065 0 0 0-6.23-.693L5 14.5m14.8.8 1.402 1.402c1.232 1.232.65 3.318-1.067 3.611A48.309 48.309 0 0 1 12 21c-2.773 0-5.491-.235-8.135-.687-1.718-.293-2.3-2.379-1.067-3.61L5 14.5"})])}function lp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m3.75 13.5 10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75Z"})])}function Ov(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082"})])}function vv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0 0 20.25 18V6A2.25 2.25 0 0 0 18 3.75H6A2.25 2.25 0 0 0 3.75 6v12A2.25 2.25 0 0 0 6 20.25Z"})])}function cp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M20.25 8.511c.884.284 1.5 1.128 1.5 2.097v4.286c0 1.136-.847 2.1-1.98 2.193-.34.027-.68.052-1.02.072v3.091l-3-3c-1.354 0-2.694-.055-4.02-.163a2.115 2.115 0 0 1-.825-.242m9.345-8.334a2.126 2.126 0 0 0-.476-.095 48.64 48.64 0 0 0-8.048 0c-1.131.094-1.976 1.057-1.976 2.192v4.286c0 .837.46 1.58 1.155 1.951m9.345-8.334V6.637c0-1.621-1.152-3.026-2.76-3.235A48.455 48.455 0 0 0 11.25 3c-2.115 0-4.198.137-6.24.402-1.608.209-2.76 1.614-2.76 3.235v6.226c0 1.621 1.152 3.026 2.76 3.235.577.075 1.157.14 1.74.194V21l4.155-4.155"})])}function bv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M2.25 12.76c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.076-4.076a1.526 1.526 0 0 1 1.037-.443 48.282 48.282 0 0 0 5.68-.494c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z"})])}function _u(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m4.5 12.75 6 6 9-13.5"})])}function xv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})])}function Ru(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 15 12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9"})])}function yv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m4.5 15.75 7.5-7.5 7.5 7.5"})])}function Bu(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25ZM6.75 12h.008v.008H6.75V12Zm0 3h.008v.008H6.75V15Zm0 3h.008v.008H6.75V18Z"})])}function Ys(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 7.5V6.108c0-1.135.845-2.098 1.976-2.192.373-.03.748-.057 1.123-.08M15.75 18H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08M15.75 18.75v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5A3.375 3.375 0 0 0 6.375 7.5H5.25m11.9-3.664A2.251 2.251 0 0 0 15 2.25h-1.5a2.251 2.251 0 0 0-2.15 1.586m5.8 0c.065.21.1.433.1.664v.75h-6V4.5c0-.231.035-.454.1-.664M6.75 7.5H4.875c-.621 0-1.125.504-1.125 1.125v12c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V16.5a9 9 0 0 0-9-9Z"})])}function up(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9.75v6.75m0 0-3-3m3 3 3-3m-8.25 6a4.5 4.5 0 0 1-1.41-8.775 5.25 5.25 0 0 1 10.233-2.33 3 3 0 0 1 3.758 3.848A3.752 3.752 0 0 1 18 19.5H6.75Z"})])}function kv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.25 9.75 16.5 12l-2.25 2.25m-4.5 0L7.5 12l2.25-2.25M6 20.25h12A2.25 2.25 0 0 0 20.25 18V6A2.25 2.25 0 0 0 18 3.75H6A2.25 2.25 0 0 0 3.75 6v12A2.25 2.25 0 0 0 6 20.25Z"})])}function Cc(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z"}),d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})])}function wv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m6.75 7.5 3 2.25-3 2.25m4.5 0h3m-9 8.25h13.5A2.25 2.25 0 0 0 21 18V6a2.25 2.25 0 0 0-2.25-2.25H5.25A2.25 2.25 0 0 0 3 6v12a2.25 2.25 0 0 0 2.25 2.25Z"})])}function Sv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M10.125 2.25h-4.5c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125v-9M10.125 2.25h.375a9 9 0 0 1 9 9v.375M10.125 2.25A3.375 3.375 0 0 1 13.5 5.625v1.5c0 .621.504 1.125 1.125 1.125h1.5a3.375 3.375 0 0 1 3.375 3.375M9 15l2.25 2.25L15 12"})])}function $v(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75"})])}function Cv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m5.231 13.481L15 17.25m-4.5-15H5.625c-.621 0-1.125.504-1.125 1.125v16.5c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Zm3.75 11.625a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z"})])}function Os(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"})])}function En(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"})])}function Qv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.98 8.223A10.477 10.477 0 0 0 1.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.451 10.451 0 0 1 12 4.5c4.756 0 8.773 3.162 10.065 7.498a10.522 10.522 0 0 1-4.293 5.774M6.228 6.228 3 3m3.228 3.228 3.65 3.65m7.894 7.894L21 21m-3.228-3.228-3.65-3.65m0 0a3 3 0 1 0-4.243-4.243m4.242 4.242L9.88 9.88"})])}function Pv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})])}function Tv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 0 0-1.883 2.542l.857 6a2.25 2.25 0 0 0 2.227 1.932H19.05a2.25 2.25 0 0 0 2.227-1.932l.857-6a2.25 2.25 0 0 0-1.883-2.542m-16.5 0V6A2.25 2.25 0 0 1 6 3.75h3.879a1.5 1.5 0 0 1 1.06.44l2.122 2.12a1.5 1.5 0 0 0 1.06.44H18A2.25 2.25 0 0 1 20.25 9v.776"})])}function Mv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 0 1-.659 1.591l-5.432 5.432a2.25 2.25 0 0 0-.659 1.591v2.927a2.25 2.25 0 0 1-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 0 0-.659-1.591L3.659 7.409A2.25 2.25 0 0 1 3 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0 1 12 3Z"})])}function Av(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5.25 8.25h15m-16.5 7.5h15m-1.8-13.5-3.9 19.5m-2.1-19.5-3.9 19.5"})])}function _v(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"})])}function Rv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 18v-5.25m0 0a6.01 6.01 0 0 0 1.5-.189m-1.5.189a6.01 6.01 0 0 1-1.5-.189m3.75 7.478a12.06 12.06 0 0 1-4.5 0m3.75 2.383a14.406 14.406 0 0 1-3 0M14.25 18v-.192c0-.983.658-1.823 1.508-2.316a7.5 7.5 0 1 0-7.517 0c.85.493 1.509 1.333 1.509 2.316V18"})])}function hp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0ZM3.75 12h.007v.008H3.75V12Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm-.375 5.25h.007v.008H3.75v-.008Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"})])}function fs(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"})])}function Bv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5 12h14"})])}function Zv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m18.375 12.739-7.693 7.693a4.5 4.5 0 0 1-6.364-6.364l10.94-10.94A3 3 0 1 1 19.5 7.372L8.552 18.32m.009-.01-.01.01m5.699-9.941-7.81 7.81a1.5 1.5 0 0 0 2.112 2.13"})])}function dp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10"})])}function Ev(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.347a1.125 1.125 0 0 1 0 1.972l-11.54 6.347a1.125 1.125 0 0 1-1.667-.986V5.653Z"})])}function Jh(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 0 1-.657.643 48.39 48.39 0 0 1-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 0 1-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 0 0-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.039 48.039 0 0 1-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 0 0 .657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 0 0 5.427-.63 48.05 48.05 0 0 0 .582-4.717.532.532 0 0 0-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 0 0 .658-.663 48.422 48.422 0 0 0-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 0 1-.61-.58v0Z"})])}function Zu(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 5.25h.008v.008H12v-.008Z"})])}function fp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 0 1 0 3.75H5.625a1.875 1.875 0 0 1 0-3.75Z"})])}function mp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 12.75 11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285Z"})])}function Eu(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m0-10.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.75c0 5.592 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.57-.598-3.75h-.152c-3.196 0-6.1-1.25-8.25-3.286Zm0 13.036h.008v.008H12v-.008Z"})])}function ji(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09ZM18.259 8.715 18 9.75l-.259-1.035a3.375 3.375 0 0 0-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 0 0 2.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 0 0 2.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 0 0-2.456 2.456ZM16.894 20.567 16.5 21.75l-.394-1.183a2.25 2.25 0 0 0-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 0 0 1.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 0 0 1.423 1.423l1.183.394-1.183.394a2.25 2.25 0 0 0-1.423 1.423Z"})])}function pp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}),d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 9.563C9 9.252 9.252 9 9.563 9h4.874c.311 0 .563.252.563.563v4.874c0 .311-.252.563-.563.563H9.564A.562.562 0 0 1 9 14.437V9.564Z"})])}function Du(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.568 3H5.25A2.25 2.25 0 0 0 3 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.095 18.095 0 0 0 5.223-5.223c.542-.827.369-1.908-.33-2.607L11.16 3.66A2.25 2.25 0 0 0 9.568 3Z"}),d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 6h.008v.008H6V6Z"})])}function Dv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M11.42 15.17 17.25 21A2.652 2.652 0 0 0 21 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 1 1-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 0 0 4.486-6.336l-3.276 3.277a3.004 3.004 0 0 1-2.25-2.25l3.276-3.276a4.5 4.5 0 0 0-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437 1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008Z"})])}async function ed(r){return $fetch("/api/chat/worktree",{method:"POST",body:r})}async function Lv(r){await $fetch("/api/chat/worktree",{method:"DELETE",body:r})}async function Xv(r){const e=await $fetch("/api/chat/preview-sync",{method:"POST",body:r});if(!e.success)throw new Error(e.error||"Unknown preview sync failure")}const Iv={class:"flex items-center gap-1.5 px-2 py-1.5 bg-retro-panel border-b border-retro-border"},Vv={class:"relative flex-1 min-w-0"},zv={key:0,class:"text-[11px] text-retro-muted flex-shrink-0 min-w-[60px] text-center"},Nv=["disabled"],Wv=["disabled"],qv=Ve({__name:"GitFindWidget",props:{resultCount:{},currentIndex:{}},emits:["search","next","prev","close"],setup(r,{expose:e,emit:t}){const n=t,s=P(""),i=P(null);let o=null;function a(){o&&clearTimeout(o),o=setTimeout(()=>{n("search",s.value)},200)}function l(u){u.key==="Escape"?(u.preventDefault(),n("close")):u.key==="Enter"&&(u.preventDefault(),u.shiftKey?n("prev"):n("next"))}function c(){i.value?.focus(),i.value?.select()}return e({focus:c}),(u,h)=>(v(),y("div",Iv,[ee(m(fs),{class:"w-4 h-4 text-retro-muted flex-shrink-0"}),d("div",Vv,[je(d("input",{ref_key:"inputRef",ref:i,"onUpdate:modelValue":h[0]||(h[0]=f=>Je(s)?s.value=f:null),type:"text",placeholder:"Find in commits...","aria-label":"Search commits",class:"w-full px-2 py-1 text-sm bg-retro-dark border border-retro-border rounded text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan",onInput:a,onKeydown:l},null,544),[[Rt,m(s)]])]),m(s)?(v(),y("span",zv,[r.resultCount>0?(v(),y(we,{key:0},[Ie(A(r.currentIndex+1)+" of "+A(r.resultCount),1)],64)):(v(),y(we,{key:1},[Ie(" No results ")],64))])):F("",!0),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-text disabled:opacity-30 disabled:cursor-not-allowed transition-colors",disabled:r.resultCount===0,"aria-label":"Previous result",title:"Previous (Shift+Enter)",onClick:h[1]||(h[1]=f=>n("prev"))},[ee(m(yv),{class:"w-4 h-4"})],8,Nv),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-text disabled:opacity-30 disabled:cursor-not-allowed transition-colors",disabled:r.resultCount===0,"aria-label":"Next result",title:"Next (Enter)",onClick:h[2]||(h[2]=f=>n("next"))},[ee(m(xv),{class:"w-4 h-4"})],8,Wv),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-text transition-colors","aria-label":"Close find widget",title:"Close (Escape)",onClick:h[3]||(h[3]=f=>n("close"))},[ee(m(St),{class:"w-4 h-4"})])]))}}),jv={class:"flex flex-col bg-retro-dark border border-retro-border rounded shadow-lg max-w-md w-full"},Yv={class:"flex items-center justify-between px-3 py-2 border-b border-retro-border"},Fv={class:"flex-1 overflow-auto max-h-[300px]"},Uv={class:"font-semibold text-retro-cyan flex-shrink-0 min-w-[60px]"},Gv=["onKeyup"],Hv=["onClick"],Kv={class:"text-retro-muted truncate flex-1 font-mono"},Jv=["onClick"],eb=["onClick"],tb={key:0,class:"px-3 py-4 text-center text-retro-muted text-xs"},rb={key:0,class:"px-3 py-2 border-t border-retro-border space-y-2"},nb={class:"flex gap-2 justify-end"},sb=["disabled"],ib={key:1,class:"px-3 py-2 border-t border-retro-border"},ob=Ve({__name:"GitRemoteManager",props:{remotes:{},loading:{type:Boolean}},emits:["add","edit","delete","close"],setup(r,{emit:e}){const t=e,n=P(!1),s=P(""),i=P(""),o=P(null),a=P("");function l(){n.value=!0,s.value="",i.value=""}function c(){!s.value.trim()||!i.value.trim()||(t("add",{name:s.value.trim(),url:i.value.trim()}),n.value=!1)}function u(p){o.value=p.name,a.value=p.fetchUrl}function h(p){a.value.trim()&&(t("edit",{name:p,newUrl:a.value.trim()}),o.value=null)}function f(){o.value=null}return(p,g)=>(v(),y("div",jv,[d("div",Yv,[g[5]||(g[5]=d("h3",{class:"text-sm font-semibold text-retro-text"},"Remote Repositories",-1)),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-text transition-colors",onClick:g[0]||(g[0]=O=>t("close"))},[ee(m(St),{class:"w-4 h-4"})])]),d("div",Fv,[(v(!0),y(we,null,Ne(r.remotes,O=>(v(),y("div",{key:O.name,class:"flex items-center gap-2 px-3 py-2 border-b border-retro-border/50 text-xs"},[d("span",Uv,A(O.name),1),m(o)===O.name?(v(),y(we,{key:0},[je(d("input",{"onUpdate:modelValue":g[1]||(g[1]=b=>Je(a)?a.value=b:null),type:"text",class:"flex-1 px-2 py-1 text-xs bg-retro-panel border border-retro-border rounded text-retro-text focus:outline-none focus:border-retro-cyan",onKeyup:[hs(b=>h(O.name),["enter"]),hs(f,["escape"])]},null,40,Gv),[[Rt,m(a)]]),d("button",{class:"p-0.5 text-retro-green hover:text-retro-green/80",onClick:b=>h(O.name)},[ee(m(_u),{class:"w-3.5 h-3.5"})],8,Hv),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-text",onClick:f},[ee(m(St),{class:"w-3.5 h-3.5"})])],64)):(v(),y(we,{key:1},[d("span",Kv,A(O.fetchUrl),1),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-text",title:"Edit",onClick:b=>u(O)},[ee(m(dp),{class:"w-3.5 h-3.5"})],8,Jv),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-red",title:"Delete",onClick:b=>t("delete",O.name)},[ee(m(vn),{class:"w-3.5 h-3.5"})],8,eb)],64))]))),128)),r.remotes.length===0?(v(),y("div",tb," No remotes configured ")):F("",!0)]),m(n)?(v(),y("div",rb,[je(d("input",{"onUpdate:modelValue":g[2]||(g[2]=O=>Je(s)?s.value=O:null),type:"text",placeholder:"Remote name (e.g., origin)",class:"w-full px-2 py-1 text-xs bg-retro-panel border border-retro-border rounded text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan"},null,512),[[Rt,m(s)]]),je(d("input",{"onUpdate:modelValue":g[3]||(g[3]=O=>Je(i)?i.value=O:null),type:"text",placeholder:"Remote URL",class:"w-full px-2 py-1 text-xs bg-retro-panel border border-retro-border rounded text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan",onKeyup:hs(c,["enter"])},null,544),[[Rt,m(i)]]),d("div",nb,[d("button",{class:"px-2 py-1 text-xs text-retro-muted hover:text-retro-text transition-colors",onClick:g[4]||(g[4]=O=>n.value=!1)}," Cancel "),d("button",{class:"px-2 py-1 text-xs bg-retro-cyan/20 text-retro-cyan border border-retro-cyan/40 rounded hover:bg-retro-cyan/30 transition-colors",disabled:!m(s).trim()||!m(i).trim(),onClick:c}," Add Remote ",8,sb)])])):F("",!0),m(n)?F("",!0):(v(),y("div",ib,[d("button",{class:"flex items-center gap-1 text-xs text-retro-cyan hover:text-retro-cyan/80 transition-colors",onClick:l},[ee(m(dl),{class:"w-3.5 h-3.5"}),g[6]||(g[6]=Ie(" Add Remote ",-1))])]))]))}}),fl={NODE_RADIUS:4,ROW_HEIGHT:32,COLUMN_WIDTH:20,PADDING:10,VISIBLE_BUFFER:10},Lo=["#3B82F6","#EF4444","#10B981","#F59E0B","#8B5CF6","#EC4899","#14B8A6","#F97316","#06B6D4","#84CC16","#F43F5E","#A855F7"],Fs={A:{label:"Added",colorClass:"text-retro-green"},M:{label:"Modified",colorClass:"text-retro-yellow"},D:{label:"Deleted",colorClass:"text-retro-red"},R:{label:"Renamed",colorClass:"text-retro-blue"},C:{label:"Copied",colorClass:"text-retro-purple"},U:{label:"Unmerged",colorClass:"text-retro-cyan"}},ab=["width","height"],lb=["d","stroke","stroke-dasharray"],cb={key:0},ub=["cx","r"],hb=["cx","r","fill"],db=["cx","r","stroke"],fb=["cx","r","fill"],mb=["cx","r","stroke"],pb=["cx","r","fill"],gb=["cx","r"],Ob=["cx","r","fill"],gp=Ve({__name:"GitGraphSvg",props:{rowData:{},maxLane:{default:4},highlightBranches:{},tooltipText:{}},setup(r){const e=r,{COLUMN_WIDTH:t,ROW_HEIGHT:n,NODE_RADIUS:s,PADDING:i}=fl,o=J(()=>i*2+(e.maxLane+1)*t),a=n,l=n/2;function c(f){return i+f*t}function u(f){const p=c(f.fromLane),g=c(f.toLane);if(f.type==="vertical")return`M ${p} 0 L ${g} ${a}`;if(f.type==="vertical-top")return`M ${p} 0 L ${p} ${l}`;if(f.type==="vertical-bottom")return`M ${p} ${l} L ${p} ${a}`;if(f.style==="rounded")return`M ${p} ${l} C ${p} ${a}, ${g} ${a}, ${g} ${a}`;{const O=a*.75;return`M ${p} ${l} L ${p} ${O} L ${g} ${a}`}}const h=J(()=>e.rowData?c(e.rowData.lane):i);return(f,p)=>(v(),y("svg",{width:m(o),height:m(a),class:"block flex-shrink-0","aria-hidden":"true"},[r.rowData?(v(),y(we,{key:0},[(v(!0),y(we,null,Ne(r.rowData.connections,(g,O)=>(v(),y("path",{key:O,d:u(g),stroke:g.color,"stroke-width":"2",fill:"none","stroke-dasharray":g.type.startsWith("merge")?"4 3":"none"},null,8,lb))),128)),d("g",null,[r.tooltipText?(v(),y("title",cb,A(r.tooltipText),1)):F("",!0),r.rowData.nodeType==="head"?(v(),y(we,{key:1},[d("circle",{cx:m(h),cy:l,r:m(s)+2,fill:"none",stroke:"currentColor","stroke-width":"2",class:"text-retro-cyan"},null,8,ub),d("circle",{cx:m(h),cy:l,r:m(s),fill:r.rowData.color},null,8,hb)],64)):r.rowData.nodeType==="merge"?(v(),y(we,{key:2},[d("circle",{cx:m(h),cy:l,r:m(s)+1,fill:"none",stroke:r.rowData.color,"stroke-width":"1.5"},null,8,db),d("circle",{cx:m(h),cy:l,r:m(s)-1,fill:r.rowData.color},null,8,fb)],64)):r.rowData.nodeType==="stash"?(v(),y(we,{key:3},[d("circle",{cx:m(h),cy:l,r:m(s),fill:"none",stroke:r.rowData.color,"stroke-width":"2"},null,8,mb),d("circle",{cx:m(h),cy:l,r:m(s)-2,fill:r.rowData.color},null,8,pb)],64)):r.rowData.nodeType==="uncommitted"?(v(),y("circle",{key:4,cx:m(h),cy:l,r:m(s),fill:"none",stroke:"currentColor","stroke-width":"2",class:"text-retro-yellow","stroke-dasharray":"3 2"},null,8,gb)):(v(),y("circle",{key:5,cx:m(h),cy:l,r:m(s),fill:r.rowData.color},null,8,Ob))])],64)):F("",!0)],8,ab))}}),vb=["aria-selected","aria-label"],bb={key:1,class:"flex gap-1 flex-shrink-0"},xb=["title","onContextmenu"],yb={key:2,class:"flex gap-1 flex-shrink-0"},kb=["onContextmenu"],wb={class:"text-retro-text text-xs truncate flex-1"},Sb={key:5,class:"flex-shrink-0 text-retro-muted text-[10px] hidden sm:inline"},$b={key:6,class:"flex-shrink-0 text-retro-muted text-[10px]"},td=72,Cb=Ve({__name:"GitCommitRow",props:{commit:{},index:{},isSelected:{type:Boolean},isHighlighted:{type:Boolean},isBranchHighlighted:{type:Boolean},isFeatureHighlighted:{type:Boolean},isPreviewHighlighted:{type:Boolean},isMuted:{type:Boolean},currentBranchName:{},localBranchNames:{},graphRowData:{},maxLane:{},columnVisibility:{}},emits:["click","keydown","branchContextMenu","commitContextMenu","tagContextMenu"],setup(r,{emit:e}){const t=r,n=e,s=J(()=>{const f=t.commit.branches;if(f.length===0)return[];const p=t.localBranchNames,g=[],O=[];for(const S of f)p.has(S)?g.push(S):O.push(S);const b=new Set(g),x=new Map,k=[];for(const S of O){const Q=S.indexOf("/");if(Q>0){const L=S.substring(Q+1),D=S.substring(0,Q);b.has(L)?(x.has(L)||x.set(L,[]),x.get(L).push(D)):k.push(S)}else k.push(S)}const w=[];for(const S of g){const Q=x.get(S)||[];Q.length>0?w.push({displayName:`${S}/${Q.join(",")}`,originalBranches:[S,...Q.map(L=>`${L}/${S}`)],isLocal:!0}):w.push({displayName:S,originalBranches:[S],isLocal:!0})}for(const S of k)w.push({displayName:S,originalBranches:[S],isLocal:!1});return w});function i(f,p){f.preventDefault(),f.stopPropagation();const g=p.originalBranches[0];n("branchContextMenu",{branch:g,x:f.clientX,y:f.clientY,isCurrentBranch:p.isLocal&&p.originalBranches.includes(t.currentBranchName??""),isLocal:p.isLocal})}function o(f,p){f.preventDefault(),f.stopPropagation(),n("tagContextMenu",{tag:p,x:f.clientX,y:f.clientY})}function a(f){f.preventDefault(),f.stopPropagation(),n("commitContextMenu",{x:f.clientX,y:f.clientY})}const{ROW_HEIGHT:l}=fl,c=J(()=>{const f=[t.commit.shortHash];return t.commit.branches.length>0&&f.push(t.commit.branches.join(", ")),t.commit.tags.length>0&&f.push(t.commit.tags.map(p=>`tag: ${p}`).join(", ")),f.join(" — ")});function u(f){const g=Date.now()/1e3-f;return g<60?"just now":g<3600?`${Math.floor(g/60)}m ago`:g<86400?`${Math.floor(g/3600)}h ago`:g<604800?`${Math.floor(g/86400)}d ago`:g<2592e3?`${Math.floor(g/604800)}w ago`:new Date(f*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function h(f){const p=f.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BeBeZcRQ.js","./C7AMOFY8.js","./entry.BUDfUMkE.css","./BpYxF7v5.js"])))=>i.map(i=>d[i]);
2
+ import{y as v,z as y,A as d,d as Ve,C as ee,G as m,R as je,S as Je,U as Rt,I as we,E as Ie,B as A,K as F,g as P,J as Ne,V as hs,k as J,W as tr,L as _e,H as pe,o as gt,X as wt,Y as Gm,O as ze,Z as It,T as Pr,_ as ps,M as Mu,$ as Ae,a0 as ds,P as On,D as ut,Q as kr,a1 as Hm,a2 as Or,a3 as ks,a4 as Sc,a5 as z1,c as N1,a6 as zh,a7 as Km,a8 as W1,q as q1,a9 as j1,x as Y1,aa as Eo}from"./C7AMOFY8.js";import{r as St,c as vn,b as dl,a as gs}from"./qOn4ZFdM.js";import{g as Oo,m as F1,p as U1,h as Nh,i as G1,j as Wh,k as H1,l as K1,n as J1,w as ev,o as tv,q as Jm,s as qh,C as rv,_ as nv,t as Au,u as sv,r as jh,a as Yh}from"./DCnFPBGM.js";import{_ as ws}from"./DlAUqK2U.js";import{S as Ma,i as iv,b as ov,P as av,W as Fh,M as Uh,c as Gh,d as Hh,g as Kh,e as lv,D as ep,f as tp,h as cv,a as vo,j as Ht,u as bo,k as Zs,l as Do}from"./BeBeZcRQ.js";import{u as $c,_ as uv}from"./C4M037xP.js";function hv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M10.5 6h9.75M10.5 6a1.5 1.5 0 1 1-3 0m3 0a1.5 1.5 0 1 0-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-9.75 0h9.75"})])}function dv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m20.25 7.5-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5m8.25 3v6.75m0 0-3-3m3 3 3-3M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z"})])}function fv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 8.25H7.5a2.25 2.25 0 0 0-2.25 2.25v9a2.25 2.25 0 0 0 2.25 2.25h9a2.25 2.25 0 0 0 2.25-2.25v-9a2.25 2.25 0 0 0-2.25-2.25H15M9 12l3 3m0 0 3-3m-3 3V2.25"})])}function mv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"})])}function pv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18"})])}function rp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M19.5 12c0-1.232-.046-2.453-.138-3.662a4.006 4.006 0 0 0-3.7-3.7 48.678 48.678 0 0 0-7.324 0 4.006 4.006 0 0 0-3.7 3.7c-.017.22-.032.441-.046.662M19.5 12l3-3m-3 3-3-3m-12 3c0 1.232.046 2.453.138 3.662a4.006 4.006 0 0 0 3.7 3.7 48.656 48.656 0 0 0 7.324 0 4.006 4.006 0 0 0 3.7-3.7c.017-.22.032-.441.046-.662M4.5 12l3 3m-3-3-3 3"})])}function np(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5m-13.5-9L12 3m0 0 4.5 4.5M12 3v13.5"})])}function sp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 15 3 9m0 0 6-6M3 9h12a6 6 0 0 1 0 12h-3"})])}function ip(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 9V4.5M9 9H4.5M9 9 3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5 5.25 5.25"})])}function op(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"})])}function ap(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"})])}function gv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.75 3.104v5.714a2.25 2.25 0 0 1-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 0 1 4.5 0m0 0v5.714c0 .597.237 1.17.659 1.591L19.8 15.3M14.25 3.104c.251.023.501.05.75.082M19.8 15.3l-1.57.393A9.065 9.065 0 0 1 12 15a9.065 9.065 0 0 0-6.23-.693L5 14.5m14.8.8 1.402 1.402c1.232 1.232.65 3.318-1.067 3.611A48.309 48.309 0 0 1 12 21c-2.773 0-5.491-.235-8.135-.687-1.718-.293-2.3-2.379-1.067-3.61L5 14.5"})])}function lp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m3.75 13.5 10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75Z"})])}function Ov(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082"})])}function vv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0 0 20.25 18V6A2.25 2.25 0 0 0 18 3.75H6A2.25 2.25 0 0 0 3.75 6v12A2.25 2.25 0 0 0 6 20.25Z"})])}function cp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M20.25 8.511c.884.284 1.5 1.128 1.5 2.097v4.286c0 1.136-.847 2.1-1.98 2.193-.34.027-.68.052-1.02.072v3.091l-3-3c-1.354 0-2.694-.055-4.02-.163a2.115 2.115 0 0 1-.825-.242m9.345-8.334a2.126 2.126 0 0 0-.476-.095 48.64 48.64 0 0 0-8.048 0c-1.131.094-1.976 1.057-1.976 2.192v4.286c0 .837.46 1.58 1.155 1.951m9.345-8.334V6.637c0-1.621-1.152-3.026-2.76-3.235A48.455 48.455 0 0 0 11.25 3c-2.115 0-4.198.137-6.24.402-1.608.209-2.76 1.614-2.76 3.235v6.226c0 1.621 1.152 3.026 2.76 3.235.577.075 1.157.14 1.74.194V21l4.155-4.155"})])}function bv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M2.25 12.76c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.076-4.076a1.526 1.526 0 0 1 1.037-.443 48.282 48.282 0 0 0 5.68-.494c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z"})])}function _u(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m4.5 12.75 6 6 9-13.5"})])}function xv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})])}function Ru(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 15 12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9"})])}function yv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m4.5 15.75 7.5-7.5 7.5 7.5"})])}function Bu(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25ZM6.75 12h.008v.008H6.75V12Zm0 3h.008v.008H6.75V15Zm0 3h.008v.008H6.75V18Z"})])}function Ys(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 7.5V6.108c0-1.135.845-2.098 1.976-2.192.373-.03.748-.057 1.123-.08M15.75 18H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08M15.75 18.75v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5A3.375 3.375 0 0 0 6.375 7.5H5.25m11.9-3.664A2.251 2.251 0 0 0 15 2.25h-1.5a2.251 2.251 0 0 0-2.15 1.586m5.8 0c.065.21.1.433.1.664v.75h-6V4.5c0-.231.035-.454.1-.664M6.75 7.5H4.875c-.621 0-1.125.504-1.125 1.125v12c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V16.5a9 9 0 0 0-9-9Z"})])}function up(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9.75v6.75m0 0-3-3m3 3 3-3m-8.25 6a4.5 4.5 0 0 1-1.41-8.775 5.25 5.25 0 0 1 10.233-2.33 3 3 0 0 1 3.758 3.848A3.752 3.752 0 0 1 18 19.5H6.75Z"})])}function kv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.25 9.75 16.5 12l-2.25 2.25m-4.5 0L7.5 12l2.25-2.25M6 20.25h12A2.25 2.25 0 0 0 20.25 18V6A2.25 2.25 0 0 0 18 3.75H6A2.25 2.25 0 0 0 3.75 6v12A2.25 2.25 0 0 0 6 20.25Z"})])}function Cc(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z"}),d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})])}function wv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m6.75 7.5 3 2.25-3 2.25m4.5 0h3m-9 8.25h13.5A2.25 2.25 0 0 0 21 18V6a2.25 2.25 0 0 0-2.25-2.25H5.25A2.25 2.25 0 0 0 3 6v12a2.25 2.25 0 0 0 2.25 2.25Z"})])}function Sv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M10.125 2.25h-4.5c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125v-9M10.125 2.25h.375a9 9 0 0 1 9 9v.375M10.125 2.25A3.375 3.375 0 0 1 13.5 5.625v1.5c0 .621.504 1.125 1.125 1.125h1.5a3.375 3.375 0 0 1 3.375 3.375M9 15l2.25 2.25L15 12"})])}function $v(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75"})])}function Cv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m5.231 13.481L15 17.25m-4.5-15H5.625c-.621 0-1.125.504-1.125 1.125v16.5c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Zm3.75 11.625a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z"})])}function Os(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"})])}function En(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"})])}function Qv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.98 8.223A10.477 10.477 0 0 0 1.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.451 10.451 0 0 1 12 4.5c4.756 0 8.773 3.162 10.065 7.498a10.522 10.522 0 0 1-4.293 5.774M6.228 6.228 3 3m3.228 3.228 3.65 3.65m7.894 7.894L21 21m-3.228-3.228-3.65-3.65m0 0a3 3 0 1 0-4.243-4.243m4.242 4.242L9.88 9.88"})])}function Pv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})])}function Tv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 0 0-1.883 2.542l.857 6a2.25 2.25 0 0 0 2.227 1.932H19.05a2.25 2.25 0 0 0 2.227-1.932l.857-6a2.25 2.25 0 0 0-1.883-2.542m-16.5 0V6A2.25 2.25 0 0 1 6 3.75h3.879a1.5 1.5 0 0 1 1.06.44l2.122 2.12a1.5 1.5 0 0 0 1.06.44H18A2.25 2.25 0 0 1 20.25 9v.776"})])}function Mv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 0 1-.659 1.591l-5.432 5.432a2.25 2.25 0 0 0-.659 1.591v2.927a2.25 2.25 0 0 1-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 0 0-.659-1.591L3.659 7.409A2.25 2.25 0 0 1 3 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0 1 12 3Z"})])}function Av(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5.25 8.25h15m-16.5 7.5h15m-1.8-13.5-3.9 19.5m-2.1-19.5-3.9 19.5"})])}function _v(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"})])}function Rv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 18v-5.25m0 0a6.01 6.01 0 0 0 1.5-.189m-1.5.189a6.01 6.01 0 0 1-1.5-.189m3.75 7.478a12.06 12.06 0 0 1-4.5 0m3.75 2.383a14.406 14.406 0 0 1-3 0M14.25 18v-.192c0-.983.658-1.823 1.508-2.316a7.5 7.5 0 1 0-7.517 0c.85.493 1.509 1.333 1.509 2.316V18"})])}function hp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0ZM3.75 12h.007v.008H3.75V12Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm-.375 5.25h.007v.008H3.75v-.008Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"})])}function fs(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"})])}function Bv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5 12h14"})])}function Zv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m18.375 12.739-7.693 7.693a4.5 4.5 0 0 1-6.364-6.364l10.94-10.94A3 3 0 1 1 19.5 7.372L8.552 18.32m.009-.01-.01.01m5.699-9.941-7.81 7.81a1.5 1.5 0 0 0 2.112 2.13"})])}function dp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10"})])}function Ev(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.347a1.125 1.125 0 0 1 0 1.972l-11.54 6.347a1.125 1.125 0 0 1-1.667-.986V5.653Z"})])}function Jh(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 0 1-.657.643 48.39 48.39 0 0 1-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 0 1-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 0 0-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.039 48.039 0 0 1-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 0 0 .657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 0 0 5.427-.63 48.05 48.05 0 0 0 .582-4.717.532.532 0 0 0-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 0 0 .658-.663 48.422 48.422 0 0 0-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 0 1-.61-.58v0Z"})])}function Zu(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 5.25h.008v.008H12v-.008Z"})])}function fp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 0 1 0 3.75H5.625a1.875 1.875 0 0 1 0-3.75Z"})])}function mp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 12.75 11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285Z"})])}function Eu(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m0-10.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.75c0 5.592 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.57-.598-3.75h-.152c-3.196 0-6.1-1.25-8.25-3.286Zm0 13.036h.008v.008H12v-.008Z"})])}function ji(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09ZM18.259 8.715 18 9.75l-.259-1.035a3.375 3.375 0 0 0-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 0 0 2.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 0 0 2.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 0 0-2.456 2.456ZM16.894 20.567 16.5 21.75l-.394-1.183a2.25 2.25 0 0 0-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 0 0 1.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 0 0 1.423 1.423l1.183.394-1.183.394a2.25 2.25 0 0 0-1.423 1.423Z"})])}function pp(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}),d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 9.563C9 9.252 9.252 9 9.563 9h4.874c.311 0 .563.252.563.563v4.874c0 .311-.252.563-.563.563H9.564A.562.562 0 0 1 9 14.437V9.564Z"})])}function Du(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.568 3H5.25A2.25 2.25 0 0 0 3 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.095 18.095 0 0 0 5.223-5.223c.542-.827.369-1.908-.33-2.607L11.16 3.66A2.25 2.25 0 0 0 9.568 3Z"}),d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 6h.008v.008H6V6Z"})])}function Dv(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M11.42 15.17 17.25 21A2.652 2.652 0 0 0 21 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 1 1-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 0 0 4.486-6.336l-3.276 3.277a3.004 3.004 0 0 1-2.25-2.25l3.276-3.276a4.5 4.5 0 0 0-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437 1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008Z"})])}async function ed(r){return $fetch("/api/chat/worktree",{method:"POST",body:r})}async function Lv(r){await $fetch("/api/chat/worktree",{method:"DELETE",body:r})}async function Xv(r){const e=await $fetch("/api/chat/preview-sync",{method:"POST",body:r});if(!e.success)throw new Error(e.error||"Unknown preview sync failure")}const Iv={class:"flex items-center gap-1.5 px-2 py-1.5 bg-retro-panel border-b border-retro-border"},Vv={class:"relative flex-1 min-w-0"},zv={key:0,class:"text-[11px] text-retro-muted flex-shrink-0 min-w-[60px] text-center"},Nv=["disabled"],Wv=["disabled"],qv=Ve({__name:"GitFindWidget",props:{resultCount:{},currentIndex:{}},emits:["search","next","prev","close"],setup(r,{expose:e,emit:t}){const n=t,s=P(""),i=P(null);let o=null;function a(){o&&clearTimeout(o),o=setTimeout(()=>{n("search",s.value)},200)}function l(u){u.key==="Escape"?(u.preventDefault(),n("close")):u.key==="Enter"&&(u.preventDefault(),u.shiftKey?n("prev"):n("next"))}function c(){i.value?.focus(),i.value?.select()}return e({focus:c}),(u,h)=>(v(),y("div",Iv,[ee(m(fs),{class:"w-4 h-4 text-retro-muted flex-shrink-0"}),d("div",Vv,[je(d("input",{ref_key:"inputRef",ref:i,"onUpdate:modelValue":h[0]||(h[0]=f=>Je(s)?s.value=f:null),type:"text",placeholder:"Find in commits...","aria-label":"Search commits",class:"w-full px-2 py-1 text-sm bg-retro-dark border border-retro-border rounded text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan",onInput:a,onKeydown:l},null,544),[[Rt,m(s)]])]),m(s)?(v(),y("span",zv,[r.resultCount>0?(v(),y(we,{key:0},[Ie(A(r.currentIndex+1)+" of "+A(r.resultCount),1)],64)):(v(),y(we,{key:1},[Ie(" No results ")],64))])):F("",!0),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-text disabled:opacity-30 disabled:cursor-not-allowed transition-colors",disabled:r.resultCount===0,"aria-label":"Previous result",title:"Previous (Shift+Enter)",onClick:h[1]||(h[1]=f=>n("prev"))},[ee(m(yv),{class:"w-4 h-4"})],8,Nv),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-text disabled:opacity-30 disabled:cursor-not-allowed transition-colors",disabled:r.resultCount===0,"aria-label":"Next result",title:"Next (Enter)",onClick:h[2]||(h[2]=f=>n("next"))},[ee(m(xv),{class:"w-4 h-4"})],8,Wv),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-text transition-colors","aria-label":"Close find widget",title:"Close (Escape)",onClick:h[3]||(h[3]=f=>n("close"))},[ee(m(St),{class:"w-4 h-4"})])]))}}),jv={class:"flex flex-col bg-retro-dark border border-retro-border rounded shadow-lg max-w-md w-full"},Yv={class:"flex items-center justify-between px-3 py-2 border-b border-retro-border"},Fv={class:"flex-1 overflow-auto max-h-[300px]"},Uv={class:"font-semibold text-retro-cyan flex-shrink-0 min-w-[60px]"},Gv=["onKeyup"],Hv=["onClick"],Kv={class:"text-retro-muted truncate flex-1 font-mono"},Jv=["onClick"],eb=["onClick"],tb={key:0,class:"px-3 py-4 text-center text-retro-muted text-xs"},rb={key:0,class:"px-3 py-2 border-t border-retro-border space-y-2"},nb={class:"flex gap-2 justify-end"},sb=["disabled"],ib={key:1,class:"px-3 py-2 border-t border-retro-border"},ob=Ve({__name:"GitRemoteManager",props:{remotes:{},loading:{type:Boolean}},emits:["add","edit","delete","close"],setup(r,{emit:e}){const t=e,n=P(!1),s=P(""),i=P(""),o=P(null),a=P("");function l(){n.value=!0,s.value="",i.value=""}function c(){!s.value.trim()||!i.value.trim()||(t("add",{name:s.value.trim(),url:i.value.trim()}),n.value=!1)}function u(p){o.value=p.name,a.value=p.fetchUrl}function h(p){a.value.trim()&&(t("edit",{name:p,newUrl:a.value.trim()}),o.value=null)}function f(){o.value=null}return(p,g)=>(v(),y("div",jv,[d("div",Yv,[g[5]||(g[5]=d("h3",{class:"text-sm font-semibold text-retro-text"},"Remote Repositories",-1)),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-text transition-colors",onClick:g[0]||(g[0]=O=>t("close"))},[ee(m(St),{class:"w-4 h-4"})])]),d("div",Fv,[(v(!0),y(we,null,Ne(r.remotes,O=>(v(),y("div",{key:O.name,class:"flex items-center gap-2 px-3 py-2 border-b border-retro-border/50 text-xs"},[d("span",Uv,A(O.name),1),m(o)===O.name?(v(),y(we,{key:0},[je(d("input",{"onUpdate:modelValue":g[1]||(g[1]=b=>Je(a)?a.value=b:null),type:"text",class:"flex-1 px-2 py-1 text-xs bg-retro-panel border border-retro-border rounded text-retro-text focus:outline-none focus:border-retro-cyan",onKeyup:[hs(b=>h(O.name),["enter"]),hs(f,["escape"])]},null,40,Gv),[[Rt,m(a)]]),d("button",{class:"p-0.5 text-retro-green hover:text-retro-green/80",onClick:b=>h(O.name)},[ee(m(_u),{class:"w-3.5 h-3.5"})],8,Hv),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-text",onClick:f},[ee(m(St),{class:"w-3.5 h-3.5"})])],64)):(v(),y(we,{key:1},[d("span",Kv,A(O.fetchUrl),1),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-text",title:"Edit",onClick:b=>u(O)},[ee(m(dp),{class:"w-3.5 h-3.5"})],8,Jv),d("button",{class:"p-0.5 text-retro-muted hover:text-retro-red",title:"Delete",onClick:b=>t("delete",O.name)},[ee(m(vn),{class:"w-3.5 h-3.5"})],8,eb)],64))]))),128)),r.remotes.length===0?(v(),y("div",tb," No remotes configured ")):F("",!0)]),m(n)?(v(),y("div",rb,[je(d("input",{"onUpdate:modelValue":g[2]||(g[2]=O=>Je(s)?s.value=O:null),type:"text",placeholder:"Remote name (e.g., origin)",class:"w-full px-2 py-1 text-xs bg-retro-panel border border-retro-border rounded text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan"},null,512),[[Rt,m(s)]]),je(d("input",{"onUpdate:modelValue":g[3]||(g[3]=O=>Je(i)?i.value=O:null),type:"text",placeholder:"Remote URL",class:"w-full px-2 py-1 text-xs bg-retro-panel border border-retro-border rounded text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan",onKeyup:hs(c,["enter"])},null,544),[[Rt,m(i)]]),d("div",nb,[d("button",{class:"px-2 py-1 text-xs text-retro-muted hover:text-retro-text transition-colors",onClick:g[4]||(g[4]=O=>n.value=!1)}," Cancel "),d("button",{class:"px-2 py-1 text-xs bg-retro-cyan/20 text-retro-cyan border border-retro-cyan/40 rounded hover:bg-retro-cyan/30 transition-colors",disabled:!m(s).trim()||!m(i).trim(),onClick:c}," Add Remote ",8,sb)])])):F("",!0),m(n)?F("",!0):(v(),y("div",ib,[d("button",{class:"flex items-center gap-1 text-xs text-retro-cyan hover:text-retro-cyan/80 transition-colors",onClick:l},[ee(m(dl),{class:"w-3.5 h-3.5"}),g[6]||(g[6]=Ie(" Add Remote ",-1))])]))]))}}),fl={NODE_RADIUS:4,ROW_HEIGHT:32,COLUMN_WIDTH:20,PADDING:10,VISIBLE_BUFFER:10},Lo=["#3B82F6","#EF4444","#10B981","#F59E0B","#8B5CF6","#EC4899","#14B8A6","#F97316","#06B6D4","#84CC16","#F43F5E","#A855F7"],Fs={A:{label:"Added",colorClass:"text-retro-green"},M:{label:"Modified",colorClass:"text-retro-yellow"},D:{label:"Deleted",colorClass:"text-retro-red"},R:{label:"Renamed",colorClass:"text-retro-blue"},C:{label:"Copied",colorClass:"text-retro-purple"},U:{label:"Unmerged",colorClass:"text-retro-cyan"}},ab=["width","height"],lb=["d","stroke","stroke-dasharray"],cb={key:0},ub=["cx","r"],hb=["cx","r","fill"],db=["cx","r","stroke"],fb=["cx","r","fill"],mb=["cx","r","stroke"],pb=["cx","r","fill"],gb=["cx","r"],Ob=["cx","r","fill"],gp=Ve({__name:"GitGraphSvg",props:{rowData:{},maxLane:{default:4},highlightBranches:{},tooltipText:{}},setup(r){const e=r,{COLUMN_WIDTH:t,ROW_HEIGHT:n,NODE_RADIUS:s,PADDING:i}=fl,o=J(()=>i*2+(e.maxLane+1)*t),a=n,l=n/2;function c(f){return i+f*t}function u(f){const p=c(f.fromLane),g=c(f.toLane);if(f.type==="vertical")return`M ${p} 0 L ${g} ${a}`;if(f.type==="vertical-top")return`M ${p} 0 L ${p} ${l}`;if(f.type==="vertical-bottom")return`M ${p} ${l} L ${p} ${a}`;if(f.style==="rounded")return`M ${p} ${l} C ${p} ${a}, ${g} ${a}, ${g} ${a}`;{const O=a*.75;return`M ${p} ${l} L ${p} ${O} L ${g} ${a}`}}const h=J(()=>e.rowData?c(e.rowData.lane):i);return(f,p)=>(v(),y("svg",{width:m(o),height:m(a),class:"block flex-shrink-0","aria-hidden":"true"},[r.rowData?(v(),y(we,{key:0},[(v(!0),y(we,null,Ne(r.rowData.connections,(g,O)=>(v(),y("path",{key:O,d:u(g),stroke:g.color,"stroke-width":"2",fill:"none","stroke-dasharray":g.type.startsWith("merge")?"4 3":"none"},null,8,lb))),128)),d("g",null,[r.tooltipText?(v(),y("title",cb,A(r.tooltipText),1)):F("",!0),r.rowData.nodeType==="head"?(v(),y(we,{key:1},[d("circle",{cx:m(h),cy:l,r:m(s)+2,fill:"none",stroke:"currentColor","stroke-width":"2",class:"text-retro-cyan"},null,8,ub),d("circle",{cx:m(h),cy:l,r:m(s),fill:r.rowData.color},null,8,hb)],64)):r.rowData.nodeType==="merge"?(v(),y(we,{key:2},[d("circle",{cx:m(h),cy:l,r:m(s)+1,fill:"none",stroke:r.rowData.color,"stroke-width":"1.5"},null,8,db),d("circle",{cx:m(h),cy:l,r:m(s)-1,fill:r.rowData.color},null,8,fb)],64)):r.rowData.nodeType==="stash"?(v(),y(we,{key:3},[d("circle",{cx:m(h),cy:l,r:m(s),fill:"none",stroke:r.rowData.color,"stroke-width":"2"},null,8,mb),d("circle",{cx:m(h),cy:l,r:m(s)-2,fill:r.rowData.color},null,8,pb)],64)):r.rowData.nodeType==="uncommitted"?(v(),y("circle",{key:4,cx:m(h),cy:l,r:m(s),fill:"none",stroke:"currentColor","stroke-width":"2",class:"text-retro-yellow","stroke-dasharray":"3 2"},null,8,gb)):(v(),y("circle",{key:5,cx:m(h),cy:l,r:m(s),fill:r.rowData.color},null,8,Ob))])],64)):F("",!0)],8,ab))}}),vb=["aria-selected","aria-label"],bb={key:1,class:"flex gap-1 flex-shrink-0"},xb=["title","onContextmenu"],yb={key:2,class:"flex gap-1 flex-shrink-0"},kb=["onContextmenu"],wb={class:"text-retro-text text-xs truncate flex-1"},Sb={key:5,class:"flex-shrink-0 text-retro-muted text-[10px] hidden sm:inline"},$b={key:6,class:"flex-shrink-0 text-retro-muted text-[10px]"},td=72,Cb=Ve({__name:"GitCommitRow",props:{commit:{},index:{},isSelected:{type:Boolean},isHighlighted:{type:Boolean},isBranchHighlighted:{type:Boolean},isFeatureHighlighted:{type:Boolean},isPreviewHighlighted:{type:Boolean},isMuted:{type:Boolean},currentBranchName:{},localBranchNames:{},graphRowData:{},maxLane:{},columnVisibility:{}},emits:["click","keydown","branchContextMenu","commitContextMenu","tagContextMenu"],setup(r,{emit:e}){const t=r,n=e,s=J(()=>{const f=t.commit.branches;if(f.length===0)return[];const p=t.localBranchNames,g=[],O=[];for(const S of f)p.has(S)?g.push(S):O.push(S);const b=new Set(g),x=new Map,k=[];for(const S of O){const Q=S.indexOf("/");if(Q>0){const L=S.substring(Q+1),D=S.substring(0,Q);b.has(L)?(x.has(L)||x.set(L,[]),x.get(L).push(D)):k.push(S)}else k.push(S)}const w=[];for(const S of g){const Q=x.get(S)||[];Q.length>0?w.push({displayName:`${S}/${Q.join(",")}`,originalBranches:[S,...Q.map(L=>`${L}/${S}`)],isLocal:!0}):w.push({displayName:S,originalBranches:[S],isLocal:!0})}for(const S of k)w.push({displayName:S,originalBranches:[S],isLocal:!1});return w});function i(f,p){f.preventDefault(),f.stopPropagation();const g=p.originalBranches[0];n("branchContextMenu",{branch:g,x:f.clientX,y:f.clientY,isCurrentBranch:p.isLocal&&p.originalBranches.includes(t.currentBranchName??""),isLocal:p.isLocal})}function o(f,p){f.preventDefault(),f.stopPropagation(),n("tagContextMenu",{tag:p,x:f.clientX,y:f.clientY})}function a(f){f.preventDefault(),f.stopPropagation(),n("commitContextMenu",{x:f.clientX,y:f.clientY})}const{ROW_HEIGHT:l}=fl,c=J(()=>{const f=[t.commit.shortHash];return t.commit.branches.length>0&&f.push(t.commit.branches.join(", ")),t.commit.tags.length>0&&f.push(t.commit.tags.map(p=>`tag: ${p}`).join(", ")),f.join(" — ")});function u(f){const g=Date.now()/1e3-f;return g<60?"just now":g<3600?`${Math.floor(g/60)}m ago`:g<86400?`${Math.floor(g/3600)}h ago`:g<604800?`${Math.floor(g/86400)}d ago`:g<2592e3?`${Math.floor(g/604800)}w ago`:new Date(f*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function h(f){const p=f.split(`
3
3
  `)[0];return p.length>td?p.substring(0,td-3)+"...":p}return(f,p)=>{const g=gp;return v(),y("div",{class:_e(["flex items-center cursor-pointer group focus:outline-none focus:ring-1 focus:ring-retro-cyan/50 focus:ring-inset",{"opacity-40":r.isMuted,"bg-retro-magenta/10":r.isPreviewHighlighted,"bg-retro-yellow/20":r.isFeatureHighlighted&&!r.isPreviewHighlighted}]),style:tr({height:`${m(l)}px`}),role:"row",tabindex:"0","aria-selected":r.isSelected,"aria-label":`Commit ${r.commit.shortHash} by ${r.commit.author}: ${r.commit.message.split(`
4
4
  `)[0]}`,onClick:p[0]||(p[0]=O=>n("click",O)),onKeydown:p[1]||(p[1]=O=>n("keydown",O)),onContextmenu:a},[ee(g,{rowData:r.graphRowData,maxLane:r.maxLane,tooltipText:m(c)},null,8,["rowData","maxLane","tooltipText"]),d("div",{class:_e(["flex-1 flex items-center gap-2 px-2 min-w-0 rounded-r transition-colors",{"bg-retro-magenta/10 border-l-2 border-retro-magenta/40":r.isPreviewHighlighted,"bg-retro-yellow/30 border-l-2 border-retro-yellow":r.isFeatureHighlighted&&!r.isPreviewHighlighted,"bg-retro-cyan/15":r.isSelected&&!r.isFeatureHighlighted&&!r.isPreviewHighlighted,"bg-retro-yellow/10":r.isHighlighted&&!r.isSelected&&!r.isFeatureHighlighted&&!r.isPreviewHighlighted,"bg-retro-cyan/5":r.isBranchHighlighted&&!r.isSelected&&!r.isHighlighted&&!r.isFeatureHighlighted&&!r.isPreviewHighlighted,"group-hover:bg-retro-panel/50":!r.isSelected&&!r.isHighlighted&&!r.isFeatureHighlighted&&!r.isPreviewHighlighted&&!r.isBranchHighlighted}]),style:tr({height:`${m(l)-4}px`})},[!r.columnVisibility||r.columnVisibility.commit!==!1?(v(),y("span",{key:0,class:_e(["flex-shrink-0 font-mono text-[11px]",r.commit.isHead?"text-retro-cyan font-semibold":"text-retro-muted"])},A(r.commit.shortHash),3)):F("",!0),m(s).length>0?(v(),y("div",bb,[(v(!0),y(we,null,Ne(m(s),O=>(v(),y("span",{key:O.displayName,class:_e(["px-1.5 py-0.5 text-[10px] rounded font-semibold leading-none cursor-context-menu hover:ring-1 hover:ring-retro-cyan/50",r.commit.isHead&&O.isLocal?"bg-retro-cyan/20 text-retro-cyan border border-retro-cyan/40":r.isPreviewHighlighted?"bg-retro-magenta/10 text-retro-magenta border border-retro-magenta/40":r.isFeatureHighlighted?"bg-retro-yellow/15 text-retro-yellow border border-retro-yellow/30":r.isBranchHighlighted?"bg-retro-cyan/15 text-retro-cyan/80 border border-retro-cyan/30":O.isLocal?"bg-retro-green/15 text-retro-green border border-retro-green/30":"bg-retro-orange/15 text-retro-orange border border-retro-orange/30"]),title:O.originalBranches.join(", "),onContextmenu:b=>i(b,O)},A(O.displayName),43,xb))),128))])):F("",!0),r.commit.tags.length>0?(v(),y("div",yb,[(v(!0),y(we,null,Ne(r.commit.tags,O=>(v(),y("span",{key:O,class:"px-1 py-0.5 text-[10px] rounded-sm bg-retro-yellow/15 text-retro-yellow border border-retro-yellow/25 flex items-center gap-0.5 leading-none cursor-context-menu hover:ring-1 hover:ring-retro-yellow/50",onContextmenu:b=>o(b,O)},[ee(m(Du),{class:"w-2.5 h-2.5"}),Ie(" "+A(O),1)],40,kb))),128))])):F("",!0),d("span",wb,A(h(r.commit.message)),1),r.commit.signatureStatus==="good"?(v(),pe(m(mp),{key:3,class:"w-3.5 h-3.5 flex-shrink-0 text-retro-green",title:"Verified signature"})):r.commit.signatureStatus==="bad"?(v(),pe(m(Eu),{key:4,class:"w-3.5 h-3.5 flex-shrink-0 text-retro-red",title:"Bad signature"})):F("",!0),!r.columnVisibility||r.columnVisibility.author!==!1?(v(),y("span",Sb,A(r.commit.author),1)):F("",!0),!r.columnVisibility||r.columnVisibility.date!==!1?(v(),y("span",$b,A(u(r.commit.timestamp)),1)):F("",!0)],6)],46,vb)}}});function Qb(){const{COLUMN_WIDTH:r,ROW_HEIGHT:e,NODE_RADIUS:t,PADDING:n}=fl;function s(l){let c=0;for(let u=0;u<l.length;u++){const h=l.charCodeAt(u);c=(c<<5)-c+h,c=c&c}return Math.abs(c)}function i(l){const c=s(l)%Lo.length;return Lo[c]}function o(l,c="rounded"){const u=new Map;if(l.length===0)return u;const h=new Set,f=new Map;for(const w of l)f.set(w.hash,w);const p=l[0];if(p){let w=p;for(;w;){h.add(w.hash);const S=w.parents?.[0];w=S?f.get(S):void 0}}const g=new Map,O=new Map,b=new Map,x=new Map,k=new Map;for(let w=0;w<l.length;w++){const S=l[w];k.set(S.hash,w);const Q=h.has(S.hash);let L,D;if(x.has(S.hash)){const V=x.get(S.hash);L=V.lane,D=V.color,x.delete(S.hash)}else if(Q)L=0,D=Lo[0];else{for(L=1;b.has(L);)L++;D=i(S.hash.substring(0,7))}g.set(S.hash,L),O.set(S.hash,D),b.set(L,S.hash);const G=S.isMerge||S.parents&&S.parents.length>1;let oe="regular";S.isHead?oe="head":G&&(oe="merge"),u.set(S.hash,{commitHash:S.hash,lane:L,color:D,nodeType:oe,isMainline:h.has(S.hash),connections:[]});const ie=S.parents||[];for(let V=0;V<ie.length;V++){const Z=ie[V];if(g.has(Z)||x.has(Z))continue;const U=h.has(Z);let W,N;if(V===0)W=L,N=D;else if(U)W=0,N=Lo[0];else{for(W=1;b.has(W)||W===L;)W++;N=i(Z.substring(0,7))}x.set(Z,{lane:W,color:N,childHash:S.hash})}const j=ie[0];if(!j)b.delete(L);else{const V=g.get(j),Z=x.get(j),U=V??Z?.lane;U!==void 0&&U!==L&&b.delete(L)}}for(let w=0;w<l.length;w++){const S=l[w],Q=u.get(S.hash);if(!Q)continue;const L=S.parents||[];for(let D=0;D<L.length;D++){const G=L[D],oe=g.get(G),ie=k.get(G);if(oe===void 0)continue;const j=Q.lane,V=oe,Z=D===0?Q.color:O.get(G)||i(G.substring(0,7));if(j===V?Q.connections.push({type:"vertical-bottom",fromLane:j,toLane:V,color:Z,style:c}):D>0?Q.connections.push({type:j<V?"merge-out":"merge-in",fromLane:j,toLane:V,color:Z,style:c}):Q.connections.push({type:j<V?"branch-out":"branch-in",fromLane:j,toLane:V,color:Z,style:c}),ie!==void 0&&ie>w+1)for(let U=w+1;U<ie;U++){const W=l[U],N=u.get(W.hash);N&&N.connections.push({type:"vertical",fromLane:V,toLane:V,color:Z,style:c})}if(ie!==void 0){const U=u.get(G);U&&U.connections.push({type:"vertical-top",fromLane:V,toLane:V,color:Z,style:c})}}}return u}function a(l){let c=0;for(const u of l.values()){u.lane>c&&(c=u.lane);for(const h of u.connections)h.fromLane>c&&(c=h.fromLane),h.toLane>c&&(c=h.toLane)}return c}return{computeGraphRows:o,computeMaxLane:a,getBranchColor:i,COLUMN_WIDTH:r,ROW_HEIGHT:e,NODE_RADIUS:t,PADDING:n}}const Pb=["aria-selected"],Tb={class:"text-retro-yellow text-xs font-medium"},Mb={key:1,class:"flex items-center justify-center gap-2 p-2 text-retro-muted text-sm"},Ab={key:2,class:"p-2 text-center text-retro-muted/50 text-xs"},_b=Ve({__name:"GitCommitList",props:{commits:{},stashes:{},selectedCommit:{},hasMore:{type:Boolean},loading:{type:Boolean},loadingMore:{type:Boolean},searchQuery:{},uncommittedChangesCount:{},isUncommittedChangesSelected:{type:Boolean},highlightBranches:{},featureHighlightBranches:{},featureMergeBases:{},previewHighlightBranches:{},previewMergeBases:{},currentBranchName:{},localBranchNames:{},graphStyle:{default:"rounded"},muteNonAncestral:{type:Boolean},columnVisibility:{}},emits:["select","compareSelect","loadMore","branchContextMenu","commitContextMenu","tagContextMenu","stashContextMenu","selectUncommittedChanges","scrollStart","scrollEnd"],setup(r,{expose:e,emit:t}){const n=r,s=t;function i(){s("selectUncommittedChanges")}function o(re){(re.key==="Enter"||re.key===" ")&&(re.preventDefault(),s("selectUncommittedChanges"))}const a=J(()=>n.searchQuery?.toLowerCase()??""),l=J(()=>new Set(n.highlightBranches??[])),c=J(()=>l.value.size>0),u=J(()=>{const re=a.value;if(!re)return new Set;const Oe=new Set;for(const ge of n.commits)(ge.message.toLowerCase().includes(re)||ge.author.toLowerCase().includes(re)||ge.shortHash.toLowerCase().includes(re)||ge.hash.toLowerCase().includes(re)||ge.branches.some($e=>$e.toLowerCase().includes(re))||ge.tags.some($e=>$e.toLowerCase().includes(re)))&&Oe.add(ge.hash);return Oe}),h=J(()=>{if(!c.value)return new Set;const re=new Set;for(const Oe of n.commits)Oe.branches.some(ge=>l.value.has(ge))&&re.add(Oe.hash);return re}),f=J(()=>{if(!n.featureHighlightBranches||n.featureHighlightBranches.length===0)return new Set;const re=n.featureMergeBases??{},Oe=new Map;for(const $e of n.commits)Oe.set($e.hash,$e);const ge=new Set;for(const $e of n.featureHighlightBranches){const Pe=n.commits.find(M=>M.branches.includes($e));if(!Pe)continue;const Fe=re[$e]??null;if(!Fe)continue;let T=Pe;for(;T&&T.hash!==Fe;)ge.add(T.hash),T=T.parents?.[0]?Oe.get(T.parents[0]):void 0}return ge}),p=J(()=>{if(!n.previewHighlightBranches||n.previewHighlightBranches.length===0)return new Set;const re=n.previewMergeBases??{},Oe=new Map;for(const $e of n.commits)Oe.set($e.hash,$e);const ge=new Set;for(const $e of n.previewHighlightBranches){const Pe=n.commits.find(M=>M.branches.includes($e));if(!Pe)continue;const Fe=re[$e]??null;if(!Fe)continue;let T=Pe;for(;T&&T.hash!==Fe;)ge.add(T.hash),T=T.parents?.[0]?Oe.get(T.parents[0]):void 0}return ge});function g(re,Oe){s("branchContextMenu",{...Oe,commitHash:re.hash})}function O(re,Oe){s("commitContextMenu",{commit:re,...Oe})}function b(re,Oe){s("tagContextMenu",{...Oe,commitHash:re.hash})}const{ROW_HEIGHT:x,VISIBLE_BUFFER:k}=fl,{computeGraphRows:w,computeMaxLane:S}=Qb(),Q=J(()=>w([...n.commits],n.graphStyle)),L=J(()=>S(Q.value)),D=J(()=>{const re=n.stashes||[];if(re.length===0)return n.commits.map((Pe,Fe)=>({type:"commit",commit:Pe,commitIndex:Fe}));const Oe=[],ge=[...re].sort((Pe,Fe)=>new Date(Fe.date).getTime()-new Date(Pe.date).getTime());let $e=0;for(let Pe=0;Pe<n.commits.length;Pe++){const Fe=n.commits[Pe],T=Fe.timestamp*1e3;for(;$e<ge.length&&new Date(ge[$e].date).getTime()>=T;)Oe.push({type:"stash",stash:ge[$e]}),$e++;Oe.push({type:"commit",commit:Fe,commitIndex:Pe})}for(;$e<ge.length;)Oe.push({type:"stash",stash:ge[$e]}),$e++;return Oe}),G=P(null),oe=P(0),ie=P(400);let j=null;const V=J(()=>{const re=k,Oe=D.value.length,ge=Math.max(0,Math.floor(oe.value/x)-re),$e=Math.min(Oe,Math.ceil((oe.value+ie.value)/x)+re);return{startIndex:ge,endIndex:$e}}),Z=J(()=>{const{startIndex:re,endIndex:Oe}=V.value;return D.value.slice(re,Oe).map((ge,$e)=>({row:ge,index:re+$e,graphRow:ge.type==="commit"&&Q.value.get(ge.commit.hash)||null,isHighlighted:ge.type==="commit"?u.value.has(ge.commit.hash):!1,isBranchHighlighted:ge.type==="commit"?h.value.has(ge.commit.hash):!1,isFeatureHighlighted:ge.type==="commit"?f.value.has(ge.commit.hash):!1,isPreviewHighlighted:ge.type==="commit"?p.value.has(ge.commit.hash):!1,isMuted:ge.type==="commit"&&n.muteNonAncestral?!(Q.value.get(ge.commit.hash)?.isMainline??!1):!1}))}),U=J(()=>D.value.length*x),W=J(()=>V.value.startIndex*x);function N(re){const Oe=re.target;oe.value=Oe.scrollTop,j||s("scrollStart"),j&&clearTimeout(j),j=setTimeout(()=>{j=null,s("scrollEnd")},150),n.hasMore&&!n.loading&&!n.loadingMore&&Oe.scrollTop+Oe.clientHeight>=Oe.scrollHeight-200&&s("loadMore")}function I(re,Oe){Oe.ctrlKey||Oe.metaKey?s("compareSelect",re):s("select",re)}function z(re,Oe,ge){if(re.key==="Enter"||re.key===" ")re.preventDefault(),s("select",Oe);else if(re.key==="ArrowDown"){re.preventDefault();for(let $e=ge+1;$e<D.value.length;$e++){const Pe=D.value[$e];if(Pe.type==="commit"){s("select",Pe.commit),be($e);break}}}else if(re.key==="ArrowUp"){re.preventDefault();for(let $e=ge-1;$e>=0;$e--){const Pe=D.value[$e];if(Pe.type==="commit"){s("select",Pe.commit),be($e);break}}}}function be(re){if(!G.value)return;const Oe=re*x,ge=G.value.scrollTop,$e=ge+G.value.clientHeight;Oe<ge?G.value.scrollTop=Oe:Oe+x>$e&&(G.value.scrollTop=Oe+x-G.value.clientHeight)}gt(()=>{if(G.value){ie.value=G.value.clientHeight;const re=new ResizeObserver(Oe=>{for(const ge of Oe)ie.value=ge.contentRect.height});re.observe(G.value),wt(()=>re.disconnect())}});function K(){return G.value?.scrollTop??0}function H(re){G.value&&(G.value.scrollTop=re)}return e({getScrollPosition:K,setScrollPosition:H,scrollToIndex:be}),(re,Oe)=>{const ge=gp,$e=Cb;return v(),y("div",{ref_key:"containerRef",ref:G,class:"h-full overflow-auto",role:"list","aria-label":"Commit history",onScroll:N},[r.uncommittedChangesCount&&r.uncommittedChangesCount>0?(v(),y("div",{key:0,class:"flex items-center cursor-pointer group sticky top-0 z-10 bg-retro-dark border-b border-retro-border",style:tr({height:`${m(x)}px`}),role:"button",tabindex:"0","aria-selected":r.isUncommittedChangesSelected,onClick:i,onKeydown:o},[ee(ge,{rowData:{commitHash:"uncommitted",lane:0,color:"#F59E0B",nodeType:"uncommitted",isMainline:!1,connections:[]},maxLane:m(L)},null,8,["maxLane"]),d("div",{class:_e(["flex-1 flex items-center gap-2 px-2 min-w-0 rounded-r transition-colors",{"bg-retro-yellow/15":r.isUncommittedChangesSelected,"group-hover:bg-retro-panel/50":!r.isUncommittedChangesSelected}]),style:tr({height:`${m(x)-4}px`})},[ee(m(Oo),{class:"w-4 h-4 text-retro-yellow flex-shrink-0"}),d("span",Tb," Uncommitted Changes ("+A(r.uncommittedChangesCount)+") ",1),Oe[1]||(Oe[1]=d("span",{class:"flex-1"},null,-1)),Oe[2]||(Oe[2]=d("span",{class:"text-retro-muted text-[10px]"},"Working tree",-1))],6)],44,Pb)):F("",!0),d("div",{class:"relative",style:tr({height:`${m(U)}px`})},[d("div",{class:"absolute left-0 right-0",style:tr({transform:`translateY(${m(W)}px)`})},[(v(!0),y(we,null,Ne(m(Z),({row:Pe,index:Fe,graphRow:T,isHighlighted:M,isBranchHighlighted:E,isFeatureHighlighted:B,isPreviewHighlighted:xe,isMuted:Re})=>(v(),y(we,{key:Pe.type==="commit"?Pe.commit.hash:`stash-${Pe.stash.index}`},[Pe.type==="commit"?Gm([Pe.commit.hash,Pe.commit.message,Pe.commit.timestamp,Pe.commit.branches.join("|"),Pe.commit.tags.join("|"),r.selectedCommit?.hash===Pe.commit.hash,M,E,B,xe,Re,n.currentBranchName||"",n.columnVisibility?.date!==!1,n.columnVisibility?.author!==!1,n.columnVisibility?.commit!==!1],()=>(v(),pe($e,{key:0,commit:Pe.commit,index:Pe.commitIndex,isSelected:r.selectedCommit?.hash===Pe.commit.hash,isHighlighted:M,isBranchHighlighted:E,isFeatureHighlighted:B,isPreviewHighlighted:xe,isMuted:Re,currentBranchName:n.currentBranchName,localBranchNames:n.localBranchNames,graphRowData:T,maxLane:m(L),columnVisibility:n.columnVisibility,onClick:Me=>I(Pe.commit,Me),onKeydown:Me=>z(Me,Pe.commit,Fe),onBranchContextMenu:Me=>g(Pe.commit,Me),onCommitContextMenu:Me=>O(Pe.commit,Me),onTagContextMenu:Me=>b(Pe.commit,Me)},null,8,["commit","index","isSelected","isHighlighted","isBranchHighlighted","isFeatureHighlighted","isPreviewHighlighted","isMuted","currentBranchName","localBranchNames","graphRowData","maxLane","columnVisibility","onClick","onKeydown","onBranchContextMenu","onCommitContextMenu","onTagContextMenu"])),Oe,0):F("",!0)],64))),128))],4)],4),(r.loading||r.loadingMore)&&r.commits.length>0?(v(),y("div",Mb,[...Oe[3]||(Oe[3]=[d("div",{class:"w-3 h-3 border-2 border-retro-muted border-t-retro-cyan rounded-full animate-spin"},null,-1),Ie(" Loading more commits... ",-1)])])):F("",!0),!r.hasMore&&r.commits.length>0&&!r.loading?(v(),y("div",Ab,A(r.commits.length)+" commits loaded ",1)):F("",!0)],544)}}});function Rb(r){const e=r.charAt(0).toUpperCase();return e in Fs?e:"M"}function Xo(r,e){if(r&&typeof r=="object"){const t=r;if(typeof t.data?.message=="string"&&t.data.message.trim())return t.data.message;if(typeof t.statusMessage=="string"&&t.statusMessage.trim())return t.statusMessage;if(typeof t.message=="string"&&t.message.trim())return t.message}return r instanceof Error&&r.message?r.message:e}function Op(r,e){const t=e.trim().toLowerCase();return t?r.filter(n=>n.message.toLowerCase().includes(t)||n.author.toLowerCase().includes(t)||n.shortHash.includes(t)||n.hash.includes(t)||n.branches.some(s=>s.toLowerCase().includes(t))||n.tags.some(s=>s.toLowerCase().includes(t))):[...r]}function Bb(r,e){return e.size===0?[...r]:r.filter(t=>t.branches.some(n=>e.has(n)))}function Zb(r=10){const e=new Map;function t(s,i){const o=i.toLowerCase(),a=`${o}:${s.length}`,l=e.get(a);if(l)return l;const c=Op(s,o);if(e.size>=r){const u=e.keys().next().value;u!==void 0&&e.delete(u)}return e.set(a,c),c}function n(){e.clear()}return{filter:t,clear:n}}const Eb={class:"flex flex-col h-full border-t border-retro-border bg-retro-dark"},Db={class:"flex items-center justify-between p-2 border-b border-retro-border flex-shrink-0"},Lb={class:"flex items-center gap-2 text-xs min-w-0"},Xb={class:"font-mono text-retro-cyan"},Ib={class:"font-mono text-retro-cyan"},Vb={key:0,class:"px-3 py-1.5 text-xs text-retro-muted border-b border-retro-border flex-shrink-0"},zb={class:"text-retro-green"},Nb={class:"text-retro-red"},Wb={key:1,class:"flex-1 flex items-center justify-center"},qb={key:2,class:"flex-1 overflow-auto"},jb={class:"text-retro-text truncate flex-1"},Yb={class:"text-retro-muted"},Fb={key:0,class:"flex-shrink-0 text-[10px] font-mono"},Ub={key:0,class:"text-retro-green"},Gb={key:1,class:"text-retro-red ml-1"},Hb={key:1,class:"flex-shrink-0 text-[10px] text-retro-muted italic"},Kb={key:3,class:"flex-1 flex items-center justify-center text-retro-muted text-sm"},Jb=Ve({__name:"GitComparisonView",props:{fromCommit:{},toCommit:{},files:{},stats:{},loading:{type:Boolean}},emits:["close"],setup(r,{emit:e}){const t=e;function n(s){const i=Rb(s);return Fs[i]||Fs.M}return(s,i)=>(v(),y("div",Eb,[d("div",Db,[d("div",Lb,[i[1]||(i[1]=d("span",{class:"text-retro-muted"},"Comparing",-1)),d("span",Xb,A(r.fromCommit.shortHash),1),i[2]||(i[2]=d("span",{class:"text-retro-muted"},"→",-1)),d("span",Ib,A(r.toCommit.shortHash),1)]),d("button",{class:"p-1 text-retro-muted hover:text-retro-text transition-colors flex-shrink-0","aria-label":"Close comparison",onClick:i[0]||(i[0]=o=>t("close"))},[ee(m(St),{class:"w-4 h-4"})])]),r.stats?(v(),y("div",Vb,[Ie(A(r.stats.filesChanged)+" file"+A(r.stats.filesChanged!==1?"s":"")+" changed, ",1),d("span",zb,"+"+A(r.stats.additions),1),d("span",Nb," -"+A(r.stats.deletions),1)])):F("",!0),r.loading?(v(),y("div",Wb,[...i[3]||(i[3]=[d("div",{class:"flex items-center gap-2 text-retro-muted text-sm"},[d("div",{class:"w-4 h-4 border-2 border-retro-muted border-t-retro-cyan rounded-full animate-spin"}),Ie(" Loading comparison... ")],-1)])])):r.files&&r.files.length>0?(v(),y("div",qb,[(v(!0),y(we,null,Ne(r.files,o=>(v(),y("div",{key:o.path,class:"flex items-center gap-2 px-3 py-1.5 hover:bg-retro-panel/50 text-xs border-b border-retro-border/50"},[d("span",{class:_e(["flex-shrink-0 w-4 text-center font-semibold text-[10px]",n(o.status).colorClass])},A(o.status.charAt(0)),3),d("span",jb,[o.oldPath&&o.status.startsWith("R")?(v(),y(we,{key:0},[d("span",Yb,A(o.oldPath),1),i[4]||(i[4]=d("span",{class:"text-retro-muted mx-1"},"→",-1))],64)):F("",!0),Ie(" "+A(o.path),1)]),o.binary?(v(),y("span",Hb,"binary")):(v(),y("span",Fb,[o.additions>0?(v(),y("span",Ub,"+"+A(o.additions),1)):F("",!0),o.deletions>0?(v(),y("span",Gb,"-"+A(o.deletions),1)):F("",!0)]))]))),128))])):r.files&&r.files.length===0?(v(),y("div",Kb," No differences between these commits ")):F("",!0)]))}}),ex={":art:":"🎨",":zap:":"⚡",":fire:":"🔥",":bug:":"🐛",":ambulance:":"🚑",":sparkles:":"✨",":memo:":"📝",":rocket:":"🚀",":lipstick:":"💄",":tada:":"🎉",":white_check_mark:":"✅",":lock:":"🔒",":closed_lock_with_key:":"🔐",":bookmark:":"🔖",":rotating_light:":"🚨",":construction:":"🚧",":green_heart:":"💚",":arrow_down:":"⬇️",":arrow_up:":"⬆️",":pushpin:":"📌",":construction_worker:":"👷",":chart_with_upwards_trend:":"📈",":recycle:":"♻️",":heavy_plus_sign:":"➕",":heavy_minus_sign:":"➖",":wrench:":"🔧",":hammer:":"🔨",":globe_with_meridians:":"🌐",":pencil2:":"✏️",":poop:":"💩",":rewind:":"⏪",":twisted_rightwards_arrows:":"🔀",":package:":"📦",":alien:":"👽",":truck:":"🚚",":page_facing_up:":"📄",":boom:":"💥",":bento:":"🍱",":wheelchair:":"♿",":bulb:":"💡",":beers:":"🍻",":speech_balloon:":"💬",":card_file_box:":"🗃️",":loud_sound:":"🔊",":mute:":"🔇",":busts_in_silhouette:":"👥",":children_crossing:":"🚸",":building_construction:":"🏗️",":iphone:":"📱",":clown_face:":"🤡",":egg:":"🥚",":see_no_evil:":"🙈",":camera_flash:":"📸",":alembic:":"⚗️",":mag:":"🔍",":label:":"🏷️",":seedling:":"🌱",":triangular_flag_on_post:":"🚩",":goal_net:":"🥅",":dizzy:":"💫",":wastebasket:":"🗑️",":passport_control:":"🛂",":adhesive_bandage:":"🩹",":monocle_face:":"🧐",":coffin:":"⚰️",":test_tube:":"🧪",":necktie:":"👔",":stethoscope:":"🩺",":bricks:":"🧱",":technologist:":"🧑‍💻",":money_with_wings:":"💸",":thread:":"🧵",":safety_vest:":"🦺"},tx=/https?:\/\/[^\s<>)"']+/g;function rx(r){return r.replace(tx,e=>`<a href="${e}" target="_blank" rel="noopener noreferrer" class="text-retro-blue hover:underline">${e}</a>`)}function nx(r){return r.replace(/:[a-z0-9_]+:/g,e=>ex[e]||e)}function sx(r){if(!r)return"";let e=nx(r);return e=F1.parse(e),e=rx(e),e=U1.sanitize(e,{ALLOWED_TAGS:["a","strong","em","code","b","i","br","p","ul","ol","li","pre","blockquote","h1","h2","h3"],ALLOWED_ATTR:["href","target","rel","class"]}),e}const ix={class:"flex-shrink-0 flex items-center justify-between px-4 py-2 border-b border-retro-border bg-retro-panel"},ox={class:"flex items-center gap-2 min-w-0"},ax={class:"text-retro-cyan font-mono text-sm"},lx={class:"text-retro-muted text-sm truncate"},cx={class:"flex items-center gap-1 flex-shrink-0"},ux=["aria-label","title"],hx={class:"flex-1 overflow-auto p-4 space-y-4"},dx={class:"space-y-2"},fx={class:"flex items-center gap-2 text-sm"},mx={class:"text-retro-text font-mono text-xs bg-retro-panel px-2 py-1 rounded"},px={class:"flex items-center gap-2 text-sm"},gx={class:"text-retro-text"},Ox={class:"text-retro-muted"},vx={key:0,class:"flex items-center gap-2 text-sm"},bx={class:"text-retro-text"},xx={class:"text-retro-muted"},yx={class:"flex items-center gap-2 text-sm"},kx={class:"text-retro-text"},wx={key:1,class:"flex items-start gap-2 text-sm"},Sx={class:"flex flex-wrap gap-1"},$x=["onClick","title"],Cx={key:2,class:"flex items-start gap-2 text-sm"},Qx={class:"flex flex-wrap gap-1"},Px={key:3,class:"flex items-start gap-2 text-sm"},Tx={class:"flex flex-wrap gap-1"},Mx={class:"space-y-1"},Ax={class:"text-retro-text text-sm font-mono bg-retro-panel p-3 rounded"},_x={key:0,class:"space-y-1"},Rx=["innerHTML"],Bx={key:1,class:"space-y-2"},Zx={class:"flex items-center gap-2 text-sm"},Ex={class:"text-retro-muted"},Dx={key:0,class:"flex items-center gap-2"},Lx={class:"text-retro-green text-xs font-mono"},Xx={class:"flex-1 h-2 rounded overflow-hidden bg-retro-panel flex"},Ix={class:"text-retro-red text-xs font-mono"},Vx={key:2,class:"space-y-2"},zx={class:"flex items-center justify-between"},Nx={class:"text-retro-muted text-xs uppercase tracking-wide"},Wx={class:"flex items-center gap-1"},qx={key:0,class:"text-retro-muted text-sm py-2"},jx={key:1,class:"space-y-0.5"},Yx=["onClick"],Fx=["title"],Ux={class:"text-retro-text font-mono text-xs truncate flex-1"},Gx={class:"text-retro-muted"},Hx={class:"text-retro-text"},Kx={key:0,class:"flex-shrink-0 font-mono text-xs flex items-center gap-1"},Jx={key:0,class:"text-retro-green"},ey={key:1,class:"text-retro-red"},ty={key:1,class:"flex-shrink-0 font-mono text-xs text-retro-muted"},ry={key:2,class:"space-y-0"},ny=["onClick"],sy={class:"text-retro-text font-mono text-xs"},iy=["title"],oy={class:"text-retro-text font-mono text-xs truncate flex-1"},ay={class:"text-retro-muted"},ly={class:"text-retro-text"},cy={key:0,class:"flex-shrink-0 font-mono text-xs flex items-center gap-1"},uy={key:0,class:"text-retro-green"},hy={key:1,class:"text-retro-red"},dy={key:1,class:"flex-shrink-0 font-mono text-xs text-retro-muted"},fy={key:3,class:"flex items-center gap-2 text-retro-muted text-sm py-2"},my={key:4,class:"text-retro-muted text-sm py-2"},py=Ve({__name:"GitCommitDetail",props:{commit:{},files:{},stats:{},loading:{type:Boolean,default:!1},committer:{},committerEmail:{},detailPosition:{default:"inline"}},emits:["close","navigateToCommit","togglePosition","navigatePrev","navigateNext","openFileDiff"],setup(r,{emit:e}){const t=r,n=e,s=P(null),i=P("flat"),o=P(new Set),a=J(()=>!t.committer||!t.committerEmail?!1:t.committer!==t.commit.author||t.committerEmail!==t.commit.email),l=J(()=>{const j=t.commit.body;return j?sx(j):""}),c=J(()=>{if(!t.stats)return"";const{filesChanged:j,additions:V,deletions:Z}=t.stats,W=[`${j} ${j===1?"file":"files"} changed`];return V>0&&W.push(`+${V} insertion${V===1?"":"s"}`),Z>0&&W.push(`-${Z} deletion${Z===1?"":"s"}`),W.join(", ")});function u(j){const V=[];for(const Z of j){const U=Z.path.split("/");let W=V;for(let N=0;N<U.length;N++){const I=U[N],z=N===U.length-1,be=U.slice(0,N+1).join("/");let K=W.find(H=>H.name===I&&H.isDirectory===!z);K||(K={name:I,fullPath:be,isDirectory:!z,children:[],file:z?Z:void 0},W.push(K)),z||(W=K.children)}}return h(V),V}function h(j){for(const V of j)if(V.isDirectory)for(h(V.children);V.children.length===1&&V.children[0].isDirectory;){const Z=V.children[0];V.name=`${V.name}/${Z.name}`,V.fullPath=Z.fullPath,V.children=Z.children}}function f(j){return[...j].sort((V,Z)=>V.isDirectory&&!Z.isDirectory?-1:!V.isDirectory&&Z.isDirectory?1:V.name.localeCompare(Z.name))}function p(j,V,Z){const U=[];for(const W of f(j)){const N=Z.size===0?!0:Z.has(W.fullPath);U.push({key:W.fullPath,depth:V,isDirectory:W.isDirectory,name:W.name,fullPath:W.fullPath,expanded:W.isDirectory?N:!1,file:W.file}),W.isDirectory&&N&&U.push(...p(W.children,V+1,Z))}return U}const g=J(()=>!t.files||t.files.length===0?[]:u(t.files)),O=J(()=>p(g.value,0,o.value));function b(j){o.value.has(j)?o.value.delete(j):o.value.add(j),o.value=new Set(o.value)}function x(){const j=V=>{const Z=[];for(const U of V)U.isDirectory&&(Z.push(U.fullPath),Z.push(...j(U.children)));return Z};o.value=new Set(j(g.value))}function k(){o.value=new Set}ze(i,j=>{j==="tree"&&x()});function w(j){return new Date(j*1e3).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0})}function S(j){return Fs[j]||{label:j,colorClass:"text-retro-muted"}}const Q=J(()=>{if(!t.stats)return{addPct:0,delPct:0};const j=t.stats.additions+t.stats.deletions;return j===0?{addPct:50,delPct:50}:{addPct:Math.round(t.stats.additions/j*100),delPct:Math.round(t.stats.deletions/j*100)}});function L(j){j.key==="ArrowUp"?(j.preventDefault(),n("navigatePrev")):j.key==="ArrowDown"?(j.preventDefault(),n("navigateNext")):j.key==="Escape"&&(j.preventDefault(),n("close"))}gt(()=>{It(()=>{s.value?.focus()})}),ze(()=>t.commit.hash,()=>{It(()=>{s.value?.focus()})});function D(){n("close")}function G(j){n("navigateToCommit",j)}function oe(){n("togglePosition")}function ie(j){n("openFileDiff",j)}return(j,V)=>(v(),y("section",{ref_key:"containerRef",ref:s,tabindex:0,onKeydown:L,class:"flex-1 min-h-0 flex flex-col border-t border-retro-border bg-retro-dark focus:outline-none","aria-label":"Commit details",role:"region"},[d("div",ix,[d("div",ox,[d("span",ax,A(r.commit.shortHash),1),d("span",lx,A(r.commit.message.split(`
5
5
  `)[0]),1)]),d("div",cx,[d("button",{onClick:oe,class:"p-1 hover:bg-retro-dark rounded transition-colors focus:outline-none focus:ring-2 focus:ring-retro-cyan","aria-label":r.detailPosition==="inline"?"Dock detail to bottom":"Show detail inline",title:r.detailPosition==="inline"?"Dock to bottom":"Show inline"},[r.detailPosition==="inline"?(v(),pe(m(op),{key:0,class:"w-4 h-4 text-retro-muted hover:text-retro-text"})):(v(),pe(m(ip),{key:1,class:"w-4 h-4 text-retro-muted hover:text-retro-text"}))],8,ux),d("button",{onClick:D,class:"p-1 hover:bg-retro-dark rounded transition-colors focus:outline-none focus:ring-2 focus:ring-retro-cyan","aria-label":"Close commit details"},[ee(m(St),{class:"w-4 h-4 text-retro-muted hover:text-retro-text"})])])]),d("div",hx,[d("div",dx,[d("div",fx,[V[2]||(V[2]=d("span",{class:"text-retro-muted w-20 flex-shrink-0"},"Hash:",-1)),d("code",mx,A(r.commit.hash),1)]),d("div",px,[ee(m(Nh),{class:"w-4 h-4 text-retro-muted flex-shrink-0"}),d("span",gx,A(r.commit.author),1),d("span",Ox,"<"+A(r.commit.email)+">",1)]),a.value?(v(),y("div",vx,[ee(m(Nh),{class:"w-4 h-4 text-retro-yellow flex-shrink-0"}),V[3]||(V[3]=d("span",{class:"text-retro-muted text-xs uppercase mr-1"},"Committer:",-1)),d("span",bx,A(r.committer),1),d("span",xx,"<"+A(r.committerEmail)+">",1)])):F("",!0),d("div",yx,[ee(m(G1),{class:"w-4 h-4 text-retro-muted flex-shrink-0"}),d("span",kx,A(w(r.commit.timestamp)),1)]),r.commit.parents?.length>0?(v(),y("div",wx,[V[4]||(V[4]=d("span",{class:"text-retro-muted w-20 flex-shrink-0"},"Parents:",-1)),d("div",Sx,[(v(!0),y(we,null,Ne(r.commit.parents,Z=>(v(),y("button",{key:Z,onClick:U=>G(Z),class:"text-retro-cyan font-mono text-xs bg-retro-panel px-2 py-0.5 rounded hover:bg-retro-dark hover:text-retro-text transition-colors cursor-pointer focus:outline-none focus:ring-2 focus:ring-retro-cyan",title:`Navigate to parent ${Z.substring(0,7)}`},A(Z.substring(0,7)),9,$x))),128))])])):F("",!0),r.commit.branches?.length>0?(v(),y("div",Cx,[V[5]||(V[5]=d("span",{class:"text-retro-muted w-20 flex-shrink-0"},"Branches:",-1)),d("div",Qx,[(v(!0),y(we,null,Ne(r.commit.branches,Z=>(v(),y("span",{key:Z,class:"text-retro-green font-mono text-xs bg-retro-panel px-2 py-0.5 rounded"},A(Z),1))),128))])])):F("",!0),r.commit.tags?.length>0?(v(),y("div",Px,[V[6]||(V[6]=d("span",{class:"text-retro-muted w-20 flex-shrink-0"},"Tags:",-1)),d("div",Tx,[(v(!0),y(we,null,Ne(r.commit.tags,Z=>(v(),y("span",{key:Z,class:"text-retro-yellow font-mono text-xs bg-retro-panel px-2 py-0.5 rounded"},A(Z),1))),128))])])):F("",!0)]),d("div",Mx,[V[7]||(V[7]=d("h4",{class:"text-retro-muted text-xs uppercase tracking-wide"}," Message ",-1)),d("div",Ax,A(r.commit.message.split(`
6
6
  `)[0]),1)]),r.commit.body?(v(),y("div",_x,[V[8]||(V[8]=d("h4",{class:"text-retro-muted text-xs uppercase tracking-wide"}," Body ",-1)),d("div",{class:"text-retro-text text-sm font-mono bg-retro-panel p-3 rounded commit-body-rendered",innerHTML:l.value},null,8,Rx)])):F("",!0),r.stats?(v(),y("div",Bx,[d("div",Zx,[d("span",Ex,A(c.value),1)]),r.stats.additions>0||r.stats.deletions>0?(v(),y("div",Dx,[d("span",Lx,"+"+A(r.stats.additions),1),d("div",Xx,[d("div",{class:"bg-retro-green h-full transition-all",style:tr({width:Q.value.addPct+"%"})},null,4),d("div",{class:"bg-retro-red h-full transition-all",style:tr({width:Q.value.delPct+"%"})},null,4)]),d("span",Ix,"-"+A(r.stats.deletions),1)])):F("",!0)])):F("",!0),r.files?(v(),y("div",Vx,[d("div",zx,[d("h4",Nx," Files Changed ("+A(r.files.length)+") ",1),d("div",Wx,[d("button",{onClick:V[0]||(V[0]=Z=>i.value="flat"),class:_e(["p-1 rounded transition-colors focus:outline-none focus:ring-2 focus:ring-retro-cyan",i.value==="flat"?"bg-retro-panel text-retro-cyan":"text-retro-muted hover:text-retro-text"]),"aria-label":"Flat file list",title:"Flat file list"},[ee(m(hp),{class:"w-4 h-4"})],2),d("button",{onClick:V[1]||(V[1]=Z=>i.value="tree"),class:_e(["p-1 rounded transition-colors focus:outline-none focus:ring-2 focus:ring-retro-cyan",i.value==="tree"?"bg-retro-panel text-retro-cyan":"text-retro-muted hover:text-retro-text"]),"aria-label":"Tree file view",title:"Tree file view"},[ee(m(Wh),{class:"w-4 h-4"})],2)])]),r.files.length===0?(v(),y("div",qx," No files changed in this commit. ")):i.value==="flat"?(v(),y("ul",jx,[(v(!0),y(we,null,Ne(r.files,Z=>(v(),y("li",{key:Z.path,class:"flex items-center gap-2 text-sm py-1 px-2 hover:bg-retro-panel rounded group cursor-pointer",onClick:U=>ie(Z)},[d("span",{class:_e(["flex-shrink-0 w-5 h-5 flex items-center justify-center text-xs font-bold rounded",S(Z.status).colorClass]),title:S(Z.status).label},A(Z.status),11,Fx),ee(m(Os),{class:"w-4 h-4 text-retro-muted flex-shrink-0"}),d("span",Ux,[Z.status==="R"&&Z.oldPath?(v(),y(we,{key:0},[d("span",Gx,A(Z.oldPath),1),V[9]||(V[9]=d("span",{class:"text-retro-yellow mx-1"},"→",-1)),d("span",Hx,A(Z.path),1)],64)):(v(),y(we,{key:1},[Ie(A(Z.path),1)],64))]),!Z.binary&&(Z.additions>0||Z.deletions>0)?(v(),y("span",Kx,[Z.additions>0?(v(),y("span",Jx,"+"+A(Z.additions),1)):F("",!0),Z.deletions>0?(v(),y("span",ey,"-"+A(Z.deletions),1)):F("",!0)])):Z.binary?(v(),y("span",ty,"binary")):F("",!0)],8,Yx))),128))])):(v(),y("div",ry,[d("div",{class:"flex items-center gap-2 mb-1"},[d("button",{onClick:x,class:"text-xs text-retro-muted hover:text-retro-text transition-colors"}," Expand all "),V[10]||(V[10]=d("span",{class:"text-retro-muted text-xs"},"|",-1)),d("button",{onClick:k,class:"text-xs text-retro-muted hover:text-retro-text transition-colors"}," Collapse all ")]),(v(!0),y(we,null,Ne(O.value,Z=>(v(),y("div",{key:Z.key,class:_e(["flex items-center gap-1 py-0.5 px-1 hover:bg-retro-panel rounded text-sm cursor-pointer",{"select-none":Z.isDirectory}]),style:tr({paddingLeft:Z.depth*16+4+"px"}),onClick:U=>Z.isDirectory?b(Z.fullPath):Z.file?ie(Z.file):void 0},[Z.isDirectory?(v(),y(we,{key:0},[ee(m(H1),{class:_e(["w-3 h-3 text-retro-muted transition-transform flex-shrink-0",{"rotate-90":Z.expanded}])},null,8,["class"]),ee(m(Wh),{class:"w-4 h-4 text-retro-yellow flex-shrink-0"}),d("span",sy,A(Z.name),1)],64)):Z.file?(v(),y(we,{key:1},[d("span",{class:_e(["flex-shrink-0 w-5 h-5 flex items-center justify-center text-xs font-bold rounded",S(Z.file.status).colorClass]),title:S(Z.file.status).label},A(Z.file.status),11,iy),ee(m(Os),{class:"w-4 h-4 text-retro-muted flex-shrink-0"}),d("span",oy,[Z.file.status==="R"&&Z.file.oldPath?(v(),y(we,{key:0},[d("span",ay,A(Z.file.oldPath.split("/").pop()),1),V[11]||(V[11]=d("span",{class:"text-retro-yellow mx-1"},"→",-1)),d("span",ly,A(Z.name),1)],64)):(v(),y(we,{key:1},[Ie(A(Z.name),1)],64))]),!Z.file.binary&&(Z.file.additions>0||Z.file.deletions>0)?(v(),y("span",cy,[Z.file.additions>0?(v(),y("span",uy,"+"+A(Z.file.additions),1)):F("",!0),Z.file.deletions>0?(v(),y("span",hy,"-"+A(Z.file.deletions),1)):F("",!0)])):Z.file.binary?(v(),y("span",dy,"binary")):F("",!0)],64)):F("",!0)],14,ny))),128))]))])):r.loading?(v(),y("div",fy,[...V[12]||(V[12]=[d("div",{class:"w-3 h-3 border-2 border-retro-muted border-t-retro-cyan rounded-full animate-spin"},null,-1),Ie(" Loading file changes... ",-1)])])):(v(),y("div",my," Failed to load file changes. "))])],544))}}),gy=ws(py,[["__scopeId","data-v-29f450ea"]]),Oy={class:"flex-1 min-h-0 flex flex-col border-t border-retro-border bg-retro-dark","aria-label":"Uncommitted changes details"},vy={class:"flex-shrink-0 flex items-center justify-between px-4 py-2 border-b border-retro-border bg-retro-panel"},by={class:"flex items-center gap-2 min-w-0"},xy={class:"text-retro-muted text-sm"},yy={key:0,class:"w-3 h-3 border-2 border-retro-muted border-t-retro-cyan rounded-full animate-spin",title:"Staging..."},ky={class:"flex-1 overflow-auto p-4 space-y-3"},wy={class:"space-y-2"},Sy=["disabled"],$y={class:"space-y-1"},Cy={class:"flex items-center justify-between"},Qy={class:"text-retro-green text-xs uppercase tracking-wide font-semibold"},Py={key:0,class:"text-retro-muted text-xs py-1"},Ty={key:1,class:"space-y-0.5"},My=["aria-label","onClick"],Ay={class:"text-retro-text font-mono text-xs truncate"},_y={class:"space-y-1"},Ry={class:"flex items-center justify-between"},By={class:"text-retro-yellow text-xs uppercase tracking-wide font-semibold"},Zy={key:0,class:"text-retro-muted text-xs py-1"},Ey={key:1,class:"space-y-0.5"},Dy=["aria-label","onClick"],Ly={class:"text-retro-text font-mono text-xs truncate"},Xy=Ve({__name:"GitUncommittedDetail",props:{stagedFiles:{default:()=>[]},unstagedFiles:{default:()=>[]},isStaging:{type:Boolean,default:!1},isCommitting:{type:Boolean,default:!1}},emits:["close","stageFiles","unstageFiles","stageAll","unstageAll","commit"],setup(r,{emit:e}){const t=r,n=e,s=P(""),i=P(!1),o=J(()=>s.value.trim().length>0&&t.stagedFiles.length>0&&!i.value&&!t.isCommitting);function a(O){return Fs[O]||{label:O,colorClass:"text-retro-muted"}}function l(){n("close")}function c(O){n("stageFiles",[O.path])}function u(O){n("unstageFiles",[O.path])}function h(){n("stageAll")}function f(){n("unstageAll")}async function p(){o.value&&(i.value=!0,n("commit",s.value.trim()),s.value="",i.value=!1)}function g(O){(O.metaKey||O.ctrlKey)&&O.key==="Enter"&&(O.preventDefault(),p())}return(O,b)=>(v(),y("section",Oy,[d("div",vy,[d("div",by,[ee(m(Oo),{class:"w-4 h-4 text-retro-yellow"}),b[1]||(b[1]=d("span",{class:"text-retro-yellow font-semibold text-sm"},"Uncommitted Changes",-1)),d("span",xy,"("+A(r.stagedFiles.length+r.unstagedFiles.length)+" files)",1),t.isStaging?(v(),y("div",yy)):F("",!0)]),d("button",{onClick:l,class:"p-1 hover:bg-retro-dark rounded transition-colors focus:outline-none focus:ring-2 focus:ring-retro-cyan","aria-label":"Close uncommitted changes details"},[ee(m(St),{class:"w-4 h-4 text-retro-muted hover:text-retro-text"})])]),d("div",ky,[d("div",wy,[je(d("textarea",{"onUpdate:modelValue":b[0]||(b[0]=x=>Je(s)?s.value=x:null),placeholder:"Commit message...",rows:"3",class:"w-full px-3 py-2 text-sm bg-retro-panel border border-retro-border rounded text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan resize-none font-mono",onKeydown:g},null,544),[[Rt,m(s)]]),d("button",{disabled:!m(o),class:_e(["w-full px-3 py-1.5 text-sm font-semibold rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",m(o)?"bg-retro-green text-retro-dark hover:bg-retro-green/90":"bg-retro-green/30 text-retro-dark"]),onClick:p},A(m(i)||t.isCommitting?"Committing...":`Commit (${r.stagedFiles.length} staged)`),11,Sy)]),d("div",$y,[d("div",Cy,[d("h4",Qy," Staged Changes ("+A(r.stagedFiles.length)+") ",1),r.stagedFiles.length>0?(v(),y("button",{key:0,class:"text-[11px] text-retro-muted hover:text-retro-text transition-colors",onClick:f}," Unstage All ")):F("",!0)]),r.stagedFiles.length===0?(v(),y("div",Py," No staged files. Stage files below to commit. ")):(v(),y("ul",Ty,[(v(!0),y(we,null,Ne(r.stagedFiles,x=>(v(),y("li",{key:"staged-"+x.path,class:"flex items-center gap-2 text-sm py-1 px-2 hover:bg-retro-panel rounded group"},[d("button",{class:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded hover:bg-retro-red/20 transition-colors opacity-60 group-hover:opacity-100",title:"Unstage file","aria-label":`Unstage ${x.path}`,onClick:k=>u(x)},[ee(m(Bv),{class:"w-3.5 h-3.5 text-retro-red"})],8,My),d("span",{class:_e(["flex-shrink-0 w-4 text-center text-xs font-bold",a(x.status).colorClass])},A(x.status),3),ee(m(Os),{class:"w-3.5 h-3.5 text-retro-muted flex-shrink-0"}),d("span",Ay,A(x.oldPath?`${x.oldPath} → ${x.path}`:x.path),1)]))),128))]))]),d("div",_y,[d("div",Ry,[d("h4",By," Unstaged Changes ("+A(r.unstagedFiles.length)+") ",1),r.unstagedFiles.length>0?(v(),y("button",{key:0,class:"text-[11px] text-retro-muted hover:text-retro-text transition-colors",onClick:h}," Stage All ")):F("",!0)]),r.unstagedFiles.length===0?(v(),y("div",Zy," No unstaged changes. ")):(v(),y("ul",Ey,[(v(!0),y(we,null,Ne(r.unstagedFiles,x=>(v(),y("li",{key:"unstaged-"+x.path,class:"flex items-center gap-2 text-sm py-1 px-2 hover:bg-retro-panel rounded group"},[d("button",{class:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded hover:bg-retro-green/20 transition-colors opacity-60 group-hover:opacity-100",title:"Stage file","aria-label":`Stage ${x.path}`,onClick:k=>c(x)},[ee(m(dl),{class:"w-3.5 h-3.5 text-retro-green"})],8,Dy),d("span",{class:_e(["flex-shrink-0 w-4 text-center text-xs font-bold",a(x.status).colorClass])},A(x.status),3),ee(m(Os),{class:"w-3.5 h-3.5 text-retro-muted flex-shrink-0"}),d("span",Ly,A(x.oldPath?`${x.oldPath} → ${x.path}`:x.path),1)]))),128))]))])])]))}}),Iy=["aria-label"],Vy={key:0,class:"px-3 py-1 text-xs text-retro-muted border-b border-retro-border truncate font-mono"},zy={key:0,class:"my-1 border-t border-retro-border",role:"separator"},Ny=["aria-disabled","onClick","onMouseenter"],Wy={key:1,class:"w-4 h-4 flex-shrink-0"},rd=220,qy=36,jy=9,Yy=29,hn=8,xo=Ve({__name:"GitContextMenu",props:{items:{},x:{},y:{},title:{}},emits:["close","action"],setup(r,{emit:e}){const t=r,n=e,s=P(null),i=P(-1),o=J(()=>t.items.map((p,g)=>({item:p,i:g})).filter(({item:p})=>!p.disabled).map(({i:p})=>p));let a=!1;function l(p){a&&s.value&&!s.value.contains(p.target)&&n("close")}gt(()=>{requestAnimationFrame(()=>{a=!0}),document.addEventListener("mousedown",l),document.addEventListener("contextmenu",l),It(()=>{s.value?.focus()})}),wt(()=>{a=!1,document.removeEventListener("mousedown",l),document.removeEventListener("contextmenu",l)});function c(p){const g=o.value;if(g.length===0)return;if(i.value===-1){i.value=p===1?g[0]:g[g.length-1];return}const O=g.indexOf(i.value);if(O===-1){i.value=p===1?g[0]:g[g.length-1];return}const b=O+p;b>=0&&b<g.length&&(i.value=g[b])}function u(p){switch(p.key){case"Escape":p.preventDefault(),n("close");break;case"ArrowDown":p.preventDefault(),c(1);break;case"ArrowUp":p.preventDefault(),c(-1);break;case"Enter":{p.preventDefault();const g=t.items[i.value];g&&!g.disabled&&(n("action",g.key),n("close"));break}}}function h(p){p.disabled||(n("action",p.key),n("close"))}const f=J(()=>{const p=t.title?Yy:0,g=t.items.filter(w=>w.separator).length,O=t.items.length*qy+g*jy+hn,b=p+O;let x=t.x,k=t.y;return typeof window<"u"&&(x+rd>window.innerWidth-hn&&(x=window.innerWidth-rd-hn),x<hn&&(x=hn),k+b>window.innerHeight-hn&&(k=window.innerHeight-b-hn),k<hn&&(k=hn)),{left:`${x}px`,top:`${k}px`}});return(p,g)=>(v(),pe(Pr,{to:"body"},[d("div",{ref_key:"menuRef",ref:s,class:"fixed z-50 bg-retro-panel border border-retro-border rounded shadow-lg py-1 min-w-[220px]",style:tr(m(f)),role:"menu","aria-label":r.title??"Context menu",tabindex:"-1",onKeydown:u},[r.title?(v(),y("div",Vy,A(r.title),1)):F("",!0),(v(!0),y(we,null,Ne(r.items,(O,b)=>(v(),y(we,{key:O.key},[O.separator?(v(),y("div",zy)):F("",!0),d("button",{class:_e(["w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors focus:outline-none",[O.disabled?"text-retro-muted/50 cursor-not-allowed":O.danger?["text-retro-red hover:bg-retro-red/10 focus:bg-retro-red/10",m(i)===b?"bg-retro-red/10":""]:["text-retro-text hover:bg-retro-cyan/10 focus:bg-retro-cyan/10",m(i)===b?"bg-retro-cyan/10":""]]]),role:"menuitem","aria-disabled":O.disabled||void 0,tabindex:-1,onClick:x=>h(O),onMouseenter:x=>i.value=O.disabled?m(i):b,onMouseleave:g[0]||(g[0]=x=>i.value=-1)},[O.icon?(v(),pe(ps(O.icon),{key:0,class:_e(["w-4 h-4 flex-shrink-0",O.disabled?"opacity-50":O.danger?"":"text-retro-muted"])},null,8,["class"])):(v(),y("span",Wy)),Ie(" "+A(O.label),1)],42,Ny)],64))),128))],44,Iy)]))}}),Fy=Ve({__name:"GitBranchMenu",props:{branchName:{},isCurrentBranch:{type:Boolean},isLocal:{type:Boolean},x:{},y:{}},emits:["close","checkout","createBranch","deleteBranch","rename","merge","rebase","push","pull","fetch","copyName"],setup(r,{emit:e}){const t=r,n=e,s=J(()=>[{key:"checkout",label:"Checkout",icon:gs,disabled:t.isCurrentBranch},{key:"rename",label:"Rename",icon:K1,separator:!0},{key:"deleteBranch",label:"Delete",icon:vn,danger:!0,disabled:t.isCurrentBranch},{key:"merge",label:"Merge into Current",icon:ap,separator:!0,disabled:t.isCurrentBranch},{key:"rebase",label:"Rebase Current Onto",icon:rp,disabled:t.isCurrentBranch},{key:"push",label:"Push",icon:np,separator:!0},{key:"copyName",label:"Copy Branch Name",icon:Ys,separator:!0}]),i=J(()=>[{key:"checkout",label:"Checkout",icon:gs},{key:"deleteBranch",label:"Delete Remote Branch",icon:vn,separator:!0,danger:!0},{key:"fetch",label:"Fetch",icon:up,separator:!0},{key:"pull",label:"Pull into Current",icon:mv},{key:"copyName",label:"Copy Branch Name",icon:Ys,separator:!0}]),o=J(()=>t.isLocal?s.value:i.value),a={checkout:()=>n("checkout"),createBranch:()=>n("createBranch"),deleteBranch:()=>n("deleteBranch"),rename:()=>n("rename"),merge:()=>n("merge"),rebase:()=>n("rebase"),push:()=>n("push"),pull:()=>n("pull"),fetch:()=>n("fetch"),copyName:()=>n("copyName")};function l(c){a[c]?.(),n("close")}return(c,u)=>{const h=xo;return v(),pe(h,{items:m(o),x:r.x,y:r.y,title:r.branchName,onAction:l,onClose:u[0]||(u[0]=f=>n("close"))},null,8,["items","x","y","title"])}}}),Uy=Ve({__name:"GitCommitMenu",props:{commit:{},x:{},y:{}},emits:["close","addTag","createBranch","checkout","cherryPick","revert","mergeInto","reset","copyHash","copySubject"],setup(r,{emit:e}){const t=e,n=J(()=>[{key:"addTag",label:"Add Tag",icon:Du},{key:"createBranch",label:"Create Branch",icon:dl},{key:"checkout",label:"Checkout (detached HEAD)",icon:gs,separator:!0},{key:"cherryPick",label:"Cherry Pick",icon:$v},{key:"revert",label:"Revert",icon:sp},{key:"mergeInto",label:"Merge into Current",icon:ap,separator:!0},{key:"reset",label:"Reset Current Branch to Here",icon:rp,danger:!0},{key:"copyHash",label:"Copy Commit Hash",icon:Ys,separator:!0},{key:"copySubject",label:"Copy Commit Subject",icon:Ys}]),s={addTag:()=>t("addTag"),createBranch:()=>t("createBranch"),checkout:()=>t("checkout"),cherryPick:()=>t("cherryPick"),revert:()=>t("revert"),mergeInto:()=>t("mergeInto"),reset:()=>t("reset"),copyHash:()=>t("copyHash"),copySubject:()=>t("copySubject")};function i(o){s[o]?.(),t("close")}return(o,a)=>{const l=xo;return v(),pe(l,{items:m(n),x:r.x,y:r.y,title:r.commit.shortHash,onAction:i,onClose:a[0]||(a[0]=c=>t("close"))},null,8,["items","x","y","title"])}}}),Gy=Ve({__name:"GitTagMenu",props:{tagName:{},x:{},y:{}},emits:["close","viewDetails","deleteTag","pushTag","copyName"],setup(r,{emit:e}){const t=e,n=[{key:"viewDetails",label:"View Details",icon:Du},{key:"deleteTag",label:"Delete Tag",icon:vn,separator:!0,danger:!0},{key:"pushTag",label:"Push Tag",icon:np},{key:"copyName",label:"Copy Tag Name",icon:Ys,separator:!0}],s={viewDetails:()=>t("viewDetails"),deleteTag:()=>t("deleteTag"),pushTag:()=>t("pushTag"),copyName:()=>t("copyName")};function i(o){s[o]?.()}return(o,a)=>{const l=xo;return v(),pe(l,{items:n,x:r.x,y:r.y,title:r.tagName,onClose:a[0]||(a[0]=c=>t("close")),onAction:i},null,8,["x","y","title"])}}}),Hy=Ve({__name:"GitStashMenu",props:{stashIndex:{},stashMessage:{},x:{},y:{}},emits:["close","apply","pop","drop","createBranch","copyName","copyHash"],setup(r,{emit:e}){const t=e,n=[{key:"apply",label:"Apply Stash",icon:fv},{key:"pop",label:"Pop Stash",icon:sp},{key:"createBranch",label:"Create Branch from Stash",icon:J1,separator:!0},{key:"drop",label:"Drop Stash",icon:vn,separator:!0,danger:!0},{key:"copyName",label:"Copy Stash Reference",icon:Ys,separator:!0},{key:"copyHash",label:"Copy Stash Hash",icon:Av}],s={apply:()=>t("apply"),pop:()=>t("pop"),drop:()=>t("drop"),createBranch:()=>t("createBranch"),copyName:()=>t("copyName"),copyHash:()=>t("copyHash")};function i(o){s[o]?.()}return(o,a)=>{const l=xo;return v(),pe(l,{items:n,x:r.x,y:r.y,title:r.stashMessage,onClose:a[0]||(a[0]=c=>t("close")),onAction:i},null,8,["x","y","title"])}}}),Ky=Ve({__name:"GitUncommittedMenu",props:{x:{},y:{}},emits:["close","stash","reset","clean"],setup(r,{emit:e}){const t=e,n=[{key:"stash",label:"Stash Uncommitted Changes",icon:dv},{key:"reset",label:"Reset Working Directory",icon:gs,separator:!0,danger:!0},{key:"clean",label:"Clean Untracked Files",icon:vn,danger:!0}],s={stash:()=>t("stash"),reset:()=>t("reset"),clean:()=>t("clean")};function i(o){s[o]?.()}return(o,a)=>{const l=xo;return v(),pe(l,{items:n,x:r.x,y:r.y,title:"Uncommitted Changes",onClose:a[0]||(a[0]=c=>t("close")),onAction:i},null,8,["x","y"])}}});async function Jy(r,e,t){try{return(await $fetch("/api/git/merge-base",{params:{workingDirectory:r,branch:e,baseBranch:t??void 0}})).mergeBase}catch{return null}}function nd(r){const e={};for(const{branch:t,mergeBase:n}of r)t&&n&&(e[t]=n);return e}async function ek(r){return $fetch("/api/git/file-diff",{query:r})}async function tk(r){return $fetch("/api/git/diff",{query:r})}const ml=Mu("gitGraph",()=>{const r=P([]),e=P([]),t=P([]),n=P(new Set),s=P([]),i=P([]),o=P(0),a=P(!1),l=P(null),c=P(null),u=P(null),h=P(!1),f=P(null),p=P(!1),g=P(0),O=P(""),b=P([]),x=P(null),k=P(!1),w=P(!1),S=P(!1),Q=P(!1),L=8e3,D=P(null);let G=null;function oe(Y){D.value=Y,G&&clearTimeout(G),G=setTimeout(()=>{D.value=null},L)}function ie(){D.value=null,G&&(clearTimeout(G),G=null)}async function j(Y,se,Xe,Ut){if(!x.value)return{success:!1,error:"No working directory set"};try{const zr=await $fetch(Y,{method:Ut?.method??"POST",body:{workingDirectory:x.value,...se}});return(Ut?.reloadGraph??!0)&&await sr(x.value),{success:!0,data:zr}}catch(zr){const Nr=Xo(zr,Xe);return oe(Nr),{success:!1,error:Nr}}}const V=P(null),Z=P(!1),U=P(!1),W=P(null),N=P([]),I=P([]),z=P(null),be=P(null),K=P(null),H=P("inline"),re=P("list"),Oe=P("rounded"),ge=P(!1),$e=P({date:!0,author:!0,commit:!0}),Pe=P(0),Fe=P(0),T=P(null),M=P(null),E=P(null),B=P(null),xe=P(null),Re=P(null),Me=P(null),ue=P(null),ne=P(null),Ce=P(null),q=P(null),ve=P(!1),Ze=Zb(),it=J(()=>{if(!O.value&&b.value.length===0)return r.value;let Y=r.value;if(O.value&&(Y=Ze.filter(Y,O.value)),b.value.length>0){const se=new Set(b.value);Y=Bb(Y,se)}return Y}),Nt=J(()=>e.value.find(Y=>Y.isHead)||null);async function sr(Y){x.value=Y,h.value=!0,f.value=null;try{const[se,Xe,Ut,zr,Nr]=await Promise.all([$fetch("/api/git/log",{query:{workingDirectory:Y}}),$fetch("/api/git/status",{query:{workingDirectory:Y}}),$fetch("/api/git/stash",{query:{workingDirectory:Y}}).then(Pn=>Pn.stashes).catch(()=>[]),$fetch("/api/git/remotes",{query:{workingDirectory:Y}}).then(Pn=>Pn.remotes).catch(()=>[]),$fetch("/api/git/state",{query:{workingDirectory:Y}}).then(Pn=>Pn.state).catch(()=>null)]);r.value=se.commits,e.value=se.branches,t.value=se.tags,n.value=new Set(se.localBranches??[]),p.value=se.hasMore,g.value=se.totalCount,s.value=Xe.stagedFiles??[],i.value=Xe.unstagedFiles??[],o.value=(Xe.stagedCount??0)+(Xe.unstagedCount??0),N.value=Ut,I.value=zr,W.value=Nr,V.value=Date.now(),await Ts()}catch(se){const Xe=se instanceof Error?se.message:"Failed to load git graph";f.value=Xe,r.value=[],e.value=[],t.value=[],s.value=[],i.value=[],o.value=0,N.value=[],I.value=[]}finally{h.value=!1}}async function on(){if(x.value)try{const Y=await $fetch("/api/git/status",{query:{workingDirectory:x.value}});s.value=Y.stagedFiles??[],i.value=Y.unstagedFiles??[],o.value=(Y.stagedCount??0)+(Y.unstagedCount??0)}catch(Y){console.error("Failed to refresh uncommitted changes:",Y)}}const xr=P(!1);async function qn(){if(!(!x.value||!p.value||h.value||xr.value)){xr.value=!0;try{const Y=await $fetch("/api/git/log",{query:{workingDirectory:x.value,offset:r.value.length}});r.value=[...r.value,...Y.commits],p.value=Y.hasMore}catch(Y){console.error("Failed to load more commits:",Y)}finally{xr.value=!1}}}async function an(Y){if(l.value=Y,c.value=null,u.value=null,a.value=!1,k.value=!0,!x.value){k.value=!1;return}try{const se=await $fetch("/api/git/show",{query:{workingDirectory:x.value,hash:Y.hash}});c.value=se.files,u.value=se.stats}catch(se){console.error("Failed to load commit details:",se),c.value=[],u.value={additions:0,deletions:0,filesChanged:0},oe("Failed to load commit details")}finally{k.value=!1}}function jn(){l.value=null,c.value=null,u.value=null,a.value=!1}function ln(){l.value=null,u.value=null,c.value=null,a.value=!0}function Sn(Y){O.value=Y,Pe.value=0,Wt()}const Et=J(()=>O.value?Op(r.value,O.value).map(Y=>Y.hash):[]);function Wt(){Fe.value=Et.value.length}function he(){Et.value.length!==0&&(Pe.value=(Pe.value+1)%Et.value.length,Wt(),Be())}function ye(){Et.value.length!==0&&(Pe.value=Pe.value<=0?Et.value.length-1:Pe.value-1,Wt(),Be())}function Be(){const Y=Et.value[Pe.value];if(Y){const se=r.value.find(Xe=>Xe.hash===Y);se&&an(se)}}function Ye(Y){const se=b.value.indexOf(Y);se===-1?b.value.push(Y):b.value.splice(se,1)}function Ue(){O.value="",b.value=[]}async function Ct(Y){if(!x.value)return{success:!1,error:"No working directory set"};Q.value=!0;try{const se=await $fetch("/api/git/checkout",{method:"POST",body:{workingDirectory:x.value,branchName:Y}});return se.success&&await sr(x.value),{success:se.success,error:se.error}}catch(se){const Xe=se instanceof Error?se.message:"Failed to checkout branch";return oe(Xe),{success:!1,error:Xe}}finally{Q.value=!1}}async function ot(Y,se){if(!x.value)return{success:!1,error:"No working directory set"};try{const Xe=await $fetch("/api/git/checkout",{method:"POST",body:{workingDirectory:x.value,branchName:Y,createBranch:!0,fromCommit:se}});return Xe.success&&await sr(x.value),{success:Xe.success,error:Xe.error}}catch(Xe){return{success:!1,error:Xe instanceof Error?Xe.message:"Failed to create branch"}}}async function Ft(Y,se=!1){return j("/api/git/branch",{branchName:Y,force:se},"Failed to delete branch",{method:"DELETE"})}async function ir(Y){return j("/api/git/branch",{branchName:Y,remote:!0},"Failed to delete remote branch",{method:"DELETE"})}async function yr(Y){if(!x.value)return{success:!1,error:"No working directory set"};w.value=!0;try{return await $fetch("/api/git/stage",{method:"POST",body:{workingDirectory:x.value,files:Y}}),await on(),{success:!0}}catch(se){const Xe=se instanceof Error?se.message:"Failed to stage files";return oe(Xe),{success:!1,error:Xe}}finally{w.value=!1}}async function Yn(Y){if(!x.value)return{success:!1,error:"No working directory set"};w.value=!0;try{return await $fetch("/api/git/unstage",{method:"POST",body:{workingDirectory:x.value,files:Y}}),await on(),{success:!0}}catch(se){const Xe=se instanceof Error?se.message:"Failed to unstage files";return oe(Xe),{success:!1,error:Xe}}finally{w.value=!1}}async function Xr(Y){if(!x.value)return{success:!1,error:"No working directory set"};S.value=!0;try{return await $fetch("/api/git/commit",{method:"POST",body:{workingDirectory:x.value,message:Y}}),await sr(x.value),{success:!0}}catch(se){const Xe=se instanceof Error?se.message:"Failed to commit changes";return oe(Xe),{success:!1,error:Xe}}finally{S.value=!1}}async function hi(Y,se){return j("/api/git/branch-rename",{oldName:Y,newName:se},"Failed to rename branch")}async function di(Y,se){return j("/api/git/merge",{branch:Y,...se},"Failed to merge branch")}async function fi(Y){return j("/api/git/rebase",{onto:Y},"Failed to rebase branch")}async function mi(Y,se,Xe,Ut){return j("/api/git/push",{branch:Y,remote:se,force:Xe,forceWithLease:Ut},"Failed to push branch")}async function pi(Y,se,Xe,Ut){return j("/api/git/pull",{branch:Y,remote:se,noFastForward:Xe,squash:Ut},"Failed to pull branch")}async function gi(Y,se,Xe){return j("/api/git/fetch",{branch:Y,remote:se,...Xe},"Failed to fetch")}async function Oi(Y,se,Xe){return j("/api/git/cherry-pick",{hash:Y,recordOrigin:se,noCommit:Xe},"Failed to cherry-pick commit")}async function vi(Y){return j("/api/git/revert",{hash:Y},"Failed to revert commit")}async function bi(Y,se){return j("/api/git/reset",{hash:Y,mode:se},"Failed to reset to commit")}async function xi(Y){if(!x.value)return{success:!1,error:"No working directory set"};try{return await $fetch("/api/git/checkout",{method:"POST",body:{workingDirectory:x.value,branchName:Y}}),await sr(x.value),{success:!0}}catch(se){const Xe=se?.data?.message||se?.statusMessage||se?.message||"Failed to checkout commit";return oe(Xe),{success:!1,error:Xe}}}async function Dt(Y){const se=Y.message.split(`
7
7
  `)[0];return lr(se)}async function or(Y,se,Xe,Ut,zr){return j("/api/git/tag",{name:Y,hash:se,annotated:Xe,message:Ut,pushToRemote:zr},"Failed to create tag")}async function Ss(Y,se){return j("/api/git/tag",{name:Y,deleteFromRemote:se},"Failed to delete tag",{method:"DELETE"})}async function cn(Y,se){return j("/api/git/tag-push",{name:Y,remote:se},"Failed to push tag")}async function $n(Y){if(!x.value)return{success:!1,error:"No working directory set"};try{return{success:!0,data:await $fetch(`/api/git/tag/${encodeURIComponent(Y)}`,{query:{workingDirectory:x.value}})}}catch(se){const Xe=Xo(se,"Failed to get tag detail");return oe(Xe),{success:!1,error:Xe}}}async function $s(Y){return lr(Y)}async function Cn(){if(!x.value)return{success:!1,error:"No working directory set"};try{const Y=await $fetch("/api/git/stash",{query:{workingDirectory:x.value}});return N.value=Y.stashes,{success:!0}}catch(Y){const se=Xo(Y,"Failed to load stashes");return oe(se),{success:!1,error:se}}}async function un(Y,se){return j("/api/git/stash-apply",{index:Y,reinstateIndex:se},"Failed to apply stash")}async function yi(Y,se){return j("/api/git/stash-pop",{index:Y,reinstateIndex:se},"Failed to pop stash")}async function Cs(Y){return j("/api/git/stash-drop",{index:Y},"Failed to drop stash")}async function Qn(Y,se){return j("/api/git/stash-branch",{index:Y,branchName:se},"Failed to create branch from stash")}async function Ot(Y,se){return j("/api/git/stash",{message:Y,includeUntracked:se},"Failed to stash changes")}async function _r(){if(!x.value)return{success:!1,error:"No working directory set"};try{const Y=await $fetch("/api/git/remotes",{query:{workingDirectory:x.value}});return I.value=Y.remotes,{success:!0}}catch(Y){const se=Xo(Y,"Failed to load remotes");return oe(se),{success:!1,error:se}}}async function Fn(Y,se){return j("/api/git/remote",{name:Y,url:se},"Failed to add remote")}async function ki(Y,se){return j("/api/git/remote",{name:Y,newUrl:se},"Failed to edit remote",{method:"PUT"})}async function Un(Y){return j("/api/git/remote",{name:Y},"Failed to delete remote",{method:"DELETE"})}async function Qs(Y,se){return j("/api/git/fetch",{all:!0,prune:Y,pruneTags:se},"Failed to fetch all")}function Ps(){H.value=H.value==="inline"?"bottom":"inline"}function Ir(){re.value=re.value==="list"?"tree":"list"}function ar(Y){Oe.value=Y}function Gn(){ge.value=!ge.value}function wi(Y){$e.value={...$e.value,[Y]:!$e.value[Y]}}async function Vr(Y,se,Xe){if(!se||!x.value){Y.value=null;return}Y.value=await Jy(x.value,se,Xe)}async function Si(Y){T.value=Y,await Vr(M,Y)}async function Hn(Y,se){E.value=Y,xe.value=se??null,await Vr(B,Y,se)}async function Kn(Y,se){Re.value=Y,ue.value=se??null,await Vr(Me,Y,se)}async function Ts(){x.value&&await Promise.all([Vr(M,T.value),Vr(B,E.value,xe.value),Vr(Me,Re.value,ue.value)])}function Ee(Y){const se=r.value.find(Xe=>Xe.hash===Y||Xe.shortHash===Y);se&&an(se)}async function le(Y){return j("/api/git/reset",{hash:"HEAD",mode:Y},"Failed to reset working directory")}async function C(){return j("/api/git/clean",{},"Failed to clean untracked files")}function R(Y){be.value=Y}function _(){be.value=null}function X(Y){K.value=Y}function ce(){K.value=null}const de=P(null),ae=P(null),fe=P(!1),rt=J(()=>!!z.value&&!!l.value);function at(Y){z.value=Y,Y&&l.value&&et()}function qt(){z.value=null,de.value=null,ae.value=null,fe.value=!1}async function et(){if(!(!x.value||!l.value||!z.value)){fe.value=!0;try{const Y=await tk({workingDirectory:x.value,from:z.value.hash,to:l.value.hash});de.value=Y.files,ae.value=Y.stats}catch(Y){console.error("Failed to load comparison:",Y),oe("Failed to load commit comparison"),de.value=null,ae.value=null}finally{fe.value=!1}}}async function lr(Y){try{return await ev(Y),{success:!0}}catch(se){const Xe=se?.message||"Failed to copy to clipboard";return oe(Xe),{success:!1,error:Xe}}}async function Ms(Y,se){ne.value=se,Ce.value=Y,q.value=null,ve.value=!0,await Z1()}function Vh(){ne.value=null,Ce.value=null,q.value=null,ve.value=!1}async function Z1(){if(!x.value||!Ce.value||!ne.value){ve.value=!1;return}ve.value=!0;try{q.value=await ek({workingDirectory:x.value,commitHash:Ce.value,filePath:ne.value.path})}catch(Y){console.error("Failed to load file diff:",Y),oe("Failed to load file diff"),q.value=null}finally{ve.value=!1}}function E1(){r.value=[],e.value=[],t.value=[],n.value=new Set,s.value=[],i.value=[],o.value=0,a.value=!1,l.value=null,c.value=null,u.value=null,h.value=!1,f.value=null,p.value=!1,g.value=0,O.value="",b.value=[],x.value=null,V.value=null,Z.value=!1,U.value=!1,W.value=null,xr.value=!1,k.value=!1,w.value=!1,S.value=!1,Q.value=!1,N.value=[],I.value=[],z.value=null,de.value=null,ae.value=null,fe.value=!1,be.value=null,K.value=null,H.value="inline",re.value="list",Oe.value="rounded",ge.value=!1,$e.value={date:!0,author:!0,commit:!0},Pe.value=0,Fe.value=0,T.value=null,E.value=null,B.value=null,xe.value=null,Re.value=null,Me.value=null,ue.value=null,ne.value=null,Ce.value=null,q.value=null,ve.value=!1,ie(),Ze.clear()}async function D1(){if(!x.value||U.value||h.value)return!1;U.value=!0;try{const Y=(await $fetch("/api/git/state",{query:{workingDirectory:x.value}})).state,se=W.value;if(W.value=Y,V.value=Date.now(),!se)return!1;const Xe=se.headCommit!==Y.headCommit||se.branchListHash!==Y.branchListHash,Ut=se.workingTreeHash!==Y.workingTreeHash,zr=se.stashListHash!==Y.stashListHash;if(Xe){const[Tn,Zo,I1]=await Promise.all([$fetch("/api/git/log",{query:{workingDirectory:x.value}}),$fetch("/api/git/status",{query:{workingDirectory:x.value}}),$fetch("/api/git/stash",{query:{workingDirectory:x.value}}).then(V1=>V1.stashes).catch(()=>[])]);return r.value=Tn.commits,e.value=Tn.branches,t.value=Tn.tags,n.value=new Set(Tn.localBranches??[]),p.value=Tn.hasMore,g.value=Tn.totalCount,s.value=Zo.stagedFiles??[],i.value=Zo.unstagedFiles??[],o.value=(Zo.stagedCount??0)+(Zo.unstagedCount??0),N.value=I1,await Ts(),!0}if(!Ut&&!zr)return!1;const[Nr,Pn]=await Promise.all([Ut?$fetch("/api/git/status",{query:{workingDirectory:x.value}}):Promise.resolve(null),zr?$fetch("/api/git/stash",{query:{workingDirectory:x.value}}).then(Tn=>Tn.stashes).catch(()=>[]):Promise.resolve(null)]);return Nr&&(s.value=Nr.stagedFiles??[],i.value=Nr.unstagedFiles??[],o.value=(Nr.stagedCount??0)+(Nr.unstagedCount??0)),Pn&&(N.value=Pn),!0}catch(Y){return console.error("Failed to refresh git graph:",Y),!1}finally{U.value=!1}}function L1(){Z.value=!0}function X1(){Z.value=!1}return{commits:Ae(r),branches:Ae(e),tags:Ae(t),localBranchNames:Ae(n),stagedFiles:Ae(s),unstagedFiles:Ae(i),uncommittedChangesCount:Ae(o),isUncommittedChangesSelected:Ae(a),selectedCommit:Ae(l),selectedCommitFiles:Ae(c),selectedCommitStats:Ae(u),loading:Ae(h),loadingMore:Ae(xr),error:Ae(f),hasMore:Ae(p),totalCount:Ae(g),searchQuery:Ae(O),filteredBranches:Ae(b),workingDirectory:Ae(x),stashes:Ae(N),remotes:Ae(I),comparisonCommit:Ae(z),comparisonFiles:Ae(de),comparisonStats:Ae(ae),comparisonLoading:Ae(fe),isComparing:rt,activeDialog:Ae(be),activeContextMenu:Ae(K),detailViewPosition:Ae(H),fileViewMode:Ae(re),graphStyle:Ae(Oe),muteNonAncestral:Ae(ge),columnVisibility:Ae($e),searchResultIndex:Ae(Pe),searchResultCount:Ae(Fe),selectedFeatureId:Ae(T),featureMergeBase:Ae(M),conversationBranch:Ae(E),conversationMergeBase:Ae(B),conversationBaseBranch:Ae(xe),previewBranch:Ae(Re),previewMergeBase:Ae(Me),previewBaseBranch:Ae(ue),diffViewerFile:Ae(ne),diffViewerCommitHash:Ae(Ce),diffViewerContent:Ae(q),diffViewerLoading:Ae(ve),lastRefreshTime:Ae(V),isPollingActive:Ae(Z),isRefreshing:Ae(U),isLoadingDetails:Ae(k),isStaging:Ae(w),isCommitting:Ae(S),isCheckingOut:Ae(Q),operationError:Ae(D),filteredCommits:it,currentBranch:Nt,searchResultHashes:Et,loadGitGraph:sr,loadMoreCommits:qn,refreshUncommittedChanges:on,selectCommit:an,selectUncommittedChanges:ln,clearSelection:jn,setSearchQuery:Sn,toggleBranchFilter:Ye,clearFilters:Ue,nextSearchResult:he,prevSearchResult:ye,checkoutBranch:Ct,createBranch:ot,deleteLocalBranch:Ft,deleteRemoteBranch:ir,stageFiles:yr,unstageFiles:Yn,commitChanges:Xr,reset:E1,clearOperationError:ie,renameBranch:hi,mergeBranch:di,rebaseBranch:fi,pushBranch:mi,pullBranch:pi,fetchBranch:gi,cherryPickCommit:Oi,revertCommit:vi,resetToCommit:bi,checkoutCommit:xi,copyCommitSubject:Dt,createTag:or,deleteTag:Ss,pushTag:cn,getTagDetail:$n,copyTagName:$s,loadStashes:Cn,applyStash:un,popStash:yi,dropStash:Cs,stashBranch:Qn,stashChanges:Ot,loadRemotes:_r,addRemote:Fn,editRemote:ki,deleteRemote:Un,fetchAll:Qs,setActiveDialog:R,clearActiveDialog:_,setActiveContextMenu:X,clearActiveContextMenu:ce,selectComparisonCommit:at,clearComparison:qt,loadComparisonData:et,copyToClipboard:lr,toggleDetailViewPosition:Ps,toggleFileViewMode:Ir,setGraphStyle:ar,toggleMuteNonAncestral:Gn,toggleColumnVisibility:wi,navigateToCommit:Ee,resetWorking:le,cleanUntracked:C,setSelectedFeatureId:Si,setConversationBranch:Hn,setPreviewBranch:Kn,openFileDiff:Ms,closeFileDiff:Vh,checkAndRefresh:D1,startPolling:L1,stopPolling:X1}});async function sd(){if(typeof window>"u")return{conversations:[],archivedConversations:[],discardedConversations:0,discardedArchives:0};try{const r=await $fetch("/api/conversations");if(!r||!Array.isArray(r.conversations))return console.warn("[conversationStorage] Invalid data structure from server"),{conversations:[],archivedConversations:[],discardedConversations:0,discardedArchives:0};r.version!==Ma&&console.warn(`[conversationStorage] Storage version mismatch: ${r.version} vs ${Ma}`);const e=r.conversations.map(l=>{if(!l||typeof l!="object")return l;const c=l;return"claudeSessionId"in c&&!("providerSessionId"in c)?{...c,providerSessionId:c.claudeSessionId}:l}),n=(Array.isArray(r.archivedConversations)?r.archivedConversations:[]).map(l=>{if(!l||typeof l!="object")return l;const c=l;return"claudeSessionId"in c&&!("providerSessionId"in c)?{...c,providerSessionId:c.claudeSessionId}:l}),s=e.filter(iv),i=n.filter(ov),o=e.length-s.length,a=n.length-i.length;return o>0&&console.warn(`[conversationStorage] Discarded ${o} corrupted active conversation(s)`),a>0&&console.warn(`[conversationStorage] Discarded ${a} corrupted archive conversation(s)`),{conversations:s,archivedConversations:i,discardedConversations:o,discardedArchives:a}}catch(r){return console.error("[conversationStorage] Failed to load conversations:",r),{conversations:[],archivedConversations:[],discardedConversations:0,discardedArchives:0}}}async function rk(r,e=[]){if(typeof window>"u")return!1;try{return await $fetch("/api/conversations",{method:"POST",body:{version:Ma,conversations:r,archivedConversations:e}}),!0}catch(t){return console.error("Failed to save conversations:",t),!1}}async function nk(r){if(typeof window>"u")return!1;try{return await $fetch("/api/conversations/update",{method:"POST",body:{version:Ma,conversation:r}}),!0}catch(e){return console.error("Failed to save conversation:",e),!1}}function sk(r){return r?r.map(e=>{switch(e.type){case"text":return e.text;case"tool_use":return`[${e.name}] ${e.inputSummary}`;case"tool_result":return e.isError?`Error: ${e.content.slice(0,100)}`:"";case"thinking":case"result_summary":case"session_init":return"";default:return""}}).filter(Boolean).join(`
8
- `):""}function Io(r){r.contentBlocks&&(r.content=sk(r.contentBlocks))}function ik(r,e){if(r.type!==e.type)return!0;switch(e.type){case"text":return r.text!==e.text;case"tool_use":{const t=r;return t.name!==e.name||t.inputSummary!==e.inputSummary}case"tool_result":{const t=r;return t.content!==e.content||t.isError!==e.isError}default:return!1}}function ok(r,e,t="info",n,s=Date.now,i=Math.random){return{id:`conflict-msg-${s()}-${i().toString(36).slice(2,7)}`,role:r,content:e,timestamp:s(),type:t,fileRef:n}}function ak(r,e){return e===0?{message:`All ${r} file${r===1?"":"s"} resolved successfully. Click "Continue Rebase" to proceed.`,succeeded:!0}:{message:`Resolution complete: ${r} succeeded, ${e} failed. You can retry or abort.`,succeeded:!1}}function lk(r,e){const t=[];for(let n=0;n<r.length;n+=e)t.push(r.slice(n,n+e));return t}function ck(r,e){return r.filter(t=>!e.has(t.path))}function uk(r){return`Detected ${r} conflicted file${r===1?"":"s"}. Enter optional guidance below and click "Resolve Conflicts Automatically" to start.`}function hk(r){return`Starting AI resolution for ${r} file${r===1?"":"s"} (parallel)...`}async function dk(r){return $fetch("/api/chat/preview",{method:"POST",body:r})}async function fk(r){return $fetch("/api/chat/preview",{method:"DELETE",body:r})}function mk(r,e){return r===e?{kind:"end-current",id:e}:r?{kind:"swap",endId:r,startId:e}:{kind:"start",id:e}}function pk(r){const e=new Map,t=r.setTimer??setTimeout,n=r.clearTimer??clearTimeout;function s(l){if(e.has(l))return;const c=t(()=>{e.delete(l),r.onFlush(l)},r.delayMs);e.set(l,c)}function i(l){const c=e.get(l);c&&(n(c),e.delete(l)),r.onFlush(l)}function o(l){const c=e.get(l);c&&(n(c),e.delete(l))}function a(){for(const l of e.values())n(l);e.clear()}return{schedule:s,flush:i,cancel:o,cancelAll:a,hasPending:l=>e.has(l),pendingCount:()=>e.size}}async function gk(r){return $fetch("/api/chat/finalize",{method:"POST",body:r})}async function Ok(r){return $fetch("/api/chat/rebase",{method:"POST",body:r})}async function vk(r){return $fetch("/api/rebase/conflicts",{params:{worktreePath:r}})}async function bk(r){return $fetch("/api/rebase/resolve",{method:"PUT",body:r})}async function xk(r){const e=r.mode==="sync"?"/api/rebase/continue-sync":"/api/rebase/continue",{mode:t,...n}=r;return $fetch(e,{method:"POST",body:n})}async function id(r){return $fetch("/api/rebase/abort",{method:"POST",body:{worktreePath:r}})}async function yk(r){return $fetch("/api/rebase/ai-resolve",{method:"POST",body:r})}const vr=Mu("chat",()=>{const r=P(!1),e=P(av),t=P("ask"),n=P(""),s=P([]),i=P([]),o=P(null),a=P("active"),l=P(new Set),c=new Map,u=P(!1),h=P(0),p=pk({delayMs:1200,onFlush:C=>{const R=s.value.find(_=>_.id===C);R&&(R.updatedAt=new Date().toISOString(),nk(R))}}),g=P(null),O=P(null);let b=null;function x(C){return C?c.get(C)??null:null}function k(C){let R=c.get(C);return R||(R={session:null,pendingPermission:null,pendingPlanApproval:null,lastError:null,debugEvents:[]},c.set(C,R)),R}const w=J(()=>s.value.find(C=>C.id===o.value)||null),S=J(()=>w.value?.messages??[]),Q=J(()=>(h.value,x(o.value)?.session??null)),L=J(()=>(h.value,x(o.value)?.pendingPermission??null)),D=J(()=>(h.value,x(o.value)?.pendingPlanApproval??null)),G=J(()=>(h.value,x(o.value)?.lastError??null)),oe=J(()=>(h.value,x(o.value)?.debugEvents??[])),ie=J(()=>Q.value?.status==="streaming"),j=J(()=>w.value?.providerSessionId??""),V=J(()=>S.value.length>0),Z=J(()=>S.value[S.value.length-1]||null);function U(C){return l.value.has(C)}const W=J(()=>o.value?l.value.has(o.value):!1),N=J(()=>s.value.length>0),I=J(()=>i.value.length>0),z=J(()=>s.value.length),be=J(()=>z.value>=Fh),K=J(()=>s.value),H=J(()=>i.value),re=J(()=>g.value&&s.value.find(C=>C.id===g.value)||null);function Oe(C){return g.value===C}function ge(C){a.value=C}async function $e(C){if(!(!C?.previewBranch||!C.worktreePath))try{await Xv({previewBranch:C.previewBranch,worktreePath:C.worktreePath})}catch(R){console.warn("[chat] Failed to sync preview branch after worktree update",{conversationId:C.id,previewBranch:C.previewBranch,worktreePath:C.worktreePath,error:R instanceof Error?R.message:String(R)})}}async function Pe(C){if(U(C))return{success:!1,error:"Cannot archive while this conversation is streaming"};if(s.value.findIndex(_=>_.id===C)===-1)return{success:!1,error:"Conversation not found"};try{const _=await $fetch(`/api/conversations/${C}/archive`,{method:"POST"});return _.success&&_.archived?(p.cancel(C),c.delete(C),s.value=Array.isArray(_.conversations)?_.conversations:s.value.filter(X=>X.id!==C),i.value=Array.isArray(_.archivedConversations)?_.archivedConversations:[_.archived,...i.value],cn(),$n(),g.value===C&&(g.value=null),o.value===C&&(o.value=s.value[0]?.id??null),typeof window<"u"&&$fetch("/api/settings",{method:"POST",body:{activeConversationId:o.value}}).catch(X=>{console.error("Failed to save active conversation:",X)}),{success:!0}):{success:!1,error:"Failed to archive conversation"}}catch(_){return{success:!1,error:_ instanceof Error?_.message:"Failed to archive conversation"}}}async function Fe(C,R){if(Kn().atLimit)return{success:!1,error:`Cannot restore. Active conversations reached ${Uh}.`};if(!i.value.some(X=>X.id===C))return{success:!1,error:"Archived conversation not found"};try{const X=await $fetch(`/api/conversations/archives/${C}/restore`,{method:"POST",body:{baseBranch:R}});return X.success&&X.conversation?(s.value=Array.isArray(X.conversations)?X.conversations:[X.conversation,...s.value],Array.isArray(X.archivedConversations)?i.value=X.archivedConversations:i.value=i.value.filter(ce=>ce.id!==C),a.value="active",Cn(X.conversation.id),cn(),Dt(),{success:!0,conversationId:X.conversation.id}):{success:!1,error:"Failed to restore archived conversation"}}catch(X){return{success:!1,error:X instanceof Error?X.message:"Failed to restore archived conversation"}}}async function T(C){const R=i.value.findIndex(_=>_.id===C);if(R===-1)return{success:!1,error:"Archived conversation not found"};try{return await $fetch(`/api/conversations/archives/${C}`,{method:"DELETE"}),i.value.splice(R,1),$n(),{success:!0}}catch{return i.value.splice(R,1),Dt(),{success:!0}}}async function M(){if(!(typeof window>"u"))try{const C=await $fetch("/api/settings");if(C){if(typeof C.panelWidth=="number"){const X=C.panelWidth;X>=Gh&&X<=Hh&&(e.value=X)}typeof C.isPanelOpen=="boolean"&&(r.value=C.isPanelOpen),typeof C.activeConversationId=="string"&&(o.value=C.activeConversationId);const{useSettingsStore:R}=await ds(async()=>{const{useSettingsStore:X}=await import("./Bq8BNs4s.js").then(ce=>ce.s);return{useSettingsStore:X}},__vite__mapDeps([0,1,2]),import.meta.url),_=R();await _.hydrate(),t.value=_.permissionMode}}catch(C){console.error("Failed to load chat settings:",C)}}function E(C){t.value=C,typeof window<"u"&&ds(async()=>{const{useSettingsStore:R}=await import("./Bq8BNs4s.js").then(_=>_.s);return{useSettingsStore:R}},__vite__mapDeps([0,1,2]),import.meta.url).then(({useSettingsStore:R})=>{R().setPermissionMode(C)})}function B(C,R){const _=R??o.value;if(!_)return;const X=k(_);X.pendingPermission=C,h.value++}function xe(C){const R=C??o.value;if(!R)return;const _=c.get(R);_&&(_.pendingPermission=null,h.value++)}function Re(C,R){const _=R??o.value;if(!_)return;const X=k(_);X.pendingPlanApproval=C,h.value++}function Me(C){const R=C??o.value;if(!R)return;const _=c.get(R);_&&(_.pendingPlanApproval=null,h.value++)}function ue(){r.value=!r.value,q()}function ne(){r.value=!0,q()}function Ce(){r.value=!1,q()}function q(){typeof window<"u"&&$fetch("/api/settings",{method:"POST",body:{isPanelOpen:r.value}}).catch(C=>{console.error("Failed to save panel state:",C)})}function ve(C){const R=Math.max(Gh,Math.min(Hh,C));e.value=R,typeof window<"u"&&$fetch("/api/settings",{method:"POST",body:{panelWidth:R}}).catch(_=>{console.error("Failed to save panel width:",_)})}function Ze(C){n.value=C}function it(C,R){const _=R??o.value;if(!_)return;const X=s.value.find(ce=>ce.id===_);X&&(X.providerSessionId=C)}function Nt(C,R){const _=s.value.find(X=>X.id===C);_&&(_.worktreeBranch=R,_.lastCommitTime=new Date().toISOString())}async function sr(C){const R=s.value.find(X=>X.id===C);if(!R?.worktreeBranch)return null;const _=R.worktreeBranch.trim();if(!_)return null;try{const ce=(await $fetch("/api/specs/features")).features.find(de=>de.id===_);return ce?(R.featureId!==ce.id&&(R.featureId=ce.id,R.updatedAt=new Date().toISOString(),Dt()),ce.id):null}catch(X){return console.warn("[chat] Failed to map branch to feature",{conversationId:C,branchName:_,error:X instanceof Error?X.message:String(X)}),null}}function on(C,R,_){const X=s.value.find(ce=>ce.id===C);X&&(X.providerId=R,X.providerModelKey=_)}function xr(C){const R=C??o.value;if(!R)return;const _=s.value.find(X=>X.id===R);_&&(_.providerSessionId="")}function qn(C){return s.value.find(_=>_.id===C)?.providerSessionId??""}function an(C){l.value.add(C)}function jn(C){l.value.delete(C)}function ln(C,R){const _=R??o.value;if(!_)return;const X=s.value.find(ce=>ce.id===_);X&&X.messages.push(C)}function Sn(C,R,_){const X={id:Kh(),role:"user",content:C,attachments:_&&_.length>0?_:void 0,timestamp:new Date().toISOString()};return ln(X,R),X}function Et(C){const R={id:Kh(),role:"assistant",content:"",timestamp:new Date().toISOString(),status:"streaming"};return ln(R,C),R}function Wt(C,R,_){const X=_??o.value;if(!X)return;const ce=s.value.find(ae=>ae.id===X);if(!ce)return;const de=ce.messages.findIndex(ae=>ae.id===C);de!==-1&&(ce.messages[de]={...ce.messages[de],...R})}function he(C,R){const _=s.value.find(ce=>ce.id===R);if(!_)return;const X=_.messages.findIndex(ce=>ce.id===C);X!==-1&&(_.messages[X]={..._.messages[X],content:"",status:"streaming",contentBlocks:[]})}function ye(C,R,_){const X=_??o.value;if(!X)return;const ce=s.value.find(ae=>ae.id===X);if(!ce)return;const de=ce.messages.findIndex(ae=>ae.id===C);de!==-1&&(ce.messages[de].content+=R)}function Be(C,R,_){const X=_??o.value;if(!X)return;const ce=s.value.find(ae=>ae.id===X);if(!ce)return;const de=ce.messages.findIndex(ae=>ae.id===C);if(de!==-1){const ae=ce.messages[de],fe=ae.tools?[...ae.tools,R]:[R];ce.messages[de]={...ae,tools:fe}}}function Ye(C,R,_,X){const ce=X??o.value;if(!ce)return;const de=s.value.find(fe=>fe.id===ce);if(!de)return;const ae=de.messages.findIndex(fe=>fe.id===C);if(ae!==-1){const fe=de.messages[ae];if(fe.tools){const rt=fe.tools.findIndex(at=>at.id===R);if(rt!==-1){const at=[...fe.tools];at[rt]={...at[rt],..._},de.messages[ae]={...fe,tools:at}}}}or(ce,!1)}function Ue(C,R){const _=R??o.value;if(!_)return;const X=s.value.find(de=>de.id===_);if(!X)return;const ce=X.messages.find(de=>de.id===C);ce&&!ce.contentBlocks&&(ce.contentBlocks=[])}function Ct(C,R,_){const X=_??o.value;if(!X)return;const ce=s.value.find(ae=>ae.id===X);if(!ce)return;const de=ce.messages.find(ae=>ae.id===C);de&&(de.contentBlocks||(de.contentBlocks=[]),de.contentBlocks.push(R),Io(de))}function ot(C,R,_,X){const ce=X??o.value;if(!ce)return;const de=s.value.find(qt=>qt.id===ce);if(!de)return;const ae=de.messages.find(qt=>qt.id===C);if(!ae?.contentBlocks)return;const fe=ae.contentBlocks.findIndex(qt=>qt.id===R);if(fe===-1)return;const at={...ae.contentBlocks[fe]};_(at),ae.contentBlocks[fe]=at}function Ft(C,R,_,X,ce){const de=X??o.value;if(!de)return;const ae=s.value.find(lr=>lr.id===de);if(!ae)return;const fe=ae.messages.find(lr=>lr.id===C);if(!fe?.contentBlocks)return;const rt=fe.contentBlocks.findIndex(lr=>lr.id===R);if(rt===-1)return;const at=fe.contentBlocks[rt],qt={...at};_(qt),fe.contentBlocks[rt]=qt,ce?.syncContent!==!1&&ik(at,qt)&&Io(fe),or(de,!1)}function ir(C,R,_){const X=_??o.value;if(!X)return;const ce=s.value.find(ae=>ae.id===X);if(!ce)return;const de=ce.messages.find(ae=>ae.id===C);de&&(de.contentBlocks||(de.contentBlocks=[]),de.contentBlocks.push(R),Io(de),or(X,!1))}function yr(C,R,_){const X=_??o.value;if(!X)return null;const ce=s.value.find(ae=>ae.id===X);if(!ce)return null;const de=ce.messages.find(ae=>ae.id===C);return de?.contentBlocks?de.contentBlocks.find(ae=>ae.type==="tool_use"&&ae.toolUseId===R)??null:null}function Yn(C,R,_,X,ce){const de=s.value.find(fe=>fe.id===ce);if(!de)return;const ae=de.messages.findIndex(fe=>fe.id===C);ae!==-1&&(de.messages[ae]={...de.messages[ae],content:_,contentBlocks:R,status:X},or(ce,!0))}function Xr(C,R){const _=R??o.value;if(!_)return;const X=c.get(_);X?.session&&(X.session.status=C,h.value++)}function hi(C,R){const _=R??o.value;if(!_)return;const X=k(_);X.session={sessionId:C,cwd:n.value,status:"streaming",startedAt:new Date().toISOString()},X.lastError=null,h.value++}function di(C){const R=C??o.value;if(!R)return;const _=c.get(R);_?.session&&(_.session.status="idle",h.value++)}function fi(C,R){const _=R??o.value;if(!_)return;const X=k(_);X.session&&(X.session.status="error",X.session.error=C),X.lastError=C,h.value++}function mi(C,R){if(!u.value)return;const _=R??o.value;if(!_)return;const X=k(_),ce=(()=>{if(typeof C.payload=="string")return C.payload;try{return JSON.stringify(C.payload,null,2)}catch{return String(C.payload)}})(),de=8e3,ae=300,fe=ce.length>de?`${ce.slice(0,de)}
9
- ... (truncated)`:ce;X.debugEvents.push({id:`dbg-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,timestamp:new Date().toISOString(),direction:C.direction,channel:C.channel,eventType:C.eventType||"unknown",payload:fe}),X.debugEvents.length>ae&&X.debugEvents.splice(0,X.debugEvents.length-ae),h.value++}function pi(C){u.value=C}function gi(C){const R=C??o.value;if(!R)return;const _=c.get(R);_&&(_.debugEvents=[],h.value++)}function Oi(){if(!o.value)return;const C=s.value.find(_=>_.id===o.value);C&&(C.messages=[]);const R=o.value;c.delete(R),h.value++}function vi(C){const R=C??o.value;if(!R)return;const _=c.get(R);_&&(_.lastError=null,_.session&&(_.session.error=void 0),h.value++)}async function bi(){const C=await sd();if(s.value=C.conversations,i.value=C.archivedConversations,C.discardedArchives>0&&console.warn(`[chat] Skipped ${C.discardedArchives} corrupted archived conversation(s)`),cn(),$n(),!g.value){const R=s.value.find(_=>!!_.previewBranch&&!_.finalized);R&&(g.value=R.id)}if(o.value){const R=s.value.find(_=>_.id===o.value);R&&R.cwd?n.value=R.cwd:R||(o.value=null,r.value=!1)}}async function xi(){const C=await sd(),R=new Map(s.value.map(ae=>[ae.id,ae])),_=new Set(C.conversations.map(ae=>ae.id));let X=0,ce=0,de=0;for(const ae of C.conversations){const fe=R.get(ae.id);if(!fe)s.value.push(ae),R.set(ae.id,ae),X++,console.log(`[chat] refresh: added new conversation ${ae.id} (source=${ae.source}, msgs=${ae.messages.length})`);else if(ae.source!=="user"&&(ae.messages.length>fe.messages.length||ae.updatedAt>(fe.updatedAt||""))){const rt=s.value.findIndex(at=>at.id===ae.id);rt!==-1&&(s.value.splice(rt,1,ae),console.log(`[chat] refresh: updated conversation ${ae.id} (msgs: ${fe.messages.length} → ${ae.messages.length}, updatedAt: ${fe.updatedAt} → ${ae.updatedAt})`)),ce++}else fe&&ae.messages.length!==fe.messages.length&&console.log(`[chat] refresh: skipped update for ${ae.id} (source=${ae.source}, server msgs=${ae.messages.length}, local msgs=${fe.messages.length})`)}for(let ae=s.value.length-1;ae>=0;ae--){const fe=s.value[ae];!_.has(fe.id)&&!l.value.has(fe.id)&&(console.log(`[chat] refresh: removed conversation ${fe.id} (no longer on server)`),o.value===fe.id&&(o.value=null),s.value.splice(ae,1),de++)}return C.archivedConversations&&(i.value=C.archivedConversations),(X>0||ce>0||de>0)&&cn(),console.log(`[chat] refreshServerConversations: loaded=${C.conversations.length}, added=${X}, updated=${ce}, removed=${de}`),X+ce+de}function Dt(){rk(s.value,i.value)}function or(C,R=!1){s.value.find(X=>X.id===C)&&(R?p.flush(C):p.schedule(C))}function Ss(C=!1){o.value&&or(o.value,C)}function cn(){s.value.sort((C,R)=>new Date(R.createdAt).getTime()-new Date(C.createdAt).getTime())}function $n(){i.value.sort((C,R)=>new Date(R.archivedAt).getTime()-new Date(C.archivedAt).getTime())}async function $s(C){if(Kn().atLimit)return"";const _=lv();let X=null;if(C?.featureId){const fe=await ed({conversationId:_,featureId:C.featureId,baseBranch:C.baseBranch});if(!fe.success&&fe.error)throw new Error(fe.error);X=fe}let ce=null;if(typeof window<"u")try{const{useSettingsStore:fe}=await ds(async()=>{const{useSettingsStore:at}=await import("./Bq8BNs4s.js").then(qt=>qt.s);return{useSettingsStore:at}},__vite__mapDeps([0,1,2]),import.meta.url),rt=fe();await rt.hydrate(),ce=rt.providerSelection}catch(fe){console.warn("[chat] Failed to load provider selection for new conversation",fe)}const de=ce||{providerId:tp,modelKey:ep},ae={id:_,title:"New Conversation",messages:[],createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),cwd:n.value||process.cwd?.()||"",source:C?.featureId?"cascade":"user",featureId:C?.featureId,providerId:de.providerId,providerModelKey:de.modelKey};if(X?.success&&X.worktreePath&&X.branch&&(ae.worktreePath=X.worktreePath,ae.worktreeBranch=X.branch,ae.cwd=X.worktreePath,ae.hasWorktree=!0,X.baseBranch&&(ae.baseBranch=X.baseBranch)),s.value.unshift(ae),o.value=_,typeof window<"u"&&$fetch("/api/settings",{method:"POST",body:{activeConversationId:_}}).catch(fe=>{console.error("Failed to save active conversation:",fe)}),!C?.featureId)try{const fe=await ed({conversationId:_,baseBranch:C?.baseBranch});if(fe.success&&fe.worktreePath&&fe.branch){const rt=s.value.find(at=>at.id===_);rt&&(rt.worktreePath=fe.worktreePath,rt.worktreeBranch=fe.branch,rt.cwd=fe.worktreePath,rt.hasWorktree=!0,fe.baseBranch&&(rt.baseBranch=fe.baseBranch))}}catch(fe){console.warn("[chat] Failed to create worktree for conversation",_,fe)}return or(_,!0),_}function Cn(C){const R=s.value.find(_=>_.id===C);R&&(o.value=C,r.value=!0,R.cwd&&(n.value=R.cwd),!R.featureId&&R.worktreeBranch&&sr(C),typeof window<"u"&&$fetch("/api/settings",{method:"POST",body:{activeConversationId:C,isPanelOpen:!0}}).catch(_=>{console.error("Failed to save active conversation:",_)}))}async function un(C){const R=s.value.findIndex(X=>X.id===C);if(R===-1)return;const _=s.value[R];if(g.value===C&&(g.value=null),_.hasWorktree&&_.worktreePath&&_.worktreeBranch)try{await Lv({worktreePath:_.worktreePath,branch:_.worktreeBranch})}catch(X){console.warn("[chat] Failed to clean up worktree for conversation",C,X)}s.value.splice(R,1),c.delete(C),p.cancel(C),o.value===C&&(o.value=null,typeof window<"u"&&$fetch("/api/settings",{method:"POST",body:{activeConversationId:null}}).catch(X=>{console.error("Failed to clear active conversation:",X)})),Dt()}async function yi(C,R,_){const X=s.value.find(de=>de.id===C);if(!X)return{success:!1,error:"Conversation not found"};if(!X.hasWorktree)return{success:!1,error:"No worktree associated with this conversation"};const ce=_||X.baseBranch;try{const de=await gk({conversationId:C,commitMessage:R,baseBranch:ce,worktreePath:X.worktreePath,worktreeBranch:X.worktreeBranch,previewBranch:X.previewBranch});return de.success?(g.value===C&&(g.value=null),X.worktreePath=void 0,X.worktreeBranch=void 0,X.hasWorktree=!1,X.baseBranch=void 0,X.previewBranch=void 0,X.finalized=!0,X.updatedAt=new Date().toISOString(),Dt()):de.rebaseInProgress&&await Qn(C,X.worktreePath,ce||"main",R),de}catch(de){return{success:!1,error:de instanceof Error?de.message:String(de)}}}async function Cs(C,R){const _=s.value.find(ce=>ce.id===C);if(!_)return{success:!1,error:"Conversation not found"};if(!_.hasWorktree)return{success:!1,error:"No worktree associated with this conversation"};const X=R||_.baseBranch;try{const ce=await Ok({conversationId:C,baseBranch:X,worktreePath:_.worktreePath});return ce.rebaseInProgress?await Qn(C,_.worktreePath,X||"main","","sync"):ce.success&&(await $e(_),_.baseBranch=X,Dt()),ce}catch(ce){return{success:!1,error:ce instanceof Error?ce.message:String(ce)}}}async function Qn(C,R,_,X,ce="finalize"){O.value={conversationId:C,worktreePath:R,baseBranch:_,commitMessage:X,files:[],resolvedFiles:new Set,loading:!0,error:null,mode:ce,retryCount:0,strategy:"auto",chatMessages:[],userGuidance:"",lifecycleState:"detected"};try{const de=await vk(R);O.value&&(O.value.files=de.files,O.value.loading=!1,Ot("system",uk(de.files.length),"info"))}catch(de){O.value&&(O.value.error=de instanceof Error?de.message:String(de),O.value.loading=!1)}}function Ot(C,R,_="info",X){O.value&&O.value.chatMessages.push(ok(C,R,_,X))}function _r(C){O.value&&(O.value.userGuidance=C)}async function Fn(C,R){if(!O.value)return!1;try{const _=await bk({worktreePath:O.value.worktreePath,filePath:C,content:R});return _.success&&O.value&&O.value.resolvedFiles.add(C),_.success}catch{return!1}}async function ki(){if(!O.value)return{success:!1,error:"No conflict resolution in progress"};const{conversationId:C,commitMessage:R,baseBranch:_,mode:X,worktreePath:ce}=O.value;try{const de=s.value.find(fe=>fe.id===C),ae=await xk({mode:X,conversationId:C,commitMessage:R,baseBranch:_,worktreePath:ce,worktreeBranch:de?.worktreeBranch,previewBranch:de?.previewBranch});if(ae.success){if(X==="finalize"){g.value===C&&(g.value=null);const fe=s.value.find(rt=>rt.id===C);fe&&(fe.worktreePath=void 0,fe.worktreeBranch=void 0,fe.hasWorktree=!1,fe.baseBranch=void 0,fe.previewBranch=void 0,fe.finalized=!0,fe.updatedAt=new Date().toISOString(),Dt())}else if(X==="sync"){const fe=s.value.find(rt=>rt.id===C);fe&&(await $e(fe),fe.baseBranch=_,fe.updatedAt=new Date().toISOString(),Dt())}O.value=null}else ae.rebaseInProgress&&await Qn(C,ce,_,R,X);return ae}catch(de){return{success:!1,error:de instanceof Error?de.message:String(de)}}}async function Un(){if(!O.value)return!1;try{const C=await id(O.value.worktreePath);return O.value=null,C.success}catch{return O.value=null,!1}}async function Qs(C){if(!O.value)return!1;const R=O.value.files.find(_=>_.path===C);if(!R)return!1;try{const _=await yk({worktreePath:O.value.worktreePath,filePath:C,conflictContent:R.content,userGuidance:O.value.userGuidance||void 0});if(_.success&&_.resolvedContent!==void 0){R.content=_.resolvedContent;const X=await Fn(C,_.resolvedContent);return X?Ot("assistant",`Resolved: ${C}`,"success",C):Ot("assistant",`Failed to write resolved content for ${C}`,"error",C),X}return Ot("assistant",`Failed to resolve ${C}: ${_.error||"Unknown error"}`,"error",C),!1}catch(_){const X=_ instanceof Error?_.message:String(_);return Ot("assistant",`Error resolving ${C}: ${X}`,"error",C),!1}}async function Ps(){if(!O.value)return;const C=ck(O.value.files,O.value.resolvedFiles);if(C.length===0){Ot("system","All files are already resolved.","info");return}b=new AbortController;const R=b.signal;O.value.lifecycleState="resolving";const _=O.value.userGuidance;_&&Ot("user",_),Ot("system",hk(C.length),"info");let X=0,ce=0;const de=lk(C,3);for(const fe of de){if(!O.value||R.aborted)break;for(const at of fe)Ot("assistant",`Resolving: ${at.path}...`,"progress",at.path);const rt=await Promise.all(fe.map(at=>Qs(at.path)));for(const at of rt)at?X++:ce++}if(b=null,!O.value||R.aborted)return;const ae=ak(X,ce);O.value.lifecycleState=ae.succeeded?"resolved":"failed",Ot("system",ae.message,"summary")}async function Ir(){if(!O.value)return;b&&(b.abort(),b=null);const{conversationId:C,worktreePath:R,baseBranch:_,commitMessage:X,mode:ce}=O.value;Ot("system","Resolution cancelled. Resetting conflict state...","info");try{await id(R)}catch{}O.value=null,Ot("system","Conflict resolution aborted and reset.","info")}async function ar(C){const R=s.value.find(_=>_.id===C);if(!R)return{success:!1,error:"Conversation not found"};if(!R.hasWorktree||!R.worktreePath||!R.baseBranch)return{success:!1,error:"No worktree to preview"};try{const _=await dk({conversationId:C,worktreePath:R.worktreePath,baseBranch:R.baseBranch});return _.success&&_.previewBranch&&(R.previewBranch=_.previewBranch,g.value=C,R.updatedAt=new Date().toISOString(),Dt()),{success:_.success,error:_.error}}catch(_){return{success:!1,error:_ instanceof Error?_.message:String(_)}}}async function Gn(C){const R=s.value.find(_=>_.id===C);if(!R)return{success:!1,error:"Conversation not found"};if(!R.previewBranch||!R.baseBranch)return g.value=null,{success:!1,error:"No active preview"};try{const _=await fk({previewBranch:R.previewBranch,baseBranch:R.baseBranch});return _.success&&(R.previewBranch=void 0,g.value=null,R.updatedAt=new Date().toISOString(),Dt()),{success:_.success,error:_.error}}catch(_){return{success:!1,error:_ instanceof Error?_.message:String(_)}}}async function wi(C){const R=mk(g.value,C);if(R.kind==="end-current")return await Gn(R.id);if(R.kind==="swap"){const _=await Gn(R.endId);return _.success?await ar(R.startId):{success:!1,error:`Failed to end previous preview: ${_.error}`}}return await ar(R.id)}function Vr(C){const R=C.trim();if(!R)return null;const _=s.value.filter(X=>X.featureId===R?!0:X.worktreeBranch?.trim()===R);return _.length===0?null:_.sort((X,ce)=>new Date(ce.updatedAt).getTime()-new Date(X.updatedAt).getTime())[0]||null}function Si(C,R){const _=s.value.find(X=>X.id===C);_&&(_.title=R.trim(),_.updatedAt=new Date().toISOString(),cn(),Dt())}function Hn(C){const R=o.value;if(!R)return;const _=s.value.find(ce=>ce.id===R);if(!_||_.title!=="New Conversation")return;const X=_.messages.find(ce=>ce.role==="user");X&&(X.content.trim().length>0?_.title=cv(X.content):X.attachments&&X.attachments.length>0&&(_.title=X.attachments.length===1?"[Image] New Conversation":`[${X.attachments.length} Images] New Conversation`))}function Kn(){const C=s.value.length;return{atLimit:C>=Uh,nearLimit:C>=Fh,count:C}}async function Ts(C,R){o.value||await $s();const _=Sn(C,void 0,R);return Hn(),Ss(!0),_}function Ee(C,R,_){const X=_??o.value;ye(C,R,X??void 0),X&&or(X,!1)}function le(C,R){const _=R??o.value;Wt(C,{status:"complete"},_??void 0),_&&or(_,!0)}return{messages:S,session:Q,isPanelOpen:r,panelWidth:Ae(e),permissionMode:Ae(t),pendingPermission:L,pendingPlanApproval:D,cwd:Ae(n),lastError:G,debugEvents:oe,debugStreamEnabled:Ae(u),providerSessionId:j,conversations:Ae(s),archivedConversations:Ae(i),activeConversationId:Ae(o),conversationViewMode:Ae(a),conflictState:Ae(O),previewingConversationId:Ae(g),isStreaming:ie,hasMessages:V,lastMessage:Z,isActiveConversationStreaming:W,hasConversations:N,hasArchivedConversations:I,activeConversation:w,conversationCount:z,isNearStorageLimit:be,sortedConversations:K,sortedArchivedConversations:H,previewingConversation:re,streamingConversations:Ae(l),initialize:M,togglePanel:ue,openPanel:ne,closePanel:Ce,setPanelWidth:ve,setPermissionMode:E,setPendingPermission:B,clearPendingPermission:xe,setPendingPlanApproval:Re,clearPendingPlanApproval:Me,setCwd:Ze,setProviderSessionId:it,clearProviderSession:xr,getProviderSessionId:qn,updateWorktreeBranch:Nt,setConversationProviderSelection:on,startConversationStreaming:an,endConversationStreaming:jn,isConversationStreaming:U,addMessage:ln,addUserMessage:Sn,addAssistantMessage:Et,updateMessage:Wt,resetMessageForReplay:he,appendToMessage:ye,addToolToMessage:Be,updateToolInMessage:Ye,initContentBlocks:Ue,appendContentBlock:Ct,appendContentBlockWithSave:ir,updateBlockById:ot,updateBlockWithSave:Ft,findToolUseBlock:yr,batchSetMessageBlocks:Yn,syncContentFromBlocks:Io,setSessionStatus:Xr,startSession:hi,endSession:di,setSessionError:fi,setDebugStreamEnabled:pi,pushDebugEvent:mi,clearDebugEvents:gi,clearMessages:Oi,clearError:vi,loadConversations:bi,refreshServerConversations:xi,saveAllConversations:Dt,saveCurrentConversation:Ss,saveConversation:or,createConversation:$s,selectConversation:Cn,deleteConversation:un,archiveConversation:Pe,restoreArchivedConversation:Fe,deleteArchivedConversation:T,setConversationViewMode:ge,findConversationByFeature:Vr,syncConversationFeatureFromBranch:sr,renameConversation:Si,checkStorageLimits:Kn,finalizeConversation:yi,rebaseConversation:Cs,resolveConflictFile:Fn,continueRebase:ki,abortRebase:Un,aiResolveConflictFile:Qs,aiResolveAllConflicts:Ps,addConflictChatMessage:Ot,setConflictUserGuidance:_r,cancelConflictResolution:Ir,previewConversation:ar,unpreviewConversation:Gn,togglePreview:wi,isConversationPreviewing:Oe,addUserMessageWithConversation:Ts,appendToMessageWithSave:Ee,completeMessageWithSave:le}});function kk(r={}){const e=ml(),t=300,n=5e3,s=250;let i=null,o=null,a=null,l=null,c=null,u=!1,h=!1;const f=P(!1),p=P(!1);let g=r;function O(V){g=V}async function b(){const V=g.getScrollPosition?.()??0,Z=await e.checkAndRefresh();return Z&&g.setScrollPosition&&(await It(),g.setScrollPosition(V)),Z}function x(){return f.value||!!e.activeContextMenu||!!e.activeDialog}async function k(){if(x()){p.value=!0;return}S()}async function w(){if(u){h=!0;return}u=!0;try{await b()}finally{u=!1,h&&(h=!1,S())}}function S(){o&&clearTimeout(o),o=setTimeout(()=>{o=null,w()},s)}function Q(V){if(typeof window>"u")return;if(a&&a.readyState===WebSocket.OPEN){a.send(JSON.stringify({type:"watch",workingDirectory:V}));return}l&&(clearTimeout(l),l=null);const U=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/git-watcher-ws`;a=new WebSocket(U),a.onopen=()=>{a.send(JSON.stringify({type:"watch",workingDirectory:V}))},a.onmessage=W=>{try{JSON.parse(W.data).type==="git_changed"&&k()}catch{}},a.onclose=()=>{a=null,e.isPollingActive&&c&&(l=setTimeout(()=>{c&&Q(c)},n))},a.onerror=()=>{}}function L(){l&&(clearTimeout(l),l=null),a&&(a.close(),a=null)}function D(V){V&&(c=V),!e.isPollingActive&&(e.startPolling(),c&&Q(c))}function G(){L(),e.stopPolling()}function oe(){f.value=!0,i&&(clearTimeout(i),i=null)}function ie(){i&&clearTimeout(i),i=setTimeout(async()=>{f.value=!1,p.value&&(p.value=!1,S())},t)}function j(){G(),i&&(clearTimeout(i),i=null),o&&(clearTimeout(o),o=null),u=!1,h=!1,c=null}return ze(()=>[e.activeContextMenu,e.activeDialog],()=>{!e.activeContextMenu&&!e.activeDialog&&p.value&&!f.value&&(p.value=!1,S())}),{isUserInteracting:Ae(f),isDeferredRefresh:Ae(p),startPolling:D,stopPolling:G,startInteraction:oe,endInteraction:ie,cleanup:j,setScrollCallbacks:O}}function wk(r){function e(s){if((s.ctrlKey||s.metaKey)&&s.key==="h"){s.preventDefault(),r.onScrollToHead();return}if(s.key==="Escape"){s.preventDefault(),r.onEscape();return}}function t(){document.addEventListener("keydown",e)}function n(){document.removeEventListener("keydown",e)}return{start:t,stop:n}}function Sk(r){const e=P({visible:!1,branchName:"",loading:!1,error:null});async function t(){e.value.loading=!0,e.value.error=null;const K=await r.checkoutBranch(e.value.branchName);e.value.loading=!1,K.success?e.value.visible=!1:e.value.error=K.error||"Unknown error"}const n=P({visible:!1,fromCommit:"",loading:!1,error:null});async function s(K){n.value.loading=!0,n.value.error=null;const H=await r.createBranch(K.name,n.value.fromCommit);n.value.loading=!1,H.success?(K.checkout&&await r.checkoutBranch(K.name),n.value.visible=!1):n.value.error=H.error||"Unknown error"}const i=P({visible:!1,branchName:"",isLocal:!0,force:!1,loading:!1,error:null});async function o(K){i.value.loading=!0,i.value.error=null;const{branchName:H,isLocal:re}=i.value,Oe=K?.force??i.value.force,ge=re?await r.deleteLocalBranch(H,Oe):await r.deleteRemoteBranch(H);i.value.loading=!1,ge.success?i.value.visible=!1:i.value.error=ge.error||"Unknown error"}const a=P({visible:!1,branchName:"",newName:"",loading:!1,error:null});async function l(){if(!a.value.newName.trim()){a.value.error="Branch name is required";return}a.value.loading=!0,a.value.error=null;const K=await r.renameBranch(a.value.branchName,a.value.newName.trim());a.value.loading=!1,K.success?a.value.visible=!1:a.value.error=K.error||"Unknown error"}const c=P({visible:!1,branchName:"",loading:!1,error:null});async function u(K){c.value.loading=!0,c.value.error=null;const H=await r.mergeBranch(c.value.branchName,K);c.value.loading=!1,H.success?c.value.visible=!1:c.value.error=H.error||"Unknown error"}const h=P({visible:!1,branchName:"",loading:!1,error:null});async function f(){h.value.loading=!0,h.value.error=null;const K=await r.rebaseBranch(h.value.branchName);h.value.loading=!1,K.success?h.value.visible=!1:h.value.error=K.error||"Unknown error"}const p=P({visible:!1,branchName:"",loading:!1,error:null});async function g(K){p.value.loading=!0,p.value.error=null;const H=await r.pushBranch(p.value.branchName,K.remote,K.force,K.forceWithLease);p.value.loading=!1,H.success?p.value.visible=!1:p.value.error=H.error||"Unknown error"}const O=P({visible:!1,branchName:"",loading:!1,error:null});async function b(K){O.value.loading=!0,O.value.error=null;const H=await r.pullBranch(O.value.branchName,K.remote,K.noFastForward,K.squash);O.value.loading=!1,H.success?O.value.visible=!1:O.value.error=H.error||"Unknown error"}const x=P({visible:!1,commitHash:"",commitMessage:"",loading:!1,error:null});async function k(K){x.value.loading=!0,x.value.error=null;const H=await r.cherryPickCommit(x.value.commitHash,K.recordOrigin,K.noCommit);x.value.loading=!1,H.success?x.value.visible=!1:x.value.error=H.error||"Unknown error"}const w=P({visible:!1,commitHash:"",commitMessage:"",loading:!1,error:null});async function S(K){w.value.loading=!0,w.value.error=null;const H=await r.resetToCommit(w.value.commitHash,K.mode);w.value.loading=!1,H.success?w.value.visible=!1:w.value.error=H.error||"Unknown error"}const Q=P({visible:!1,commitHash:"",loading:!1,error:null});async function L(K){Q.value.loading=!0,Q.value.error=null;const H=await r.createTag(K.name,Q.value.commitHash,K.annotated,K.message,K.pushToRemote);Q.value.loading=!1,H.success?Q.value.visible=!1:Q.value.error=H.error||"Unknown error"}const D=P({visible:!1,tagName:"",loading:!1,error:null});async function G(K){D.value.loading=!0,D.value.error=null;const H=await r.deleteTag(D.value.tagName,K.deleteFromRemote?K.remote||"origin":void 0);D.value.loading=!1,H.success?D.value.visible=!1:D.value.error=H.error||"Unknown error"}const oe=P({visible:!1,tagName:"",loading:!1,tagDetail:null}),ie=P({visible:!1,loading:!1,error:null});async function j(K){ie.value.loading=!0,ie.value.error=null;const H=await r.stashChanges(K.message,K.includeUntracked);ie.value.loading=!1,H.success?ie.value.visible=!1:ie.value.error=H.error||"Unknown error"}const V=P({visible:!1,stashIndex:0,loading:!1,error:null}),Z=P("");async function U(K){V.value.loading=!0,V.value.error=null;const H=await r.stashBranch(V.value.stashIndex,K);V.value.loading=!1,H.success?V.value.visible=!1:V.value.error=H.error||"Unknown error"}const W=P({visible:!1,loading:!1,error:null});async function N(K){W.value.loading=!0,W.value.error=null;const H=await r.resetWorking(K.mode);W.value.loading=!1,H.success?W.value.visible=!1:W.value.error=H.error||"Unknown error"}const I=P({visible:!1,loading:!1,error:null});async function z(){I.value.loading=!0,I.value.error=null;const K=await r.cleanUntracked();I.value.loading=!1,K.success?I.value.visible=!1:I.value.error=K.error||"Unknown error"}const be=J(()=>e.value.visible||n.value.visible||i.value.visible||a.value.visible||c.value.visible||h.value.visible||p.value.visible||O.value.visible||x.value.visible||w.value.visible||Q.value.visible||D.value.visible||oe.value.visible||ie.value.visible||V.value.visible||W.value.visible||I.value.visible);return{checkoutDialog:e,confirmCheckout:t,createBranchDialog:n,confirmCreateBranch:s,deleteBranchDialog:i,confirmDeleteBranch:o,renameDialog:a,confirmRenameBranch:l,mergeDialog:c,confirmMerge:u,rebaseDialog:h,confirmRebase:f,pushDialog:p,confirmPush:g,pullDialog:O,confirmPull:b,cherryPickDialog:x,confirmCherryPick:k,resetDialog:w,confirmReset:S,tagCreateDialog:Q,confirmTagCreate:L,tagDeleteDialog:D,confirmTagDelete:G,tagDetailDialog:oe,stashDialog:ie,confirmStash:j,stashBranchDialog:V,stashBranchInput:Z,confirmStashBranch:U,resetWorkingDialog:W,confirmResetWorking:N,cleanUntrackedDialog:I,confirmCleanUntracked:z,isAnyDialogOpen:be}}function $k(r,e){const t=P({visible:!1,x:0,y:0});function n(q,ve){t.value={visible:!0,x:q,y:ve},setTimeout(()=>{t.value.visible=!1},1500)}const s=P({visible:!1,branch:"",x:0,y:0,isCurrentBranch:!1,isLocal:!0,commitHash:""});function i(q){s.value={visible:!0,...q},r.setActiveContextMenu({type:"branch",props:q,position:{x:q.x,y:q.y}})}function o(){s.value.visible=!1,r.clearActiveContextMenu()}function a(){o(),e.checkoutDialog.value={visible:!0,branchName:s.value.branch,loading:!1,error:null}}function l(){const q=s.value.branch;o(),e.renameDialog.value={visible:!0,branchName:q,newName:q,loading:!1,error:null}}function c(){const{branch:q,isLocal:ve}=s.value;o(),e.deleteBranchDialog.value={visible:!0,branchName:q,isLocal:ve,force:!1,loading:!1,error:null}}function u(){const q=s.value.branch;o(),e.mergeDialog.value={visible:!0,branchName:q,loading:!1,error:null}}function h(){const q=s.value.branch;o(),e.rebaseDialog.value={visible:!0,branchName:q,loading:!1,error:null}}function f(){const q=s.value.branch;o(),e.pushDialog.value={visible:!0,branchName:q,loading:!1,error:null}}function p(){const q=s.value.branch;o(),e.pullDialog.value={visible:!0,branchName:q,loading:!1,error:null}}async function g(){const q=s.value.branch;o(),await r.fetchBranch(q)}async function O(){const{branch:q,x:ve,y:Ze}=s.value;o(),(await r.copyToClipboard(q)).success&&n(ve,Ze)}function b(){o(),e.createBranchDialog.value={visible:!0,fromCommit:s.value.commitHash,loading:!1,error:null}}const x=P({visible:!1,commit:null,x:0,y:0});function k(q){x.value={visible:!0,commit:q.commit,x:q.x,y:q.y},r.setActiveContextMenu({type:"commit",props:q,position:{x:q.x,y:q.y}})}function w(){x.value.visible=!1,r.clearActiveContextMenu()}function S(q){return q===!1?!1:typeof q=="object"&&q!==null&&"success"in q?!!q.success:!0}function Q(q){const ve=x.value.commit;if(!ve)return!1;w();const Ze=q(ve);return Ze&&typeof Ze.then=="function"?Ze.then(S).catch(()=>!1):S(Ze)}function L(){Q(q=>{e.tagCreateDialog.value={visible:!0,commitHash:q.hash,loading:!1,error:null}})}function D(){Q(q=>{e.createBranchDialog.value={visible:!0,fromCommit:q.hash,loading:!1,error:null}})}function G(){Q(q=>{e.checkoutDialog.value={visible:!0,branchName:q.hash,loading:!1,error:null}})}function oe(){Q(q=>{e.cherryPickDialog.value={visible:!0,commitHash:q.hash,commitMessage:q.message,loading:!1,error:null}})}async function ie(){await Q(q=>r.revertCommit(q.hash))}function j(){Q(q=>{e.mergeDialog.value={visible:!0,branchName:q.shortHash,loading:!1,error:null}})}function V(){Q(q=>{e.resetDialog.value={visible:!0,commitHash:q.hash,commitMessage:q.message,loading:!1,error:null}})}async function Z(){const{x:q,y:ve}=x.value;await Q(it=>r.copyToClipboard(it.hash))&&n(q,ve)}async function U(){const{x:q,y:ve}=x.value;await Q(it=>r.copyCommitSubject(it))&&n(q,ve)}const W=P({visible:!1,tag:"",x:0,y:0,commitHash:""});function N(q){W.value={visible:!0,...q},r.setActiveContextMenu({type:"tag",props:q,position:{x:q.x,y:q.y}})}function I(){W.value.visible=!1,r.clearActiveContextMenu()}async function z(){const q=W.value.tag;I(),e.tagDetailDialog.value={visible:!0,tagName:q,loading:!0,tagDetail:null};const ve=await r.getTagDetail(q);e.tagDetailDialog.value.loading=!1,ve.success&&ve.data&&(e.tagDetailDialog.value.tagDetail=ve.data)}function be(){const q=W.value.tag;I(),e.tagDeleteDialog.value={visible:!0,tagName:q,loading:!1,error:null}}async function K(){const q=W.value.tag;I(),await r.pushTag(q)}async function H(){const{tag:q,x:ve,y:Ze}=W.value;I(),(await r.copyToClipboard(q)).success&&n(ve,Ze)}const re=P({visible:!1,x:0,y:0});function Oe(q){re.value={visible:!0,...q},r.setActiveContextMenu({type:"uncommitted",props:q,position:{x:q.x,y:q.y}})}function ge(){re.value.visible=!1,r.clearActiveContextMenu()}function $e(){ge(),e.stashDialog.value={visible:!0,loading:!1,error:null}}function Pe(){ge(),e.resetWorkingDialog.value={visible:!0,loading:!1,error:null}}function Fe(){ge(),e.cleanUntrackedDialog.value={visible:!0,loading:!1,error:null}}const T=P({visible:!1,stash:null,x:0,y:0});function M(q){T.value={visible:!0,stash:q.stash,x:q.x,y:q.y},r.setActiveContextMenu({type:"stash",props:q,position:{x:q.x,y:q.y}})}function E(){T.value.visible=!1,r.clearActiveContextMenu()}function B(q){const ve=T.value.stash;if(!ve)return!1;E();const Ze=q(ve);return Ze&&typeof Ze.then=="function"?Ze.then(S).catch(()=>!1):S(Ze)}async function xe(){await B(q=>r.applyStash(q.index))}async function Re(){await B(q=>r.popStash(q.index))}async function Me(){await B(q=>r.dropStash(q.index))}function ue(){B(q=>{e.stashBranchDialog.value={visible:!0,stashIndex:q.index,loading:!1,error:null}})}async function ne(){const{x:q,y:ve}=T.value;await B(it=>r.copyToClipboard(`stash@{${it.index}}`))&&n(q,ve)}async function Ce(){const{x:q,y:ve}=T.value;await B(it=>r.copyToClipboard(it.hash))&&n(q,ve)}return{copyFeedback:t,showCopyFeedback:n,branchMenu:s,handleBranchContextMenu:i,closeBranchMenu:o,handleBranchCheckout:a,handleBranchRename:l,handleBranchDelete:c,handleBranchMerge:u,handleBranchRebase:h,handleBranchPush:f,handleBranchPull:p,handleBranchFetch:g,handleBranchCopyName:O,handleBranchCreateBranch:b,commitMenu:x,handleCommitContextMenu:k,closeCommitMenu:w,handleCommitAddTag:L,handleCommitCreateBranch:D,handleCommitCheckout:G,handleCommitCherryPick:oe,handleCommitRevert:ie,handleCommitMergeInto:j,handleCommitReset:V,handleCommitCopyHash:Z,handleCommitCopySubject:U,tagMenu:W,handleTagContextMenu:N,closeTagMenu:I,handleTagViewDetails:z,handleTagDelete:be,handleTagPush:K,handleTagCopyName:H,uncommittedMenu:re,handleUncommittedContextMenu:Oe,closeUncommittedMenu:ge,handleUncommittedStash:$e,handleUncommittedReset:Pe,handleUncommittedClean:Fe,stashMenu:T,handleStashContextMenu:M,closeStashMenu:E,handleStashApply:xe,handleStashPop:Re,handleStashDrop:Me,handleStashCreateBranch:ue,handleStashCopyName:ne,handleStashCopyHash:Ce}}const Ck={class:"w-full max-w-md mx-4 bg-retro-dark border border-retro-border rounded-lg shadow-xl"},Qk={class:"flex items-center justify-between px-4 py-3 border-b border-retro-border"},Pk={class:"text-sm font-mono text-retro-text"},Tk={class:"p-4"},Mk={key:0,class:"mb-3 p-2 text-xs font-mono text-retro-red bg-retro-red/10 border border-retro-red/30 rounded"},Ak={class:"flex justify-end gap-2 px-4 py-3 border-t border-retro-border"},_k=["disabled"],Rk=["disabled"],Bt=Ve({__name:"GitDialog",props:{title:{},visible:{type:Boolean},loading:{type:Boolean,default:!1},error:{default:null},confirmLabel:{default:"Confirm"},confirmDanger:{type:Boolean,default:!1},cancelLabel:{default:"Cancel"}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e;function s(i){i.key==="Escape"&&n("close"),i.key==="Enter"&&!t.loading&&(i.preventDefault(),n("confirm"))}return ze(()=>t.visible,i=>{i?document.addEventListener("keydown",s):document.removeEventListener("keydown",s)}),wt(()=>{document.removeEventListener("keydown",s)}),(i,o)=>(v(),pe(Pr,{to:"body"},[ee(On,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ut(()=>[r.visible?(v(),y("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",role:"dialog","aria-modal":"true",onClick:o[3]||(o[3]=kr(a=>n("close"),["self"]))},[d("div",Ck,[d("div",Qk,[d("h3",Pk,A(r.title),1),d("button",{type:"button",class:"p-1 rounded text-retro-muted hover:text-retro-text hover:bg-retro-panel transition-colors",title:"Close",onClick:o[0]||(o[0]=a=>n("close"))},[ee(m(St),{class:"h-4 w-4"})])]),d("div",Tk,[r.error?(v(),y("div",Mk,A(r.error),1)):F("",!0),Hm(i.$slots,"default")]),d("div",Ak,[d("button",{type:"button",class:"px-3 py-1.5 text-xs font-mono text-retro-muted hover:text-retro-text bg-retro-panel hover:bg-retro-border rounded transition-colors",disabled:r.loading,onClick:o[1]||(o[1]=a=>n("close"))},A(r.cancelLabel),9,_k),d("button",{type:"button",class:_e(["px-3 py-1.5 text-xs font-mono rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",[r.confirmDanger?"text-retro-red bg-retro-red/10 border border-retro-red/30 hover:bg-retro-red/20":"text-retro-black bg-retro-cyan hover:bg-retro-cyan/80"]]),disabled:r.loading,onClick:o[2]||(o[2]=a=>n("confirm"))},A(r.loading?"Loading...":r.confirmLabel),11,Rk)])])])):F("",!0)]),_:3})]))}}),Bk={class:"text-retro-text text-sm font-mono mb-4"},Zk={class:"text-retro-cyan"},Ek={class:"space-y-3"},Dk={class:"flex items-center gap-2 cursor-pointer"},Lk={class:"flex items-center gap-2 cursor-pointer"},Xk={class:"flex items-center gap-2 cursor-pointer"},Ik=Ve({__name:"MergeDialog",props:{visible:{type:Boolean},branchName:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e,s=P(!1),i=P(!1),o=P(!1);function a(){n("confirm",{noCommit:s.value,noFastForward:i.value,squash:o.value})}return ze(()=>t.visible,l=>{l&&(s.value=!1,i.value=!1,o.value=!1)}),(l,c)=>(v(),pe(Bt,{title:"Merge Branch",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Merge",onClose:c[3]||(c[3]=u=>n("close")),onConfirm:a},{default:ut(()=>[d("p",Bk,[c[4]||(c[4]=Ie(" Merge ",-1)),d("span",Zk,A(r.branchName),1),c[5]||(c[5]=Ie(" into current branch ",-1))]),d("div",Ek,[d("label",Dk,[je(d("input",{"onUpdate:modelValue":c[0]||(c[0]=u=>Je(s)?s.value=u:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(s)]]),c[6]||(c[6]=d("span",{class:"text-retro-muted text-sm"},"No commit (stage changes only)",-1))]),d("label",Lk,[je(d("input",{"onUpdate:modelValue":c[1]||(c[1]=u=>Je(i)?i.value=u:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(i)]]),c[7]||(c[7]=d("span",{class:"text-retro-muted text-sm"},"No fast-forward (always create merge commit)",-1))]),d("label",Xk,[je(d("input",{"onUpdate:modelValue":c[2]||(c[2]=u=>Je(o)?o.value=u:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(o)]]),c[8]||(c[8]=d("span",{class:"text-retro-muted text-sm"},"Squash (combine all commits into one)",-1))])])]),_:1},8,["visible","loading","error"]))}}),Vk={class:"text-retro-text text-sm font-mono mb-2"},zk={class:"text-retro-cyan"},Nk={class:"space-y-3 mt-4"},Wk={class:"flex items-center gap-2 cursor-pointer"},qk=Ve({__name:"DeleteBranchDialog",props:{visible:{type:Boolean},branchName:{},isLocal:{type:Boolean},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e,s=P(!1);function i(){n("confirm",{force:s.value})}return ze(()=>t.visible,o=>{o&&(s.value=!1)}),(o,a)=>(v(),pe(Bt,{title:"Delete Branch",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Delete","confirm-danger":!0,onClose:a[1]||(a[1]=l=>n("close")),onConfirm:i},{default:ut(()=>[a[4]||(a[4]=d("div",{class:"mb-4 p-2 text-xs font-mono text-retro-yellow bg-retro-yellow/10 border border-retro-yellow/30 rounded"}," This action is permanent and cannot be undone. ",-1)),d("p",Vk,[Ie(" Delete "+A(r.isLocal?"local":"remote")+" branch ",1),d("span",zk,A(r.branchName),1),a[2]||(a[2]=Ie("? ",-1))]),d("div",Nk,[d("label",Wk,[je(d("input",{"onUpdate:modelValue":a[0]||(a[0]=l=>Je(s)?s.value=l:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(s)]]),a[3]||(a[3]=d("span",{class:"text-retro-muted text-sm"},"Force delete (even if not fully merged)",-1))])])]),_:1},8,["visible","loading","error"]))}}),jk={class:"text-retro-text text-sm font-mono mb-4"},Yk={class:"text-retro-cyan"},Fk={class:"space-y-3"},Uk=["value"],Gk={class:"flex items-center gap-2 cursor-pointer"},Hk=["checked"],Kk={class:"flex items-center gap-2 cursor-pointer"},Jk=["checked"],ew={key:0,class:"p-2 text-xs font-mono text-retro-yellow bg-retro-yellow/10 border border-retro-yellow/30 rounded"},tw=Ve({__name:"PushDialog",props:{visible:{type:Boolean},branchName:{},remotes:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e,s=P("origin"),i=P(!1),o=P(!1);function a(u){i.value=u,u&&(o.value=!1)}function l(u){o.value=u,u&&(i.value=!1)}function c(){n("confirm",{remote:s.value,force:i.value,forceWithLease:o.value})}return ze(()=>t.visible,u=>{u&&(s.value=t.remotes.includes("origin")?"origin":t.remotes[0]??"origin",i.value=!1,o.value=!1)}),(u,h)=>(v(),pe(Bt,{title:"Push Branch",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Push",onClose:h[3]||(h[3]=f=>n("close")),onConfirm:c},{default:ut(()=>[d("p",jk,[h[4]||(h[4]=Ie(" Push ",-1)),d("span",Yk,A(r.branchName),1),h[5]||(h[5]=Ie(" to remote ",-1))]),d("div",Fk,[d("div",null,[h[6]||(h[6]=d("label",{class:"text-retro-muted text-sm block mb-1"},"Remote",-1)),je(d("select",{"onUpdate:modelValue":h[0]||(h[0]=f=>Je(s)?s.value=f:null),class:"w-full bg-retro-panel border border-retro-border rounded text-retro-text text-sm px-2 py-1.5 font-mono focus:outline-none focus:border-retro-cyan"},[(v(!0),y(we,null,Ne(r.remotes,f=>(v(),y("option",{key:f,value:f},A(f),9,Uk))),128))],512),[[ks,m(s)]])]),d("label",Gk,[d("input",{checked:m(i),type:"checkbox",class:"accent-retro-cyan",onChange:h[1]||(h[1]=f=>a(f.target.checked))},null,40,Hk),h[7]||(h[7]=d("span",{class:"text-retro-muted text-sm"},"Force push",-1))]),d("label",Kk,[d("input",{checked:m(o),type:"checkbox",class:"accent-retro-cyan",onChange:h[2]||(h[2]=f=>l(f.target.checked))},null,40,Jk),h[8]||(h[8]=d("span",{class:"text-retro-muted text-sm"},"Force with lease (safer force push)",-1))]),m(i)||m(o)?(v(),y("div",ew,A(m(i)?"Force push will overwrite remote history. Use with caution.":"Force with lease will reject the push if the remote has been updated since your last fetch."),1)):F("",!0)])]),_:1},8,["visible","loading","error"]))}}),rw={class:"text-retro-text text-sm font-mono mb-4"},nw={class:"text-retro-cyan"},sw={class:"space-y-3"},iw=["value"],ow={class:"flex items-center gap-2 cursor-pointer"},aw={class:"flex items-center gap-2 cursor-pointer"},lw=Ve({__name:"PullDialog",props:{visible:{type:Boolean},branchName:{},remotes:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e,s=P("origin"),i=P(!1),o=P(!1);function a(){n("confirm",{remote:s.value,noFastForward:i.value,squash:o.value})}return ze(()=>t.visible,l=>{l&&(s.value=t.remotes.includes("origin")?"origin":t.remotes[0]??"origin",i.value=!1,o.value=!1)}),(l,c)=>(v(),pe(Bt,{title:"Pull Branch",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Pull",onClose:c[3]||(c[3]=u=>n("close")),onConfirm:a},{default:ut(()=>[d("p",rw,[c[4]||(c[4]=Ie(" Pull ",-1)),d("span",nw,A(r.branchName),1),c[5]||(c[5]=Ie(" from remote ",-1))]),d("div",sw,[d("div",null,[c[6]||(c[6]=d("label",{class:"text-retro-muted text-sm block mb-1"},"Remote",-1)),je(d("select",{"onUpdate:modelValue":c[0]||(c[0]=u=>Je(s)?s.value=u:null),class:"w-full bg-retro-panel border border-retro-border rounded text-retro-text text-sm px-2 py-1.5 font-mono focus:outline-none focus:border-retro-cyan"},[(v(!0),y(we,null,Ne(r.remotes,u=>(v(),y("option",{key:u,value:u},A(u),9,iw))),128))],512),[[ks,m(s)]])]),d("label",ow,[je(d("input",{"onUpdate:modelValue":c[1]||(c[1]=u=>Je(i)?i.value=u:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(i)]]),c[7]||(c[7]=d("span",{class:"text-retro-muted text-sm"},"No fast-forward (always create merge commit)",-1))]),d("label",aw,[je(d("input",{"onUpdate:modelValue":c[2]||(c[2]=u=>Je(o)?o.value=u:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(o)]]),c[8]||(c[8]=d("span",{class:"text-retro-muted text-sm"},"Squash (combine all commits into one)",-1))])])]),_:1},8,["visible","loading","error"]))}}),cw={class:"text-retro-text text-sm font-mono mb-4"},uw={class:"text-retro-cyan"},hw={class:"text-retro-cyan"},dw={class:"p-2 text-xs font-mono text-retro-yellow bg-retro-yellow/10 border border-retro-yellow/30 rounded"},fw={class:"text-retro-cyan"},mw={class:"text-retro-cyan"},pw=Ve({__name:"RebaseDialog",props:{visible:{type:Boolean},branchName:{},ontoBranch:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=e;return(n,s)=>(v(),pe(Bt,{title:"Rebase Branch",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Rebase",onClose:s[0]||(s[0]=i=>t("close")),onConfirm:s[1]||(s[1]=i=>t("confirm"))},{default:ut(()=>[d("p",cw,[s[2]||(s[2]=Ie(" Rebase ",-1)),d("span",uw,A(r.branchName),1),s[3]||(s[3]=Ie(" onto ",-1)),d("span",hw,A(r.ontoBranch),1)]),d("div",dw,[s[4]||(s[4]=Ie(" This will rewrite commit history. Commits from ",-1)),d("span",fw,A(r.branchName),1),s[5]||(s[5]=Ie(" will be replayed on top of ",-1)),d("span",mw,A(r.ontoBranch),1),s[6]||(s[6]=Ie(". ",-1))])]),_:1},8,["visible","loading","error"]))}}),gw={class:"mb-4 p-3 bg-retro-panel border border-retro-border rounded"},Ow={class:"text-sm font-mono text-retro-cyan"},vw={class:"text-xs font-mono text-retro-text mt-1 truncate"},bw={class:"space-y-3"},xw={class:"flex items-start gap-2 cursor-pointer group"},yw={class:"flex items-start gap-2 cursor-pointer group"},kw=Ve({__name:"CherryPickDialog",props:{visible:{type:Boolean},commitHash:{},commitMessage:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=e,n=P(!1),s=P(!1);function i(){t("confirm",{recordOrigin:n.value,noCommit:s.value})}function o(){n.value=!1,s.value=!1,t("close")}return(a,l)=>(v(),pe(Bt,{title:"Cherry-Pick Commit",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Cherry-Pick",onClose:o,onConfirm:i},{default:ut(()=>[d("div",gw,[l[2]||(l[2]=d("div",{class:"text-xs font-mono text-retro-muted mb-1"},"Commit",-1)),d("div",Ow,A(r.commitHash.slice(0,7)),1),d("div",vw,A(r.commitMessage.split(`
8
+ `):""}function Io(r){r.contentBlocks&&(r.content=sk(r.contentBlocks))}function ik(r,e){if(r.type!==e.type)return!0;switch(e.type){case"text":return r.text!==e.text;case"tool_use":{const t=r;return t.name!==e.name||t.inputSummary!==e.inputSummary}case"tool_result":{const t=r;return t.content!==e.content||t.isError!==e.isError}default:return!1}}function ok(r,e,t="info",n,s=Date.now,i=Math.random){return{id:`conflict-msg-${s()}-${i().toString(36).slice(2,7)}`,role:r,content:e,timestamp:s(),type:t,fileRef:n}}function ak(r,e){return e===0?{message:`All ${r} file${r===1?"":"s"} resolved successfully. Click "Continue Rebase" to proceed.`,succeeded:!0}:{message:`Resolution complete: ${r} succeeded, ${e} failed. You can retry or abort.`,succeeded:!1}}function lk(r,e){const t=[];for(let n=0;n<r.length;n+=e)t.push(r.slice(n,n+e));return t}function ck(r,e){return r.filter(t=>!e.has(t.path))}function uk(r){return`Detected ${r} conflicted file${r===1?"":"s"}. Enter optional guidance below and click "Resolve Conflicts Automatically" to start.`}function hk(r){return`Starting AI resolution for ${r} file${r===1?"":"s"} (parallel)...`}async function dk(r){return $fetch("/api/chat/preview",{method:"POST",body:r})}async function fk(r){return $fetch("/api/chat/preview",{method:"DELETE",body:r})}function mk(r,e){return r===e?{kind:"end-current",id:e}:r?{kind:"swap",endId:r,startId:e}:{kind:"start",id:e}}function pk(r){const e=new Map,t=r.setTimer??setTimeout,n=r.clearTimer??clearTimeout;function s(l){if(e.has(l))return;const c=t(()=>{e.delete(l),r.onFlush(l)},r.delayMs);e.set(l,c)}function i(l){const c=e.get(l);c&&(n(c),e.delete(l)),r.onFlush(l)}function o(l){const c=e.get(l);c&&(n(c),e.delete(l))}function a(){for(const l of e.values())n(l);e.clear()}return{schedule:s,flush:i,cancel:o,cancelAll:a,hasPending:l=>e.has(l),pendingCount:()=>e.size}}async function gk(r){return $fetch("/api/chat/finalize",{method:"POST",body:r})}async function Ok(r){return $fetch("/api/chat/rebase",{method:"POST",body:r})}async function vk(r){return $fetch("/api/rebase/conflicts",{params:{worktreePath:r}})}async function bk(r){return $fetch("/api/rebase/resolve",{method:"PUT",body:r})}async function xk(r){const e=r.mode==="sync"?"/api/rebase/continue-sync":"/api/rebase/continue",{mode:t,...n}=r;return $fetch(e,{method:"POST",body:n})}async function id(r){return $fetch("/api/rebase/abort",{method:"POST",body:{worktreePath:r}})}async function yk(r){return $fetch("/api/rebase/ai-resolve",{method:"POST",body:r})}const vr=Mu("chat",()=>{const r=P(!1),e=P(av),t=P("ask"),n=P(""),s=P([]),i=P([]),o=P(null),a=P("active"),l=P(new Set),c=new Map,u=P(!1),h=P(0),p=pk({delayMs:1200,onFlush:C=>{const R=s.value.find(_=>_.id===C);R&&(R.updatedAt=new Date().toISOString(),nk(R))}}),g=P(null),O=P(null);let b=null;function x(C){return C?c.get(C)??null:null}function k(C){let R=c.get(C);return R||(R={session:null,pendingPermission:null,pendingPlanApproval:null,lastError:null,debugEvents:[]},c.set(C,R)),R}const w=J(()=>s.value.find(C=>C.id===o.value)||null),S=J(()=>w.value?.messages??[]),Q=J(()=>(h.value,x(o.value)?.session??null)),L=J(()=>(h.value,x(o.value)?.pendingPermission??null)),D=J(()=>(h.value,x(o.value)?.pendingPlanApproval??null)),G=J(()=>(h.value,x(o.value)?.lastError??null)),oe=J(()=>(h.value,x(o.value)?.debugEvents??[])),ie=J(()=>Q.value?.status==="streaming"),j=J(()=>w.value?.providerSessionId??""),V=J(()=>S.value.length>0),Z=J(()=>S.value[S.value.length-1]||null);function U(C){return l.value.has(C)}const W=J(()=>o.value?l.value.has(o.value):!1),N=J(()=>s.value.length>0),I=J(()=>i.value.length>0),z=J(()=>s.value.length),be=J(()=>z.value>=Fh),K=J(()=>s.value),H=J(()=>i.value),re=J(()=>g.value&&s.value.find(C=>C.id===g.value)||null);function Oe(C){return g.value===C}function ge(C){a.value=C}async function $e(C){if(!(!C?.previewBranch||!C.worktreePath))try{await Xv({previewBranch:C.previewBranch,worktreePath:C.worktreePath})}catch(R){console.warn("[chat] Failed to sync preview branch after worktree update",{conversationId:C.id,previewBranch:C.previewBranch,worktreePath:C.worktreePath,error:R instanceof Error?R.message:String(R)})}}async function Pe(C){if(U(C))return{success:!1,error:"Cannot archive while this conversation is streaming"};if(s.value.findIndex(_=>_.id===C)===-1)return{success:!1,error:"Conversation not found"};try{const _=await $fetch(`/api/conversations/${C}/archive`,{method:"POST"});return _.success&&_.archived?(p.cancel(C),c.delete(C),s.value=Array.isArray(_.conversations)?_.conversations:s.value.filter(X=>X.id!==C),i.value=Array.isArray(_.archivedConversations)?_.archivedConversations:[_.archived,...i.value],cn(),$n(),g.value===C&&(g.value=null),o.value===C&&(o.value=s.value[0]?.id??null),typeof window<"u"&&$fetch("/api/settings",{method:"POST",body:{activeConversationId:o.value}}).catch(X=>{console.error("Failed to save active conversation:",X)}),{success:!0}):{success:!1,error:"Failed to archive conversation"}}catch(_){return{success:!1,error:_ instanceof Error?_.message:"Failed to archive conversation"}}}async function Fe(C,R){if(Kn().atLimit)return{success:!1,error:`Cannot restore. Active conversations reached ${Uh}.`};if(!i.value.some(X=>X.id===C))return{success:!1,error:"Archived conversation not found"};try{const X=await $fetch(`/api/conversations/archives/${C}/restore`,{method:"POST",body:{baseBranch:R}});return X.success&&X.conversation?(s.value=Array.isArray(X.conversations)?X.conversations:[X.conversation,...s.value],Array.isArray(X.archivedConversations)?i.value=X.archivedConversations:i.value=i.value.filter(ce=>ce.id!==C),a.value="active",Cn(X.conversation.id),cn(),Dt(),{success:!0,conversationId:X.conversation.id}):{success:!1,error:"Failed to restore archived conversation"}}catch(X){return{success:!1,error:X instanceof Error?X.message:"Failed to restore archived conversation"}}}async function T(C){const R=i.value.findIndex(_=>_.id===C);if(R===-1)return{success:!1,error:"Archived conversation not found"};try{return await $fetch(`/api/conversations/archives/${C}`,{method:"DELETE"}),i.value.splice(R,1),$n(),{success:!0}}catch{return i.value.splice(R,1),Dt(),{success:!0}}}async function M(){if(!(typeof window>"u"))try{const C=await $fetch("/api/settings");if(C){if(typeof C.panelWidth=="number"){const X=C.panelWidth;X>=Gh&&X<=Hh&&(e.value=X)}typeof C.isPanelOpen=="boolean"&&(r.value=C.isPanelOpen),typeof C.activeConversationId=="string"&&(o.value=C.activeConversationId);const{useSettingsStore:R}=await ds(async()=>{const{useSettingsStore:X}=await import("./BeBeZcRQ.js").then(ce=>ce.s);return{useSettingsStore:X}},__vite__mapDeps([0,1,2]),import.meta.url),_=R();await _.hydrate(),t.value=_.permissionMode}}catch(C){console.error("Failed to load chat settings:",C)}}function E(C){t.value=C,typeof window<"u"&&ds(async()=>{const{useSettingsStore:R}=await import("./BeBeZcRQ.js").then(_=>_.s);return{useSettingsStore:R}},__vite__mapDeps([0,1,2]),import.meta.url).then(({useSettingsStore:R})=>{R().setPermissionMode(C)})}function B(C,R){const _=R??o.value;if(!_)return;const X=k(_);X.pendingPermission=C,h.value++}function xe(C){const R=C??o.value;if(!R)return;const _=c.get(R);_&&(_.pendingPermission=null,h.value++)}function Re(C,R){const _=R??o.value;if(!_)return;const X=k(_);X.pendingPlanApproval=C,h.value++}function Me(C){const R=C??o.value;if(!R)return;const _=c.get(R);_&&(_.pendingPlanApproval=null,h.value++)}function ue(){r.value=!r.value,q()}function ne(){r.value=!0,q()}function Ce(){r.value=!1,q()}function q(){typeof window<"u"&&$fetch("/api/settings",{method:"POST",body:{isPanelOpen:r.value}}).catch(C=>{console.error("Failed to save panel state:",C)})}function ve(C){const R=Math.max(Gh,Math.min(Hh,C));e.value=R,typeof window<"u"&&$fetch("/api/settings",{method:"POST",body:{panelWidth:R}}).catch(_=>{console.error("Failed to save panel width:",_)})}function Ze(C){n.value=C}function it(C,R){const _=R??o.value;if(!_)return;const X=s.value.find(ce=>ce.id===_);X&&(X.providerSessionId=C)}function Nt(C,R){const _=s.value.find(X=>X.id===C);_&&(_.worktreeBranch=R,_.lastCommitTime=new Date().toISOString())}async function sr(C){const R=s.value.find(X=>X.id===C);if(!R?.worktreeBranch)return null;const _=R.worktreeBranch.trim();if(!_)return null;try{const ce=(await $fetch("/api/specs/features")).features.find(de=>de.id===_);return ce?(R.featureId!==ce.id&&(R.featureId=ce.id,R.updatedAt=new Date().toISOString(),Dt()),ce.id):null}catch(X){return console.warn("[chat] Failed to map branch to feature",{conversationId:C,branchName:_,error:X instanceof Error?X.message:String(X)}),null}}function on(C,R,_){const X=s.value.find(ce=>ce.id===C);X&&(X.providerId=R,X.providerModelKey=_)}function xr(C){const R=C??o.value;if(!R)return;const _=s.value.find(X=>X.id===R);_&&(_.providerSessionId="")}function qn(C){return s.value.find(_=>_.id===C)?.providerSessionId??""}function an(C){l.value.add(C)}function jn(C){l.value.delete(C)}function ln(C,R){const _=R??o.value;if(!_)return;const X=s.value.find(ce=>ce.id===_);X&&X.messages.push(C)}function Sn(C,R,_){const X={id:Kh(),role:"user",content:C,attachments:_&&_.length>0?_:void 0,timestamp:new Date().toISOString()};return ln(X,R),X}function Et(C){const R={id:Kh(),role:"assistant",content:"",timestamp:new Date().toISOString(),status:"streaming"};return ln(R,C),R}function Wt(C,R,_){const X=_??o.value;if(!X)return;const ce=s.value.find(ae=>ae.id===X);if(!ce)return;const de=ce.messages.findIndex(ae=>ae.id===C);de!==-1&&(ce.messages[de]={...ce.messages[de],...R})}function he(C,R){const _=s.value.find(ce=>ce.id===R);if(!_)return;const X=_.messages.findIndex(ce=>ce.id===C);X!==-1&&(_.messages[X]={..._.messages[X],content:"",status:"streaming",contentBlocks:[]})}function ye(C,R,_){const X=_??o.value;if(!X)return;const ce=s.value.find(ae=>ae.id===X);if(!ce)return;const de=ce.messages.findIndex(ae=>ae.id===C);de!==-1&&(ce.messages[de].content+=R)}function Be(C,R,_){const X=_??o.value;if(!X)return;const ce=s.value.find(ae=>ae.id===X);if(!ce)return;const de=ce.messages.findIndex(ae=>ae.id===C);if(de!==-1){const ae=ce.messages[de],fe=ae.tools?[...ae.tools,R]:[R];ce.messages[de]={...ae,tools:fe}}}function Ye(C,R,_,X){const ce=X??o.value;if(!ce)return;const de=s.value.find(fe=>fe.id===ce);if(!de)return;const ae=de.messages.findIndex(fe=>fe.id===C);if(ae!==-1){const fe=de.messages[ae];if(fe.tools){const rt=fe.tools.findIndex(at=>at.id===R);if(rt!==-1){const at=[...fe.tools];at[rt]={...at[rt],..._},de.messages[ae]={...fe,tools:at}}}}or(ce,!1)}function Ue(C,R){const _=R??o.value;if(!_)return;const X=s.value.find(de=>de.id===_);if(!X)return;const ce=X.messages.find(de=>de.id===C);ce&&!ce.contentBlocks&&(ce.contentBlocks=[])}function Ct(C,R,_){const X=_??o.value;if(!X)return;const ce=s.value.find(ae=>ae.id===X);if(!ce)return;const de=ce.messages.find(ae=>ae.id===C);de&&(de.contentBlocks||(de.contentBlocks=[]),de.contentBlocks.push(R),Io(de))}function ot(C,R,_,X){const ce=X??o.value;if(!ce)return;const de=s.value.find(qt=>qt.id===ce);if(!de)return;const ae=de.messages.find(qt=>qt.id===C);if(!ae?.contentBlocks)return;const fe=ae.contentBlocks.findIndex(qt=>qt.id===R);if(fe===-1)return;const at={...ae.contentBlocks[fe]};_(at),ae.contentBlocks[fe]=at}function Ft(C,R,_,X,ce){const de=X??o.value;if(!de)return;const ae=s.value.find(lr=>lr.id===de);if(!ae)return;const fe=ae.messages.find(lr=>lr.id===C);if(!fe?.contentBlocks)return;const rt=fe.contentBlocks.findIndex(lr=>lr.id===R);if(rt===-1)return;const at=fe.contentBlocks[rt],qt={...at};_(qt),fe.contentBlocks[rt]=qt,ce?.syncContent!==!1&&ik(at,qt)&&Io(fe),or(de,!1)}function ir(C,R,_){const X=_??o.value;if(!X)return;const ce=s.value.find(ae=>ae.id===X);if(!ce)return;const de=ce.messages.find(ae=>ae.id===C);de&&(de.contentBlocks||(de.contentBlocks=[]),de.contentBlocks.push(R),Io(de),or(X,!1))}function yr(C,R,_){const X=_??o.value;if(!X)return null;const ce=s.value.find(ae=>ae.id===X);if(!ce)return null;const de=ce.messages.find(ae=>ae.id===C);return de?.contentBlocks?de.contentBlocks.find(ae=>ae.type==="tool_use"&&ae.toolUseId===R)??null:null}function Yn(C,R,_,X,ce){const de=s.value.find(fe=>fe.id===ce);if(!de)return;const ae=de.messages.findIndex(fe=>fe.id===C);ae!==-1&&(de.messages[ae]={...de.messages[ae],content:_,contentBlocks:R,status:X},or(ce,!0))}function Xr(C,R){const _=R??o.value;if(!_)return;const X=c.get(_);X?.session&&(X.session.status=C,h.value++)}function hi(C,R){const _=R??o.value;if(!_)return;const X=k(_);X.session={sessionId:C,cwd:n.value,status:"streaming",startedAt:new Date().toISOString()},X.lastError=null,h.value++}function di(C){const R=C??o.value;if(!R)return;const _=c.get(R);_?.session&&(_.session.status="idle",h.value++)}function fi(C,R){const _=R??o.value;if(!_)return;const X=k(_);X.session&&(X.session.status="error",X.session.error=C),X.lastError=C,h.value++}function mi(C,R){if(!u.value)return;const _=R??o.value;if(!_)return;const X=k(_),ce=(()=>{if(typeof C.payload=="string")return C.payload;try{return JSON.stringify(C.payload,null,2)}catch{return String(C.payload)}})(),de=8e3,ae=300,fe=ce.length>de?`${ce.slice(0,de)}
9
+ ... (truncated)`:ce;X.debugEvents.push({id:`dbg-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,timestamp:new Date().toISOString(),direction:C.direction,channel:C.channel,eventType:C.eventType||"unknown",payload:fe}),X.debugEvents.length>ae&&X.debugEvents.splice(0,X.debugEvents.length-ae),h.value++}function pi(C){u.value=C}function gi(C){const R=C??o.value;if(!R)return;const _=c.get(R);_&&(_.debugEvents=[],h.value++)}function Oi(){if(!o.value)return;const C=s.value.find(_=>_.id===o.value);C&&(C.messages=[]);const R=o.value;c.delete(R),h.value++}function vi(C){const R=C??o.value;if(!R)return;const _=c.get(R);_&&(_.lastError=null,_.session&&(_.session.error=void 0),h.value++)}async function bi(){const C=await sd();if(s.value=C.conversations,i.value=C.archivedConversations,C.discardedArchives>0&&console.warn(`[chat] Skipped ${C.discardedArchives} corrupted archived conversation(s)`),cn(),$n(),!g.value){const R=s.value.find(_=>!!_.previewBranch&&!_.finalized);R&&(g.value=R.id)}if(o.value){const R=s.value.find(_=>_.id===o.value);R&&R.cwd?n.value=R.cwd:R||(o.value=null,r.value=!1)}}async function xi(){const C=await sd(),R=new Map(s.value.map(ae=>[ae.id,ae])),_=new Set(C.conversations.map(ae=>ae.id));let X=0,ce=0,de=0;for(const ae of C.conversations){const fe=R.get(ae.id);if(!fe)s.value.push(ae),R.set(ae.id,ae),X++,console.log(`[chat] refresh: added new conversation ${ae.id} (source=${ae.source}, msgs=${ae.messages.length})`);else if(ae.source!=="user"&&(ae.messages.length>fe.messages.length||ae.updatedAt>(fe.updatedAt||""))){const rt=s.value.findIndex(at=>at.id===ae.id);rt!==-1&&(s.value.splice(rt,1,ae),console.log(`[chat] refresh: updated conversation ${ae.id} (msgs: ${fe.messages.length} → ${ae.messages.length}, updatedAt: ${fe.updatedAt} → ${ae.updatedAt})`)),ce++}else fe&&ae.messages.length!==fe.messages.length&&console.log(`[chat] refresh: skipped update for ${ae.id} (source=${ae.source}, server msgs=${ae.messages.length}, local msgs=${fe.messages.length})`)}for(let ae=s.value.length-1;ae>=0;ae--){const fe=s.value[ae];!_.has(fe.id)&&!l.value.has(fe.id)&&(console.log(`[chat] refresh: removed conversation ${fe.id} (no longer on server)`),o.value===fe.id&&(o.value=null),s.value.splice(ae,1),de++)}return C.archivedConversations&&(i.value=C.archivedConversations),(X>0||ce>0||de>0)&&cn(),console.log(`[chat] refreshServerConversations: loaded=${C.conversations.length}, added=${X}, updated=${ce}, removed=${de}`),X+ce+de}function Dt(){rk(s.value,i.value)}function or(C,R=!1){s.value.find(X=>X.id===C)&&(R?p.flush(C):p.schedule(C))}function Ss(C=!1){o.value&&or(o.value,C)}function cn(){s.value.sort((C,R)=>new Date(R.createdAt).getTime()-new Date(C.createdAt).getTime())}function $n(){i.value.sort((C,R)=>new Date(R.archivedAt).getTime()-new Date(C.archivedAt).getTime())}async function $s(C){if(Kn().atLimit)return"";const _=lv();let X=null;if(C?.featureId){const fe=await ed({conversationId:_,featureId:C.featureId,baseBranch:C.baseBranch});if(!fe.success&&fe.error)throw new Error(fe.error);X=fe}let ce=null;if(typeof window<"u")try{const{useSettingsStore:fe}=await ds(async()=>{const{useSettingsStore:at}=await import("./BeBeZcRQ.js").then(qt=>qt.s);return{useSettingsStore:at}},__vite__mapDeps([0,1,2]),import.meta.url),rt=fe();await rt.hydrate(),ce=rt.providerSelection}catch(fe){console.warn("[chat] Failed to load provider selection for new conversation",fe)}const de=ce||{providerId:tp,modelKey:ep},ae={id:_,title:"New Conversation",messages:[],createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),cwd:n.value||process.cwd?.()||"",source:C?.featureId?"cascade":"user",featureId:C?.featureId,providerId:de.providerId,providerModelKey:de.modelKey};if(X?.success&&X.worktreePath&&X.branch&&(ae.worktreePath=X.worktreePath,ae.worktreeBranch=X.branch,ae.cwd=X.worktreePath,ae.hasWorktree=!0,X.baseBranch&&(ae.baseBranch=X.baseBranch)),s.value.unshift(ae),o.value=_,typeof window<"u"&&$fetch("/api/settings",{method:"POST",body:{activeConversationId:_}}).catch(fe=>{console.error("Failed to save active conversation:",fe)}),!C?.featureId)try{const fe=await ed({conversationId:_,baseBranch:C?.baseBranch});if(fe.success&&fe.worktreePath&&fe.branch){const rt=s.value.find(at=>at.id===_);rt&&(rt.worktreePath=fe.worktreePath,rt.worktreeBranch=fe.branch,rt.cwd=fe.worktreePath,rt.hasWorktree=!0,fe.baseBranch&&(rt.baseBranch=fe.baseBranch))}}catch(fe){console.warn("[chat] Failed to create worktree for conversation",_,fe)}return or(_,!0),_}function Cn(C){const R=s.value.find(_=>_.id===C);R&&(o.value=C,r.value=!0,R.cwd&&(n.value=R.cwd),!R.featureId&&R.worktreeBranch&&sr(C),typeof window<"u"&&$fetch("/api/settings",{method:"POST",body:{activeConversationId:C,isPanelOpen:!0}}).catch(_=>{console.error("Failed to save active conversation:",_)}))}async function un(C){const R=s.value.findIndex(X=>X.id===C);if(R===-1)return;const _=s.value[R];if(g.value===C&&(g.value=null),_.hasWorktree&&_.worktreePath&&_.worktreeBranch)try{await Lv({worktreePath:_.worktreePath,branch:_.worktreeBranch})}catch(X){console.warn("[chat] Failed to clean up worktree for conversation",C,X)}s.value.splice(R,1),c.delete(C),p.cancel(C),o.value===C&&(o.value=null,typeof window<"u"&&$fetch("/api/settings",{method:"POST",body:{activeConversationId:null}}).catch(X=>{console.error("Failed to clear active conversation:",X)})),Dt()}async function yi(C,R,_){const X=s.value.find(de=>de.id===C);if(!X)return{success:!1,error:"Conversation not found"};if(!X.hasWorktree)return{success:!1,error:"No worktree associated with this conversation"};const ce=_||X.baseBranch;try{const de=await gk({conversationId:C,commitMessage:R,baseBranch:ce,worktreePath:X.worktreePath,worktreeBranch:X.worktreeBranch,previewBranch:X.previewBranch});return de.success?(g.value===C&&(g.value=null),X.worktreePath=void 0,X.worktreeBranch=void 0,X.hasWorktree=!1,X.baseBranch=void 0,X.previewBranch=void 0,X.finalized=!0,X.updatedAt=new Date().toISOString(),Dt()):de.rebaseInProgress&&await Qn(C,X.worktreePath,ce||"main",R),de}catch(de){return{success:!1,error:de instanceof Error?de.message:String(de)}}}async function Cs(C,R){const _=s.value.find(ce=>ce.id===C);if(!_)return{success:!1,error:"Conversation not found"};if(!_.hasWorktree)return{success:!1,error:"No worktree associated with this conversation"};const X=R||_.baseBranch;try{const ce=await Ok({conversationId:C,baseBranch:X,worktreePath:_.worktreePath});return ce.rebaseInProgress?await Qn(C,_.worktreePath,X||"main","","sync"):ce.success&&(await $e(_),_.baseBranch=X,Dt()),ce}catch(ce){return{success:!1,error:ce instanceof Error?ce.message:String(ce)}}}async function Qn(C,R,_,X,ce="finalize"){O.value={conversationId:C,worktreePath:R,baseBranch:_,commitMessage:X,files:[],resolvedFiles:new Set,loading:!0,error:null,mode:ce,retryCount:0,strategy:"auto",chatMessages:[],userGuidance:"",lifecycleState:"detected"};try{const de=await vk(R);O.value&&(O.value.files=de.files,O.value.loading=!1,Ot("system",uk(de.files.length),"info"))}catch(de){O.value&&(O.value.error=de instanceof Error?de.message:String(de),O.value.loading=!1)}}function Ot(C,R,_="info",X){O.value&&O.value.chatMessages.push(ok(C,R,_,X))}function _r(C){O.value&&(O.value.userGuidance=C)}async function Fn(C,R){if(!O.value)return!1;try{const _=await bk({worktreePath:O.value.worktreePath,filePath:C,content:R});return _.success&&O.value&&O.value.resolvedFiles.add(C),_.success}catch{return!1}}async function ki(){if(!O.value)return{success:!1,error:"No conflict resolution in progress"};const{conversationId:C,commitMessage:R,baseBranch:_,mode:X,worktreePath:ce}=O.value;try{const de=s.value.find(fe=>fe.id===C),ae=await xk({mode:X,conversationId:C,commitMessage:R,baseBranch:_,worktreePath:ce,worktreeBranch:de?.worktreeBranch,previewBranch:de?.previewBranch});if(ae.success){if(X==="finalize"){g.value===C&&(g.value=null);const fe=s.value.find(rt=>rt.id===C);fe&&(fe.worktreePath=void 0,fe.worktreeBranch=void 0,fe.hasWorktree=!1,fe.baseBranch=void 0,fe.previewBranch=void 0,fe.finalized=!0,fe.updatedAt=new Date().toISOString(),Dt())}else if(X==="sync"){const fe=s.value.find(rt=>rt.id===C);fe&&(await $e(fe),fe.baseBranch=_,fe.updatedAt=new Date().toISOString(),Dt())}O.value=null}else ae.rebaseInProgress&&await Qn(C,ce,_,R,X);return ae}catch(de){return{success:!1,error:de instanceof Error?de.message:String(de)}}}async function Un(){if(!O.value)return!1;try{const C=await id(O.value.worktreePath);return O.value=null,C.success}catch{return O.value=null,!1}}async function Qs(C){if(!O.value)return!1;const R=O.value.files.find(_=>_.path===C);if(!R)return!1;try{const _=await yk({worktreePath:O.value.worktreePath,filePath:C,conflictContent:R.content,userGuidance:O.value.userGuidance||void 0});if(_.success&&_.resolvedContent!==void 0){R.content=_.resolvedContent;const X=await Fn(C,_.resolvedContent);return X?Ot("assistant",`Resolved: ${C}`,"success",C):Ot("assistant",`Failed to write resolved content for ${C}`,"error",C),X}return Ot("assistant",`Failed to resolve ${C}: ${_.error||"Unknown error"}`,"error",C),!1}catch(_){const X=_ instanceof Error?_.message:String(_);return Ot("assistant",`Error resolving ${C}: ${X}`,"error",C),!1}}async function Ps(){if(!O.value)return;const C=ck(O.value.files,O.value.resolvedFiles);if(C.length===0){Ot("system","All files are already resolved.","info");return}b=new AbortController;const R=b.signal;O.value.lifecycleState="resolving";const _=O.value.userGuidance;_&&Ot("user",_),Ot("system",hk(C.length),"info");let X=0,ce=0;const de=lk(C,3);for(const fe of de){if(!O.value||R.aborted)break;for(const at of fe)Ot("assistant",`Resolving: ${at.path}...`,"progress",at.path);const rt=await Promise.all(fe.map(at=>Qs(at.path)));for(const at of rt)at?X++:ce++}if(b=null,!O.value||R.aborted)return;const ae=ak(X,ce);O.value.lifecycleState=ae.succeeded?"resolved":"failed",Ot("system",ae.message,"summary")}async function Ir(){if(!O.value)return;b&&(b.abort(),b=null);const{conversationId:C,worktreePath:R,baseBranch:_,commitMessage:X,mode:ce}=O.value;Ot("system","Resolution cancelled. Resetting conflict state...","info");try{await id(R)}catch{}O.value=null,Ot("system","Conflict resolution aborted and reset.","info")}async function ar(C){const R=s.value.find(_=>_.id===C);if(!R)return{success:!1,error:"Conversation not found"};if(!R.hasWorktree||!R.worktreePath||!R.baseBranch)return{success:!1,error:"No worktree to preview"};try{const _=await dk({conversationId:C,worktreePath:R.worktreePath,baseBranch:R.baseBranch});return _.success&&_.previewBranch&&(R.previewBranch=_.previewBranch,g.value=C,R.updatedAt=new Date().toISOString(),Dt()),{success:_.success,error:_.error}}catch(_){return{success:!1,error:_ instanceof Error?_.message:String(_)}}}async function Gn(C){const R=s.value.find(_=>_.id===C);if(!R)return{success:!1,error:"Conversation not found"};if(!R.previewBranch||!R.baseBranch)return g.value=null,{success:!1,error:"No active preview"};try{const _=await fk({previewBranch:R.previewBranch,baseBranch:R.baseBranch});return _.success&&(R.previewBranch=void 0,g.value=null,R.updatedAt=new Date().toISOString(),Dt()),{success:_.success,error:_.error}}catch(_){return{success:!1,error:_ instanceof Error?_.message:String(_)}}}async function wi(C){const R=mk(g.value,C);if(R.kind==="end-current")return await Gn(R.id);if(R.kind==="swap"){const _=await Gn(R.endId);return _.success?await ar(R.startId):{success:!1,error:`Failed to end previous preview: ${_.error}`}}return await ar(R.id)}function Vr(C){const R=C.trim();if(!R)return null;const _=s.value.filter(X=>X.featureId===R?!0:X.worktreeBranch?.trim()===R);return _.length===0?null:_.sort((X,ce)=>new Date(ce.updatedAt).getTime()-new Date(X.updatedAt).getTime())[0]||null}function Si(C,R){const _=s.value.find(X=>X.id===C);_&&(_.title=R.trim(),_.updatedAt=new Date().toISOString(),cn(),Dt())}function Hn(C){const R=o.value;if(!R)return;const _=s.value.find(ce=>ce.id===R);if(!_||_.title!=="New Conversation")return;const X=_.messages.find(ce=>ce.role==="user");X&&(X.content.trim().length>0?_.title=cv(X.content):X.attachments&&X.attachments.length>0&&(_.title=X.attachments.length===1?"[Image] New Conversation":`[${X.attachments.length} Images] New Conversation`))}function Kn(){const C=s.value.length;return{atLimit:C>=Uh,nearLimit:C>=Fh,count:C}}async function Ts(C,R){o.value||await $s();const _=Sn(C,void 0,R);return Hn(),Ss(!0),_}function Ee(C,R,_){const X=_??o.value;ye(C,R,X??void 0),X&&or(X,!1)}function le(C,R){const _=R??o.value;Wt(C,{status:"complete"},_??void 0),_&&or(_,!0)}return{messages:S,session:Q,isPanelOpen:r,panelWidth:Ae(e),permissionMode:Ae(t),pendingPermission:L,pendingPlanApproval:D,cwd:Ae(n),lastError:G,debugEvents:oe,debugStreamEnabled:Ae(u),providerSessionId:j,conversations:Ae(s),archivedConversations:Ae(i),activeConversationId:Ae(o),conversationViewMode:Ae(a),conflictState:Ae(O),previewingConversationId:Ae(g),isStreaming:ie,hasMessages:V,lastMessage:Z,isActiveConversationStreaming:W,hasConversations:N,hasArchivedConversations:I,activeConversation:w,conversationCount:z,isNearStorageLimit:be,sortedConversations:K,sortedArchivedConversations:H,previewingConversation:re,streamingConversations:Ae(l),initialize:M,togglePanel:ue,openPanel:ne,closePanel:Ce,setPanelWidth:ve,setPermissionMode:E,setPendingPermission:B,clearPendingPermission:xe,setPendingPlanApproval:Re,clearPendingPlanApproval:Me,setCwd:Ze,setProviderSessionId:it,clearProviderSession:xr,getProviderSessionId:qn,updateWorktreeBranch:Nt,setConversationProviderSelection:on,startConversationStreaming:an,endConversationStreaming:jn,isConversationStreaming:U,addMessage:ln,addUserMessage:Sn,addAssistantMessage:Et,updateMessage:Wt,resetMessageForReplay:he,appendToMessage:ye,addToolToMessage:Be,updateToolInMessage:Ye,initContentBlocks:Ue,appendContentBlock:Ct,appendContentBlockWithSave:ir,updateBlockById:ot,updateBlockWithSave:Ft,findToolUseBlock:yr,batchSetMessageBlocks:Yn,syncContentFromBlocks:Io,setSessionStatus:Xr,startSession:hi,endSession:di,setSessionError:fi,setDebugStreamEnabled:pi,pushDebugEvent:mi,clearDebugEvents:gi,clearMessages:Oi,clearError:vi,loadConversations:bi,refreshServerConversations:xi,saveAllConversations:Dt,saveCurrentConversation:Ss,saveConversation:or,createConversation:$s,selectConversation:Cn,deleteConversation:un,archiveConversation:Pe,restoreArchivedConversation:Fe,deleteArchivedConversation:T,setConversationViewMode:ge,findConversationByFeature:Vr,syncConversationFeatureFromBranch:sr,renameConversation:Si,checkStorageLimits:Kn,finalizeConversation:yi,rebaseConversation:Cs,resolveConflictFile:Fn,continueRebase:ki,abortRebase:Un,aiResolveConflictFile:Qs,aiResolveAllConflicts:Ps,addConflictChatMessage:Ot,setConflictUserGuidance:_r,cancelConflictResolution:Ir,previewConversation:ar,unpreviewConversation:Gn,togglePreview:wi,isConversationPreviewing:Oe,addUserMessageWithConversation:Ts,appendToMessageWithSave:Ee,completeMessageWithSave:le}});function kk(r={}){const e=ml(),t=300,n=5e3,s=250;let i=null,o=null,a=null,l=null,c=null,u=!1,h=!1;const f=P(!1),p=P(!1);let g=r;function O(V){g=V}async function b(){const V=g.getScrollPosition?.()??0,Z=await e.checkAndRefresh();return Z&&g.setScrollPosition&&(await It(),g.setScrollPosition(V)),Z}function x(){return f.value||!!e.activeContextMenu||!!e.activeDialog}async function k(){if(x()){p.value=!0;return}S()}async function w(){if(u){h=!0;return}u=!0;try{await b()}finally{u=!1,h&&(h=!1,S())}}function S(){o&&clearTimeout(o),o=setTimeout(()=>{o=null,w()},s)}function Q(V){if(typeof window>"u")return;if(a&&a.readyState===WebSocket.OPEN){a.send(JSON.stringify({type:"watch",workingDirectory:V}));return}l&&(clearTimeout(l),l=null);const U=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/git-watcher-ws`;a=new WebSocket(U),a.onopen=()=>{a.send(JSON.stringify({type:"watch",workingDirectory:V}))},a.onmessage=W=>{try{JSON.parse(W.data).type==="git_changed"&&k()}catch{}},a.onclose=()=>{a=null,e.isPollingActive&&c&&(l=setTimeout(()=>{c&&Q(c)},n))},a.onerror=()=>{}}function L(){l&&(clearTimeout(l),l=null),a&&(a.close(),a=null)}function D(V){V&&(c=V),!e.isPollingActive&&(e.startPolling(),c&&Q(c))}function G(){L(),e.stopPolling()}function oe(){f.value=!0,i&&(clearTimeout(i),i=null)}function ie(){i&&clearTimeout(i),i=setTimeout(async()=>{f.value=!1,p.value&&(p.value=!1,S())},t)}function j(){G(),i&&(clearTimeout(i),i=null),o&&(clearTimeout(o),o=null),u=!1,h=!1,c=null}return ze(()=>[e.activeContextMenu,e.activeDialog],()=>{!e.activeContextMenu&&!e.activeDialog&&p.value&&!f.value&&(p.value=!1,S())}),{isUserInteracting:Ae(f),isDeferredRefresh:Ae(p),startPolling:D,stopPolling:G,startInteraction:oe,endInteraction:ie,cleanup:j,setScrollCallbacks:O}}function wk(r){function e(s){if((s.ctrlKey||s.metaKey)&&s.key==="h"){s.preventDefault(),r.onScrollToHead();return}if(s.key==="Escape"){s.preventDefault(),r.onEscape();return}}function t(){document.addEventListener("keydown",e)}function n(){document.removeEventListener("keydown",e)}return{start:t,stop:n}}function Sk(r){const e=P({visible:!1,branchName:"",loading:!1,error:null});async function t(){e.value.loading=!0,e.value.error=null;const K=await r.checkoutBranch(e.value.branchName);e.value.loading=!1,K.success?e.value.visible=!1:e.value.error=K.error||"Unknown error"}const n=P({visible:!1,fromCommit:"",loading:!1,error:null});async function s(K){n.value.loading=!0,n.value.error=null;const H=await r.createBranch(K.name,n.value.fromCommit);n.value.loading=!1,H.success?(K.checkout&&await r.checkoutBranch(K.name),n.value.visible=!1):n.value.error=H.error||"Unknown error"}const i=P({visible:!1,branchName:"",isLocal:!0,force:!1,loading:!1,error:null});async function o(K){i.value.loading=!0,i.value.error=null;const{branchName:H,isLocal:re}=i.value,Oe=K?.force??i.value.force,ge=re?await r.deleteLocalBranch(H,Oe):await r.deleteRemoteBranch(H);i.value.loading=!1,ge.success?i.value.visible=!1:i.value.error=ge.error||"Unknown error"}const a=P({visible:!1,branchName:"",newName:"",loading:!1,error:null});async function l(){if(!a.value.newName.trim()){a.value.error="Branch name is required";return}a.value.loading=!0,a.value.error=null;const K=await r.renameBranch(a.value.branchName,a.value.newName.trim());a.value.loading=!1,K.success?a.value.visible=!1:a.value.error=K.error||"Unknown error"}const c=P({visible:!1,branchName:"",loading:!1,error:null});async function u(K){c.value.loading=!0,c.value.error=null;const H=await r.mergeBranch(c.value.branchName,K);c.value.loading=!1,H.success?c.value.visible=!1:c.value.error=H.error||"Unknown error"}const h=P({visible:!1,branchName:"",loading:!1,error:null});async function f(){h.value.loading=!0,h.value.error=null;const K=await r.rebaseBranch(h.value.branchName);h.value.loading=!1,K.success?h.value.visible=!1:h.value.error=K.error||"Unknown error"}const p=P({visible:!1,branchName:"",loading:!1,error:null});async function g(K){p.value.loading=!0,p.value.error=null;const H=await r.pushBranch(p.value.branchName,K.remote,K.force,K.forceWithLease);p.value.loading=!1,H.success?p.value.visible=!1:p.value.error=H.error||"Unknown error"}const O=P({visible:!1,branchName:"",loading:!1,error:null});async function b(K){O.value.loading=!0,O.value.error=null;const H=await r.pullBranch(O.value.branchName,K.remote,K.noFastForward,K.squash);O.value.loading=!1,H.success?O.value.visible=!1:O.value.error=H.error||"Unknown error"}const x=P({visible:!1,commitHash:"",commitMessage:"",loading:!1,error:null});async function k(K){x.value.loading=!0,x.value.error=null;const H=await r.cherryPickCommit(x.value.commitHash,K.recordOrigin,K.noCommit);x.value.loading=!1,H.success?x.value.visible=!1:x.value.error=H.error||"Unknown error"}const w=P({visible:!1,commitHash:"",commitMessage:"",loading:!1,error:null});async function S(K){w.value.loading=!0,w.value.error=null;const H=await r.resetToCommit(w.value.commitHash,K.mode);w.value.loading=!1,H.success?w.value.visible=!1:w.value.error=H.error||"Unknown error"}const Q=P({visible:!1,commitHash:"",loading:!1,error:null});async function L(K){Q.value.loading=!0,Q.value.error=null;const H=await r.createTag(K.name,Q.value.commitHash,K.annotated,K.message,K.pushToRemote);Q.value.loading=!1,H.success?Q.value.visible=!1:Q.value.error=H.error||"Unknown error"}const D=P({visible:!1,tagName:"",loading:!1,error:null});async function G(K){D.value.loading=!0,D.value.error=null;const H=await r.deleteTag(D.value.tagName,K.deleteFromRemote?K.remote||"origin":void 0);D.value.loading=!1,H.success?D.value.visible=!1:D.value.error=H.error||"Unknown error"}const oe=P({visible:!1,tagName:"",loading:!1,tagDetail:null}),ie=P({visible:!1,loading:!1,error:null});async function j(K){ie.value.loading=!0,ie.value.error=null;const H=await r.stashChanges(K.message,K.includeUntracked);ie.value.loading=!1,H.success?ie.value.visible=!1:ie.value.error=H.error||"Unknown error"}const V=P({visible:!1,stashIndex:0,loading:!1,error:null}),Z=P("");async function U(K){V.value.loading=!0,V.value.error=null;const H=await r.stashBranch(V.value.stashIndex,K);V.value.loading=!1,H.success?V.value.visible=!1:V.value.error=H.error||"Unknown error"}const W=P({visible:!1,loading:!1,error:null});async function N(K){W.value.loading=!0,W.value.error=null;const H=await r.resetWorking(K.mode);W.value.loading=!1,H.success?W.value.visible=!1:W.value.error=H.error||"Unknown error"}const I=P({visible:!1,loading:!1,error:null});async function z(){I.value.loading=!0,I.value.error=null;const K=await r.cleanUntracked();I.value.loading=!1,K.success?I.value.visible=!1:I.value.error=K.error||"Unknown error"}const be=J(()=>e.value.visible||n.value.visible||i.value.visible||a.value.visible||c.value.visible||h.value.visible||p.value.visible||O.value.visible||x.value.visible||w.value.visible||Q.value.visible||D.value.visible||oe.value.visible||ie.value.visible||V.value.visible||W.value.visible||I.value.visible);return{checkoutDialog:e,confirmCheckout:t,createBranchDialog:n,confirmCreateBranch:s,deleteBranchDialog:i,confirmDeleteBranch:o,renameDialog:a,confirmRenameBranch:l,mergeDialog:c,confirmMerge:u,rebaseDialog:h,confirmRebase:f,pushDialog:p,confirmPush:g,pullDialog:O,confirmPull:b,cherryPickDialog:x,confirmCherryPick:k,resetDialog:w,confirmReset:S,tagCreateDialog:Q,confirmTagCreate:L,tagDeleteDialog:D,confirmTagDelete:G,tagDetailDialog:oe,stashDialog:ie,confirmStash:j,stashBranchDialog:V,stashBranchInput:Z,confirmStashBranch:U,resetWorkingDialog:W,confirmResetWorking:N,cleanUntrackedDialog:I,confirmCleanUntracked:z,isAnyDialogOpen:be}}function $k(r,e){const t=P({visible:!1,x:0,y:0});function n(q,ve){t.value={visible:!0,x:q,y:ve},setTimeout(()=>{t.value.visible=!1},1500)}const s=P({visible:!1,branch:"",x:0,y:0,isCurrentBranch:!1,isLocal:!0,commitHash:""});function i(q){s.value={visible:!0,...q},r.setActiveContextMenu({type:"branch",props:q,position:{x:q.x,y:q.y}})}function o(){s.value.visible=!1,r.clearActiveContextMenu()}function a(){o(),e.checkoutDialog.value={visible:!0,branchName:s.value.branch,loading:!1,error:null}}function l(){const q=s.value.branch;o(),e.renameDialog.value={visible:!0,branchName:q,newName:q,loading:!1,error:null}}function c(){const{branch:q,isLocal:ve}=s.value;o(),e.deleteBranchDialog.value={visible:!0,branchName:q,isLocal:ve,force:!1,loading:!1,error:null}}function u(){const q=s.value.branch;o(),e.mergeDialog.value={visible:!0,branchName:q,loading:!1,error:null}}function h(){const q=s.value.branch;o(),e.rebaseDialog.value={visible:!0,branchName:q,loading:!1,error:null}}function f(){const q=s.value.branch;o(),e.pushDialog.value={visible:!0,branchName:q,loading:!1,error:null}}function p(){const q=s.value.branch;o(),e.pullDialog.value={visible:!0,branchName:q,loading:!1,error:null}}async function g(){const q=s.value.branch;o(),await r.fetchBranch(q)}async function O(){const{branch:q,x:ve,y:Ze}=s.value;o(),(await r.copyToClipboard(q)).success&&n(ve,Ze)}function b(){o(),e.createBranchDialog.value={visible:!0,fromCommit:s.value.commitHash,loading:!1,error:null}}const x=P({visible:!1,commit:null,x:0,y:0});function k(q){x.value={visible:!0,commit:q.commit,x:q.x,y:q.y},r.setActiveContextMenu({type:"commit",props:q,position:{x:q.x,y:q.y}})}function w(){x.value.visible=!1,r.clearActiveContextMenu()}function S(q){return q===!1?!1:typeof q=="object"&&q!==null&&"success"in q?!!q.success:!0}function Q(q){const ve=x.value.commit;if(!ve)return!1;w();const Ze=q(ve);return Ze&&typeof Ze.then=="function"?Ze.then(S).catch(()=>!1):S(Ze)}function L(){Q(q=>{e.tagCreateDialog.value={visible:!0,commitHash:q.hash,loading:!1,error:null}})}function D(){Q(q=>{e.createBranchDialog.value={visible:!0,fromCommit:q.hash,loading:!1,error:null}})}function G(){Q(q=>{e.checkoutDialog.value={visible:!0,branchName:q.hash,loading:!1,error:null}})}function oe(){Q(q=>{e.cherryPickDialog.value={visible:!0,commitHash:q.hash,commitMessage:q.message,loading:!1,error:null}})}async function ie(){await Q(q=>r.revertCommit(q.hash))}function j(){Q(q=>{e.mergeDialog.value={visible:!0,branchName:q.shortHash,loading:!1,error:null}})}function V(){Q(q=>{e.resetDialog.value={visible:!0,commitHash:q.hash,commitMessage:q.message,loading:!1,error:null}})}async function Z(){const{x:q,y:ve}=x.value;await Q(it=>r.copyToClipboard(it.hash))&&n(q,ve)}async function U(){const{x:q,y:ve}=x.value;await Q(it=>r.copyCommitSubject(it))&&n(q,ve)}const W=P({visible:!1,tag:"",x:0,y:0,commitHash:""});function N(q){W.value={visible:!0,...q},r.setActiveContextMenu({type:"tag",props:q,position:{x:q.x,y:q.y}})}function I(){W.value.visible=!1,r.clearActiveContextMenu()}async function z(){const q=W.value.tag;I(),e.tagDetailDialog.value={visible:!0,tagName:q,loading:!0,tagDetail:null};const ve=await r.getTagDetail(q);e.tagDetailDialog.value.loading=!1,ve.success&&ve.data&&(e.tagDetailDialog.value.tagDetail=ve.data)}function be(){const q=W.value.tag;I(),e.tagDeleteDialog.value={visible:!0,tagName:q,loading:!1,error:null}}async function K(){const q=W.value.tag;I(),await r.pushTag(q)}async function H(){const{tag:q,x:ve,y:Ze}=W.value;I(),(await r.copyToClipboard(q)).success&&n(ve,Ze)}const re=P({visible:!1,x:0,y:0});function Oe(q){re.value={visible:!0,...q},r.setActiveContextMenu({type:"uncommitted",props:q,position:{x:q.x,y:q.y}})}function ge(){re.value.visible=!1,r.clearActiveContextMenu()}function $e(){ge(),e.stashDialog.value={visible:!0,loading:!1,error:null}}function Pe(){ge(),e.resetWorkingDialog.value={visible:!0,loading:!1,error:null}}function Fe(){ge(),e.cleanUntrackedDialog.value={visible:!0,loading:!1,error:null}}const T=P({visible:!1,stash:null,x:0,y:0});function M(q){T.value={visible:!0,stash:q.stash,x:q.x,y:q.y},r.setActiveContextMenu({type:"stash",props:q,position:{x:q.x,y:q.y}})}function E(){T.value.visible=!1,r.clearActiveContextMenu()}function B(q){const ve=T.value.stash;if(!ve)return!1;E();const Ze=q(ve);return Ze&&typeof Ze.then=="function"?Ze.then(S).catch(()=>!1):S(Ze)}async function xe(){await B(q=>r.applyStash(q.index))}async function Re(){await B(q=>r.popStash(q.index))}async function Me(){await B(q=>r.dropStash(q.index))}function ue(){B(q=>{e.stashBranchDialog.value={visible:!0,stashIndex:q.index,loading:!1,error:null}})}async function ne(){const{x:q,y:ve}=T.value;await B(it=>r.copyToClipboard(`stash@{${it.index}}`))&&n(q,ve)}async function Ce(){const{x:q,y:ve}=T.value;await B(it=>r.copyToClipboard(it.hash))&&n(q,ve)}return{copyFeedback:t,showCopyFeedback:n,branchMenu:s,handleBranchContextMenu:i,closeBranchMenu:o,handleBranchCheckout:a,handleBranchRename:l,handleBranchDelete:c,handleBranchMerge:u,handleBranchRebase:h,handleBranchPush:f,handleBranchPull:p,handleBranchFetch:g,handleBranchCopyName:O,handleBranchCreateBranch:b,commitMenu:x,handleCommitContextMenu:k,closeCommitMenu:w,handleCommitAddTag:L,handleCommitCreateBranch:D,handleCommitCheckout:G,handleCommitCherryPick:oe,handleCommitRevert:ie,handleCommitMergeInto:j,handleCommitReset:V,handleCommitCopyHash:Z,handleCommitCopySubject:U,tagMenu:W,handleTagContextMenu:N,closeTagMenu:I,handleTagViewDetails:z,handleTagDelete:be,handleTagPush:K,handleTagCopyName:H,uncommittedMenu:re,handleUncommittedContextMenu:Oe,closeUncommittedMenu:ge,handleUncommittedStash:$e,handleUncommittedReset:Pe,handleUncommittedClean:Fe,stashMenu:T,handleStashContextMenu:M,closeStashMenu:E,handleStashApply:xe,handleStashPop:Re,handleStashDrop:Me,handleStashCreateBranch:ue,handleStashCopyName:ne,handleStashCopyHash:Ce}}const Ck={class:"w-full max-w-md mx-4 bg-retro-dark border border-retro-border rounded-lg shadow-xl"},Qk={class:"flex items-center justify-between px-4 py-3 border-b border-retro-border"},Pk={class:"text-sm font-mono text-retro-text"},Tk={class:"p-4"},Mk={key:0,class:"mb-3 p-2 text-xs font-mono text-retro-red bg-retro-red/10 border border-retro-red/30 rounded"},Ak={class:"flex justify-end gap-2 px-4 py-3 border-t border-retro-border"},_k=["disabled"],Rk=["disabled"],Bt=Ve({__name:"GitDialog",props:{title:{},visible:{type:Boolean},loading:{type:Boolean,default:!1},error:{default:null},confirmLabel:{default:"Confirm"},confirmDanger:{type:Boolean,default:!1},cancelLabel:{default:"Cancel"}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e;function s(i){i.key==="Escape"&&n("close"),i.key==="Enter"&&!t.loading&&(i.preventDefault(),n("confirm"))}return ze(()=>t.visible,i=>{i?document.addEventListener("keydown",s):document.removeEventListener("keydown",s)}),wt(()=>{document.removeEventListener("keydown",s)}),(i,o)=>(v(),pe(Pr,{to:"body"},[ee(On,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ut(()=>[r.visible?(v(),y("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",role:"dialog","aria-modal":"true",onClick:o[3]||(o[3]=kr(a=>n("close"),["self"]))},[d("div",Ck,[d("div",Qk,[d("h3",Pk,A(r.title),1),d("button",{type:"button",class:"p-1 rounded text-retro-muted hover:text-retro-text hover:bg-retro-panel transition-colors",title:"Close",onClick:o[0]||(o[0]=a=>n("close"))},[ee(m(St),{class:"h-4 w-4"})])]),d("div",Tk,[r.error?(v(),y("div",Mk,A(r.error),1)):F("",!0),Hm(i.$slots,"default")]),d("div",Ak,[d("button",{type:"button",class:"px-3 py-1.5 text-xs font-mono text-retro-muted hover:text-retro-text bg-retro-panel hover:bg-retro-border rounded transition-colors",disabled:r.loading,onClick:o[1]||(o[1]=a=>n("close"))},A(r.cancelLabel),9,_k),d("button",{type:"button",class:_e(["px-3 py-1.5 text-xs font-mono rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",[r.confirmDanger?"text-retro-red bg-retro-red/10 border border-retro-red/30 hover:bg-retro-red/20":"text-retro-black bg-retro-cyan hover:bg-retro-cyan/80"]]),disabled:r.loading,onClick:o[2]||(o[2]=a=>n("confirm"))},A(r.loading?"Loading...":r.confirmLabel),11,Rk)])])])):F("",!0)]),_:3})]))}}),Bk={class:"text-retro-text text-sm font-mono mb-4"},Zk={class:"text-retro-cyan"},Ek={class:"space-y-3"},Dk={class:"flex items-center gap-2 cursor-pointer"},Lk={class:"flex items-center gap-2 cursor-pointer"},Xk={class:"flex items-center gap-2 cursor-pointer"},Ik=Ve({__name:"MergeDialog",props:{visible:{type:Boolean},branchName:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e,s=P(!1),i=P(!1),o=P(!1);function a(){n("confirm",{noCommit:s.value,noFastForward:i.value,squash:o.value})}return ze(()=>t.visible,l=>{l&&(s.value=!1,i.value=!1,o.value=!1)}),(l,c)=>(v(),pe(Bt,{title:"Merge Branch",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Merge",onClose:c[3]||(c[3]=u=>n("close")),onConfirm:a},{default:ut(()=>[d("p",Bk,[c[4]||(c[4]=Ie(" Merge ",-1)),d("span",Zk,A(r.branchName),1),c[5]||(c[5]=Ie(" into current branch ",-1))]),d("div",Ek,[d("label",Dk,[je(d("input",{"onUpdate:modelValue":c[0]||(c[0]=u=>Je(s)?s.value=u:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(s)]]),c[6]||(c[6]=d("span",{class:"text-retro-muted text-sm"},"No commit (stage changes only)",-1))]),d("label",Lk,[je(d("input",{"onUpdate:modelValue":c[1]||(c[1]=u=>Je(i)?i.value=u:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(i)]]),c[7]||(c[7]=d("span",{class:"text-retro-muted text-sm"},"No fast-forward (always create merge commit)",-1))]),d("label",Xk,[je(d("input",{"onUpdate:modelValue":c[2]||(c[2]=u=>Je(o)?o.value=u:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(o)]]),c[8]||(c[8]=d("span",{class:"text-retro-muted text-sm"},"Squash (combine all commits into one)",-1))])])]),_:1},8,["visible","loading","error"]))}}),Vk={class:"text-retro-text text-sm font-mono mb-2"},zk={class:"text-retro-cyan"},Nk={class:"space-y-3 mt-4"},Wk={class:"flex items-center gap-2 cursor-pointer"},qk=Ve({__name:"DeleteBranchDialog",props:{visible:{type:Boolean},branchName:{},isLocal:{type:Boolean},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e,s=P(!1);function i(){n("confirm",{force:s.value})}return ze(()=>t.visible,o=>{o&&(s.value=!1)}),(o,a)=>(v(),pe(Bt,{title:"Delete Branch",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Delete","confirm-danger":!0,onClose:a[1]||(a[1]=l=>n("close")),onConfirm:i},{default:ut(()=>[a[4]||(a[4]=d("div",{class:"mb-4 p-2 text-xs font-mono text-retro-yellow bg-retro-yellow/10 border border-retro-yellow/30 rounded"}," This action is permanent and cannot be undone. ",-1)),d("p",Vk,[Ie(" Delete "+A(r.isLocal?"local":"remote")+" branch ",1),d("span",zk,A(r.branchName),1),a[2]||(a[2]=Ie("? ",-1))]),d("div",Nk,[d("label",Wk,[je(d("input",{"onUpdate:modelValue":a[0]||(a[0]=l=>Je(s)?s.value=l:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(s)]]),a[3]||(a[3]=d("span",{class:"text-retro-muted text-sm"},"Force delete (even if not fully merged)",-1))])])]),_:1},8,["visible","loading","error"]))}}),jk={class:"text-retro-text text-sm font-mono mb-4"},Yk={class:"text-retro-cyan"},Fk={class:"space-y-3"},Uk=["value"],Gk={class:"flex items-center gap-2 cursor-pointer"},Hk=["checked"],Kk={class:"flex items-center gap-2 cursor-pointer"},Jk=["checked"],ew={key:0,class:"p-2 text-xs font-mono text-retro-yellow bg-retro-yellow/10 border border-retro-yellow/30 rounded"},tw=Ve({__name:"PushDialog",props:{visible:{type:Boolean},branchName:{},remotes:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e,s=P("origin"),i=P(!1),o=P(!1);function a(u){i.value=u,u&&(o.value=!1)}function l(u){o.value=u,u&&(i.value=!1)}function c(){n("confirm",{remote:s.value,force:i.value,forceWithLease:o.value})}return ze(()=>t.visible,u=>{u&&(s.value=t.remotes.includes("origin")?"origin":t.remotes[0]??"origin",i.value=!1,o.value=!1)}),(u,h)=>(v(),pe(Bt,{title:"Push Branch",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Push",onClose:h[3]||(h[3]=f=>n("close")),onConfirm:c},{default:ut(()=>[d("p",jk,[h[4]||(h[4]=Ie(" Push ",-1)),d("span",Yk,A(r.branchName),1),h[5]||(h[5]=Ie(" to remote ",-1))]),d("div",Fk,[d("div",null,[h[6]||(h[6]=d("label",{class:"text-retro-muted text-sm block mb-1"},"Remote",-1)),je(d("select",{"onUpdate:modelValue":h[0]||(h[0]=f=>Je(s)?s.value=f:null),class:"w-full bg-retro-panel border border-retro-border rounded text-retro-text text-sm px-2 py-1.5 font-mono focus:outline-none focus:border-retro-cyan"},[(v(!0),y(we,null,Ne(r.remotes,f=>(v(),y("option",{key:f,value:f},A(f),9,Uk))),128))],512),[[ks,m(s)]])]),d("label",Gk,[d("input",{checked:m(i),type:"checkbox",class:"accent-retro-cyan",onChange:h[1]||(h[1]=f=>a(f.target.checked))},null,40,Hk),h[7]||(h[7]=d("span",{class:"text-retro-muted text-sm"},"Force push",-1))]),d("label",Kk,[d("input",{checked:m(o),type:"checkbox",class:"accent-retro-cyan",onChange:h[2]||(h[2]=f=>l(f.target.checked))},null,40,Jk),h[8]||(h[8]=d("span",{class:"text-retro-muted text-sm"},"Force with lease (safer force push)",-1))]),m(i)||m(o)?(v(),y("div",ew,A(m(i)?"Force push will overwrite remote history. Use with caution.":"Force with lease will reject the push if the remote has been updated since your last fetch."),1)):F("",!0)])]),_:1},8,["visible","loading","error"]))}}),rw={class:"text-retro-text text-sm font-mono mb-4"},nw={class:"text-retro-cyan"},sw={class:"space-y-3"},iw=["value"],ow={class:"flex items-center gap-2 cursor-pointer"},aw={class:"flex items-center gap-2 cursor-pointer"},lw=Ve({__name:"PullDialog",props:{visible:{type:Boolean},branchName:{},remotes:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e,s=P("origin"),i=P(!1),o=P(!1);function a(){n("confirm",{remote:s.value,noFastForward:i.value,squash:o.value})}return ze(()=>t.visible,l=>{l&&(s.value=t.remotes.includes("origin")?"origin":t.remotes[0]??"origin",i.value=!1,o.value=!1)}),(l,c)=>(v(),pe(Bt,{title:"Pull Branch",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Pull",onClose:c[3]||(c[3]=u=>n("close")),onConfirm:a},{default:ut(()=>[d("p",rw,[c[4]||(c[4]=Ie(" Pull ",-1)),d("span",nw,A(r.branchName),1),c[5]||(c[5]=Ie(" from remote ",-1))]),d("div",sw,[d("div",null,[c[6]||(c[6]=d("label",{class:"text-retro-muted text-sm block mb-1"},"Remote",-1)),je(d("select",{"onUpdate:modelValue":c[0]||(c[0]=u=>Je(s)?s.value=u:null),class:"w-full bg-retro-panel border border-retro-border rounded text-retro-text text-sm px-2 py-1.5 font-mono focus:outline-none focus:border-retro-cyan"},[(v(!0),y(we,null,Ne(r.remotes,u=>(v(),y("option",{key:u,value:u},A(u),9,iw))),128))],512),[[ks,m(s)]])]),d("label",ow,[je(d("input",{"onUpdate:modelValue":c[1]||(c[1]=u=>Je(i)?i.value=u:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(i)]]),c[7]||(c[7]=d("span",{class:"text-retro-muted text-sm"},"No fast-forward (always create merge commit)",-1))]),d("label",aw,[je(d("input",{"onUpdate:modelValue":c[2]||(c[2]=u=>Je(o)?o.value=u:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(o)]]),c[8]||(c[8]=d("span",{class:"text-retro-muted text-sm"},"Squash (combine all commits into one)",-1))])])]),_:1},8,["visible","loading","error"]))}}),cw={class:"text-retro-text text-sm font-mono mb-4"},uw={class:"text-retro-cyan"},hw={class:"text-retro-cyan"},dw={class:"p-2 text-xs font-mono text-retro-yellow bg-retro-yellow/10 border border-retro-yellow/30 rounded"},fw={class:"text-retro-cyan"},mw={class:"text-retro-cyan"},pw=Ve({__name:"RebaseDialog",props:{visible:{type:Boolean},branchName:{},ontoBranch:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=e;return(n,s)=>(v(),pe(Bt,{title:"Rebase Branch",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Rebase",onClose:s[0]||(s[0]=i=>t("close")),onConfirm:s[1]||(s[1]=i=>t("confirm"))},{default:ut(()=>[d("p",cw,[s[2]||(s[2]=Ie(" Rebase ",-1)),d("span",uw,A(r.branchName),1),s[3]||(s[3]=Ie(" onto ",-1)),d("span",hw,A(r.ontoBranch),1)]),d("div",dw,[s[4]||(s[4]=Ie(" This will rewrite commit history. Commits from ",-1)),d("span",fw,A(r.branchName),1),s[5]||(s[5]=Ie(" will be replayed on top of ",-1)),d("span",mw,A(r.ontoBranch),1),s[6]||(s[6]=Ie(". ",-1))])]),_:1},8,["visible","loading","error"]))}}),gw={class:"mb-4 p-3 bg-retro-panel border border-retro-border rounded"},Ow={class:"text-sm font-mono text-retro-cyan"},vw={class:"text-xs font-mono text-retro-text mt-1 truncate"},bw={class:"space-y-3"},xw={class:"flex items-start gap-2 cursor-pointer group"},yw={class:"flex items-start gap-2 cursor-pointer group"},kw=Ve({__name:"CherryPickDialog",props:{visible:{type:Boolean},commitHash:{},commitMessage:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=e,n=P(!1),s=P(!1);function i(){t("confirm",{recordOrigin:n.value,noCommit:s.value})}function o(){n.value=!1,s.value=!1,t("close")}return(a,l)=>(v(),pe(Bt,{title:"Cherry-Pick Commit",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Cherry-Pick",onClose:o,onConfirm:i},{default:ut(()=>[d("div",gw,[l[2]||(l[2]=d("div",{class:"text-xs font-mono text-retro-muted mb-1"},"Commit",-1)),d("div",Ow,A(r.commitHash.slice(0,7)),1),d("div",vw,A(r.commitMessage.split(`
10
10
  `)[0]),1)]),d("div",bw,[d("label",xw,[je(d("input",{"onUpdate:modelValue":l[0]||(l[0]=c=>Je(n)?n.value=c:null),type:"checkbox",class:"mt-0.5 accent-retro-cyan"},null,512),[[Or,m(n)]]),l[3]||(l[3]=d("div",null,[d("span",{class:"text-sm font-mono text-retro-text group-hover:text-retro-cyan transition-colors"}," Record origin (-x) "),d("p",{class:"text-xs font-mono text-retro-muted mt-0.5"},' Append "(cherry picked from commit ...)" to the commit message ')],-1))]),d("label",yw,[je(d("input",{"onUpdate:modelValue":l[1]||(l[1]=c=>Je(s)?s.value=c:null),type:"checkbox",class:"mt-0.5 accent-retro-cyan"},null,512),[[Or,m(s)]]),l[4]||(l[4]=d("div",null,[d("span",{class:"text-sm font-mono text-retro-text group-hover:text-retro-cyan transition-colors"}," No commit "),d("p",{class:"text-xs font-mono text-retro-muted mt-0.5"}," Apply changes to the working directory without committing ")],-1))])])]),_:1},8,["visible","loading","error"]))}}),ww={class:"mb-4 p-3 bg-retro-panel border border-retro-border rounded"},Sw={class:"text-sm font-mono text-retro-cyan"},$w={class:"text-xs font-mono text-retro-text mt-1 truncate"},Cw={class:"space-y-2"},Qw=["value"],Pw={key:0,class:"mt-3 p-2 text-xs font-mono text-retro-red bg-retro-red/10 border border-retro-red/30 rounded"},Tw=Ve({__name:"ResetDialog",props:{visible:{type:Boolean},commitHash:{},commitMessage:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=e,n=P("mixed"),s=[{value:"soft",label:"Soft",description:"Move HEAD, keep staged changes and working directory"},{value:"mixed",label:"Mixed",description:"Move HEAD, reset staging area, keep working directory"},{value:"hard",label:"Hard",description:"Move HEAD, reset staging area and working directory (DESTRUCTIVE)"}];function i(){t("confirm",{mode:n.value})}function o(){n.value="mixed",t("close")}return(a,l)=>(v(),pe(Bt,{title:"Reset to Commit",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Reset","confirm-danger":m(n)==="hard",onClose:o,onConfirm:i},{default:ut(()=>[d("div",ww,[l[1]||(l[1]=d("div",{class:"text-xs font-mono text-retro-muted mb-1"},"Reset to",-1)),d("div",Sw,A(r.commitHash.slice(0,7)),1),d("div",$w,A(r.commitMessage.split(`
11
11
  `)[0]),1)]),d("div",Cw,[l[2]||(l[2]=d("div",{class:"text-xs font-mono text-retro-muted mb-2"},"Reset mode",-1)),(v(),y(we,null,Ne(s,c=>d("label",{key:c.value,class:_e(["flex items-start gap-2 p-2 rounded cursor-pointer group border transition-colors",[m(n)===c.value?"border-retro-cyan bg-retro-cyan/5":"border-transparent hover:bg-retro-panel"]])},[je(d("input",{"onUpdate:modelValue":l[0]||(l[0]=u=>Je(n)?n.value=u:null),type:"radio",name:"reset-mode",value:c.value,class:"mt-0.5 accent-retro-cyan"},null,8,Qw),[[Sc,m(n)]]),d("div",null,[d("span",{class:_e(["text-sm font-mono transition-colors",[c.value==="hard"?"text-retro-red":"text-retro-text",m(n)===c.value?"text-retro-cyan":""]])},A(c.label),3),d("p",{class:_e(["text-xs font-mono mt-0.5",c.value==="hard"?"text-retro-red/70":"text-retro-muted"])},A(c.description),3)])],2)),64))]),m(n)==="hard"?(v(),y("div",Pw," Warning: Hard reset will permanently discard all uncommitted changes in your working directory and staging area. This action cannot be undone. ")):F("",!0)]),_:1},8,["visible","loading","error","confirm-danger"]))}}),Mw={class:"mb-4 p-3 bg-retro-panel border border-retro-border rounded"},Aw={class:"text-sm font-mono text-retro-cyan"},_w={class:"mb-4"},Rw={class:"mb-3"},Bw={class:"flex items-start gap-2 cursor-pointer group"},Zw={key:0,class:"mb-4"},Ew={class:"space-y-2"},Dw={class:"flex items-start gap-2 cursor-pointer group"},Lw=["disabled"],Xw={key:0,class:"ml-6"},Iw=["value"],Vw=Ve({__name:"TagCreateDialog",props:{visible:{type:Boolean},commitHash:{},remotes:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=e,n=P(""),s=P(!1),i=P(""),o=P(!1),a=P(""),l=J(()=>n.value.trim().length>0);function c(){if(!l.value)return;const h={name:n.value.trim(),annotated:s.value};s.value&&i.value.trim()&&(h.message=i.value.trim()),o.value&&a.value&&(h.pushToRemote=a.value),t("confirm",h)}function u(){n.value="",s.value=!1,i.value="",o.value=!1,a.value="",t("close")}return ze(()=>s.value,h=>{h||(i.value="")}),(h,f)=>(v(),pe(Bt,{title:"Create Tag",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Create Tag",onClose:u,onConfirm:c},{default:ut(()=>[d("div",Mw,[f[5]||(f[5]=d("div",{class:"text-xs font-mono text-retro-muted mb-1"},"At commit",-1)),d("div",Aw,A(r.commitHash.slice(0,7)),1)]),d("div",_w,[f[6]||(f[6]=d("label",{class:"block text-xs font-mono text-retro-muted mb-1.5"},"Tag name",-1)),je(d("input",{"onUpdate:modelValue":f[0]||(f[0]=p=>Je(n)?n.value=p:null),type:"text",placeholder:"v1.0.0",class:"w-full px-3 py-2 text-sm bg-retro-panel border border-retro-border rounded text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan"},null,512),[[Rt,m(n)]])]),d("div",Rw,[d("label",Bw,[je(d("input",{"onUpdate:modelValue":f[1]||(f[1]=p=>Je(s)?s.value=p:null),type:"checkbox",class:"mt-0.5 accent-retro-cyan"},null,512),[[Or,m(s)]]),f[7]||(f[7]=d("div",null,[d("span",{class:"text-sm font-mono text-retro-text group-hover:text-retro-cyan transition-colors"}," Annotated tag "),d("p",{class:"text-xs font-mono text-retro-muted mt-0.5"}," Create a full tag object with message and tagger info ")],-1))])]),m(s)?(v(),y("div",Zw,[f[8]||(f[8]=d("label",{class:"block text-xs font-mono text-retro-muted mb-1.5"},"Tag message",-1)),je(d("textarea",{"onUpdate:modelValue":f[2]||(f[2]=p=>Je(i)?i.value=p:null),rows:"3",placeholder:"Release description...",class:"w-full px-3 py-2 text-sm bg-retro-panel border border-retro-border rounded text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan resize-none"},null,512),[[Rt,m(i)]])])):F("",!0),d("div",Ew,[d("label",Dw,[je(d("input",{"onUpdate:modelValue":f[3]||(f[3]=p=>Je(o)?o.value=p:null),type:"checkbox",class:"mt-0.5 accent-retro-cyan",disabled:r.remotes.length===0},null,8,Lw),[[Or,m(o)]]),d("div",null,[d("span",{class:_e(["text-sm font-mono transition-colors",r.remotes.length===0?"text-retro-muted":"text-retro-text group-hover:text-retro-cyan"])}," Push to remote ",2)])]),m(o)&&r.remotes.length>0?(v(),y("div",Xw,[je(d("select",{"onUpdate:modelValue":f[4]||(f[4]=p=>Je(a)?a.value=p:null),class:"w-full px-3 py-2 text-sm bg-retro-panel border border-retro-border rounded text-retro-text focus:outline-none focus:border-retro-cyan"},[f[9]||(f[9]=d("option",{value:"",disabled:"",class:"text-retro-muted"},"Select remote",-1)),(v(!0),y(we,null,Ne(r.remotes,p=>(v(),y("option",{key:p,value:p},A(p),9,Iw))),128))],512),[[ks,m(a)]])])):F("",!0)])]),_:1},8,["visible","loading","error"]))}}),zw={class:"text-retro-text text-sm font-mono mb-2"},Nw={class:"text-retro-cyan"},Ww={class:"space-y-3 mt-4"},qw={class:"flex items-center gap-2 cursor-pointer"},jw={key:0,class:"ml-6"},Yw=["value"],Fw=Ve({__name:"TagDeleteDialog",props:{visible:{type:Boolean},tagName:{},remotes:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e,s=P(!1),i=P("origin");function o(){n("confirm",{deleteFromRemote:s.value,remote:s.value?i.value:void 0})}return ze(()=>t.visible,a=>{a&&(s.value=!1,i.value=t.remotes.includes("origin")?"origin":t.remotes[0]??"origin")}),(a,l)=>(v(),pe(Bt,{title:"Delete Tag",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Delete","confirm-danger":!0,onClose:l[2]||(l[2]=c=>n("close")),onConfirm:o},{default:ut(()=>[l[7]||(l[7]=d("div",{class:"mb-4 p-2 text-xs font-mono text-retro-yellow bg-retro-yellow/10 border border-retro-yellow/30 rounded"}," This action is permanent and cannot be undone. ",-1)),d("p",zw,[l[3]||(l[3]=Ie(" Delete tag ",-1)),d("span",Nw,A(r.tagName),1),l[4]||(l[4]=Ie("? ",-1))]),d("div",Ww,[d("label",qw,[je(d("input",{"onUpdate:modelValue":l[0]||(l[0]=c=>Je(s)?s.value=c:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(s)]]),l[5]||(l[5]=d("span",{class:"text-retro-muted text-sm"},"Also delete from remote",-1))]),m(s)?(v(),y("div",jw,[l[6]||(l[6]=d("label",{class:"block text-retro-muted text-xs font-mono mb-1"},"Remote",-1)),je(d("select",{"onUpdate:modelValue":l[1]||(l[1]=c=>Je(i)?i.value=c:null),class:"w-full px-2 py-1.5 text-sm font-mono bg-retro-panel border border-retro-border rounded text-retro-text focus:outline-none focus:border-retro-cyan"},[(v(!0),y(we,null,Ne(r.remotes,c=>(v(),y("option",{key:c,value:c},A(c),9,Yw))),128))],512),[[ks,m(i)]])])):F("",!0)])]),_:1},8,["visible","loading","error"]))}}),Uw={class:"mb-4"},Gw={class:"text-retro-cyan text-sm font-mono"},Hw={class:"mb-4"},Kw={class:"text-retro-text text-sm font-mono"},Jw={class:"mb-4"},eS={class:"text-retro-text text-sm font-mono break-all select-all"},tS={class:"mb-4"},rS={class:"text-retro-text text-sm font-mono"},nS={class:"text-retro-muted"},sS={class:"mb-4"},iS={class:"text-retro-text text-sm font-mono"},oS={key:1,class:"mb-2"},aS={class:"p-2 text-sm font-mono text-retro-text bg-retro-panel border border-retro-border rounded whitespace-pre-wrap"},lS={key:1,class:"text-retro-muted text-sm font-mono text-center py-4"},cS=Ve({__name:"TagDetailDialog",props:{visible:{type:Boolean},tagName:{},tagDetail:{},loading:{type:Boolean,default:!1}},emits:["close"],setup(r,{emit:e}){const t=e;return(n,s)=>(v(),pe(Bt,{title:"Tag Details",visible:r.visible,loading:r.loading,"confirm-label":"Close","cancel-label":"Close",onClose:s[0]||(s[0]=i=>t("close")),onConfirm:s[1]||(s[1]=i=>t("close"))},{default:ut(()=>[d("div",Uw,[s[2]||(s[2]=d("label",{class:"block text-retro-muted text-xs font-mono mb-1"},"Tag",-1)),d("p",Gw,A(r.tagName),1)]),r.tagDetail?(v(),y(we,{key:0},[d("div",Hw,[s[3]||(s[3]=d("label",{class:"block text-retro-muted text-xs font-mono mb-1"},"Type",-1)),d("p",Kw,A(r.tagDetail.isAnnotated?"Annotated":"Lightweight"),1)]),d("div",Jw,[s[4]||(s[4]=d("label",{class:"block text-retro-muted text-xs font-mono mb-1"},"Hash",-1)),d("p",eS,A(r.tagDetail.hash),1)]),r.tagDetail.tagger?(v(),y(we,{key:0},[d("div",tS,[s[5]||(s[5]=d("label",{class:"block text-retro-muted text-xs font-mono mb-1"},"Tagger",-1)),d("p",rS,[Ie(A(r.tagDetail.tagger.name)+" ",1),d("span",nS,"<"+A(r.tagDetail.tagger.email)+">",1)])]),d("div",sS,[s[6]||(s[6]=d("label",{class:"block text-retro-muted text-xs font-mono mb-1"},"Date",-1)),d("p",iS,A(r.tagDetail.tagger.date),1)])],64)):F("",!0),r.tagDetail.message?(v(),y("div",oS,[s[7]||(s[7]=d("label",{class:"block text-retro-muted text-xs font-mono mb-1"},"Message",-1)),d("div",aS,A(r.tagDetail.message),1)])):F("",!0)],64)):r.loading?(v(),y("div",lS," Loading tag details... ")):F("",!0)]),_:1},8,["visible","loading"]))}}),uS={class:"mb-4 p-3 bg-retro-panel border border-retro-border rounded"},hS={class:"text-sm font-mono text-retro-cyan"},dS={class:"mb-4"},fS={class:"flex items-start gap-2 cursor-pointer group"},mS=Ve({__name:"CreateBranchDialog",props:{visible:{type:Boolean},fromCommit:{},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=e,n=P(""),s=P(!0),i=J(()=>n.value.trim().length>0);function o(){i.value&&t("confirm",{name:n.value.trim(),checkout:s.value})}function a(){n.value="",s.value=!0,t("close")}return(l,c)=>(v(),pe(Bt,{title:"Create Branch",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Create Branch",onClose:a,onConfirm:o},{default:ut(()=>[d("div",uS,[c[2]||(c[2]=d("div",{class:"text-xs font-mono text-retro-muted mb-1"},"From",-1)),d("div",hS,A(r.fromCommit.slice(0,7)),1)]),d("div",dS,[c[3]||(c[3]=d("label",{class:"block text-xs font-mono text-retro-muted mb-1.5"},"Branch name",-1)),je(d("input",{"onUpdate:modelValue":c[0]||(c[0]=u=>Je(n)?n.value=u:null),type:"text",placeholder:"feature/my-branch",class:"w-full px-3 py-2 text-sm bg-retro-panel border border-retro-border rounded text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan"},null,512),[[Rt,m(n)]])]),d("label",fS,[je(d("input",{"onUpdate:modelValue":c[1]||(c[1]=u=>Je(s)?s.value=u:null),type:"checkbox",class:"mt-0.5 accent-retro-cyan"},null,512),[[Or,m(s)]]),c[4]||(c[4]=d("div",null,[d("span",{class:"text-sm font-mono text-retro-text group-hover:text-retro-cyan transition-colors"}," Switch to new branch "),d("p",{class:"text-xs font-mono text-retro-muted mt-0.5"}," Checkout the branch after creating it ")],-1))])]),_:1},8,["visible","loading","error"]))}}),pS={class:"space-y-4"},gS={class:"flex items-center gap-2 cursor-pointer"},OS=Ve({__name:"StashDialog",props:{visible:{type:Boolean},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e,s=P(""),i=P(!1);function o(){n("confirm",{message:s.value.trim()||void 0,includeUntracked:i.value})}return ze(()=>t.visible,a=>{a&&(s.value="",i.value=!1)}),(a,l)=>(v(),pe(Bt,{title:"Stash Changes",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Stash",onClose:l[2]||(l[2]=c=>n("close")),onConfirm:o},{default:ut(()=>[l[5]||(l[5]=d("p",{class:"text-retro-text text-sm font-mono mb-4"}," Save uncommitted changes to the stash. ",-1)),d("div",pS,[d("div",null,[l[3]||(l[3]=d("label",{class:"block text-retro-muted text-xs font-mono mb-1"},"Message (optional)",-1)),je(d("input",{"onUpdate:modelValue":l[0]||(l[0]=c=>Je(s)?s.value=c:null),type:"text",placeholder:"Stash description...",class:"w-full px-2 py-1.5 text-sm font-mono bg-retro-panel border border-retro-border rounded text-retro-text placeholder-retro-muted/50 focus:outline-none focus:border-retro-cyan"},null,512),[[Rt,m(s)]])]),d("label",gS,[je(d("input",{"onUpdate:modelValue":l[1]||(l[1]=c=>Je(i)?i.value=c:null),type:"checkbox",class:"accent-retro-cyan"},null,512),[[Or,m(i)]]),l[4]||(l[4]=d("span",{class:"text-retro-muted text-sm"},"Include untracked files",-1))])])]),_:1},8,["visible","loading","error"]))}}),vS={class:"space-y-3"},bS={class:"flex items-start gap-2 cursor-pointer"},xS={class:"flex items-start gap-2 cursor-pointer"},yS={key:0,class:"mt-4 p-2 text-xs font-mono text-retro-red bg-retro-red/10 border border-retro-red/30 rounded"},kS=Ve({__name:"ResetWorkingDialog",props:{visible:{type:Boolean},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=r,n=e,s=P("mixed"),i=J(()=>s.value==="hard");function o(){n("confirm",{mode:s.value})}return ze(()=>t.visible,a=>{a&&(s.value="mixed")}),(a,l)=>(v(),pe(Bt,{title:"Reset Working Directory",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Reset","confirm-danger":m(i),onClose:l[2]||(l[2]=c=>n("close")),onConfirm:o},{default:ut(()=>[l[5]||(l[5]=d("p",{class:"text-retro-text text-sm font-mono mb-4"}," Reset the working directory to HEAD. ",-1)),d("div",vS,[d("label",bS,[je(d("input",{"onUpdate:modelValue":l[0]||(l[0]=c=>Je(s)?s.value=c:null),type:"radio",value:"mixed",name:"reset-mode",class:"accent-retro-cyan mt-0.5"},null,512),[[Sc,m(s)]]),l[3]||(l[3]=d("div",null,[d("span",{class:"text-retro-text text-sm font-mono"},"Mixed"),d("p",{class:"text-retro-muted text-xs font-mono mt-0.5"}," Reset staging area, keep working directory ")],-1))]),d("label",xS,[je(d("input",{"onUpdate:modelValue":l[1]||(l[1]=c=>Je(s)?s.value=c:null),type:"radio",value:"hard",name:"reset-mode",class:"accent-retro-cyan mt-0.5"},null,512),[[Sc,m(s)]]),l[4]||(l[4]=d("div",null,[d("span",{class:"text-retro-text text-sm font-mono"},"Hard"),d("p",{class:"text-retro-muted text-xs font-mono mt-0.5"}," Reset staging area AND working directory (DESTRUCTIVE) ")],-1))])]),m(i)?(v(),y("div",yS," WARNING: Hard reset will permanently discard all uncommitted changes. This cannot be undone. ")):F("",!0)]),_:1},8,["visible","loading","error","confirm-danger"]))}}),wS=Ve({__name:"CleanUntrackedDialog",props:{visible:{type:Boolean},loading:{type:Boolean,default:!1},error:{default:null}},emits:["close","confirm"],setup(r,{emit:e}){const t=e;return(n,s)=>(v(),pe(Bt,{title:"Clean Untracked Files",visible:r.visible,loading:r.loading,error:r.error,"confirm-label":"Clean","confirm-danger":"",onClose:s[0]||(s[0]=i=>t("close")),onConfirm:s[1]||(s[1]=i=>t("confirm"))},{default:ut(()=>[...s[2]||(s[2]=[d("div",{class:"space-y-3"},[d("p",{class:"text-retro-text text-sm font-mono"}," Remove all untracked files and directories from the working tree. "),d("p",{class:"text-retro-muted text-xs font-mono"},[Ie(" This runs "),d("code",null,"git clean -fd"),Ie(" and cannot be undone. ")])],-1)])]),_:1},8,["visible","loading","error"]))}}),SS={class:"text-retro-muted text-sm"},$S={class:"text-retro-cyan font-mono"},CS={class:"space-y-3"},QS={class:"text-retro-muted text-sm"},PS={class:"text-retro-cyan font-mono"},TS={class:"space-y-3"},MS={class:"text-retro-muted text-sm"},AS={class:"text-retro-magenta font-mono"},_S={key:0,class:"fixed bottom-4 right-4 z-50 flex items-center gap-2 px-4 py-2.5 text-sm bg-retro-red/90 text-white rounded-lg shadow-lg max-w-sm",role:"alert"},RS={class:"flex-1"},BS=Ve({__name:"GitGraphDialogs",props:{dialogs:{},store:{},remoteNames:{},copyFeedback:{}},setup(r){const e=r,{checkoutDialog:t,confirmCheckout:n,createBranchDialog:s,confirmCreateBranch:i,deleteBranchDialog:o,confirmDeleteBranch:a,renameDialog:l,confirmRenameBranch:c,mergeDialog:u,confirmMerge:h,rebaseDialog:f,confirmRebase:p,pushDialog:g,confirmPush:O,pullDialog:b,confirmPull:x,cherryPickDialog:k,confirmCherryPick:w,resetDialog:S,confirmReset:Q,tagCreateDialog:L,confirmTagCreate:D,tagDeleteDialog:G,confirmTagDelete:oe,tagDetailDialog:ie,stashDialog:j,confirmStash:V,stashBranchDialog:Z,stashBranchInput:U,confirmStashBranch:W,resetWorkingDialog:N,confirmResetWorking:I,cleanUntrackedDialog:z,confirmCleanUntracked:be}=e.dialogs;return(K,H)=>(v(),y(we,null,[m(t).visible?(v(),pe(Bt,{key:0,title:"Checkout",visible:m(t).visible,loading:m(t).loading,error:m(t).error,confirmLabel:"Checkout",onClose:H[0]||(H[0]=re=>m(t).visible=!1),onConfirm:m(n)},{default:ut(()=>[d("p",SS,[H[23]||(H[23]=Ie(" Are you sure you want to checkout ",-1)),d("span",$S,A(m(t).branchName),1),H[24]||(H[24]=Ie("? ",-1))])]),_:1},8,["visible","loading","error","onConfirm"])):F("",!0),m(l).visible?(v(),pe(Bt,{key:1,title:"Rename Branch",visible:m(l).visible,loading:m(l).loading,error:m(l).error,confirmLabel:"Rename",onClose:H[3]||(H[3]=re=>m(l).visible=!1),onConfirm:m(c)},{default:ut(()=>[d("div",CS,[d("p",QS,[H[25]||(H[25]=Ie(" Rename ",-1)),d("span",PS,A(m(l).branchName),1)]),je(d("input",{"onUpdate:modelValue":H[1]||(H[1]=re=>m(l).newName=re),type:"text",class:"w-full px-3 py-2 text-sm bg-retro-panel border border-retro-border rounded text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan",placeholder:"New branch name",onKeyup:H[2]||(H[2]=hs((...re)=>m(c)&&m(c)(...re),["enter"]))},null,544),[[Rt,m(l).newName]])])]),_:1},8,["visible","loading","error","onConfirm"])):F("",!0),m(u).visible?(v(),pe(Ik,{key:2,visible:m(u).visible,branchName:m(u).branchName,loading:m(u).loading,error:m(u).error,onClose:H[4]||(H[4]=re=>m(u).visible=!1),onConfirm:m(h)},null,8,["visible","branchName","loading","error","onConfirm"])):F("",!0),m(o).visible?(v(),pe(qk,{key:3,visible:m(o).visible,branchName:m(o).branchName,isLocal:m(o).isLocal,loading:m(o).loading,error:m(o).error,onClose:H[5]||(H[5]=re=>m(o).visible=!1),onConfirm:m(a)},null,8,["visible","branchName","isLocal","loading","error","onConfirm"])):F("",!0),m(g).visible?(v(),pe(tw,{key:4,visible:m(g).visible,branchName:m(g).branchName,remotes:r.remoteNames,loading:m(g).loading,error:m(g).error,onClose:H[6]||(H[6]=re=>m(g).visible=!1),onConfirm:m(O)},null,8,["visible","branchName","remotes","loading","error","onConfirm"])):F("",!0),m(b).visible?(v(),pe(lw,{key:5,visible:m(b).visible,branchName:m(b).branchName,remotes:r.remoteNames,loading:m(b).loading,error:m(b).error,onClose:H[7]||(H[7]=re=>m(b).visible=!1),onConfirm:m(x)},null,8,["visible","branchName","remotes","loading","error","onConfirm"])):F("",!0),m(f).visible?(v(),pe(pw,{key:6,visible:m(f).visible,branchName:r.store.currentBranch?.name||"HEAD",ontoBranch:m(f).branchName,loading:m(f).loading,error:m(f).error,onClose:H[8]||(H[8]=re=>m(f).visible=!1),onConfirm:m(p)},null,8,["visible","branchName","ontoBranch","loading","error","onConfirm"])):F("",!0),m(k).visible?(v(),pe(kw,{key:7,visible:m(k).visible,commitHash:m(k).commitHash,commitMessage:m(k).commitMessage,loading:m(k).loading,error:m(k).error,onClose:H[9]||(H[9]=re=>m(k).visible=!1),onConfirm:m(w)},null,8,["visible","commitHash","commitMessage","loading","error","onConfirm"])):F("",!0),m(S).visible?(v(),pe(Tw,{key:8,visible:m(S).visible,commitHash:m(S).commitHash,commitMessage:m(S).commitMessage,loading:m(S).loading,error:m(S).error,onClose:H[10]||(H[10]=re=>m(S).visible=!1),onConfirm:m(Q)},null,8,["visible","commitHash","commitMessage","loading","error","onConfirm"])):F("",!0),m(L).visible?(v(),pe(Vw,{key:9,visible:m(L).visible,commitHash:m(L).commitHash,remotes:r.remoteNames,loading:m(L).loading,error:m(L).error,onClose:H[11]||(H[11]=re=>m(L).visible=!1),onConfirm:m(D)},null,8,["visible","commitHash","remotes","loading","error","onConfirm"])):F("",!0),m(G).visible?(v(),pe(Fw,{key:10,visible:m(G).visible,tagName:m(G).tagName,remotes:r.remoteNames,loading:m(G).loading,error:m(G).error,onClose:H[12]||(H[12]=re=>m(G).visible=!1),onConfirm:m(oe)},null,8,["visible","tagName","remotes","loading","error","onConfirm"])):F("",!0),m(ie).visible?(v(),pe(cS,{key:11,visible:m(ie).visible,tagName:m(ie).tagName,tagDetail:m(ie).tagDetail,loading:m(ie).loading,onClose:H[13]||(H[13]=re=>m(ie).visible=!1)},null,8,["visible","tagName","tagDetail","loading"])):F("",!0),m(s).visible?(v(),pe(mS,{key:12,visible:m(s).visible,fromCommit:m(s).fromCommit,loading:m(s).loading,error:m(s).error,onClose:H[14]||(H[14]=re=>m(s).visible=!1),onConfirm:m(i)},null,8,["visible","fromCommit","loading","error","onConfirm"])):F("",!0),m(Z).visible?(v(),pe(Bt,{key:13,title:"Create Branch from Stash",visible:m(Z).visible,loading:m(Z).loading,error:m(Z).error,confirmLabel:"Create Branch",onClose:H[17]||(H[17]=re=>m(Z).visible=!1),onConfirm:H[18]||(H[18]=re=>m(W)(m(U)))},{default:ut(()=>[d("div",TS,[d("p",MS,[H[26]||(H[26]=Ie(" Create a new branch from ",-1)),d("span",AS,"stash@"+A("{")+A(m(Z).stashIndex)+A("}"),1)]),je(d("input",{"onUpdate:modelValue":H[15]||(H[15]=re=>Je(U)?U.value=re:null),type:"text",class:"w-full px-3 py-2 text-sm bg-retro-panel border border-retro-border rounded text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan",placeholder:"Branch name",onKeyup:H[16]||(H[16]=hs(re=>m(W)(m(U)),["enter"]))},null,544),[[Rt,m(U)]])])]),_:1},8,["visible","loading","error"])):F("",!0),m(j).visible?(v(),pe(OS,{key:14,visible:m(j).visible,loading:m(j).loading,error:m(j).error,onClose:H[19]||(H[19]=re=>m(j).visible=!1),onConfirm:m(V)},null,8,["visible","loading","error","onConfirm"])):F("",!0),m(N).visible?(v(),pe(kS,{key:15,visible:m(N).visible,loading:m(N).loading,error:m(N).error,onClose:H[20]||(H[20]=re=>m(N).visible=!1),onConfirm:m(I)},null,8,["visible","loading","error","onConfirm"])):F("",!0),m(z).visible?(v(),pe(wS,{key:16,visible:m(z).visible,loading:m(z).loading,error:m(z).error,onClose:H[21]||(H[21]=re=>m(z).visible=!1),onConfirm:m(be)},null,8,["visible","loading","error","onConfirm"])):F("",!0),(v(),pe(Pr,{to:"body"},[ee(On,{name:"fade"},{default:ut(()=>[r.copyFeedback.visible?(v(),y("div",{key:0,class:"fixed z-50 px-3 py-1.5 text-sm bg-retro-green text-retro-dark rounded shadow-lg",style:tr({left:`${r.copyFeedback.x}px`,top:`${r.copyFeedback.y-40}px`})}," Copied! ",4)):F("",!0)]),_:1})])),(v(),pe(Pr,{to:"body"},[ee(On,{name:"fade"},{default:ut(()=>[r.store.operationError?(v(),y("div",_S,[ee(m(En),{class:"w-4 h-4 flex-shrink-0"}),d("span",RS,A(r.store.operationError),1),d("button",{class:"flex-shrink-0 p-0.5 hover:bg-white/20 rounded transition-colors",onClick:H[22]||(H[22]=re=>r.store.clearOperationError()),"aria-label":"Dismiss error"},[ee(m(St),{class:"w-3.5 h-3.5"})])])):F("",!0)]),_:1})]))],64))}}),ZS=ws(BS,[["__scopeId","data-v-c47c4487"]]),Lu=globalThis.setInterval,ES={class:"h-full flex flex-col bg-retro-dark",role:"region","aria-label":"Git Graph"},DS={key:0,class:"flex-1 flex flex-col items-center justify-center gap-3"},LS={key:1,class:"flex-1 flex flex-col items-center justify-center p-8 text-center"},XS={key:2,class:"flex-1 flex flex-col items-center justify-center p-8 text-center"},IS={class:"text-retro-red text-sm mb-4"},VS={key:3,class:"flex-1 flex items-center justify-center p-4"},zS={class:"flex-shrink-0 flex items-center gap-2 p-2 border-b border-retro-border"},NS={class:"relative"},WS={key:0,class:"absolute left-0 top-full mt-1 z-10 bg-retro-panel border border-retro-border rounded shadow-lg py-2 min-w-[200px]"},qS={class:"flex items-center gap-2 px-3 py-1 hover:bg-retro-panel/50 cursor-pointer"},jS=["checked"],YS={class:"flex items-center gap-2 px-3 py-1 hover:bg-retro-panel/50 cursor-pointer"},FS=["checked"],US={class:"flex items-center gap-2 px-3 py-1 hover:bg-retro-panel/50 cursor-pointer"},GS=["checked"],HS={class:"flex items-center gap-2 px-3 py-1 hover:bg-retro-panel/50 cursor-pointer"},KS=["checked"],JS={class:"flex items-center gap-2 px-3 py-1 hover:bg-retro-panel/50 cursor-pointer"},e2=["checked"],t2={class:"flex items-center gap-2 px-3 py-1 hover:bg-retro-panel/50 cursor-pointer"},r2=["checked"],n2={class:"relative"},s2=["aria-expanded"],i2={key:0,class:"text-xs"},o2={key:0,class:"absolute right-0 top-full mt-1 z-10 bg-retro-panel border border-retro-border rounded shadow-lg py-1 min-w-[220px] max-h-[400px] overflow-auto"},a2=["checked","onChange"],l2={class:"text-sm text-retro-text truncate"},c2={key:0,class:"text-[10px] text-retro-cyan"},u2={class:"px-3 py-1 text-[10px] text-retro-orange font-semibold uppercase tracking-wider mt-1"},h2=["checked","onChange"],d2={class:"text-sm text-retro-text truncate"},f2={class:"relative"},m2={key:0,class:"absolute right-0 top-full mt-1 z-20"},p2=["title"],g2=5e3,O2=Ve({__name:"GitGraph",props:{workingDirectory:{},isActive:{type:Boolean,default:!0}},setup(r){const e=r,t=ml(),n=vr(),s=kk(),i=Sk(t),o=$k(t,i),{checkoutDialog:a,confirmCheckout:l,createBranchDialog:c,confirmCreateBranch:u,deleteBranchDialog:h,confirmDeleteBranch:f,renameDialog:p,confirmRenameBranch:g,mergeDialog:O,confirmMerge:b,rebaseDialog:x,confirmRebase:k,pushDialog:w,confirmPush:S,pullDialog:Q,confirmPull:L,cherryPickDialog:D,confirmCherryPick:G,resetDialog:oe,confirmReset:ie,tagCreateDialog:j,confirmTagCreate:V,tagDeleteDialog:Z,confirmTagDelete:U,tagDetailDialog:W,stashDialog:N,confirmStash:I,stashBranchDialog:z,stashBranchInput:be,confirmStashBranch:K,resetWorkingDialog:H,confirmResetWorking:re,cleanUntrackedDialog:Oe,confirmCleanUntracked:ge,isAnyDialogOpen:$e}=i,{copyFeedback:Pe,branchMenu:Fe,handleBranchContextMenu:T,closeBranchMenu:M,handleBranchCheckout:E,handleBranchRename:B,handleBranchDelete:xe,handleBranchMerge:Re,handleBranchRebase:Me,handleBranchPush:ue,handleBranchPull:ne,handleBranchFetch:Ce,handleBranchCopyName:q,handleBranchCreateBranch:ve,commitMenu:Ze,handleCommitContextMenu:it,closeCommitMenu:Nt,handleCommitAddTag:sr,handleCommitCreateBranch:on,handleCommitCheckout:xr,handleCommitCherryPick:qn,handleCommitRevert:an,handleCommitMergeInto:jn,handleCommitReset:ln,handleCommitCopyHash:Sn,handleCommitCopySubject:Et,tagMenu:Wt,handleTagContextMenu:he,closeTagMenu:ye,handleTagViewDetails:Be,handleTagDelete:Ye,handleTagPush:Ue,handleTagCopyName:Ct,uncommittedMenu:ot,closeUncommittedMenu:Ft,handleUncommittedStash:ir,handleUncommittedReset:yr,handleUncommittedClean:Yn,stashMenu:Xr,handleStashContextMenu:hi,closeStashMenu:di,handleStashApply:fi,handleStashPop:mi,handleStashDrop:pi,handleStashCreateBranch:gi,handleStashCopyName:Oi,handleStashCopyHash:vi}=o,bi=J(()=>{const Ee=n.activeConversation?.worktreeBranch;return Ee?[Ee]:[]}),xi=J(()=>{const Ee=[],le=t.selectedFeatureId;le&&Ee.push(le);const C=t.conversationBranch;return C&&!Ee.includes(C)&&Ee.push(C),Ee});ze(()=>[n.activeConversation?.worktreeBranch,n.activeConversation?.baseBranch],([Ee,le])=>{t.setConversationBranch(Ee??null,le??null)},{immediate:!0});const Dt=J(()=>{const Ee=t.previewBranch;return Ee?[Ee]:[]});ze(()=>[n.previewingConversation?.worktreeBranch,n.previewingConversation?.baseBranch],([Ee,le])=>{t.setPreviewBranch(Ee??null,le??null)},{immediate:!0});const or=J(()=>nd([{branch:t.previewBranch,mergeBase:t.previewMergeBase}])),Ss=J(()=>nd([{branch:t.selectedFeatureId,mergeBase:t.featureMergeBase},{branch:t.conversationBranch,mergeBase:t.conversationMergeBase}])),cn=J(()=>t.remotes.map(Ee=>Ee.name)),$n=P(null);ze(()=>e.workingDirectory,async Ee=>{if(Ee){await t.loadGitGraph(Ee);const le=n.previewingConversation?.worktreeBranch;le&&await t.setPreviewBranch(le,n.previewingConversation?.baseBranch??null);const C=n.activeConversation?.worktreeBranch;C&&await t.setConversationBranch(C,n.activeConversation?.baseBranch??null)}},{immediate:!0}),ze(()=>e.isActive,Ee=>{Ee&&t.commits.length>0&&!t.error?s.startPolling(e.workingDirectory):s.stopPolling()},{immediate:!0}),ze(()=>t.commits.length,Ee=>{Ee>0&&e.isActive&&!t.error&&s.startPolling(e.workingDirectory)}),ze(()=>$n.value,Ee=>{Ee&&s.setScrollCallbacks({getScrollPosition:()=>Ee.getScrollPosition(),setScrollPosition:le=>Ee.setScrollPosition(le)})}),wt(()=>{s.cleanup(),t.reset()});const $s=J(()=>t.error?.includes("Not a Git repository")),Cn=P(Date.now());let un=null;const yi=()=>{un||(un=Lu(()=>{Cn.value=Date.now()},g2))},Cs=()=>{un&&(clearInterval(un),un=null)};gt(()=>{ze(()=>e.isActive,Ee=>{Ee?(Cn.value=Date.now(),yi()):Cs()},{immediate:!0})}),wt(()=>{Cs()});const Qn=J(()=>{const Ee=t.lastRefreshTime;if(!Ee)return null;const le=Math.floor((Cn.value-Ee)/1e3);return t.isRefreshing?"Syncing...":le<5?"Just now":le<60?`${le}s ago`:`${Math.floor(le/60)}m ago`}),Ot=P(!1),_r=P(!1),Fn=P(null);function ki(){Ot.value=!0,It(()=>Fn.value?.focus())}function Un(){Ot.value=!1,t.setSearchQuery("")}function Qs(Ee){t.setSearchQuery(Ee)}const Ps=wk({onScrollToHead:()=>{const Ee=t.commits.find(le=>le.isHead);Ee&&t.selectCommit(Ee)},onEscape:()=>{Ir.value?Ir.value=!1:_r.value?_r.value=!1:ar.value?ar.value=!1:Ot.value?Un():t.isComparing?t.clearComparison():(t.selectedCommit||t.isUncommittedChangesSelected)&&t.clearSelection()}});gt(()=>{Ps.start()}),wt(()=>{Ps.stop()});const Ir=P(!1),ar=P(!1);async function Gn(){await t.fetchAll(!0)}async function wi(Ee){await t.addRemote(Ee.name,Ee.url)}async function Vr(Ee){await t.editRemote(Ee.name,Ee.newUrl)}async function Si(Ee){await t.deleteRemote(Ee)}const Hn=J(()=>{const Ee=[],le={};for(const C of t.branches)if(t.localBranchNames.has(C.name))Ee.push(C);else{const R=C.name.indexOf("/");if(R>0){const _=C.name.substring(0,R);le[_]||(le[_]=[]),le[_].push(C)}else Ee.push(C)}return{local:Ee,remotes:le}});ze($e,Ee=>{Ee?t.setActiveDialog({type:"generic",props:{}}):t.clearActiveDialog()});function Kn(Ee){t.selectedCommit?t.selectComparisonCommit(Ee):t.selectCommit(Ee)}function Ts(Ee){t.navigateToCommit(Ee)}return(Ee,le)=>{const C=qv,R=ob,_=_b,X=Jb,ce=gy,de=Xy,ae=Fy,fe=Uy,rt=Gy,at=Hy,qt=Ky;return v(),y("div",ES,[m(t).loading&&m(t).commits.length===0?(v(),y("div",DS,[...le[20]||(le[20]=[d("div",{class:"w-6 h-6 border-2 border-retro-muted border-t-retro-cyan rounded-full animate-spin"},null,-1),d("div",{class:"text-retro-muted text-sm"},"Loading git history...",-1)])])):m($s)?(v(),y("div",LS,[ee(m(En),{class:"w-12 h-12 text-retro-yellow mb-4"}),le[21]||(le[21]=d("h3",{class:"text-retro-text font-semibold mb-2"},"Not a Git Repository",-1)),le[22]||(le[22]=d("p",{class:"text-retro-muted text-sm max-w-xs"},[Ie(" This directory is not initialized as a Git repository. Run "),d("code",{class:"text-retro-cyan"},"git init"),Ie(" to get started. ")],-1))])):m(t).error?(v(),y("div",XS,[ee(m(En),{class:"w-10 h-10 text-retro-red mb-3"}),d("p",IS,A(m(t).error),1),d("button",{class:"flex items-center gap-2 px-3 py-1.5 text-sm text-retro-text border border-retro-border rounded hover:border-retro-cyan hover:text-retro-cyan transition-colors",onClick:le[0]||(le[0]=et=>m(t).loadGitGraph(e.workingDirectory))},[ee(m(gs),{class:"w-4 h-4"}),le[23]||(le[23]=Ie(" Retry ",-1))])])):m(t).commits.length===0?(v(),y("div",VS,[...le[24]||(le[24]=[d("div",{class:"text-retro-muted text-center"},[d("p",null,"No commits found in this repository.")],-1)])])):(v(),y(we,{key:4},[m(Ot)?(v(),pe(C,{key:0,ref_key:"findWidgetRef",ref:Fn,resultCount:m(t).searchResultHashes.length,currentIndex:m(t).searchResultIndex,onSearch:Qs,onNext:m(t).nextSearchResult,onPrev:m(t).prevSearchResult,onClose:Un},null,8,["resultCount","currentIndex","onNext","onPrev"])):F("",!0),d("div",zS,[d("button",{class:_e(["flex items-center gap-1 px-2 py-1.5 text-sm border rounded transition-colors",m(Ot)?"border-retro-cyan text-retro-cyan bg-retro-cyan/10":"border-retro-border text-retro-muted hover:text-retro-text hover:border-retro-text"]),"aria-label":"Find",title:"Find",onClick:le[1]||(le[1]=et=>m(Ot)?Un():ki())},[ee(m(fs),{class:"w-4 h-4"})],2),d("div",NS,[d("button",{class:_e(["flex items-center gap-1 px-2 py-1.5 text-sm border rounded transition-colors",m(Ir)?"border-retro-cyan text-retro-cyan bg-retro-cyan/10":"border-retro-border text-retro-muted hover:text-retro-text hover:border-retro-text"]),"aria-label":"Graph settings",title:"Settings",onClick:le[2]||(le[2]=et=>Ir.value=!m(Ir))},[ee(m(hv),{class:"w-4 h-4"})],2),m(Ir)?(v(),y("div",WS,[le[31]||(le[31]=d("div",{class:"px-3 py-1 text-xs text-retro-muted border-b border-retro-border mb-1"}," Graph Style ",-1)),d("label",qS,[d("input",{type:"radio",name:"graphStyle",value:"rounded",checked:m(t).graphStyle==="rounded",class:"accent-retro-cyan",onChange:le[3]||(le[3]=et=>m(t).setGraphStyle("rounded"))},null,40,jS),le[25]||(le[25]=d("span",{class:"text-sm text-retro-text"},"Rounded",-1))]),d("label",YS,[d("input",{type:"radio",name:"graphStyle",value:"angular",checked:m(t).graphStyle==="angular",class:"accent-retro-cyan",onChange:le[4]||(le[4]=et=>m(t).setGraphStyle("angular"))},null,40,FS),le[26]||(le[26]=d("span",{class:"text-sm text-retro-text"},"Angular",-1))]),le[32]||(le[32]=d("div",{class:"px-3 py-1 text-xs text-retro-muted border-b border-retro-border mt-2 mb-1"}," Display ",-1)),d("label",US,[d("input",{type:"checkbox",checked:m(t).muteNonAncestral,class:"accent-retro-cyan",onChange:le[5]||(le[5]=et=>m(t).toggleMuteNonAncestral())},null,40,GS),le[27]||(le[27]=d("span",{class:"text-sm text-retro-text"},"Mute non-ancestral",-1))]),le[33]||(le[33]=d("div",{class:"px-3 py-1 text-xs text-retro-muted border-b border-retro-border mt-2 mb-1"}," Columns ",-1)),d("label",HS,[d("input",{type:"checkbox",checked:m(t).columnVisibility.commit!==!1,class:"accent-retro-cyan",onChange:le[6]||(le[6]=et=>m(t).toggleColumnVisibility("commit"))},null,40,KS),le[28]||(le[28]=d("span",{class:"text-sm text-retro-text"},"Hash",-1))]),d("label",JS,[d("input",{type:"checkbox",checked:m(t).columnVisibility.author!==!1,class:"accent-retro-cyan",onChange:le[7]||(le[7]=et=>m(t).toggleColumnVisibility("author"))},null,40,e2),le[29]||(le[29]=d("span",{class:"text-sm text-retro-text"},"Author",-1))]),d("label",t2,[d("input",{type:"checkbox",checked:m(t).columnVisibility.date!==!1,class:"accent-retro-cyan",onChange:le[8]||(le[8]=et=>m(t).toggleColumnVisibility("date"))},null,40,r2),le[30]||(le[30]=d("span",{class:"text-sm text-retro-text"},"Date",-1))])])):F("",!0)]),le[36]||(le[36]=d("span",{class:"flex-1"},null,-1)),d("div",n2,[d("button",{class:_e(["flex items-center gap-1 px-2 py-1.5 text-sm border rounded transition-colors",m(_r)||m(t).filteredBranches.length>0?"border-retro-cyan text-retro-cyan bg-retro-cyan/10":"border-retro-border text-retro-muted hover:text-retro-text hover:border-retro-text"]),"aria-label":"Filter by branch","aria-expanded":m(_r),onClick:le[9]||(le[9]=et=>_r.value=!m(_r))},[ee(m(Mv),{class:"w-4 h-4"}),m(t).filteredBranches.length>0?(v(),y("span",i2," ("+A(m(t).filteredBranches.length)+") ",1)):F("",!0)],10,s2),m(_r)?(v(),y("div",o2,[le[35]||(le[35]=d("div",{class:"px-3 py-1 text-xs text-retro-muted border-b border-retro-border"}," Filter by Branch ",-1)),m(t).filteredBranches.length>0?(v(),y("button",{key:0,class:"w-full text-left px-3 py-1.5 text-sm text-retro-cyan hover:bg-retro-cyan/10",onClick:le[10]||(le[10]=et=>m(t).clearFilters())}," Clear All Filters ")):F("",!0),m(Hn).local.length>0?(v(),y(we,{key:1},[le[34]||(le[34]=d("div",{class:"px-3 py-1 text-[10px] text-retro-green font-semibold uppercase tracking-wider mt-1"}," Local ",-1)),(v(!0),y(we,null,Ne(m(Hn).local,et=>(v(),y("label",{key:et.name,class:"flex items-center gap-2 px-3 py-1 hover:bg-retro-panel/50 cursor-pointer"},[d("input",{type:"checkbox",checked:m(t).filteredBranches.includes(et.name),class:"accent-retro-cyan",onChange:lr=>m(t).toggleBranchFilter(et.name)},null,40,a2),d("span",l2,A(et.name),1),et.isHead?(v(),y("span",c2,"(HEAD)")):F("",!0)]))),128))],64)):F("",!0),(v(!0),y(we,null,Ne(m(Hn).remotes,(et,lr)=>(v(),y(we,{key:lr},[d("div",u2,A(lr),1),(v(!0),y(we,null,Ne(et,Ms=>(v(),y("label",{key:Ms.name,class:"flex items-center gap-2 px-3 py-1 hover:bg-retro-panel/50 cursor-pointer"},[d("input",{type:"checkbox",checked:m(t).filteredBranches.includes(Ms.name),class:"accent-retro-cyan",onChange:Vh=>m(t).toggleBranchFilter(Ms.name)},null,40,h2),d("span",d2,A(Ms.name),1)]))),128))],64))),128))])):F("",!0)]),d("button",{class:_e(["flex items-center gap-1 px-2 py-1.5 text-sm border border-retro-border text-retro-muted rounded hover:text-retro-text hover:border-retro-text transition-colors",{"animate-spin":m(t).isRefreshing}]),"aria-label":"Refresh",title:"Refresh",onClick:le[11]||(le[11]=et=>m(t).loadGitGraph(e.workingDirectory))},[ee(m(gs),{class:"w-4 h-4"})],2),d("button",{class:"flex items-center gap-1 px-2 py-1.5 text-sm border border-retro-border text-retro-muted rounded hover:text-retro-text hover:border-retro-text transition-colors","aria-label":"Fetch all remotes",title:"Fetch All",onClick:Gn},[ee(m(up),{class:"w-4 h-4"})]),d("div",f2,[d("button",{class:_e(["flex items-center gap-1 px-2 py-1.5 text-sm border rounded transition-colors",m(ar)?"border-retro-cyan text-retro-cyan bg-retro-cyan/10":"border-retro-border text-retro-muted hover:text-retro-text hover:border-retro-text"]),"aria-label":"Manage remotes",title:"Remotes",onClick:le[12]||(le[12]=et=>ar.value=!m(ar))},[ee(m(Cc),{class:"w-4 h-4"})],2),m(ar)?(v(),y("div",m2,[ee(R,{remotes:m(t).remotes,onAdd:wi,onEdit:Vr,onDelete:Si,onClose:le[13]||(le[13]=et=>ar.value=!1)},null,8,["remotes"])])):F("",!0)]),m(Qn)&&e.isActive?(v(),y("div",{key:0,class:_e(["flex items-center text-[10px] text-retro-muted",{"text-retro-cyan":m(t).isRefreshing}]),title:m(t).lastRefreshTime?`Last checked: ${new Date(m(t).lastRefreshTime).toLocaleTimeString()}`:"","aria-live":"polite","aria-atomic":"true"},[d("span",{class:_e(["inline-block w-1.5 h-1.5 rounded-full mr-1",m(t).isRefreshing?"bg-retro-cyan animate-pulse":"bg-retro-muted/50"]),"aria-hidden":"true"},null,2),Ie(" "+A(m(Qn)),1)],10,p2)):F("",!0)]),d("div",{class:_e(["flex-1 min-h-0 overflow-hidden",{"max-h-[50%]":m(t).selectedCommit||m(t).isUncommittedChangesSelected}])},[ee(_,{ref_key:"commitListRef",ref:$n,commits:m(t).filteredCommits,stashes:m(t).stashes,selectedCommit:m(t).selectedCommit,hasMore:m(t).hasMore,loading:m(t).loading,loadingMore:m(t).loadingMore,searchQuery:m(t).searchQuery,uncommittedChangesCount:m(t).uncommittedChangesCount,isUncommittedChangesSelected:m(t).isUncommittedChangesSelected,highlightBranches:m(bi),featureHighlightBranches:m(xi),featureMergeBases:m(Ss),previewHighlightBranches:m(Dt),previewMergeBases:m(or),currentBranchName:m(t).currentBranch?.name,localBranchNames:m(t).localBranchNames,graphStyle:m(t).graphStyle,muteNonAncestral:m(t).muteNonAncestral,columnVisibility:m(t).columnVisibility,onSelect:m(t).selectCommit,onLoadMore:m(t).loadMoreCommits,onBranchContextMenu:m(T),onCommitContextMenu:m(it),onTagContextMenu:m(he),onStashContextMenu:m(hi),onCompareSelect:Kn,onSelectUncommittedChanges:m(t).selectUncommittedChanges,onScrollStart:m(s).startInteraction,onScrollEnd:m(s).endInteraction},null,8,["commits","stashes","selectedCommit","hasMore","loading","loadingMore","searchQuery","uncommittedChangesCount","isUncommittedChangesSelected","highlightBranches","featureHighlightBranches","featureMergeBases","previewHighlightBranches","previewMergeBases","currentBranchName","localBranchNames","graphStyle","muteNonAncestral","columnVisibility","onSelect","onLoadMore","onBranchContextMenu","onCommitContextMenu","onTagContextMenu","onStashContextMenu","onSelectUncommittedChanges","onScrollStart","onScrollEnd"])],2),m(t).isComparing&&m(t).selectedCommit&&m(t).comparisonCommit?(v(),pe(X,{key:1,fromCommit:m(t).comparisonCommit,toCommit:m(t).selectedCommit,files:m(t).comparisonFiles,stats:m(t).comparisonStats,loading:m(t).comparisonLoading,onClose:m(t).clearComparison},null,8,["fromCommit","toCommit","files","stats","loading","onClose"])):m(t).selectedCommit?(v(),pe(ce,{key:2,commit:m(t).selectedCommit,files:m(t).selectedCommitFiles,stats:m(t).selectedCommitStats,loading:m(t).isLoadingDetails,detailPosition:m(t).detailViewPosition,onClose:m(t).clearSelection,onNavigateToCommit:Ts,onTogglePosition:m(t).toggleDetailViewPosition,onOpenFileDiff:le[14]||(le[14]=et=>m(t).selectedCommit&&m(t).openFileDiff(m(t).selectedCommit.hash,et))},null,8,["commit","files","stats","loading","detailPosition","onClose","onTogglePosition"])):F("",!0),m(t).isUncommittedChangesSelected?(v(),pe(de,{key:3,stagedFiles:m(t).stagedFiles,unstagedFiles:m(t).unstagedFiles,isStaging:m(t).isStaging,isCommitting:m(t).isCommitting,onClose:m(t).clearSelection,onStageFiles:le[15]||(le[15]=et=>m(t).stageFiles(et)),onUnstageFiles:le[16]||(le[16]=et=>m(t).unstageFiles(et)),onStageAll:le[17]||(le[17]=()=>m(t).stageFiles([])),onUnstageAll:le[18]||(le[18]=()=>m(t).unstageFiles([])),onCommit:le[19]||(le[19]=et=>m(t).commitChanges(et))},null,8,["stagedFiles","unstagedFiles","isStaging","isCommitting","onClose"])):F("",!0)],64)),m(Fe).visible?(v(),pe(ae,{key:5,branchName:m(Fe).branch,isCurrentBranch:m(Fe).isCurrentBranch,isLocal:m(Fe).isLocal,x:m(Fe).x,y:m(Fe).y,onClose:m(M),onCheckout:m(E),onCreateBranch:m(ve),onDeleteBranch:m(xe),onRename:m(B),onMerge:m(Re),onRebase:m(Me),onPush:m(ue),onPull:m(ne),onFetch:m(Ce),onCopyName:m(q)},null,8,["branchName","isCurrentBranch","isLocal","x","y","onClose","onCheckout","onCreateBranch","onDeleteBranch","onRename","onMerge","onRebase","onPush","onPull","onFetch","onCopyName"])):F("",!0),m(Ze).visible&&m(Ze).commit?(v(),pe(fe,{key:6,commit:m(Ze).commit,x:m(Ze).x,y:m(Ze).y,onClose:m(Nt),onAddTag:m(sr),onCreateBranch:m(on),onCheckout:m(xr),onCherryPick:m(qn),onRevert:m(an),onMergeInto:m(jn),onReset:m(ln),onCopyHash:m(Sn),onCopySubject:m(Et)},null,8,["commit","x","y","onClose","onAddTag","onCreateBranch","onCheckout","onCherryPick","onRevert","onMergeInto","onReset","onCopyHash","onCopySubject"])):F("",!0),m(Wt).visible?(v(),pe(rt,{key:7,tagName:m(Wt).tag,x:m(Wt).x,y:m(Wt).y,onClose:m(ye),onViewDetails:m(Be),onDeleteTag:m(Ye),onPushTag:m(Ue),onCopyName:m(Ct)},null,8,["tagName","x","y","onClose","onViewDetails","onDeleteTag","onPushTag","onCopyName"])):F("",!0),m(Xr).visible&&m(Xr).stash?(v(),pe(at,{key:8,stashIndex:m(Xr).stash.index,stashMessage:m(Xr).stash.message,x:m(Xr).x,y:m(Xr).y,onClose:m(di),onApply:m(fi),onPop:m(mi),onDrop:m(pi),onCreateBranch:m(gi),onCopyName:m(Oi),onCopyHash:m(vi)},null,8,["stashIndex","stashMessage","x","y","onClose","onApply","onPop","onDrop","onCreateBranch","onCopyName","onCopyHash"])):F("",!0),m(ot).visible?(v(),pe(qt,{key:9,x:m(ot).x,y:m(ot).y,onClose:m(Ft),onStash:m(ir),onReset:m(yr),onClean:m(Yn)},null,8,["x","y","onClose","onStash","onReset","onClean"])):F("",!0),ee(ZS,{dialogs:m(i),store:m(t),remoteNames:m(cn),copyFeedback:m(Pe)},null,8,["dialogs","store","remoteNames","copyFeedback"])])}}}),v2=ws(O2,[["__scopeId","data-v-e2b31aba"]]),od=z1("/app-logo.svg"),b2={class:"flex items-start justify-between gap-2"},x2={class:"flex-1 min-w-0"},y2={class:"flex items-center gap-2"},k2={class:"font-mono text-sm text-retro-text truncate"},w2={class:"text-xs font-mono text-retro-muted mt-1 truncate"},S2={class:"flex items-center gap-1 flex-shrink-0"},$2={key:0,class:"inline-flex items-center gap-1 text-[10px] font-mono text-retro-red",title:"Critical traceability gaps"},C2={key:1,class:"inline-flex items-center gap-1 text-[10px] font-mono text-retro-yellow",title:"Major traceability gaps"},Q2={key:2,class:"text-[10px] font-mono text-retro-muted mr-1",title:"Completed tasks / total tasks"},P2={key:3,class:"w-2 h-2 rounded-full bg-retro-green",title:"spec"},T2={key:4,class:"w-2 h-2 rounded-full bg-retro-cyan",title:"plan"},M2={key:5,class:"w-2 h-2 rounded-full bg-retro-yellow",title:"tasks"},A2={class:"flex flex-wrap items-center justify-between gap-1 mt-2"},_2={key:0,class:"flex items-center gap-1"},R2=["title","disabled","onClick"],B2=Ve({__name:"FeatureCard",props:{feature:{},skills:{},isActive:{type:Boolean},criticalAlerts:{},majorAlerts:{}},emits:["select","cascade","openChat","skill"],setup(r,{emit:e}){const t={DocumentCheckIcon:Sv,PuzzlePieceIcon:Jh,DocumentMagnifyingGlassIcon:Cv,WrenchScrewdriverIcon:Dv,SparklesIcon:ji,BeakerIcon:gv,ShieldCheckIcon:mp,CommandLineIcon:wv,CpuChipIcon:tv,LightBulbIcon:Rv},n=r,s=e,i=vr();function o(f){return t[f]||Jh}function a(f){return f.prerequisites.every(p=>n.feature.files.some(g=>g.filename===p))}function l(f){return f.prerequisites.filter(p=>!n.feature.files.some(g=>g.filename===p))}function c(f){return a(f)?`${f.name} (Shift+click: new conversation)`:`Requires: ${l(f).join(", ")}`}const u=J(()=>{const f=i.findConversationByFeature(n.feature.id);return f?i.isConversationStreaming(f.id):!1}),h=J(()=>n.isActive?["border-retro-cyan shadow-retro","feature-card-active","dark:bg-gradient-to-br dark:from-retro-cyan/10 dark:via-retro-panel dark:to-retro-magenta/5"]:["border-retro-border","feature-card-light","hover:border-retro-muted","dark:bg-gradient-to-br","dark:from-retro-panel dark:via-retro-panel dark:to-retro-cyan/5","dark:hover:from-retro-cyan/5 dark:hover:via-retro-panel dark:hover:to-retro-magenta/5"]);return(f,p)=>(v(),y("button",{type:"button",class:_e(["w-full p-3 text-left rounded-lg border transition-all duration-200 group",m(h)]),onClick:p[5]||(p[5]=g=>s("select",r.feature.id))},[d("div",b2,[d("div",x2,[d("div",y2,[ee(m(Os),{class:_e(["h-4 w-4 flex-shrink-0 transition-colors duration-200",r.isActive?"text-retro-cyan":"text-retro-muted group-hover:text-retro-cyan"])},null,8,["class"]),d("span",k2,A(r.feature.id),1)]),d("p",w2,A(r.feature.name),1)]),d("div",S2,[r.criticalAlerts>0?(v(),y("span",$2,[p[6]||(p[6]=d("span",{class:"w-1.5 h-1.5 rounded-full bg-retro-red"},null,-1)),Ie(" "+A(r.criticalAlerts),1)])):F("",!0),r.majorAlerts>0?(v(),y("span",C2,[p[7]||(p[7]=d("span",{class:"w-1.5 h-1.5 rounded-full bg-retro-yellow"},null,-1)),Ie(" "+A(r.majorAlerts),1)])):F("",!0),r.feature.hasTasks?(v(),y("span",Q2,A(r.feature.completedTasks)+"/"+A(r.feature.totalTasks),1)):F("",!0),r.feature.hasSpec?(v(),y("span",P2)):F("",!0),r.feature.hasPlan?(v(),y("span",T2)):F("",!0),r.feature.hasTasks?(v(),y("span",M2)):F("",!0)])]),d("div",A2,[r.feature.hasSpec?(v(),y("div",_2,[d("button",{type:"button",class:"flex items-center justify-center p-1 bg-retro-cyan/20 text-retro-cyan rounded hover:bg-retro-cyan/30 transition-colors",title:"Clarify spec (Shift+click: new conversation)",onClick:p[0]||(p[0]=kr(g=>s("cascade",g,r.feature.id,"clarify"),["stop"]))},[ee(m(Zu),{class:"h-3.5 w-3.5"})]),d("button",{type:"button",class:"flex items-center justify-center p-1 bg-retro-cyan/20 text-retro-cyan rounded hover:bg-retro-cyan/30 transition-colors",title:"Plan → Tasks → Implement (Shift+click: new conversation)",onClick:p[1]||(p[1]=kr(g=>s("cascade",g,r.feature.id,"plan"),["stop"]))},[ee(m(Bu),{class:"h-3.5 w-3.5"})]),r.feature.hasPlan?(v(),y("button",{key:0,type:"button",class:"flex items-center justify-center p-1 bg-retro-yellow/20 text-retro-yellow rounded hover:bg-retro-yellow/30 transition-colors",title:"Tasks → Implement (Shift+click: new conversation)",onClick:p[2]||(p[2]=kr(g=>s("cascade",g,r.feature.id,"tasks"),["stop"]))},[ee(m(hp),{class:"h-3.5 w-3.5"})])):F("",!0),r.feature.hasTasks?(v(),y("button",{key:1,type:"button",class:"flex items-center justify-center p-1 bg-retro-magenta/20 text-retro-magenta rounded hover:bg-retro-magenta/30 transition-colors",title:"Implement (Shift+click: new conversation)",onClick:p[3]||(p[3]=kr(g=>s("cascade",g,r.feature.id,"implement"),["stop"]))},[ee(m(Ev),{class:"h-3.5 w-3.5"})])):F("",!0),r.skills.length>0?(v(),y(we,{key:2},[p[8]||(p[8]=d("div",{class:"w-px h-4 bg-retro-border mx-0.5"},null,-1)),(v(!0),y(we,null,Ne(r.skills,g=>(v(),y("button",{key:g.id,type:"button",class:_e(["flex items-center justify-center p-1 rounded transition-colors",[a(g)&&!m(u)?"bg-retro-pink/20 text-retro-pink hover:bg-retro-pink/30":"bg-retro-subtle/10 text-retro-subtle cursor-not-allowed",m(u)?"animate-pulse":""]]),title:c(g),disabled:!a(g)||m(u),onClick:kr(O=>s("skill",O,r.feature.id,g.id),["stop"])},[(v(),pe(ps(o(g.icon)),{class:"h-3.5 w-3.5"}))],10,R2))),128))],64)):F("",!0)])):F("",!0),r.feature.hasSpec?(v(),y("button",{key:1,type:"button",class:"flex items-center justify-center p-1 bg-retro-green/20 text-retro-green rounded hover:bg-retro-green/30 transition-colors",title:"Open new chat linked to this spec",onClick:p[4]||(p[4]=kr(g=>s("openChat",g,r.feature.id),["stop"]))},[ee(m(bv),{class:"h-3.5 w-3.5"})])):F("",!0)])],2))}});let Qc=[],vp=[];(()=>{let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<r.length;e++)(e%2?vp:Qc).push(t=t+r[e])})();function Z2(r){if(r<768)return!1;for(let e=0,t=Qc.length;;){let n=e+t>>1;if(r<Qc[n])t=n;else if(r>=vp[n])e=n+1;else return!0;if(e==t)return!1}}function ad(r){return r>=127462&&r<=127487}const ld=8205;function E2(r,e,t=!0,n=!0){return(t?bp:D2)(r,e,n)}function bp(r,e,t){if(e==r.length)return e;e&&xp(r.charCodeAt(e))&&yp(r.charCodeAt(e-1))&&e--;let n=Al(r,e);for(e+=cd(n);e<r.length;){let s=Al(r,e);if(n==ld||s==ld||t&&Z2(s))e+=cd(s),n=s;else if(ad(s)){let i=0,o=e-2;for(;o>=0&&ad(Al(r,o));)i++,o-=2;if(i%2==0)break;e+=2}else break}return e}function D2(r,e,t){for(;e>0;){let n=bp(r,e-2,t);if(n<e)return n;e--}return 0}function Al(r,e){let t=r.charCodeAt(e);if(!yp(t)||e+1==r.length)return t;let n=r.charCodeAt(e+1);return xp(n)?(t-55296<<10)+(n-56320)+65536:t}function xp(r){return r>=56320&&r<57344}function yp(r){return r>=55296&&r<56320}function cd(r){return r<65536?1:2}class tt{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Us(this,e,t);let s=[];return this.decompose(0,e,s,2),n.length&&n.decompose(0,n.length,s,3),this.decompose(t,this.length,s,1),Fr.from(s,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Us(this,e,t);let n=[];return this.decompose(e,t,n,0),Fr.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),s=new Li(this),i=new Li(e);for(let o=t,a=t;;){if(s.next(o),i.next(o),o=0,s.lineBreak!=i.lineBreak||s.done!=i.done||s.value!=i.value)return!1;if(a+=s.value.length,s.done||a>=n)return!0}}iter(e=1){return new Li(this,e)}iterRange(e,t=this.length){return new kp(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;n=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new wp(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?tt.empty:e.length<=32?new vt(e):Fr.from(vt.split(e,[]))}}class vt extends tt{constructor(e,t=L2(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,s){for(let i=0;;i++){let o=this.text[i],a=s+o.length;if((t?n:a)>=e)return new X2(s,a,n,o);s=a+1,n++}}decompose(e,t,n,s){let i=e<=0&&t>=this.length?this:new vt(ud(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=n.pop(),a=ga(i.text,o.text.slice(),0,i.length);if(a.length<=32)n.push(new vt(a,o.length+i.length));else{let l=a.length>>1;n.push(new vt(a.slice(0,l)),new vt(a.slice(l)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof vt))return super.replace(e,t,n);[e,t]=Us(this,e,t);let s=ga(this.text,ga(n.text,ud(this.text,0,e)),t),i=this.length+n.length-(t-e);return s.length<=32?new vt(s,i):Fr.from(vt.split(s,[]),i)}sliceString(e,t=this.length,n=`
12
12
  `){[e,t]=Us(this,e,t);let s="";for(let i=0,o=0;i<=t&&o<this.text.length;o++){let a=this.text[o],l=i+a.length;i>e&&o&&(s+=n),e<l&&t>i&&(s+=a.slice(Math.max(0,e-i),t-i)),i=l+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],s=-1;for(let i of e)n.push(i),s+=i.length+1,n.length==32&&(t.push(new vt(n,s)),n=[],s=-1);return s>-1&&t.push(new vt(n,s)),t}}class Fr extends tt{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,s){for(let i=0;;i++){let o=this.children[i],a=s+o.length,l=n+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,n,s);s=a+1,n=l+1}}decompose(e,t,n,s){for(let i=0,o=0;o<=t&&i<this.children.length;i++){let a=this.children[i],l=o+a.length;if(e<=l&&t>=o){let c=s&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!c?n.push(a):a.decompose(e-o,t-o,n,c)}o=l+1}}replace(e,t,n){if([e,t]=Us(this,e,t),n.lines<this.lines)for(let s=0,i=0;s<this.children.length;s++){let o=this.children[s],a=i+o.length;if(e>=i&&t<=a){let l=o.replace(e-i,t-i,n),c=this.lines-o.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[s]=l,new Fr(u,this.length-(t-e)+n.length)}return super.replace(i,a,l)}i=a+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
@@ -36,7 +36,7 @@ import{y as v,z as y,A as d,d as Ve,C as ee,G as m,R as je,S as Je,U as Rt,I as
36
36
  constructor(\${params}) {
37
37
  \${}
38
38
  }
39
- }`,{label:"class",detail:"definition",type:"keyword"}),Gt('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Gt('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],MA=e1.concat([Gt("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Gt("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Gt("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Tm=new qg,t1=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Ai(r){return(e,t)=>{let n=e.node.getChild("VariableDefinition");return n&&t(n,r),!0}}const AA=["FunctionDeclaration"],_A={FunctionDeclaration:Ai("function"),ClassDeclaration:Ai("class"),ClassExpression:()=>!0,EnumDeclaration:Ai("constant"),TypeAliasDeclaration:Ai("type"),NamespaceDeclaration:Ai("namespace"),VariableDefinition(r,e){r.matchContext(AA)||e(r,"variable")},TypeDefinition(r,e){e(r,"type")},__proto__:null};function r1(r,e){let t=Tm.get(e);if(t)return t;let n=[],s=!0;function i(o,a){let l=r.sliceString(o.from,o.to);n.push({label:l,type:a})}return e.cursor(st.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let a=_A[o.name];if(a&&a(o,i)||t1.has(o.name))return!1}else if(o.to-o.from>8192){for(let a of r1(r,o.node))n.push(a);return!1}}),Tm.set(e,n),n}const Mm=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,n1=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function RA(r){let e=dt(r.state).resolveInner(r.pos,-1);if(n1.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Mm.test(r.state.sliceDoc(e.from,e.to));if(!t&&!r.explicit)return null;let n=[];for(let s=e;s;s=s.parent)t1.has(s.name)&&(n=n.concat(r1(r.state.doc,s)));return{options:n,from:t?e.from:r.pos,validFor:Mm}}const rn=Js.define({name:"javascript",parser:TA.configure({props:[Po.add({IfStatement:Sa({except:/^\s*({|else\b)/}),TryStatement:Sa({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:kQ,SwitchBody:r=>{let e=r.textAfter,t=/^\s*\}/.test(e),n=/^\s*(case|default)\b/.test(e);return r.baseIndent+(t?0:n?1:2)*r.unit},Block:yQ({closing:"}"}),ArrowFunction:r=>r.baseIndent+r.unit,"TemplateString BlockComment":()=>null,"Statement Property":Sa({except:/^\s*{/}),JSXElement(r){let e=/^\s*<\//.test(r.textAfter);return r.lineIndent(r.node.from)+(e?0:r.unit)},JSXEscape(r){let e=/\s*\}/.test(r.textAfter);return r.lineIndent(r.node.from)+(e?0:r.unit)},"JSXOpenTag JSXSelfClosingTag"(r){return r.column(r.node.from)+r.unit}}),ai.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Jg,BlockComment(r){return{from:r.from+2,to:r.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),s1={test:r=>/^JSX/.test(r.name),facet:lh({commentTokens:{block:{open:"{/*",close:"*/}"}}})},i1=rn.configure({dialect:"ts"},"typescript"),o1=rn.configure({dialect:"jsx",props:[ch.add(r=>r.isTop?[s1]:void 0)]}),a1=rn.configure({dialect:"jsx ts",props:[ch.add(r=>r.isTop?[s1]:void 0)]},"typescript");let l1=r=>({label:r,type:"keyword"});const c1="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(l1),BA=c1.concat(["declare","implements","private","protected","public"].map(l1));function ZA(r={}){let e=r.jsx?r.typescript?a1:o1:r.typescript?i1:rn,t=r.typescript?MA.concat(BA):e1.concat(c1);return new so(e,[rn.data.of({autocomplete:N3(n1,JO(t))}),rn.data.of({autocomplete:RA}),r.jsx?LA:[]])}function EA(r){for(;;){if(r.name=="JSXOpenTag"||r.name=="JSXSelfClosingTag"||r.name=="JSXFragmentTag")return r;if(r.name=="JSXEscape"||!r.parent)return null;r=r.parent}}function Am(r,e,t=r.length){for(let n=e?.firstChild;n;n=n.nextSibling)if(n.name=="JSXIdentifier"||n.name=="JSXBuiltin"||n.name=="JSXNamespacedName"||n.name=="JSXMemberExpression")return r.sliceString(n.from,Math.min(n.to,t));return""}const DA=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),LA=Se.inputHandler.of((r,e,t,n,s)=>{if((DA?r.composing:r.compositionStarted)||r.state.readOnly||e!=t||n!=">"&&n!="/"||!rn.isActiveAt(r.state,e,-1))return!1;let i=s(),{state:o}=i,a=o.changeByRange(l=>{var c;let{head:u}=l,h=dt(o).resolveInner(u-1,-1),f;if(h.name=="JSXStartTag"&&(h=h.parent),!(o.doc.sliceString(u-1,u)!=n||h.name=="JSXAttributeValue"&&h.to>u)){if(n==">"&&h.name=="JSXFragmentTag")return{range:l,changes:{from:u,insert:"</>"}};if(n=="/"&&h.name=="JSXStartCloseTag"){let p=h.parent,g=p.parent;if(g&&p.from==u-2&&((f=Am(o.doc,g.firstChild,u))||((c=g.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let O=`${f}>`;return{range:te.cursor(u+O.length,-1),changes:{from:u,insert:O}}}}else if(n==">"){let p=EA(h);if(p&&p.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(u,u+2))&&(f=Am(o.doc,p,u)))return{range:l,changes:{from:u,insert:`</${f}>`}}}}return{range:l}});return a.changes.empty?!1:(r.dispatch([i,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),_i=["_blank","_self","_top","_parent"],mc=["ascii","utf-8","utf-16","latin1","latin1"],pc=["get","post","put","delete"],gc=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],hr=["true","false"],De={},XA={a:{attrs:{href:null,ping:null,type:null,media:null,target:_i,hreflang:null}},abbr:De,address:De,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:De,aside:De,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:De,base:{attrs:{href:null,target:_i}},bdi:De,bdo:De,blockquote:{attrs:{cite:null}},body:De,br:De,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:gc,formmethod:pc,formnovalidate:["novalidate"],formtarget:_i,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:De,center:De,cite:De,code:De,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:De,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:De,div:De,dl:De,dt:De,em:De,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:De,figure:De,footer:De,form:{attrs:{action:null,name:null,"accept-charset":mc,autocomplete:["on","off"],enctype:gc,method:pc,novalidate:["novalidate"],target:_i}},h1:De,h2:De,h3:De,h4:De,h5:De,h6:De,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:De,hgroup:De,hr:De,html:{attrs:{manifest:null}},i:De,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:gc,formmethod:pc,formnovalidate:["novalidate"],formtarget:_i,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:De,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:De,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:De,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:mc,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:De,noscript:De,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:De,param:{attrs:{name:null,value:null}},pre:De,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:De,rt:De,ruby:De,samp:De,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:mc}},section:De,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:De,source:{attrs:{src:null,type:null,media:null}},span:De,strong:De,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:De,summary:De,sup:De,table:De,tbody:De,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:De,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:De,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:De,time:{attrs:{datetime:null}},title:De,tr:De,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:De,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:De},u1={accesskey:null,class:null,contenteditable:hr,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:hr,autocorrect:hr,autocapitalize:hr,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":hr,"aria-autocomplete":["inline","list","both","none"],"aria-busy":hr,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":hr,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":hr,"aria-hidden":hr,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":hr,"aria-multiselectable":hr,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":hr,"aria-relevant":null,"aria-required":hr,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},h1="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(r=>"on"+r);for(let r of h1)u1[r]=null;class go{constructor(e,t){this.tags={...XA,...e},this.globalAttrs={...u1,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}go.default=new go;function si(r,e,t=r.length){if(!e)return"";let n=e.firstChild,s=n&&n.getChild("TagName");return s?r.sliceString(s.from,Math.min(s.to,t)):""}function ii(r,e=!1){for(;r;r=r.parent)if(r.name=="Element")if(e)e=!1;else return r;return null}function d1(r,e,t){let n=t.tags[si(r,ii(e))];return n?.children||t.allTags}function Eh(r,e){let t=[];for(let n=ii(e);n&&!n.type.isTop;n=ii(n.parent)){let s=si(r,n);if(s&&n.lastChild.name=="CloseTag")break;s&&t.indexOf(s)<0&&(e.name=="EndTag"||e.from>=n.firstChild.to)&&t.push(s)}return t}const f1=/^[:\-\.\w\u00b7-\uffff]*$/;function _m(r,e,t,n,s){let i=/\s*>/.test(r.sliceDoc(s,s+5))?"":">",o=ii(t,t.name=="StartTag"||t.name=="TagName");return{from:n,to:s,options:d1(r.doc,o,e).map(a=>({label:a,type:"type"})).concat(Eh(r.doc,t).map((a,l)=>({label:"/"+a,apply:"/"+a+i,type:"type",boost:99-l}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function Rm(r,e,t,n){let s=/\s*>/.test(r.sliceDoc(n,n+5))?"":">";return{from:t,to:n,options:Eh(r.doc,e).map((i,o)=>({label:i,apply:i+s,type:"type",boost:99-o})),validFor:f1}}function IA(r,e,t,n){let s=[],i=0;for(let o of d1(r.doc,t,e))s.push({label:"<"+o,type:"type"});for(let o of Eh(r.doc,t))s.push({label:"</"+o+">",type:"type",boost:99-i++});return{from:n,to:n,options:s,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function VA(r,e,t,n,s){let i=ii(t),o=i?e.tags[si(r.doc,i)]:null,a=o&&o.attrs?Object.keys(o.attrs):[],l=o&&o.globalAttrs===!1?a:a.length?a.concat(e.globalAttrNames):e.globalAttrNames;return{from:n,to:s,options:l.map(c=>({label:c,type:"property"})),validFor:f1}}function zA(r,e,t,n,s){var i;let o=(i=t.parent)===null||i===void 0?void 0:i.getChild("AttributeName"),a=[],l;if(o){let c=r.sliceDoc(o.from,o.to),u=e.globalAttrs[c];if(!u){let h=ii(t),f=h?e.tags[si(r.doc,h)]:null;u=f?.attrs&&f.attrs[c]}if(u){let h=r.sliceDoc(n,s).toLowerCase(),f='"',p='"';/^['"]/.test(h)?(l=h[0]=='"'?/^[^"]*$/:/^[^']*$/,f="",p=r.sliceDoc(s,s+1)==h[0]?"":h[0],h=h.slice(1),n++):l=/^[^\s<>='"]*$/;for(let g of u)a.push({label:g,apply:f+g+p,type:"constant"})}}return{from:n,to:s,options:a,validFor:l}}function m1(r,e){let{state:t,pos:n}=e,s=dt(t).resolveInner(n,-1),i=s.resolve(n);for(let o=n,a;i==s&&(a=s.childBefore(o));){let l=a.lastChild;if(!l||!l.type.isError||l.from<l.to)break;i=s=a,o=l.from}return s.name=="TagName"?s.parent&&/CloseTag$/.test(s.parent.name)?Rm(t,s,s.from,n):_m(t,r,s,s.from,n):s.name=="StartTag"||s.name=="IncompleteTag"?_m(t,r,s,n,n):s.name=="StartCloseTag"||s.name=="IncompleteCloseTag"?Rm(t,s,n,n):s.name=="OpenTag"||s.name=="SelfClosingTag"||s.name=="AttributeName"?VA(t,r,s,s.name=="AttributeName"?s.from:n,n):s.name=="Is"||s.name=="AttributeValue"||s.name=="UnquotedAttributeValue"?zA(t,r,s,s.name=="Is"?n:s.from,n):e.explicit&&(i.name=="Element"||i.name=="Text"||i.name=="Document")?IA(t,r,s,n):null}function NA(r){return m1(go.default,r)}function WA(r){let{extraTags:e,extraGlobalAttributes:t}=r,n=t||e?new go(e,t):go.default;return s=>m1(n,s)}const qA=rn.parser.configure({top:"SingleExpression"}),p1=[{tag:"script",attrs:r=>r.type=="text/typescript"||r.lang=="ts",parser:i1.parser},{tag:"script",attrs:r=>r.type=="text/babel"||r.type=="text/jsx",parser:o1.parser},{tag:"script",attrs:r=>r.type=="text/typescript-jsx",parser:a1.parser},{tag:"script",attrs(r){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(r.type)},parser:qA},{tag:"script",attrs(r){return!r.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(r.type)},parser:rn.parser},{tag:"style",attrs(r){return(!r.lang||r.lang=="css")&&(!r.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(r.type))},parser:cl.parser}],g1=[{name:"style",parser:cl.parser.configure({top:"Styles"})}].concat(h1.map(r=>({name:r,parser:rn.parser}))),O1=Js.define({name:"html",parser:g4.configure({props:[Po.add({Element(r){let e=/^(\s*)(<\/)?/.exec(r.textAfter);return r.node.to<=r.pos+e[0].length?r.continue():r.lineIndent(r.node.from)+(e[2]?0:r.unit)},"OpenTag CloseTag SelfClosingTag"(r){return r.column(r.node.from)+r.unit},Document(r){if(r.pos+/\s*/.exec(r.textAfter)[0].length<r.node.to)return r.continue();let e=null,t;for(let n=r.node;;){let s=n.lastChild;if(!s||s.name!="Element"||s.to!=n.to)break;e=n=s}return e&&!((t=e.lastChild)&&(t.name=="CloseTag"||t.name=="SelfClosingTag"))?r.lineIndent(e.from)+r.unit:null}}),ai.add({Element(r){let e=r.firstChild,t=r.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:t.name=="CloseTag"?t.from:r.to}}}),dO.add({"OpenTag CloseTag":r=>r.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),Qa=O1.configure({wrap:Y0(p1,g1)});function jA(r={}){let e="",t;r.matchClosingTags===!1&&(e="noMatch"),r.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(r.nestedLanguages&&r.nestedLanguages.length||r.nestedAttributes&&r.nestedAttributes.length)&&(t=Y0((r.nestedLanguages||[]).concat(p1),(r.nestedAttributes||[]).concat(g1)));let n=t?O1.configure({wrap:t,dialect:e}):e?Qa.configure({dialect:e}):Qa;return new so(n,[Qa.data.of({autocomplete:WA(r)}),r.autoCloseTags!==!1?YA:[],ZA().support,K4().support])}const Bm=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),YA=Se.inputHandler.of((r,e,t,n,s)=>{if(r.composing||r.state.readOnly||e!=t||n!=">"&&n!="/"||!Qa.isActiveAt(r.state,e,-1))return!1;let i=s(),{state:o}=i,a=o.changeByRange(l=>{var c,u,h;let f=o.doc.sliceString(l.from-1,l.to)==n,{head:p}=l,g=dt(o).resolveInner(p,-1),O;if(f&&n==">"&&g.name=="EndTag"){let b=g.parent;if(((u=(c=b.parent)===null||c===void 0?void 0:c.lastChild)===null||u===void 0?void 0:u.name)!="CloseTag"&&(O=si(o.doc,b.parent,p))&&!Bm.has(O)){let x=p+(o.doc.sliceString(p,p+1)===">"?1:0),k=`</${O}>`;return{range:l,changes:{from:p,to:x,insert:k}}}}else if(f&&n=="/"&&g.name=="IncompleteCloseTag"){let b=g.parent;if(g.from==p-2&&((h=b.lastChild)===null||h===void 0?void 0:h.name)!="CloseTag"&&(O=si(o.doc,b,p))&&!Bm.has(O)){let x=p+(o.doc.sliceString(p,p+1)===">"?1:0),k=`${O}>`;return{range:te.cursor(p+k.length,-1),changes:{from:p,to:x,insert:k}}}}return{range:l}});return a.changes.empty?!1:(r.dispatch([i,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),v1=lh({commentTokens:{block:{open:"<!--",close:"-->"}}}),b1=new qe,x1=uM.configure({props:[ai.add(r=>!r.is("Block")||r.is("Document")||Qu(r)!=null||FA(r)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),b1.add(Qu),Po.add({Document:()=>null}),cs.add({Document:v1})]});function Qu(r){let e=/^(?:ATX|Setext)Heading(\d)$/.exec(r.name);return e?+e[1]:void 0}function FA(r){return r.name=="OrderedList"||r.name=="BulletList"}function UA(r,e){let t=r;for(;;){let n=t.nextSibling,s;if(!n||(s=Qu(n.type))!=null&&s<=e)break;t=n}return t.to}const GA=Kg.of((r,e,t)=>{for(let n=dt(r).resolveInner(t,-1);n&&!(n.from<e);n=n.parent){let s=n.type.prop(b1);if(s==null)continue;let i=UA(n,s);if(i>t)return{from:t,to:i}}return null});function Dh(r){return new $r(v1,r,[],"markdown")}const HA=Dh(x1),KA=x1.configure([yM,wM,kM,SM,{props:[ai.add({Table:(r,e)=>({from:e.doc.lineAt(r.from).to,to:r.to})})]}]),ul=Dh(KA);function JA(r,e){return t=>{if(t&&r){let n=null;if(t=/\S*/.exec(t)[0],typeof r=="function"?n=r(t):n=qa.matchLanguageName(r,t,!0),n instanceof qa)return n.support?n.support.language.parser:no.getSkippingParser(n.load());if(n)return n.parser}return e?e.parser:null}}class Oc{constructor(e,t,n,s,i,o,a){this.node=e,this.from=t,this.to=n,this.spaceBefore=s,this.spaceAfter=i,this.type=o,this.item=a}blank(e,t=!0){let n=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(e!=null){for(;n.length<e;)n+=" ";return n}else{for(let s=this.to-this.from-n.length-this.spaceAfter.length;s>0;s--)n+=" ";return n+(t?this.spaceAfter:"")}}marker(e,t){let n=this.node.name=="OrderedList"?String(+k1(this.item,e)[2]+t):"";return this.spaceBefore+n+this.type+this.spaceAfter}}function y1(r,e){let t=[],n=[];for(let s=r;s;s=s.parent){if(s.name=="FencedCode")return n;(s.name=="ListItem"||s.name=="Blockquote")&&t.push(s)}for(let s=t.length-1;s>=0;s--){let i=t[s],o,a=e.lineAt(i.from),l=i.from-a.from;if(i.name=="Blockquote"&&(o=/^ *>( ?)/.exec(a.text.slice(l))))n.push(new Oc(i,l,l+o[0].length,"",o[1],">",null));else if(i.name=="ListItem"&&i.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(a.text.slice(l)))){let c=o[3],u=o[0].length;c.length>=4&&(c=c.slice(0,c.length-4),u-=4),n.push(new Oc(i.parent,l,l+u,o[1],c,o[2],i))}else if(i.name=="ListItem"&&i.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(a.text.slice(l)))){let c=o[4],u=o[0].length;c.length>4&&(c=c.slice(0,c.length-4),u-=4);let h=o[2];o[3]&&(h+=o[3].replace(/[xX]/," ")),n.push(new Oc(i.parent,l,l+u,o[1],c,h,i))}}return n}function k1(r,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(r.from,r.from+10))}function vc(r,e,t,n=0){for(let s=-1,i=r;;){if(i.name=="ListItem"){let a=k1(i,e),l=+a[2];if(s>=0){if(l!=s+1)return;t.push({from:i.from+a[1].length,to:i.from+a[0].length,insert:String(s+2+n)})}s=l}let o=i.nextSibling;if(!o)break;i=o}}function Lh(r,e){let t=/^[ \t]*/.exec(r)[0].length;if(!t||e.facet(Qo)!=" ")return r;let n=Zr(r,4,t),s="";for(let i=n;i>0;)i>=4?(s+=" ",i-=4):(s+=" ",i--);return s+r.slice(t)}const e_=(r={})=>({state:e,dispatch:t})=>{let n=dt(e),{doc:s}=e,i=null,o=e.changeByRange(a=>{if(!a.empty||!ul.isActiveAt(e,a.from,-1)&&!ul.isActiveAt(e,a.from,1))return i={range:a};let l=a.from,c=s.lineAt(l),u=y1(n.resolveInner(l,-1),s);for(;u.length&&u[u.length-1].from>l-c.from;)u.pop();if(!u.length)return i={range:a};let h=u[u.length-1];if(h.to-h.spaceAfter.length>l-c.from)return i={range:a};let f=l>=h.to-h.spaceAfter.length&&!/\S/.test(c.text.slice(h.to));if(h.item&&f){let x=h.node.firstChild,k=h.node.getChild("ListItem","ListItem");if(x.to>=l||k&&k.to<l||c.from>0&&!/[^\s>]/.test(s.lineAt(c.from-1).text)||r.nonTightLists===!1){let w=u.length>1?u[u.length-2]:null,S,Q="";w&&w.item?(S=c.from+w.from,Q=w.marker(s,1)):S=c.from+(w?w.to:0);let L=[{from:S,to:l,insert:Q}];return h.node.name=="OrderedList"&&vc(h.item,s,L,-2),w&&w.node.name=="OrderedList"&&vc(w.item,s,L),{range:te.cursor(S+Q.length),changes:L}}else{let w=Em(u,e,c);return{range:te.cursor(l+w.length+1),changes:{from:c.from,insert:w+e.lineBreak}}}}if(h.node.name=="Blockquote"&&f&&c.from){let x=s.lineAt(c.from-1),k=/>\s*$/.exec(x.text);if(k&&k.index==h.from){let w=e.changes([{from:x.from+k.index,to:x.to},{from:c.from+h.from,to:c.to}]);return{range:a.map(w),changes:w}}}let p=[];h.node.name=="OrderedList"&&vc(h.item,s,p);let g=h.item&&h.item.from<c.from,O="";if(!g||/^[\s\d.)\-+*>]*/.exec(c.text)[0].length>=h.to)for(let x=0,k=u.length-1;x<=k;x++)O+=x==k&&!g?u[x].marker(s,1):u[x].blank(x<k?Zr(c.text,4,u[x+1].from)-O.length:null);let b=l;for(;b>c.from&&/\s/.test(c.text.charAt(b-c.from-1));)b--;return O=Lh(O,e),r_(h.node,e.doc)&&(O=Em(u,e,c)+e.lineBreak+O),p.push({from:b,to:l,insert:e.lineBreak+O}),{range:te.cursor(b+O.length+1),changes:p}});return i?!1:(t(e.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},t_=e_();function Zm(r){return r.name=="QuoteMark"||r.name=="ListMark"}function r_(r,e){if(r.name!="OrderedList"&&r.name!="BulletList")return!1;let t=r.firstChild,n=r.getChild("ListItem","ListItem");if(!n)return!1;let s=e.lineAt(t.to),i=e.lineAt(n.from),o=/^[\s>]*$/.test(s.text);return s.number+(o?0:1)<i.number}function Em(r,e,t){let n="";for(let s=0,i=r.length-2;s<=i;s++)n+=r[s].blank(s<i?Zr(t.text,4,r[s+1].from)-n.length:null,s<i);return Lh(n,e)}function n_(r,e){let t=r.resolveInner(e,-1),n=e;Zm(t)&&(n=t.from,t=t.parent);for(let s;s=t.childBefore(n);)if(Zm(s))n=s.from;else if(s.name=="OrderedList"||s.name=="BulletList")t=s.lastChild,n=t.to;else break;return t}const s_=({state:r,dispatch:e})=>{let t=dt(r),n=null,s=r.changeByRange(i=>{let o=i.from,{doc:a}=r;if(i.empty&&ul.isActiveAt(r,i.from)){let l=a.lineAt(o),c=y1(n_(t,o),a);if(c.length){let u=c[c.length-1],h=u.to-u.spaceAfter.length+(u.spaceAfter?1:0);if(o-l.from>h&&!/\S/.test(l.text.slice(h,o-l.from)))return{range:te.cursor(l.from+h),changes:{from:l.from+h,to:o}};if(o-l.from==h&&(!u.item||l.from<=u.item.from||!/\S/.test(l.text.slice(0,u.to)))){let f=l.from+u.from;if(u.item&&u.node.from<u.item.from&&/\S/.test(l.text.slice(u.from,u.to))){let p=u.blank(Zr(l.text,4,u.to)-Zr(l.text,4,u.from));return f==l.from&&(p=Lh(p,r)),{range:te.cursor(f+p.length),changes:{from:f,to:l.from+u.to,insert:p}}}if(f<o)return{range:te.cursor(f),changes:{from:f,to:o}}}}}return n={range:i}});return n?!1:(e(r.update(s,{scrollIntoView:!0,userEvent:"delete"})),!0)},i_=[{key:"Enter",run:t_},{key:"Backspace",run:s_}],w1=jA({matchClosingTags:!1});function o_(r={}){let{codeLanguages:e,defaultCodeLanguage:t,addKeymap:n=!0,base:{parser:s}=HA,completeHTMLTags:i=!0,pasteURLAsLink:o=!0,htmlTagLanguage:a=w1}=r;if(!(s instanceof Tl))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let l=r.extensions?[r.extensions]:[],c=[a.support,GA],u;o&&c.push(u_),t instanceof so?(c.push(t.support),u=t.language):t&&(u=t);let h=e||u?JA(e,u):void 0;l.push(dM({codeParser:h,htmlParser:a.language.parser})),n&&c.push(kn.high(So.of(i_)));let f=Dh(s.configure(l));return i&&c.push(f.data.of({autocomplete:a_})),new so(f,c)}function a_(r){let{state:e,pos:t}=r,n=/<[:\-\.\w\u00b7-\uffff]*$/.exec(e.sliceDoc(t-25,t));if(!n)return null;let s=dt(e).resolveInner(t,-1);for(;s&&!s.type.isTop;){if(s.name=="CodeBlock"||s.name=="FencedCode"||s.name=="ProcessingInstructionBlock"||s.name=="CommentBlock"||s.name=="Link"||s.name=="Image")return null;s=s.parent}return{from:t-n[0].length,to:t,options:l_(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let bc=null;function l_(){if(bc)return bc;let r=NA(new bh(He.create({extensions:w1}),0,!0));return bc=r?r.options:[]}const c_=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,u_=Se.domEventHandlers({paste:(r,e)=>{var t;let{main:n}=e.state.selection;if(n.empty)return!1;let s=(t=r.clipboardData)===null||t===void 0?void 0:t.getData("text/plain");if(!s||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(s)||(/^www\./.test(s)&&(s="https://"+s),!ul.isActiveAt(e.state,n.from,1)))return!1;let i=dt(e.state),o=!1;return i.iterate({from:n.from,to:n.to,enter:a=>{(a.from>n.from||c_.test(a.name))&&(o=!0)},leave:a=>{a.to<n.to&&(o=!0)}}),o?!1:(e.dispatch({changes:[{from:n.from,insert:"["},{from:n.to,insert:`](${s})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}}),h_="#e5c07b",Dm="#e06c75",d_="#56b6c2",f_="#ffffff",Pa="#abb2bf",Pu="#7d8799",m_="#61afef",p_="#98c379",Lm="#d19a66",g_="#c678dd",O_="#21252b",Xm="#2c313a",Im="#282c34",xc="#353a42",v_="#3E4451",Vm="#528bff",b_=Se.theme({"&":{color:Pa,backgroundColor:Im},".cm-content":{caretColor:Vm},".cm-cursor, .cm-dropCursor":{borderLeftColor:Vm},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:v_},".cm-panels":{backgroundColor:O_,color:Pa},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Im,color:Pu,border:"none"},".cm-activeLineGutter":{backgroundColor:Xm},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:xc},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:xc,borderBottomColor:xc},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Xm,color:Pa}}},{dark:!0}),x_=Mo.define([{tag:$.keyword,color:g_},{tag:[$.name,$.deleted,$.character,$.propertyName,$.macroName],color:Dm},{tag:[$.function($.variableName),$.labelName],color:m_},{tag:[$.color,$.constant($.name),$.standard($.name)],color:Lm},{tag:[$.definition($.name),$.separator],color:Pa},{tag:[$.typeName,$.className,$.number,$.changed,$.annotation,$.modifier,$.self,$.namespace],color:h_},{tag:[$.operator,$.operatorKeyword,$.url,$.escape,$.regexp,$.link,$.special($.string)],color:d_},{tag:[$.meta,$.comment],color:Pu},{tag:$.strong,fontWeight:"bold"},{tag:$.emphasis,fontStyle:"italic"},{tag:$.strikethrough,textDecoration:"line-through"},{tag:$.link,color:Pu,textDecoration:"underline"},{tag:$.heading,fontWeight:"bold",color:Dm},{tag:[$.atom,$.bool,$.special($.variableName)],color:Lm},{tag:[$.processingInstruction,$.string,$.inserted],color:p_},{tag:$.invalid,color:f_}]),y_=[b_,lO(x_)],k_=Ve({__name:"MarkdownCodeEditor",props:{modelValue:{},readOnly:{type:Boolean,default:!1},lineToReveal:{default:null}},emits:["update:modelValue"],setup(r,{emit:e}){const t=r,n=e,s=P(null);let i=null,o=!1,a=null;const l=We.define(),c=We.define(),u=Tt.define({create(){return Le.none},update(g,O){let b=g.map(O.changes);for(const x of O.effects)if(x.is(c)&&(b=Le.none),x.is(l)){const k=Math.max(1,Math.min(x.value,O.state.doc.lines)),w=O.state.doc.line(k);b=Le.set([Le.line({class:"cm-target-line"}).range(w.from)])}return b},provide:g=>Se.decorations.from(g)});function h(){i&&(a&&clearTimeout(a),a=setTimeout(()=>{i&&i.dispatch({effects:c.of(void 0)})},1600))}function f(g){if(!i)return;const O=Math.max(1,Math.min(g,i.state.doc.lines)),b=i.state.doc.line(O);i.dispatch({selection:{anchor:b.from},effects:[Se.scrollIntoView(b.from,{y:"center"}),l.of(O)]}),i.focus(),h()}function p(g,O){return He.create({doc:g,extensions:[KT,o_(),y_,Se.lineWrapping,u,Se.updateListener.of(b=>{!b.docChanged||o||n("update:modelValue",b.state.doc.toString())}),Se.theme({"&":{height:"100%",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace",fontSize:"13px",backgroundColor:"rgb(var(--color-retro-black))",color:"rgb(var(--color-retro-text))"},".cm-scroller":{overflow:"auto",lineHeight:"1.6"},".cm-gutters":{backgroundColor:"rgb(var(--color-retro-dark))",color:"rgb(var(--color-retro-subtle))",borderRight:"1px solid rgb(var(--color-retro-border))"},".cm-content":{caretColor:"rgb(var(--color-retro-cyan))",padding:"12px 0"},".cm-activeLine":{backgroundColor:"rgba(34, 211, 238, 0.08)"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"rgba(34, 211, 238, 0.22)"}}),He.readOnly.of(O)]})}return gt(()=>{s.value&&(i=new Se({state:p(t.modelValue,t.readOnly),parent:s.value}),t.lineToReveal&&f(t.lineToReveal))}),ze(()=>t.modelValue,g=>{if(!i)return;const O=i.state.doc.toString();O!==g&&(o=!0,i.dispatch({changes:{from:0,to:O.length,insert:g}}),o=!1)}),ze(()=>t.lineToReveal,g=>{g&&f(g)}),N1(()=>{a&&clearTimeout(a),i&&(i.destroy(),i=null)}),(g,O)=>(v(),y("div",{ref_key:"rootRef",ref:s,class:"h-full w-full"},null,512))}}),w_=ws(k_,[["__scopeId","data-v-d77d4160"]]),S_={class:"fixed inset-0 z-50 flex items-center justify-center"},$_={class:"relative w-[96vw] h-[94vh] bg-retro-black border border-retro-border rounded-lg shadow-2xl flex flex-col overflow-hidden"},C_={class:"flex-shrink-0 flex items-center justify-between px-4 h-12 border-b border-retro-border bg-retro-dark"},Q_={class:"flex items-center gap-3 min-w-0"},P_={class:"text-sm font-mono font-bold text-retro-cyan truncate"},T_={class:"text-xs font-mono text-retro-subtle"},M_={class:"flex items-center gap-2"},A_=["disabled"],__={class:"flex-shrink-0 flex items-center gap-0 border-b border-retro-border bg-retro-dark overflow-x-auto"},R_=["onClick"],B_={class:"flex-1 min-h-0 overflow-y-auto"},Z_={key:0,class:"p-5 max-w-6xl mx-auto"},E_={key:0,class:"flex items-center justify-center py-12"},D_={key:1,class:"flex flex-col items-center justify-center py-12 text-center px-4"},L_={class:"text-sm font-mono text-retro-red"},X_={key:2,class:"space-y-4"},I_={key:0,class:"rounded border border-retro-cyan/40 bg-retro-cyan/10 px-3 py-2 text-xs font-mono text-retro-cyan"},V_={class:"grid grid-cols-2 lg:grid-cols-5 gap-2"},z_={class:"rounded border border-retro-border bg-retro-panel px-3 py-2"},N_={class:"text-sm font-mono text-retro-text"},W_={class:"rounded border border-retro-border bg-retro-panel px-3 py-2"},q_={class:"text-sm font-mono text-retro-cyan"},j_={class:"rounded border border-retro-border bg-retro-panel px-3 py-2"},Y_={class:"text-sm font-mono text-retro-yellow"},F_={class:"rounded border border-retro-border bg-retro-panel px-3 py-2"},U_={class:"text-sm font-mono text-retro-green"},G_={class:"rounded border border-retro-border bg-retro-panel px-3 py-2"},H_={class:"text-sm font-mono text-retro-text"},K_={class:"rounded border border-retro-border bg-retro-panel px-3 py-3"},J_={class:"flex items-center justify-between gap-2 mb-2"},eR={class:"text-[11px] font-mono text-retro-subtle"},tR={key:0,class:"text-xs font-mono text-retro-green"},rR={key:1,class:"space-y-2"},nR={class:"uppercase tracking-wide mr-2"},sR={class:"rounded border border-retro-border bg-retro-panel p-3 overflow-x-auto"},iR={class:"min-w-[760px]"},oR={class:"text-retro-text"},aR=["disabled","onClick"],lR=["disabled","onClick"],cR=["disabled","onClick"],uR={class:"text-retro-muted"},hR={key:1,class:"flex items-center justify-center py-12"},dR={key:2,class:"flex flex-col items-center justify-center py-12 text-center px-4"},fR={class:"text-sm font-mono text-retro-red"},mR={key:3,class:"flex flex-col items-center justify-center py-12 text-center"},pR={key:4,class:"h-full flex flex-col"},gR=["innerHTML"],OR=Ve({__name:"SpecViewerModal",props:{feature:{}},emits:["close"],setup(r,{emit:e}){const t=r,n=e,s=vo(),{renderMarkdown:i}=Jm(),o=P(t.feature.files[0]?.filename||""),a=P("document"),l=P(""),c=P(!1),u=P(null),h=P(!1),f=P(""),p=P(!1),g=P(null),O=P(null),b=P(!1),x=P(null),k=P(null),w=J(()=>{const I={critical:0,major:1,minor:2};return[...k.value?.alerts??[]].sort((z,be)=>I[z.severity]-I[be.severity])});function S(I){return I.status==="covered"?"text-retro-green border-retro-green/40 bg-retro-green/10":I.status==="partial"?"text-retro-yellow border-retro-yellow/40 bg-retro-yellow/10":"text-retro-red border-retro-red/40 bg-retro-red/10"}function Q(I){return I.severity==="critical"?"text-retro-red border-retro-red/40 bg-retro-red/10":I.severity==="major"?"text-retro-yellow border-retro-yellow/40 bg-retro-yellow/10":"text-retro-cyan border-retro-cyan/40 bg-retro-cyan/10"}async function L(){b.value=!0,x.value=null;try{k.value=await $fetch(`/api/specs/traceability/${t.feature.id}`)}catch{x.value="Failed to load traceability data",k.value=null}finally{b.value=!1}}async function D(I=o.value){if(I){c.value=!0,u.value=null;try{const z=`/api/specs/${t.feature.id}/${I}`,be=await $fetch(z);l.value=be.content}catch{u.value="Failed to load file",l.value=""}finally{c.value=!1}}}function G(){D()}const oe=J(()=>l.value?i(l.value):"");function ie(I){O.value=null,a.value="document",h.value&&(h.value=!1),o.value=I,D()}function j(){h.value&&U(),a.value="traceability",!k.value&&!b.value&&L()}async function V(I,z,be){z&&(o.value!==I?(o.value=I,await D(I)):l.value||await D(I),a.value="document",h.value=!0,f.value=l.value,g.value=null,O.value={filename:I,line:z,requirementId:be},await It(),g.value=z)}function Z(){f.value=l.value,g.value=null,h.value=!0}function U(){h.value=!1,f.value=""}async function W(){p.value=!0;try{const I=`/api/specs/${t.feature.id}/${o.value}`;await $fetch(I,{method:"PUT",body:{content:f.value}}),l.value=f.value,h.value=!1,s.success("Saved")}catch{s.error("Failed to save")}finally{p.value=!1}}function N(I){I.key==="Escape"&&(h.value?U():n("close"))}return gt(()=>{window.addEventListener("keydown",N),D(),L()}),wt(()=>{window.removeEventListener("keydown",N)}),(I,z)=>{const be=w_;return v(),pe(Pr,{to:"body"},[d("div",S_,[d("div",{class:"absolute inset-0 bg-black/80",onClick:z[0]||(z[0]=K=>n("close"))}),d("div",$_,[d("div",C_,[d("div",Q_,[d("span",P_,A(r.feature.name),1),d("span",T_,A(r.feature.id),1)]),d("div",M_,[m(h)?(v(),y(we,{key:0},[d("button",{type:"button",class:"px-3 py-1 text-xs font-mono rounded border border-retro-border text-retro-muted hover:text-retro-text hover:border-retro-muted transition-colors",onClick:U}," Cancel "),d("button",{type:"button",class:"px-3 py-1 text-xs font-mono rounded border border-retro-cyan text-retro-cyan hover:bg-retro-cyan/10 transition-colors disabled:opacity-50",disabled:m(p),onClick:W},A(m(p)?"Saving...":"Save"),9,A_)],64)):m(a)==="document"&&m(l)&&!m(c)&&!m(u)?(v(),y("button",{key:1,type:"button",class:"p-1.5 rounded text-retro-muted hover:text-retro-cyan hover:bg-retro-panel transition-colors",title:"Edit",onClick:Z},[ee(m(dp),{class:"h-4 w-4"})])):F("",!0),d("button",{type:"button",class:"p-1.5 rounded text-retro-muted hover:text-retro-text hover:bg-retro-panel transition-colors",title:"Close (ESC)",onClick:z[1]||(z[1]=K=>n("close"))},[ee(m(St),{class:"h-4 w-4"})])])]),d("div",__,[d("button",{type:"button",class:_e(["px-4 py-2 text-xs font-mono border-b-2 transition-colors whitespace-nowrap flex items-center gap-1",[m(a)==="traceability"?"border-retro-magenta text-retro-magenta bg-retro-black":"border-transparent text-retro-muted hover:text-retro-text hover:bg-retro-panel"]]),onClick:j},[ee(m(vv),{class:"h-3.5 w-3.5"}),z[3]||(z[3]=Ie(" Traceability ",-1))],2),(v(!0),y(we,null,Ne(r.feature.files,K=>(v(),y("button",{key:K.filename,type:"button",class:_e(["px-4 py-2 text-xs font-mono border-b-2 transition-colors whitespace-nowrap",[m(a)==="document"&&m(o)===K.filename?"border-retro-cyan text-retro-cyan bg-retro-black":"border-transparent text-retro-muted hover:text-retro-text hover:bg-retro-panel"]]),onClick:H=>ie(K.filename)},A(K.label),11,R_))),128))]),d("div",B_,[m(a)==="traceability"?(v(),y("div",Z_,[m(b)?(v(),y("div",E_,[...z[4]||(z[4]=[d("span",{class:"text-sm font-mono text-retro-muted animate-pulse"},"Loading traceability...",-1)])])):m(x)?(v(),y("div",D_,[d("p",L_,A(m(x)),1),d("button",{type:"button",class:"mt-3 px-3 py-1.5 text-xs font-mono bg-retro-panel border border-retro-border rounded text-retro-muted hover:text-retro-cyan hover:border-retro-cyan transition-colors",onClick:L}," Retry ")])):m(k)?(v(),y("div",X_,[m(O)?(v(),y("div",I_," Jump target: "+A(m(O).requirementId)+" → "+A(m(O).filename)+":"+A(m(O).line),1)):F("",!0),d("div",V_,[d("div",z_,[z[5]||(z[5]=d("p",{class:"text-[11px] font-mono text-retro-subtle"},"FR total",-1)),d("p",N_,A(m(k).summary.frTotal),1)]),d("div",W_,[z[6]||(z[6]=d("p",{class:"text-[11px] font-mono text-retro-subtle"},"Plan coverage",-1)),d("p",q_,A(m(k).summary.frWithPlan)+"/"+A(m(k).summary.frTotal),1)]),d("div",j_,[z[7]||(z[7]=d("p",{class:"text-[11px] font-mono text-retro-subtle"},"Task mapping",-1)),d("p",Y_,A(m(k).summary.frWithTasks)+"/"+A(m(k).summary.frTotal),1)]),d("div",F_,[z[8]||(z[8]=d("p",{class:"text-[11px] font-mono text-retro-subtle"},"Fully covered",-1)),d("p",U_,A(m(k).summary.frFullyCovered)+"/"+A(m(k).summary.frTotal),1)]),d("div",G_,[z[9]||(z[9]=d("p",{class:"text-[11px] font-mono text-retro-subtle"},"Task progress",-1)),d("p",H_,A(m(k).summary.taskCompleted)+"/"+A(m(k).summary.taskTotal),1)])]),d("div",K_,[d("div",J_,[z[10]||(z[10]=d("h3",{class:"text-xs font-mono text-retro-text"},"Gap Alerts",-1)),d("span",eR,A(m(w).length)+" issues",1)]),m(w).length===0?(v(),y("div",tR," No traceability gaps detected. ")):(v(),y("div",rR,[(v(!0),y(we,null,Ne(m(w),K=>(v(),y("div",{key:K.id,class:_e(["rounded border px-2.5 py-2 text-xs font-mono",Q(K)])},[d("span",nR,A(K.severity),1),d("span",null,A(K.message),1)],2))),128))]))]),d("div",sR,[d("div",iR,[z[11]||(z[11]=d("div",{class:"grid grid-cols-[140px_1fr_1fr_1fr_120px] gap-2 text-[11px] font-mono text-retro-subtle px-2 pb-2 border-b border-retro-border"},[d("span",null,"Requirement"),d("span",null,"Spec"),d("span",null,"Plan"),d("span",null,"Tasks"),d("span",null,"Progress")],-1)),(v(!0),y(we,null,Ne(m(k).requirements,K=>(v(),y("div",{key:K.id,class:"grid grid-cols-[140px_1fr_1fr_1fr_120px] gap-2 items-center px-2 py-2 border-b border-retro-border/60 text-xs font-mono"},[d("span",oR,A(K.id),1),d("button",{type:"button",class:"h-6 rounded border border-retro-green/40 bg-retro-green/10 flex items-center px-2 text-retro-green disabled:opacity-50 disabled:cursor-not-allowed",disabled:!K.locations.specLine,onClick:H=>V("spec.md",K.locations.specLine,K.id)},[d("span",null,A(K.locations.specLine?`L${K.locations.specLine}`:"Defined"),1)],8,aR),d("button",{type:"button",class:_e(["h-6 rounded border flex items-center px-2 disabled:opacity-50 disabled:cursor-not-allowed",K.inPlan?"text-retro-cyan border-retro-cyan/40 bg-retro-cyan/10":"text-retro-subtle border-retro-border bg-retro-black/50"]),disabled:!K.locations.planLine,onClick:H=>V("plan.md",K.locations.planLine,K.id)},[d("span",null,A(K.locations.planLine?`L${K.locations.planLine}`:K.inPlan?"Linked":"Missing"),1)],10,lR),d("button",{type:"button",class:_e(["h-6 rounded border flex items-center px-2 disabled:opacity-50 disabled:cursor-not-allowed",S(K)]),disabled:K.locations.taskLines.length===0,onClick:H=>V("tasks.md",K.locations.taskLines[0],K.id)},[d("span",null,A(K.locations.taskLines.length>0?`L${K.locations.taskLines[0]}`:K.inTasks?"Mapped":"Missing"),1)],10,cR),d("span",uR,A(K.taskCompleted)+"/"+A(K.taskTotal),1)]))),128))])])])):F("",!0)])):m(c)?(v(),y("div",hR,[...z[12]||(z[12]=[d("span",{class:"text-sm font-mono text-retro-muted animate-pulse"},"Loading...",-1)])])):m(u)?(v(),y("div",dR,[d("p",fR,A(m(u)),1),d("button",{type:"button",class:"mt-3 px-3 py-1.5 text-xs font-mono bg-retro-panel border border-retro-border rounded text-retro-muted hover:text-retro-cyan hover:border-retro-cyan transition-colors",onClick:G}," Retry ")])):r.feature.files.length===0?(v(),y("div",mR,[...z[13]||(z[13]=[d("p",{class:"text-sm font-mono text-retro-muted"},"No spec files found",-1),d("p",{class:"mt-1 text-xs font-mono text-retro-subtle"}," This feature directory has no .md files ",-1)])])):m(h)?(v(),y("div",pR,[ee(be,{modelValue:m(f),"onUpdate:modelValue":z[2]||(z[2]=K=>Je(f)?f.value=K:null),"line-to-reveal":m(g),class:"flex-1"},null,8,["modelValue","line-to-reveal"])])):(v(),y("div",{key:5,class:"spec-markdown p-6 text-sm font-mono text-retro-text max-w-4xl mx-auto",innerHTML:m(oe)},null,8,gR))])])])])}}}),vR={class:"w-full max-w-2xl rounded-xl border border-retro-border/80 bg-retro-black shadow-[0_24px_70px_rgba(0,0,0,0.55)] overflow-hidden"},bR={class:"flex items-center justify-between px-4 py-2 border-b border-retro-border/60 bg-retro-dark/70"},xR={class:"flex items-center gap-2 px-4 py-3 border-b border-retro-border/60"},yR={class:"flex items-center justify-between px-4 py-1.5 border-b border-retro-border/40 bg-retro-dark/30 text-[10px] font-mono text-retro-subtle"},kR={class:"flex items-center gap-3"},wR={class:"inline-flex items-center gap-1"},SR={key:0},$R={key:0,class:"truncate max-w-[42%]"},CR={class:"max-h-[58vh] overflow-y-auto"},QR={key:0,class:"px-4 py-3 text-xs font-mono text-retro-subtle animate-pulse"},PR={key:1,class:"px-4 py-4 text-xs font-mono text-retro-subtle"},TR={key:2,class:"px-4 py-4 text-xs font-mono text-retro-subtle"},MR={key:3,class:"px-4 py-3 text-xs font-mono text-retro-red"},AR={key:4,class:"py-2 px-2 space-y-2"},_R=["onMouseenter","onClick"],RR={class:"flex items-center justify-between gap-3 text-[10px] font-mono"},BR={class:"text-retro-cyan/90"},ZR={class:"text-retro-subtle truncate"},ER=["innerHTML"],DR={key:5,class:"px-4 py-3 text-xs font-mono text-retro-subtle"},LR={class:"flex items-center justify-between gap-3 px-4 py-2 border-t border-retro-border/60 bg-retro-dark/50 text-[11px] font-mono text-retro-subtle"},XR={key:0,class:"text-retro-yellow"},IR={key:0,class:"px-4 pb-3 text-xs font-mono text-retro-red flex items-center gap-2"},VR=400,zR=Ve({__name:"FeatureSearchModal",props:{availableFeatureIds:{}},emits:["close","select"],setup(r,{emit:e}){const t=r,n=e,{renderMarkdown:s}=Jm(),i=P(""),o=P(!1),a=P(!1),l=P(null),c=P(null),u=P(null),h=P(null),f=P([]),p=P(-1),g=P(null),O=P([]);let b=null,x=0;const k=J(()=>i.value.trim()),w=J(()=>{const W=k.value.toLowerCase().split(/\s+/).map(N=>N.trim()).filter(N=>N.length>=2);return Array.from(new Set(W)).slice(0,8)}),S=J(()=>l.value||c.value?"error":!k.value&&a.value?"empty-query":f.value.length>0?"results":a.value&&!o.value?"no-results":"idle");function Q(W){return{featureId:W.chunk.featureId,sourcePath:W.chunk.sourcePath,headingHierarchy:W.chunk.headingHierarchy,snippet:W.chunk.content,matchType:W.matchType,score:W.score,lineStart:W.chunk.lineStart,lineEnd:W.chunk.lineEnd}}async function L(){const W=k.value;if(c.value=null,!W){a.value=!0,u.value=null,h.value=null,l.value=null,f.value=[],p.value=-1;return}const N=++x;a.value=!0,l.value=null,o.value=!0;try{const I=await $fetch("/api/specs/search",{query:{q:W,mode:"keyword",limit:20}});if(N!==x)return;u.value=I.warning??null,h.value=I.searchTime,f.value=I.results.map(Q),p.value=f.value.length>0?0:-1}catch(I){if(N!==x)return;const z=I instanceof Error?I.message:"Failed to search specs";l.value=z,h.value=null,f.value=[],p.value=-1}finally{N===x&&(o.value=!1)}}ze(i,()=>{l.value=null,c.value=null,b&&clearTimeout(b),b=setTimeout(()=>{L()},VR)}),ze(f,()=>{O.value=[]}),ze(p,async W=>{W<0||(await It(),O.value[W]?.scrollIntoView({block:"nearest"}))});function D(){n("close")}function G(W){const N=f.value[W];if(N){if(!t.availableFeatureIds.includes(N.featureId)){c.value="Feature unavailable";return}n("select",N.featureId),n("close")}}function oe(W){if(f.value.length===0)return;if(p.value<0){p.value=0;return}const N=p.value+W;if(N<0){p.value=f.value.length-1;return}if(N>=f.value.length){p.value=0;return}p.value=N}function ie(W){if(W.key==="ArrowDown"){W.preventDefault(),oe(1);return}if(W.key==="ArrowUp"){W.preventDefault(),oe(-1);return}if(W.key==="Enter"){W.preventDefault(),p.value>=0&&G(p.value);return}W.key==="Escape"&&(W.preventDefault(),D())}function j(W){W.target===W.currentTarget&&D()}function V(W,N){if(!N){O.value[W]=null;return}if(N instanceof HTMLElement){O.value[W]=N;return}const I=N.$el;O.value[W]=I instanceof HTMLElement?I:null}function Z(){L()}function U(W){const N=W.trim();if(!N)return"";const I=N.length>700?`${N.slice(0,700)}...`:N,z=s(I);if(w.value.length===0)return z;const be=w.value.map(H=>H.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),K=new RegExp(`(${be.join("|")})`,"gi");return z.split(/(<[^>]+>)/g).map(H=>H.startsWith("<")?H:H.replace(K,"<mark>$1</mark>")).join("")}return gt(()=>{It(()=>{g.value?.focus()})}),wt(()=>{b&&clearTimeout(b)}),(W,N)=>(v(),pe(Pr,{to:"body"},[ee(On,{appear:"","enter-active-class":"transition duration-150 ease-out","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition duration-120 ease-in","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ut(()=>[d("div",{class:"fixed inset-0 z-50 flex items-start justify-center pt-16 px-4 bg-black/75 backdrop-blur-[1px]",onClick:j},[ee(On,{appear:"","enter-active-class":"transition duration-150 ease-out","enter-from-class":"opacity-0 translate-y-2 scale-[0.99]","enter-to-class":"opacity-100 translate-y-0 scale-100","leave-active-class":"transition duration-120 ease-in","leave-from-class":"opacity-100 translate-y-0 scale-100","leave-to-class":"opacity-0 translate-y-1 scale-[0.995]"},{default:ut(()=>[d("div",vR,[d("div",bR,[N[1]||(N[1]=d("div",{class:"flex items-center gap-2"},[d("span",{class:"inline-flex items-center rounded px-2 py-0.5 text-[10px] font-mono border border-retro-cyan/50 text-retro-cyan bg-retro-cyan/10"}," Command Palette "),d("span",{class:"text-[10px] font-mono text-retro-subtle"},"Global spec search")],-1)),d("button",{type:"button",class:"p-1 rounded text-retro-muted hover:text-retro-text hover:bg-retro-panel transition-colors",title:"Close (Escape)",onClick:D},[ee(m(St),{class:"h-4 w-4"})])]),d("div",xR,[ee(m(fs),{class:"h-4 w-4 text-retro-cyan"}),je(d("input",{ref_key:"inputRef",ref:g,"onUpdate:modelValue":N[0]||(N[0]=I=>Je(i)?i.value=I:null),type:"text",placeholder:"Search specs across all features...",class:"flex-1 bg-transparent text-sm font-mono text-retro-text placeholder:text-retro-subtle focus:outline-none",onKeydown:ie},null,544),[[Rt,m(i)]]),N[2]||(N[2]=d("span",{class:"text-[10px] font-mono text-retro-subtle border border-retro-border/60 rounded px-1.5 py-0.5"},"400ms",-1))]),d("div",yR,[d("div",kR,[d("span",wR,[ee(m(Os),{class:"h-3.5 w-3.5"}),Ie(" "+A(m(f).length)+" results ",1)]),m(h)!==null?(v(),y("span",SR,A(m(h))+"ms",1)):F("",!0)]),m(k)?(v(),y("span",$R,"“"+A(m(k))+"”",1)):F("",!0)]),d("div",CR,[m(o)?(v(),y("div",QR," Searching... ")):m(S)==="empty-query"?(v(),y("div",PR," Enter a search term to search across all feature specs. ")):m(S)==="no-results"?(v(),y("div",TR," No matching features found. ")):m(S)==="error"?(v(),y("div",MR,[d("p",null,A(m(c)||m(l)),1),m(l)?(v(),y("button",{key:0,type:"button",class:"mt-2 px-2 py-1 rounded border border-retro-border text-retro-muted hover:text-retro-cyan hover:border-retro-cyan transition-colors",onClick:Z}," Retry ")):F("",!0)])):m(f).length>0?(v(),y("ul",AR,[(v(!0),y(we,null,Ne(m(f),(I,z)=>(v(),y("li",{key:`${I.featureId}:${I.sourcePath}:${z}`},[d("button",{type:"button",ref_for:!0,ref:be=>V(z,be),class:_e(["w-full text-left px-4 py-3 min-h-[132px] rounded-lg border border-retro-border/40 border-l-2 transition-colors",z===m(p)?"border-retro-cyan bg-retro-panel/95 text-retro-text shadow-[0_0_0_1px_rgba(34,211,238,0.18)]":"text-retro-muted hover:text-retro-text hover:bg-retro-panel/90"]),onMouseenter:be=>p.value=z,onClick:be=>G(z)},[d("div",RR,[d("span",BR,A(I.featureId),1),d("span",ZR,A(I.sourcePath)+":"+A(I.lineStart)+"-"+A(I.lineEnd),1)]),d("div",{class:"snippet-markdown mt-2 max-h-20 overflow-hidden text-xs text-retro-text",innerHTML:U(I.snippet)},null,8,ER),N[3]||(N[3]=d("div",{class:"mt-2 text-[10px] font-mono text-retro-subtle"}," Select feature ",-1))],42,_R)]))),128))])):(v(),y("div",DR," Start typing to search. "))]),d("div",LR,[N[4]||(N[4]=d("div",{class:"flex items-center gap-2"},[d("span",{class:"border border-retro-border/70 rounded px-1.5 py-0.5"},"↑↓ move"),d("span",{class:"border border-retro-border/70 rounded px-1.5 py-0.5"},"Enter select"),d("span",{class:"border border-retro-border/70 rounded px-1.5 py-0.5"},"Esc close")],-1)),m(u)?(v(),y("span",XR,A(m(u)),1)):F("",!0)]),m(c)?(v(),y("div",IR,[ee(m(En),{class:"h-3.5 w-3.5"}),d("span",null,A(m(c)),1)])):F("",!0)])]),_:1})])]),_:1})]))}}),NR=ws(zR,[["__scopeId","data-v-5199b408"]]);function WR(r){return/^\/speckit\.(clarify|plan|tasks|implement)(\s|$)/.test(r)}function qR(r=Date.now,e=Math.random){return`req-${r()}-${e().toString(36).slice(2,8)}`}function zm(r=Date.now){return`session-${r()}`}function Ta(r,e=!1){const t={};return(!e||r?.hasWorktree)&&r?.worktreePath&&(t.cwd=r.worktreePath,t.worktreeBranch=r.worktreeBranch),r?.baseBranch&&(t.baseBranch=r.baseBranch),r?.featureId&&(t.featureId=r.featureId),Object.keys(t).length>0?t:void 0}function S1(r){if(r.file_path)return String(r.file_path);if(r.path)return String(r.path);if(r.command)return String(r.command).slice(0,50);if(r.pattern)return String(r.pattern);for(const e of Object.values(r))if(typeof e=="string"&&e.length<100)return e;return""}function jR(r){switch(r){case 1e3:return"Normal closure";case 1001:return"Endpoint is going away (server shutdown or page navigation)";case 1002:return"Protocol error";case 1003:return"Unsupported data";case 1005:return"No status code received from peer (close frame had no code)";case 1006:return"Abnormal closure (connection dropped without close frame)";case 1007:return"Invalid payload data";case 1008:return"Policy violation";case 1009:return"Message too big";case 1010:return"Missing required extension";case 1011:return"Internal server error";case 1012:return"Service restart";case 1013:return"Try again later (temporary overload)";case 1015:return"TLS handshake failure";default:return r>=4e3&&r<=4999?"Application-specific close code":"Unknown close code"}}function YR(r,e){const t=[];return r.reason?t.push(r.reason):t.push(jR(r.code)),e?.lastServerError?t.push(`Last server error: ${e.lastServerError}`):e?.lastSocketError&&t.push(`Last socket error: ${e.lastSocketError}`),t.push(`wasClean: ${r.wasClean?"yes":"no"}`),t.join(" | ")}function Nm(r,e="Permission"){const t=r||"",n=t.match(/write to (.+?)(?:[\s,?]|$)/i),s=t.match(/read (.+?)(?:[\s,?]|$)/i),i=t.match(/run (.+?)(?:[?,]|$)/i);return n?.[1]?{tool:"Write",description:t,filePath:n[1].trim()}:s?.[1]?{tool:"Read",description:t,filePath:s[1].trim()}:i?.[1]?{tool:"Bash",description:t,command:i[1].trim()}:{tool:e,description:t}}function FR(){return typeof document>"u"||typeof document.hasFocus!="function"?!1:document.visibilityState==="visible"&&document.hasFocus()}function UR(){return typeof window>"u"?"":`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/_ws`}function yc(r,e){return`${r}:${e}`}function da(r,e){for(const t of r)if(t.type==="tool_use"){const n=t;(n.status==="running"||n.status==="pending")&&(n.status=e)}}function GR(){const r=new Map;function e(a,l,c){r.set(a,{featureId:l,queue:[...c]})}function t(a){a?r.delete(a):r.clear()}function n(a){return r.get(a)}function s(a){const l=r.get(a);if(!l||l.queue.length===0)return null;const c=l.queue.shift();return l.queue.length===0&&r.delete(a),{featureId:l.featureId,step:c}}function i(a){return r.has(a)}function o(){return r.size}return{enable:e,disable:t,get:n,popNextStep:s,has:i,size:o}}function $1(r,e=Ht){return{id:e(),type:"session_init",model:r.model,tools:r.tools,permissionMode:r.permissionMode,cwd:r.cwd}}function C1(r,e=Ht){return{id:r.blockId||e(),type:"text",text:r.text||""}}function Q1(r,e=Ht){return{id:r.blockId||e(),type:"thinking",thinking:r.thinking||""}}function P1(r,e=Ht){if(!r.toolUseId||!r.name)return null;const t=r.blockId||e();return{block:{id:t,type:"tool_use",toolUseId:r.toolUseId,name:r.name,input:{},inputSummary:"",status:"running"},tracking:{blockId:t,toolUseId:r.toolUseId,name:r.name,inputJson:""},index:r.index??0}}function T1(r,e=Ht){return{id:e(),type:"tool_result",toolUseId:r.toolUseId,content:r.content||"",isError:!!r.isError}}function M1(r,e=Ht){return r.subtype!=="success"||!r.usage?null:{id:e(),type:"result_summary",totalCostUsd:r.totalCostUsd??0,durationMs:r.durationMs??0,numTurns:r.numTurns??0,usage:r.usage}}function hl(r,e,t){if(e!==void 0){const n=r.get(e);if(n)return n}if(t){for(const[,n]of r)if(n.blockId===t)return n}}function HR(r,e=Ht){const t=[],n=new Map,s=[];let i="",o=null,a=null,l="streaming",c=!1;for(const u of r){if(u.type==="done"){u.denied?(da(t,"error"),l="stopped"):u.awaitingUserInput?l="complete":l==="error"||l==="stopped"?da(t,"error"):(da(t,"complete"),l="complete"),c=!0;continue}if(u.type==="error"){da(t,"error"),l="error";continue}if(u.type!=="ui_event"||!u.event)continue;const h=u.event;switch(h.sessionId&&s.push(h.sessionId),h.type){case"session_init":{t.push($1(h,e));break}case"block_start":{if(h.blockType==="text"){const f=C1(h,e);t.push(f),o=f.id,h.text&&(i+=h.text)}else if(h.blockType==="thinking"){const f=Q1(h,e);t.push(f),a=f.id}else if(h.blockType==="tool_use"){const f=P1(h,e);f&&(t.push(f.block),n.set(f.index,f.tracking))}break}case"block_delta":{if(h.text&&o){const f=t.find(p=>p.id===o);f&&f.type==="text"&&(f.text+=h.text,i+=h.text)}if(h.thinking&&a){const f=t.find(p=>p.id===a);f&&f.type==="thinking"&&(f.thinking+=h.thinking)}if(h.partialJson){const f=hl(n,h.index,h.blockId);f&&(f.inputJson+=h.partialJson)}break}case"block_end":{const f=hl(n,h.index,h.blockId);if(!f)o&&(o=null),a&&(a=null);else{let p={};try{p=JSON.parse(f.inputJson)}catch{}const g=t.find(O=>O.id===f.blockId);if(g&&g.type==="tool_use"){const O=g;O.input=p,O.inputSummary=S1(p),O.status="pending"}}break}case"tool_result":{const f=t.find(p=>p.type==="tool_use"&&p.toolUseId===h.toolUseId);f&&f.type==="tool_use"&&(f.status=h.isError?"error":"complete"),t.push(T1(h,e));break}case"turn_result":{h.subtype!=="success"&&(l="error");const f=M1(h,e);f&&t.push(f);break}case"error":{l="error";break}}}return{contentBlocks:t,flatText:i,currentTextBlockId:o,currentThinkingBlockId:a,activeTools:n,finalStatus:l,isDone:c,providerSessionIds:s}}function KR(r,e,t=Date.now){return{ws:r,currentMessageId:"",conversationId:e,activeTools:new Map,currentTextBlockId:null,currentThinkingBlockId:null,healthCheckInterval:null,lastMessageTime:t(),lastServerError:null,lastSocketError:null,isReplaying:!1,replayBuffer:[]}}function kc(r,e,t){const n=r.get(e);return!!n&&n.ws!==t}function JR(r,e){const t=r.get(e);return t?t.ws.readyState===WebSocket.OPEN?{kind:"open",conn:t}:{kind:"stale",conn:t}:{kind:"none"}}const mt=new Map;let fa=0;const As=GR(),ma=new Set,eB=3e4,A1=18e4,tB=Math.round(A1/1e3);function Ml(){const r=vr(),e=bo();fa++;function t(T){const E=r.conversations.find(B=>B.id===T)?.title?.trim()||"Chat";return new Notification("Spec Cat",{body:`${E} response completed.`,tag:`chat-complete-${T}`})}async function n(T){if(!(typeof window>"u"||typeof Notification>"u")&&!FR()){if(Notification.permission==="granted"){t(T);return}if(Notification.permission==="default")try{await Notification.requestPermission()==="granted"&&t(T)}catch(M){console.warn("[useChatStream] Failed to request browser notification permission:",M)}}}function s(T){T.healthCheckInterval&&(clearInterval(T.healthCheckInterval),T.healthCheckInterval=null)}function i(T){s(T),T.lastMessageTime=Date.now(),T.healthCheckInterval=Lu(()=>{const M=T.conversationId;if(T.ws.readyState!==WebSocket.OPEN){console.warn(`[useChatStream] Health check: WebSocket not open for ${M}`),s(T),r.isConversationStreaming(M)&&(c(T.currentMessageId,M,"error"),r.updateMessage(T.currentMessageId,{status:"error"},M),r.setSessionError("Connection lost during streaming",M),r.endSession(M),r.endConversationStreaming(M)),mt.delete(M);return}if(r.isConversationStreaming(M)){const E=Date.now()-T.lastMessageTime;E>A1&&(console.warn(`[useChatStream] Health check: streaming timeout for ${M} (${Math.round(E/1e3)}s)`),s(T),c(T.currentMessageId,M,"error"),r.updateMessage(T.currentMessageId,{status:"error"},M),r.setSessionError(`Streaming timed out — no response from server for ${tB} seconds`,M),r.endSession(M),r.endConversationStreaming(M),T.ws.close(),mt.delete(M))}},eB)}function o(T,M){return r.conversations.find(B=>B.id===T)?.messages.find(B=>B.id===M)?.status}function a(T,M=!0){const E=mt.get(T);E&&(s(E),M&&E.ws.readyState===WebSocket.OPEN&&E.ws.close(),mt.delete(T))}function l(T,M,E){!E||!T.currentTextBlockId||(r.updateBlockWithSave(T.currentMessageId,T.currentTextBlockId,B=>{B.type==="text"&&(B.text+=E)},M,{syncContent:!1}),r.appendToMessage(T.currentMessageId,E,M))}function c(T,M,E){const xe=r.conversations.find(Re=>Re.id===M)?.messages.find(Re=>Re.id===T);if(xe?.contentBlocks)for(const Re of xe.contentBlocks)Re.type==="tool_use"&&(Re.status==="running"||Re.status==="pending")&&r.updateBlockById(T,Re.id,Me=>{Me.type==="tool_use"&&(Me.status=E)},M)}async function u(T){try{(await h(T)).send(JSON.stringify({type:"reset_context"})),r.clearProviderSession(T),console.log("[useChatStream] Context reset requested for conversation:",T)}catch(M){throw console.error("[useChatStream] Failed to reset context:",M),M}}function h(T){return new Promise((M,E)=>{let B=!1;const xe=q=>{B||(B=!0,M(q))},Re=q=>{B||(B=!0,E(q))},Me=JR(mt,T);if(Me.kind==="open"){xe(Me.conn.ws);return}Me.kind==="stale"&&(Me.conn.ws.close(),mt.delete(T));const ue=UR(),ne=new WebSocket(ue),Ce=KR(ne,T);mt.set(T,Ce),ne.onopen=()=>{xe(ne)},ne.onerror=q=>{if(console.error(`[useChatStream] WebSocket error for conversation ${T}:`,q),kc(mt,T,ne))return;const ve=mt.get(T);ve&&(ve.lastSocketError="Browser reported a WebSocket transport error (network/proxy/server)"),r.isConversationStreaming(T)&&(ve?.currentMessageId&&(c(ve.currentMessageId,T,"error"),r.updateMessage(ve.currentMessageId,{status:"error"},T)),r.setSessionError("Connection error during streaming",T),r.endSession(T),r.endConversationStreaming(T)),mt.delete(T),Re(new Error("WebSocket connection failed. Server may be unavailable."))},ne.onclose=q=>{if(kc(mt,T,ne))return;const ve=mt.get(T);if(ve&&s(ve),mt.delete(T),As.disable(T),!B){Re(new Error(`WebSocket closed before connection was established (code: ${q.code})`));return}if(r.isConversationStreaming(T)){ve?.currentMessageId&&(c(ve.currentMessageId,T,"error"),r.updateMessage(ve.currentMessageId,{status:"error"},T));const Ze=YR(q,ve);r.setSessionError(`Connection closed: ${Ze} (code: ${q.code})`,T),r.endSession(T),r.endConversationStreaming(T)}},ne.onmessage=q=>{kc(mt,T,ne)||g(q.data,T)}})}async function f(T,M=3){for(let E=0;E<M;E++){const B=r.conversations.find(xe=>xe.id===T);if(B)return B;E<M-1&&await new Promise(xe=>setTimeout(xe,100))}console.error("[useChatStream] Conversation not found after retries:",T)}function p(T,M){const E=r.conversations.find(xe=>xe.id===T);if(!E)return null;const B=E.messages.findIndex(xe=>xe.id===M);if(B<=0)return null;for(let xe=B-1;xe>=0;xe--){const Re=E.messages[xe];if(Re.role==="user"&&Re.content.trim().length>0)return Re.content}return null}async function g(T,M){const E=mt.get(M);if(E){E.lastMessageTime=Date.now();try{r.pushDebugEvent({direction:"in",channel:"ws",eventType:"ws.raw",payload:T},M);const B=JSON.parse(T);if(r.pushDebugEvent({direction:"in",channel:"ws",eventType:B.type,payload:B},M),E.isReplaying&&((B.type==="ui_event"||B.type==="done"||B.type==="error")&&E.replayBuffer.push(B),B.type!=="replay_end"))return;if(B.type==="error")return await Q(B,E,M),void 0;if(B.type==="done"){await L(B,E,M);return}if(B.type==="pong")return;if(B.type==="session_reset"){console.warn(`[useChatStream] Session reset for ${M}:`,B.reason),r.setProviderSessionId("",M),W(E.currentMessageId,`
39
+ }`,{label:"class",detail:"definition",type:"keyword"}),Gt('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Gt('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],MA=e1.concat([Gt("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Gt("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Gt("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Tm=new qg,t1=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Ai(r){return(e,t)=>{let n=e.node.getChild("VariableDefinition");return n&&t(n,r),!0}}const AA=["FunctionDeclaration"],_A={FunctionDeclaration:Ai("function"),ClassDeclaration:Ai("class"),ClassExpression:()=>!0,EnumDeclaration:Ai("constant"),TypeAliasDeclaration:Ai("type"),NamespaceDeclaration:Ai("namespace"),VariableDefinition(r,e){r.matchContext(AA)||e(r,"variable")},TypeDefinition(r,e){e(r,"type")},__proto__:null};function r1(r,e){let t=Tm.get(e);if(t)return t;let n=[],s=!0;function i(o,a){let l=r.sliceString(o.from,o.to);n.push({label:l,type:a})}return e.cursor(st.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let a=_A[o.name];if(a&&a(o,i)||t1.has(o.name))return!1}else if(o.to-o.from>8192){for(let a of r1(r,o.node))n.push(a);return!1}}),Tm.set(e,n),n}const Mm=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,n1=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function RA(r){let e=dt(r.state).resolveInner(r.pos,-1);if(n1.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Mm.test(r.state.sliceDoc(e.from,e.to));if(!t&&!r.explicit)return null;let n=[];for(let s=e;s;s=s.parent)t1.has(s.name)&&(n=n.concat(r1(r.state.doc,s)));return{options:n,from:t?e.from:r.pos,validFor:Mm}}const rn=Js.define({name:"javascript",parser:TA.configure({props:[Po.add({IfStatement:Sa({except:/^\s*({|else\b)/}),TryStatement:Sa({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:kQ,SwitchBody:r=>{let e=r.textAfter,t=/^\s*\}/.test(e),n=/^\s*(case|default)\b/.test(e);return r.baseIndent+(t?0:n?1:2)*r.unit},Block:yQ({closing:"}"}),ArrowFunction:r=>r.baseIndent+r.unit,"TemplateString BlockComment":()=>null,"Statement Property":Sa({except:/^\s*{/}),JSXElement(r){let e=/^\s*<\//.test(r.textAfter);return r.lineIndent(r.node.from)+(e?0:r.unit)},JSXEscape(r){let e=/\s*\}/.test(r.textAfter);return r.lineIndent(r.node.from)+(e?0:r.unit)},"JSXOpenTag JSXSelfClosingTag"(r){return r.column(r.node.from)+r.unit}}),ai.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Jg,BlockComment(r){return{from:r.from+2,to:r.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),s1={test:r=>/^JSX/.test(r.name),facet:lh({commentTokens:{block:{open:"{/*",close:"*/}"}}})},i1=rn.configure({dialect:"ts"},"typescript"),o1=rn.configure({dialect:"jsx",props:[ch.add(r=>r.isTop?[s1]:void 0)]}),a1=rn.configure({dialect:"jsx ts",props:[ch.add(r=>r.isTop?[s1]:void 0)]},"typescript");let l1=r=>({label:r,type:"keyword"});const c1="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(l1),BA=c1.concat(["declare","implements","private","protected","public"].map(l1));function ZA(r={}){let e=r.jsx?r.typescript?a1:o1:r.typescript?i1:rn,t=r.typescript?MA.concat(BA):e1.concat(c1);return new so(e,[rn.data.of({autocomplete:N3(n1,JO(t))}),rn.data.of({autocomplete:RA}),r.jsx?LA:[]])}function EA(r){for(;;){if(r.name=="JSXOpenTag"||r.name=="JSXSelfClosingTag"||r.name=="JSXFragmentTag")return r;if(r.name=="JSXEscape"||!r.parent)return null;r=r.parent}}function Am(r,e,t=r.length){for(let n=e?.firstChild;n;n=n.nextSibling)if(n.name=="JSXIdentifier"||n.name=="JSXBuiltin"||n.name=="JSXNamespacedName"||n.name=="JSXMemberExpression")return r.sliceString(n.from,Math.min(n.to,t));return""}const DA=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),LA=Se.inputHandler.of((r,e,t,n,s)=>{if((DA?r.composing:r.compositionStarted)||r.state.readOnly||e!=t||n!=">"&&n!="/"||!rn.isActiveAt(r.state,e,-1))return!1;let i=s(),{state:o}=i,a=o.changeByRange(l=>{var c;let{head:u}=l,h=dt(o).resolveInner(u-1,-1),f;if(h.name=="JSXStartTag"&&(h=h.parent),!(o.doc.sliceString(u-1,u)!=n||h.name=="JSXAttributeValue"&&h.to>u)){if(n==">"&&h.name=="JSXFragmentTag")return{range:l,changes:{from:u,insert:"</>"}};if(n=="/"&&h.name=="JSXStartCloseTag"){let p=h.parent,g=p.parent;if(g&&p.from==u-2&&((f=Am(o.doc,g.firstChild,u))||((c=g.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let O=`${f}>`;return{range:te.cursor(u+O.length,-1),changes:{from:u,insert:O}}}}else if(n==">"){let p=EA(h);if(p&&p.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(u,u+2))&&(f=Am(o.doc,p,u)))return{range:l,changes:{from:u,insert:`</${f}>`}}}}return{range:l}});return a.changes.empty?!1:(r.dispatch([i,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),_i=["_blank","_self","_top","_parent"],mc=["ascii","utf-8","utf-16","latin1","latin1"],pc=["get","post","put","delete"],gc=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],hr=["true","false"],De={},XA={a:{attrs:{href:null,ping:null,type:null,media:null,target:_i,hreflang:null}},abbr:De,address:De,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:De,aside:De,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:De,base:{attrs:{href:null,target:_i}},bdi:De,bdo:De,blockquote:{attrs:{cite:null}},body:De,br:De,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:gc,formmethod:pc,formnovalidate:["novalidate"],formtarget:_i,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:De,center:De,cite:De,code:De,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:De,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:De,div:De,dl:De,dt:De,em:De,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:De,figure:De,footer:De,form:{attrs:{action:null,name:null,"accept-charset":mc,autocomplete:["on","off"],enctype:gc,method:pc,novalidate:["novalidate"],target:_i}},h1:De,h2:De,h3:De,h4:De,h5:De,h6:De,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:De,hgroup:De,hr:De,html:{attrs:{manifest:null}},i:De,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:gc,formmethod:pc,formnovalidate:["novalidate"],formtarget:_i,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:De,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:De,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:De,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:mc,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:De,noscript:De,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:De,param:{attrs:{name:null,value:null}},pre:De,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:De,rt:De,ruby:De,samp:De,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:mc}},section:De,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:De,source:{attrs:{src:null,type:null,media:null}},span:De,strong:De,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:De,summary:De,sup:De,table:De,tbody:De,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:De,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:De,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:De,time:{attrs:{datetime:null}},title:De,tr:De,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:De,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:De},u1={accesskey:null,class:null,contenteditable:hr,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:hr,autocorrect:hr,autocapitalize:hr,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":hr,"aria-autocomplete":["inline","list","both","none"],"aria-busy":hr,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":hr,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":hr,"aria-hidden":hr,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":hr,"aria-multiselectable":hr,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":hr,"aria-relevant":null,"aria-required":hr,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},h1="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(r=>"on"+r);for(let r of h1)u1[r]=null;class go{constructor(e,t){this.tags={...XA,...e},this.globalAttrs={...u1,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}go.default=new go;function si(r,e,t=r.length){if(!e)return"";let n=e.firstChild,s=n&&n.getChild("TagName");return s?r.sliceString(s.from,Math.min(s.to,t)):""}function ii(r,e=!1){for(;r;r=r.parent)if(r.name=="Element")if(e)e=!1;else return r;return null}function d1(r,e,t){let n=t.tags[si(r,ii(e))];return n?.children||t.allTags}function Eh(r,e){let t=[];for(let n=ii(e);n&&!n.type.isTop;n=ii(n.parent)){let s=si(r,n);if(s&&n.lastChild.name=="CloseTag")break;s&&t.indexOf(s)<0&&(e.name=="EndTag"||e.from>=n.firstChild.to)&&t.push(s)}return t}const f1=/^[:\-\.\w\u00b7-\uffff]*$/;function _m(r,e,t,n,s){let i=/\s*>/.test(r.sliceDoc(s,s+5))?"":">",o=ii(t,t.name=="StartTag"||t.name=="TagName");return{from:n,to:s,options:d1(r.doc,o,e).map(a=>({label:a,type:"type"})).concat(Eh(r.doc,t).map((a,l)=>({label:"/"+a,apply:"/"+a+i,type:"type",boost:99-l}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function Rm(r,e,t,n){let s=/\s*>/.test(r.sliceDoc(n,n+5))?"":">";return{from:t,to:n,options:Eh(r.doc,e).map((i,o)=>({label:i,apply:i+s,type:"type",boost:99-o})),validFor:f1}}function IA(r,e,t,n){let s=[],i=0;for(let o of d1(r.doc,t,e))s.push({label:"<"+o,type:"type"});for(let o of Eh(r.doc,t))s.push({label:"</"+o+">",type:"type",boost:99-i++});return{from:n,to:n,options:s,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function VA(r,e,t,n,s){let i=ii(t),o=i?e.tags[si(r.doc,i)]:null,a=o&&o.attrs?Object.keys(o.attrs):[],l=o&&o.globalAttrs===!1?a:a.length?a.concat(e.globalAttrNames):e.globalAttrNames;return{from:n,to:s,options:l.map(c=>({label:c,type:"property"})),validFor:f1}}function zA(r,e,t,n,s){var i;let o=(i=t.parent)===null||i===void 0?void 0:i.getChild("AttributeName"),a=[],l;if(o){let c=r.sliceDoc(o.from,o.to),u=e.globalAttrs[c];if(!u){let h=ii(t),f=h?e.tags[si(r.doc,h)]:null;u=f?.attrs&&f.attrs[c]}if(u){let h=r.sliceDoc(n,s).toLowerCase(),f='"',p='"';/^['"]/.test(h)?(l=h[0]=='"'?/^[^"]*$/:/^[^']*$/,f="",p=r.sliceDoc(s,s+1)==h[0]?"":h[0],h=h.slice(1),n++):l=/^[^\s<>='"]*$/;for(let g of u)a.push({label:g,apply:f+g+p,type:"constant"})}}return{from:n,to:s,options:a,validFor:l}}function m1(r,e){let{state:t,pos:n}=e,s=dt(t).resolveInner(n,-1),i=s.resolve(n);for(let o=n,a;i==s&&(a=s.childBefore(o));){let l=a.lastChild;if(!l||!l.type.isError||l.from<l.to)break;i=s=a,o=l.from}return s.name=="TagName"?s.parent&&/CloseTag$/.test(s.parent.name)?Rm(t,s,s.from,n):_m(t,r,s,s.from,n):s.name=="StartTag"||s.name=="IncompleteTag"?_m(t,r,s,n,n):s.name=="StartCloseTag"||s.name=="IncompleteCloseTag"?Rm(t,s,n,n):s.name=="OpenTag"||s.name=="SelfClosingTag"||s.name=="AttributeName"?VA(t,r,s,s.name=="AttributeName"?s.from:n,n):s.name=="Is"||s.name=="AttributeValue"||s.name=="UnquotedAttributeValue"?zA(t,r,s,s.name=="Is"?n:s.from,n):e.explicit&&(i.name=="Element"||i.name=="Text"||i.name=="Document")?IA(t,r,s,n):null}function NA(r){return m1(go.default,r)}function WA(r){let{extraTags:e,extraGlobalAttributes:t}=r,n=t||e?new go(e,t):go.default;return s=>m1(n,s)}const qA=rn.parser.configure({top:"SingleExpression"}),p1=[{tag:"script",attrs:r=>r.type=="text/typescript"||r.lang=="ts",parser:i1.parser},{tag:"script",attrs:r=>r.type=="text/babel"||r.type=="text/jsx",parser:o1.parser},{tag:"script",attrs:r=>r.type=="text/typescript-jsx",parser:a1.parser},{tag:"script",attrs(r){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(r.type)},parser:qA},{tag:"script",attrs(r){return!r.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(r.type)},parser:rn.parser},{tag:"style",attrs(r){return(!r.lang||r.lang=="css")&&(!r.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(r.type))},parser:cl.parser}],g1=[{name:"style",parser:cl.parser.configure({top:"Styles"})}].concat(h1.map(r=>({name:r,parser:rn.parser}))),O1=Js.define({name:"html",parser:g4.configure({props:[Po.add({Element(r){let e=/^(\s*)(<\/)?/.exec(r.textAfter);return r.node.to<=r.pos+e[0].length?r.continue():r.lineIndent(r.node.from)+(e[2]?0:r.unit)},"OpenTag CloseTag SelfClosingTag"(r){return r.column(r.node.from)+r.unit},Document(r){if(r.pos+/\s*/.exec(r.textAfter)[0].length<r.node.to)return r.continue();let e=null,t;for(let n=r.node;;){let s=n.lastChild;if(!s||s.name!="Element"||s.to!=n.to)break;e=n=s}return e&&!((t=e.lastChild)&&(t.name=="CloseTag"||t.name=="SelfClosingTag"))?r.lineIndent(e.from)+r.unit:null}}),ai.add({Element(r){let e=r.firstChild,t=r.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:t.name=="CloseTag"?t.from:r.to}}}),dO.add({"OpenTag CloseTag":r=>r.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),Qa=O1.configure({wrap:Y0(p1,g1)});function jA(r={}){let e="",t;r.matchClosingTags===!1&&(e="noMatch"),r.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(r.nestedLanguages&&r.nestedLanguages.length||r.nestedAttributes&&r.nestedAttributes.length)&&(t=Y0((r.nestedLanguages||[]).concat(p1),(r.nestedAttributes||[]).concat(g1)));let n=t?O1.configure({wrap:t,dialect:e}):e?Qa.configure({dialect:e}):Qa;return new so(n,[Qa.data.of({autocomplete:WA(r)}),r.autoCloseTags!==!1?YA:[],ZA().support,K4().support])}const Bm=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),YA=Se.inputHandler.of((r,e,t,n,s)=>{if(r.composing||r.state.readOnly||e!=t||n!=">"&&n!="/"||!Qa.isActiveAt(r.state,e,-1))return!1;let i=s(),{state:o}=i,a=o.changeByRange(l=>{var c,u,h;let f=o.doc.sliceString(l.from-1,l.to)==n,{head:p}=l,g=dt(o).resolveInner(p,-1),O;if(f&&n==">"&&g.name=="EndTag"){let b=g.parent;if(((u=(c=b.parent)===null||c===void 0?void 0:c.lastChild)===null||u===void 0?void 0:u.name)!="CloseTag"&&(O=si(o.doc,b.parent,p))&&!Bm.has(O)){let x=p+(o.doc.sliceString(p,p+1)===">"?1:0),k=`</${O}>`;return{range:l,changes:{from:p,to:x,insert:k}}}}else if(f&&n=="/"&&g.name=="IncompleteCloseTag"){let b=g.parent;if(g.from==p-2&&((h=b.lastChild)===null||h===void 0?void 0:h.name)!="CloseTag"&&(O=si(o.doc,b,p))&&!Bm.has(O)){let x=p+(o.doc.sliceString(p,p+1)===">"?1:0),k=`${O}>`;return{range:te.cursor(p+k.length,-1),changes:{from:p,to:x,insert:k}}}}return{range:l}});return a.changes.empty?!1:(r.dispatch([i,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),v1=lh({commentTokens:{block:{open:"<!--",close:"-->"}}}),b1=new qe,x1=uM.configure({props:[ai.add(r=>!r.is("Block")||r.is("Document")||Qu(r)!=null||FA(r)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),b1.add(Qu),Po.add({Document:()=>null}),cs.add({Document:v1})]});function Qu(r){let e=/^(?:ATX|Setext)Heading(\d)$/.exec(r.name);return e?+e[1]:void 0}function FA(r){return r.name=="OrderedList"||r.name=="BulletList"}function UA(r,e){let t=r;for(;;){let n=t.nextSibling,s;if(!n||(s=Qu(n.type))!=null&&s<=e)break;t=n}return t.to}const GA=Kg.of((r,e,t)=>{for(let n=dt(r).resolveInner(t,-1);n&&!(n.from<e);n=n.parent){let s=n.type.prop(b1);if(s==null)continue;let i=UA(n,s);if(i>t)return{from:t,to:i}}return null});function Dh(r){return new $r(v1,r,[],"markdown")}const HA=Dh(x1),KA=x1.configure([yM,wM,kM,SM,{props:[ai.add({Table:(r,e)=>({from:e.doc.lineAt(r.from).to,to:r.to})})]}]),ul=Dh(KA);function JA(r,e){return t=>{if(t&&r){let n=null;if(t=/\S*/.exec(t)[0],typeof r=="function"?n=r(t):n=qa.matchLanguageName(r,t,!0),n instanceof qa)return n.support?n.support.language.parser:no.getSkippingParser(n.load());if(n)return n.parser}return e?e.parser:null}}class Oc{constructor(e,t,n,s,i,o,a){this.node=e,this.from=t,this.to=n,this.spaceBefore=s,this.spaceAfter=i,this.type=o,this.item=a}blank(e,t=!0){let n=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(e!=null){for(;n.length<e;)n+=" ";return n}else{for(let s=this.to-this.from-n.length-this.spaceAfter.length;s>0;s--)n+=" ";return n+(t?this.spaceAfter:"")}}marker(e,t){let n=this.node.name=="OrderedList"?String(+k1(this.item,e)[2]+t):"";return this.spaceBefore+n+this.type+this.spaceAfter}}function y1(r,e){let t=[],n=[];for(let s=r;s;s=s.parent){if(s.name=="FencedCode")return n;(s.name=="ListItem"||s.name=="Blockquote")&&t.push(s)}for(let s=t.length-1;s>=0;s--){let i=t[s],o,a=e.lineAt(i.from),l=i.from-a.from;if(i.name=="Blockquote"&&(o=/^ *>( ?)/.exec(a.text.slice(l))))n.push(new Oc(i,l,l+o[0].length,"",o[1],">",null));else if(i.name=="ListItem"&&i.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(a.text.slice(l)))){let c=o[3],u=o[0].length;c.length>=4&&(c=c.slice(0,c.length-4),u-=4),n.push(new Oc(i.parent,l,l+u,o[1],c,o[2],i))}else if(i.name=="ListItem"&&i.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(a.text.slice(l)))){let c=o[4],u=o[0].length;c.length>4&&(c=c.slice(0,c.length-4),u-=4);let h=o[2];o[3]&&(h+=o[3].replace(/[xX]/," ")),n.push(new Oc(i.parent,l,l+u,o[1],c,h,i))}}return n}function k1(r,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(r.from,r.from+10))}function vc(r,e,t,n=0){for(let s=-1,i=r;;){if(i.name=="ListItem"){let a=k1(i,e),l=+a[2];if(s>=0){if(l!=s+1)return;t.push({from:i.from+a[1].length,to:i.from+a[0].length,insert:String(s+2+n)})}s=l}let o=i.nextSibling;if(!o)break;i=o}}function Lh(r,e){let t=/^[ \t]*/.exec(r)[0].length;if(!t||e.facet(Qo)!=" ")return r;let n=Zr(r,4,t),s="";for(let i=n;i>0;)i>=4?(s+=" ",i-=4):(s+=" ",i--);return s+r.slice(t)}const e_=(r={})=>({state:e,dispatch:t})=>{let n=dt(e),{doc:s}=e,i=null,o=e.changeByRange(a=>{if(!a.empty||!ul.isActiveAt(e,a.from,-1)&&!ul.isActiveAt(e,a.from,1))return i={range:a};let l=a.from,c=s.lineAt(l),u=y1(n.resolveInner(l,-1),s);for(;u.length&&u[u.length-1].from>l-c.from;)u.pop();if(!u.length)return i={range:a};let h=u[u.length-1];if(h.to-h.spaceAfter.length>l-c.from)return i={range:a};let f=l>=h.to-h.spaceAfter.length&&!/\S/.test(c.text.slice(h.to));if(h.item&&f){let x=h.node.firstChild,k=h.node.getChild("ListItem","ListItem");if(x.to>=l||k&&k.to<l||c.from>0&&!/[^\s>]/.test(s.lineAt(c.from-1).text)||r.nonTightLists===!1){let w=u.length>1?u[u.length-2]:null,S,Q="";w&&w.item?(S=c.from+w.from,Q=w.marker(s,1)):S=c.from+(w?w.to:0);let L=[{from:S,to:l,insert:Q}];return h.node.name=="OrderedList"&&vc(h.item,s,L,-2),w&&w.node.name=="OrderedList"&&vc(w.item,s,L),{range:te.cursor(S+Q.length),changes:L}}else{let w=Em(u,e,c);return{range:te.cursor(l+w.length+1),changes:{from:c.from,insert:w+e.lineBreak}}}}if(h.node.name=="Blockquote"&&f&&c.from){let x=s.lineAt(c.from-1),k=/>\s*$/.exec(x.text);if(k&&k.index==h.from){let w=e.changes([{from:x.from+k.index,to:x.to},{from:c.from+h.from,to:c.to}]);return{range:a.map(w),changes:w}}}let p=[];h.node.name=="OrderedList"&&vc(h.item,s,p);let g=h.item&&h.item.from<c.from,O="";if(!g||/^[\s\d.)\-+*>]*/.exec(c.text)[0].length>=h.to)for(let x=0,k=u.length-1;x<=k;x++)O+=x==k&&!g?u[x].marker(s,1):u[x].blank(x<k?Zr(c.text,4,u[x+1].from)-O.length:null);let b=l;for(;b>c.from&&/\s/.test(c.text.charAt(b-c.from-1));)b--;return O=Lh(O,e),r_(h.node,e.doc)&&(O=Em(u,e,c)+e.lineBreak+O),p.push({from:b,to:l,insert:e.lineBreak+O}),{range:te.cursor(b+O.length+1),changes:p}});return i?!1:(t(e.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},t_=e_();function Zm(r){return r.name=="QuoteMark"||r.name=="ListMark"}function r_(r,e){if(r.name!="OrderedList"&&r.name!="BulletList")return!1;let t=r.firstChild,n=r.getChild("ListItem","ListItem");if(!n)return!1;let s=e.lineAt(t.to),i=e.lineAt(n.from),o=/^[\s>]*$/.test(s.text);return s.number+(o?0:1)<i.number}function Em(r,e,t){let n="";for(let s=0,i=r.length-2;s<=i;s++)n+=r[s].blank(s<i?Zr(t.text,4,r[s+1].from)-n.length:null,s<i);return Lh(n,e)}function n_(r,e){let t=r.resolveInner(e,-1),n=e;Zm(t)&&(n=t.from,t=t.parent);for(let s;s=t.childBefore(n);)if(Zm(s))n=s.from;else if(s.name=="OrderedList"||s.name=="BulletList")t=s.lastChild,n=t.to;else break;return t}const s_=({state:r,dispatch:e})=>{let t=dt(r),n=null,s=r.changeByRange(i=>{let o=i.from,{doc:a}=r;if(i.empty&&ul.isActiveAt(r,i.from)){let l=a.lineAt(o),c=y1(n_(t,o),a);if(c.length){let u=c[c.length-1],h=u.to-u.spaceAfter.length+(u.spaceAfter?1:0);if(o-l.from>h&&!/\S/.test(l.text.slice(h,o-l.from)))return{range:te.cursor(l.from+h),changes:{from:l.from+h,to:o}};if(o-l.from==h&&(!u.item||l.from<=u.item.from||!/\S/.test(l.text.slice(0,u.to)))){let f=l.from+u.from;if(u.item&&u.node.from<u.item.from&&/\S/.test(l.text.slice(u.from,u.to))){let p=u.blank(Zr(l.text,4,u.to)-Zr(l.text,4,u.from));return f==l.from&&(p=Lh(p,r)),{range:te.cursor(f+p.length),changes:{from:f,to:l.from+u.to,insert:p}}}if(f<o)return{range:te.cursor(f),changes:{from:f,to:o}}}}}return n={range:i}});return n?!1:(e(r.update(s,{scrollIntoView:!0,userEvent:"delete"})),!0)},i_=[{key:"Enter",run:t_},{key:"Backspace",run:s_}],w1=jA({matchClosingTags:!1});function o_(r={}){let{codeLanguages:e,defaultCodeLanguage:t,addKeymap:n=!0,base:{parser:s}=HA,completeHTMLTags:i=!0,pasteURLAsLink:o=!0,htmlTagLanguage:a=w1}=r;if(!(s instanceof Tl))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let l=r.extensions?[r.extensions]:[],c=[a.support,GA],u;o&&c.push(u_),t instanceof so?(c.push(t.support),u=t.language):t&&(u=t);let h=e||u?JA(e,u):void 0;l.push(dM({codeParser:h,htmlParser:a.language.parser})),n&&c.push(kn.high(So.of(i_)));let f=Dh(s.configure(l));return i&&c.push(f.data.of({autocomplete:a_})),new so(f,c)}function a_(r){let{state:e,pos:t}=r,n=/<[:\-\.\w\u00b7-\uffff]*$/.exec(e.sliceDoc(t-25,t));if(!n)return null;let s=dt(e).resolveInner(t,-1);for(;s&&!s.type.isTop;){if(s.name=="CodeBlock"||s.name=="FencedCode"||s.name=="ProcessingInstructionBlock"||s.name=="CommentBlock"||s.name=="Link"||s.name=="Image")return null;s=s.parent}return{from:t-n[0].length,to:t,options:l_(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let bc=null;function l_(){if(bc)return bc;let r=NA(new bh(He.create({extensions:w1}),0,!0));return bc=r?r.options:[]}const c_=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,u_=Se.domEventHandlers({paste:(r,e)=>{var t;let{main:n}=e.state.selection;if(n.empty)return!1;let s=(t=r.clipboardData)===null||t===void 0?void 0:t.getData("text/plain");if(!s||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(s)||(/^www\./.test(s)&&(s="https://"+s),!ul.isActiveAt(e.state,n.from,1)))return!1;let i=dt(e.state),o=!1;return i.iterate({from:n.from,to:n.to,enter:a=>{(a.from>n.from||c_.test(a.name))&&(o=!0)},leave:a=>{a.to<n.to&&(o=!0)}}),o?!1:(e.dispatch({changes:[{from:n.from,insert:"["},{from:n.to,insert:`](${s})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}}),h_="#e5c07b",Dm="#e06c75",d_="#56b6c2",f_="#ffffff",Pa="#abb2bf",Pu="#7d8799",m_="#61afef",p_="#98c379",Lm="#d19a66",g_="#c678dd",O_="#21252b",Xm="#2c313a",Im="#282c34",xc="#353a42",v_="#3E4451",Vm="#528bff",b_=Se.theme({"&":{color:Pa,backgroundColor:Im},".cm-content":{caretColor:Vm},".cm-cursor, .cm-dropCursor":{borderLeftColor:Vm},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:v_},".cm-panels":{backgroundColor:O_,color:Pa},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Im,color:Pu,border:"none"},".cm-activeLineGutter":{backgroundColor:Xm},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:xc},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:xc,borderBottomColor:xc},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Xm,color:Pa}}},{dark:!0}),x_=Mo.define([{tag:$.keyword,color:g_},{tag:[$.name,$.deleted,$.character,$.propertyName,$.macroName],color:Dm},{tag:[$.function($.variableName),$.labelName],color:m_},{tag:[$.color,$.constant($.name),$.standard($.name)],color:Lm},{tag:[$.definition($.name),$.separator],color:Pa},{tag:[$.typeName,$.className,$.number,$.changed,$.annotation,$.modifier,$.self,$.namespace],color:h_},{tag:[$.operator,$.operatorKeyword,$.url,$.escape,$.regexp,$.link,$.special($.string)],color:d_},{tag:[$.meta,$.comment],color:Pu},{tag:$.strong,fontWeight:"bold"},{tag:$.emphasis,fontStyle:"italic"},{tag:$.strikethrough,textDecoration:"line-through"},{tag:$.link,color:Pu,textDecoration:"underline"},{tag:$.heading,fontWeight:"bold",color:Dm},{tag:[$.atom,$.bool,$.special($.variableName)],color:Lm},{tag:[$.processingInstruction,$.string,$.inserted],color:p_},{tag:$.invalid,color:f_}]),y_=[b_,lO(x_)],k_=Ve({__name:"MarkdownCodeEditor",props:{modelValue:{},readOnly:{type:Boolean,default:!1},lineToReveal:{default:null}},emits:["update:modelValue"],setup(r,{emit:e}){const t=r,n=e,s=P(null);let i=null,o=!1,a=null;const l=We.define(),c=We.define(),u=Tt.define({create(){return Le.none},update(g,O){let b=g.map(O.changes);for(const x of O.effects)if(x.is(c)&&(b=Le.none),x.is(l)){const k=Math.max(1,Math.min(x.value,O.state.doc.lines)),w=O.state.doc.line(k);b=Le.set([Le.line({class:"cm-target-line"}).range(w.from)])}return b},provide:g=>Se.decorations.from(g)});function h(){i&&(a&&clearTimeout(a),a=setTimeout(()=>{i&&i.dispatch({effects:c.of(void 0)})},1600))}function f(g){if(!i)return;const O=Math.max(1,Math.min(g,i.state.doc.lines)),b=i.state.doc.line(O);i.dispatch({selection:{anchor:b.from},effects:[Se.scrollIntoView(b.from,{y:"center"}),l.of(O)]}),i.focus(),h()}function p(g,O){return He.create({doc:g,extensions:[KT,o_(),y_,Se.lineWrapping,u,Se.updateListener.of(b=>{!b.docChanged||o||n("update:modelValue",b.state.doc.toString())}),Se.theme({"&":{height:"100%",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace",fontSize:"13px",backgroundColor:"rgb(var(--color-retro-black))",color:"rgb(var(--color-retro-text))"},".cm-scroller":{overflow:"auto",lineHeight:"1.6"},".cm-gutters":{backgroundColor:"rgb(var(--color-retro-dark))",color:"rgb(var(--color-retro-subtle))",borderRight:"1px solid rgb(var(--color-retro-border))"},".cm-content":{caretColor:"rgb(var(--color-retro-cyan))",padding:"12px 0"},".cm-activeLine":{backgroundColor:"rgba(34, 211, 238, 0.08)"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"rgba(34, 211, 238, 0.22)"}}),He.readOnly.of(O)]})}return gt(()=>{s.value&&(i=new Se({state:p(t.modelValue,t.readOnly),parent:s.value}),t.lineToReveal&&f(t.lineToReveal))}),ze(()=>t.modelValue,g=>{if(!i)return;const O=i.state.doc.toString();O!==g&&(o=!0,i.dispatch({changes:{from:0,to:O.length,insert:g}}),o=!1)}),ze(()=>t.lineToReveal,g=>{g&&f(g)}),N1(()=>{a&&clearTimeout(a),i&&(i.destroy(),i=null)}),(g,O)=>(v(),y("div",{ref_key:"rootRef",ref:s,class:"h-full w-full"},null,512))}}),w_=ws(k_,[["__scopeId","data-v-d77d4160"]]),S_={class:"fixed inset-0 z-50 flex items-center justify-center"},$_={class:"relative w-[96vw] h-[94vh] bg-retro-black border border-retro-border rounded-lg shadow-2xl flex flex-col overflow-hidden"},C_={class:"flex-shrink-0 flex items-center justify-between px-4 h-12 border-b border-retro-border bg-retro-dark"},Q_={class:"flex items-center gap-3 min-w-0"},P_={class:"text-sm font-mono font-bold text-retro-cyan truncate"},T_={class:"text-xs font-mono text-retro-subtle"},M_={class:"flex items-center gap-2"},A_=["disabled"],__={class:"flex-shrink-0 flex items-center gap-0 border-b border-retro-border bg-retro-dark overflow-x-auto"},R_=["onClick"],B_={class:"flex-1 min-h-0 overflow-y-auto"},Z_={key:0,class:"p-5 max-w-6xl mx-auto"},E_={key:0,class:"flex items-center justify-center py-12"},D_={key:1,class:"flex flex-col items-center justify-center py-12 text-center px-4"},L_={class:"text-sm font-mono text-retro-red"},X_={key:2,class:"space-y-4"},I_={key:0,class:"rounded border border-retro-cyan/40 bg-retro-cyan/10 px-3 py-2 text-xs font-mono text-retro-cyan"},V_={class:"grid grid-cols-2 lg:grid-cols-5 gap-2"},z_={class:"rounded border border-retro-border bg-retro-panel px-3 py-2"},N_={class:"text-sm font-mono text-retro-text"},W_={class:"rounded border border-retro-border bg-retro-panel px-3 py-2"},q_={class:"text-sm font-mono text-retro-cyan"},j_={class:"rounded border border-retro-border bg-retro-panel px-3 py-2"},Y_={class:"text-sm font-mono text-retro-yellow"},F_={class:"rounded border border-retro-border bg-retro-panel px-3 py-2"},U_={class:"text-sm font-mono text-retro-green"},G_={class:"rounded border border-retro-border bg-retro-panel px-3 py-2"},H_={class:"text-sm font-mono text-retro-text"},K_={class:"rounded border border-retro-border bg-retro-panel px-3 py-3"},J_={class:"flex items-center justify-between gap-2 mb-2"},eR={class:"text-[11px] font-mono text-retro-subtle"},tR={key:0,class:"text-xs font-mono text-retro-green"},rR={key:1,class:"space-y-2"},nR={class:"uppercase tracking-wide mr-2"},sR={class:"rounded border border-retro-border bg-retro-panel p-3 overflow-x-auto"},iR={class:"min-w-[760px]"},oR={class:"text-retro-text"},aR=["disabled","onClick"],lR=["disabled","onClick"],cR=["disabled","onClick"],uR={class:"text-retro-muted"},hR={key:1,class:"flex items-center justify-center py-12"},dR={key:2,class:"flex flex-col items-center justify-center py-12 text-center px-4"},fR={class:"text-sm font-mono text-retro-red"},mR={key:3,class:"flex flex-col items-center justify-center py-12 text-center"},pR={key:4,class:"h-full flex flex-col"},gR=["innerHTML"],OR=Ve({__name:"SpecViewerModal",props:{feature:{}},emits:["close"],setup(r,{emit:e}){const t=r,n=e,s=vo(),{renderMarkdown:i}=Jm(),o=P(t.feature.files[0]?.filename||""),a=P("document"),l=P(""),c=P(!1),u=P(null),h=P(!1),f=P(""),p=P(!1),g=P(null),O=P(null),b=P(!1),x=P(null),k=P(null),w=J(()=>{const I={critical:0,major:1,minor:2};return[...k.value?.alerts??[]].sort((z,be)=>I[z.severity]-I[be.severity])});function S(I){return I.status==="covered"?"text-retro-green border-retro-green/40 bg-retro-green/10":I.status==="partial"?"text-retro-yellow border-retro-yellow/40 bg-retro-yellow/10":"text-retro-red border-retro-red/40 bg-retro-red/10"}function Q(I){return I.severity==="critical"?"text-retro-red border-retro-red/40 bg-retro-red/10":I.severity==="major"?"text-retro-yellow border-retro-yellow/40 bg-retro-yellow/10":"text-retro-cyan border-retro-cyan/40 bg-retro-cyan/10"}async function L(){b.value=!0,x.value=null;try{k.value=await $fetch(`/api/specs/traceability/${t.feature.id}`)}catch{x.value="Failed to load traceability data",k.value=null}finally{b.value=!1}}async function D(I=o.value){if(I){c.value=!0,u.value=null;try{const z=`/api/specs/${t.feature.id}/${I}`,be=await $fetch(z);l.value=be.content}catch{u.value="Failed to load file",l.value=""}finally{c.value=!1}}}function G(){D()}const oe=J(()=>l.value?i(l.value):"");function ie(I){O.value=null,a.value="document",h.value&&(h.value=!1),o.value=I,D()}function j(){h.value&&U(),a.value="traceability",!k.value&&!b.value&&L()}async function V(I,z,be){z&&(o.value!==I?(o.value=I,await D(I)):l.value||await D(I),a.value="document",h.value=!0,f.value=l.value,g.value=null,O.value={filename:I,line:z,requirementId:be},await It(),g.value=z)}function Z(){f.value=l.value,g.value=null,h.value=!0}function U(){h.value=!1,f.value=""}async function W(){p.value=!0;try{const I=`/api/specs/${t.feature.id}/${o.value}`;await $fetch(I,{method:"PUT",body:{content:f.value}}),l.value=f.value,h.value=!1,s.success("Saved")}catch{s.error("Failed to save")}finally{p.value=!1}}function N(I){I.key==="Escape"&&(h.value?U():n("close"))}return gt(()=>{window.addEventListener("keydown",N),D(),L()}),wt(()=>{window.removeEventListener("keydown",N)}),(I,z)=>{const be=w_;return v(),pe(Pr,{to:"body"},[d("div",S_,[d("div",{class:"absolute inset-0 bg-black/80",onClick:z[0]||(z[0]=K=>n("close"))}),d("div",$_,[d("div",C_,[d("div",Q_,[d("span",P_,A(r.feature.name),1),d("span",T_,A(r.feature.id),1)]),d("div",M_,[m(h)?(v(),y(we,{key:0},[d("button",{type:"button",class:"px-3 py-1 text-xs font-mono rounded border border-retro-border text-retro-muted hover:text-retro-text hover:border-retro-muted transition-colors",onClick:U}," Cancel "),d("button",{type:"button",class:"px-3 py-1 text-xs font-mono rounded border border-retro-cyan text-retro-cyan hover:bg-retro-cyan/10 transition-colors disabled:opacity-50",disabled:m(p),onClick:W},A(m(p)?"Saving...":"Save"),9,A_)],64)):m(a)==="document"&&m(l)&&!m(c)&&!m(u)?(v(),y("button",{key:1,type:"button",class:"p-1.5 rounded text-retro-muted hover:text-retro-cyan hover:bg-retro-panel transition-colors",title:"Edit",onClick:Z},[ee(m(dp),{class:"h-4 w-4"})])):F("",!0),d("button",{type:"button",class:"p-1.5 rounded text-retro-muted hover:text-retro-text hover:bg-retro-panel transition-colors",title:"Close (ESC)",onClick:z[1]||(z[1]=K=>n("close"))},[ee(m(St),{class:"h-4 w-4"})])])]),d("div",__,[d("button",{type:"button",class:_e(["px-4 py-2 text-xs font-mono border-b-2 transition-colors whitespace-nowrap flex items-center gap-1",[m(a)==="traceability"?"border-retro-magenta text-retro-magenta bg-retro-black":"border-transparent text-retro-muted hover:text-retro-text hover:bg-retro-panel"]]),onClick:j},[ee(m(vv),{class:"h-3.5 w-3.5"}),z[3]||(z[3]=Ie(" Traceability ",-1))],2),(v(!0),y(we,null,Ne(r.feature.files,K=>(v(),y("button",{key:K.filename,type:"button",class:_e(["px-4 py-2 text-xs font-mono border-b-2 transition-colors whitespace-nowrap",[m(a)==="document"&&m(o)===K.filename?"border-retro-cyan text-retro-cyan bg-retro-black":"border-transparent text-retro-muted hover:text-retro-text hover:bg-retro-panel"]]),onClick:H=>ie(K.filename)},A(K.label),11,R_))),128))]),d("div",B_,[m(a)==="traceability"?(v(),y("div",Z_,[m(b)?(v(),y("div",E_,[...z[4]||(z[4]=[d("span",{class:"text-sm font-mono text-retro-muted animate-pulse"},"Loading traceability...",-1)])])):m(x)?(v(),y("div",D_,[d("p",L_,A(m(x)),1),d("button",{type:"button",class:"mt-3 px-3 py-1.5 text-xs font-mono bg-retro-panel border border-retro-border rounded text-retro-muted hover:text-retro-cyan hover:border-retro-cyan transition-colors",onClick:L}," Retry ")])):m(k)?(v(),y("div",X_,[m(O)?(v(),y("div",I_," Jump target: "+A(m(O).requirementId)+" → "+A(m(O).filename)+":"+A(m(O).line),1)):F("",!0),d("div",V_,[d("div",z_,[z[5]||(z[5]=d("p",{class:"text-[11px] font-mono text-retro-subtle"},"FR total",-1)),d("p",N_,A(m(k).summary.frTotal),1)]),d("div",W_,[z[6]||(z[6]=d("p",{class:"text-[11px] font-mono text-retro-subtle"},"Plan coverage",-1)),d("p",q_,A(m(k).summary.frWithPlan)+"/"+A(m(k).summary.frTotal),1)]),d("div",j_,[z[7]||(z[7]=d("p",{class:"text-[11px] font-mono text-retro-subtle"},"Task mapping",-1)),d("p",Y_,A(m(k).summary.frWithTasks)+"/"+A(m(k).summary.frTotal),1)]),d("div",F_,[z[8]||(z[8]=d("p",{class:"text-[11px] font-mono text-retro-subtle"},"Fully covered",-1)),d("p",U_,A(m(k).summary.frFullyCovered)+"/"+A(m(k).summary.frTotal),1)]),d("div",G_,[z[9]||(z[9]=d("p",{class:"text-[11px] font-mono text-retro-subtle"},"Task progress",-1)),d("p",H_,A(m(k).summary.taskCompleted)+"/"+A(m(k).summary.taskTotal),1)])]),d("div",K_,[d("div",J_,[z[10]||(z[10]=d("h3",{class:"text-xs font-mono text-retro-text"},"Gap Alerts",-1)),d("span",eR,A(m(w).length)+" issues",1)]),m(w).length===0?(v(),y("div",tR," No traceability gaps detected. ")):(v(),y("div",rR,[(v(!0),y(we,null,Ne(m(w),K=>(v(),y("div",{key:K.id,class:_e(["rounded border px-2.5 py-2 text-xs font-mono",Q(K)])},[d("span",nR,A(K.severity),1),d("span",null,A(K.message),1)],2))),128))]))]),d("div",sR,[d("div",iR,[z[11]||(z[11]=d("div",{class:"grid grid-cols-[140px_1fr_1fr_1fr_120px] gap-2 text-[11px] font-mono text-retro-subtle px-2 pb-2 border-b border-retro-border"},[d("span",null,"Requirement"),d("span",null,"Spec"),d("span",null,"Plan"),d("span",null,"Tasks"),d("span",null,"Progress")],-1)),(v(!0),y(we,null,Ne(m(k).requirements,K=>(v(),y("div",{key:K.id,class:"grid grid-cols-[140px_1fr_1fr_1fr_120px] gap-2 items-center px-2 py-2 border-b border-retro-border/60 text-xs font-mono"},[d("span",oR,A(K.id),1),d("button",{type:"button",class:"h-6 rounded border border-retro-green/40 bg-retro-green/10 flex items-center px-2 text-retro-green disabled:opacity-50 disabled:cursor-not-allowed",disabled:!K.locations.specLine,onClick:H=>V("spec.md",K.locations.specLine,K.id)},[d("span",null,A(K.locations.specLine?`L${K.locations.specLine}`:"Defined"),1)],8,aR),d("button",{type:"button",class:_e(["h-6 rounded border flex items-center px-2 disabled:opacity-50 disabled:cursor-not-allowed",K.inPlan?"text-retro-cyan border-retro-cyan/40 bg-retro-cyan/10":"text-retro-subtle border-retro-border bg-retro-black/50"]),disabled:!K.locations.planLine,onClick:H=>V("plan.md",K.locations.planLine,K.id)},[d("span",null,A(K.locations.planLine?`L${K.locations.planLine}`:K.inPlan?"Linked":"Missing"),1)],10,lR),d("button",{type:"button",class:_e(["h-6 rounded border flex items-center px-2 disabled:opacity-50 disabled:cursor-not-allowed",S(K)]),disabled:K.locations.taskLines.length===0,onClick:H=>V("tasks.md",K.locations.taskLines[0],K.id)},[d("span",null,A(K.locations.taskLines.length>0?`L${K.locations.taskLines[0]}`:K.inTasks?"Mapped":"Missing"),1)],10,cR),d("span",uR,A(K.taskCompleted)+"/"+A(K.taskTotal),1)]))),128))])])])):F("",!0)])):m(c)?(v(),y("div",hR,[...z[12]||(z[12]=[d("span",{class:"text-sm font-mono text-retro-muted animate-pulse"},"Loading...",-1)])])):m(u)?(v(),y("div",dR,[d("p",fR,A(m(u)),1),d("button",{type:"button",class:"mt-3 px-3 py-1.5 text-xs font-mono bg-retro-panel border border-retro-border rounded text-retro-muted hover:text-retro-cyan hover:border-retro-cyan transition-colors",onClick:G}," Retry ")])):r.feature.files.length===0?(v(),y("div",mR,[...z[13]||(z[13]=[d("p",{class:"text-sm font-mono text-retro-muted"},"No spec files found",-1),d("p",{class:"mt-1 text-xs font-mono text-retro-subtle"}," This feature directory has no .md files ",-1)])])):m(h)?(v(),y("div",pR,[ee(be,{modelValue:m(f),"onUpdate:modelValue":z[2]||(z[2]=K=>Je(f)?f.value=K:null),"line-to-reveal":m(g),class:"flex-1"},null,8,["modelValue","line-to-reveal"])])):(v(),y("div",{key:5,class:"spec-markdown p-6 text-sm font-mono text-retro-text max-w-4xl mx-auto",innerHTML:m(oe)},null,8,gR))])])])])}}}),vR={class:"w-full max-w-2xl rounded-xl border border-retro-border/80 bg-retro-black shadow-[0_24px_70px_rgba(0,0,0,0.55)] overflow-hidden"},bR={class:"flex items-center justify-between px-4 py-2 border-b border-retro-border/60 bg-retro-dark/70"},xR={class:"flex items-center gap-2 px-4 py-3 border-b border-retro-border/60"},yR={class:"flex items-center justify-between px-4 py-1.5 border-b border-retro-border/40 bg-retro-dark/30 text-[10px] font-mono text-retro-subtle"},kR={class:"flex items-center gap-3"},wR={class:"inline-flex items-center gap-1"},SR={key:0},$R={key:0,class:"truncate max-w-[42%]"},CR={class:"max-h-[58vh] overflow-y-auto"},QR={key:0,class:"px-4 py-3 text-xs font-mono text-retro-subtle animate-pulse"},PR={key:1,class:"px-4 py-4 text-xs font-mono text-retro-subtle"},TR={key:2,class:"px-4 py-4 text-xs font-mono text-retro-subtle"},MR={key:3,class:"px-4 py-3 text-xs font-mono text-retro-red"},AR={key:4,class:"py-2 px-2 space-y-2"},_R=["onMouseenter","onClick"],RR={class:"flex items-center justify-between gap-3 text-[10px] font-mono"},BR={class:"text-retro-cyan/90"},ZR={class:"text-retro-subtle truncate"},ER=["innerHTML"],DR={key:5,class:"px-4 py-3 text-xs font-mono text-retro-subtle"},LR={class:"flex items-center justify-between gap-3 px-4 py-2 border-t border-retro-border/60 bg-retro-dark/50 text-[11px] font-mono text-retro-subtle"},XR={key:0,class:"text-retro-yellow"},IR={key:0,class:"px-4 pb-3 text-xs font-mono text-retro-red flex items-center gap-2"},VR=400,zR=Ve({__name:"FeatureSearchModal",props:{availableFeatureIds:{}},emits:["close","select"],setup(r,{emit:e}){const t=r,n=e,{renderMarkdown:s}=Jm(),i=P(""),o=P(!1),a=P(!1),l=P(null),c=P(null),u=P(null),h=P(null),f=P([]),p=P(-1),g=P(null),O=P([]);let b=null,x=0;const k=J(()=>i.value.trim()),w=J(()=>{const W=k.value.toLowerCase().split(/\s+/).map(N=>N.trim()).filter(N=>N.length>=2);return Array.from(new Set(W)).slice(0,8)}),S=J(()=>l.value||c.value?"error":!k.value&&a.value?"empty-query":f.value.length>0?"results":a.value&&!o.value?"no-results":"idle");function Q(W){return{featureId:W.chunk.featureId,sourcePath:W.chunk.sourcePath,headingHierarchy:W.chunk.headingHierarchy,snippet:W.chunk.content,matchType:W.matchType,score:W.score,lineStart:W.chunk.lineStart,lineEnd:W.chunk.lineEnd}}async function L(){const W=k.value;if(c.value=null,!W){a.value=!0,u.value=null,h.value=null,l.value=null,f.value=[],p.value=-1;return}const N=++x;a.value=!0,l.value=null,o.value=!0;try{const I=await $fetch("/api/specs/search",{query:{q:W,mode:"keyword",limit:20}});if(N!==x)return;u.value=I.warning??null,h.value=I.searchTime,f.value=I.results.map(Q),p.value=f.value.length>0?0:-1}catch(I){if(N!==x)return;const z=I instanceof Error?I.message:"Failed to search specs";l.value=z,h.value=null,f.value=[],p.value=-1}finally{N===x&&(o.value=!1)}}ze(i,()=>{l.value=null,c.value=null,b&&clearTimeout(b),b=setTimeout(()=>{L()},VR)}),ze(f,()=>{O.value=[]}),ze(p,async W=>{W<0||(await It(),O.value[W]?.scrollIntoView({block:"nearest"}))});function D(){n("close")}function G(W){const N=f.value[W];if(N){if(!t.availableFeatureIds.includes(N.featureId)){c.value="Feature unavailable";return}n("select",N.featureId),n("close")}}function oe(W){if(f.value.length===0)return;if(p.value<0){p.value=0;return}const N=p.value+W;if(N<0){p.value=f.value.length-1;return}if(N>=f.value.length){p.value=0;return}p.value=N}function ie(W){if(W.key==="ArrowDown"){W.preventDefault(),oe(1);return}if(W.key==="ArrowUp"){W.preventDefault(),oe(-1);return}if(W.key==="Enter"){W.preventDefault(),p.value>=0&&G(p.value);return}W.key==="Escape"&&(W.preventDefault(),D())}function j(W){W.target===W.currentTarget&&D()}function V(W,N){if(!N){O.value[W]=null;return}if(N instanceof HTMLElement){O.value[W]=N;return}const I=N.$el;O.value[W]=I instanceof HTMLElement?I:null}function Z(){L()}function U(W){const N=W.trim();if(!N)return"";const I=N.length>700?`${N.slice(0,700)}...`:N,z=s(I);if(w.value.length===0)return z;const be=w.value.map(H=>H.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),K=new RegExp(`(${be.join("|")})`,"gi");return z.split(/(<[^>]+>)/g).map(H=>H.startsWith("<")?H:H.replace(K,"<mark>$1</mark>")).join("")}return gt(()=>{It(()=>{g.value?.focus()})}),wt(()=>{b&&clearTimeout(b)}),(W,N)=>(v(),pe(Pr,{to:"body"},[ee(On,{appear:"","enter-active-class":"transition duration-150 ease-out","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition duration-120 ease-in","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ut(()=>[d("div",{class:"fixed inset-0 z-50 flex items-start justify-center pt-16 px-4 bg-black/75 backdrop-blur-[1px]",onClick:j},[ee(On,{appear:"","enter-active-class":"transition duration-150 ease-out","enter-from-class":"opacity-0 translate-y-2 scale-[0.99]","enter-to-class":"opacity-100 translate-y-0 scale-100","leave-active-class":"transition duration-120 ease-in","leave-from-class":"opacity-100 translate-y-0 scale-100","leave-to-class":"opacity-0 translate-y-1 scale-[0.995]"},{default:ut(()=>[d("div",vR,[d("div",bR,[N[1]||(N[1]=d("div",{class:"flex items-center gap-2"},[d("span",{class:"inline-flex items-center rounded px-2 py-0.5 text-[10px] font-mono border border-retro-cyan/50 text-retro-cyan bg-retro-cyan/10"}," Command Palette "),d("span",{class:"text-[10px] font-mono text-retro-subtle"},"Global spec search")],-1)),d("button",{type:"button",class:"p-1 rounded text-retro-muted hover:text-retro-text hover:bg-retro-panel transition-colors",title:"Close (Escape)",onClick:D},[ee(m(St),{class:"h-4 w-4"})])]),d("div",xR,[ee(m(fs),{class:"h-4 w-4 text-retro-cyan"}),je(d("input",{ref_key:"inputRef",ref:g,"onUpdate:modelValue":N[0]||(N[0]=I=>Je(i)?i.value=I:null),type:"text",placeholder:"Search specs across all features...",class:"flex-1 bg-transparent text-sm font-mono text-retro-text placeholder:text-retro-subtle focus:outline-none",onKeydown:ie},null,544),[[Rt,m(i)]]),N[2]||(N[2]=d("span",{class:"text-[10px] font-mono text-retro-subtle border border-retro-border/60 rounded px-1.5 py-0.5"},"400ms",-1))]),d("div",yR,[d("div",kR,[d("span",wR,[ee(m(Os),{class:"h-3.5 w-3.5"}),Ie(" "+A(m(f).length)+" results ",1)]),m(h)!==null?(v(),y("span",SR,A(m(h))+"ms",1)):F("",!0)]),m(k)?(v(),y("span",$R,"“"+A(m(k))+"”",1)):F("",!0)]),d("div",CR,[m(o)?(v(),y("div",QR," Searching... ")):m(S)==="empty-query"?(v(),y("div",PR," Enter a search term to search across all feature specs. ")):m(S)==="no-results"?(v(),y("div",TR," No matching features found. ")):m(S)==="error"?(v(),y("div",MR,[d("p",null,A(m(c)||m(l)),1),m(l)?(v(),y("button",{key:0,type:"button",class:"mt-2 px-2 py-1 rounded border border-retro-border text-retro-muted hover:text-retro-cyan hover:border-retro-cyan transition-colors",onClick:Z}," Retry ")):F("",!0)])):m(f).length>0?(v(),y("ul",AR,[(v(!0),y(we,null,Ne(m(f),(I,z)=>(v(),y("li",{key:`${I.featureId}:${I.sourcePath}:${z}`},[d("button",{type:"button",ref_for:!0,ref:be=>V(z,be),class:_e(["w-full text-left px-4 py-3 min-h-[132px] rounded-lg border border-retro-border/40 border-l-2 transition-colors",z===m(p)?"border-retro-cyan bg-retro-panel/95 text-retro-text shadow-[0_0_0_1px_rgba(34,211,238,0.18)]":"text-retro-muted hover:text-retro-text hover:bg-retro-panel/90"]),onMouseenter:be=>p.value=z,onClick:be=>G(z)},[d("div",RR,[d("span",BR,A(I.featureId),1),d("span",ZR,A(I.sourcePath)+":"+A(I.lineStart)+"-"+A(I.lineEnd),1)]),d("div",{class:"snippet-markdown mt-2 max-h-20 overflow-hidden text-xs text-retro-text",innerHTML:U(I.snippet)},null,8,ER),N[3]||(N[3]=d("div",{class:"mt-2 text-[10px] font-mono text-retro-subtle"}," Select feature ",-1))],42,_R)]))),128))])):(v(),y("div",DR," Start typing to search. "))]),d("div",LR,[N[4]||(N[4]=d("div",{class:"flex items-center gap-2"},[d("span",{class:"border border-retro-border/70 rounded px-1.5 py-0.5"},"↑↓ move"),d("span",{class:"border border-retro-border/70 rounded px-1.5 py-0.5"},"Enter select"),d("span",{class:"border border-retro-border/70 rounded px-1.5 py-0.5"},"Esc close")],-1)),m(u)?(v(),y("span",XR,A(m(u)),1)):F("",!0)]),m(c)?(v(),y("div",IR,[ee(m(En),{class:"h-3.5 w-3.5"}),d("span",null,A(m(c)),1)])):F("",!0)])]),_:1})])]),_:1})]))}}),NR=ws(zR,[["__scopeId","data-v-5199b408"]]);function WR(r){return/^\/speckit\.(clarify|plan|tasks|implement)(\s|$)/.test(r)}function qR(r=Date.now,e=Math.random){return`req-${r()}-${e().toString(36).slice(2,8)}`}function zm(r=Date.now){return`session-${r()}`}function Ta(r,e=!1){const t={};return(!e||r?.hasWorktree)&&r?.worktreePath&&(t.cwd=r.worktreePath,t.worktreeBranch=r.worktreeBranch),r?.baseBranch&&(t.baseBranch=r.baseBranch),r?.featureId&&(t.featureId=r.featureId),Object.keys(t).length>0?t:void 0}function S1(r){if(r.file_path)return String(r.file_path);if(r.path)return String(r.path);if(r.command)return String(r.command).slice(0,50);if(r.pattern)return String(r.pattern);for(const e of Object.values(r))if(typeof e=="string"&&e.length<100)return e;return""}function jR(r){switch(r){case 1e3:return"Normal closure";case 1001:return"Endpoint is going away (server shutdown or page navigation)";case 1002:return"Protocol error";case 1003:return"Unsupported data";case 1005:return"No status code received from peer (close frame had no code)";case 1006:return"Abnormal closure (connection dropped without close frame)";case 1007:return"Invalid payload data";case 1008:return"Policy violation";case 1009:return"Message too big";case 1010:return"Missing required extension";case 1011:return"Internal server error";case 1012:return"Service restart";case 1013:return"Try again later (temporary overload)";case 1015:return"TLS handshake failure";default:return r>=4e3&&r<=4999?"Application-specific close code":"Unknown close code"}}function YR(r,e){const t=[];return r.reason?t.push(r.reason):t.push(jR(r.code)),e?.lastServerError?t.push(`Last server error: ${e.lastServerError}`):e?.lastSocketError&&t.push(`Last socket error: ${e.lastSocketError}`),t.push(`wasClean: ${r.wasClean?"yes":"no"}`),t.join(" | ")}function Nm(r,e="Permission"){const t=r||"",n=t.match(/write to (.+?)(?:[\s,?]|$)/i),s=t.match(/read (.+?)(?:[\s,?]|$)/i),i=t.match(/run (.+?)(?:[?,]|$)/i);return n?.[1]?{tool:"Write",description:t,filePath:n[1].trim()}:s?.[1]?{tool:"Read",description:t,filePath:s[1].trim()}:i?.[1]?{tool:"Bash",description:t,command:i[1].trim()}:{tool:e,description:t}}function FR(){return typeof document>"u"||typeof document.hasFocus!="function"?!1:document.visibilityState==="visible"&&document.hasFocus()}function UR(){return typeof window>"u"?"":`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/_ws`}function yc(r,e){return`${r}:${e}`}function da(r,e){for(const t of r)if(t.type==="tool_use"){const n=t;(n.status==="running"||n.status==="pending")&&(n.status=e)}}function GR(){const r=new Map;function e(a,l,c){r.set(a,{featureId:l,queue:[...c]})}function t(a){a?r.delete(a):r.clear()}function n(a){return r.get(a)}function s(a){const l=r.get(a);if(!l||l.queue.length===0)return null;const c=l.queue.shift();return l.queue.length===0&&r.delete(a),{featureId:l.featureId,step:c}}function i(a){return r.has(a)}function o(){return r.size}return{enable:e,disable:t,get:n,popNextStep:s,has:i,size:o}}function $1(r,e=Ht){return{id:e(),type:"session_init",model:r.model,tools:r.tools,permissionMode:r.permissionMode,cwd:r.cwd}}function C1(r,e=Ht){return{id:r.blockId||e(),type:"text",text:r.text||""}}function Q1(r,e=Ht){return{id:r.blockId||e(),type:"thinking",thinking:r.thinking||""}}function P1(r,e=Ht){if(!r.toolUseId||!r.name)return null;const t=r.blockId||e();return{block:{id:t,type:"tool_use",toolUseId:r.toolUseId,name:r.name,input:{},inputSummary:"",status:"running"},tracking:{blockId:t,toolUseId:r.toolUseId,name:r.name,inputJson:""},index:r.index??0}}function T1(r,e=Ht){return{id:e(),type:"tool_result",toolUseId:r.toolUseId,content:r.content||"",isError:!!r.isError}}function M1(r,e=Ht){return r.subtype!=="success"||!r.usage?null:{id:e(),type:"result_summary",totalCostUsd:r.totalCostUsd??0,durationMs:r.durationMs??0,numTurns:r.numTurns??0,usage:r.usage}}function hl(r,e,t){if(e!==void 0){const n=r.get(e);if(n)return n}if(t){for(const[,n]of r)if(n.blockId===t)return n}}function HR(r,e=Ht){const t=[],n=new Map,s=[];let i="",o=null,a=null,l="streaming",c=!1;for(const u of r){if(u.type==="done"){u.denied||u.aborted?(da(t,"error"),l="stopped"):u.awaitingUserInput?l="complete":l==="error"||l==="stopped"?da(t,"error"):(da(t,"complete"),l="complete"),c=!0;continue}if(u.type==="error"){da(t,"error"),l="error";continue}if(u.type!=="ui_event"||!u.event)continue;const h=u.event;switch(h.sessionId&&s.push(h.sessionId),h.type){case"session_init":{t.push($1(h,e));break}case"block_start":{if(h.blockType==="text"){const f=C1(h,e);t.push(f),o=f.id,h.text&&(i+=h.text)}else if(h.blockType==="thinking"){const f=Q1(h,e);t.push(f),a=f.id}else if(h.blockType==="tool_use"){const f=P1(h,e);f&&(t.push(f.block),n.set(f.index,f.tracking))}break}case"block_delta":{if(h.text&&o){const f=t.find(p=>p.id===o);f&&f.type==="text"&&(f.text+=h.text,i+=h.text)}if(h.thinking&&a){const f=t.find(p=>p.id===a);f&&f.type==="thinking"&&(f.thinking+=h.thinking)}if(h.partialJson){const f=hl(n,h.index,h.blockId);f&&(f.inputJson+=h.partialJson)}break}case"block_end":{const f=hl(n,h.index,h.blockId);if(!f)o&&(o=null),a&&(a=null);else{let p={};try{p=JSON.parse(f.inputJson)}catch{}const g=t.find(O=>O.id===f.blockId);if(g&&g.type==="tool_use"){const O=g;O.input=p,O.inputSummary=S1(p),O.status="pending"}}break}case"tool_result":{const f=t.find(p=>p.type==="tool_use"&&p.toolUseId===h.toolUseId);f&&f.type==="tool_use"&&(f.status=h.isError?"error":"complete"),t.push(T1(h,e));break}case"turn_result":{h.subtype!=="success"&&(l="error");const f=M1(h,e);f&&t.push(f);break}case"error":{l="error";break}}}return{contentBlocks:t,flatText:i,currentTextBlockId:o,currentThinkingBlockId:a,activeTools:n,finalStatus:l,isDone:c,providerSessionIds:s}}function KR(r,e,t=Date.now){return{ws:r,currentMessageId:"",conversationId:e,activeTools:new Map,currentTextBlockId:null,currentThinkingBlockId:null,healthCheckInterval:null,lastMessageTime:t(),lastServerError:null,lastSocketError:null,isReplaying:!1,replayBuffer:[]}}function kc(r,e,t){const n=r.get(e);return!!n&&n.ws!==t}function JR(r,e){const t=r.get(e);return t?t.ws.readyState===WebSocket.OPEN?{kind:"open",conn:t}:{kind:"stale",conn:t}:{kind:"none"}}const mt=new Map;let fa=0;const As=GR(),ma=new Set,eB=3e4,A1=18e4,tB=Math.round(A1/1e3);function Ml(){const r=vr(),e=bo();fa++;function t(T){const E=r.conversations.find(B=>B.id===T)?.title?.trim()||"Chat";return new Notification("Spec Cat",{body:`${E} response completed.`,tag:`chat-complete-${T}`})}async function n(T){if(!(typeof window>"u"||typeof Notification>"u")&&!FR()){if(Notification.permission==="granted"){t(T);return}if(Notification.permission==="default")try{await Notification.requestPermission()==="granted"&&t(T)}catch(M){console.warn("[useChatStream] Failed to request browser notification permission:",M)}}}function s(T){T.healthCheckInterval&&(clearInterval(T.healthCheckInterval),T.healthCheckInterval=null)}function i(T){s(T),T.lastMessageTime=Date.now(),T.healthCheckInterval=Lu(()=>{const M=T.conversationId;if(T.ws.readyState!==WebSocket.OPEN){console.warn(`[useChatStream] Health check: WebSocket not open for ${M}`),s(T),r.isConversationStreaming(M)&&(c(T.currentMessageId,M,"error"),r.updateMessage(T.currentMessageId,{status:"error"},M),r.setSessionError("Connection lost during streaming",M),r.endSession(M),r.endConversationStreaming(M)),mt.delete(M);return}if(r.isConversationStreaming(M)){const E=Date.now()-T.lastMessageTime;E>A1&&(console.warn(`[useChatStream] Health check: streaming timeout for ${M} (${Math.round(E/1e3)}s)`),s(T),c(T.currentMessageId,M,"error"),r.updateMessage(T.currentMessageId,{status:"error"},M),r.setSessionError(`Streaming timed out — no response from server for ${tB} seconds`,M),r.endSession(M),r.endConversationStreaming(M),T.ws.close(),mt.delete(M))}},eB)}function o(T,M){return r.conversations.find(B=>B.id===T)?.messages.find(B=>B.id===M)?.status}function a(T,M=!0){const E=mt.get(T);E&&(s(E),M&&E.ws.readyState===WebSocket.OPEN&&E.ws.close(),mt.delete(T))}function l(T,M,E){!E||!T.currentTextBlockId||(r.updateBlockWithSave(T.currentMessageId,T.currentTextBlockId,B=>{B.type==="text"&&(B.text+=E)},M,{syncContent:!1}),r.appendToMessage(T.currentMessageId,E,M))}function c(T,M,E){const xe=r.conversations.find(Re=>Re.id===M)?.messages.find(Re=>Re.id===T);if(xe?.contentBlocks)for(const Re of xe.contentBlocks)Re.type==="tool_use"&&(Re.status==="running"||Re.status==="pending")&&r.updateBlockById(T,Re.id,Me=>{Me.type==="tool_use"&&(Me.status=E)},M)}async function u(T){try{(await h(T)).send(JSON.stringify({type:"reset_context"})),r.clearProviderSession(T),console.log("[useChatStream] Context reset requested for conversation:",T)}catch(M){throw console.error("[useChatStream] Failed to reset context:",M),M}}function h(T){return new Promise((M,E)=>{let B=!1;const xe=q=>{B||(B=!0,M(q))},Re=q=>{B||(B=!0,E(q))},Me=JR(mt,T);if(Me.kind==="open"){xe(Me.conn.ws);return}Me.kind==="stale"&&(Me.conn.ws.close(),mt.delete(T));const ue=UR(),ne=new WebSocket(ue),Ce=KR(ne,T);mt.set(T,Ce),ne.onopen=()=>{xe(ne)},ne.onerror=q=>{if(console.error(`[useChatStream] WebSocket error for conversation ${T}:`,q),kc(mt,T,ne))return;const ve=mt.get(T);ve&&(ve.lastSocketError="Browser reported a WebSocket transport error (network/proxy/server)"),r.isConversationStreaming(T)&&(ve?.currentMessageId&&(c(ve.currentMessageId,T,"error"),r.updateMessage(ve.currentMessageId,{status:"error"},T)),r.setSessionError("Connection error during streaming",T),r.endSession(T),r.endConversationStreaming(T)),mt.delete(T),Re(new Error("WebSocket connection failed. Server may be unavailable."))},ne.onclose=q=>{if(kc(mt,T,ne))return;const ve=mt.get(T);if(ve&&s(ve),mt.delete(T),As.disable(T),!B){Re(new Error(`WebSocket closed before connection was established (code: ${q.code})`));return}if(r.isConversationStreaming(T)){ve?.currentMessageId&&(c(ve.currentMessageId,T,"error"),r.updateMessage(ve.currentMessageId,{status:"error"},T));const Ze=YR(q,ve);r.setSessionError(`Connection closed: ${Ze} (code: ${q.code})`,T),r.endSession(T),r.endConversationStreaming(T)}},ne.onmessage=q=>{kc(mt,T,ne)||g(q.data,T)}})}async function f(T,M=3){for(let E=0;E<M;E++){const B=r.conversations.find(xe=>xe.id===T);if(B)return B;E<M-1&&await new Promise(xe=>setTimeout(xe,100))}console.error("[useChatStream] Conversation not found after retries:",T)}function p(T,M){const E=r.conversations.find(xe=>xe.id===T);if(!E)return null;const B=E.messages.findIndex(xe=>xe.id===M);if(B<=0)return null;for(let xe=B-1;xe>=0;xe--){const Re=E.messages[xe];if(Re.role==="user"&&Re.content.trim().length>0)return Re.content}return null}async function g(T,M){const E=mt.get(M);if(E){E.lastMessageTime=Date.now();try{r.pushDebugEvent({direction:"in",channel:"ws",eventType:"ws.raw",payload:T},M);const B=JSON.parse(T);if(r.pushDebugEvent({direction:"in",channel:"ws",eventType:B.type,payload:B},M),E.isReplaying&&((B.type==="ui_event"||B.type==="done"||B.type==="error")&&E.replayBuffer.push(B),B.type!=="replay_end"))return;if(B.type==="error")return await Q(B,E,M),void 0;if(B.type==="done"){await L(B,E,M);return}if(B.type==="pong")return;if(B.type==="session_reset"){console.warn(`[useChatStream] Session reset for ${M}:`,B.reason),r.setProviderSessionId("",M),W(E.currentMessageId,`
40
40
 
41
41
  > **Session Reset**: Previous session could not be resumed. Retrying with a fresh session...
42
42
 
@@ -54,7 +54,7 @@ import{y as v,z as y,A as d,d as Ve,C as ee,G as m,R as je,S as Je,U as Rt,I as
54
54
 
55
55
  > **Session Reset**: Codex resume state was corrupted. Retrying once with a fresh session...
56
56
 
57
- `,E);try{const ne=r.conversations.find(q=>q.id===E),Ce=Ta(ne);return await N(ue,M.currentMessageId,E,Ce),!0}catch(ne){console.error(`[useChatStream] Rollout-path recovery retry failed for ${E}:`,ne)}}}}return s(M),c(M.currentMessageId,E,"error"),r.updateMessage(M.currentMessageId,{status:"error"},E),S.test(B)&&r.setProviderSessionId("",E),ma.delete(yc(E,M.currentMessageId)),r.setSessionError(B,E),r.endSession(E),r.endConversationStreaming(E),be(E),r.saveConversation(E,!0),a(E),!1}async function L(T,M,E){s(M);const B=o(E,M.currentMessageId);if(ma.delete(yc(E,M.currentMessageId)),T.denied){c(M.currentMessageId,E,"error"),r.updateMessage(M.currentMessageId,{status:"stopped"},E),D(M,E);return}if(T.awaitingUserInput){r.completeMessageWithSave(M.currentMessageId,E),r.endSession(E),r.endConversationStreaming(E),n(E),r.clearPendingPermission(E),r.saveConversation(E,!0),M.activeTools.clear();return}if(B==="error"||B==="stopped"){c(M.currentMessageId,E,"error"),D(M,E);return}c(M.currentMessageId,E,"complete"),r.completeMessageWithSave(M.currentMessageId,E),r.endSession(E),r.endConversationStreaming(E),n(E);const xe=await f(E),Re=G(xe,E,M),Me=As.popNextStep(E);Me&&Re.then(()=>{setTimeout(()=>{K(E,Me.featureId,Me.step)},1500)}),r.clearPendingPermission(E),r.saveConversation(E,!0),M.activeTools.clear()}function D(T,M){r.endSession(M),r.endConversationStreaming(M),be(M),r.clearPendingPermission(M),T.activeTools.clear(),r.saveConversation(M,!0)}function G(T,M,E){return!T?.hasWorktree||!T.worktreePath?Promise.resolve():$fetch("/api/chat/worktree-commit",{method:"POST",body:{worktreePath:T.worktreePath,conversationId:M,previousBranch:T.worktreeBranch}}).then(B=>T.previewBranch&&T.worktreePath?$fetch("/api/chat/preview-sync",{method:"POST",body:{previewBranch:T.previewBranch,worktreePath:T.worktreePath}}).then(xe=>{if(!xe.success)throw new Error(xe.error||"Unknown preview sync failure");return B}):B).then(async B=>{if(B?.success&&B.currentBranch!==T.worktreeBranch){const xe=T.worktreeBranch||"unknown";r.updateWorktreeBranch(M,B.currentBranch);const Re=await r.syncConversationFeatureFromBranch(M),Me=B.deletedPreviousBranch?` and deleted \`${xe}\``:"",ue=Re?` and linked to feature \`${Re}\``:"";W(E.currentMessageId,`
57
+ `,E);try{const ne=r.conversations.find(q=>q.id===E),Ce=Ta(ne);return await N(ue,M.currentMessageId,E,Ce),!0}catch(ne){console.error(`[useChatStream] Rollout-path recovery retry failed for ${E}:`,ne)}}}}return s(M),c(M.currentMessageId,E,"error"),r.updateMessage(M.currentMessageId,{status:"error"},E),S.test(B)&&r.setProviderSessionId("",E),ma.delete(yc(E,M.currentMessageId)),r.setSessionError(B,E),r.endSession(E),r.endConversationStreaming(E),be(E),r.saveConversation(E,!0),a(E),!1}async function L(T,M,E){s(M);const B=o(E,M.currentMessageId);if(ma.delete(yc(E,M.currentMessageId)),T.denied||T.aborted){c(M.currentMessageId,E,"error"),r.updateMessage(M.currentMessageId,{status:"stopped"},E),D(M,E);return}if(T.awaitingUserInput){r.completeMessageWithSave(M.currentMessageId,E),r.endSession(E),r.endConversationStreaming(E),n(E),r.clearPendingPermission(E),r.saveConversation(E,!0),M.activeTools.clear();return}if(B==="error"||B==="stopped"){c(M.currentMessageId,E,"error"),D(M,E);return}c(M.currentMessageId,E,"complete"),r.completeMessageWithSave(M.currentMessageId,E),r.endSession(E),r.endConversationStreaming(E),n(E);const xe=await f(E),Re=G(xe,E,M),Me=As.popNextStep(E);Me&&Re.then(()=>{setTimeout(()=>{K(E,Me.featureId,Me.step)},1500)}),r.clearPendingPermission(E),r.saveConversation(E,!0),M.activeTools.clear()}function D(T,M){r.endSession(M),r.endConversationStreaming(M),be(M),r.clearPendingPermission(M),T.activeTools.clear(),r.saveConversation(M,!0)}function G(T,M,E){return!T?.hasWorktree||!T.worktreePath?Promise.resolve():$fetch("/api/chat/worktree-commit",{method:"POST",body:{worktreePath:T.worktreePath,conversationId:M,previousBranch:T.worktreeBranch}}).then(B=>T.previewBranch&&T.worktreePath?$fetch("/api/chat/preview-sync",{method:"POST",body:{previewBranch:T.previewBranch,worktreePath:T.worktreePath}}).then(xe=>{if(!xe.success)throw new Error(xe.error||"Unknown preview sync failure");return B}):B).then(async B=>{if(B?.success&&B.currentBranch!==T.worktreeBranch){const xe=T.worktreeBranch||"unknown";r.updateWorktreeBranch(M,B.currentBranch);const Re=await r.syncConversationFeatureFromBranch(M),Me=B.deletedPreviousBranch?` and deleted \`${xe}\``:"",ue=Re?` and linked to feature \`${Re}\``:"";W(E.currentMessageId,`
58
58
 
59
59
  > **Branch changed**: AI switched from \`${xe}\` to \`${B.currentBranch}\`${Me}${ue}
60
60
 
@@ -62,14 +62,14 @@ import{y as v,z as y,A as d,d as Ve,C as ee,G as m,R as je,S as Je,U as Rt,I as
62
62
 
63
63
  **Permission Required**: ${B.tool}
64
64
  `,M);break}case"turn_result":{T.subtype!=="success"&&(r.updateMessage(E.currentMessageId,{status:"error"},M),be(M),T.subtype==="max_turns"?r.setSessionError("Maximum conversation turns reached. Please start a new conversation.",M):r.setSessionError("Provider reported an execution error.",M));const B=M1(T);B&&(U(E.currentMessageId,M),r.appendContentBlockWithSave(E.currentMessageId,B,M));break}case"error":{r.updateMessage(E.currentMessageId,{status:"error"},M),r.setSessionError(T.error,M);break}}}function Z(T,M){const E=T.replayBuffer;if(E.length===0)return;const B=HR(E);for(const xe of B.providerSessionIds)r.setProviderSessionId(xe,M);r.batchSetMessageBlocks(T.currentMessageId,B.contentBlocks,B.flatText,B.finalStatus,M),T.currentTextBlockId=B.currentTextBlockId,T.currentThinkingBlockId=B.currentThinkingBlockId,T.activeTools=B.activeTools,B.isDone&&(s(T),r.endSession(M),r.endConversationStreaming(M),n(M)),console.log(`[useChatStream] Replay batch processed: ${E.length} events → ${B.contentBlocks.length} blocks, status=${B.finalStatus}`)}function U(T,M){r.initContentBlocks(T,M)}function W(T,M,E){U(T,E);const B={id:Ht(),type:"text",text:M};r.appendContentBlockWithSave(T,B,E)}async function N(T,M,E,B){if(typeof window>"u")return;const xe=qR();try{const Re=await h(E),Me=mt.get(E);Me&&(Me.currentMessageId=M,Me.activeTools.clear(),Me.currentTextBlockId=null,Me.currentThinkingBlockId=null,i(Me)),WR(T)&&r.setProviderSessionId("",E);const ne=r.getProviderSessionId(E),Ce=r.conversations.find(it=>it.id===E),q=Ce?.providerId||e.providerSelection.providerId||tp,ve=Ce?.providerModelKey||e.providerSelection.modelKey||ep;Ce&&(!Ce.providerId||!Ce.providerModelKey)&&(r.setConversationProviderSelection(E,q,ve),r.saveConversation(E,!0));const Ze={type:"chat",message:T,attachments:B?.attachments,requestId:xe,sessionId:ne||void 0,permissionMode:r.permissionMode,conversationId:E,cwd:B?.cwd,worktreeBranch:B?.worktreeBranch,baseBranch:B?.baseBranch,featureId:B?.featureId,providerId:q,providerModelKey:ve};r.pushDebugEvent({direction:"out",channel:"ws",eventType:"chat",payload:Ze},E),Re.send(JSON.stringify(Ze))}catch(Re){r.updateMessage(M,{status:"error"},E),r.setSessionError(Re.message||"Connection failed",E),r.endSession(E),r.endConversationStreaming(E),r.saveConversation(E,!0),a(E)}}function I(T,M){const E=M??r.activeConversationId;if(!E)return;const B=mt.get(E);if(!B||B.ws.readyState!==WebSocket.OPEN)return;const xe={type:"permission_response",allow:T};r.pushDebugEvent({direction:"out",channel:"ws",eventType:"permission_response",payload:xe},E),B.ws.send(JSON.stringify(xe)),T&&(r.startConversationStreaming(E),i(B));const Re=T?"Allowed":"Denied";W(B.currentMessageId,`${Re}
65
- `,E),r.clearPendingPermission(E)}function z(T,M,E){As.enable(M,T,E)}function be(T){As.disable(T)}async function K(T,M,E){r.activeConversationId!==T&&r.selectConversation(T);const B=r.conversations.find(ue=>ue.id===T);let xe;if(E.startsWith("skill:")){const ue=E.replace("skill:","");try{xe=(await $fetch(`/api/skills/${ue}/prompt`,{method:"POST",body:{featureId:M,cwd:B?.worktreePath}})).prompt}catch(ne){console.error(`[useChatStream] Failed to render skill prompt for ${ue}:`,ne);return}}else xe=`/speckit.${E} ${M}`;r.addUserMessage(xe,T),r.saveConversation(T,!0);const Re=r.addAssistantMessage(T);r.startSession(zm(),T),r.startConversationStreaming(T);const Me=Ta(B);await N(xe,Re.id,T,Me)}async function H(T,M,E=0){if(!(typeof window>"u"))try{const B=await h(T),xe=mt.get(T);xe&&(xe.currentMessageId=M,xe.activeTools.clear(),xe.currentTextBlockId=null,xe.currentThinkingBlockId=null,i(xe)),r.startConversationStreaming(T);const Re={type:"subscribe",conversationId:T,cursor:E};r.pushDebugEvent({direction:"out",channel:"ws",eventType:"subscribe",payload:Re},T),B.send(JSON.stringify(Re))}catch(B){console.error(`[useChatStream] Failed to subscribe to ${T}:`,B),r.setSessionError(B.message||"Subscribe failed",T)}}function re(T){const M=T??r.activeConversationId;if(!M)return;const E=mt.get(M);if(E){if(E.ws.readyState===WebSocket.OPEN){const B={type:"abort"};r.pushDebugEvent({direction:"out",channel:"ws",eventType:"abort",payload:B},M),E.ws.send(JSON.stringify(B)),E.ws.close()}E.currentMessageId&&(c(E.currentMessageId,M,"error"),r.updateMessage(E.currentMessageId,{status:"stopped"},M),r.endSession(M),r.saveConversation(M,!0)),mt.delete(M)}r.endConversationStreaming(M),r.clearPendingPermission(M),be(M)}function Oe(T){const M=mt.get(T);M&&(s(M),M.ws.close(),mt.delete(T)),As.disable(T)}function ge(){for(const[T,M]of mt)s(M),M.ws.close(),mt.delete(T);As.disable()}async function $e(T){const M=T??r.activeConversationId;if(!M)return;r.clearPendingPlanApproval(M),r.setPermissionMode("auto");const E="Approved. Proceed with the implementation.";r.addUserMessage(E,M),r.saveConversation(M,!0);const B=r.addAssistantMessage(M);r.startSession(zm(),M),r.startConversationStreaming(M);const xe=r.conversations.find(Me=>Me.id===M),Re=Ta(xe,!0);await N(E,B.id,M,Re)}function Pe(T){const M=T??r.activeConversationId;M&&r.clearPendingPlanApproval(M)}async function Fe(T){if(typeof window>"u")return!1;try{const M=await $fetch("/api/jobs",{params:{conversationId:T}}),B=M.find(Me=>Me.status==="running"||Me.status==="waiting_permission"||Me.status==="queued")||[...M].sort((Me,ue)=>ue.eventCount-Me.eventCount).find(Me=>Me.eventCount>0),xe=r.conversations.find(Me=>Me.id===T);if(!xe)return!1;const Re=[...xe.messages].reverse().find(Me=>Me.role==="assistant");return B?!Re||Re.status!=="streaming"?!1:(console.log("[useChatStream] Resuming streaming for",T,"job:",B.id,"status:",B.status,"events:",B.eventCount),r.resetMessageForReplay(Re.id,T),r.startSession(`resume-${Date.now()}`,T),await H(T,Re.id,0),!0):(Re&&Re.status==="streaming"&&(r.updateMessage(Re.id,{status:"error"},T),r.setSessionError("Streaming was interrupted (server job no longer active)",T)),!1)}catch(M){return console.error("[useChatStream] Failed to resume streaming:",M),!1}}return wt(()=>{fa--,fa<=0&&(fa=0,ge())}),{sendMessage:N,sendPermissionResponse:I,subscribe:H,tryResumeStreaming:Fe,approvePlan:$e,rejectPlan:Pe,abort:re,disconnect:ge,disconnectConversation:Oe,enableCascade:z,disableCascade:be,resetContext:u}}const rB=/^[0-9a-f]{7,40}$/i;function Bo(r){if(typeof r!="string")return!1;const e=r.trim();return e.length>0&&e!=="HEAD"&&!e.startsWith("sc/")&&!rB.test(e)}function Xh(r,e){const t=e.map(s=>s.trim()).filter(Boolean),n=r?.trim()||"";return n&&t.includes(n)&&Bo(n)?n:t.includes("main")?"main":t.includes("master")?"master":t[0]||null}function _1(r){return Bo(r)?r.trim():"Loading branches..."}function Ih(r){const e=[r.name,r.ref];for(const t of e){if(typeof t!="string")continue;const n=t.trim();if(!n)continue;const s=n.startsWith("refs/heads/")?n.slice(11):n;if(Bo(s))return s}return null}const nB={class:"w-full max-w-md mx-4 bg-retro-dark border border-retro-border rounded-lg shadow-xl"},sB={class:"px-4 py-3 border-b border-retro-border flex items-center justify-between"},iB=["disabled"],oB={class:"px-4 py-4 space-y-3"},aB={class:"relative"},lB=["disabled"],cB={key:0,value:""},uB=["value"],hB={key:0,class:"text-xs font-mono text-retro-red"},dB={key:1,class:"text-xs font-mono text-retro-muted"},fB={class:"px-4 py-3 border-t border-retro-border flex items-center gap-2 justify-end"},mB=["disabled"],pB=["disabled"],Tu=Ve({__name:"NewConversationModal",props:{show:{type:Boolean},creating:{type:Boolean}},emits:["close","create"],setup(r,{emit:e}){const t=r,n=e,s=P([]),i=P(""),o=P(!1),a=P(""),l=J(()=>!o.value&&!t.creating&&i.value.length>0&&s.value.length>0);async function c(){o.value=!0,a.value="";try{const{cwd:h}=await $fetch("/api/cwd"),p=(await $fetch("/api/git/branches",{query:{excludeSc:!0,workingDirectory:h}})).branches.filter(O=>!O.isRemote).map(Ih).filter(O=>!!O),g=Array.from(new Set(p)).sort((O,b)=>{const x=w=>w==="main"?0:w==="master"?1:2,k=x(O)-x(b);return k!==0?k:O.localeCompare(b,void 0,{sensitivity:"base"})});if(s.value=g,!g.length){i.value="",a.value="No local branches available for chat creation.";return}i.value=Xh("main",g)||g[0]}catch(h){s.value=[],i.value="",a.value=h instanceof Error?h.message:"Failed to load branches"}finally{o.value=!1}}ze(()=>t.show,h=>{h&&c()});function u(){l.value&&n("create",i.value)}return(h,f)=>(v(),pe(Pr,{to:"body"},[ee(On,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ut(()=>[r.show?(v(),y("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:f[3]||(f[3]=kr(p=>n("close"),["self"]))},[d("div",nB,[d("div",sB,[f[4]||(f[4]=d("h3",{class:"text-sm font-mono text-retro-text font-semibold"},"New Conversation",-1)),d("button",{type:"button",class:"p-1 text-retro-muted hover:text-retro-text transition-colors",disabled:r.creating,onClick:f[0]||(f[0]=p=>n("close"))},[ee(m(St),{class:"w-4 h-4"})],8,iB)]),d("div",oB,[f[5]||(f[5]=d("label",{class:"block text-xs font-mono text-retro-muted"},"Base Branch",-1)),d("div",aB,[je(d("select",{"onUpdate:modelValue":f[1]||(f[1]=p=>i.value=p),disabled:o.value||r.creating||s.value.length===0,class:"w-full appearance-none bg-retro-black border border-retro-border rounded px-2 py-1.5 pr-7 text-xs font-mono text-retro-cyan focus:outline-none focus:border-retro-cyan disabled:opacity-40"},[o.value?(v(),y("option",cB,"Loading branches...")):F("",!0),(v(!0),y(we,null,Ne(s.value,p=>(v(),y("option",{key:p,value:p},A(p),9,uB))),128))],8,lB),[[ks,i.value]]),ee(m(Ru),{class:"absolute right-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-retro-muted pointer-events-none"})]),a.value?(v(),y("p",hB,A(a.value),1)):(v(),y("p",dB," The conversation worktree will be created from the selected branch. "))]),d("div",fB,[d("button",{type:"button",class:"px-3 py-1.5 text-xs font-mono rounded border border-retro-border text-retro-muted hover:text-retro-text hover:border-retro-text/30 transition-colors disabled:opacity-40",disabled:r.creating,onClick:f[2]||(f[2]=p=>n("close"))}," Cancel ",8,mB),d("button",{type:"button",disabled:!l.value,class:"px-3 py-1.5 text-xs font-mono rounded border bg-retro-cyan/10 border-retro-cyan/50 text-retro-cyan hover:bg-retro-cyan/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",onClick:u},A(r.creating?"Creating...":"Create"),9,pB)])])])):F("",!0)]),_:1})]))}}),gB={class:"h-full flex flex-col bg-retro-black"},OB={class:"flex-shrink-0 flex items-center justify-between px-4 py-2 border-b border-retro-border"},vB={class:"flex items-center gap-1"},bB={class:"flex-shrink-0 px-3 pt-3"},xB={class:"relative"},yB={class:"flex-1 overflow-y-auto p-3"},kB={class:"space-y-2"},wB={key:0,class:"flex items-center justify-center py-12"},SB={key:1,class:"flex flex-col items-center justify-center py-12 text-center"},$B={key:2,class:"flex flex-col items-center justify-center py-12 text-center"},Wm=Ve({__name:"FeaturesPanel",setup(r){const e=vr(),t=ml(),{sendMessage:n,enableCascade:s}=Ml(),i=vo(),o=P("features"),a=P(null),l=P(null),c=P([]),u=P([]),h=P(!1),f=P({}),p=P(!1),g=P(null),O=P(!1),b=P(!1),x=P(!1),k=P(null),w=P(""),S=P("");let Q=null;ze(w,ue=>{Q&&clearTimeout(Q),Q=setTimeout(()=>{S.value=ue},300)});const L=J(()=>{const ue=S.value.trim().toLowerCase();return ue?c.value.filter(ne=>ne.name.toLowerCase().includes(ue)||ne.id.toLowerCase().includes(ue)):c.value}),D=P({}),G=J(()=>{const ue=e.activeConversation;if(!ue)return null;if(ue.featureId)return ue.featureId;const ne=ue.worktreeBranch?.trim();return ne&&c.value.some(Ce=>Ce.id===ne)?ne:null}),oe=J(()=>G.value||a.value);ze(()=>e.activeConversationId,()=>{a.value=null;const ue=G.value;t.setSelectedFeatureId(ue),ue&&It(()=>{const ne=D.value[ue];ne&&ne.scrollIntoView({behavior:"auto",block:"nearest"})})}),ze(a,ue=>{ue&&It(()=>{const ne=D.value[ue];ne&&ne.scrollIntoView({behavior:"auto",block:"nearest"})})});async function ie(){h.value=!0;try{const ue=await $fetch("/api/specs/features");c.value=ue.features,j(ue.features)}catch{i.error("Failed to load features"),c.value=[],f.value={}}finally{h.value=!1}}async function j(ue){if(ue.length===0){f.value={};return}const ne=await Promise.allSettled(ue.map(async q=>{const ve=await $fetch(`/api/specs/traceability/${q.id}`),Ze=ve.alerts.filter(Nt=>Nt.severity==="critical").length,it=ve.alerts.filter(Nt=>Nt.severity==="major").length;return{featureId:q.id,critical:Ze,major:it}})),Ce={};for(const q of ne)q.status==="fulfilled"&&(Ce[q.value.featureId]={critical:q.value.critical,major:q.value.major});f.value=Ce}async function V(){try{const ue=await $fetch("/api/skills");u.value=ue.skills}catch{u.value=[]}}gt(()=>{ie(),V(),window.addEventListener("keydown",W)}),wt(()=>{window.removeEventListener("keydown",W)});function Z(ue,ne={}){if(a.value=ue,l.value=null,o.value="files",t.setSelectedFeatureId(ue),ne.openViewer!==!1){const Ce=c.value.find(q=>q.id===ue);Ce&&(g.value=Ce,p.value=!0)}}function U(){p.value=!1,g.value=null}function W(ue){(ue.ctrlKey||ue.metaKey)&&ue.key.toLowerCase()==="k"&&(ue.preventDefault(),O.value||(O.value=!0))}function N(){O.value=!1}function I(ue){Z(ue,{openViewer:!1}),O.value=!1}function z(){O.value=!0}const be=J(()=>c.value.map(ue=>ue.id));function K(ue){return f.value[ue]??{critical:0,major:0}}const H={plan:["tasks","implement"],tasks:["implement"],implement:[],clarify:[],analyze:[]},re={analyze:["skill:better-spec"]};async function Oe(ue,ne,Ce){if(ue.startsWith("skill:")){const q=ue.replace("skill:",""),ve=Ce?e.conversations.find(it=>it.id===Ce):null;return(await $fetch(`/api/skills/${q}/prompt`,{method:"POST",body:{featureId:ne,cwd:ve?.worktreePath}})).prompt}return`/speckit.${ue} ${ne}`}function ge(ue,ne){if(ne)return null;const Ce=e.findConversationByFeature(ue);return Ce&&!e.isConversationStreaming(Ce.id)&&!Ce.finalized?(e.selectConversation(Ce.id),Ce.id):null}function $e(ue){const ne=e.findConversationByFeature(ue);return ne&&ne.finalized?(i.error(`This feature has a finalized conversation "${ne.title}". Please archive it first to start a new conversation.`),e.selectConversation(ne.id),!0):!1}async function Pe(ue,ne,Ce){const q=await e.createConversation({featureId:ue,baseBranch:Ce});if(!q)throw new Error("Failed to create conversation");return e.renameConversation(q,ne),e.selectConversation(q),q}async function Fe(ue,ne){e.addUserMessage(ne,ue),e.saveConversation(ue,!0);const Ce=e.conversations.find(Ze=>Ze.id===ue),q=e.addAssistantMessage(ue);e.startSession(`session-${Date.now()}`,ue),e.startConversationStreaming(ue);const ve={};Ce?.worktreePath&&(ve.cwd=Ce.worktreePath,ve.worktreeBranch=Ce.worktreeBranch),Ce?.featureId&&(ve.featureId=Ce.featureId),await n(ne,q.id,ue,Object.keys(ve).length>0?ve:void 0)}async function T(ue,ne,Ce){const q=re[ne];let ve;if(q&&q.length>0){const Ze=[...q.slice(1),ne,...H[ne]||[]];s(ue,Ce,Ze);const it=q[0];try{ve=await Oe(it,ue,Ce)}catch(Nt){i.error(Nt instanceof Error?Nt.message:"Failed to resolve prerequisite step");return}}else{const Ze=H[ne]||[];Ze.length>0&&s(ue,Ce,Ze),ve=`/speckit.${ne} ${ue}`}await Fe(Ce,ve)}async function M(ue,ne,Ce){const q=ue.shiftKey;if(!q&&$e(ne))return;const ve=ge(ne,q);if(ve){try{await T(ne,Ce,ve)}catch(Ze){i.error(Ze instanceof Error?Ze.message:"Failed to run cascade action")}return}k.value={type:"cascade",featureId:ne,command:Ce,title:`${Ce}: ${ne}`},b.value=!0}async function E(ue,ne){$e(ne)||(k.value={type:"open-chat",featureId:ne,title:`spec: ${ne}`},b.value=!0)}async function B(ue,ne,Ce){let q;try{const ve=e.conversations.find(Ze=>Ze.id===Ce);q=await $fetch(`/api/skills/${ne}/prompt`,{method:"POST",body:{featureId:ue,cwd:ve?.worktreePath}})}catch(ve){throw new Error(ve instanceof Error?ve.message:"Failed to render skill prompt")}await Fe(Ce,q.prompt)}async function xe(ue,ne,Ce){const q=ue.shiftKey;if(!q&&$e(ne))return;const ve=ge(ne,q);if(ve){try{await B(ne,Ce,ve)}catch(Ze){i.error(Ze instanceof Error?Ze.message:"Failed to run skill")}return}k.value={type:"skill",featureId:ne,skillId:Ce,title:`skill: ${Ce} — ${ne}`},b.value=!0}function Re(){b.value=!1,k.value=null}async function Me(ue){if(k.value){x.value=!0;try{const ne=k.value,Ce=await Pe(ne.featureId,ne.title,ue);ne.type==="cascade"?await T(ne.featureId,ne.command,Ce):ne.type==="skill"&&await B(ne.featureId,ne.skillId,Ce),b.value=!1,k.value=null}catch(ne){i.error(ne instanceof Error?ne.message:"Failed to create conversation")}finally{x.value=!1}}}return(ue,ne)=>{const Ce=B2,q=OR,ve=NR;return v(),y("div",gB,[d("div",OB,[ne[2]||(ne[2]=d("div",{class:"flex items-center gap-2 min-w-0"},null,-1)),d("div",vB,[d("button",{type:"button",class:"p-1.5 rounded text-retro-muted hover:text-retro-cyan hover:bg-retro-panel transition-colors",title:"Search (Ctrl/Cmd+K)",onClick:z},[ee(m(fs),{class:"h-4 w-4"})]),d("button",{type:"button",class:"p-1.5 rounded text-retro-muted hover:text-retro-cyan hover:bg-retro-panel transition-colors",title:"Refresh",onClick:ie},[ee(m(gs),{class:_e(["h-4 w-4",{"animate-spin":m(h)}])},null,8,["class"])])])]),d("div",bB,[d("div",xB,[ee(m(fs),{class:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-retro-subtle"}),je(d("input",{"onUpdate:modelValue":ne[0]||(ne[0]=Ze=>Je(w)?w.value=Ze:null),type:"text",placeholder:"Search features...",class:"w-full pl-8 pr-3 py-1.5 text-xs font-mono rounded border border-retro-border bg-retro-panel text-retro-text placeholder:text-retro-subtle focus:outline-none focus:border-retro-cyan transition-colors"},null,512),[[Rt,m(w)]])])]),d("div",yB,[d("div",kB,[(v(!0),y(we,null,Ne(m(L),Ze=>(v(),y("div",{key:Ze.id,ref_for:!0,ref:it=>{m(D)[Ze.id]=it}},[ee(Ce,{feature:Ze,skills:m(u),"is-active":m(oe)===Ze.id,"critical-alerts":K(Ze.id).critical,"major-alerts":K(Ze.id).major,onSelect:ne[1]||(ne[1]=it=>Z(it,{openViewer:!0})),onCascade:M,onOpenChat:E,onSkill:xe},null,8,["feature","skills","is-active","critical-alerts","major-alerts"])]))),128))]),m(h)&&m(c).length===0?(v(),y("div",wB,[...ne[3]||(ne[3]=[d("span",{class:"text-sm font-mono text-retro-muted animate-pulse"},"Loading features...",-1)])])):F("",!0),!m(h)&&m(c).length>0&&m(L).length===0?(v(),y("div",SB,[ee(m(fs),{class:"h-10 w-10 text-retro-subtle mb-3"}),ne[4]||(ne[4]=d("p",{class:"text-sm font-mono text-retro-muted"},"No matching features",-1)),ne[5]||(ne[5]=d("p",{class:"mt-1 text-xs font-mono text-retro-subtle"}," Try a different search term ",-1))])):F("",!0),!m(h)&&m(c).length===0?(v(),y("div",$B,[ee(m(Tv),{class:"h-10 w-10 text-retro-subtle mb-3"}),ne[6]||(ne[6]=d("p",{class:"text-sm font-mono text-retro-muted"},"No features found",-1)),ne[7]||(ne[7]=d("p",{class:"mt-1 text-xs font-mono text-retro-subtle"}," Create a feature in specs/ to get started ",-1))])):F("",!0)]),m(p)&&m(g)?(v(),pe(q,{key:0,feature:m(g),onClose:U},null,8,["feature"])):F("",!0),m(O)?(v(),pe(ve,{key:1,"available-feature-ids":m(be),onClose:N,onSelect:I},null,8,["available-feature-ids"])):F("",!0),ee(Tu,{show:m(b),creating:m(x),onClose:Re,onCreate:Me},null,8,["show","creating"])])}}}),CB={class:"h-full flex flex-col bg-retro-black"},QB={class:"flex-shrink-0 px-3 py-2 border-b border-retro-border space-y-2"},PB={class:"flex items-center justify-between gap-2"},TB={class:"flex items-center gap-1"},MB={class:"relative"},AB=["placeholder"],_B={key:0,class:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-retro-yellow/10 border-b border-retro-yellow/30 text-xs"},RB={class:"text-retro-yellow font-mono"},BB={class:"flex-1 overflow-y-auto p-2"},ZB={key:0,class:"space-y-1"},EB={key:1,class:"text-center py-6 text-retro-muted"},DB={class:"font-mono text-xs"},LB={key:1,class:"text-center py-8 text-retro-muted"},XB={key:0,class:"space-y-2"},IB={class:"flex items-start justify-between gap-2"},VB={class:"min-w-0"},zB={class:"text-sm font-mono text-retro-text truncate"},NB={class:"text-xs text-retro-muted mt-1 truncate"},WB={class:"text-xs text-retro-muted/70 mt-1"},qB={class:"text-xs text-retro-muted/70"},jB={class:"flex items-center gap-1 flex-shrink-0"},YB=["onClick"],FB=["onClick"],UB={key:1,class:"text-center py-6 text-retro-muted"},GB={class:"font-mono text-xs"},HB={key:1,class:"text-center py-8 text-retro-muted"},qm=Ve({__name:"ConversationsPanel",setup(r){const e=vr(),t=vo(),n=P(""),s=P(""),i=P(!1),o=P(!1),a=P(!1),l=P(!1),c=P(null);let u=null;ze(n,N=>{u&&clearTimeout(u),u=setTimeout(()=>{s.value=N},180)},{immediate:!0}),wt(()=>{u&&(clearTimeout(u),u=null)});const h=new Map,f=new Map;ze(()=>e.sortedConversations.map(N=>N.id),N=>{const I=new Set(N);for(const z of h.keys())I.has(z)||h.delete(z)},{immediate:!0}),ze(()=>e.sortedArchivedConversations.map(N=>N.id),N=>{const I=new Set(N);for(const z of f.keys())I.has(z)||f.delete(z)},{immediate:!0});function p(N){const I=N.messages[N.messages.length-1];return[N.updatedAt,N.title,N.messages.length,I?.id||"",I?.content?.length||0].join("|")}function g(N){const I=N.messages[N.messages.length-1];return[N.updatedAt,N.archivedAt,N.title,N.messages.length,I?.id||"",I?.content?.length||0].join("|")}function O(N){const I=p(N),z=h.get(N.id);if(z&&z.signature===I)return z.text;const be=[N.title,...N.messages.map(K=>K.content||"")].join(`
65
+ `,E),r.clearPendingPermission(E)}function z(T,M,E){As.enable(M,T,E)}function be(T){As.disable(T)}async function K(T,M,E){r.activeConversationId!==T&&r.selectConversation(T);const B=r.conversations.find(ue=>ue.id===T);let xe;if(E.startsWith("skill:")){const ue=E.replace("skill:","");try{xe=(await $fetch(`/api/skills/${ue}/prompt`,{method:"POST",body:{featureId:M,cwd:B?.worktreePath}})).prompt}catch(ne){console.error(`[useChatStream] Failed to render skill prompt for ${ue}:`,ne);return}}else xe=`/speckit.${E} ${M}`;r.addUserMessage(xe,T),r.saveConversation(T,!0);const Re=r.addAssistantMessage(T);r.startSession(zm(),T),r.startConversationStreaming(T);const Me=Ta(B);await N(xe,Re.id,T,Me)}async function H(T,M,E=0){if(!(typeof window>"u"))try{const B=await h(T),xe=mt.get(T);xe&&(xe.currentMessageId=M,xe.activeTools.clear(),xe.currentTextBlockId=null,xe.currentThinkingBlockId=null,i(xe)),r.startConversationStreaming(T);const Re={type:"subscribe",conversationId:T,cursor:E};r.pushDebugEvent({direction:"out",channel:"ws",eventType:"subscribe",payload:Re},T),B.send(JSON.stringify(Re))}catch(B){console.error(`[useChatStream] Failed to subscribe to ${T}:`,B),r.setSessionError(B.message||"Subscribe failed",T)}}function re(T){const M=T??r.activeConversationId;if(!M)return;const E=mt.get(M);if(E){if(E.ws.readyState===WebSocket.OPEN){const B={type:"abort",conversationId:M};r.pushDebugEvent({direction:"out",channel:"ws",eventType:"abort",payload:B},M),E.ws.send(JSON.stringify(B)),E.ws.close()}E.currentMessageId&&(c(E.currentMessageId,M,"error"),r.updateMessage(E.currentMessageId,{status:"stopped"},M),r.endSession(M),r.saveConversation(M,!0)),mt.delete(M)}r.endConversationStreaming(M),r.clearPendingPermission(M),be(M)}function Oe(T){const M=mt.get(T);M&&(s(M),M.ws.close(),mt.delete(T)),As.disable(T)}function ge(){for(const[T,M]of mt)s(M),M.ws.close(),mt.delete(T);As.disable()}async function $e(T){const M=T??r.activeConversationId;if(!M)return;r.clearPendingPlanApproval(M),r.setPermissionMode("auto");const E="Approved. Proceed with the implementation.";r.addUserMessage(E,M),r.saveConversation(M,!0);const B=r.addAssistantMessage(M);r.startSession(zm(),M),r.startConversationStreaming(M);const xe=r.conversations.find(Me=>Me.id===M),Re=Ta(xe,!0);await N(E,B.id,M,Re)}function Pe(T){const M=T??r.activeConversationId;M&&r.clearPendingPlanApproval(M)}async function Fe(T){if(typeof window>"u")return!1;try{const M=await $fetch("/api/jobs",{params:{conversationId:T}}),B=M.find(Me=>Me.status==="running"||Me.status==="waiting_permission"||Me.status==="queued")||[...M].sort((Me,ue)=>ue.eventCount-Me.eventCount).find(Me=>Me.eventCount>0),xe=r.conversations.find(Me=>Me.id===T);if(!xe)return!1;const Re=[...xe.messages].reverse().find(Me=>Me.role==="assistant");return B?!Re||Re.status!=="streaming"?!1:(console.log("[useChatStream] Resuming streaming for",T,"job:",B.id,"status:",B.status,"events:",B.eventCount),r.resetMessageForReplay(Re.id,T),r.startSession(`resume-${Date.now()}`,T),await H(T,Re.id,0),!0):(Re&&Re.status==="streaming"&&(r.updateMessage(Re.id,{status:"error"},T),r.setSessionError("Streaming was interrupted (server job no longer active)",T)),!1)}catch(M){return console.error("[useChatStream] Failed to resume streaming:",M),!1}}return wt(()=>{fa--,fa<=0&&(fa=0,ge())}),{sendMessage:N,sendPermissionResponse:I,subscribe:H,tryResumeStreaming:Fe,approvePlan:$e,rejectPlan:Pe,abort:re,disconnect:ge,disconnectConversation:Oe,enableCascade:z,disableCascade:be,resetContext:u}}const rB=/^[0-9a-f]{7,40}$/i;function Bo(r){if(typeof r!="string")return!1;const e=r.trim();return e.length>0&&e!=="HEAD"&&!e.startsWith("sc/")&&!rB.test(e)}function Xh(r,e){const t=e.map(s=>s.trim()).filter(Boolean),n=r?.trim()||"";return n&&t.includes(n)&&Bo(n)?n:t.includes("main")?"main":t.includes("master")?"master":t[0]||null}function _1(r){return Bo(r)?r.trim():"Loading branches..."}function Ih(r){const e=[r.name,r.ref];for(const t of e){if(typeof t!="string")continue;const n=t.trim();if(!n)continue;const s=n.startsWith("refs/heads/")?n.slice(11):n;if(Bo(s))return s}return null}const nB={class:"w-full max-w-md mx-4 bg-retro-dark border border-retro-border rounded-lg shadow-xl"},sB={class:"px-4 py-3 border-b border-retro-border flex items-center justify-between"},iB=["disabled"],oB={class:"px-4 py-4 space-y-3"},aB={class:"relative"},lB=["disabled"],cB={key:0,value:""},uB=["value"],hB={key:0,class:"text-xs font-mono text-retro-red"},dB={key:1,class:"text-xs font-mono text-retro-muted"},fB={class:"px-4 py-3 border-t border-retro-border flex items-center gap-2 justify-end"},mB=["disabled"],pB=["disabled"],Tu=Ve({__name:"NewConversationModal",props:{show:{type:Boolean},creating:{type:Boolean}},emits:["close","create"],setup(r,{emit:e}){const t=r,n=e,s=P([]),i=P(""),o=P(!1),a=P(""),l=J(()=>!o.value&&!t.creating&&i.value.length>0&&s.value.length>0);async function c(){o.value=!0,a.value="";try{const{cwd:h}=await $fetch("/api/cwd"),p=(await $fetch("/api/git/branches",{query:{excludeSc:!0,workingDirectory:h}})).branches.filter(O=>!O.isRemote).map(Ih).filter(O=>!!O),g=Array.from(new Set(p)).sort((O,b)=>{const x=w=>w==="main"?0:w==="master"?1:2,k=x(O)-x(b);return k!==0?k:O.localeCompare(b,void 0,{sensitivity:"base"})});if(s.value=g,!g.length){i.value="",a.value="No local branches available for chat creation.";return}i.value=Xh("main",g)||g[0]}catch(h){s.value=[],i.value="",a.value=h instanceof Error?h.message:"Failed to load branches"}finally{o.value=!1}}ze(()=>t.show,h=>{h&&c()});function u(){l.value&&n("create",i.value)}return(h,f)=>(v(),pe(Pr,{to:"body"},[ee(On,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ut(()=>[r.show?(v(),y("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:f[3]||(f[3]=kr(p=>n("close"),["self"]))},[d("div",nB,[d("div",sB,[f[4]||(f[4]=d("h3",{class:"text-sm font-mono text-retro-text font-semibold"},"New Conversation",-1)),d("button",{type:"button",class:"p-1 text-retro-muted hover:text-retro-text transition-colors",disabled:r.creating,onClick:f[0]||(f[0]=p=>n("close"))},[ee(m(St),{class:"w-4 h-4"})],8,iB)]),d("div",oB,[f[5]||(f[5]=d("label",{class:"block text-xs font-mono text-retro-muted"},"Base Branch",-1)),d("div",aB,[je(d("select",{"onUpdate:modelValue":f[1]||(f[1]=p=>i.value=p),disabled:o.value||r.creating||s.value.length===0,class:"w-full appearance-none bg-retro-black border border-retro-border rounded px-2 py-1.5 pr-7 text-xs font-mono text-retro-cyan focus:outline-none focus:border-retro-cyan disabled:opacity-40"},[o.value?(v(),y("option",cB,"Loading branches...")):F("",!0),(v(!0),y(we,null,Ne(s.value,p=>(v(),y("option",{key:p,value:p},A(p),9,uB))),128))],8,lB),[[ks,i.value]]),ee(m(Ru),{class:"absolute right-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-retro-muted pointer-events-none"})]),a.value?(v(),y("p",hB,A(a.value),1)):(v(),y("p",dB," The conversation worktree will be created from the selected branch. "))]),d("div",fB,[d("button",{type:"button",class:"px-3 py-1.5 text-xs font-mono rounded border border-retro-border text-retro-muted hover:text-retro-text hover:border-retro-text/30 transition-colors disabled:opacity-40",disabled:r.creating,onClick:f[2]||(f[2]=p=>n("close"))}," Cancel ",8,mB),d("button",{type:"button",disabled:!l.value,class:"px-3 py-1.5 text-xs font-mono rounded border bg-retro-cyan/10 border-retro-cyan/50 text-retro-cyan hover:bg-retro-cyan/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",onClick:u},A(r.creating?"Creating...":"Create"),9,pB)])])])):F("",!0)]),_:1})]))}}),gB={class:"h-full flex flex-col bg-retro-black"},OB={class:"flex-shrink-0 flex items-center justify-between px-4 py-2 border-b border-retro-border"},vB={class:"flex items-center gap-1"},bB={class:"flex-shrink-0 px-3 pt-3"},xB={class:"relative"},yB={class:"flex-1 overflow-y-auto p-3"},kB={class:"space-y-2"},wB={key:0,class:"flex items-center justify-center py-12"},SB={key:1,class:"flex flex-col items-center justify-center py-12 text-center"},$B={key:2,class:"flex flex-col items-center justify-center py-12 text-center"},Wm=Ve({__name:"FeaturesPanel",setup(r){const e=vr(),t=ml(),{sendMessage:n,enableCascade:s}=Ml(),i=vo(),o=P("features"),a=P(null),l=P(null),c=P([]),u=P([]),h=P(!1),f=P({}),p=P(!1),g=P(null),O=P(!1),b=P(!1),x=P(!1),k=P(null),w=P(""),S=P("");let Q=null;ze(w,ue=>{Q&&clearTimeout(Q),Q=setTimeout(()=>{S.value=ue},300)});const L=J(()=>{const ue=S.value.trim().toLowerCase();return ue?c.value.filter(ne=>ne.name.toLowerCase().includes(ue)||ne.id.toLowerCase().includes(ue)):c.value}),D=P({}),G=J(()=>{const ue=e.activeConversation;if(!ue)return null;if(ue.featureId)return ue.featureId;const ne=ue.worktreeBranch?.trim();return ne&&c.value.some(Ce=>Ce.id===ne)?ne:null}),oe=J(()=>G.value||a.value);ze(()=>e.activeConversationId,()=>{a.value=null;const ue=G.value;t.setSelectedFeatureId(ue),ue&&It(()=>{const ne=D.value[ue];ne&&ne.scrollIntoView({behavior:"auto",block:"nearest"})})}),ze(a,ue=>{ue&&It(()=>{const ne=D.value[ue];ne&&ne.scrollIntoView({behavior:"auto",block:"nearest"})})});async function ie(){h.value=!0;try{const ue=await $fetch("/api/specs/features");c.value=ue.features,j(ue.features)}catch{i.error("Failed to load features"),c.value=[],f.value={}}finally{h.value=!1}}async function j(ue){if(ue.length===0){f.value={};return}const ne=await Promise.allSettled(ue.map(async q=>{const ve=await $fetch(`/api/specs/traceability/${q.id}`),Ze=ve.alerts.filter(Nt=>Nt.severity==="critical").length,it=ve.alerts.filter(Nt=>Nt.severity==="major").length;return{featureId:q.id,critical:Ze,major:it}})),Ce={};for(const q of ne)q.status==="fulfilled"&&(Ce[q.value.featureId]={critical:q.value.critical,major:q.value.major});f.value=Ce}async function V(){try{const ue=await $fetch("/api/skills");u.value=ue.skills}catch{u.value=[]}}gt(()=>{ie(),V(),window.addEventListener("keydown",W)}),wt(()=>{window.removeEventListener("keydown",W)});function Z(ue,ne={}){if(a.value=ue,l.value=null,o.value="files",t.setSelectedFeatureId(ue),ne.openViewer!==!1){const Ce=c.value.find(q=>q.id===ue);Ce&&(g.value=Ce,p.value=!0)}}function U(){p.value=!1,g.value=null}function W(ue){(ue.ctrlKey||ue.metaKey)&&ue.key.toLowerCase()==="k"&&(ue.preventDefault(),O.value||(O.value=!0))}function N(){O.value=!1}function I(ue){Z(ue,{openViewer:!1}),O.value=!1}function z(){O.value=!0}const be=J(()=>c.value.map(ue=>ue.id));function K(ue){return f.value[ue]??{critical:0,major:0}}const H={plan:["tasks","implement"],tasks:["implement"],implement:[],clarify:[],analyze:[]},re={analyze:["skill:better-spec"]};async function Oe(ue,ne,Ce){if(ue.startsWith("skill:")){const q=ue.replace("skill:",""),ve=Ce?e.conversations.find(it=>it.id===Ce):null;return(await $fetch(`/api/skills/${q}/prompt`,{method:"POST",body:{featureId:ne,cwd:ve?.worktreePath}})).prompt}return`/speckit.${ue} ${ne}`}function ge(ue,ne){if(ne)return null;const Ce=e.findConversationByFeature(ue);return Ce&&!e.isConversationStreaming(Ce.id)&&!Ce.finalized?(e.selectConversation(Ce.id),Ce.id):null}function $e(ue){const ne=e.findConversationByFeature(ue);return ne&&ne.finalized?(i.error(`This feature has a finalized conversation "${ne.title}". Please archive it first to start a new conversation.`),e.selectConversation(ne.id),!0):!1}async function Pe(ue,ne,Ce){const q=await e.createConversation({featureId:ue,baseBranch:Ce});if(!q)throw new Error("Failed to create conversation");return e.renameConversation(q,ne),e.selectConversation(q),q}async function Fe(ue,ne){e.addUserMessage(ne,ue),e.saveConversation(ue,!0);const Ce=e.conversations.find(Ze=>Ze.id===ue),q=e.addAssistantMessage(ue);e.startSession(`session-${Date.now()}`,ue),e.startConversationStreaming(ue);const ve={};Ce?.worktreePath&&(ve.cwd=Ce.worktreePath,ve.worktreeBranch=Ce.worktreeBranch),Ce?.featureId&&(ve.featureId=Ce.featureId),await n(ne,q.id,ue,Object.keys(ve).length>0?ve:void 0)}async function T(ue,ne,Ce){const q=re[ne];let ve;if(q&&q.length>0){const Ze=[...q.slice(1),ne,...H[ne]||[]];s(ue,Ce,Ze);const it=q[0];try{ve=await Oe(it,ue,Ce)}catch(Nt){i.error(Nt instanceof Error?Nt.message:"Failed to resolve prerequisite step");return}}else{const Ze=H[ne]||[];Ze.length>0&&s(ue,Ce,Ze),ve=`/speckit.${ne} ${ue}`}await Fe(Ce,ve)}async function M(ue,ne,Ce){const q=ue.shiftKey;if(!q&&$e(ne))return;const ve=ge(ne,q);if(ve){try{await T(ne,Ce,ve)}catch(Ze){i.error(Ze instanceof Error?Ze.message:"Failed to run cascade action")}return}k.value={type:"cascade",featureId:ne,command:Ce,title:`${Ce}: ${ne}`},b.value=!0}async function E(ue,ne){$e(ne)||(k.value={type:"open-chat",featureId:ne,title:`spec: ${ne}`},b.value=!0)}async function B(ue,ne,Ce){let q;try{const ve=e.conversations.find(Ze=>Ze.id===Ce);q=await $fetch(`/api/skills/${ne}/prompt`,{method:"POST",body:{featureId:ue,cwd:ve?.worktreePath}})}catch(ve){throw new Error(ve instanceof Error?ve.message:"Failed to render skill prompt")}await Fe(Ce,q.prompt)}async function xe(ue,ne,Ce){const q=ue.shiftKey;if(!q&&$e(ne))return;const ve=ge(ne,q);if(ve){try{await B(ne,Ce,ve)}catch(Ze){i.error(Ze instanceof Error?Ze.message:"Failed to run skill")}return}k.value={type:"skill",featureId:ne,skillId:Ce,title:`skill: ${Ce} — ${ne}`},b.value=!0}function Re(){b.value=!1,k.value=null}async function Me(ue){if(k.value){x.value=!0;try{const ne=k.value,Ce=await Pe(ne.featureId,ne.title,ue);ne.type==="cascade"?await T(ne.featureId,ne.command,Ce):ne.type==="skill"&&await B(ne.featureId,ne.skillId,Ce),b.value=!1,k.value=null}catch(ne){i.error(ne instanceof Error?ne.message:"Failed to create conversation")}finally{x.value=!1}}}return(ue,ne)=>{const Ce=B2,q=OR,ve=NR;return v(),y("div",gB,[d("div",OB,[ne[2]||(ne[2]=d("div",{class:"flex items-center gap-2 min-w-0"},null,-1)),d("div",vB,[d("button",{type:"button",class:"p-1.5 rounded text-retro-muted hover:text-retro-cyan hover:bg-retro-panel transition-colors",title:"Search (Ctrl/Cmd+K)",onClick:z},[ee(m(fs),{class:"h-4 w-4"})]),d("button",{type:"button",class:"p-1.5 rounded text-retro-muted hover:text-retro-cyan hover:bg-retro-panel transition-colors",title:"Refresh",onClick:ie},[ee(m(gs),{class:_e(["h-4 w-4",{"animate-spin":m(h)}])},null,8,["class"])])])]),d("div",bB,[d("div",xB,[ee(m(fs),{class:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-retro-subtle"}),je(d("input",{"onUpdate:modelValue":ne[0]||(ne[0]=Ze=>Je(w)?w.value=Ze:null),type:"text",placeholder:"Search features...",class:"w-full pl-8 pr-3 py-1.5 text-xs font-mono rounded border border-retro-border bg-retro-panel text-retro-text placeholder:text-retro-subtle focus:outline-none focus:border-retro-cyan transition-colors"},null,512),[[Rt,m(w)]])])]),d("div",yB,[d("div",kB,[(v(!0),y(we,null,Ne(m(L),Ze=>(v(),y("div",{key:Ze.id,ref_for:!0,ref:it=>{m(D)[Ze.id]=it}},[ee(Ce,{feature:Ze,skills:m(u),"is-active":m(oe)===Ze.id,"critical-alerts":K(Ze.id).critical,"major-alerts":K(Ze.id).major,onSelect:ne[1]||(ne[1]=it=>Z(it,{openViewer:!0})),onCascade:M,onOpenChat:E,onSkill:xe},null,8,["feature","skills","is-active","critical-alerts","major-alerts"])]))),128))]),m(h)&&m(c).length===0?(v(),y("div",wB,[...ne[3]||(ne[3]=[d("span",{class:"text-sm font-mono text-retro-muted animate-pulse"},"Loading features...",-1)])])):F("",!0),!m(h)&&m(c).length>0&&m(L).length===0?(v(),y("div",SB,[ee(m(fs),{class:"h-10 w-10 text-retro-subtle mb-3"}),ne[4]||(ne[4]=d("p",{class:"text-sm font-mono text-retro-muted"},"No matching features",-1)),ne[5]||(ne[5]=d("p",{class:"mt-1 text-xs font-mono text-retro-subtle"}," Try a different search term ",-1))])):F("",!0),!m(h)&&m(c).length===0?(v(),y("div",$B,[ee(m(Tv),{class:"h-10 w-10 text-retro-subtle mb-3"}),ne[6]||(ne[6]=d("p",{class:"text-sm font-mono text-retro-muted"},"No features found",-1)),ne[7]||(ne[7]=d("p",{class:"mt-1 text-xs font-mono text-retro-subtle"}," Create a feature in specs/ to get started ",-1))])):F("",!0)]),m(p)&&m(g)?(v(),pe(q,{key:0,feature:m(g),onClose:U},null,8,["feature"])):F("",!0),m(O)?(v(),pe(ve,{key:1,"available-feature-ids":m(be),onClose:N,onSelect:I},null,8,["available-feature-ids"])):F("",!0),ee(Tu,{show:m(b),creating:m(x),onClose:Re,onCreate:Me},null,8,["show","creating"])])}}}),CB={class:"h-full flex flex-col bg-retro-black"},QB={class:"flex-shrink-0 px-3 py-2 border-b border-retro-border space-y-2"},PB={class:"flex items-center justify-between gap-2"},TB={class:"flex items-center gap-1"},MB={class:"relative"},AB=["placeholder"],_B={key:0,class:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-retro-yellow/10 border-b border-retro-yellow/30 text-xs"},RB={class:"text-retro-yellow font-mono"},BB={class:"flex-1 overflow-y-auto p-2"},ZB={key:0,class:"space-y-1"},EB={key:1,class:"text-center py-6 text-retro-muted"},DB={class:"font-mono text-xs"},LB={key:1,class:"text-center py-8 text-retro-muted"},XB={key:0,class:"space-y-2"},IB={class:"flex items-start justify-between gap-2"},VB={class:"min-w-0"},zB={class:"text-sm font-mono text-retro-text truncate"},NB={class:"text-xs text-retro-muted mt-1 truncate"},WB={class:"text-xs text-retro-muted/70 mt-1"},qB={class:"text-xs text-retro-muted/70"},jB={class:"flex items-center gap-1 flex-shrink-0"},YB=["onClick"],FB=["onClick"],UB={key:1,class:"text-center py-6 text-retro-muted"},GB={class:"font-mono text-xs"},HB={key:1,class:"text-center py-8 text-retro-muted"},qm=Ve({__name:"ConversationsPanel",setup(r){const e=vr(),t=vo(),n=P(""),s=P(""),i=P(!1),o=P(!1),a=P(!1),l=P(!1),c=P(null);let u=null;ze(n,N=>{u&&clearTimeout(u),u=setTimeout(()=>{s.value=N},180)},{immediate:!0}),wt(()=>{u&&(clearTimeout(u),u=null)});const h=new Map,f=new Map;ze(()=>e.sortedConversations.map(N=>N.id),N=>{const I=new Set(N);for(const z of h.keys())I.has(z)||h.delete(z)},{immediate:!0}),ze(()=>e.sortedArchivedConversations.map(N=>N.id),N=>{const I=new Set(N);for(const z of f.keys())I.has(z)||f.delete(z)},{immediate:!0});function p(N){const I=N.messages[N.messages.length-1];return[N.updatedAt,N.title,N.messages.length,I?.id||"",I?.content?.length||0].join("|")}function g(N){const I=N.messages[N.messages.length-1];return[N.updatedAt,N.archivedAt,N.title,N.messages.length,I?.id||"",I?.content?.length||0].join("|")}function O(N){const I=p(N),z=h.get(N.id);if(z&&z.signature===I)return z.text;const be=[N.title,...N.messages.map(K=>K.content||"")].join(`
66
66
  `).toLowerCase();return h.set(N.id,{signature:I,text:be}),be}function b(N){const I=g(N),z=f.get(N.id);if(z&&z.signature===I)return z.text;const be=[N.title,...N.messages.map(K=>K.content||"")].join(`
67
67
  `).toLowerCase();return f.set(N.id,{signature:I,text:be}),be}const x=J(()=>e.conversationViewMode==="archive"),k=J(()=>{const N=e.sortedConversations;if(!s.value.trim())return N;const I=s.value.toLowerCase().trim();return N.filter(z=>O(z).includes(I))}),w=J(()=>{const N=e.sortedArchivedConversations;if(!s.value.trim())return N;const I=s.value.toLowerCase().trim();return N.filter(z=>b(z).includes(I))}),S=J(()=>e.previewingConversationId);async function Q(){if(e.checkStorageLimits().atLimit){t.error("Delete or archive a conversation first (limit: 100).");return}i.value=!0}async function L(N){o.value=!0;try{if(!await e.createConversation({baseBranch:N})){t.error("Failed to create conversation");return}i.value=!1}catch(I){t.error(I instanceof Error?I.message:"Failed to create conversation")}finally{o.value=!1}}function D(N){e.selectConversation(N),e.setConversationViewMode("active")}async function G(N){const I=await e.archiveConversation(N);if(!I.success){t.error(I.error||"Failed to archive conversation");return}t.success("Conversation archived")}async function oe(N){c.value=N,a.value=!0}function ie(){a.value=!1,c.value=null}async function j(N){if(c.value){l.value=!0;try{const I=await e.restoreArchivedConversation(c.value,N);if(!I.success){t.error(I.error||"Failed to restore archived conversation");return}t.success("Archived conversation restored"),a.value=!1,c.value=null}finally{l.value=!1}}}async function V(N){const I=await e.deleteArchivedConversation(N);if(!I.success){t.error(I.error||"Failed to delete archived conversation");return}t.success("Archived conversation deleted")}function Z(N,I){e.renameConversation(N,I)}function U(N){return new Date(N).toLocaleString()}function W(N){if(!N.length)return"No messages";const z=(N[N.length-1].content||"").trim();return z?z.length>80?`${z.slice(0,80)}...`:z:"No messages"}return(N,I)=>(v(),y("div",CB,[d("div",QB,[d("div",PB,[d("button",{onClick:Q,class:"p-1.5 rounded text-retro-muted hover:text-retro-cyan hover:bg-retro-panel transition-colors",title:"New conversation","aria-label":"New conversation"},[ee(m(dl),{class:"w-4 h-4"})]),d("div",TB,[d("button",{onClick:I[0]||(I[0]=z=>m(e).setConversationViewMode("active")),class:_e(["p-1.5 rounded transition-colors",x.value?"text-retro-muted hover:text-retro-cyan hover:bg-retro-panel":"text-retro-cyan bg-retro-cyan/10"]),title:"Active conversations","aria-label":"Active conversations"},[ee(m(cp),{class:"w-4 h-4"})],2),d("button",{onClick:I[1]||(I[1]=z=>m(e).setConversationViewMode("archive")),class:_e(["p-1.5 rounded transition-colors",x.value?"text-retro-cyan bg-retro-cyan/10":"text-retro-muted hover:text-retro-cyan hover:bg-retro-panel"]),title:"Archived conversations","aria-label":"Archived conversations"},[ee(m(qh),{class:"w-4 h-4"})],2)])]),d("div",MB,[ee(m(fs),{class:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-retro-muted"}),je(d("input",{"onUpdate:modelValue":I[2]||(I[2]=z=>n.value=z),type:"text",placeholder:x.value?"Search archive...":"Search conversations...",class:"w-full pl-8 pr-3 py-1.5 text-xs font-mono bg-retro-black border border-retro-border rounded focus:border-retro-cyan focus:outline-none focus:ring-1 focus:ring-retro-cyan text-retro-text placeholder-retro-muted"},null,8,AB),[[Rt,n.value]])])]),m(e).isNearStorageLimit?(v(),y("div",_B,[ee(m(En),{class:"w-4 h-4 text-retro-yellow flex-shrink-0"}),d("p",RB,A(m(e).conversationCount)+" active conversations. Limit is 100. ",1)])):F("",!0),d("div",BB,[x.value?(v(),y(we,{key:1},[m(e).hasArchivedConversations?(v(),y("div",XB,[w.value.length>0?(v(!0),y(we,{key:0},Ne(w.value,(z,be,K,H)=>{const re=[z.id,z.title,z.updatedAt,z.archivedAt,z.messages.length];if(H&&H.key===z.id&&zh(H,re))return H;const Oe=(v(),y("div",{key:z.id,onClick:ge=>oe(z.id),onKeydown:[hs(kr(ge=>oe(z.id),["prevent"]),["enter"]),hs(kr(ge=>oe(z.id),["prevent"]),["space"])],class:"w-full text-left p-3 rounded border border-retro-border hover:border-retro-cyan/50 hover:bg-retro-cyan/5 transition-colors",role:"button",tabindex:"0"},[d("div",IB,[d("div",VB,[d("h3",zB,A(z.title),1),d("p",NB,A(W(z.messages)),1),d("p",WB," Archived: "+A(U(z.archivedAt)),1),d("p",qB," Updated: "+A(U(z.updatedAt)),1)]),d("div",jB,[d("button",{onClick:kr(ge=>oe(z.id),["stop"]),class:"inline-flex items-center gap-1 px-2 py-1 text-xs font-mono border border-retro-cyan/40 text-retro-cyan rounded hover:bg-retro-cyan/10 transition-colors",title:"Restore archived conversation"},[ee(m(qh),{class:"w-3.5 h-3.5"}),I[9]||(I[9]=Ie(" Restore ",-1))],8,YB),d("button",{onClick:kr(ge=>V(z.id),["stop"]),class:"inline-flex items-center gap-1 px-2 py-1 text-xs font-mono border border-red-400/40 text-red-300 rounded hover:bg-red-500/10 transition-colors",title:"Delete archived conversation"},[ee(m(vn),{class:"w-3.5 h-3.5"}),I[10]||(I[10]=Ie(" Delete ",-1))],8,FB)])])],40,["onClick","onKeydown"]));return Oe.memo=re,Oe},I,5),128)):(v(),y("div",UB,[d("p",GB,'No archived results for "'+A(n.value)+'"',1)]))])):(v(),y("div",HB,[...I[11]||(I[11]=[d("p",{class:"font-mono text-sm"},"No archived conversations",-1),d("p",{class:"text-xs mt-1"},"Archived conversations will appear here",-1)])]))],64)):(v(),y(we,{key:0},[m(e).hasConversations?(v(),y("div",ZB,[k.value.length>0?(v(!0),y(we,{key:0},Ne(k.value,(z,be,K,H)=>{const re=[z.id,z.title,z.updatedAt,z.messages.length,z.finalized,z.id===m(e).activeConversationId,m(e).isConversationStreaming(z.id),S.value===z.id];if(H&&H.key===z.id&&zh(H,re))return H;const Oe=(v(),y("div",{key:z.id},[ee(rv,{conversation:z,"is-active":z.id===m(e).activeConversationId,"is-streaming":m(e).isConversationStreaming(z.id),"is-previewing":S.value===z.id,onSelect:ge=>D(z.id),onArchive:ge=>G(z.id),onRename:ge=>Z(z.id,ge)},null,8,["conversation","is-active","is-streaming","is-previewing","onSelect","onArchive","onRename"])]));return Oe.memo=re,Oe},I,3),128)):(v(),y("div",EB,[d("p",DB,'No results for "'+A(n.value)+'"',1)]))])):(v(),y("div",LB,[...I[8]||(I[8]=[d("p",{class:"font-mono text-sm"},"No conversations",-1),d("p",{class:"text-xs mt-1"},'Click "New" to start',-1)])]))],64))]),ee(Tu,{show:i.value,creating:o.value,onClose:I[7]||(I[7]=z=>i.value=!1),onCreate:L},null,8,["show","creating"]),ee(Tu,{show:a.value,creating:l.value,onClose:ie,onCreate:j},null,8,["show","creating"])]))}}),KB={mobile:768,tablet:1024};function JB(r,e){return r<e.mobile?"mobile":r<e.tablet?"tablet":"desktop"}const R1=Mu("layout",{state:()=>({currentViewport:"desktop",chatFullscreen:!1}),getters:{isMobile:r=>r.currentViewport==="mobile",isTablet:r=>r.currentViewport==="tablet",isDesktop:r=>r.currentViewport==="desktop",isChatFullscreen:r=>r.chatFullscreen},actions:{updateViewport(r){this.currentViewport=JB(r,KB)},toggleChatFullscreen(){this.chatFullscreen=!this.chatFullscreen},setChatFullscreen(r){this.chatFullscreen=r}}});function e7(){const r=P(null),e=P(!0);let t=null,n="smooth";const s=50;function i(){const f=r.value;return f?f.scrollHeight-f.scrollTop-f.clientHeight<s:!0}function o(){e.value=i()}function a(f="smooth"){if(n=f,t!==null)return;t=(typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):g=>setTimeout(()=>g(Date.now()),16))(()=>{t=null,It(()=>{const g=r.value;g&&g.scrollTo({top:g.scrollHeight,behavior:n})})})}function l(f="smooth"){a(f),e.value=!0}function c(f="smooth"){e.value&&a(f)}function u(){e.value=!0}function h(){e.value=!1}return{containerRef:r,shouldAutoScroll:Ae(e),onScroll:o,scrollToBottom:a,forceScrollToBottom:l,maybeScrollToBottom:c,enableAutoScroll:u,disableAutoScroll:h}}function t7(r){if(!r)return null;if(r instanceof HTMLElement)return r;if(typeof r=="object"&&"$el"in r){const e=r.$el;return e instanceof HTMLElement?e:null}return null}function r7(r){const{allMessages:e,containerRef:t,estimateItemHeight:n=120,overscan:s=6}=r,i=P(0),o=P(0),a=P(new Map),l=new Map;let c=null;function u(k,w){if(!Number.isFinite(w)||w<=0)return;const S=Math.ceil(w);if(a.value.get(k)===S)return;const Q=new Map(a.value);Q.set(k,S),a.value=Q}function h(k,w){u(k,w.getBoundingClientRect().height)}function f(k,w){const S=l.get(k);S&&c&&c.unobserve(S),S&&delete S.dataset.virtualMessageId,l.delete(k);const Q=t7(w);Q&&(Q.dataset.virtualMessageId=k,l.set(k,Q),h(k,Q),c&&c.observe(Q))}function p(){const k=t.value;k&&(i.value=k.scrollTop)}const g=J(()=>{const k=e.value,w=new Array(k.length);let S=0;for(let Q=0;Q<k.length;Q++)w[Q]=S,S+=a.value.get(k[Q].id)??n;return{offsets:w,totalHeight:S}});function O(k,w){let S=0,Q=k.length-1,L=k.length;for(;S<=Q;){const D=Math.floor((S+Q)/2);k[D]>=w?(L=D,Q=D-1):S=D+1}return L===k.length?Math.max(0,k.length-1):L}const b=J(()=>{const k=e.value;if(k.length===0)return[];const{offsets:w}=g.value,S=i.value,Q=S+Math.max(o.value,1),L=O(w,Math.max(0,S-n));let D=L;for(;D<k.length&&w[D]<Q;)D++;const G=Math.max(0,L-s),oe=Math.min(k.length,D+s),ie=[];for(let j=G;j<oe;j++)ie.push({message:k[j],index:j,top:w[j]});return ie}),x=J(()=>g.value.totalHeight);return gt(()=>{const k=t.value;k&&(o.value=k.clientHeight,i.value=k.scrollTop),c=new ResizeObserver(w=>{for(const S of w){const Q=S.target;if(t.value&&Q===t.value){o.value=S.contentRect.height;continue}const L=Q.dataset.virtualMessageId;L&&u(L,S.contentRect.height)}}),t.value&&c.observe(t.value);for(const[w,S]of l)S.dataset.virtualMessageId=w,c.observe(S),h(w,S)}),wt(()=>{c&&(c.disconnect(),c=null),l.clear()}),{visibleItems:b,totalHeight:x,onVirtualScroll:p,setItemRef:f}}const n7={key:0,class:"flex flex-col items-center justify-center h-full p-8 text-center"},s7={key:1,class:"relative"},i7={class:"sticky bottom-0"},o7={key:0,class:"px-4 py-2 bg-retro-dark/90 border-t border-retro-border/50 backdrop-blur-sm"},a7={key:1,class:"px-4 py-2.5 bg-retro-red/20 border-t border-retro-red/50"},l7={class:"flex items-start gap-2"},c7={class:"flex-1 min-w-0"},u7={class:"flex items-center justify-between gap-2 mb-0.5"},h7={class:"text-xs font-mono text-retro-red/80 break-words whitespace-pre-wrap"},d7={key:2,class:"px-4 py-2 bg-retro-dark/90 border-t border-retro-border/50"},f7=Ve({__name:"ChatMessages",setup(r){const e=vr(),{containerRef:t,onScroll:n,maybeScrollToBottom:s,scrollToBottom:i,forceScrollToBottom:o}=e7(),{visibleItems:a,totalHeight:l,onVirtualScroll:c,setItemRef:u}=r7({allMessages:J(()=>e.messages),containerRef:t});function h(){n(),c()}const f=J(()=>e.isActiveConversationStreaming),p=J(()=>{const k=e.lastMessage;return!k||k.role!=="assistant"?null:k.status}),g=P(!1);function O(k){const w=k.contentBlocks;return!w||w.length===0?"":w.map(S=>{switch(S.type){case"tool_use":return`u:${S.id}:${S.status}:${S.inputSummary}`;case"tool_result":return`r:${S.id}:${S.toolUseId}:${S.isError?1:0}:${S.content.length}`;case"text":return`t:${S.id}:${S.text.length}`;case"thinking":return`k:${S.id}:${S.thinking.length}`;case"result_summary":return`s:${S.id}:${S.numTurns}:${S.durationMs}`;case"session_init":return`i:${S.id}:${S.model}:${S.tools.length}`;default:return""}}).join("|")}const b=P(null);function x(){if(b.value&&(b.value(),b.value=null),!t.value||typeof ResizeObserver>"u")return;const k=new ResizeObserver(()=>{s("instant")});k.observe(t.value),b.value=()=>{k.disconnect()}}return gt(()=>{i("instant"),x()}),wt(()=>{b.value&&b.value()}),ze(()=>e.activeConversationId,()=>{g.value=!1,i("instant")}),ze(t,()=>{x()}),ze(()=>[e.activeConversationId,e.messages.length],([k,w])=>{!k||w===0||g.value||(g.value=!0,o("instant"))},{immediate:!0}),ze(()=>e.messages.length,()=>{s("instant")}),ze(()=>e.lastMessage?.content,()=>{s("instant")}),ze([f,()=>e.lastError],()=>{s("instant")}),ze(l,()=>{s("instant")}),(k,w)=>(v(),y("div",{ref_key:"containerRef",ref:t,class:"flex-1 overflow-y-auto",onScroll:h},[m(e).hasMessages?(v(),y("div",s7,[d("div",{class:"relative",style:tr({height:`${m(l)}px`})},[(v(!0),y(we,null,Ne(m(a),S=>(v(),y("div",{key:S.message.id,class:"absolute left-0 right-0 border-b border-retro-border/30",style:tr({transform:`translateY(${S.top}px)`})},[d("div",{ref_for:!0,ref:Q=>m(u)(S.message.id,Q)},[Gm([S.message.id,S.message.status,S.message.content,S.message.contentBlocks?.length||0,O(S.message),S.message.tools?.length||0],()=>ee(nv,{message:S.message},null,8,["message"]),w,0)],512)],4))),128))],4)])):(v(),y("div",n7,[...w[2]||(w[2]=[d("div",{class:"text-retro-muted text-sm font-mono mb-2"}," No messages yet ",-1),d("div",{class:"text-retro-muted text-xs font-mono"}," Send a message to start chatting ",-1)])])),d("div",i7,[m(f)&&!m(e).lastError?(v(),y("div",o7,[...w[3]||(w[3]=[Km('<div class="flex items-center gap-2"><div class="flex gap-1"><span class="w-1.5 h-1.5 rounded-full bg-retro-cyan animate-bounce" style="animation-delay:0ms;"></span><span class="w-1.5 h-1.5 rounded-full bg-retro-cyan animate-bounce" style="animation-delay:150ms;"></span><span class="w-1.5 h-1.5 rounded-full bg-retro-cyan animate-bounce" style="animation-delay:300ms;"></span></div><span class="text-xs font-mono text-retro-muted">Processing...</span></div>',1)])])):F("",!0),m(e).lastError?(v(),y("div",a7,[d("div",l7,[ee(m(Oo),{class:"w-4 h-4 text-retro-red flex-shrink-0 mt-0.5"}),d("div",c7,[d("div",u7,[w[4]||(w[4]=d("p",{class:"text-xs font-mono font-semibold text-retro-red"},"Error",-1)),d("button",{class:"text-xs font-mono text-retro-red/60 hover:text-retro-red underline",onClick:w[1]||(w[1]=S=>m(e).clearError())}," Dismiss ")]),d("p",h7,A(m(e).lastError),1),w[5]||(w[5]=d("p",{class:"text-xs font-mono text-retro-muted mt-1"}," Check browser console (F12) for more details ",-1))])])])):m(p)==="stopped"?(v(),y("div",d7,[...w[6]||(w[6]=[d("div",{class:"flex items-center gap-2"},[d("span",{class:"w-2 h-2 rounded-full bg-retro-muted"}),d("span",{class:"text-xs font-mono text-retro-muted"},"Stopped")],-1)])])):F("",!0)])],544))}});function m7(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"fill-rule":"evenodd",d:"M4.755 10.059a7.5 7.5 0 0 1 12.548-3.364l1.903 1.903h-3.183a.75.75 0 1 0 0 1.5h4.992a.75.75 0 0 0 .75-.75V4.356a.75.75 0 0 0-1.5 0v3.18l-1.9-1.9A9 9 0 0 0 3.306 9.67a.75.75 0 1 0 1.45.388Zm15.408 3.352a.75.75 0 0 0-.919.53 7.5 7.5 0 0 1-12.548 3.364l-1.902-1.903h3.183a.75.75 0 0 0 0-1.5H2.984a.75.75 0 0 0-.75.75v4.992a.75.75 0 0 0 1.5 0v-3.18l1.9 1.9a9 9 0 0 0 15.059-4.035.75.75 0 0 0-.53-.918Z","clip-rule":"evenodd"})])}function jm(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"fill-rule":"evenodd",d:"M12.53 16.28a.75.75 0 0 1-1.06 0l-7.5-7.5a.75.75 0 0 1 1.06-1.06L12 14.69l6.97-6.97a.75.75 0 1 1 1.06 1.06l-7.5 7.5Z","clip-rule":"evenodd"})])}function p7(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{d:"M3.478 2.404a.75.75 0 0 0-.926.941l2.432 7.905H13.5a.75.75 0 0 1 0 1.5H4.984l-2.432 7.905a.75.75 0 0 0 .926.94 60.519 60.519 0 0 0 18.445-8.986.75.75 0 0 0 0-1.218A60.517 60.517 0 0 0 3.478 2.404Z"})])}function g7(r,e){return v(),y("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon"},[d("path",{"fill-rule":"evenodd",d:"M4.5 7.5a3 3 0 0 1 3-3h9a3 3 0 0 1 3 3v9a3 3 0 0 1-3 3h-9a3 3 0 0 1-3-3v-9Z","clip-rule":"evenodd"})])}const O7=/^\/(reset|reset-context|new|clear)$/,v7=/^\/(context|ctx)$/;function b7(r){if(O7.test(r))return{kind:"reset"};if(v7.test(r))return{kind:"context"};const e=S7(r);return e?{kind:"spec-search",command:e}:{kind:"none"}}function x7(r,e){const t={permissionMode:e};return r?.hasWorktree&&r.worktreePath?t.cwd=r.worktreePath:r?.cwd&&(t.cwd=r.cwd),r?.featureId&&(t.featureId=r.featureId),r?.providerId&&(t.providerId=r.providerId),r?.providerModelKey&&(t.providerModelKey=r.providerModelKey),r?.providerSessionId&&(t.providerSessionId=r.providerSessionId),t}function y7(r,e={}){return{q:r.q,mode:r.mode??"hybrid",featureId:r.featureId??e.featureId,fileType:r.fileType,limit:String(r.limit??5)}}function k7(r){const e=r.instructionFiles.length>0?r.instructionFiles.map(n=>{const s=n.source==="cwd"?"cwd":"ancestor",i=n.mtime?` (mtime: ${n.mtime})`:"";return`- \`${n.path}\` [${s}] - ${n.hint}${i}`}):["- (none detected from current cwd ancestry)"],t=r.specContext.files.length>0?r.specContext.files.map(n=>`- \`${n}\``):["- (none)"];return["## Context Snapshot","",`- Time: ${r.generatedAt}`,`- Session state: **${r.sessionState}**`,`- Provider session ID: \`${r.providerSessionId??"(empty)"}\``,`- Provider: \`${r.providerId}\` / \`${r.providerModelKey}\``,`- Permission mode: \`${r.permissionMode}\``,`- CWD (requested): \`${r.requestedCwd}\``,`- CWD (effective): \`${r.effectiveCwd}\``,`- Feature: \`${r.featureId??"(none)"}\``,"","### Spec Context Injection",`- Active on next turn: **${r.specContext.active?"yes":"no"}**`,`- Reason: ${r.specContext.reason}`,...t,"","### Detected Instruction Files",...e].join(`
68
68
  `)}function w7(r){return(r.match(/"[^"]*"|'[^']*'|\S+/g)??[]).map(t=>t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t)}function S7(r){const e=r.match(/^\/(?:spec-search|specsearch)\b(.*)$/i);if(!e)return null;const t=w7(e[1]?.trim()??""),n=[],s={q:""};for(let i=0;i<t.length;i++){const o=t[i];if(o==="--mode"&&t[i+1]){const a=t[++i];(a==="keyword"||a==="semantic"||a==="hybrid")&&(s.mode=a);continue}if(o.startsWith("--mode=")){const a=o.slice(7);(a==="keyword"||a==="semantic"||a==="hybrid")&&(s.mode=a);continue}if(o==="--feature"&&t[i+1]){s.featureId=t[++i];continue}if(o.startsWith("--feature=")){s.featureId=o.slice(10);continue}if(o==="--file-type"&&t[i+1]){s.fileType=t[++i];continue}if(o.startsWith("--file-type=")){s.fileType=o.slice(12);continue}if(o==="--limit"&&t[i+1]){const a=Number.parseInt(t[++i],10);Number.isFinite(a)&&a>0&&(s.limit=a);continue}if(o.startsWith("--limit=")){const a=Number.parseInt(o.slice(8),10);Number.isFinite(a)&&a>0&&(s.limit=a);continue}n.push(o)}return s.q=n.join(" ").trim(),s}function $7(r,e=1400){const t=r.trim();return t.length<=e?t:`${t.slice(0,e)}
69
69
  ...`}function C7(r,e){const t=[];if(t.push("## Spec Search Results"),t.push(""),t.push(`- Query: \`${r.q}\``),t.push(`- Mode: \`${e.mode}\``),r.featureId&&t.push(`- Feature filter: \`${r.featureId}\``),r.fileType&&t.push(`- File type filter: \`${r.fileType}\``),t.push(`- Hits: **${e.totalCount}** (${e.searchTime}ms)`),e.warning&&t.push(`- Warning: ${e.warning}`),e.results.length===0)return t.push(""),t.push("No matching indexed chunks were found."),t.join(`
70
70
  `);t.push("");for(const[n,s]of e.results.entries()){const i=s.chunk;t.push(`### ${n+1}. \`${i.sourcePath}:${i.lineStart}\``),t.push(`- Match: \`${s.matchType}\` (score: ${s.score.toFixed(3)})`),i.headingHierarchy.length>0&&t.push(`- Headings: ${i.headingHierarchy.join(" > ")}`),t.push(""),t.push($7(i.content)),t.push("")}return t.join(`
71
- `)}function B1(r){return`${r.providerId}::${r.modelKey}`}function Q7(r,e){const t=new Map;for(const s of r)for(const i of s.models)t.set(i.label,(t.get(i.label)??0)+1);return r.flatMap(s=>s.models.map(i=>{const o=s.capabilities.streaming&&(!e||s.capabilities.permissions),a=(t.get(i.label)??0)>1;return{key:`${s.id}::${i.key}`,providerId:s.id,providerName:s.name,modelKey:i.key,modelLabel:i.label,label:a?`${i.label} · ${s.name}`:i.label,compatible:o}})).sort((s,i)=>s.modelLabel.localeCompare(i.modelLabel,void 0,{sensitivity:"base"})||s.providerName.localeCompare(i.providerName,void 0,{sensitivity:"base"}))}function P7(r){const e=new Map;for(const s of r){const i=e.get(s.providerId);if(i){i.options.push(s);continue}e.set(s.providerId,{providerId:s.providerId,providerName:s.providerName,options:[s]})}const t=new Map([["codex",0],["claude",1]]),n=Array.from(e.values());return n.sort((s,i)=>{const o=t.get(s.providerId)??99,a=t.get(i.providerId)??99;return o!==a?o-a:s.providerName.localeCompare(i.providerName,void 0,{sensitivity:"base"})}),n}function T7(r,e){const t=B1(e);return r.find(n=>n.key===t)??null}const Ym=4,M7=5*1024*1024;function A7(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function _7(r,e=M7){return r.type.startsWith("image/")?r.size>e?{ok:!1,reason:"too-large"}:{ok:!0}:{ok:!1,reason:"not-image"}}function R7(r){return new Promise((e,t)=>{const n=new FileReader;n.onload=()=>{typeof n.result=="string"?e(n.result):t(new Error("Failed to read image"))},n.onerror=()=>t(n.error||new Error("Failed to read image")),n.readAsDataURL(r)})}function B7(r=Date.now,e=Math.random){return`att-${r()}-${e().toString(36).slice(2,8)}`}function Z7(r=Date.now,e=Math.random){return`q-${r()}-${e().toString(36).slice(2,8)}`}function E7(r,e=Z7){const t=r.text.trim();return t.length===0&&r.attachments.length===0?null:{id:e(),text:t,attachments:[...r.attachments]}}function D7(r,e){return r.filter(t=>t.id!==e)}const L7={class:"flex-shrink-0 flex-grow-0 border-t border-retro-border bg-retro-dark p-3"},X7={class:"flex flex-wrap items-center gap-2 mb-2"},I7={class:"relative min-w-0 flex-1 max-w-full sm:max-w-[154px] model-selector"},V7=["disabled"],z7={class:"truncate text-left"},N7={key:0,class:"absolute bottom-full left-0 mb-1 py-1 bg-retro-dark border border-retro-border rounded shadow-lg z-10 min-w-[220px] max-w-[280px]"},W7={key:0,class:"px-3 py-1.5 text-xs font-mono text-retro-muted"},q7={class:"px-3 py-1 text-[11px] font-mono uppercase tracking-wide text-retro-cyan/80 select-none"},j7=["disabled","onClick"],Y7={class:"truncate"},F7={class:"relative mode-selector"},U7={key:0,class:"absolute bottom-full left-0 mb-1 py-1 bg-retro-dark border border-retro-border rounded shadow-lg z-10 min-w-[140px]"},G7=["onClick"],H7={class:"hidden text-xs font-mono text-retro-muted sm:inline"},K7={key:0,class:"mb-3 p-3 bg-retro-yellow/10 border border-retro-yellow/50 rounded"},J7={class:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"},e8={class:"flex-1 min-w-0"},t8={class:"text-xs font-mono text-retro-text truncate"},r8={class:"text-retro-cyan"},n8={key:0,class:"text-retro-muted"},s8={key:1,class:"text-retro-muted"},i8={key:1,class:"mb-3 p-3 bg-retro-cyan/10 border border-retro-cyan/50 rounded"},o8={key:2,class:"mb-2 flex flex-wrap gap-2"},a8=["src","alt"],l8={class:"mt-1 truncate text-[10px] font-mono text-retro-muted"},c8={class:"truncate text-[10px] font-mono text-retro-muted/80"},u8=["onClick"],h8={key:3,class:"mb-2"},d8={class:"text-[10px] font-mono text-retro-muted mb-1 uppercase tracking-wide"},f8={class:"space-y-1"},m8={class:"text-[10px] font-mono text-retro-yellow flex-shrink-0"},p8={class:"flex-1 text-xs font-mono text-retro-text truncate"},g8={key:0,class:"text-[10px] font-mono text-retro-muted flex-shrink-0"},O8=["onClick"],v8={class:"flex gap-2 items-start"},b8=["disabled"],x8={class:"flex-1 relative min-h-[40px]"},y8=["disabled","placeholder"],k8=["disabled","title"],w8=Ve({__name:"ChatInput",props:{disabled:{type:Boolean}},setup(r){const e=r,t=vr(),n=bo(),{sendMessage:s,sendPermissionResponse:i,approvePlan:o,rejectPlan:a,abort:l,resetContext:c}=Ml(),u=P(""),h=P(null),f=P(null),p=P(!1),g=P(!1),O=P(!1),b=P([]);let x=null;const k=P(null),w=P({}),S=J(()=>{const he=t.activeConversationId;return he?w.value[he]??[]:[]});function Q(he,ye){if(ye.length===0){const{[he]:Be,...Ye}=w.value;w.value=Ye}else w.value={...w.value,[he]:ye}}const{data:L,pending:D}=$c("chat-input-ai-providers",()=>$fetch("/api/ai/providers"),{server:!1,default:()=>({providers:[]})}),G=J(()=>L.value?.providers??[]),oe=J(()=>t.permissionMode==="ask"||t.permissionMode==="plan"),ie=J(()=>Q7(G.value,oe.value)),j=J(()=>P7(ie.value)),V=J(()=>{const he=t.activeConversation;return he?.providerId&&he.providerModelKey?{providerId:he.providerId,modelKey:he.providerModelKey}:k.value?k.value:n.providerSelection}),Z=J(()=>B1(V.value)),U=J(()=>T7(ie.value,V.value)),W=J(()=>U.value?.label||"Select model");function N(he,ye){t.setConversationProviderSelection(he,ye.providerId,ye.modelKey),t.clearProviderSession(he),t.saveConversation(he,!0)}function I(he){k.value&&(N(he,k.value),k.value=null)}function z(he){if(!he||!he.compatible)return;const ye={providerId:he.providerId,modelKey:he.modelKey},Be=t.activeConversationId;if(Be){N(Be,ye),k.value=null,O.value=!1;return}k.value=ye,O.value=!1}const be={plan:Bu,ask:Zu,auto:lp,bypass:Eu},K={plan:"text-retro-cyan",ask:"text-retro-green",auto:"text-retro-yellow",bypass:"text-retro-red"};function H(he){t.setPermissionMode(he),g.value=!1}function re(he){const ye=he.target;ye.closest(".mode-selector")||(g.value=!1),ye.closest(".model-selector")||(O.value=!1)}gt(()=>{document.addEventListener("click",re),n.hydrate()}),wt(()=>{document.removeEventListener("click",re),x!==null&&typeof window<"u"&&typeof window.cancelAnimationFrame=="function"&&(window.cancelAnimationFrame(x),x=null)});const Oe=J(()=>(u.value.trim().length>0||b.value.length>0)&&!p.value&&!t.pendingPermission&&!Pe.value),ge=J(()=>t.isActiveConversationStreaming&&!t.pendingPermission),$e=J(()=>t.pendingPermission!==null),Pe=J(()=>t.pendingPlanApproval!==null);function Fe(){i(!0,t.activeConversationId)}function T(){i(!1,t.activeConversationId)}function M(){o(t.activeConversationId)}function E(){a(t.activeConversationId)}function B(){b.value=[],f.value&&(f.value.value="")}function xe(he){b.value=b.value.filter(ye=>ye.id!==he)}async function Re(he){const ye=he.target,Be=ye.files?Array.from(ye.files):[];if(Be.length===0)return;const{useToast:Ye}=await ds(async()=>{const{useToast:ot}=await import("./Bq8BNs4s.js").then(Ft=>Ft.n);return{useToast:ot}},__vite__mapDeps([0,1,2]),import.meta.url),Ue=Ye();let Ct=Ym-b.value.length;if(Ct<=0){Ue.warning(`You can attach up to ${Ym} images per message.`),ye.value="";return}for(const ot of Be){if(Ct<=0)break;const Ft=_7(ot);if(!Ft.ok){Ft.reason==="not-image"?Ue.warning(`Skipped "${ot.name}": only image files are supported.`):Ue.warning(`Skipped "${ot.name}": max size is 5 MB.`);continue}try{const ir=await R7(ot);b.value.push({id:B7(),name:ot.name,mimeType:ot.type,size:ot.size,dataUrl:ir}),Ct--}catch{Ue.error(`Failed to attach "${ot.name}".`)}}ye.value=""}const Me=J(()=>{if(t.isActiveConversationStreaming||p.value)return!1;const he=t.lastMessage;return he?.role==="assistant"&&he?.status==="error"});async function ue(he){const ye=t.activeConversationId??await t.createConversation(),Be=t.addAssistantMessage(ye);if(!he.q){t.updateMessage(Be.id,{content:["Usage: `/spec-search <query> [--mode keyword|semantic|hybrid] [--feature <feature-id>] [--file-type <type>] [--limit <n>]`","","Examples:","- `/spec-search FR-001`",'- `/spec-search "indexing indicator" --mode hybrid --feature 008-spec-search --limit 5`'].join(`
72
- `),status:"complete"},ye);return}const Ye=t.activeConversation,Ue=y7(he,{featureId:Ye?.featureId});try{const Ct=await $fetch("/api/specs/search",{query:Ue});t.updateMessage(Be.id,{content:C7({...he,mode:Ue.mode,featureId:Ue.featureId},Ct),status:"complete"},ye)}catch(Ct){const ot=Ct instanceof Error?Ct.message:"Failed to run spec search";t.updateMessage(Be.id,{content:`Spec search failed: ${ot}`,status:"error"},ye)}}async function ne(){const he=x7(t.activeConversation,t.permissionMode),ye=await $fetch("/api/chat/context",{query:he}),Be=t.activeConversationId??await t.createConversation(),Ye=t.addAssistantMessage(Be);t.updateMessage(Ye.id,{content:k7(ye),status:"complete"},Be)}function Ce(he=[]){const ye=Ta(t.activeConversation,!0)??{};return he.length>0?{...ye,attachments:he}:Object.keys(ye).length>0?ye:void 0}function q(he){const ye=t.addAssistantMessage(he);return t.startSession(`session-${Date.now()}`,he),t.startConversationStreaming(he),t.saveConversation(he,!0),ye}function ve(he,ye,Be,Ye){const Ue=Be instanceof Error?Be.message:Ye;t.setSessionError(Ue,he),t.updateMessage(ye,{status:"error"},he),t.endSession(he),t.endConversationStreaming(he)}async function Ze(he,ye){const Be=he!==void 0,Ye=(he??u.value).trim(),Ue=ye??[...b.value];if(Ye.length===0&&Ue.length===0||t.isActiveConversationStreaming||p.value||e.disabled)return;const Ct=!!t.activeConversationId;let ot=null,Ft=null;const ir=b7(Ye);if(ir.kind!=="none"){if(ir.kind==="reset"){await qn();return}ir.kind==="context"?await ne():ir.kind==="spec-search"&&await ue(ir.command),Be||(u.value="",B(),Et());return}p.value=!0,Be||(u.value="",B(),Et());try{if(await t.addUserMessageWithConversation(Ye,Ue),ot=t.activeConversationId,!ot)throw new Error("Failed to create or select a conversation");Ct||I(ot);const yr=q(ot);Ft=yr.id,await s(Ye,yr.id,ot,Ce(Ue))}catch(yr){if(ot&&Ft)ve(ot,Ft,yr,"Failed to send message");else{const Yn=yr instanceof Error?yr.message:"Failed to send message";t.setSessionError(Yn)}}finally{p.value=!1}}async function it(){try{l(t.activeConversationId)}catch{}}function Nt(){t.isActiveConversationStreaming?sr():Ze()}function sr(){const he=t.activeConversationId;if(!he)return;const ye=E7({text:u.value,attachments:b.value});ye&&(Q(he,[...S.value,ye]),u.value="",B(),Et(),Wt())}function on(he){const ye=t.activeConversationId;ye&&Q(ye,D7(S.value,he))}async function xr(){const he=t.activeConversationId;if(!he)return;const ye=w.value[he]??[];if(ye.length===0||t.isActiveConversationStreaming||p.value)return;const[Be,...Ye]=ye;Q(he,Ye),await Ze(Be.text,Be.attachments)}async function qn(){if(t.activeConversationId){u.value="",B(),Et(),p.value=!0;try{await c(t.activeConversationId);const he=t.addAssistantMessage(t.activeConversationId);t.updateMessage(he.id,{content:"✨ **Context cleared** — The AI conversation context has been reset. Starting fresh from here.",status:"complete"},t.activeConversationId);const{useToast:ye}=await ds(async()=>{const{useToast:Ye}=await import("./Bq8BNs4s.js").then(Ue=>Ue.n);return{useToast:Ye}},__vite__mapDeps([0,1,2]),import.meta.url);ye().success("AI context has been reset. The conversation will start fresh.")}catch(he){console.error("Failed to reset context:",he);const{useToast:ye}=await ds(async()=>{const{useToast:Ye}=await import("./Bq8BNs4s.js").then(Ue=>Ue.n);return{useToast:Ye}},__vite__mapDeps([0,1,2]),import.meta.url);ye().error("Failed to reset context. Please try again.")}finally{p.value=!1}}}async function an(){const he=t.messages;let ye=null;for(let Ue=he.length-1;Ue>=0;Ue--)if(he[Ue].role==="user"){ye={content:he[Ue].content,attachments:he[Ue].attachments??[]};break}if(!ye||!t.activeConversationId)return;const Be=t.activeConversationId;t.clearError(),p.value=!0;let Ye=null;try{const Ue=q(Be);Ye=Ue.id,await s(ye.content,Ue.id,Be,Ce(ye.attachments))}catch(Ue){if(Ye)ve(Be,Ye,Ue,"Failed to retry message");else{const Ct=Ue instanceof Error?Ue.message:"Failed to retry message";t.setSessionError(Ct,Be)}}finally{p.value=!1}}function jn(he){he.key==="Enter"&&!he.shiftKey&&(he.preventDefault(),Nt())}function ln(){const he=h.value;if(he){if(!u.value.trim()){he.style.height="";return}he.style.height="auto",he.style.height=Math.min(he.scrollHeight,200)+"px"}}function Sn(){if(x!==null)return;x=(typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):ye=>setTimeout(()=>ye(Date.now()),16))(()=>{x=null,ln()})}function Et(){const he=h.value;he&&(he.style.height="")}function Wt(){It(()=>{h.value?.focus()})}return ze(u,Sn),ze(()=>t.isActiveConversationStreaming,(he,ye)=>{ye&&!he&&(S.value.length>0?It(()=>xr()):Wt())}),ze(()=>t.activeConversationId,()=>{t.activeConversationId&&(k.value=null),B(),Wt(),!t.isActiveConversationStreaming&&S.value.length>0&&It(()=>xr())}),(he,ye)=>(v(),y("div",L7,[d("div",X7,[d("div",I7,[d("button",{disabled:r.disabled||m(t).isActiveConversationStreaming||m($e)||m(Pe)||m(D)||m(ie).length===0,class:"flex items-center justify-between gap-1.5 w-full px-2 py-1 rounded border border-retro-border/50 hover:border-retro-border text-xs font-mono text-retro-muted transition-colors disabled:opacity-60 disabled:cursor-not-allowed",onClick:ye[0]||(ye[0]=Be=>O.value=!m(O))},[d("span",z7,A(m(W)),1),ee(m(jm),{class:"w-3 h-3 flex-shrink-0"})],8,V7),m(O)?(v(),y("div",N7,[m(ie).length===0?(v(),y("div",W7," Loading models... ")):F("",!0),(v(!0),y(we,null,Ne(m(j),Be=>(v(),y("div",{key:Be.providerId,class:"py-0.5"},[d("div",q7,A(Be.providerName),1),(v(!0),y(we,null,Ne(Be.options,Ye=>(v(),y("button",{key:Ye.key,disabled:!Ye.compatible,class:_e(["flex items-center gap-2 w-full px-3 py-1.5 text-xs font-mono text-left hover:bg-retro-panel transition-colors disabled:opacity-50 disabled:cursor-not-allowed",m(Z)===Ye.key?"bg-retro-panel text-retro-text":"text-retro-muted"]),onClick:Ue=>z(Ye)},[d("span",Y7,A(Ye.modelLabel)+A(Ye.compatible?"":" (unsupported for current permission mode)"),1)],10,j7))),128))]))),128))])):F("",!0)]),d("div",F7,[d("button",{class:_e(["flex items-center gap-1.5 px-2 py-1 rounded border border-retro-border/50 hover:border-retro-border text-xs font-mono transition-colors",K[m(t).permissionMode]]),onClick:ye[1]||(ye[1]=Be=>g.value=!m(g))},[(v(),pe(ps(be[m(t).permissionMode]),{class:"w-4 h-4"})),d("span",null,A(m(Zs)[m(t).permissionMode]),1),ee(m(jm),{class:"w-3 h-3"})],2),m(g)?(v(),y("div",U7,[(v(),y(we,null,Ne(["plan","ask","auto","bypass"],Be=>d("button",{key:Be,class:_e(["flex items-center gap-2 w-full px-3 py-1.5 text-xs font-mono text-left hover:bg-retro-panel transition-colors",[K[Be],m(t).permissionMode===Be?"bg-retro-panel":""]]),onClick:Ye=>H(Be)},[(v(),pe(ps(be[Be]),{class:"w-4 h-4"})),d("span",null,A(m(Zs)[Be]),1)],10,G7)),64))])):F("",!0)]),d("span",H7,A(m(t).permissionMode==="plan"?"Plan only":m(t).permissionMode==="ask"?"Ask before actions":m(t).permissionMode==="auto"?"Auto approve":"All permissions"),1)]),m($e)?(v(),y("div",K7,[d("div",J7,[d("div",e8,[ye[4]||(ye[4]=d("div",{class:"text-xs font-mono text-retro-yellow font-bold mb-1"}," Permission Required ",-1)),d("div",t8,[d("span",r8,A(m(t).pendingPermission?.tool),1),m(t).pendingPermission?.filePath?(v(),y("span",n8," - "+A(m(t).pendingPermission.filePath),1)):m(t).pendingPermission?.command?(v(),y("span",s8," - "+A(m(t).pendingPermission.command),1)):F("",!0)])]),d("div",{class:"flex flex-shrink-0 gap-2"},[d("button",{class:"px-3 py-1.5 text-xs font-mono rounded bg-retro-green/20 text-retro-green border border-retro-green/50 hover:bg-retro-green/30 transition-colors",onClick:Fe}," Allow "),d("button",{class:"px-3 py-1.5 text-xs font-mono rounded bg-retro-red/20 text-retro-red border border-retro-red/50 hover:bg-retro-red/30 transition-colors",onClick:T}," Deny ")])])])):F("",!0),m(Pe)?(v(),y("div",i8,[d("div",{class:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"},[ye[5]||(ye[5]=d("div",{class:"flex-1 min-w-0"},[d("div",{class:"text-xs font-mono text-retro-cyan font-bold mb-1"}," Plan Ready for Review "),d("div",{class:"text-xs font-mono text-retro-muted"}," Approve to switch to Auto mode and start implementation. ")],-1)),d("div",{class:"flex flex-shrink-0 gap-2"},[d("button",{class:"px-3 py-1.5 text-xs font-mono rounded bg-retro-green/20 text-retro-green border border-retro-green/50 hover:bg-retro-green/30 transition-colors",onClick:M}," Approve & Implement "),d("button",{class:"px-3 py-1.5 text-xs font-mono rounded bg-retro-red/20 text-retro-red border border-retro-red/50 hover:bg-retro-red/30 transition-colors",onClick:E}," Reject ")])])])):F("",!0),m(b).length>0?(v(),y("div",o8,[(v(!0),y(we,null,Ne(m(b),Be=>(v(),y("div",{key:Be.id,class:"relative w-24 rounded border border-retro-border/70 bg-retro-black/80 p-1"},[d("img",{src:Be.dataUrl,alt:Be.name,class:"h-16 w-full rounded object-cover"},null,8,a8),d("div",l8,A(Be.name),1),d("div",c8,A(m(A7)(Be.size)),1),d("button",{class:"absolute -right-2 -top-2 rounded-full border border-retro-border bg-retro-panel p-0.5 text-retro-red hover:bg-retro-red/20",type:"button",onClick:Ye=>xe(Be.id)},[ee(m(St),{class:"h-3 w-3"})],8,u8)]))),128))])):F("",!0),m(S).length>0?(v(),y("div",h8,[d("div",d8," Queued ("+A(m(S).length)+") ",1),d("div",f8,[(v(!0),y(we,null,Ne(m(S),(Be,Ye)=>(v(),y("div",{key:Be.id,class:"flex items-center gap-2 px-2.5 py-1.5 bg-retro-panel/50 border border-retro-border/30 rounded"},[d("span",m8,"#"+A(Ye+1),1),d("span",p8,A(Be.text),1),Be.attachments.length>0?(v(),y("span",g8," +"+A(Be.attachments.length)+" img ",1)):F("",!0),d("button",{class:"flex-shrink-0 p-0.5 text-retro-muted hover:text-retro-red transition-colors",title:"Cancel queued message",onClick:Ue=>on(Be.id)},[ee(m(St),{class:"w-3.5 h-3.5"})],8,O8)]))),128))])])):F("",!0),d("div",v8,[d("input",{ref_key:"fileInputRef",ref:f,type:"file",accept:"image/*",multiple:"",class:"hidden",onChange:Re},null,544),d("button",{class:"flex-shrink-0 h-10 w-10 inline-flex items-center justify-center p-0 rounded bg-retro-panel/70 text-retro-muted hover:text-retro-cyan hover:bg-retro-panel disabled:opacity-50 disabled:cursor-not-allowed transition-colors",type:"button",title:"Attach images",disabled:r.disabled||m($e)||m(Pe),onClick:ye[2]||(ye[2]=Be=>m(f)?.click())},[ee(m(Zv),{class:"w-5 h-5"})],8,b8),d("div",x8,[je(d("textarea",{ref_key:"inputRef",ref:h,"onUpdate:modelValue":ye[3]||(ye[3]=Be=>Je(u)?u.value=Be:null),disabled:r.disabled||m($e)||m(Pe),placeholder:r.disabled?"This conversation is finalized (read-only)":m(t).isActiveConversationStreaming?"Type to queue a message...":"Type a message...",rows:"1",class:"w-full h-full min-h-[40px] px-3 py-2 bg-retro-black border border-retro-border rounded text-sm font-mono text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan disabled:opacity-50 disabled:cursor-not-allowed resize-none overflow-hidden",onKeydown:jn},null,40,y8),[[Rt,m(u)]])]),m(Me)?(v(),y("button",{key:0,class:"flex-shrink-0 h-10 w-10 inline-flex items-center justify-center p-0 rounded bg-retro-yellow/20 text-retro-yellow hover:bg-retro-yellow/30 transition-colors",title:"Retry last message",onClick:an},[ee(m(m7),{class:"w-5 h-5"})])):F("",!0),m($e)?F("",!0):(v(),y("button",{key:1,disabled:!m(Oe),title:m(t).isActiveConversationStreaming?"Queue message":"Send message",class:_e(["flex-shrink-0 h-10 w-10 inline-flex items-center justify-center p-0 rounded disabled:opacity-50 disabled:cursor-not-allowed transition-colors",m(t).isActiveConversationStreaming?"bg-retro-yellow/20 text-retro-yellow hover:bg-retro-yellow/30":"bg-retro-cyan/20 text-retro-cyan hover:bg-retro-cyan/30"]),onClick:Nt},[m(t).isActiveConversationStreaming?(v(),pe(m(fp),{key:0,class:"w-5 h-5"})):(v(),pe(m(p7),{key:1,class:"w-5 h-5"}))],10,k8)),m(ge)?(v(),y("button",{key:2,class:"flex-shrink-0 h-10 w-10 inline-flex items-center justify-center p-0 rounded bg-retro-red/20 text-retro-red hover:bg-retro-red/30 transition-colors",onClick:it},[ee(m(g7),{class:"w-5 h-5"})])):F("",!0)]),ye[6]||(ye[6]=d("div",{class:"mt-1 hidden text-xs font-mono text-retro-muted sm:block"}," Press Enter to send (or queue while AI is responding), Shift+Enter for new line. Slash commands: `/context`, `/reset`, `/new`, `/clear`, `/spec-search`. ",-1))]))}}),S8={class:"h-64 border-t border-retro-border bg-retro-dark/50 flex flex-col"},$8={class:"h-9 flex items-center justify-between px-3 border-b border-retro-border/40"},C8={key:0,class:"flex-1 flex items-center justify-center text-xs font-mono text-retro-muted"},Q8={key:1,class:"flex-1 overflow-y-auto scrollbar-custom"},P8={class:"flex items-center gap-2 text-[10px] font-mono"},T8={class:"text-retro-muted"},M8={class:"text-retro-muted"},A8={class:"text-retro-green truncate"},_8={class:"mt-1 text-[11px] font-mono text-retro-text whitespace-pre-wrap break-words"},R8=Ve({__name:"ChatDebugPanel",setup(r){const e=vr(),{debugEvents:t}=W1(e);function n(i){return new Date(i).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function s(i){return i==="in"?"text-retro-cyan":i==="out"?"text-retro-yellow":"text-retro-muted"}return(i,o)=>(v(),y("div",S8,[d("div",$8,[o[1]||(o[1]=d("div",{class:"text-[11px] font-mono text-retro-text"}," Debug Stream (CLI/Provider) ",-1)),d("button",{class:"p-1 rounded hover:bg-retro-panel transition-colors",title:"Clear debug events",onClick:o[0]||(o[0]=a=>m(e).clearDebugEvents())},[ee(m(vn),{class:"w-3.5 h-3.5 text-retro-muted"})])]),m(t).length===0?(v(),y("div",C8," No debug events yet ")):(v(),y("div",Q8,[(v(!0),y(we,null,Ne(m(t),a=>(v(),y("div",{key:a.id,class:"px-3 py-2 border-b border-retro-border/20"},[d("div",P8,[d("span",T8,A(n(a.timestamp)),1),d("span",{class:_e(s(a.direction))},A(a.direction.toUpperCase()),3),d("span",M8,A(a.channel),1),d("span",A8,A(a.eventType),1)]),d("pre",_8,A(a.payload),1)]))),128))]))]))}}),B8={class:"px-4 py-3 border-b border-retro-border bg-retro-dark/80 space-y-3"},Z8={class:"flex items-center justify-between"},E8={class:"space-y-1 text-xs font-mono"},D8={class:"flex items-center gap-2"},L8={class:"relative"},X8=["disabled"],I8=["value"],V8=["value"],z8={class:"flex items-center gap-2"},N8={class:"text-retro-text"},W8={class:"relative"},q8=["disabled"],j8=["disabled"],Y8={key:0,class:"flex items-center justify-between gap-3 rounded border border-retro-border bg-retro-black px-2 py-1.5 text-xs font-mono"},F8={class:"min-w-0"},U8={class:"flex items-center gap-2"},G8={class:"text-retro-text truncate"},H8={key:0,class:"mt-0.5 text-retro-red truncate"},K8={class:"flex items-center gap-2"},J8=["disabled"],eZ=["disabled"],tZ=Ve({__name:"FinalizeConfirm",props:{baseBranch:{},worktreeBranch:{},worktreePath:{}},emits:["confirm","cancel"],setup(r,{emit:e}){const t=r,n=e,s=P(""),i=P(null),o=P(!1),a=P(!1),l=P("idle"),c=P(""),u=P(null),h=P(Bo(t.baseBranch)?t.baseBranch:""),f=P([]),p=P(!1),g=P(null),O=J(()=>_1(h.value||t.baseBranch));async function b(){if(a.value)return;a.value=!0,l.value="running",c.value="";const w=new AbortController;u.value=w;try{const S=await $fetch("/api/chat/generate-commit-message",{method:"POST",signal:w.signal,body:{conversationId:t.worktreePath.split("/").pop()?.replace("sc-","")||"",worktreePath:t.worktreePath,worktreeBranch:t.worktreeBranch,baseBranch:h.value||t.baseBranch}});S.success&&S.message?(s.value=S.message,l.value="done"):(l.value="error",c.value=S.error||"Failed to generate commit message")}catch(S){w.signal.aborted?l.value="aborted":(l.value="error",c.value=S instanceof Error?S.message:String(S))}finally{a.value=!1,u.value===w&&(u.value=null)}}function x(){u.value?.abort()}gt(async()=>{const w=(async()=>{try{const Q=t.worktreePath.split("/").pop()||"",L=await $fetch(`/api/commits/${encodeURIComponent(Q)}`,{params:{workingDirectory:t.worktreePath}});i.value=L.aheadCount}catch{i.value=null}})(),S=(async()=>{p.value=!0;try{const Q=t.worktreePath||(await $fetch("/api/cwd")).cwd,L=await $fetch("/api/git/branches",{query:{workingDirectory:Q}});f.value=L.branches.filter(G=>!G.isRemote&&!G.name.startsWith("sc/")).map(Ih).filter(G=>!!G);const D=Xh(h.value||t.baseBranch,f.value);D&&(h.value=D)}catch{f.value=[]}finally{p.value=!1}})();await Promise.all([w,S]),It(()=>g.value?.focus())});function k(){!s.value.trim()||!h.value||(o.value=!0,n("confirm",s.value.trim(),h.value))}return(w,S)=>(v(),y("div",B8,[d("div",Z8,[S[4]||(S[4]=d("span",{class:"text-xs font-mono text-retro-text font-semibold uppercase tracking-wide"}," Finalize ",-1)),d("button",{type:"button",class:"p-0.5 text-retro-muted hover:text-retro-text transition-colors",title:"Cancel",onClick:S[0]||(S[0]=Q=>n("cancel"))},[ee(m(St),{class:"w-4 h-4"})])]),d("div",E8,[d("div",D8,[S[5]||(S[5]=d("span",{class:"text-retro-muted"},"target:",-1)),d("div",L8,[je(d("select",{"onUpdate:modelValue":S[1]||(S[1]=Q=>h.value=Q),disabled:o.value||p.value,class:"appearance-none bg-retro-black border border-retro-border rounded px-2 py-0.5 pr-6 text-xs font-mono text-retro-cyan focus:outline-none focus:border-retro-cyan cursor-pointer disabled:opacity-40"},[p.value?(v(),y("option",{key:0,value:h.value},A(O.value),9,I8)):F("",!0),(v(!0),y(we,null,Ne(f.value,Q=>(v(),y("option",{key:Q,value:Q},A(Q),9,V8))),128))],8,X8),[[ks,h.value]]),ee(m(Ru),{class:"absolute right-1 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-retro-muted pointer-events-none"})])]),d("div",z8,[S[6]||(S[6]=d("span",{class:"text-retro-muted"},"commits:",-1)),d("span",N8,A(i.value!==null?i.value:"..."),1)])]),d("div",W8,[je(d("textarea",{ref_key:"textareaRef",ref:g,"onUpdate:modelValue":S[2]||(S[2]=Q=>s.value=Q),placeholder:"Squash commit message...",rows:"2",class:"w-full px-2 py-1.5 pr-8 text-xs font-mono bg-retro-black border border-retro-border rounded text-retro-text placeholder-retro-subtle focus:outline-none focus:border-retro-cyan resize-none",disabled:o.value||a.value},null,8,q8),[[Rt,s.value]]),d("button",{type:"button",disabled:o.value||a.value||p.value||!h.value,class:"absolute right-1.5 top-1.5 p-0.5 rounded text-retro-muted hover:text-retro-cyan transition-colors disabled:opacity-40",title:"Generate commit message",onClick:b},[ee(m(ji),{class:_e(["w-4 h-4",{"animate-spin":a.value}])},null,8,["class"])],8,j8)]),l.value!=="idle"?(v(),y("div",Y8,[d("div",F8,[d("div",U8,[ee(m(ji),{class:_e(["w-3.5 h-3.5 text-retro-cyan shrink-0",{"animate-spin":l.value==="running"}])},null,8,["class"]),d("span",G8,A(l.value==="running"?`Generating from ${h.value}...`:l.value==="done"?"Commit message generated":l.value==="aborted"?"Generation stopped":"Generation failed"),1)]),c.value?(v(),y("div",H8,A(c.value),1)):F("",!0)]),l.value==="running"?(v(),y("button",{key:0,type:"button",class:"shrink-0 p-0.5 rounded text-retro-muted hover:text-retro-red transition-colors",title:"Stop generation",onClick:x},[ee(m(pp),{class:"w-4 h-4"})])):F("",!0)])):F("",!0),d("div",K8,[d("button",{type:"button",disabled:!s.value.trim()||!h.value||o.value,class:"flex items-center gap-1 px-3 py-1 text-xs font-mono rounded border transition-colors bg-retro-green/10 border-retro-green/50 text-retro-green hover:bg-retro-green/20 disabled:opacity-40 disabled:cursor-not-allowed",onClick:k},[ee(m(_u),{class:"w-3.5 h-3.5"}),Ie(" "+A(o.value?"Finalizing...":"Confirm"),1)],8,J8),d("button",{type:"button",disabled:o.value,class:"px-3 py-1 text-xs font-mono rounded border border-retro-border text-retro-muted hover:text-retro-text hover:border-retro-text/30 transition-colors disabled:opacity-40",onClick:S[3]||(S[3]=Q=>n("cancel"))}," Cancel ",8,eZ)])]))}}),rZ={class:"px-4 py-3 border-b border-retro-border bg-retro-dark/80 space-y-3"},nZ={class:"flex items-center justify-between"},sZ={class:"space-y-1 text-xs font-mono"},iZ={class:"flex items-center gap-2"},oZ={class:"text-retro-cyan"},aZ={class:"flex items-center gap-2"},lZ={class:"relative"},cZ=["disabled"],uZ=["value"],hZ=["value"],dZ={class:"flex items-center gap-2"},fZ={class:"text-retro-text"},mZ={class:"flex items-center gap-2"},pZ=["disabled"],gZ=["disabled"],OZ=Ve({__name:"RebaseConfirm",props:{baseBranch:{},worktreeBranch:{},worktreePath:{}},emits:["confirm","cancel"],setup(r,{emit:e}){const t=r,n=e,s=P(null),i=P(!1),o=P(Bo(t.baseBranch)?t.baseBranch:""),a=P([]),l=P(!1),c=J(()=>_1(o.value||t.baseBranch));async function u(f){if(!f){s.value=null;return}try{const p=await $fetch("/api/chat/compare",{params:{worktreePath:t.worktreePath,baseBranch:f}});s.value=p.ahead}catch{s.value=null}}gt(async()=>{const f=u(o.value),p=(async()=>{l.value=!0;try{const g=t.worktreePath||(await $fetch("/api/cwd")).cwd,O=await $fetch("/api/git/branches",{query:{workingDirectory:g}});a.value=O.branches.filter(x=>!x.isRemote&&!x.name.startsWith("sc/")).map(Ih).filter(x=>!!x);const b=Xh(o.value||t.baseBranch,a.value);b&&(o.value=b)}catch{a.value=[]}finally{l.value=!1}})();await Promise.all([f,p])}),ze(o,f=>{u(f)});function h(){o.value&&(i.value=!0,n("confirm",o.value))}return(f,p)=>(v(),y("div",rZ,[d("div",nZ,[p[3]||(p[3]=d("span",{class:"text-xs font-mono text-retro-text font-semibold uppercase tracking-wide"}," Rebase Worktree ",-1)),d("button",{type:"button",class:"p-0.5 text-retro-muted hover:text-retro-text transition-colors",title:"Cancel",onClick:p[0]||(p[0]=g=>n("cancel"))},[ee(m(St),{class:"w-4 h-4"})])]),d("div",sZ,[d("div",iZ,[p[4]||(p[4]=d("span",{class:"text-retro-muted"},"worktree:",-1)),d("span",oZ,A(r.worktreeBranch),1)]),d("div",aZ,[p[5]||(p[5]=d("span",{class:"text-retro-muted"},"target:",-1)),d("div",lZ,[je(d("select",{"onUpdate:modelValue":p[1]||(p[1]=g=>o.value=g),disabled:i.value||l.value,class:"appearance-none bg-retro-black border border-retro-border rounded px-2 py-0.5 pr-6 text-xs font-mono text-retro-cyan focus:outline-none focus:border-retro-cyan cursor-pointer disabled:opacity-40"},[l.value?(v(),y("option",{key:0,value:o.value},A(c.value),9,uZ)):F("",!0),(v(!0),y(we,null,Ne(a.value,g=>(v(),y("option",{key:g,value:g},A(g),9,hZ))),128))],8,cZ),[[ks,o.value]]),ee(m(Ru),{class:"absolute right-1 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-retro-muted pointer-events-none"})])]),d("div",dZ,[p[6]||(p[6]=d("span",{class:"text-retro-muted"},"commits ahead:",-1)),d("span",fZ,A(s.value!==null?s.value:"..."),1)])]),d("div",mZ,[d("button",{type:"button",disabled:i.value||!o.value,class:"flex items-center gap-1 px-3 py-1 text-xs font-mono rounded border transition-colors bg-retro-cyan/10 border-retro-cyan/50 text-retro-cyan hover:bg-retro-cyan/20 disabled:opacity-40 disabled:cursor-not-allowed",onClick:h},[ee(m(_u),{class:"w-3.5 h-3.5"}),Ie(" "+A(i.value?"Rebasing...":"Confirm"),1)],8,pZ),d("button",{type:"button",disabled:i.value,class:"px-3 py-1 text-xs font-mono rounded border border-retro-border text-retro-muted hover:text-retro-text hover:border-retro-text/30 transition-colors disabled:opacity-40",onClick:p[2]||(p[2]=g=>n("cancel"))}," Cancel ",8,gZ)])]))}}),vZ={class:"flex-1 flex flex-col overflow-hidden"},bZ={class:"flex-shrink-0 px-4 py-2 border-b border-retro-border flex items-center justify-between bg-retro-dark"},xZ={class:"text-xs font-mono text-retro-text truncate"},yZ={class:"flex items-center gap-2 flex-shrink-0"},kZ={key:0,class:"text-xs font-mono text-retro-green"},wZ={key:1,class:"text-[11px] font-mono text-retro-muted"},SZ={key:0,class:"flex items-center justify-center h-full text-retro-muted text-xs font-mono"},$Z=["innerHTML"],CZ={key:0,class:"flex-shrink-0 px-4 py-2 border-t border-retro-border bg-retro-yellow/10 text-retro-yellow text-xs font-mono"},QZ=Ve({__name:"ConflictFileEditor",props:{file:{},resolved:{type:Boolean},isAiResolving:{type:Boolean},strategy:{}},emits:["resolve","aiResolve","retry"],setup(r,{emit:e}){const t=r;P(t.file.content);const n=P(""),s=P(!1);ze(()=>t.file.path,()=>{a()}),ze(()=>t.file.content,()=>{a()});const i=J(()=>{const c=/^<{7}\s/gm;return(t.file.content.match(c)||[]).length});function o(c){const u=c.split(".").pop()?.toLowerCase()||"";return{ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",vue:"vue",html:"html",css:"css",scss:"scss",less:"less",json:"json",yaml:"yaml",yml:"yaml",md:"markdown",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",sh:"bash",zsh:"bash",sql:"sql",graphql:"graphql",xml:"xml",svg:"xml",toml:"toml",ini:"ini",dockerfile:"dockerfile"}[u]||"text"}async function a(){s.value=!0;try{const{codeToHtml:c}=await ds(async()=>{const{codeToHtml:x}=await import("./PyyEm6pa.js");return{codeToHtml:x}},__vite__mapDeps([3,1,2]),import.meta.url),u=o(t.file.path),f=t.file.content.split(`
71
+ `)}function B1(r){return`${r.providerId}::${r.modelKey}`}function Q7(r,e){const t=new Map;for(const s of r)for(const i of s.models)t.set(i.label,(t.get(i.label)??0)+1);return r.flatMap(s=>s.models.map(i=>{const o=s.capabilities.streaming&&(!e||s.capabilities.permissions),a=(t.get(i.label)??0)>1;return{key:`${s.id}::${i.key}`,providerId:s.id,providerName:s.name,modelKey:i.key,modelLabel:i.label,label:a?`${i.label} · ${s.name}`:i.label,compatible:o}})).sort((s,i)=>s.modelLabel.localeCompare(i.modelLabel,void 0,{sensitivity:"base"})||s.providerName.localeCompare(i.providerName,void 0,{sensitivity:"base"}))}function P7(r){const e=new Map;for(const s of r){const i=e.get(s.providerId);if(i){i.options.push(s);continue}e.set(s.providerId,{providerId:s.providerId,providerName:s.providerName,options:[s]})}const t=new Map([["codex",0],["claude",1]]),n=Array.from(e.values());return n.sort((s,i)=>{const o=t.get(s.providerId)??99,a=t.get(i.providerId)??99;return o!==a?o-a:s.providerName.localeCompare(i.providerName,void 0,{sensitivity:"base"})}),n}function T7(r,e){const t=B1(e);return r.find(n=>n.key===t)??null}const Ym=4,M7=5*1024*1024;function A7(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function _7(r,e=M7){return r.type.startsWith("image/")?r.size>e?{ok:!1,reason:"too-large"}:{ok:!0}:{ok:!1,reason:"not-image"}}function R7(r){return new Promise((e,t)=>{const n=new FileReader;n.onload=()=>{typeof n.result=="string"?e(n.result):t(new Error("Failed to read image"))},n.onerror=()=>t(n.error||new Error("Failed to read image")),n.readAsDataURL(r)})}function B7(r=Date.now,e=Math.random){return`att-${r()}-${e().toString(36).slice(2,8)}`}function Z7(r=Date.now,e=Math.random){return`q-${r()}-${e().toString(36).slice(2,8)}`}function E7(r,e=Z7){const t=r.text.trim();return t.length===0&&r.attachments.length===0?null:{id:e(),text:t,attachments:[...r.attachments]}}function D7(r,e){return r.filter(t=>t.id!==e)}const L7={class:"flex-shrink-0 flex-grow-0 border-t border-retro-border bg-retro-dark p-3"},X7={class:"flex flex-wrap items-center gap-2 mb-2"},I7={class:"relative min-w-0 flex-1 max-w-full sm:max-w-[154px] model-selector"},V7=["disabled"],z7={class:"truncate text-left"},N7={key:0,class:"absolute bottom-full left-0 mb-1 py-1 bg-retro-dark border border-retro-border rounded shadow-lg z-10 min-w-[220px] max-w-[280px]"},W7={key:0,class:"px-3 py-1.5 text-xs font-mono text-retro-muted"},q7={class:"px-3 py-1 text-[11px] font-mono uppercase tracking-wide text-retro-cyan/80 select-none"},j7=["disabled","onClick"],Y7={class:"truncate"},F7={class:"relative mode-selector"},U7={key:0,class:"absolute bottom-full left-0 mb-1 py-1 bg-retro-dark border border-retro-border rounded shadow-lg z-10 min-w-[140px]"},G7=["onClick"],H7={class:"hidden text-xs font-mono text-retro-muted sm:inline"},K7={key:0,class:"mb-3 p-3 bg-retro-yellow/10 border border-retro-yellow/50 rounded"},J7={class:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"},e8={class:"flex-1 min-w-0"},t8={class:"text-xs font-mono text-retro-text truncate"},r8={class:"text-retro-cyan"},n8={key:0,class:"text-retro-muted"},s8={key:1,class:"text-retro-muted"},i8={key:1,class:"mb-3 p-3 bg-retro-cyan/10 border border-retro-cyan/50 rounded"},o8={key:2,class:"mb-2 flex flex-wrap gap-2"},a8=["src","alt"],l8={class:"mt-1 truncate text-[10px] font-mono text-retro-muted"},c8={class:"truncate text-[10px] font-mono text-retro-muted/80"},u8=["onClick"],h8={key:3,class:"mb-2"},d8={class:"text-[10px] font-mono text-retro-muted mb-1 uppercase tracking-wide"},f8={class:"space-y-1"},m8={class:"text-[10px] font-mono text-retro-yellow flex-shrink-0"},p8={class:"flex-1 text-xs font-mono text-retro-text truncate"},g8={key:0,class:"text-[10px] font-mono text-retro-muted flex-shrink-0"},O8=["onClick"],v8={class:"flex gap-2 items-start"},b8=["disabled"],x8={class:"flex-1 relative min-h-[40px]"},y8=["disabled","placeholder"],k8=["disabled","title"],w8=Ve({__name:"ChatInput",props:{disabled:{type:Boolean}},setup(r){const e=r,t=vr(),n=bo(),{sendMessage:s,sendPermissionResponse:i,approvePlan:o,rejectPlan:a,abort:l,resetContext:c}=Ml(),u=P(""),h=P(null),f=P(null),p=P(!1),g=P(!1),O=P(!1),b=P([]);let x=null;const k=P(null),w=P({}),S=J(()=>{const he=t.activeConversationId;return he?w.value[he]??[]:[]});function Q(he,ye){if(ye.length===0){const{[he]:Be,...Ye}=w.value;w.value=Ye}else w.value={...w.value,[he]:ye}}const{data:L,pending:D}=$c("chat-input-ai-providers",()=>$fetch("/api/ai/providers"),{server:!1,default:()=>({providers:[]})}),G=J(()=>L.value?.providers??[]),oe=J(()=>t.permissionMode==="ask"||t.permissionMode==="plan"),ie=J(()=>Q7(G.value,oe.value)),j=J(()=>P7(ie.value)),V=J(()=>{const he=t.activeConversation;return he?.providerId&&he.providerModelKey?{providerId:he.providerId,modelKey:he.providerModelKey}:k.value?k.value:n.providerSelection}),Z=J(()=>B1(V.value)),U=J(()=>T7(ie.value,V.value)),W=J(()=>U.value?.label||"Select model");function N(he,ye){t.setConversationProviderSelection(he,ye.providerId,ye.modelKey),t.clearProviderSession(he),t.saveConversation(he,!0)}function I(he){k.value&&(N(he,k.value),k.value=null)}function z(he){if(!he||!he.compatible)return;const ye={providerId:he.providerId,modelKey:he.modelKey},Be=t.activeConversationId;if(Be){N(Be,ye),k.value=null,O.value=!1;return}k.value=ye,O.value=!1}const be={plan:Bu,ask:Zu,auto:lp,bypass:Eu},K={plan:"text-retro-cyan",ask:"text-retro-green",auto:"text-retro-yellow",bypass:"text-retro-red"};function H(he){t.setPermissionMode(he),g.value=!1}function re(he){const ye=he.target;ye.closest(".mode-selector")||(g.value=!1),ye.closest(".model-selector")||(O.value=!1)}gt(()=>{document.addEventListener("click",re),n.hydrate()}),wt(()=>{document.removeEventListener("click",re),x!==null&&typeof window<"u"&&typeof window.cancelAnimationFrame=="function"&&(window.cancelAnimationFrame(x),x=null)});const Oe=J(()=>(u.value.trim().length>0||b.value.length>0)&&!p.value&&!t.pendingPermission&&!Pe.value),ge=J(()=>t.isActiveConversationStreaming&&!t.pendingPermission),$e=J(()=>t.pendingPermission!==null),Pe=J(()=>t.pendingPlanApproval!==null);function Fe(){i(!0,t.activeConversationId)}function T(){i(!1,t.activeConversationId)}function M(){o(t.activeConversationId)}function E(){a(t.activeConversationId)}function B(){b.value=[],f.value&&(f.value.value="")}function xe(he){b.value=b.value.filter(ye=>ye.id!==he)}async function Re(he){const ye=he.target,Be=ye.files?Array.from(ye.files):[];if(Be.length===0)return;const{useToast:Ye}=await ds(async()=>{const{useToast:ot}=await import("./BeBeZcRQ.js").then(Ft=>Ft.n);return{useToast:ot}},__vite__mapDeps([0,1,2]),import.meta.url),Ue=Ye();let Ct=Ym-b.value.length;if(Ct<=0){Ue.warning(`You can attach up to ${Ym} images per message.`),ye.value="";return}for(const ot of Be){if(Ct<=0)break;const Ft=_7(ot);if(!Ft.ok){Ft.reason==="not-image"?Ue.warning(`Skipped "${ot.name}": only image files are supported.`):Ue.warning(`Skipped "${ot.name}": max size is 5 MB.`);continue}try{const ir=await R7(ot);b.value.push({id:B7(),name:ot.name,mimeType:ot.type,size:ot.size,dataUrl:ir}),Ct--}catch{Ue.error(`Failed to attach "${ot.name}".`)}}ye.value=""}const Me=J(()=>{if(t.isActiveConversationStreaming||p.value)return!1;const he=t.lastMessage;return he?.role==="assistant"&&he?.status==="error"});async function ue(he){const ye=t.activeConversationId??await t.createConversation(),Be=t.addAssistantMessage(ye);if(!he.q){t.updateMessage(Be.id,{content:["Usage: `/spec-search <query> [--mode keyword|semantic|hybrid] [--feature <feature-id>] [--file-type <type>] [--limit <n>]`","","Examples:","- `/spec-search FR-001`",'- `/spec-search "indexing indicator" --mode hybrid --feature 008-spec-search --limit 5`'].join(`
72
+ `),status:"complete"},ye);return}const Ye=t.activeConversation,Ue=y7(he,{featureId:Ye?.featureId});try{const Ct=await $fetch("/api/specs/search",{query:Ue});t.updateMessage(Be.id,{content:C7({...he,mode:Ue.mode,featureId:Ue.featureId},Ct),status:"complete"},ye)}catch(Ct){const ot=Ct instanceof Error?Ct.message:"Failed to run spec search";t.updateMessage(Be.id,{content:`Spec search failed: ${ot}`,status:"error"},ye)}}async function ne(){const he=x7(t.activeConversation,t.permissionMode),ye=await $fetch("/api/chat/context",{query:he}),Be=t.activeConversationId??await t.createConversation(),Ye=t.addAssistantMessage(Be);t.updateMessage(Ye.id,{content:k7(ye),status:"complete"},Be)}function Ce(he=[]){const ye=Ta(t.activeConversation,!0)??{};return he.length>0?{...ye,attachments:he}:Object.keys(ye).length>0?ye:void 0}function q(he){const ye=t.addAssistantMessage(he);return t.startSession(`session-${Date.now()}`,he),t.startConversationStreaming(he),t.saveConversation(he,!0),ye}function ve(he,ye,Be,Ye){const Ue=Be instanceof Error?Be.message:Ye;t.setSessionError(Ue,he),t.updateMessage(ye,{status:"error"},he),t.endSession(he),t.endConversationStreaming(he)}async function Ze(he,ye){const Be=he!==void 0,Ye=(he??u.value).trim(),Ue=ye??[...b.value];if(Ye.length===0&&Ue.length===0||t.isActiveConversationStreaming||p.value||e.disabled)return;const Ct=!!t.activeConversationId;let ot=null,Ft=null;const ir=b7(Ye);if(ir.kind!=="none"){if(ir.kind==="reset"){await qn();return}ir.kind==="context"?await ne():ir.kind==="spec-search"&&await ue(ir.command),Be||(u.value="",B(),Et());return}p.value=!0,Be||(u.value="",B(),Et());try{if(await t.addUserMessageWithConversation(Ye,Ue),ot=t.activeConversationId,!ot)throw new Error("Failed to create or select a conversation");Ct||I(ot);const yr=q(ot);Ft=yr.id,await s(Ye,yr.id,ot,Ce(Ue))}catch(yr){if(ot&&Ft)ve(ot,Ft,yr,"Failed to send message");else{const Yn=yr instanceof Error?yr.message:"Failed to send message";t.setSessionError(Yn)}}finally{p.value=!1}}async function it(){try{l(t.activeConversationId)}catch{}}function Nt(){t.isActiveConversationStreaming?sr():Ze()}function sr(){const he=t.activeConversationId;if(!he)return;const ye=E7({text:u.value,attachments:b.value});ye&&(Q(he,[...S.value,ye]),u.value="",B(),Et(),Wt())}function on(he){const ye=t.activeConversationId;ye&&Q(ye,D7(S.value,he))}async function xr(){const he=t.activeConversationId;if(!he)return;const ye=w.value[he]??[];if(ye.length===0||t.isActiveConversationStreaming||p.value)return;const[Be,...Ye]=ye;Q(he,Ye),await Ze(Be.text,Be.attachments)}async function qn(){if(t.activeConversationId){u.value="",B(),Et(),p.value=!0;try{await c(t.activeConversationId);const he=t.addAssistantMessage(t.activeConversationId);t.updateMessage(he.id,{content:"✨ **Context cleared** — The AI conversation context has been reset. Starting fresh from here.",status:"complete"},t.activeConversationId);const{useToast:ye}=await ds(async()=>{const{useToast:Ye}=await import("./BeBeZcRQ.js").then(Ue=>Ue.n);return{useToast:Ye}},__vite__mapDeps([0,1,2]),import.meta.url);ye().success("AI context has been reset. The conversation will start fresh.")}catch(he){console.error("Failed to reset context:",he);const{useToast:ye}=await ds(async()=>{const{useToast:Ye}=await import("./BeBeZcRQ.js").then(Ue=>Ue.n);return{useToast:Ye}},__vite__mapDeps([0,1,2]),import.meta.url);ye().error("Failed to reset context. Please try again.")}finally{p.value=!1}}}async function an(){const he=t.messages;let ye=null;for(let Ue=he.length-1;Ue>=0;Ue--)if(he[Ue].role==="user"){ye={content:he[Ue].content,attachments:he[Ue].attachments??[]};break}if(!ye||!t.activeConversationId)return;const Be=t.activeConversationId;t.clearError(),p.value=!0;let Ye=null;try{const Ue=q(Be);Ye=Ue.id,await s(ye.content,Ue.id,Be,Ce(ye.attachments))}catch(Ue){if(Ye)ve(Be,Ye,Ue,"Failed to retry message");else{const Ct=Ue instanceof Error?Ue.message:"Failed to retry message";t.setSessionError(Ct,Be)}}finally{p.value=!1}}function jn(he){he.key==="Enter"&&!he.shiftKey&&(he.preventDefault(),Nt())}function ln(){const he=h.value;if(he){if(!u.value.trim()){he.style.height="";return}he.style.height="auto",he.style.height=Math.min(he.scrollHeight,200)+"px"}}function Sn(){if(x!==null)return;x=(typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):ye=>setTimeout(()=>ye(Date.now()),16))(()=>{x=null,ln()})}function Et(){const he=h.value;he&&(he.style.height="")}function Wt(){It(()=>{h.value?.focus()})}return ze(u,Sn),ze(()=>t.isActiveConversationStreaming,(he,ye)=>{ye&&!he&&(S.value.length>0?It(()=>xr()):Wt())}),ze(()=>t.activeConversationId,()=>{t.activeConversationId&&(k.value=null),B(),Wt(),!t.isActiveConversationStreaming&&S.value.length>0&&It(()=>xr())}),(he,ye)=>(v(),y("div",L7,[d("div",X7,[d("div",I7,[d("button",{disabled:r.disabled||m(t).isActiveConversationStreaming||m($e)||m(Pe)||m(D)||m(ie).length===0,class:"flex items-center justify-between gap-1.5 w-full px-2 py-1 rounded border border-retro-border/50 hover:border-retro-border text-xs font-mono text-retro-muted transition-colors disabled:opacity-60 disabled:cursor-not-allowed",onClick:ye[0]||(ye[0]=Be=>O.value=!m(O))},[d("span",z7,A(m(W)),1),ee(m(jm),{class:"w-3 h-3 flex-shrink-0"})],8,V7),m(O)?(v(),y("div",N7,[m(ie).length===0?(v(),y("div",W7," Loading models... ")):F("",!0),(v(!0),y(we,null,Ne(m(j),Be=>(v(),y("div",{key:Be.providerId,class:"py-0.5"},[d("div",q7,A(Be.providerName),1),(v(!0),y(we,null,Ne(Be.options,Ye=>(v(),y("button",{key:Ye.key,disabled:!Ye.compatible,class:_e(["flex items-center gap-2 w-full px-3 py-1.5 text-xs font-mono text-left hover:bg-retro-panel transition-colors disabled:opacity-50 disabled:cursor-not-allowed",m(Z)===Ye.key?"bg-retro-panel text-retro-text":"text-retro-muted"]),onClick:Ue=>z(Ye)},[d("span",Y7,A(Ye.modelLabel)+A(Ye.compatible?"":" (unsupported for current permission mode)"),1)],10,j7))),128))]))),128))])):F("",!0)]),d("div",F7,[d("button",{class:_e(["flex items-center gap-1.5 px-2 py-1 rounded border border-retro-border/50 hover:border-retro-border text-xs font-mono transition-colors",K[m(t).permissionMode]]),onClick:ye[1]||(ye[1]=Be=>g.value=!m(g))},[(v(),pe(ps(be[m(t).permissionMode]),{class:"w-4 h-4"})),d("span",null,A(m(Zs)[m(t).permissionMode]),1),ee(m(jm),{class:"w-3 h-3"})],2),m(g)?(v(),y("div",U7,[(v(),y(we,null,Ne(["plan","ask","auto","bypass"],Be=>d("button",{key:Be,class:_e(["flex items-center gap-2 w-full px-3 py-1.5 text-xs font-mono text-left hover:bg-retro-panel transition-colors",[K[Be],m(t).permissionMode===Be?"bg-retro-panel":""]]),onClick:Ye=>H(Be)},[(v(),pe(ps(be[Be]),{class:"w-4 h-4"})),d("span",null,A(m(Zs)[Be]),1)],10,G7)),64))])):F("",!0)]),d("span",H7,A(m(t).permissionMode==="plan"?"Plan only":m(t).permissionMode==="ask"?"Ask before actions":m(t).permissionMode==="auto"?"Auto approve":"All permissions"),1)]),m($e)?(v(),y("div",K7,[d("div",J7,[d("div",e8,[ye[4]||(ye[4]=d("div",{class:"text-xs font-mono text-retro-yellow font-bold mb-1"}," Permission Required ",-1)),d("div",t8,[d("span",r8,A(m(t).pendingPermission?.tool),1),m(t).pendingPermission?.filePath?(v(),y("span",n8," - "+A(m(t).pendingPermission.filePath),1)):m(t).pendingPermission?.command?(v(),y("span",s8," - "+A(m(t).pendingPermission.command),1)):F("",!0)])]),d("div",{class:"flex flex-shrink-0 gap-2"},[d("button",{class:"px-3 py-1.5 text-xs font-mono rounded bg-retro-green/20 text-retro-green border border-retro-green/50 hover:bg-retro-green/30 transition-colors",onClick:Fe}," Allow "),d("button",{class:"px-3 py-1.5 text-xs font-mono rounded bg-retro-red/20 text-retro-red border border-retro-red/50 hover:bg-retro-red/30 transition-colors",onClick:T}," Deny ")])])])):F("",!0),m(Pe)?(v(),y("div",i8,[d("div",{class:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"},[ye[5]||(ye[5]=d("div",{class:"flex-1 min-w-0"},[d("div",{class:"text-xs font-mono text-retro-cyan font-bold mb-1"}," Plan Ready for Review "),d("div",{class:"text-xs font-mono text-retro-muted"}," Approve to switch to Auto mode and start implementation. ")],-1)),d("div",{class:"flex flex-shrink-0 gap-2"},[d("button",{class:"px-3 py-1.5 text-xs font-mono rounded bg-retro-green/20 text-retro-green border border-retro-green/50 hover:bg-retro-green/30 transition-colors",onClick:M}," Approve & Implement "),d("button",{class:"px-3 py-1.5 text-xs font-mono rounded bg-retro-red/20 text-retro-red border border-retro-red/50 hover:bg-retro-red/30 transition-colors",onClick:E}," Reject ")])])])):F("",!0),m(b).length>0?(v(),y("div",o8,[(v(!0),y(we,null,Ne(m(b),Be=>(v(),y("div",{key:Be.id,class:"relative w-24 rounded border border-retro-border/70 bg-retro-black/80 p-1"},[d("img",{src:Be.dataUrl,alt:Be.name,class:"h-16 w-full rounded object-cover"},null,8,a8),d("div",l8,A(Be.name),1),d("div",c8,A(m(A7)(Be.size)),1),d("button",{class:"absolute -right-2 -top-2 rounded-full border border-retro-border bg-retro-panel p-0.5 text-retro-red hover:bg-retro-red/20",type:"button",onClick:Ye=>xe(Be.id)},[ee(m(St),{class:"h-3 w-3"})],8,u8)]))),128))])):F("",!0),m(S).length>0?(v(),y("div",h8,[d("div",d8," Queued ("+A(m(S).length)+") ",1),d("div",f8,[(v(!0),y(we,null,Ne(m(S),(Be,Ye)=>(v(),y("div",{key:Be.id,class:"flex items-center gap-2 px-2.5 py-1.5 bg-retro-panel/50 border border-retro-border/30 rounded"},[d("span",m8,"#"+A(Ye+1),1),d("span",p8,A(Be.text),1),Be.attachments.length>0?(v(),y("span",g8," +"+A(Be.attachments.length)+" img ",1)):F("",!0),d("button",{class:"flex-shrink-0 p-0.5 text-retro-muted hover:text-retro-red transition-colors",title:"Cancel queued message",onClick:Ue=>on(Be.id)},[ee(m(St),{class:"w-3.5 h-3.5"})],8,O8)]))),128))])])):F("",!0),d("div",v8,[d("input",{ref_key:"fileInputRef",ref:f,type:"file",accept:"image/*",multiple:"",class:"hidden",onChange:Re},null,544),d("button",{class:"flex-shrink-0 h-10 w-10 inline-flex items-center justify-center p-0 rounded bg-retro-panel/70 text-retro-muted hover:text-retro-cyan hover:bg-retro-panel disabled:opacity-50 disabled:cursor-not-allowed transition-colors",type:"button",title:"Attach images",disabled:r.disabled||m($e)||m(Pe),onClick:ye[2]||(ye[2]=Be=>m(f)?.click())},[ee(m(Zv),{class:"w-5 h-5"})],8,b8),d("div",x8,[je(d("textarea",{ref_key:"inputRef",ref:h,"onUpdate:modelValue":ye[3]||(ye[3]=Be=>Je(u)?u.value=Be:null),disabled:r.disabled||m($e)||m(Pe),placeholder:r.disabled?"This conversation is finalized (read-only)":m(t).isActiveConversationStreaming?"Type to queue a message...":"Type a message...",rows:"1",class:"w-full h-full min-h-[40px] px-3 py-2 bg-retro-black border border-retro-border rounded text-sm font-mono text-retro-text placeholder-retro-muted focus:outline-none focus:border-retro-cyan disabled:opacity-50 disabled:cursor-not-allowed resize-none overflow-hidden",onKeydown:jn},null,40,y8),[[Rt,m(u)]])]),m(Me)?(v(),y("button",{key:0,class:"flex-shrink-0 h-10 w-10 inline-flex items-center justify-center p-0 rounded bg-retro-yellow/20 text-retro-yellow hover:bg-retro-yellow/30 transition-colors",title:"Retry last message",onClick:an},[ee(m(m7),{class:"w-5 h-5"})])):F("",!0),m($e)?F("",!0):(v(),y("button",{key:1,disabled:!m(Oe),title:m(t).isActiveConversationStreaming?"Queue message":"Send message",class:_e(["flex-shrink-0 h-10 w-10 inline-flex items-center justify-center p-0 rounded disabled:opacity-50 disabled:cursor-not-allowed transition-colors",m(t).isActiveConversationStreaming?"bg-retro-yellow/20 text-retro-yellow hover:bg-retro-yellow/30":"bg-retro-cyan/20 text-retro-cyan hover:bg-retro-cyan/30"]),onClick:Nt},[m(t).isActiveConversationStreaming?(v(),pe(m(fp),{key:0,class:"w-5 h-5"})):(v(),pe(m(p7),{key:1,class:"w-5 h-5"}))],10,k8)),m(ge)?(v(),y("button",{key:2,class:"flex-shrink-0 h-10 w-10 inline-flex items-center justify-center p-0 rounded bg-retro-red/20 text-retro-red hover:bg-retro-red/30 transition-colors",onClick:it},[ee(m(g7),{class:"w-5 h-5"})])):F("",!0)]),ye[6]||(ye[6]=d("div",{class:"mt-1 hidden text-xs font-mono text-retro-muted sm:block"}," Press Enter to send (or queue while AI is responding), Shift+Enter for new line. Slash commands: `/context`, `/reset`, `/new`, `/clear`, `/spec-search`. ",-1))]))}}),S8={class:"h-64 border-t border-retro-border bg-retro-dark/50 flex flex-col"},$8={class:"h-9 flex items-center justify-between px-3 border-b border-retro-border/40"},C8={key:0,class:"flex-1 flex items-center justify-center text-xs font-mono text-retro-muted"},Q8={key:1,class:"flex-1 overflow-y-auto scrollbar-custom"},P8={class:"flex items-center gap-2 text-[10px] font-mono"},T8={class:"text-retro-muted"},M8={class:"text-retro-muted"},A8={class:"text-retro-green truncate"},_8={class:"mt-1 text-[11px] font-mono text-retro-text whitespace-pre-wrap break-words"},R8=Ve({__name:"ChatDebugPanel",setup(r){const e=vr(),{debugEvents:t}=W1(e);function n(i){return new Date(i).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function s(i){return i==="in"?"text-retro-cyan":i==="out"?"text-retro-yellow":"text-retro-muted"}return(i,o)=>(v(),y("div",S8,[d("div",$8,[o[1]||(o[1]=d("div",{class:"text-[11px] font-mono text-retro-text"}," Debug Stream (CLI/Provider) ",-1)),d("button",{class:"p-1 rounded hover:bg-retro-panel transition-colors",title:"Clear debug events",onClick:o[0]||(o[0]=a=>m(e).clearDebugEvents())},[ee(m(vn),{class:"w-3.5 h-3.5 text-retro-muted"})])]),m(t).length===0?(v(),y("div",C8," No debug events yet ")):(v(),y("div",Q8,[(v(!0),y(we,null,Ne(m(t),a=>(v(),y("div",{key:a.id,class:"px-3 py-2 border-b border-retro-border/20"},[d("div",P8,[d("span",T8,A(n(a.timestamp)),1),d("span",{class:_e(s(a.direction))},A(a.direction.toUpperCase()),3),d("span",M8,A(a.channel),1),d("span",A8,A(a.eventType),1)]),d("pre",_8,A(a.payload),1)]))),128))]))]))}}),B8={class:"px-4 py-3 border-b border-retro-border bg-retro-dark/80 space-y-3"},Z8={class:"flex items-center justify-between"},E8={class:"space-y-1 text-xs font-mono"},D8={class:"flex items-center gap-2"},L8={class:"relative"},X8=["disabled"],I8=["value"],V8=["value"],z8={class:"flex items-center gap-2"},N8={class:"text-retro-text"},W8={class:"relative"},q8=["disabled"],j8=["disabled"],Y8={key:0,class:"flex items-center justify-between gap-3 rounded border border-retro-border bg-retro-black px-2 py-1.5 text-xs font-mono"},F8={class:"min-w-0"},U8={class:"flex items-center gap-2"},G8={class:"text-retro-text truncate"},H8={key:0,class:"mt-0.5 text-retro-red truncate"},K8={class:"flex items-center gap-2"},J8=["disabled"],eZ=["disabled"],tZ=Ve({__name:"FinalizeConfirm",props:{baseBranch:{},worktreeBranch:{},worktreePath:{}},emits:["confirm","cancel"],setup(r,{emit:e}){const t=r,n=e,s=P(""),i=P(null),o=P(!1),a=P(!1),l=P("idle"),c=P(""),u=P(null),h=P(Bo(t.baseBranch)?t.baseBranch:""),f=P([]),p=P(!1),g=P(null),O=J(()=>_1(h.value||t.baseBranch));async function b(){if(a.value)return;a.value=!0,l.value="running",c.value="";const w=new AbortController;u.value=w;try{const S=await $fetch("/api/chat/generate-commit-message",{method:"POST",signal:w.signal,body:{conversationId:t.worktreePath.split("/").pop()?.replace("sc-","")||"",worktreePath:t.worktreePath,worktreeBranch:t.worktreeBranch,baseBranch:h.value||t.baseBranch}});S.success&&S.message?(s.value=S.message,l.value="done"):(l.value="error",c.value=S.error||"Failed to generate commit message")}catch(S){w.signal.aborted?l.value="aborted":(l.value="error",c.value=S instanceof Error?S.message:String(S))}finally{a.value=!1,u.value===w&&(u.value=null)}}function x(){u.value?.abort()}gt(async()=>{const w=(async()=>{try{const Q=t.worktreePath.split("/").pop()||"",L=await $fetch(`/api/commits/${encodeURIComponent(Q)}`,{params:{workingDirectory:t.worktreePath}});i.value=L.aheadCount}catch{i.value=null}})(),S=(async()=>{p.value=!0;try{const Q=t.worktreePath||(await $fetch("/api/cwd")).cwd,L=await $fetch("/api/git/branches",{query:{workingDirectory:Q}});f.value=L.branches.filter(G=>!G.isRemote&&!G.name.startsWith("sc/")).map(Ih).filter(G=>!!G);const D=Xh(h.value||t.baseBranch,f.value);D&&(h.value=D)}catch{f.value=[]}finally{p.value=!1}})();await Promise.all([w,S]),It(()=>g.value?.focus())});function k(){!s.value.trim()||!h.value||(o.value=!0,n("confirm",s.value.trim(),h.value))}return(w,S)=>(v(),y("div",B8,[d("div",Z8,[S[4]||(S[4]=d("span",{class:"text-xs font-mono text-retro-text font-semibold uppercase tracking-wide"}," Finalize ",-1)),d("button",{type:"button",class:"p-0.5 text-retro-muted hover:text-retro-text transition-colors",title:"Cancel",onClick:S[0]||(S[0]=Q=>n("cancel"))},[ee(m(St),{class:"w-4 h-4"})])]),d("div",E8,[d("div",D8,[S[5]||(S[5]=d("span",{class:"text-retro-muted"},"target:",-1)),d("div",L8,[je(d("select",{"onUpdate:modelValue":S[1]||(S[1]=Q=>h.value=Q),disabled:o.value||p.value,class:"appearance-none bg-retro-black border border-retro-border rounded px-2 py-0.5 pr-6 text-xs font-mono text-retro-cyan focus:outline-none focus:border-retro-cyan cursor-pointer disabled:opacity-40"},[p.value?(v(),y("option",{key:0,value:h.value},A(O.value),9,I8)):F("",!0),(v(!0),y(we,null,Ne(f.value,Q=>(v(),y("option",{key:Q,value:Q},A(Q),9,V8))),128))],8,X8),[[ks,h.value]]),ee(m(Ru),{class:"absolute right-1 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-retro-muted pointer-events-none"})])]),d("div",z8,[S[6]||(S[6]=d("span",{class:"text-retro-muted"},"commits:",-1)),d("span",N8,A(i.value!==null?i.value:"..."),1)])]),d("div",W8,[je(d("textarea",{ref_key:"textareaRef",ref:g,"onUpdate:modelValue":S[2]||(S[2]=Q=>s.value=Q),placeholder:"Squash commit message...",rows:"2",class:"w-full px-2 py-1.5 pr-8 text-xs font-mono bg-retro-black border border-retro-border rounded text-retro-text placeholder-retro-subtle focus:outline-none focus:border-retro-cyan resize-none",disabled:o.value||a.value},null,8,q8),[[Rt,s.value]]),d("button",{type:"button",disabled:o.value||a.value||p.value||!h.value,class:"absolute right-1.5 top-1.5 p-0.5 rounded text-retro-muted hover:text-retro-cyan transition-colors disabled:opacity-40",title:"Generate commit message",onClick:b},[ee(m(ji),{class:_e(["w-4 h-4",{"animate-spin":a.value}])},null,8,["class"])],8,j8)]),l.value!=="idle"?(v(),y("div",Y8,[d("div",F8,[d("div",U8,[ee(m(ji),{class:_e(["w-3.5 h-3.5 text-retro-cyan shrink-0",{"animate-spin":l.value==="running"}])},null,8,["class"]),d("span",G8,A(l.value==="running"?`Generating from ${h.value}...`:l.value==="done"?"Commit message generated":l.value==="aborted"?"Generation stopped":"Generation failed"),1)]),c.value?(v(),y("div",H8,A(c.value),1)):F("",!0)]),l.value==="running"?(v(),y("button",{key:0,type:"button",class:"shrink-0 p-0.5 rounded text-retro-muted hover:text-retro-red transition-colors",title:"Stop generation",onClick:x},[ee(m(pp),{class:"w-4 h-4"})])):F("",!0)])):F("",!0),d("div",K8,[d("button",{type:"button",disabled:!s.value.trim()||!h.value||o.value,class:"flex items-center gap-1 px-3 py-1 text-xs font-mono rounded border transition-colors bg-retro-green/10 border-retro-green/50 text-retro-green hover:bg-retro-green/20 disabled:opacity-40 disabled:cursor-not-allowed",onClick:k},[ee(m(_u),{class:"w-3.5 h-3.5"}),Ie(" "+A(o.value?"Finalizing...":"Confirm"),1)],8,J8),d("button",{type:"button",disabled:o.value,class:"px-3 py-1 text-xs font-mono rounded border border-retro-border text-retro-muted hover:text-retro-text hover:border-retro-text/30 transition-colors disabled:opacity-40",onClick:S[3]||(S[3]=Q=>n("cancel"))}," Cancel ",8,eZ)])]))}}),rZ={class:"px-4 py-3 border-b border-retro-border bg-retro-dark/80 space-y-3"},nZ={class:"flex items-center justify-between"},sZ={class:"space-y-1 text-xs font-mono"},iZ={class:"flex items-center gap-2"},oZ={class:"text-retro-cyan"},aZ={class:"flex items-center gap-2"},lZ={class:"relative"},cZ=["disabled"],uZ=["value"],hZ=["value"],dZ={class:"flex items-center gap-2"},fZ={class:"text-retro-text"},mZ={class:"flex items-center gap-2"},pZ=["disabled"],gZ=["disabled"],OZ=Ve({__name:"RebaseConfirm",props:{baseBranch:{},worktreeBranch:{},worktreePath:{}},emits:["confirm","cancel"],setup(r,{emit:e}){const t=r,n=e,s=P(null),i=P(!1),o=P(Bo(t.baseBranch)?t.baseBranch:""),a=P([]),l=P(!1),c=J(()=>_1(o.value||t.baseBranch));async function u(f){if(!f){s.value=null;return}try{const p=await $fetch("/api/chat/compare",{params:{worktreePath:t.worktreePath,baseBranch:f}});s.value=p.ahead}catch{s.value=null}}gt(async()=>{const f=u(o.value),p=(async()=>{l.value=!0;try{const g=t.worktreePath||(await $fetch("/api/cwd")).cwd,O=await $fetch("/api/git/branches",{query:{workingDirectory:g}});a.value=O.branches.filter(x=>!x.isRemote&&!x.name.startsWith("sc/")).map(Ih).filter(x=>!!x);const b=Xh(o.value||t.baseBranch,a.value);b&&(o.value=b)}catch{a.value=[]}finally{l.value=!1}})();await Promise.all([f,p])}),ze(o,f=>{u(f)});function h(){o.value&&(i.value=!0,n("confirm",o.value))}return(f,p)=>(v(),y("div",rZ,[d("div",nZ,[p[3]||(p[3]=d("span",{class:"text-xs font-mono text-retro-text font-semibold uppercase tracking-wide"}," Rebase Worktree ",-1)),d("button",{type:"button",class:"p-0.5 text-retro-muted hover:text-retro-text transition-colors",title:"Cancel",onClick:p[0]||(p[0]=g=>n("cancel"))},[ee(m(St),{class:"w-4 h-4"})])]),d("div",sZ,[d("div",iZ,[p[4]||(p[4]=d("span",{class:"text-retro-muted"},"worktree:",-1)),d("span",oZ,A(r.worktreeBranch),1)]),d("div",aZ,[p[5]||(p[5]=d("span",{class:"text-retro-muted"},"target:",-1)),d("div",lZ,[je(d("select",{"onUpdate:modelValue":p[1]||(p[1]=g=>o.value=g),disabled:i.value||l.value,class:"appearance-none bg-retro-black border border-retro-border rounded px-2 py-0.5 pr-6 text-xs font-mono text-retro-cyan focus:outline-none focus:border-retro-cyan cursor-pointer disabled:opacity-40"},[l.value?(v(),y("option",{key:0,value:o.value},A(c.value),9,uZ)):F("",!0),(v(!0),y(we,null,Ne(a.value,g=>(v(),y("option",{key:g,value:g},A(g),9,hZ))),128))],8,cZ),[[ks,o.value]]),ee(m(Ru),{class:"absolute right-1 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-retro-muted pointer-events-none"})])]),d("div",dZ,[p[6]||(p[6]=d("span",{class:"text-retro-muted"},"commits ahead:",-1)),d("span",fZ,A(s.value!==null?s.value:"..."),1)])]),d("div",mZ,[d("button",{type:"button",disabled:i.value||!o.value,class:"flex items-center gap-1 px-3 py-1 text-xs font-mono rounded border transition-colors bg-retro-cyan/10 border-retro-cyan/50 text-retro-cyan hover:bg-retro-cyan/20 disabled:opacity-40 disabled:cursor-not-allowed",onClick:h},[ee(m(_u),{class:"w-3.5 h-3.5"}),Ie(" "+A(i.value?"Rebasing...":"Confirm"),1)],8,pZ),d("button",{type:"button",disabled:i.value,class:"px-3 py-1 text-xs font-mono rounded border border-retro-border text-retro-muted hover:text-retro-text hover:border-retro-text/30 transition-colors disabled:opacity-40",onClick:p[2]||(p[2]=g=>n("cancel"))}," Cancel ",8,gZ)])]))}}),vZ={class:"flex-1 flex flex-col overflow-hidden"},bZ={class:"flex-shrink-0 px-4 py-2 border-b border-retro-border flex items-center justify-between bg-retro-dark"},xZ={class:"text-xs font-mono text-retro-text truncate"},yZ={class:"flex items-center gap-2 flex-shrink-0"},kZ={key:0,class:"text-xs font-mono text-retro-green"},wZ={key:1,class:"text-[11px] font-mono text-retro-muted"},SZ={key:0,class:"flex items-center justify-center h-full text-retro-muted text-xs font-mono"},$Z=["innerHTML"],CZ={key:0,class:"flex-shrink-0 px-4 py-2 border-t border-retro-border bg-retro-yellow/10 text-retro-yellow text-xs font-mono"},QZ=Ve({__name:"ConflictFileEditor",props:{file:{},resolved:{type:Boolean},isAiResolving:{type:Boolean},strategy:{}},emits:["resolve","aiResolve","retry"],setup(r,{emit:e}){const t=r;P(t.file.content);const n=P(""),s=P(!1);ze(()=>t.file.path,()=>{a()}),ze(()=>t.file.content,()=>{a()});const i=J(()=>{const c=/^<{7}\s/gm;return(t.file.content.match(c)||[]).length});function o(c){const u=c.split(".").pop()?.toLowerCase()||"";return{ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",vue:"vue",html:"html",css:"css",scss:"scss",less:"less",json:"json",yaml:"yaml",yml:"yaml",md:"markdown",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",sh:"bash",zsh:"bash",sql:"sql",graphql:"graphql",xml:"xml",svg:"xml",toml:"toml",ini:"ini",dockerfile:"dockerfile"}[u]||"text"}async function a(){s.value=!0;try{const{codeToHtml:c}=await ds(async()=>{const{codeToHtml:x}=await import("./BpYxF7v5.js");return{codeToHtml:x}},__vite__mapDeps([3,1,2]),import.meta.url),u=o(t.file.path),f=t.file.content.split(`
73
73
  `);let p="",g=!1,O=!1,b=0;for(const x of f){b++;const k=/^<{7}\s/.test(x),w=/^={7}$/.test(x),S=/^>{7}\s/.test(x);if(k){g=!0,O=!1,p+=`<div class="conflict-line conflict-marker-line" data-line="${b}"><span class="line-number">${b}</span><span class="line-content conflict-marker">${l(x)}</span></div>
74
74
  `;continue}if(w&&g){g=!1,O=!0,p+=`<div class="conflict-line conflict-marker-line" data-line="${b}"><span class="line-number">${b}</span><span class="line-content conflict-marker">${l(x)}</span></div>
75
75
  `;continue}if(S){O=!1,p+=`<div class="conflict-line conflict-marker-line" data-line="${b}"><span class="line-number">${b}</span><span class="line-content conflict-marker">${l(x)}</span></div>