@mrpatronz/nexusflow 2.17.0 → 2.18.1

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 (77) hide show
  1. package/README.md +2 -0
  2. package/dist/agent/AcpCliAdapter.d.ts +2 -0
  3. package/dist/agent/AcpCliAdapter.d.ts.map +1 -1
  4. package/dist/agent/AcpCliAdapter.js +45 -0
  5. package/dist/agent/AcpCliAdapter.js.map +1 -1
  6. package/dist/agent/AntigravityCliAdapter.d.ts +6 -1
  7. package/dist/agent/AntigravityCliAdapter.d.ts.map +1 -1
  8. package/dist/agent/AntigravityCliAdapter.js +117 -12
  9. package/dist/agent/AntigravityCliAdapter.js.map +1 -1
  10. package/dist/agent/ClaudeCliAdapter.d.ts +6 -0
  11. package/dist/agent/ClaudeCliAdapter.d.ts.map +1 -1
  12. package/dist/agent/ClaudeCliAdapter.js +104 -6
  13. package/dist/agent/ClaudeCliAdapter.js.map +1 -1
  14. package/dist/agent/ClaudeSdkAdapter.d.ts.map +1 -1
  15. package/dist/agent/ClaudeSdkAdapter.js +3 -0
  16. package/dist/agent/ClaudeSdkAdapter.js.map +1 -1
  17. package/dist/agent/CodexCliAdapter.d.ts +3 -0
  18. package/dist/agent/CodexCliAdapter.d.ts.map +1 -1
  19. package/dist/agent/CodexCliAdapter.js +26 -1
  20. package/dist/agent/CodexCliAdapter.js.map +1 -1
  21. package/dist/agent/ProviderRegistry.d.ts +1 -1
  22. package/dist/agent/ProviderRegistry.d.ts.map +1 -1
  23. package/dist/agent/ProviderRegistry.js.map +1 -1
  24. package/dist/agent/TurnSessionManager.d.ts +3 -0
  25. package/dist/agent/TurnSessionManager.d.ts.map +1 -1
  26. package/dist/agent/TurnSessionManager.js +78 -2
  27. package/dist/agent/TurnSessionManager.js.map +1 -1
  28. package/dist/commands/status.d.ts.map +1 -1
  29. package/dist/commands/status.js +35 -0
  30. package/dist/commands/status.js.map +1 -1
  31. package/dist/core/config-schema.d.ts +1 -1
  32. package/dist/core/root-documents.d.ts +12 -0
  33. package/dist/core/root-documents.d.ts.map +1 -1
  34. package/dist/core/root-documents.js +4 -2
  35. package/dist/core/root-documents.js.map +1 -1
  36. package/dist/gui/assets/{AgentsPage-vWomDhqY.js → AgentsPage-B9ejJYsf.js} +2 -2
  37. package/dist/gui/assets/{DashboardPage-D2LQg1es.js → DashboardPage-BwwB7uTm.js} +1 -1
  38. package/dist/gui/assets/DocumentPreview-CtylgIF0.js +3 -0
  39. package/dist/gui/assets/{GettingStartedPage-BYPdHlcN.js → GettingStartedPage-BM8m5uir.js} +1 -1
  40. package/dist/gui/assets/{MonacoDiffAdapter-ClvAYSFE.js → MonacoDiffAdapter-DHYIkG2a.js} +1 -1
  41. package/dist/gui/assets/{ProjectsPage-DdFVpbr7.js → ProjectsPage-CNZF11wO.js} +1 -1
  42. package/dist/gui/assets/{ScaffoldRepoInline-BvOKUfOp.js → ScaffoldRepoInline-B5qMbiRV.js} +1 -1
  43. package/dist/gui/assets/{SettingsPage-BtRA38LZ.js → SettingsPage-S68Q-rBG.js} +1 -1
  44. package/dist/gui/assets/{SkillsPage-Dc8TrRyw.js → SkillsPage-B97Al8vk.js} +4 -4
  45. package/dist/gui/assets/StartWorkPage-Dq0Ke4hS.js +1 -0
  46. package/dist/gui/assets/{StrategiesPage-GkFROjyC.js → StrategiesPage-INv0HW7D.js} +2 -2
  47. package/dist/gui/assets/WorkroomsPage-uCiHE87E.js +4 -0
  48. package/dist/gui/assets/WorkspacesPage-CAHQrIgk.js +13 -0
  49. package/dist/gui/assets/alert-dialog-B-6-jHIr.js +1 -0
  50. package/dist/gui/assets/index-BzqpMUfC.css +2 -0
  51. package/dist/gui/assets/{index-DNNQAjn6.js → index-DmbV3DA2.js} +8 -8
  52. package/dist/gui/assets/{queries-DdbBkqm6.js → queries-CJBjicdw.js} +1 -1
  53. package/dist/gui/assets/{tabs-D7v4Yq0P.js → tabs-CJ2imrHY.js} +1 -1
  54. package/dist/gui/index.html +3 -3
  55. package/dist/harness/claude.d.ts.map +1 -1
  56. package/dist/harness/claude.js +92 -7
  57. package/dist/harness/claude.js.map +1 -1
  58. package/dist/harness/codex.d.ts.map +1 -1
  59. package/dist/harness/codex.js +21 -4
  60. package/dist/harness/codex.js.map +1 -1
  61. package/dist/harness/types.d.ts +58 -2
  62. package/dist/harness/types.d.ts.map +1 -1
  63. package/dist/http/work-guidance-routes.js +1 -1
  64. package/dist/http/work-guidance-routes.js.map +1 -1
  65. package/dist/types.d.ts +8 -0
  66. package/dist/types.d.ts.map +1 -1
  67. package/dist/utils/session-finder.d.ts +6 -1
  68. package/dist/utils/session-finder.d.ts.map +1 -1
  69. package/dist/utils/session-finder.js +226 -0
  70. package/dist/utils/session-finder.js.map +1 -1
  71. package/dist/workrooms/store.d.ts +1 -1
  72. package/package.json +1 -1
  73. package/dist/gui/assets/StartWorkPage-BJ7EYD7t.js +0 -1
  74. package/dist/gui/assets/WorkroomsPage-DZVZcvUV.js +0 -4
  75. package/dist/gui/assets/WorkspacesPage-DefIfu1l.js +0 -13
  76. package/dist/gui/assets/alert-dialog-B_TU2TCX.js +0 -1
  77. package/dist/gui/assets/index-CQGZNI9n.css +0 -2
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MonacoDiffAdapter-ClvAYSFE.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-DE3RlOCf.js","assets/monaco-DLwhzYMT.js","assets/monaco-d9IpiNv7.css","assets/DashboardPage-D2LQg1es.js","assets/queries-DdbBkqm6.js","assets/button-BrcP8Wxx.js","assets/brand-hHByyyzq.js","assets/client-B5szthbF.js","assets/status-CKOvrZ16.js","assets/card-BMggHY3n.js","assets/ProjectsPage-DdFVpbr7.js","assets/badge-BObbahyU.js","assets/ScaffoldRepoInline-BvOKUfOp.js","assets/useValueChanged-DfJmRF2P.js","assets/useAriaLabelledBy-DAWGcnTk.js","assets/trash-2-BrrLX4tD.js","assets/alert-dialog-B_TU2TCX.js","assets/SettingsPage-BtRA38LZ.js","assets/label-C610MHwq.js","assets/alert-CHAmIFAx.js","assets/SkillsPage-Dc8TrRyw.js","assets/chevron-down-Dy03VL1q.js","assets/square-check-big-DpHMT26q.js","assets/shield-check-FLrrAOFP.js","assets/AgentsPage-vWomDhqY.js","assets/WorkroomsPage-DZVZcvUV.js","assets/tabs-D7v4Yq0P.js","assets/isElementDisabled-BONWqXlb.js","assets/StartWorkPage-BJ7EYD7t.js","assets/vsc-EOWFTqft.js","assets/StrategiesPage-GkFROjyC.js","assets/circle-plus-D0tjHKM4.js","assets/WorkspacesPage-DefIfu1l.js","assets/GettingStartedPage-BYPdHlcN.js"])))=>i.map(i=>d[i]);
2
- import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{n as r,t as i}from"./jsx-runtime-DE3RlOCf.js";import{$ as a,$t as o,A as s,At as c,B as l,Bn as u,C as d,Ct as f,Dn as p,Dt as m,En as h,Et as g,F as _,G as v,Gn as y,Gt as b,H as x,Ht as S,I as C,J as w,Jn as T,Jt as E,K as D,Kn as ee,Kt as O,L as k,Ln as A,M as te,Mn as j,Mt as M,N,Nt as ne,O as re,On as ie,P,Pn as F,Q as I,R as L,Rt as ae,St as R,Tt as oe,U as z,Un as se,Ut as ce,V as le,Vn as ue,W as de,Wn as fe,Wt as pe,X as me,Xt as he,Y as ge,Yn as _e,Yt as ve,Z as ye,Zt as be,_ as xe,_n as Se,a as Ce,at as we,bn as Te,bt as Ee,c as De,cn as Oe,ct as ke,d as Ae,dt as je,et as Me,f as Ne,ft as Pe,g as Fe,gn as Ie,h as Le,i as Re,in as ze,it as Be,j as Ve,jn as He,jt as Ue,k as We,kt as Ge,l as Ke,lt as qe,m as Je,n as Ye,nn as Xe,nt as Ze,o as Qe,on as $e,p as et,q as tt,qn as nt,qt as rt,r as it,rn as at,s as ot,sn as st,st as ct,t as lt,tn as ut,tt as dt,u as ft,ut as pt,v as mt,wt as ht,xn as gt,xt as _t,yn as vt,yt,z as bt,zn as xt,zt as St}from"./badge-BObbahyU.js";import{$ as Ct,B as wt,C as Tt,F as Et,G as Dt,J as Ot,K as kt,P as At,R as jt,U as Mt,V as Nt,W as Pt,X as Ft,Y as It,Z as Lt,_ as Rt,_t as zt,at as Bt,ct as Vt,dt as Ht,et as Ut,ft as Wt,gt as Gt,h as Kt,ht as qt,it as Jt,k as Yt,lt as Xt,mt as Zt,n as Qt,nt as $t,ot as en,pt as tn,q as nn,rt as rn,st as an,tt as on,ut as sn,vt as cn}from"./queries-DdbBkqm6.js";import{c as ln,d as un,f as dn,h as fn,i as pn,l as mn,m as B,n as hn,o as gn,p as _n,s as vn,t as yn}from"./button-BrcP8Wxx.js";import{t as bn}from"./chevron-down-Dy03VL1q.js";import{a as xn,b as Sn,c as Cn,d as wn,f as Tn,g as En,h as Dn,i as On,l as kn,m as An,n as jn,o as Mn,p as Nn,r as Pn,s as Fn,t as In,v as Ln,x as Rn}from"./isElementDisabled-BONWqXlb.js";import{a as zn,g as Bn,i as Vn,m as Hn,o as Un,s as Wn,t as Gn}from"./status-CKOvrZ16.js";import{o as Kn}from"./monaco-DLwhzYMT.js";import{t as qn}from"./useValueChanged-DfJmRF2P.js";import{_ as Jn,a as Yn,f as Xn,h as Zn,i as Qn,l as $n,n as er,p as tr,r as nr,t as rr,u as ir,v as ar,y as or}from"./brand-hHByyyzq.js";import{n as sr}from"./client-B5szthbF.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var cr=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,ee());else{var t=n(l);t!==null&&A(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&A(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ee():S=!1}}}var ee;if(typeof y==`function`)ee=function(){y(D)};else if(typeof MessageChannel<`u`){var O=new MessageChannel,k=O.port2;O.port1.onmessage=D,ee=function(){k.postMessage(null)}}else ee=function(){_(D,0)};function A(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,A(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ee()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),lr=n(((e,t)=>{t.exports=cr()})),ur=n((e=>{var t=lr(),n=r(),i=_e();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function c(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(s(e)!==e)throw Error(a(188))}function d(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return u(i),e;if(o===r)return u(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var c=!1,l=i.child;l;){if(l===n){c=!0,n=i,r=o;break}if(l===r){c=!0,r=i,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=i;break}if(l===r){c=!0,r=o,n=i;break}l=l.sibling}if(!c)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,m=Symbol.for(`react.element`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),ee=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function te(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?te(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return te(e(t))}catch{}}return null}var j=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},re=[],ie=-1;function P(e){return{current:e}}function F(e){0>ie||(e.current=re[ie],re[ie]=null,ie--)}function I(e,t){ie++,re[ie]=e.current,e.current=t}var L=P(null),ae=P(null),R=P(null),oe=P(null);function z(e,t){switch(I(R,t),I(ae,e),I(L,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Zd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Zd(t),e=Qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}F(L),I(L,e)}function se(){F(L),F(ae),F(R)}function ce(e){e.memoizedState!==null&&I(oe,e);var t=L.current,n=Qd(t,e.type);t!==n&&(I(ae,e),I(L,n))}function le(e){ae.current===e&&(F(L),F(ae)),oe.current===e&&(F(oe),cp._currentValue=ne)}var ue,de;function fe(e){if(ue===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ue=t&&t[1]||``,de=-1<e.stack.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MonacoDiffAdapter-DHYIkG2a.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-DE3RlOCf.js","assets/monaco-DLwhzYMT.js","assets/monaco-d9IpiNv7.css","assets/DocumentPreview-CtylgIF0.js","assets/DashboardPage-BwwB7uTm.js","assets/queries-CJBjicdw.js","assets/button-BrcP8Wxx.js","assets/brand-hHByyyzq.js","assets/client-B5szthbF.js","assets/status-CKOvrZ16.js","assets/card-BMggHY3n.js","assets/ProjectsPage-CNZF11wO.js","assets/badge-BObbahyU.js","assets/ScaffoldRepoInline-B5qMbiRV.js","assets/useValueChanged-DfJmRF2P.js","assets/useAriaLabelledBy-DAWGcnTk.js","assets/trash-2-BrrLX4tD.js","assets/alert-dialog-B-6-jHIr.js","assets/SettingsPage-S68Q-rBG.js","assets/label-C610MHwq.js","assets/alert-CHAmIFAx.js","assets/SkillsPage-B97Al8vk.js","assets/chevron-down-Dy03VL1q.js","assets/square-check-big-DpHMT26q.js","assets/shield-check-FLrrAOFP.js","assets/AgentsPage-B9ejJYsf.js","assets/WorkroomsPage-uCiHE87E.js","assets/tabs-CJ2imrHY.js","assets/isElementDisabled-BONWqXlb.js","assets/StartWorkPage-Dq0Ke4hS.js","assets/vsc-EOWFTqft.js","assets/StrategiesPage-INv0HW7D.js","assets/circle-plus-D0tjHKM4.js","assets/WorkspacesPage-CAHQrIgk.js","assets/GettingStartedPage-BM8m5uir.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{n as r,t as i}from"./jsx-runtime-DE3RlOCf.js";import{$ as a,$t as o,A as s,At as c,B as l,Bn as u,C as d,Ct as f,Dn as p,Dt as m,En as h,Et as g,F as _,G as v,Gn as y,Gt as b,H as x,Ht as S,I as C,J as w,Jn as T,Jt as E,K as D,Kn as ee,Kt as O,L as k,Ln as A,M as te,Mn as j,Mt as M,N,Nt as ne,O as re,On as ie,P,Pn as F,Q as I,R as L,Rt as ae,St as R,Tt as oe,U as z,Un as se,Ut as ce,V as le,Vn as ue,W as de,Wn as fe,Wt as pe,X as me,Xt as he,Y as ge,Yn as _e,Yt as ve,Z as ye,Zt as be,_ as xe,_n as Se,a as Ce,at as we,bn as Te,bt as Ee,c as De,cn as Oe,ct as ke,d as Ae,dt as je,et as Me,f as Ne,ft as Pe,g as Fe,gn as Ie,h as Le,i as Re,in as ze,it as Be,j as Ve,jn as He,jt as Ue,k as We,kt as Ge,l as Ke,lt as qe,m as Je,n as Ye,nn as Xe,nt as Ze,o as Qe,on as $e,p as et,q as tt,qn as nt,qt as rt,r as it,rn as at,s as ot,sn as st,st as ct,t as lt,tn as ut,tt as dt,u as ft,ut as pt,v as mt,wt as ht,xn as gt,xt as _t,yn as vt,yt,z as bt,zn as xt,zt as St}from"./badge-BObbahyU.js";import{$ as Ct,B as wt,C as Tt,F as Et,G as Dt,J as Ot,K as kt,P as At,R as jt,U as Mt,V as Nt,W as Pt,X as Ft,Y as It,Z as Lt,_ as Rt,_t as zt,at as Bt,ct as Vt,dt as Ht,et as Ut,ft as Wt,gt as Gt,h as Kt,ht as qt,it as Jt,k as Yt,lt as Xt,mt as Zt,n as Qt,nt as $t,ot as en,pt as tn,q as nn,rt as rn,st as an,tt as on,ut as sn,vt as cn}from"./queries-CJBjicdw.js";import{c as ln,d as un,f as dn,h as fn,i as pn,l as mn,m as B,n as hn,o as gn,p as _n,s as vn,t as yn}from"./button-BrcP8Wxx.js";import{t as bn}from"./chevron-down-Dy03VL1q.js";import{a as xn,b as Sn,c as Cn,d as wn,f as Tn,g as En,h as Dn,i as On,l as kn,m as An,n as jn,o as Mn,p as Nn,r as Pn,s as Fn,t as In,v as Ln,x as Rn}from"./isElementDisabled-BONWqXlb.js";import{a as zn,g as Bn,i as Vn,m as Hn,o as Un,s as Wn,t as Gn}from"./status-CKOvrZ16.js";import{o as Kn}from"./monaco-DLwhzYMT.js";import{t as qn}from"./useValueChanged-DfJmRF2P.js";import{_ as Jn,a as Yn,f as Xn,h as Zn,i as Qn,l as $n,n as er,p as tr,r as nr,t as rr,u as ir,v as ar,y as or}from"./brand-hHByyyzq.js";import{n as sr}from"./client-B5szthbF.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var cr=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,ee());else{var t=n(l);t!==null&&A(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&A(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ee():S=!1}}}var ee;if(typeof y==`function`)ee=function(){y(D)};else if(typeof MessageChannel<`u`){var O=new MessageChannel,k=O.port2;O.port1.onmessage=D,ee=function(){k.postMessage(null)}}else ee=function(){_(D,0)};function A(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,A(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ee()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),lr=n(((e,t)=>{t.exports=cr()})),ur=n((e=>{var t=lr(),n=r(),i=_e();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function c(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(s(e)!==e)throw Error(a(188))}function d(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return u(i),e;if(o===r)return u(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var c=!1,l=i.child;l;){if(l===n){c=!0,n=i,r=o;break}if(l===r){c=!0,r=i,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=i;break}if(l===r){c=!0,r=o,n=i;break}l=l.sibling}if(!c)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,m=Symbol.for(`react.element`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),ee=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function te(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?te(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return te(e(t))}catch{}}return null}var j=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},re=[],ie=-1;function P(e){return{current:e}}function F(e){0>ie||(e.current=re[ie],re[ie]=null,ie--)}function I(e,t){ie++,re[ie]=e.current,e.current=t}var L=P(null),ae=P(null),R=P(null),oe=P(null);function z(e,t){switch(I(R,t),I(ae,e),I(L,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Zd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Zd(t),e=Qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}F(L),I(L,e)}function se(){F(L),F(ae),F(R)}function ce(e){e.memoizedState!==null&&I(oe,e);var t=L.current,n=Qd(t,e.type);t!==n&&(I(ae,e),I(L,n))}function le(e){ae.current===e&&(F(L),F(ae)),oe.current===e&&(F(oe),cp._currentValue=ne)}var ue,de;function fe(e){if(ue===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ue=t&&t[1]||``,de=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+ue+e+de}var pe=!1;function me(e,t){if(!e||pe)return``;pe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
5
  `),l=s.split(`
@@ -37,9 +37,9 @@ Error generating stack: `+e.message+`
37
37
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
38
38
  `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return gg(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=p_.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function C_(){return{exit:{taskListCheckValueChecked:T_,taskListCheckValueUnchecked:T_,paragraph:E_}}}function w_(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:D_}}}function T_(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function E_(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function D_(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=p_.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function O_(){return[Ph(),ig(),lg(),m_(),C_()]}function k_(e){return{extensions:[Fh(),ag(e),ug(),S_(e),w_()]}}var A_={tokenize:W_,partial:!0},j_={tokenize:G_,partial:!0},M_={tokenize:K_,partial:!0},N_={tokenize:q_,partial:!0},P_={tokenize:J_,partial:!0},F_={name:`wwwAutolink`,tokenize:H_,previous:Y_},I_={name:`protocolAutolink`,tokenize:U_,previous:X_},L_={name:`emailAutolink`,tokenize:V_,previous:Z_},R_={};function z_(){return{text:R_}}for(var B_=48;B_<123;)R_[B_]=L_,B_++,B_===58?B_=65:B_===91&&(B_=97);R_[43]=L_,R_[45]=L_,R_[46]=L_,R_[95]=L_,R_[72]=[L_,I_],R_[104]=[L_,I_],R_[87]=[L_,F_],R_[119]=[L_,F_];function V_(e,t,n){let r=this,i,a;return o;function o(t){return!Q_(t)||!Z_.call(r,r.previous)||$_(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Q_(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(P_,u,l)(t):t===45||t===95||Mu(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&ju(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function H_(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Y_.call(r,r.previous)||$_(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(A_,e.attempt(j_,e.attempt(M_,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function U_(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&X_.call(r,r.previous)&&!$_(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(ju(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Pu(t)||zu(t)||Hu(t)||Vu(t)?n(t):e.attempt(j_,e.attempt(M_,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function W_(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function G_(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(N_,c,s)(t):t===null||zu(t)||Hu(t)||t!==45&&Vu(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function K_(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(N_,t,a)(o):o===null||zu(o)||Hu(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function q_(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||zu(o)||Hu(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||zu(e)||Hu(e)?t(e):r(e)}function a(e){return ju(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):ju(t)?(e.consume(t),o):n(t)}}function J_(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Mu(e)?n(e):t(e)}}function Y_(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||zu(e)}function X_(e){return!ju(e)}function Z_(e){return!(e===47||Q_(e))}function Q_(e){return e===43||e===45||e===46||e===95||Mu(e)}function $_(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var ev={tokenize:cv,partial:!0};function tv(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:av,continuation:{tokenize:ov},exit:sv}},text:{91:{name:`gfmFootnoteCall`,tokenize:iv},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:nv,resolveTo:rv}}}}function nv(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Au(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function rv(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function iv(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||zu(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Au(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return zu(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function av(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||zu(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Au(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return zu(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),Gu(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function ov(e,t,n){return e.check(od,t,e.attempt(ev,t,n))}function sv(e){e.exit(`gfmFootnoteDefinition`)}function cv(e,t,n){let r=this;return Gu(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function lv(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Cu(o,o.length,0,$u(s,e.slice(r+1,n),t)),Cu(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Cu(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Qu(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Qu(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var uv=class{constructor(){this.map=[]}add(e,t,n){dv(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function dv(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function fv(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function pv(){return{flow:{null:{name:`table`,tokenize:mv,resolveAll:hv}}}}function mv(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):Ru(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Bu(t)?Gu(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||zu(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Bu(t)?Gu(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Bu(t)?Gu(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Ru(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Bu(t)?Gu(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Ru(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Ru(n)?(e.exit(`tableRow`),t(n)):Bu(n)?Gu(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||zu(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function hv(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new uv;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(_v(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=gv(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=gv(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=gv(f,t,o,i,n,d)):(o[0]=o[1],d=gv(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&_v(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=fv(t.events,n))}return e}function gv(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},vv(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=vv(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=vv(t.events,n[2]),a=vv(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},vv(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function _v(e,t,n,r,i){let a=[],o=vv(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function vv(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var yv={name:`tasklistCheck`,tokenize:xv};function bv(){return{text:{91:yv}}}function xv(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return zu(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Ru(r)?t(r):Bu(r)?e.check({tokenize:Sv},t,n)(r):n(r)}}function Sv(e,t,n){return Gu(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Cv(e){return Eu([z_(),tv(),lv(e),pv(),bv()])}var wv={};function Tv(e){let t=this,n=e||wv,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Cv(n)),a.push(O_()),o.push(k_(n))}var Ev=[Tv],Dv=({content:e})=>(0,H.jsx)(`div`,{className:`prose prose-sm max-w-none text-foreground prose-a:text-primary prose-code:text-foreground prose-headings:text-foreground prose-pre:border prose-pre:border-border prose-pre:bg-muted/50 prose-strong:text-foreground prose-li:marker:text-muted-foreground`,children:(0,H.jsx)(xh,{remarkPlugins:Ev,children:e})}),Ov=go,kv=so;function Av({className:e,...t}){return(0,H.jsx)(eo,{forceRender:!0,className:B(`fixed inset-0 z-50 bg-background/60 backdrop-blur-xs transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0`,e),"data-slot":`dialog-backdrop`,...t})}function jv({className:e,...t}){return(0,H.jsx)(_o,{className:B(`fixed inset-0 z-50 grid grid-rows-[1fr_auto_1fr] justify-items-center p-4`,e),"data-slot":`dialog-viewport`,...t})}function Mv({className:e,children:t,showCloseButton:n=!0,bottomStickOnMobile:r=!0,...i}){return(0,H.jsxs)(kv,{children:[(0,H.jsx)(Av,{}),(0,H.jsx)(jv,{className:B(r&&`max-sm:grid-rows-[1fr_auto] max-sm:p-0 max-sm:pt-12`),children:(0,H.jsxs)(oo,{className:B(`-translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-xl scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-xl border border-border bg-popover text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-2xl transition-[scale,opacity,translate] duration-150 ease-out will-change-transform data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0`,r&&`max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4`,e),"data-slot":`dialog-popup`,...i,children:[t,n&&(0,H.jsx)(to,{"aria-label":`Close`,className:`absolute end-2 top-2`,render:(0,H.jsx)(yn,{size:`icon`,variant:`ghost`}),children:(0,H.jsx)(Ei,{})})]})})]})}function Nv({className:e,...t}){return(0,H.jsx)(`div`,{className:B(`flex flex-col gap-2 p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pb-3 max-sm:pb-4`,e),"data-slot":`dialog-header`,...t})}function Pv({className:e,variant:t=`default`,...n}){return(0,H.jsx)(`div`,{className:B(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,t==="default"&&`border-t bg-muted/72 py-4`,t===`bare`&&`in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pt-3 pt-4 pb-6`,e),"data-slot":`dialog-footer`,...n})}function Fv({className:e,...t}){return(0,H.jsx)(vo,{className:B(`font-heading font-semibold text-xl leading-none`,e),"data-slot":`dialog-title`,...t})}function Iv({className:e,...t}){return(0,H.jsx)(no,{className:B(`text-muted-foreground text-sm`,e),"data-slot":`dialog-description`,...t})}function Lv({className:e,scrollFade:t=!0,...n}){return(0,H.jsx)(Go,{scrollFade:t,children:(0,H.jsx)(`div`,{className:B(`p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-header])]:pt-1 in-[[data-slot=dialog-popup]:has([data-slot=dialog-footer]:not(.border-t))]:pb-1`,e),"data-slot":`dialog-panel`,...n})})}function Rv({className:e,...t}){return(0,H.jsx)(Kr,{"aria-label":`Loading`,className:B(`animate-spin`,e),role:`status`,...t})}var zv=hn(`inline-flex w-fit shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full border px-2 py-0.5 font-medium text-[11px] tracking-tight transition-colors`,{defaultVariants:{tone:`neutral`},variants:{tone:{success:`border-emerald-500/20 bg-emerald-500/10 text-emerald-600 dark:border-emerald-500/25 dark:bg-emerald-500/15 dark:text-emerald-300`,warning:`border-amber-500/20 bg-amber-500/10 text-amber-700 dark:border-amber-500/25 dark:bg-amber-500/15 dark:text-amber-300`,danger:`border-rose-500/20 bg-rose-500/10 text-rose-600 dark:border-rose-500/25 dark:bg-rose-500/15 dark:text-rose-300`,running:`border-sky-500/20 bg-sky-500/10 text-sky-700 dark:border-sky-500/25 dark:bg-sky-500/15 dark:text-sky-300`,info:`border-blue-500/20 bg-blue-500/10 text-blue-600 dark:border-blue-500/25 dark:bg-blue-500/15 dark:text-blue-300`,accent:`border-primary/25 bg-primary/10 text-primary`,idle:`border-border/70 bg-muted/60 text-muted-foreground`,neutral:`border-border/70 bg-muted/60 text-muted-foreground`,"in-place":`border-sky-500/20 bg-sky-500/10 text-sky-700 dark:text-sky-300 font-mono text-[10px]`,worktree:`border-primary/20 bg-primary/10 text-primary font-mono text-[10px]`}}});function Bv({className:e,tone:t,dot:n=!0,children:r,...i}){return(0,H.jsxs)(`span`,{className:B(zv({className:e,tone:t})),"data-slot":`status-badge`,...i,children:[n&&(0,H.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-current opacity-70`}),r]})}var Vv=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),W;(function(e){e[e.EOF=-1]=`EOF`,e[e.NULL=0]=`NULL`,e[e.TABULATION=9]=`TABULATION`,e[e.CARRIAGE_RETURN=13]=`CARRIAGE_RETURN`,e[e.LINE_FEED=10]=`LINE_FEED`,e[e.FORM_FEED=12]=`FORM_FEED`,e[e.SPACE=32]=`SPACE`,e[e.EXCLAMATION_MARK=33]=`EXCLAMATION_MARK`,e[e.QUOTATION_MARK=34]=`QUOTATION_MARK`,e[e.AMPERSAND=38]=`AMPERSAND`,e[e.APOSTROPHE=39]=`APOSTROPHE`,e[e.HYPHEN_MINUS=45]=`HYPHEN_MINUS`,e[e.SOLIDUS=47]=`SOLIDUS`,e[e.DIGIT_0=48]=`DIGIT_0`,e[e.DIGIT_9=57]=`DIGIT_9`,e[e.SEMICOLON=59]=`SEMICOLON`,e[e.LESS_THAN_SIGN=60]=`LESS_THAN_SIGN`,e[e.EQUALS_SIGN=61]=`EQUALS_SIGN`,e[e.GREATER_THAN_SIGN=62]=`GREATER_THAN_SIGN`,e[e.QUESTION_MARK=63]=`QUESTION_MARK`,e[e.LATIN_CAPITAL_A=65]=`LATIN_CAPITAL_A`,e[e.LATIN_CAPITAL_Z=90]=`LATIN_CAPITAL_Z`,e[e.RIGHT_SQUARE_BRACKET=93]=`RIGHT_SQUARE_BRACKET`,e[e.GRAVE_ACCENT=96]=`GRAVE_ACCENT`,e[e.LATIN_SMALL_A=97]=`LATIN_SMALL_A`,e[e.LATIN_SMALL_Z=122]=`LATIN_SMALL_Z`})(W||={});var Hv={DASH_DASH:`--`,CDATA_START:`[CDATA[`,DOCTYPE:`doctype`,SCRIPT:`script`,PUBLIC:`public`,SYSTEM:`system`};function Uv(e){return e>=55296&&e<=57343}function Wv(e){return e>=56320&&e<=57343}function Gv(e,t){return(e-55296)*1024+9216+t}function Kv(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function qv(e){return e>=64976&&e<=65007||Vv.has(e)}var G;(function(e){e.controlCharacterInInputStream=`control-character-in-input-stream`,e.noncharacterInInputStream=`noncharacter-in-input-stream`,e.surrogateInInputStream=`surrogate-in-input-stream`,e.nonVoidHtmlElementStartTagWithTrailingSolidus=`non-void-html-element-start-tag-with-trailing-solidus`,e.endTagWithAttributes=`end-tag-with-attributes`,e.endTagWithTrailingSolidus=`end-tag-with-trailing-solidus`,e.unexpectedSolidusInTag=`unexpected-solidus-in-tag`,e.unexpectedNullCharacter=`unexpected-null-character`,e.unexpectedQuestionMarkInsteadOfTagName=`unexpected-question-mark-instead-of-tag-name`,e.invalidFirstCharacterOfTagName=`invalid-first-character-of-tag-name`,e.unexpectedEqualsSignBeforeAttributeName=`unexpected-equals-sign-before-attribute-name`,e.missingEndTagName=`missing-end-tag-name`,e.unexpectedCharacterInAttributeName=`unexpected-character-in-attribute-name`,e.unknownNamedCharacterReference=`unknown-named-character-reference`,e.missingSemicolonAfterCharacterReference=`missing-semicolon-after-character-reference`,e.unexpectedCharacterAfterDoctypeSystemIdentifier=`unexpected-character-after-doctype-system-identifier`,e.unexpectedCharacterInUnquotedAttributeValue=`unexpected-character-in-unquoted-attribute-value`,e.eofBeforeTagName=`eof-before-tag-name`,e.eofInTag=`eof-in-tag`,e.missingAttributeValue=`missing-attribute-value`,e.missingWhitespaceBetweenAttributes=`missing-whitespace-between-attributes`,e.missingWhitespaceAfterDoctypePublicKeyword=`missing-whitespace-after-doctype-public-keyword`,e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers=`missing-whitespace-between-doctype-public-and-system-identifiers`,e.missingWhitespaceAfterDoctypeSystemKeyword=`missing-whitespace-after-doctype-system-keyword`,e.missingQuoteBeforeDoctypePublicIdentifier=`missing-quote-before-doctype-public-identifier`,e.missingQuoteBeforeDoctypeSystemIdentifier=`missing-quote-before-doctype-system-identifier`,e.missingDoctypePublicIdentifier=`missing-doctype-public-identifier`,e.missingDoctypeSystemIdentifier=`missing-doctype-system-identifier`,e.abruptDoctypePublicIdentifier=`abrupt-doctype-public-identifier`,e.abruptDoctypeSystemIdentifier=`abrupt-doctype-system-identifier`,e.cdataInHtmlContent=`cdata-in-html-content`,e.incorrectlyOpenedComment=`incorrectly-opened-comment`,e.eofInScriptHtmlCommentLikeText=`eof-in-script-html-comment-like-text`,e.eofInDoctype=`eof-in-doctype`,e.nestedComment=`nested-comment`,e.abruptClosingOfEmptyComment=`abrupt-closing-of-empty-comment`,e.eofInComment=`eof-in-comment`,e.incorrectlyClosedComment=`incorrectly-closed-comment`,e.eofInCdata=`eof-in-cdata`,e.absenceOfDigitsInNumericCharacterReference=`absence-of-digits-in-numeric-character-reference`,e.nullCharacterReference=`null-character-reference`,e.surrogateCharacterReference=`surrogate-character-reference`,e.characterReferenceOutsideUnicodeRange=`character-reference-outside-unicode-range`,e.controlCharacterReference=`control-character-reference`,e.noncharacterCharacterReference=`noncharacter-character-reference`,e.missingWhitespaceBeforeDoctypeName=`missing-whitespace-before-doctype-name`,e.missingDoctypeName=`missing-doctype-name`,e.invalidCharacterSequenceAfterDoctypeName=`invalid-character-sequence-after-doctype-name`,e.duplicateAttribute=`duplicate-attribute`,e.nonConformingDoctype=`non-conforming-doctype`,e.missingDoctype=`missing-doctype`,e.misplacedDoctype=`misplaced-doctype`,e.endTagWithoutMatchingOpenElement=`end-tag-without-matching-open-element`,e.closingOfElementWithOpenChildElements=`closing-of-element-with-open-child-elements`,e.disallowedContentInNoscriptInHead=`disallowed-content-in-noscript-in-head`,e.openElementsLeftAfterEof=`open-elements-left-after-eof`,e.abandonedHeadElementChild=`abandoned-head-element-child`,e.misplacedStartTagForHeadElement=`misplaced-start-tag-for-head-element`,e.nestedNoscriptInHead=`nested-noscript-in-head`,e.eofInElementThatCanContainOnlyText=`eof-in-element-that-can-contain-only-text`})(G||={});var Jv=65536,Yv=class{constructor(e){this.handler=e,this.html=``,this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=Jv,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+Number(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(e,t){let{line:n,col:r,offset:i}=this,a=r+t,o=i+t;return{code:e,startLine:n,endLine:n,startCol:a,endCol:a,startOffset:o,endOffset:o}}_err(e){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(e,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(e){if(this.pos!==this.html.length-1){let t=this.html.charCodeAt(this.pos+1);if(Wv(t))return this.pos++,this._addGap(),Gv(e,t)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,W.EOF;return this._err(G.surrogateInInputStream),e}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(e,t){this.html.length>0?this.html+=e:this.html=e,this.endOfChunkHit=!1,this.lastChunkWritten=t}insertHtmlAtCurrentPos(e){this.html=this.html.substring(0,this.pos+1)+e+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(e,t){if(this.pos+e.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(t)return this.html.startsWith(e,this.pos);for(let t=0;t<e.length;t++)if((this.html.charCodeAt(this.pos+t)|32)!==e.charCodeAt(t))return!1;return!0}peek(e){let t=this.pos+e;if(t>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,W.EOF;let n=this.html.charCodeAt(t);return n===W.CARRIAGE_RETURN?W.LINE_FEED:n}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,W.EOF;let e=this.html.charCodeAt(this.pos);return e===W.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,W.LINE_FEED):e===W.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,Uv(e)&&(e=this._processSurrogate(e)),this.handler.onParseError===null||e>31&&e<127||e===W.LINE_FEED||e===W.CARRIAGE_RETURN||e>159&&e<64976||this._checkForProblematicCharacters(e),e)}_checkForProblematicCharacters(e){Kv(e)?this._err(G.controlCharacterInInputStream):qv(e)&&this._err(G.noncharacterInInputStream)}retreat(e){for(this.pos-=e;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}},Xv;(function(e){e[e.CHARACTER=0]=`CHARACTER`,e[e.NULL_CHARACTER=1]=`NULL_CHARACTER`,e[e.WHITESPACE_CHARACTER=2]=`WHITESPACE_CHARACTER`,e[e.START_TAG=3]=`START_TAG`,e[e.END_TAG=4]=`END_TAG`,e[e.COMMENT=5]=`COMMENT`,e[e.DOCTYPE=6]=`DOCTYPE`,e[e.EOF=7]=`EOF`,e[e.HIBERNATION=8]=`HIBERNATION`})(Xv||={});function Zv(e,t){for(let n=e.attrs.length-1;n>=0;n--)if(e.attrs[n].name===t)return e.attrs[n].value;return null}var Qv=[8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,381,0,0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,382,376];function $v(e){return e===0||e>=55296&&e<=57343||e>1114111}function ey(e){return $v(e)?65533:e>=128&&e<=159&&Qv[e-128]||e}function ty(e){return $v(e)?65533:e}var ny=(()=>{let e=new Uint8Array(127),t=0;for(let n=33;n<=126;n++)n!==34&&n!==36&&n!==92&&(e[n]=t++);return e})();function ry(e,t,n,r,i,a){let o=e.length,s=a*90,c=0,l=()=>{let t=ny[e.charCodeAt(c++)];return t<a?t:t*91-s+ny[e.charCodeAt(c++)]},u=n-r,d=n+i,f=new Int32Array(d);f.fill(-1,r,a),f.fill(-1,a+u,d);let p=new Int32Array(d),m=new Int32Array(d);function h(t,n){let r=0,i=n,a=n+t;for(;i<a;){let t=ny[e.charCodeAt(c++)];if(t<89)r+=t,f[i++]=r;else if(t===89){let t=ny[e.charCodeAt(c++)]+2;for(;t--;)f[i++]=++r}else{let t=ny[e.charCodeAt(c++)];r+=89+(t<90?t*91+ny[e.charCodeAt(c++)]:ny[e.charCodeAt(c++)]*8281+ny[e.charCodeAt(c++)]*91+ny[e.charCodeAt(c++)]),f[i++]=r}}}h(r,0),h(u,a);let g=new Int32Array(i*2),_=0,v=0;function y(e,t){for(let n=0;n<e;n++){let e=t+n,r=l(),i=l();g[v*2]=r,g[v*2+1]=i,v+=1,p[e]=_;let a=(f[r]<0?m[r]:1)+(f[i]<0?m[i]:1);m[e]=a,_+=a}}y(i-a+r,a+u),y(a-r,r);let b=new Uint16Array(_),x=0;for(let e=0;e<v;e++)for(let t=0;t<2;t++){let n=g[e*2+t],r=f[n];if(r<0){let e=p[n],t=e+m[n];for(;e<t;)b[x++]=b[e++]}else b[x++]=r}let S=new Uint16Array(t),C=0;for(;c<o;){let t=ny[e.charCodeAt(c++)];t>=a&&(t=t*91-s+ny[e.charCodeAt(c++)]);let n=f[t];if(n<0){let e=p[t],n=e+m[t];for(;e<n;)S[C++]=b[e++]}else S[C++]=n}return S}var iy=ry("!}.&u%}'&}*'~!6*)%&,~!J~!J~%L~y<~!R,~~%Lu~~#GD~~#|)1#%}^%}2%+#.##%##%}&%##%'#%##&%#%#'%#&#%#&#'#%%#&#%##%#)%''%&%#%#'%#%%#%%}%%%#%#&(23#%%#&-%0%('1#(##%#'##+%'*.:1}#%#6-+(%'%%#%%%}#L'2351&('%}&/N'(0(/*-%(%%}#'+&T%7.2}#&%&#%#36/5##%&%%#&#%%#))2%%##%&&'0~!#*+&'%1~!%).'3q?&%'1~!.##%6(~!+%%%(Gw'rT~!E#<nA%#jZ~!H%(~!42##~!*31&~!G%U~#)5~#`3~!J~!Z~%]~%Y~%C~!q~!u~#kz~%#~!6'~!D~!U~!?~#T~!c%~!G#'~%7|~!G~!J~!G&~#pb~(Df}#%}*&}#%##%##%##&#-}&'#'&%#.++}%mI,#,@&(}*%}*'%&##&#%##%}&0}#.},U},%}+%}&%}#%##&}B%(}(%}+%)})%##%#&}&%##%&}<%}>%#%&}*%}(%}9%}/%})%}*%}*%}?&}&%}3%}&*#%})%#%#)}#&#-#+*%E%%'%'#%}#*V##&##I}#&&##%&%#&&Qf%%))w/0+&%#(#.%-''''++++7}>%4'',##1,#%#&%##&#'##&#*#9)%&%}#*}%,#+P(%A&%#'&##wSD',9E00#y#@}(+}&%&>~!#~!X}#*}(&&}(&}(,%}%&#+&}#&}I%#%}%)#(},'%#*}4%%#%}(''}#/##(##),%-##%%)#&}(.}&%#&}%%}*&#%},&&}&%}#%*'#%})%}D&}&%}-&}6&#&}-,%}#%})-(~+`~,=?~I9'9%~!,#%})%})%}@%}?%}(~!?~#<~#pP~#BG~#=1#%K+~#?#~%;)~#A~#mF1~#A'~'X%'~#lR~#N~'N~#r~#m#-~#i'?%#'%~#B%##%,%#~#_%#0%~#]732~,w~2+#:&#%&'0%&>%}#>##F+)#%&&#(+_}4&}-%}(&}@&}O7Fdf0@+/v4}&WU##&/0#&'('B#%}.%}'+#%}#%%&#&%#%##+#&#)#6#'#.},%}c%},%#%##%&#&%#&~#>'*-.%##%##%}#%%}%'~#)D1}#%*&~#_%%'(~#S2%'.}#~#=##*'*-%}&'%'##&&~'E%.#&~#M4}%%##&'%#~#O1##%&#'+~#<B%##%%'%+~#;#@%}#&%#&&%#(~#H1}'%'##&&~#?A}&'~#D#%32}'&&&&~#[}'(#%}'~#;C})&}%%#%~#=&%,3}%'(#%%~#^'#&&)#%'~#Y%-~#d-%'~#^%%&#&&&}#~#b~2t*&'~&(~&@~0%~e~3}%*''0})&}+~!9##-}#%-hD*)1fC#%/&/fB#40~!+#)*4~!+~!K'&:~!/*7~!.#~!H~!L':~%x&~!H#~!*~%1~!I#~!+A~#p'~!F~~#-#~,,(~.Z~!V~%;'B'mq-W~!N~%I%#&&#&}#%},%%}'%}+X#%}#&}(%}'%}<%}#%}%%'}'%}:~![)9@~%>~#UA%-%##&~!C%~!-.9:~!1~!-^2/:a~!y,D*J#-5)/4~%23,~#G~!L1~!0X3`~!2+~!!0-~&E~!W~!o,>Y&]~%cZx_&~#O*9#A#'#+I'%#)~!0B*-5A+-((F&*M#)(-7-5+'-3a5Vi~!Y~!?+[)%3),ERHm~!+:D,VG.+)?fB%%*(%)'(#&80%1'8`K8?`+'Z#&O&'H5#*9)A%%5&3))0%39+.*7#()&&*=4@**L)<'_&*+..;(#*+)./&0#3)%')-8(4ixD(&.}%,('aI:,)%,k2231T)I'#/-W7,/'Q#.'Y24+h')37</31&83##&0#),H(?'&?/1##%#&&#%''-%&&&#(&''&#.-'%#%%(,')*'&#&#'##%(%(#%('#&##%%%%('%#%#%%#%#&%##h>w+v<ayvyvcg.uuhKr}g/v|g>u9i[~>g5uI~=RvdwEg;v/g;uk!!TTSx]@RT!U!#!@VBRUU!'UTe-d0c`e&gSdicedFcrdTaqb.kYcAohdYd@a3e+d}dMdtd.aJ#bqcK`dle/e.e'dwdPdodddjbEb}ogd^ofdpduc6j?l%d{drdqc)d7bacOdQ%T#Y)X.sR[yH>6Vyv3[xwLu>vo'!*.[yBacahoj>6Rew3[xqdZa#!a&#^(X-[yG>6Vyu3[xvg3sEr|g.u/Ri9db0T#^(Xa)!-[y;>6Vylg4wKs{JwNZt3@3r=c4Z([xlg;wKt!cpq's@v7A'*a(a+!-a#[y<3Dt?3Dt'>6Vym3[xmg9rxsNJwLZt4~?r?db1T#`-!(Xa,!0[yS>6Vz%NuQs.g4wKtnJwNZtS@3r>c4Z([y%g;wKtrdga8!a(!#&T*Y-Xa#!a0<or[yc3Dtq>6Vz43[y3JwNZtf@3s!Ju}!%Dti:pm3c_%X#tjB5pkd6q!r]u?voC'*-a.a2!0a&a+[yI3DtI3Ds~3DtH>6Vyw3[xx;:s#~<5pKJwNZtE@3r~d`a)!a2T#a.(!+U.X1[yT3Dt`3Dtv>6Vz&3[y&g9rxwzcxstPu.<rAJwLZtT~?r@dZa%!a.&^*Za(/Reu[ya>6Vz23[y1g3sEr}wkg{NuQRg{ci(U#5@b`~,cg#U(2WnH5wugcRh7dX#T(Y,a'Ta!!a,[yZ<]mj>6Vz,3[y+Pv#5ReZKu+=,%!H}7ABwkaS?Rh:BcW(X#<]mrj:ubv/ARekdg%!(!a.*Ta(Y.X1!#sP>Rl*Dt6[y>>6Vyo3Wf*jOvuumvuRgRJuq*!:9<B@bX~3jVv&v@s@5Re[d/rQt{uAvo&a&a*)a2!,0Wf!3Dt0=Bs'>6Re}3[xy~<5s%JwJZt1~Gs)c;&!#2sJkNuXvzq7rxu,Re8dka4!a8(aEZ+a@Y.X1Xa)[yd=Bs(3DtP>6Vz53[y4cX#X&Re:avRe9~<5s&JwJZtQ~Gs*i^rzvdRg+Jv{%!2sbB@bX}kdga,!Za?&^*T1/!a'Dt+[y6>6Vyf3Wf%g/u;s4hGu6?Rh-JvZ,!c%#&RoX54Rivj7uyvf8RgTKvZB%*!2sGh<vu5Rgq<=C::9bb~#dZ#T&Ta6Y.X*Dt>[y93Wf)coZ(T,6VyifluvRgC@95@B@bX~/hFu34cC#T,k/unq8w8Q5RkUklwQuzunq8w8Q5Rk8d/rJu?v8w9)-&!a0a;a&aIWejg3sEr/h1s<DtDJvyZqY5aws3Jvy!&Wei~Hr1:au5@Bag>23E~5c:Z&bX};kKv?w&unuVu5Rjc;>bs)#~@:Rh.=ay<a]C;b`}Vd6s/t{uAvoaxa()!a,a7%-a#a2Dt,[yF2Wo[>6Vyt3[xuNuPRi&NuPwpi#RoWh?vf8Ri%Jv]!%Ri:KvxD!.'2WeAjZu`q9rxu,Re7woeAg-unLq(qA_/*2Wg_g3u5q^9:4E}/jTrxrzv=Wkkd~0UX#^^Xa-a1a5T&a=U1a'*aEa]!a*aPaA-adok[y54Rn>;:p3~Dp5g9rpsFNvZqjg3uJp4~<5p0Pw;5qlJwNZt*@3p1Pw:5p/Ou!5p2JvG'!6Vye=<qnJvh_[xhg3v,Rh3kOwOw-sDuev/Re^dha[a%!%!a+#Ta7)-5TaCaO!aka!a)sf[yb2>Rl!9ARiq5E}Qg=ucRkBE|oJrJ_@Wk~@Wk{JrJ_@Wk|@WkyJrJ_@Wk}@WkzJvO_[y2g-vMRmiKuYC!)&>Ri;>Ri<@3RkNc](X#@9Rk=g5vuRmhKvDB!+'=]meg3u4Rmgd)#Y'Vz3CARmfd`a+!%T'!+#Ta1Ta6TaM-sTDt9[yA9sYd'%Y#s[[xpj:ueunaXRgEjRq,v-vuqdd2'`#6Rev<32@5>:2<E}5xIo9a*X#Y(;5RePJvD_g>vyRgNj8w)v8<wggs:RgXiZt|vjx,hSq3ah!-(~@:Ro/Ou!5RhWj^v(pyw8unRhUdx-UY#^Ua.a3a70!)%UX1TaDa)'omRiRRhE[y:3Dsz=Br,>6Vyj3[xkg6ruwjcqsrPw;5r*Ku]D'Zt-@3r(~?r.i[vwv]dU1a--U#`a4(g/vsRhPOu!5RhLj:rmu9Wo!~@:wdh@g/vsRiTjXuvvNr}:RhBj^v(pyw8unRn]dz1UYa'a+^Y(!aETZalaRY.Ta?a4[yDJw1!#qLsW>6Vyrfzq-pLflpwRe|Js>%!Dt@3Dt&Jvy_[xs~HrnjMuwpsw'RecKu+D#'!t<~Grl~?rjg5u-x,gwp{ah!-(~@:Rg~Ou!5Rh'jXuvvNr}:Rh#cW#X/c;&!#2sLi[v7u7RgpJv)(!iLrxu,Re6j7v@s@5Se[e7d`aW!Za(a`T.a#!a3!&aDa-!9)Dt_=6s+3[x~~DR|h~DS6avhGun5RkZj3w)v-]mkKunB!&*]kb97R|i<ARk<c:Z(6Vy}Juh'!wziMRoS:F|vkLuauJv5vtvQRh1d='T+Y#VyO~DR|jcF#T'7R|g97R|kJv3'!ay<Rj,Jvh&!:ReXcsa6*a+#a#_aIRf9aLRf?c,Z&Rf5Rf7c.Z&Rf;Rf>cQ#%T'p-Rf8Rf=ct#%'(*!,p,Rf4p+Rf6Rf:Rf<d~'Ua%U*^UYa(!a,-!#a4YaTalaEX0a8a<Weo3Dt/3Dsx=Br93Wen~Dr;~<5p<JwNZt2@3p=Pw:5p;Ou!5r3c7&!#:p>3Ds}KvGB)_6Vyk2sM=<r7x'eovA(!hFu1ARf}cV#X&@r5j6rvwQa^Rf3c=Za'wkghJv__g;unRggA53B9=b^}%j6uduo5Jq;!(hIv%2Re`Ou4ARe_e%a#^^^Xa&!a*a2!&a6YaP!*ad!#a:aE/5Rn?[y@>6Vyp;:pE~DrY~<5pBJwNZt8@3pCh=rt3rWPw:5pAJup_[xoNuPpF9c!#'45pD5ARn)d8#X'X*3@rU72s]h>v<<sSjJpqvewOJq/(!hNw'5ReBk0s2u3w/w'5ReE5@Jq.!a+JQ!&WeU23d(#Y&RjG5]jBk!u7w&u0udARjEe#+^^^Ub#!a2/a`Z(agT1!a-a;|@TaG!aS[yV=Re~fow'RguNuPRe?bz#'>RoUWeL>:Cbb|?JwPZtVg6ruRmzJvD'!6Vz(g/vmRh~Jvy_[y(g9voRgyx*cy(#2>Ri2B9b]~9kIw9u7rluJu3Rg]dI#a%UY'@=p%CAx.gQZ&RhwwygtRm{x5g_Z'+ABqR9Woa=Bp&dV#^*Xa'!&@o{g4v]Rk;Jv{!%Rk[wkkiA5RkiwwfUB=x,fUuqC&*!>RfTg8v0RfV~ARfSd;rJsAuAv9wR'ae+/aO!a@aza/a#[yQ@Wg!2Wemg3sEr0JvB_g>uvReWg2v+Re=KupB_+[y!2AbY~-~Hr2AJwD!(h<~El>h<~El?Kun@+_:9b`}Kg-v/Ri3g;vtwyk_9]k_d=&T#*U.6qh@Ab`|K9:H|CJv[!&3Dtex'fDwC%!Rf[9WlMd[(^X,!a%Z06Vz!@WgBg=v~Rgvg,QRe@awd,#Y+jTv|Q~EfWj]uNr|~FRfXdy#Y&^Ua%!aO.!(a)Ua;=!a@aKap!a-,a!Ta]a[rSa]p?[y82sK=Bq~;:p:~<5p8Pw:5p7d'#Y'Wf(;RnRi[u4w&RgJJvG'!6Vyh=<r#ijuuv/sIKuYD'ZtG@3p9~Gr&d2#`(g<vtRgFj`u5w&rqpxRf2CJuY!+:wfnTOu!5Rg}jNs1ucv&RfwJvA!&3@q|BDcC#T,k/unq8w8Q5RkTklwQuzunq8w8Q5Rk9dga#!a'!a=#a0!:+Tb*b@aO.a4!aba8aFJv^}?!VyR~Dr<g;u%Rn.~<5p[x'e`wNZtR@3p]Pw:5pZhNvjBp.woe_g5u-r4JwF!%DtO3:ooc7&!#:p^3DtpLuGw(!+%)Dtk6Vz#2sd=<r8d'#Y([y#<x3gJt`w@!)%}MRiowzikRij=]ilxAf3,U(#B2Rf#g0v-Rm[ck{`U#]giKv3>)!&6Ri154s,KuGB_%@r68r:dJ|t`#X(9<E|u2@H|rx3gJu?w'!+'1Nu7Reg4=H~+9<wxgY95Rm]xLggZ-`(X}U2:Ri4h<uOawRmsJv__5@bb{jbV~3dka#a'a]!,#a+U=a>b6a3b%!/aKa/)!arwve^VyJ;:pR~DpTg3uJpS~<5pOPw;5qmPw:5pNOu!5pQJvG'!6Vyx=<qoJvA!{~Jup!%@qk7Rn/KvyD!}''[xz;>wkh'?Rh,x8gyt`w5D!&),(SgyccRgztJ@3pPB5p#d'(Y#<]mmifubw&RgoJvE&!82s^JvF&!8Rf,ADb]~;x=h'rNu]vK!,%'*0RnORh)4Rh*AqQg-vaRnNg;wHwkh'ba~4cE#Ta*x3gctyw@'!+%RnFRnD<4Rn@hFvK5RnCxWg[#`&a0Ua()`1Rm75Rg[c]%X#qi8Rg^NvdRj>BwzgZauwji7Rm6A4wgg]d1#&(*,.0a#Rm;Rm<Rm=Rm>Rm?Rm@RmARmBe%#^^^Xaea?aC/b+(,!a+a#!a/!>a&Ta<aKbD!2wphBRnk[yPw}hE|.=Br-3Dtm>6Vy~g6urRf.x,hPrNav!%'RnqRo%Ro#Nu;q[Pw;5r+JwNZtM@3r)d'#Y'Weh;xChL#`&RnmRnoKu}>%(!Rne~Bs-;2wjcussJv+'!aYSO}6@B<5?ba~8LrNvj!.%*ROwungw~ng~:9;Ri^>wtnig;wHRnixDh@|(UZ.x1h@|)!#:2<H|*xHn]#-UX'3Ro)z=iT}6ARns=Bwsn_wpnaRncw]aR(#UXa&Ua*a/=]iPd'#Y&Ro'WnXf{QRm2hNvj]nZd`'T~&1`{|`#9b]{}c:'!#Wl{>@=be}]?cl{{U#:5Abb}Jds#^YaF!a*b4a#a3aPa>&Tb!bH!*a_!Eau?/a&RjY<]gj>6Vz*;:pe~DrZg,QRj1JwNZtX@wihspcJvZ&!VyX9WmOJu|!|N2WmHJvh&!]ht~Bpbcn&T(!#RmQ<s7Nu;padH#X'`+WmJ@>RmKCARhnKup=!)&Wf+:RhqNuPpf9c!#'45pd5AwghpARn(Ls@w!%,)!RmP@Wfe<E|IJva!&WmNg8vsRmLd`*.`#Y'Xa!axRn*]hrA8Rhug5s@rXg8u!RmMd8#X'X*3@rV72smdI*#UY&RmICARho~GsgxVgd)Ta'U-Y&Xa!T#RnEWnA@Wffg1uDRi0hFvK5RnBxGnG&#`%owp)@wsf+bX}Ze-*1!a*^^^Ua|!#a.aq&Ya2!a>.a6!a:aO`aJDtL[y`@Wg#>6Vz12@wzoYRoZNuPRi!NuPRhzg=ucRi,@=b`{Yg=ucRi-ACJvB!&Sh[ebSh]ebi`wUuFRm4Jw2_[y0JvB!.<Ju(!&SoG}6Shd}6<Ju(!&SoH}6She}6Kur@._g5vHRieJvx!{L2G{Kx6gd'T#?Rh82Wi5cZ#X(g1w)Rm5dW-Y(Ta#!a)!#aYa=wnfE=su2>>bU{0j9udv:<svj8uQv-7RgHdE%#^'sq9sp=>Bb_{TJv`!&g/r|snj6v(us5d,#Y(56H}[978H}]Jw5!&g1rushJvB!+j;v{u5?zDhd}6}bj;v{u5?zDhe}6}ce*#`(^^^a[aea!=!a6a*aoXb1a.!aAbL!b>,b'aL!aV@Wf|2Wlg3[y/JwNZt^@3piPw:5pgJunZou3@rsJva&!Vy_g<v~Rm#JvG'!6Vz0=<r{Ju{%!:pj@WfsiXuJu3Rm:JvZ&!WfA~Bph@c4Z&Dtwax5rubx(#:awRk1@d,#Y&RfjRfid1#,Y(@Wfp2Wlrg5s@ryKu[@!,'=]ig9wlk?Rk>g5u-rqJvy'!@9RkQcH(T#=>Ri~@<wkj(Wj(KuZB*!&<7rw@9RkRcH(T#=>Ri}@<wkj)Wj)dg(Ta2Xa9X#`-!a*CARhg@@=I}d9x;c~#X%so=<sj>2@@=aybb}XjWv0Q~EfEj3vLv;<d,#Y(56H}`978H}_dgaPaFa'a/!#a3Y0a_a;a|!1(a7-[yE3[xt;:pJNvZrrg3uJrvJwNZt=@3pIh=rt3rxPw:5pGOu!5rpJvG'!6Vys=<rz@c4Z&Dt(ax5rtJvZ!&~BpH@wsfNg-vaRlNci*U#=<wei<F}a5@Jq.!a*JQ!%@qZ23d(#Y&RjH5]jCk!u7w&u0udARjFd/prq=tyvpaEa(a:.!a1aZ(@@=I}:9wpd%=<sX55w_h}@@=I{t=ay<aU@@=I}T=ay<2@@=I})?C9:9au@9Cb]}DP~=x-fAZ(2Wl1=ay<aU@@=I}>5@d##Y+jTv|vV~EfFj]uNpn~FRfGdgaK!Z2&!a8a-Tb({E!acTbM*!a(DtY[yYd'%Y#sl[y*hHvh>Re5x2c{Z}.j4uCvcawRiMd+#X+_x&d!},<5RkX;2Hzw@x,gavfB-!{CcF&T#Roe;RodwWbBg5urRgaKvHC*_6Vz+<4opieuew&Rmq@d]&Y)X,T#X0Rh}<BqP=4qS9:ReMg/ujReNJw0!/<Jui%!bd{kawwnemRelAxUa?a3#*.&UX(Ya+a/RhvRnQ<o}9Wmtd-#Y&RgSRmw9;Rmxay=Rmyg-vaRmuxEhSrNu,v-voC!%(aR.a(a7+1Ro1>Ro5CE{A9b]{@;5x#eO{:g;urRi+KrNA!%(Ro3>Ro79;Ri_Ku@>{;&!x%gX|{KunA_+g5QRj/g3u5Rj#g>uERj%wio/xRhS&!,!#^1U}wba{8>>@=be}qC@:D5ba{7Ku+A&!}x?ba}t>>@=be}se(aA^^^Uat!b0#{pa+awUazbGa#aLb9bgaWac'a5TbS=Br!d1#`%scp_Jvl!#rT>Re0JvX&!VyN=H{Fcm#U&:pY=ReaJv2&!]h0=]nUJvG'!6Vy|=<r%JrM_=]h2@Wlud'#)U'Wf'b]{i=]h/Jvh!&~BpWg=v]RnMx+ny#'Nu;pVwjnu=]nwxJnx,T#`&Reqwjnt=]nvieu9vrRjLLuYwP(#+!th@wih5pX~Gr'g5v/Rh4KunA'!-CARnP@wwiN:Rm_9x'cvw>!|l=<saKvAA!0&3@q}>w^e1bp#&Re2Re3BDx7gH#T|f5H|eKuZ>!%(:qNAH{]Jv6!+3B2B9=b^{X<5<B92:E{ZLvhwA(a;a%!igQuyRmad+#Y}m@3Rh5d8#X'X*:AqUAHzmaxwbh<aXRnVcF}RT#Nw&cj#U(BWnug/vsRntdka)(a3+.Zb7aYYan1!bVa@Xa}[y^@b[{G=H{+hFu73Rj&Pv#5ReQcK%T#sig1v{Rj'Ku+D#'!t]~Grm~?rkKuMB!01d5#`'Vy.ta3Dtu~Hroc8#'{^45s85AwZbP&!#Rn!wghxWn#KvEA!)&2RlA2RlBx:h|#(T,=]j09Wobz>x]z/@awRoTd+#Y(az]hFhCrm4d,#Y+jTv|Q~EfMj]uNr|~FRfOdCa!Xa9_X#@<plJvf!%b`{(9;Rgwc;.!#2x7cw#T|UDb]|T5Ju={(!=@E{&Jv)&!Ab`{'awJvf!~*>>@=be{#KuY>!+&4Ezyi[ugv&RjIdea+T)#UXa&T-T&a!Rh9auRmW=]kLg5vuRn+g3u4Rn-Ow6ARn,hHus5xNk?#UX(U~)/g8v0RkD~AwkkF?Ri.OuNBwkkA?Ri/d|a2`a*^UYa.!aBTZaTa'Xa;!(!2!-a#b2[yC>6Vyq3[xr2Wi?g1rusVh%s?DtF~<5rbJs;%!DtBfswKtCj[uvuSsEu3RgVx3o:u+wN'*Zt;@3rd~Grh~?rfg8w)Lq)qE&-a%!>bI|`jWv0vV~EfCjTv|vV~Ef@j]uNpn~FRfBcK#T']gWNu7x,k7q4ai(0!hHv8<RhmkMu9vrsBuev/RhlCJvB!,g<v{wchh~@:Rhji[vrv{wchi~@:RhkdS&a5UY#Ta!RgPwwiI5BwciI~@:Rh`x'iJvj'!5]iJPu8Bwch]~@:Rhach)U#h3rp]gLh@t|Ax,hTq3ah!-(~@:Ro0Ou!5RhXj^v(pyw8unRhVd|)`,^UYas!a?/a2Z'a^Ta{Tb7Ta(a#!a,Wf&9sZ3DtAadamov=Bqt3[xig8vsRm~>waiL2b`{QJv*_Ouv2qgj<v]v2BqfdR'X*X#Y-@3qr~Gqv~?p6hHv-]glPup5Lq+q?_%*b_{qF{n9b^{rOu4ARhpKvCD!+&~Bqp:5Dbb}nwoiKl&unuTuBv]v+ueunaXRf0=Jvh!0nKufu8v1w&w7q%w&uHrz:Rgnj5w,uxDJq/(!hNw'5ReCk0s2u3w/w'5ReFd>Za&!*UaA=<wkgsRnSJv^!%Refifw3vyRgOKu_B'!,<]gkiiu:w&Rh<=C@a^<B57@2F{[<B5@aW:=3away9A5aW=<B=C@a^<B57@2F{Ie-#`(^^^bCara.b8aza6!/bZ,!adTbnTbOb+aFaS!aAT9@Wf~2Wli3Dtl2@d,#Y&RfnRfmJwJZtN~GqyJva&!VyMg<v~Rm%iXuJu3Rm9Jv[_=]ih9wlkDRkCd1#`(@Wg>2Wls3cH#T(@<Rj*=>Ri|b~'#23s9h<~El.d'#Y&Dtxi^rzvdRl#d*#U%(o|B2s`hJwSaxRmDKv4B&!1:Rmdd5#`'Vx}to~Hq{x'f1v3(!BA5ba|bJv_&!Wfug1v]ReIdO+U/Y#&G}-8wze=Rh{g1v]ReHg/uQRf/by#)ibQwERl/cH#T(@<Rj+=>Ri{cNu+vlax-!(#a0qa9<Rii2;;bU{H;x<i=&X#Rk`<4wwi=C9H~8xAI(Y#<azRi@45wXI<B9;5bb~7dL(X#Xa(+!aL6Vy{g5QqOau:5au2@ay547EzbxOcU(UX-T#Ta#:Cbb|A?wjh/b_|SOw6ARgtihr}u7Rhy<d1#T)X1@@=I|~=ay<2@@=aybb}Sj3vLv;<d,#Y(56H}A978H}@dGpvs@uAu`vcw9*!aFa+ai%(b!aXa8.a?a[ozWey=sU2@G}Nch&U#Rf_WexKu+D#'!t:~Gr`~?r^j]uNr|~FRg*j^psurwJt|RmcKv)@&!)7Rkv~Br[@wxfO:Rl3co#U'6Rezj_q#vIuavjRltwzeyh@vr5JqD0!>aY?C9:9au@9Cb]}9cl#U*5;5<H||jbuus1ucv&Rfvg1v~d/pppzqFr^a--a~!aMat1(hFv;Wiz@@=Izoj5uuv-7Rix~Cw`fk2WlVcZ#X,k)u3vWs@u2]ktg;wEx'fBq(_2Wg/jTv|vV~EfoJv]!15x'hzqG!(P~EfU~CRl_j6v(us5x4i-#T(2WmZ?C2F|d>Kq<aj1!*jTqIsBv=Wl`~Cw`fi2WlWj`v0u*~>RlR=c>Z,k#u3vWs@u2]kr<c1Z+jTqIsBv=Wla~Cw`fm2WlXdmb3!a{(arZa`bkTa%TbQTa-a9+c'!aM!/[yL=Bqug.w'RifhFvyDRj.g>vgwyk^9]k^Jv3_@WfbAARkhJw2_[x|JvB_wkoIRoKwkoJRoLd'(Y#<]gm=<9<H|yd'%_X#skDtb3awwqkgNulRkgdB#^',9:p'hJwSaxRmEBwVb8@4=H|qLu+w50&!)@3qs~?pU>Awwn;;Rn=c:Z'ARn<=<qwKvC@!/&~BqqJv6!&]eVb^z^xRge'/a%+^`#Sge}6<4Rn3=]n0Pw2>Rn8Jw0!&>Rn:>Rn6cY#a7+!a&=<wkaNw~h3z_c5Z{=wjh#=]nLKv^D!&)Vyz=bW|swYb<WetcG#T(2wxa@qVx@gD#Y&b^|V5JwG&!5bb|pg/w&RgD@x=kHs=uAvn!a%%/'+RmSRh694Ro`g-vaRmRhHv-]mlxCcS#`&ba~.5cD#Ta)P~=d,#Y(56H{>978H{Dd_#{2^Y%_+qbbb{6g3sERhsbU{?dfa.,`a(Xa<!aiX#(55RiG54RiHcI#T'WiU3RiVNvdwtfcRlKNvdd,#Y&RlHRlExQgf.1*^T'X#Sgf}6Wn4=]hfPrk>Rn7Jw0!&>Rn5>Rn9Lunw?&a2!,5<oq@@wqfdRlJj5Q~=d,#Y(~ARfcOuN]fdDKw;ay(}i!547E}j?cI#T(@5bV}iCbV}hdv(^^Tb?a40,b##Tbo!a*bR!a<b|a/!aKai!aU[yK=]o^g:v>ReGJwPZtK<7Rh+h<~El,Pv#5ReR@awwxjCg,ulRjDJv6&!]j!z?aQeeg>w=Sh<eeJw;!&axEzOg,Qosc!#*:wkeJ]eJ>x'h-u(!%Ro.w~h.zPdNZ(X,Ya![x{;9ReY;wkgxRiF:x?ap#Y&RmUg<s2Rkod]+UY0TZ'!a&A9sw<=bczLNvuw{gqzNhJwSaxRmCKuLay!#&s_Rf-55b^{uJvZa!!c%#(55Ri654wmiu5RiuawLu,vp!+}^%b_}Y9;wkgxba}o>A9:=b^}zKuh=a''!3awRk3c*'!#aHRk6c+Z&Rk5Rk4Jv)&!awRjSawd9*`#0?C2@EzMj8u<uJ5RmbjQrquJu3x,k>uq@_+=ayb^|W~ARkEOuN]k@7dhzV^X/X&a-#zRzSb`zXcJzTT#2WkVKvDBzW!%FzY9;5bbzWjQrquJu3Jw3%!b`zU=ayb^zQd:#X(T-a!6Vyywxh}=b]{Jg=u1RiAdGp~qHtzv!w(wA+a+a;<!aJaYai'anasb(=azRmV:Cbb{MLq2vb!%')RjuRjrRjtRjqx3jnqCw3!%')Rk(Rk+Rk&Rk)Lq2vb!%')Rj{RjxRjzRjwLq2vb!%')RjsRjpRjfRjex3jcqCw3!%')Rk'Rk*RjkRjl9<CbbzfOu4ARhxLq2vb!%')RjyRjvRjhRjgx=joq*uKvb!%')+-Rk.Rk%Rj~Rk-Rk#Rj}x=jdq*uKvb!%')+-Rk,Rk!Rj|RjmRjjRjidAq&qKs@uAv8Aa.'*-a@a&0!aM@a5[y73Dsy3Ds|3Dt):wxgI2sHJwJZt.~Gqxwsf0ikrzt}Rl0Jvy_[xj~HqzKv_A|D!&WfP8axRoVcf,U#k(v]v+ueunaXRf1Ju}'!g8u#Ri=jQw!sCunLprq>!,')~<5qeGzq9F{W=c##%s5au:5aU3CBE|;d4#X(D!a&6Vygx(b;#(=]ed?C2F{N<capoq2r[a&!aPa9,'Pw;5s:@@=I|,55w_h|@@=IzcP~=x'fCqB_2Wl2>aU@@=I|1OuNBc1Z+jTqIsBv=Wlc~Cw`fl2WlZ~AcTa%!Z+jTqIsBv=Wlb~Cw`fh2WlYk+uNqJsBv=WlSg,u3dca3#UXaMYa)TaB-=cM|7T#<bI}l5@B932:aV2G{BOuNBJq:|M!5Ezt=<B=C@a^<B57@2F{v>cB{/T#=ay<bI{3Jv6!a.6BKq0ah&+!5E}HP~Ef{978BaU@@=Iza<7d#.Y#978BaU@@=IzH~AJq0!(@@=IzG978BaU@@=IzFe,aU*Y&^^^bvJb,b:bFad!a,c2Ta>aL.bo6!a#CbTa'T#Re{2Wlh2@G{yg6t~Ro_NvdRfticuRQRllJv3&!x&c|zs@Jw3!%RflwpfkRlpKuL;%(!Re<@G|C2GzdhIvuBwgjAg-u0RjAKQB%!(GzZ@G|5NuuRl7d='T+Y#Vy[g<v~Rm!==G|>JvA!)@wma=]m1ifuaw&RmnLs@vT'!|/+[y,g:v>ReTJw1!#qX=x!eC{bLu+wT&)ZtZauq_~Graci&U#F|89:r_Lupvq!.)&2RlG8RfaC=x!eF{_h?rpWlmd&'!#X|&]k::xJey#`'T|+<E|&2@H|%dE#(^,g;u.RiEg6vjRiC9xCkA{O|zY#g=ucRmXKs0@!&*@G|m@awRknJuh!,3d(}gY}eJvj!%Rm):Jw3!%Rm+Rm-Ls0w(&!a(a#@b[|6cZ#X'7RkxWgAOu4ARn'dH'U#Y*Vz-Wm'CARm}d]*#a%^a*T'aK!a<9bV{PC=p*Jw4!&SgxcbB5r]idw(wBRmF7xFkt#&`(Rm/Rm8E|!JuY_9:Rl5=wrgr2:bbxd@xXfB(a*#T+!.X0X1Ta/a'T&RlDRfL>RlyARl9b[z[>RfZ:RlL:RfRwlg/ARl;9;RlxKv,A/!%7s69<74=BA5ba{-8Bde#`a<XaKYa1,a'P~=wxfB2bZ}}?C972@@=I}r8@55B9;5bb}G978B2@@=aybb}3j3vLv;<Jw3&!>Rfk=ayb^}4~Ad1#`*@@=aybb{w2@>==<bbz]dx+UY#^UaF!a9!bB'Ya1.!ajXa#%olRhD[y=3Dt#Ov5BrHKuMB%!(Rf^Wep~HrJwkiQjKr|~FRg)Ku+D#'!t5~GrF~?rDdV)UY,Z/_7RkuG{<~BrBg,rlsO:235B@bX}|d?a1!#`(6Vyn5@d##Y+jTv|vV~EfIj]uNpn~FRfH7Lq2vb1!a9-978BaU@@=Iz9978BbU}#~AJq0!(@@=Iz8978BaU@@=Iz7~AJQ|}!978BbU}!JvkaK!AdUa21-U#`a+(g/vsRn~Ou!5RPj:rmu9WhOjXuvvNr}:RhAj^v(pyw8unRn[kPr}p|u7vwv]RiSBd;pppzq@qHQa?(b.!a.a`@.|xa(hFv;Wiyj5uuv-7Riw~Cw`fg2WlU978BbU|wOuNBJqG!(P~EfD~CRlQcZ#X,k)u3vWs@u2]ksg;wEx'f@q1_2Wg.j]uNpn~FRfqJv]!15x'h{qG!(@@=IzK~CRl^j6v(us5x4i,#T(2WmY?C2F{1>Kq<aj1!*jTqIsBv=Wld~Cw`fj2Wl[j`v0u*~>RlT=c>Z,k#u3vWs@u2]kq<c1Z+jTqIsBv=Wle~Cw`fn2Wl]dn1#c(a(b^a2!b/bAT(bj!aDa7bu,a_a{c0!2T0g:v>ReD2@G{42@G{5~DpM~<5rc=Bx6i>{RT#RnI@zCx]y]z:2Jv[!zr5Awyk]9]k]dD(Y+X#6Vz.g=wKtgwhaCwgmTWj2Lu,w%_+/[y-B;b^xeg3u3Rj-2@bX{*KrJ<!+'@Wg(g?QRlC@Jv`!%b[zIwsfII}8JQ_@w|kW|=Jv(%!AqcOuNBJvEzh!bYzjLs@wP#(0!oy@>RkdJwMZtc3Dtd@BcG#T'9bWxg2@2Fznd*#Y+;2x'c}w<zizixNgwa#Z'U+!/!a'!a+w~g~z6wcn{Rn}wcnzRn|5Rh%=]nJg5vuRmvNvdRlvcprJu}w*az*a#!%.a.'Bot9qT]kj@Wg'ay2Gzv@Jv`!%b[zEwsfHI}1;ck#Ux`<Cbbx_Lu+w!a&0*!wko*wwo,So,}6Juqxf!E}PigQuyRm`d3(`#8>Rn%:A5B;bZ~%KvhCa!a2!x>k7#Uxb@b{#xaRk7Jw0!)>wwhlShl}6>wwhmShm}6CJvB!.x'hhvj{!!5Bwkhhbaz}x'hivjz~!5Bwkhibaz|xEhTrNu,v-vpD!a%&/)a3a.,%Ro2t[CE{)@3re9b]{%wjo09:rgc:Z&Ro6=<riifuaw&RmoKrNA!%(Ro4>Ro89;Ri`dSaL'UYzxZb)7Rka3xRhT&!,!#^1U}vbaz{>>@=be}yC@:D5bazzKu+A&!}{?ba}y>>@=be}wxBh[t`u~vJvr!%a!a()a,a0a4RoC=]o;Ju(!%RoGRhdwjh`=]oAg>w#Ro?g5vuRo=NvdRl|Ku]C.!&;RoEJvB!%RoORoMBx'h[v+_?w~h`}~5?w~hd~!xKh]oiptu-utv.vp!#%&a30a@a'a+(a/aOp(o~p!RoDJu(!%RoHRhewjha=]oBNvdRl}g>w#Ro@g5vuRo>c[#X']o<CauRoRAd-#Y':RkpauRoQKu]C.!&;RoFJvB!%RoNRoPBx'h]v+_?w~ha}t5?w~he}ue!/UbhYacXaW^Tc&a;b:a-c/#b&aja1(!cL+!bKbt!bmcRc9aIc?8[yW3Dtt94Rg`Jv}!&SiRMzBhEebShEMNuPRe>x7gL#TzuwjirRipc<Z&>on;>z=h-MSh.Mwqczx'a7vj&!>Re4@=ResJt__NuPRi*NuPRi)j]uNr|~FRfzKrJ>_+@Wfy@Wf]2WocKrJ<!+'@Wg%g/QRl@@Jv`!&awRl<wsfFIzgLu(w*!.*&ShBMwvhIRhI9;RhNx1hK'!#Sn]Mx1hK~0!#:2<H~7cNu+w7D*'1ZtW>Rn1~?rOc:Z&Rn2=<rQ<7wjh&=BSnLMc]#X(6Vz)w[b=a!U#9wzgMc3#&(RgMRitRis<x,gKt`ax!&+SioM=BSilMc3#&(RgKRinRimKurB,!&SiQMzBhDebShDM6BJQ!(P~Efx978B2@@=I}WLrJw!!,a*&@G}O@9wkibRid@@x'fKwC!&SlDMSfLMjUv~Q~EfKKv3@a+!(hFv-]mpx/hYZ(C5RiWz<o/MwkhY?So/M@x,gbvfB*&!SgEM:SoeeehFu3:Rgbda(,^TZa)X/7Sg[eb:2RgI~BrMC@wgkc:wwkcRerx3h(uUvK!&*,SnOM4Sh*MArRg;wHRh(x=h;rJvPwI!a4',a'0@Wg&=BSh/Mg>w=Rh=g3w*wwgGRgGcW(X#;Sg}M2Gzk@Jv`!&awRl=wsfGIz`dKZ*T'Y-:RhR7RhQg5u-p`j6v(us5d,#Y+~Awkia?RicOuNBwkibba}Ld6p~tyu_vbAa'a+!a/'a3aEa8a!>Sh,ebJv{!&Sh@ebSaReb9;SgwebNuPRi(NvdRl)NuPRi'hHu^<Rm^Jvv_@Wl(g;u1Si/ebKu'B&!*Sh?eb@Wl'z@aPeb95Si.ebcpputyvjB)!,&a+0a%ShAMWeK@G}C@WfJ9;RhMwvhH9w{ia}ix,hJvRA1(!zAn[MRhHx1hJ~*!#hFv(BSn[MBJQ!(@@=I~'978B2@@=I}2db.Ua<'X}+T#a0XaG2G}E;wkg|wuh!Rh!x,hZu,@)!&So0MVy)C5RiXACJvB!&5RiY5RiZg8w)cG}*T#2@bU}=KsA>(!a.3wkhZba~(x,h^u(A!&(SoCMRhb5Bz=h[eb?w~hb~6x,h_u(A!&(SoDMRhc5Bz=h]eb?w~hc~6e)aA1T#T,^^^c-bMb&blcPaP(a/!0!bA=b5c@a(!bfbrc#2afwmhARnjwchORnp2Wlf3DtsNvdRl-2@wpa<]m0bx(#:awRk2@Jw3!%RfhwpfgRlnKQB%!(G{V@G|'NuuRl6d='T+Y#VyUg<v~Rl~==G|<Jv+'!aYShC}6@B<5?ba~8@Jw3'!g2QRljhLrpWlOd+#Y'g.w'rIg>w*wgj@g-u0Rj@Lu+wT&)ZtUauq]~GrGci&U#F|39:rELrNvj!.%*RhCwunfw~nf~:9;Ri]>wtnhg;wHRnhx3hDs@v~!/+'@Wfr@9RkSNu&Rlo=@<5GzoKs0@_+@Wl+@awRkmJuh!-3d(}pY#qWJvj!%Rm(:Jw3!%Rm,Rm*de&!1U-U#`)Re;@G|.@9Ri82@wjfvRlq=@<5GzpLvOvr!).&2RlF8Rf`C=x!eE{.Jw3_g2QRlkhLrpWlPde(!#U{s,UXa*Ta'[y'g:v>ReS;x0PZ&RnlRnn~HrKJw1}f!=x!eB|2w]aP(#Xa&a*Ta.Ua2a7=]iOd'#Y&Ro&WnWg;u.RiDg6vjRiBNvdRlzhNvj]nYJuW_2Wm3x)kFze{9d])!a.!,Y01!#&aC!a3RndC=ox~BrC@2b^{pg,rlse7x'ksuq!%Rm.E{xidw(wBRmGx9o+)X#wwo-So-}69:Rl4@xSf@a#XZ'X)X,Ta(/ARl8b[xc>RfY:RlI:RfQwlg.ARl:9;Rlwdn'#^XafaQa1X1TaHTa)@b[{zcZ#X'7RkwWg@Ou4ARn&x)kG#{,g7u/RkGdH'U#Y*Vz'Wm&CARm|bx#(A]gUbUzJj9Q~=d,#Y(56H}l978H{U7d,0#U*2>ABb_xZ978BbU{e~AJQ{g!978BbU{hxMh?ad{oUYZ.x1h?{l!#:2<H{mx3n[t{vl!,&a%3Ro(z=iS}6ARnr=Bwsn^wvn`Rnbd`*T}B0!#^X'BG{c9b]{a>>@=be}F?JvS!&BG{d7BG}(Bde#`a1X,Ya@!a'P~=wxf@2bZ}I56B2@@=aybb}08@55B9;5bb}<j3vLv;<Jw3&!>Rfg=ayb^}&OuNBKuLA!)a!P~=x#fD{f2@>==<bbzl?C972@@=Ix^d6rSu,v7w*C(0a)a6#B+a%!sQ[y?3Dt%3[xn~<5rLOu!5p@Ku+D#'!t7~GrP~?rNKvlaya7'!h+v-5qMg=t|cd,U#5AAaa5Abb{S@52B5@a[@52B5Gx[iXueu;d<#`a(!/549C;ag>23ExY5@Dah89b^~689Jv)!~2b[~1Lv'w(%*!a#bX|aPrmawRe]keu7uhv-q6rxu,q`xTo]/a5aU!bNaDXbi!b-!ao!b<bwA!#5@B932:aV2G|:d-)Y#hJrL>RhG<7@C5<H|_=Cau:5aj5@B932:bJ|ng>vIbs)#?C2F|9jPv0w.vISh-MKvUaz(.!9ABbb|[5;5<H|Eg>unwfh;9:4E|YjQsBt|vjx'hYq3!(?C2F|J:2<BaY?C2F|GOu!5x,g|p{ah!-(?C2F|c9:4E|OjXuvvNr}:Rh&i[w*t|cd+U#jJvsu)vsSn~Mkfrmu9p}u7vwv]So!McW#Xa!ax5@A5aY:5;5<H|>kJv~vYrquJu3x4ib#T)2@SmZM?C2F|Bj:rmu9@xPhI(a*a#U#`a3-5Abb|L~@:RhK9:4E|0@52B5G|#C::aY?C2F|-:2<BaY?C2F|.5Jvk!a)javYrquJu3x4ia#T)2@SmYM?C2F|HAxPhH(!a#U#`a*-5Abb|4~@:RhJ9:4E|R@52B5G|F:2<BaY?C2F|Sc^#Xa2j=Qq5CJvB!-g<v{z;hhM?C2F|Zi[vrv{z;hiM?C2F|XKsA>!a)-g<v{z;h[eb?C2F|]i[vrv{z;h]eb?C2F|^iZu.vix,hZq3ah!.(?C2F|QOu!5ShXM:2<BaY?C2F|P",13494,2713,49,25,61),ay=new Uint16Array([512,26465,29036,7,0,2,4,116,24638,116,24636,8693,29807,24610,621,1,0,0,3,112,24614,111,115,24615]),oy;(function(e){e[e.VALUE_LENGTH=49152]=`VALUE_LENGTH`,e[e.FLAG13=8192]=`FLAG13`,e[e.BRANCH_LENGTH=8064]=`BRANCH_LENGTH`,e[e.JUMP_TABLE=127]=`JUMP_TABLE`,e[e.VALUE_MASK=8191]=`VALUE_MASK`})(oy||={});var sy;(function(e){e[e.AMP=38]=`AMP`,e[e.NUM=35]=`NUM`,e[e.SEMI=59]=`SEMI`,e[e.EQUALS=61]=`EQUALS`,e[e.ZERO=48]=`ZERO`,e[e.NINE=57]=`NINE`,e[e.LOWER_A=97]=`LOWER_A`,e[e.LOWER_X=120]=`LOWER_X`})(sy||={});var cy=32;function ly(e){return e-sy.ZERO>>>0<=9}function uy(e){return(e|cy)-sy.LOWER_A>>>0<=5}function dy(e){return(e|cy)-sy.LOWER_A>>>0<=25}function fy(e){return e===sy.EQUALS||dy(e)||ly(e)}var py;(function(e){e[e.EntityStart=0]=`EntityStart`,e[e.NumericStart=1]=`NumericStart`,e[e.NumericDecimal=2]=`NumericDecimal`,e[e.NumericHex=3]=`NumericHex`,e[e.NamedEntity=4]=`NamedEntity`})(py||={});var my;(function(e){e[e.Legacy=0]=`Legacy`,e[e.Strict=1]=`Strict`,e[e.Attribute=2]=`Attribute`})(my||={});var hy=class{decodeTree;emitCodePoint;errors;state=py.EntityStart;consumed=1;result=0;treeIndex=0;excess=1;decodeMode=my.Strict;runConsumed=0;constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n}startEntity(e){this.decodeMode=e,this.state=py.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1,this.runConsumed=0}write(e,t){switch(this.state){case py.EntityStart:return e.charCodeAt(t)===sy.NUM?(this.state=py.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=py.NamedEntity,this.stateNamedEntity(e,t));case py.NumericStart:return this.stateNumericStart(e,t);case py.NumericDecimal:return this.stateNumericDecimal(e,t);case py.NumericHex:return this.stateNumericHex(e,t);default:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(e.charCodeAt(t)|cy)===sy.LOWER_X?(this.state=py.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=py.NumericDecimal,this.stateNumericDecimal(e,t))}stateNumericHex(e,t){let n=e.length,{result:r}=this,{consumed:i}=this;for(;t<n;){let n=e.charCodeAt(t);if(ly(n)||uy(n)){let e=n<=sy.NINE?n-sy.ZERO:(n|cy)-sy.LOWER_A+10;r=r*16+e,i+=1,t+=1}else return this.result=r,this.consumed=i,this.emitNumericEntity(n,3)}return this.result=r,this.consumed=i,-1}stateNumericDecimal(e,t){let n=e.length,{result:r}=this,{consumed:i}=this;for(;t<n;){let n=e.charCodeAt(t)-sy.ZERO;if(n>>>0>9)return this.result=r,this.consumed=i,this.emitNumericEntity(n+sy.ZERO,2);r=r*10+n,i+=1,t+=1}return this.result=r,this.consumed=i,-1}emitNumericEntity(e,t){if(this.consumed<=t)return this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===sy.SEMI)this.consumed+=1;else if(this.decodeMode===my.Strict)return 0;return this.emitCodePoint((this.decodeTree===ay?ty:ey)(this.result),this.consumed),this.errors&&(e!==sy.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}flushAndEmitLegacyOrReject(e,t,n,r){return this.consumed=e,this.excess=t,this.result===0||this.decodeMode===my.Attribute&&(r===0||t>1||fy(n))?0:this.emitNotTerminatedNamedEntity()}stateNamedEntity(e,t){let{decodeTree:n}=this,r=e.length,i=this.decodeMode===my.Strict,{treeIndex:a}=this,{excess:o}=this,{consumed:s}=this,c=n[a];for(;t<r;){for(;(c&(oy.VALUE_LENGTH|oy.FLAG13))===0&&(c&oy.JUMP_TABLE)!==0;){let i=e.charCodeAt(t),l=c&oy.JUMP_TABLE,u=(c&oy.BRANCH_LENGTH)>>7;if(u===0){if(i!==l)return this.flushAndEmitLegacyOrReject(s,o,i,0);a+=1}else{let e=i-l;if(e>>>0>=u)return this.flushAndEmitLegacyOrReject(s,o,i,0);let t=n[a+1+e];if(t===0)return this.flushAndEmitLegacyOrReject(s,o,i,0);a=a+u+t&65535}if(c=n[a],t+=1,o+=1,t>=r)break}if(t>=r)break;if((c&(oy.VALUE_LENGTH|oy.FLAG13))===oy.FLAG13){let i=(c&oy.BRANCH_LENGTH)>>7,{runConsumed:l}=this;if(l===0){let n=e.charCodeAt(t);if(n!==(c&oy.JUMP_TABLE))return this.flushAndEmitLegacyOrReject(s,o,n,0);t+=1,o+=1,l=1}for(;l<i;){if(t>=r)return this.treeIndex=a,this.excess=o,this.consumed=s,this.runConsumed=l,-1;let i=l-1,c=n[a+1+(i>>1)]>>((i&1)<<3)&255,u=e.charCodeAt(t);if(u!==c)return this.runConsumed=0,this.flushAndEmitLegacyOrReject(s,o,u,0);t+=1,o+=1,l+=1}this.runConsumed=0,a+=1+(i>>1),c=n[a];continue}let l=c>>>14,u=e.charCodeAt(t);if(l!==0){if(!i&&(c&oy.FLAG13)===0&&(this.result=a,s+=o-1,o=1),u===sy.SEMI)return this.emitNamedEntityData(a,l,s+o);if(l===1)return this.flushAndEmitLegacyOrReject(s,o,u,l)}let d=gy(n,c,a+(l||1),u);if(d<0)return this.flushAndEmitLegacyOrReject(s,o,u,l);a=d,c=n[a],t+=1,o+=1}return!i&&c>>>14&&(c&oy.FLAG13)===0&&(this.result=a,s+=o-1,o=1),this.treeIndex=a,this.excess=o,this.consumed=s,-1}emitNotTerminatedNamedEntity(){let{result:e,decodeTree:t}=this,n=t[e]>>>14;return this.emitNamedEntityData(e,n,this.consumed),this.errors?.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,n){let{decodeTree:r}=this;return this.emitCodePoint(t===1?r[e]&oy.VALUE_MASK:r[e+1],n),t===3&&this.emitCodePoint(r[e+2],n),n}end(){switch(this.state){case py.NamedEntity:return this.result!==0&&(this.decodeMode!==my.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case py.NumericDecimal:return this.emitNumericEntity(0,2);case py.NumericHex:return this.emitNumericEntity(0,3);case py.NumericStart:return this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed),0;default:return 0}}};function gy(e,t,n,r){let i=(t&oy.BRANCH_LENGTH)>>7,a=t&oy.JUMP_TABLE;if(a){if(i===0)return r===a?n:-1;let t=r-a;if(t>>>0>=i)return-1;let o=e[n+t];return o===0?-1:n+i+o-1&65535}if(i===0)return-1;let o=i+1>>1,s=n+o+i;for(let t=0;t<i;t++){let i=e[n+(t>>1)]>>((t&1)<<3)&255;if(i===r)return s+e[n+o+t]&65535;if(i>r)return-1}return-1}var K;(function(e){e.HTML=`http://www.w3.org/1999/xhtml`,e.MATHML=`http://www.w3.org/1998/Math/MathML`,e.SVG=`http://www.w3.org/2000/svg`,e.XLINK=`http://www.w3.org/1999/xlink`,e.XML=`http://www.w3.org/XML/1998/namespace`,e.XMLNS=`http://www.w3.org/2000/xmlns/`})(K||={});var _y;(function(e){e.TYPE=`type`,e.ACTION=`action`,e.ENCODING=`encoding`,e.PROMPT=`prompt`,e.NAME=`name`,e.COLOR=`color`,e.FACE=`face`,e.SIZE=`size`})(_y||={});var vy;(function(e){e.NO_QUIRKS=`no-quirks`,e.QUIRKS=`quirks`,e.LIMITED_QUIRKS=`limited-quirks`})(vy||={});var q;(function(e){e.A=`a`,e.ADDRESS=`address`,e.ANNOTATION_XML=`annotation-xml`,e.APPLET=`applet`,e.AREA=`area`,e.ARTICLE=`article`,e.ASIDE=`aside`,e.B=`b`,e.BASE=`base`,e.BASEFONT=`basefont`,e.BGSOUND=`bgsound`,e.BIG=`big`,e.BLOCKQUOTE=`blockquote`,e.BODY=`body`,e.BR=`br`,e.BUTTON=`button`,e.CAPTION=`caption`,e.CENTER=`center`,e.CODE=`code`,e.COL=`col`,e.COLGROUP=`colgroup`,e.DD=`dd`,e.DESC=`desc`,e.DETAILS=`details`,e.DIALOG=`dialog`,e.DIR=`dir`,e.DIV=`div`,e.DL=`dl`,e.DT=`dt`,e.EM=`em`,e.EMBED=`embed`,e.FIELDSET=`fieldset`,e.FIGCAPTION=`figcaption`,e.FIGURE=`figure`,e.FONT=`font`,e.FOOTER=`footer`,e.FOREIGN_OBJECT=`foreignObject`,e.FORM=`form`,e.FRAME=`frame`,e.FRAMESET=`frameset`,e.H1=`h1`,e.H2=`h2`,e.H3=`h3`,e.H4=`h4`,e.H5=`h5`,e.H6=`h6`,e.HEAD=`head`,e.HEADER=`header`,e.HGROUP=`hgroup`,e.HR=`hr`,e.HTML=`html`,e.I=`i`,e.IMG=`img`,e.IMAGE=`image`,e.INPUT=`input`,e.IFRAME=`iframe`,e.KEYGEN=`keygen`,e.LABEL=`label`,e.LI=`li`,e.LINK=`link`,e.LISTING=`listing`,e.MAIN=`main`,e.MALIGNMARK=`malignmark`,e.MARQUEE=`marquee`,e.MATH=`math`,e.MENU=`menu`,e.META=`meta`,e.MGLYPH=`mglyph`,e.MI=`mi`,e.MO=`mo`,e.MN=`mn`,e.MS=`ms`,e.MTEXT=`mtext`,e.NAV=`nav`,e.NOBR=`nobr`,e.NOFRAMES=`noframes`,e.NOEMBED=`noembed`,e.NOSCRIPT=`noscript`,e.OBJECT=`object`,e.OL=`ol`,e.OPTGROUP=`optgroup`,e.OPTION=`option`,e.P=`p`,e.PARAM=`param`,e.PLAINTEXT=`plaintext`,e.PRE=`pre`,e.RB=`rb`,e.RP=`rp`,e.RT=`rt`,e.RTC=`rtc`,e.RUBY=`ruby`,e.S=`s`,e.SCRIPT=`script`,e.SEARCH=`search`,e.SECTION=`section`,e.SELECT=`select`,e.SOURCE=`source`,e.SMALL=`small`,e.SPAN=`span`,e.STRIKE=`strike`,e.STRONG=`strong`,e.STYLE=`style`,e.SUB=`sub`,e.SUMMARY=`summary`,e.SUP=`sup`,e.TABLE=`table`,e.TBODY=`tbody`,e.TEMPLATE=`template`,e.TEXTAREA=`textarea`,e.TFOOT=`tfoot`,e.TD=`td`,e.TH=`th`,e.THEAD=`thead`,e.TITLE=`title`,e.TR=`tr`,e.TRACK=`track`,e.TT=`tt`,e.U=`u`,e.UL=`ul`,e.SVG=`svg`,e.VAR=`var`,e.WBR=`wbr`,e.XMP=`xmp`})(q||={});var J;(function(e){e[e.UNKNOWN=0]=`UNKNOWN`,e[e.A=1]=`A`,e[e.ADDRESS=2]=`ADDRESS`,e[e.ANNOTATION_XML=3]=`ANNOTATION_XML`,e[e.APPLET=4]=`APPLET`,e[e.AREA=5]=`AREA`,e[e.ARTICLE=6]=`ARTICLE`,e[e.ASIDE=7]=`ASIDE`,e[e.B=8]=`B`,e[e.BASE=9]=`BASE`,e[e.BASEFONT=10]=`BASEFONT`,e[e.BGSOUND=11]=`BGSOUND`,e[e.BIG=12]=`BIG`,e[e.BLOCKQUOTE=13]=`BLOCKQUOTE`,e[e.BODY=14]=`BODY`,e[e.BR=15]=`BR`,e[e.BUTTON=16]=`BUTTON`,e[e.CAPTION=17]=`CAPTION`,e[e.CENTER=18]=`CENTER`,e[e.CODE=19]=`CODE`,e[e.COL=20]=`COL`,e[e.COLGROUP=21]=`COLGROUP`,e[e.DD=22]=`DD`,e[e.DESC=23]=`DESC`,e[e.DETAILS=24]=`DETAILS`,e[e.DIALOG=25]=`DIALOG`,e[e.DIR=26]=`DIR`,e[e.DIV=27]=`DIV`,e[e.DL=28]=`DL`,e[e.DT=29]=`DT`,e[e.EM=30]=`EM`,e[e.EMBED=31]=`EMBED`,e[e.FIELDSET=32]=`FIELDSET`,e[e.FIGCAPTION=33]=`FIGCAPTION`,e[e.FIGURE=34]=`FIGURE`,e[e.FONT=35]=`FONT`,e[e.FOOTER=36]=`FOOTER`,e[e.FOREIGN_OBJECT=37]=`FOREIGN_OBJECT`,e[e.FORM=38]=`FORM`,e[e.FRAME=39]=`FRAME`,e[e.FRAMESET=40]=`FRAMESET`,e[e.H1=41]=`H1`,e[e.H2=42]=`H2`,e[e.H3=43]=`H3`,e[e.H4=44]=`H4`,e[e.H5=45]=`H5`,e[e.H6=46]=`H6`,e[e.HEAD=47]=`HEAD`,e[e.HEADER=48]=`HEADER`,e[e.HGROUP=49]=`HGROUP`,e[e.HR=50]=`HR`,e[e.HTML=51]=`HTML`,e[e.I=52]=`I`,e[e.IMG=53]=`IMG`,e[e.IMAGE=54]=`IMAGE`,e[e.INPUT=55]=`INPUT`,e[e.IFRAME=56]=`IFRAME`,e[e.KEYGEN=57]=`KEYGEN`,e[e.LABEL=58]=`LABEL`,e[e.LI=59]=`LI`,e[e.LINK=60]=`LINK`,e[e.LISTING=61]=`LISTING`,e[e.MAIN=62]=`MAIN`,e[e.MALIGNMARK=63]=`MALIGNMARK`,e[e.MARQUEE=64]=`MARQUEE`,e[e.MATH=65]=`MATH`,e[e.MENU=66]=`MENU`,e[e.META=67]=`META`,e[e.MGLYPH=68]=`MGLYPH`,e[e.MI=69]=`MI`,e[e.MO=70]=`MO`,e[e.MN=71]=`MN`,e[e.MS=72]=`MS`,e[e.MTEXT=73]=`MTEXT`,e[e.NAV=74]=`NAV`,e[e.NOBR=75]=`NOBR`,e[e.NOFRAMES=76]=`NOFRAMES`,e[e.NOEMBED=77]=`NOEMBED`,e[e.NOSCRIPT=78]=`NOSCRIPT`,e[e.OBJECT=79]=`OBJECT`,e[e.OL=80]=`OL`,e[e.OPTGROUP=81]=`OPTGROUP`,e[e.OPTION=82]=`OPTION`,e[e.P=83]=`P`,e[e.PARAM=84]=`PARAM`,e[e.PLAINTEXT=85]=`PLAINTEXT`,e[e.PRE=86]=`PRE`,e[e.RB=87]=`RB`,e[e.RP=88]=`RP`,e[e.RT=89]=`RT`,e[e.RTC=90]=`RTC`,e[e.RUBY=91]=`RUBY`,e[e.S=92]=`S`,e[e.SCRIPT=93]=`SCRIPT`,e[e.SEARCH=94]=`SEARCH`,e[e.SECTION=95]=`SECTION`,e[e.SELECT=96]=`SELECT`,e[e.SOURCE=97]=`SOURCE`,e[e.SMALL=98]=`SMALL`,e[e.SPAN=99]=`SPAN`,e[e.STRIKE=100]=`STRIKE`,e[e.STRONG=101]=`STRONG`,e[e.STYLE=102]=`STYLE`,e[e.SUB=103]=`SUB`,e[e.SUMMARY=104]=`SUMMARY`,e[e.SUP=105]=`SUP`,e[e.TABLE=106]=`TABLE`,e[e.TBODY=107]=`TBODY`,e[e.TEMPLATE=108]=`TEMPLATE`,e[e.TEXTAREA=109]=`TEXTAREA`,e[e.TFOOT=110]=`TFOOT`,e[e.TD=111]=`TD`,e[e.TH=112]=`TH`,e[e.THEAD=113]=`THEAD`,e[e.TITLE=114]=`TITLE`,e[e.TR=115]=`TR`,e[e.TRACK=116]=`TRACK`,e[e.TT=117]=`TT`,e[e.U=118]=`U`,e[e.UL=119]=`UL`,e[e.SVG=120]=`SVG`,e[e.VAR=121]=`VAR`,e[e.WBR=122]=`WBR`,e[e.XMP=123]=`XMP`})(J||={});var yy=new Map([[q.A,J.A],[q.ADDRESS,J.ADDRESS],[q.ANNOTATION_XML,J.ANNOTATION_XML],[q.APPLET,J.APPLET],[q.AREA,J.AREA],[q.ARTICLE,J.ARTICLE],[q.ASIDE,J.ASIDE],[q.B,J.B],[q.BASE,J.BASE],[q.BASEFONT,J.BASEFONT],[q.BGSOUND,J.BGSOUND],[q.BIG,J.BIG],[q.BLOCKQUOTE,J.BLOCKQUOTE],[q.BODY,J.BODY],[q.BR,J.BR],[q.BUTTON,J.BUTTON],[q.CAPTION,J.CAPTION],[q.CENTER,J.CENTER],[q.CODE,J.CODE],[q.COL,J.COL],[q.COLGROUP,J.COLGROUP],[q.DD,J.DD],[q.DESC,J.DESC],[q.DETAILS,J.DETAILS],[q.DIALOG,J.DIALOG],[q.DIR,J.DIR],[q.DIV,J.DIV],[q.DL,J.DL],[q.DT,J.DT],[q.EM,J.EM],[q.EMBED,J.EMBED],[q.FIELDSET,J.FIELDSET],[q.FIGCAPTION,J.FIGCAPTION],[q.FIGURE,J.FIGURE],[q.FONT,J.FONT],[q.FOOTER,J.FOOTER],[q.FOREIGN_OBJECT,J.FOREIGN_OBJECT],[q.FORM,J.FORM],[q.FRAME,J.FRAME],[q.FRAMESET,J.FRAMESET],[q.H1,J.H1],[q.H2,J.H2],[q.H3,J.H3],[q.H4,J.H4],[q.H5,J.H5],[q.H6,J.H6],[q.HEAD,J.HEAD],[q.HEADER,J.HEADER],[q.HGROUP,J.HGROUP],[q.HR,J.HR],[q.HTML,J.HTML],[q.I,J.I],[q.IMG,J.IMG],[q.IMAGE,J.IMAGE],[q.INPUT,J.INPUT],[q.IFRAME,J.IFRAME],[q.KEYGEN,J.KEYGEN],[q.LABEL,J.LABEL],[q.LI,J.LI],[q.LINK,J.LINK],[q.LISTING,J.LISTING],[q.MAIN,J.MAIN],[q.MALIGNMARK,J.MALIGNMARK],[q.MARQUEE,J.MARQUEE],[q.MATH,J.MATH],[q.MENU,J.MENU],[q.META,J.META],[q.MGLYPH,J.MGLYPH],[q.MI,J.MI],[q.MO,J.MO],[q.MN,J.MN],[q.MS,J.MS],[q.MTEXT,J.MTEXT],[q.NAV,J.NAV],[q.NOBR,J.NOBR],[q.NOFRAMES,J.NOFRAMES],[q.NOEMBED,J.NOEMBED],[q.NOSCRIPT,J.NOSCRIPT],[q.OBJECT,J.OBJECT],[q.OL,J.OL],[q.OPTGROUP,J.OPTGROUP],[q.OPTION,J.OPTION],[q.P,J.P],[q.PARAM,J.PARAM],[q.PLAINTEXT,J.PLAINTEXT],[q.PRE,J.PRE],[q.RB,J.RB],[q.RP,J.RP],[q.RT,J.RT],[q.RTC,J.RTC],[q.RUBY,J.RUBY],[q.S,J.S],[q.SCRIPT,J.SCRIPT],[q.SEARCH,J.SEARCH],[q.SECTION,J.SECTION],[q.SELECT,J.SELECT],[q.SOURCE,J.SOURCE],[q.SMALL,J.SMALL],[q.SPAN,J.SPAN],[q.STRIKE,J.STRIKE],[q.STRONG,J.STRONG],[q.STYLE,J.STYLE],[q.SUB,J.SUB],[q.SUMMARY,J.SUMMARY],[q.SUP,J.SUP],[q.TABLE,J.TABLE],[q.TBODY,J.TBODY],[q.TEMPLATE,J.TEMPLATE],[q.TEXTAREA,J.TEXTAREA],[q.TFOOT,J.TFOOT],[q.TD,J.TD],[q.TH,J.TH],[q.THEAD,J.THEAD],[q.TITLE,J.TITLE],[q.TR,J.TR],[q.TRACK,J.TRACK],[q.TT,J.TT],[q.U,J.U],[q.UL,J.UL],[q.SVG,J.SVG],[q.VAR,J.VAR],[q.WBR,J.WBR],[q.XMP,J.XMP]]);function by(e){return yy.get(e)??J.UNKNOWN}var Y=J,xy={[K.HTML]:new Set([Y.ADDRESS,Y.APPLET,Y.AREA,Y.ARTICLE,Y.ASIDE,Y.BASE,Y.BASEFONT,Y.BGSOUND,Y.BLOCKQUOTE,Y.BODY,Y.BR,Y.BUTTON,Y.CAPTION,Y.CENTER,Y.COL,Y.COLGROUP,Y.DD,Y.DETAILS,Y.DIR,Y.DIV,Y.DL,Y.DT,Y.EMBED,Y.FIELDSET,Y.FIGCAPTION,Y.FIGURE,Y.FOOTER,Y.FORM,Y.FRAME,Y.FRAMESET,Y.H1,Y.H2,Y.H3,Y.H4,Y.H5,Y.H6,Y.HEAD,Y.HEADER,Y.HGROUP,Y.HR,Y.HTML,Y.IFRAME,Y.IMG,Y.INPUT,Y.LI,Y.LINK,Y.LISTING,Y.MAIN,Y.MARQUEE,Y.MENU,Y.META,Y.NAV,Y.NOEMBED,Y.NOFRAMES,Y.NOSCRIPT,Y.OBJECT,Y.OL,Y.P,Y.PARAM,Y.PLAINTEXT,Y.PRE,Y.SCRIPT,Y.SECTION,Y.SELECT,Y.SOURCE,Y.STYLE,Y.SUMMARY,Y.TABLE,Y.TBODY,Y.TD,Y.TEMPLATE,Y.TEXTAREA,Y.TFOOT,Y.TH,Y.THEAD,Y.TITLE,Y.TR,Y.TRACK,Y.UL,Y.WBR,Y.XMP]),[K.MATHML]:new Set([Y.MI,Y.MO,Y.MN,Y.MS,Y.MTEXT,Y.ANNOTATION_XML]),[K.SVG]:new Set([Y.TITLE,Y.FOREIGN_OBJECT,Y.DESC]),[K.XLINK]:new Set,[K.XML]:new Set,[K.XMLNS]:new Set},Sy=new Set([Y.H1,Y.H2,Y.H3,Y.H4,Y.H5,Y.H6]);q.STYLE,q.SCRIPT,q.XMP,q.IFRAME,q.NOEMBED,q.NOFRAMES,q.PLAINTEXT;var X;(function(e){e[e.DATA=0]=`DATA`,e[e.RCDATA=1]=`RCDATA`,e[e.RAWTEXT=2]=`RAWTEXT`,e[e.SCRIPT_DATA=3]=`SCRIPT_DATA`,e[e.PLAINTEXT=4]=`PLAINTEXT`,e[e.TAG_OPEN=5]=`TAG_OPEN`,e[e.END_TAG_OPEN=6]=`END_TAG_OPEN`,e[e.TAG_NAME=7]=`TAG_NAME`,e[e.RCDATA_LESS_THAN_SIGN=8]=`RCDATA_LESS_THAN_SIGN`,e[e.RCDATA_END_TAG_OPEN=9]=`RCDATA_END_TAG_OPEN`,e[e.RCDATA_END_TAG_NAME=10]=`RCDATA_END_TAG_NAME`,e[e.RAWTEXT_LESS_THAN_SIGN=11]=`RAWTEXT_LESS_THAN_SIGN`,e[e.RAWTEXT_END_TAG_OPEN=12]=`RAWTEXT_END_TAG_OPEN`,e[e.RAWTEXT_END_TAG_NAME=13]=`RAWTEXT_END_TAG_NAME`,e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]=`SCRIPT_DATA_LESS_THAN_SIGN`,e[e.SCRIPT_DATA_END_TAG_OPEN=15]=`SCRIPT_DATA_END_TAG_OPEN`,e[e.SCRIPT_DATA_END_TAG_NAME=16]=`SCRIPT_DATA_END_TAG_NAME`,e[e.SCRIPT_DATA_ESCAPE_START=17]=`SCRIPT_DATA_ESCAPE_START`,e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]=`SCRIPT_DATA_ESCAPE_START_DASH`,e[e.SCRIPT_DATA_ESCAPED=19]=`SCRIPT_DATA_ESCAPED`,e[e.SCRIPT_DATA_ESCAPED_DASH=20]=`SCRIPT_DATA_ESCAPED_DASH`,e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]=`SCRIPT_DATA_ESCAPED_DASH_DASH`,e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]=`SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN`,e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]=`SCRIPT_DATA_ESCAPED_END_TAG_OPEN`,e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]=`SCRIPT_DATA_ESCAPED_END_TAG_NAME`,e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]=`SCRIPT_DATA_DOUBLE_ESCAPE_START`,e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]=`SCRIPT_DATA_DOUBLE_ESCAPED`,e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]=`SCRIPT_DATA_DOUBLE_ESCAPED_DASH`,e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]=`SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH`,e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]=`SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN`,e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]=`SCRIPT_DATA_DOUBLE_ESCAPE_END`,e[e.BEFORE_ATTRIBUTE_NAME=31]=`BEFORE_ATTRIBUTE_NAME`,e[e.ATTRIBUTE_NAME=32]=`ATTRIBUTE_NAME`,e[e.AFTER_ATTRIBUTE_NAME=33]=`AFTER_ATTRIBUTE_NAME`,e[e.BEFORE_ATTRIBUTE_VALUE=34]=`BEFORE_ATTRIBUTE_VALUE`,e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]=`ATTRIBUTE_VALUE_DOUBLE_QUOTED`,e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]=`ATTRIBUTE_VALUE_SINGLE_QUOTED`,e[e.ATTRIBUTE_VALUE_UNQUOTED=37]=`ATTRIBUTE_VALUE_UNQUOTED`,e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]=`AFTER_ATTRIBUTE_VALUE_QUOTED`,e[e.SELF_CLOSING_START_TAG=39]=`SELF_CLOSING_START_TAG`,e[e.BOGUS_COMMENT=40]=`BOGUS_COMMENT`,e[e.MARKUP_DECLARATION_OPEN=41]=`MARKUP_DECLARATION_OPEN`,e[e.COMMENT_START=42]=`COMMENT_START`,e[e.COMMENT_START_DASH=43]=`COMMENT_START_DASH`,e[e.COMMENT=44]=`COMMENT`,e[e.COMMENT_LESS_THAN_SIGN=45]=`COMMENT_LESS_THAN_SIGN`,e[e.COMMENT_LESS_THAN_SIGN_BANG=46]=`COMMENT_LESS_THAN_SIGN_BANG`,e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]=`COMMENT_LESS_THAN_SIGN_BANG_DASH`,e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]=`COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH`,e[e.COMMENT_END_DASH=49]=`COMMENT_END_DASH`,e[e.COMMENT_END=50]=`COMMENT_END`,e[e.COMMENT_END_BANG=51]=`COMMENT_END_BANG`,e[e.DOCTYPE=52]=`DOCTYPE`,e[e.BEFORE_DOCTYPE_NAME=53]=`BEFORE_DOCTYPE_NAME`,e[e.DOCTYPE_NAME=54]=`DOCTYPE_NAME`,e[e.AFTER_DOCTYPE_NAME=55]=`AFTER_DOCTYPE_NAME`,e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]=`AFTER_DOCTYPE_PUBLIC_KEYWORD`,e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]=`BEFORE_DOCTYPE_PUBLIC_IDENTIFIER`,e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]=`DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED`,e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]=`DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED`,e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]=`AFTER_DOCTYPE_PUBLIC_IDENTIFIER`,e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]=`BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS`,e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]=`AFTER_DOCTYPE_SYSTEM_KEYWORD`,e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]=`BEFORE_DOCTYPE_SYSTEM_IDENTIFIER`,e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]=`DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED`,e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]=`DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED`,e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]=`AFTER_DOCTYPE_SYSTEM_IDENTIFIER`,e[e.BOGUS_DOCTYPE=67]=`BOGUS_DOCTYPE`,e[e.CDATA_SECTION=68]=`CDATA_SECTION`,e[e.CDATA_SECTION_BRACKET=69]=`CDATA_SECTION_BRACKET`,e[e.CDATA_SECTION_END=70]=`CDATA_SECTION_END`,e[e.CHARACTER_REFERENCE=71]=`CHARACTER_REFERENCE`,e[e.AMBIGUOUS_AMPERSAND=72]=`AMBIGUOUS_AMPERSAND`})(X||={});var Cy={DATA:X.DATA,RCDATA:X.RCDATA,RAWTEXT:X.RAWTEXT,SCRIPT_DATA:X.SCRIPT_DATA,PLAINTEXT:X.PLAINTEXT,CDATA_SECTION:X.CDATA_SECTION};function wy(e){return e>=W.DIGIT_0&&e<=W.DIGIT_9}function Ty(e){return e>=W.LATIN_CAPITAL_A&&e<=W.LATIN_CAPITAL_Z}function Ey(e){return e>=W.LATIN_SMALL_A&&e<=W.LATIN_SMALL_Z}function Dy(e){return Ey(e)||Ty(e)}function Oy(e){return Dy(e)||wy(e)}function ky(e){return e+32}function Ay(e){return e===W.SPACE||e===W.LINE_FEED||e===W.TABULATION||e===W.FORM_FEED}function jy(e){return Ay(e)||e===W.SOLIDUS||e===W.GREATER_THAN_SIGN}function My(e){return e===W.NULL?G.nullCharacterReference:e>1114111?G.characterReferenceOutsideUnicodeRange:Uv(e)?G.surrogateCharacterReference:qv(e)?G.noncharacterCharacterReference:Kv(e)||e===W.CARRIAGE_RETURN?G.controlCharacterReference:null}var Ny=class{constructor(e,t){this.options=e,this.handler=t,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName=``,this.active=!1,this.state=X.DATA,this.returnState=X.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:``,value:``},this.preprocessor=new Yv(t),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new hy(iy,(e,t)=>{this.preprocessor.pos=this.entityStartPos+t-1,this._flushCodePointConsumedAsCharacterReference(e)},t.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(G.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:e=>{this._err(G.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+e)},validateNumericCharacterReference:e=>{let t=My(e);t&&this._err(t,1)}}:void 0)}_err(e,t=0){var n,r;(r=(n=this.handler).onParseError)==null||r.call(n,this.preprocessor.getError(e,t))}getCurrentLocation(e){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-e,startOffset:this.preprocessor.offset-e,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;let e=this._consume();this._ensureHibernation()||this._callState(e)}this.inLoop=!1}}pause(){this.paused=!0}resume(e){if(!this.paused)throw Error(`Parser was already resumed`);this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||e?.())}write(e,t,n){this.active=!0,this.preprocessor.write(e,t),this._runParsingLoop(),this.paused||n?.()}insertHtmlAtCurrentPos(e){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(e),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(e){this.consumedAfterSnapshot+=e;for(let t=0;t<e;t++)this.preprocessor.advance()}_consumeSequenceIfMatch(e,t){return this.preprocessor.startsWith(e,t)?(this._advanceBy(e.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:Xv.START_TAG,tagName:``,tagID:J.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:Xv.END_TAG,tagName:``,tagID:J.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(e){this.currentToken={type:Xv.COMMENT,data:``,location:this.getCurrentLocation(e)}}_createDoctypeToken(e){this.currentToken={type:Xv.DOCTYPE,name:e,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(e,t){this.currentCharacterToken={type:e,chars:t,location:this.currentLocation}}_createAttr(e){this.currentAttr={name:e,value:``},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var e;let t=this.currentToken;if(Zv(t,this.currentAttr.name)===null){if(t.attrs.push(this.currentAttr),t.location&&this.currentLocation){let n=(e=t.location).attrs??(e.attrs=Object.create(null));n[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(G.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(e){this._emitCurrentCharacterToken(e.location),this.currentToken=null,e.location&&(e.location.endLine=this.preprocessor.line,e.location.endCol=this.preprocessor.col+1,e.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){let e=this.currentToken;this.prepareToken(e),e.tagID=by(e.tagName),e.type===Xv.START_TAG?(this.lastStartTagName=e.tagName,this.handler.onStartTag(e)):(e.attrs.length>0&&this._err(G.endTagWithAttributes),e.selfClosing&&this._err(G.endTagWithTrailingSolidus),this.handler.onEndTag(e)),this.preprocessor.dropParsedChunk()}emitCurrentComment(e){this.prepareToken(e),this.handler.onComment(e),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(e){this.prepareToken(e),this.handler.onDoctype(e),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(e){if(this.currentCharacterToken){switch(e&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=e.startLine,this.currentCharacterToken.location.endCol=e.startCol,this.currentCharacterToken.location.endOffset=e.startOffset),this.currentCharacterToken.type){case Xv.CHARACTER:this.handler.onCharacter(this.currentCharacterToken);break;case Xv.NULL_CHARACTER:this.handler.onNullCharacter(this.currentCharacterToken);break;case Xv.WHITESPACE_CHARACTER:this.handler.onWhitespaceCharacter(this.currentCharacterToken)}this.currentCharacterToken=null}}_emitEOFToken(){let e=this.getCurrentLocation(0);e&&(e.endLine=e.startLine,e.endCol=e.startCol,e.endOffset=e.startOffset),this._emitCurrentCharacterToken(e),this.handler.onEof({type:Xv.EOF,location:e}),this.active=!1}_appendCharToCurrentCharacterToken(e,t){if(this.currentCharacterToken){if(this.currentCharacterToken.type===e){this.currentCharacterToken.chars+=t;return}this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk()}this._createCharacterToken(e,t)}_emitCodePoint(e){let t=Ay(e)?Xv.WHITESPACE_CHARACTER:e===W.NULL?Xv.NULL_CHARACTER:Xv.CHARACTER;this._appendCharToCurrentCharacterToken(t,e<65536?String.fromCharCode(e):String.fromCodePoint(e))}_emitChars(e){this._appendCharToCurrentCharacterToken(Xv.CHARACTER,e)}_startCharacterReference(){this.returnState=this.state,this.state=X.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?my.Attribute:my.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===X.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===X.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===X.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(e){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(e):this._emitCodePoint(e)}_callState(e){switch(this.state){case X.DATA:this._stateData(e);break;case X.RCDATA:this._stateRcdata(e);break;case X.RAWTEXT:this._stateRawtext(e);break;case X.SCRIPT_DATA:this._stateScriptData(e);break;case X.PLAINTEXT:this._statePlaintext(e);break;case X.TAG_OPEN:this._stateTagOpen(e);break;case X.END_TAG_OPEN:this._stateEndTagOpen(e);break;case X.TAG_NAME:this._stateTagName(e);break;case X.RCDATA_LESS_THAN_SIGN:this._stateRcdataLessThanSign(e);break;case X.RCDATA_END_TAG_OPEN:this._stateRcdataEndTagOpen(e);break;case X.RCDATA_END_TAG_NAME:this._stateRcdataEndTagName(e);break;case X.RAWTEXT_LESS_THAN_SIGN:this._stateRawtextLessThanSign(e);break;case X.RAWTEXT_END_TAG_OPEN:this._stateRawtextEndTagOpen(e);break;case X.RAWTEXT_END_TAG_NAME:this._stateRawtextEndTagName(e);break;case X.SCRIPT_DATA_LESS_THAN_SIGN:this._stateScriptDataLessThanSign(e);break;case X.SCRIPT_DATA_END_TAG_OPEN:this._stateScriptDataEndTagOpen(e);break;case X.SCRIPT_DATA_END_TAG_NAME:this._stateScriptDataEndTagName(e);break;case X.SCRIPT_DATA_ESCAPE_START:this._stateScriptDataEscapeStart(e);break;case X.SCRIPT_DATA_ESCAPE_START_DASH:this._stateScriptDataEscapeStartDash(e);break;case X.SCRIPT_DATA_ESCAPED:this._stateScriptDataEscaped(e);break;case X.SCRIPT_DATA_ESCAPED_DASH:this._stateScriptDataEscapedDash(e);break;case X.SCRIPT_DATA_ESCAPED_DASH_DASH:this._stateScriptDataEscapedDashDash(e);break;case X.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataEscapedLessThanSign(e);break;case X.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:this._stateScriptDataEscapedEndTagOpen(e);break;case X.SCRIPT_DATA_ESCAPED_END_TAG_NAME:this._stateScriptDataEscapedEndTagName(e);break;case X.SCRIPT_DATA_DOUBLE_ESCAPE_START:this._stateScriptDataDoubleEscapeStart(e);break;case X.SCRIPT_DATA_DOUBLE_ESCAPED:this._stateScriptDataDoubleEscaped(e);break;case X.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:this._stateScriptDataDoubleEscapedDash(e);break;case X.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:this._stateScriptDataDoubleEscapedDashDash(e);break;case X.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataDoubleEscapedLessThanSign(e);break;case X.SCRIPT_DATA_DOUBLE_ESCAPE_END:this._stateScriptDataDoubleEscapeEnd(e);break;case X.BEFORE_ATTRIBUTE_NAME:this._stateBeforeAttributeName(e);break;case X.ATTRIBUTE_NAME:this._stateAttributeName(e);break;case X.AFTER_ATTRIBUTE_NAME:this._stateAfterAttributeName(e);break;case X.BEFORE_ATTRIBUTE_VALUE:this._stateBeforeAttributeValue(e);break;case X.ATTRIBUTE_VALUE_DOUBLE_QUOTED:this._stateAttributeValueDoubleQuoted(e);break;case X.ATTRIBUTE_VALUE_SINGLE_QUOTED:this._stateAttributeValueSingleQuoted(e);break;case X.ATTRIBUTE_VALUE_UNQUOTED:this._stateAttributeValueUnquoted(e);break;case X.AFTER_ATTRIBUTE_VALUE_QUOTED:this._stateAfterAttributeValueQuoted(e);break;case X.SELF_CLOSING_START_TAG:this._stateSelfClosingStartTag(e);break;case X.BOGUS_COMMENT:this._stateBogusComment(e);break;case X.MARKUP_DECLARATION_OPEN:this._stateMarkupDeclarationOpen(e);break;case X.COMMENT_START:this._stateCommentStart(e);break;case X.COMMENT_START_DASH:this._stateCommentStartDash(e);break;case X.COMMENT:this._stateComment(e);break;case X.COMMENT_LESS_THAN_SIGN:this._stateCommentLessThanSign(e);break;case X.COMMENT_LESS_THAN_SIGN_BANG:this._stateCommentLessThanSignBang(e);break;case X.COMMENT_LESS_THAN_SIGN_BANG_DASH:this._stateCommentLessThanSignBangDash(e);break;case X.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:this._stateCommentLessThanSignBangDashDash(e);break;case X.COMMENT_END_DASH:this._stateCommentEndDash(e);break;case X.COMMENT_END:this._stateCommentEnd(e);break;case X.COMMENT_END_BANG:this._stateCommentEndBang(e);break;case X.DOCTYPE:this._stateDoctype(e);break;case X.BEFORE_DOCTYPE_NAME:this._stateBeforeDoctypeName(e);break;case X.DOCTYPE_NAME:this._stateDoctypeName(e);break;case X.AFTER_DOCTYPE_NAME:this._stateAfterDoctypeName(e);break;case X.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._stateAfterDoctypePublicKeyword(e);break;case X.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:this._stateBeforeDoctypePublicIdentifier(e);break;case X.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypePublicIdentifierDoubleQuoted(e);break;case X.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypePublicIdentifierSingleQuoted(e);break;case X.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:this._stateAfterDoctypePublicIdentifier(e);break;case X.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:this._stateBetweenDoctypePublicAndSystemIdentifiers(e);break;case X.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._stateAfterDoctypeSystemKeyword(e);break;case X.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:this._stateBeforeDoctypeSystemIdentifier(e);break;case X.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypeSystemIdentifierDoubleQuoted(e);break;case X.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypeSystemIdentifierSingleQuoted(e);break;case X.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:this._stateAfterDoctypeSystemIdentifier(e);break;case X.BOGUS_DOCTYPE:this._stateBogusDoctype(e);break;case X.CDATA_SECTION:this._stateCdataSection(e);break;case X.CDATA_SECTION_BRACKET:this._stateCdataSectionBracket(e);break;case X.CDATA_SECTION_END:this._stateCdataSectionEnd(e);break;case X.CHARACTER_REFERENCE:this._stateCharacterReference();break;case X.AMBIGUOUS_AMPERSAND:this._stateAmbiguousAmpersand(e);break;default:throw Error(`Unknown state`)}}_stateData(e){switch(e){case W.LESS_THAN_SIGN:this.state=X.TAG_OPEN;break;case W.AMPERSAND:this._startCharacterReference();break;case W.NULL:this._err(G.unexpectedNullCharacter),this._emitCodePoint(e);break;case W.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRcdata(e){switch(e){case W.AMPERSAND:this._startCharacterReference();break;case W.LESS_THAN_SIGN:this.state=X.RCDATA_LESS_THAN_SIGN;break;case W.NULL:this._err(G.unexpectedNullCharacter),this._emitChars(`�`);break;case W.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRawtext(e){switch(e){case W.LESS_THAN_SIGN:this.state=X.RAWTEXT_LESS_THAN_SIGN;break;case W.NULL:this._err(G.unexpectedNullCharacter),this._emitChars(`�`);break;case W.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptData(e){switch(e){case W.LESS_THAN_SIGN:this.state=X.SCRIPT_DATA_LESS_THAN_SIGN;break;case W.NULL:this._err(G.unexpectedNullCharacter),this._emitChars(`�`);break;case W.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_statePlaintext(e){switch(e){case W.NULL:this._err(G.unexpectedNullCharacter),this._emitChars(`�`);break;case W.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateTagOpen(e){if(Dy(e))this._createStartTagToken(),this.state=X.TAG_NAME,this._stateTagName(e);else switch(e){case W.EXCLAMATION_MARK:this.state=X.MARKUP_DECLARATION_OPEN;break;case W.SOLIDUS:this.state=X.END_TAG_OPEN;break;case W.QUESTION_MARK:this._err(G.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=X.BOGUS_COMMENT,this._stateBogusComment(e);break;case W.EOF:this._err(G.eofBeforeTagName),this._emitChars(`<`),this._emitEOFToken();break;default:this._err(G.invalidFirstCharacterOfTagName),this._emitChars(`<`),this.state=X.DATA,this._stateData(e)}}_stateEndTagOpen(e){if(Dy(e))this._createEndTagToken(),this.state=X.TAG_NAME,this._stateTagName(e);else switch(e){case W.GREATER_THAN_SIGN:this._err(G.missingEndTagName),this.state=X.DATA;break;case W.EOF:this._err(G.eofBeforeTagName),this._emitChars(`</`),this._emitEOFToken();break;default:this._err(G.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=X.BOGUS_COMMENT,this._stateBogusComment(e)}}_stateTagName(e){let t=this.currentToken;switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:this.state=X.BEFORE_ATTRIBUTE_NAME;break;case W.SOLIDUS:this.state=X.SELF_CLOSING_START_TAG;break;case W.GREATER_THAN_SIGN:this.state=X.DATA,this.emitCurrentTagToken();break;case W.NULL:this._err(G.unexpectedNullCharacter),t.tagName+=`�`;break;case W.EOF:this._err(G.eofInTag),this._emitEOFToken();break;default:t.tagName+=String.fromCodePoint(Ty(e)?ky(e):e)}}_stateRcdataLessThanSign(e){e===W.SOLIDUS?this.state=X.RCDATA_END_TAG_OPEN:(this._emitChars(`<`),this.state=X.RCDATA,this._stateRcdata(e))}_stateRcdataEndTagOpen(e){Dy(e)?(this.state=X.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(e)):(this._emitChars(`</`),this.state=X.RCDATA,this._stateRcdata(e))}handleSpecialEndTag(e){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();let t=this.currentToken;switch(t.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=X.BEFORE_ATTRIBUTE_NAME,!1;case W.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=X.SELF_CLOSING_START_TAG,!1;case W.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=X.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars(`</`),this.state=X.RCDATA,this._stateRcdata(e))}_stateRawtextLessThanSign(e){e===W.SOLIDUS?this.state=X.RAWTEXT_END_TAG_OPEN:(this._emitChars(`<`),this.state=X.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagOpen(e){Dy(e)?(this.state=X.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(e)):(this._emitChars(`</`),this.state=X.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars(`</`),this.state=X.RAWTEXT,this._stateRawtext(e))}_stateScriptDataLessThanSign(e){switch(e){case W.SOLIDUS:this.state=X.SCRIPT_DATA_END_TAG_OPEN;break;case W.EXCLAMATION_MARK:this.state=X.SCRIPT_DATA_ESCAPE_START,this._emitChars(`<!`);break;default:this._emitChars(`<`),this.state=X.SCRIPT_DATA,this._stateScriptData(e)}}_stateScriptDataEndTagOpen(e){Dy(e)?(this.state=X.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(e)):(this._emitChars(`</`),this.state=X.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars(`</`),this.state=X.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStart(e){e===W.HYPHEN_MINUS?(this.state=X.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars(`-`)):(this.state=X.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStartDash(e){e===W.HYPHEN_MINUS?(this.state=X.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars(`-`)):(this.state=X.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscaped(e){switch(e){case W.HYPHEN_MINUS:this.state=X.SCRIPT_DATA_ESCAPED_DASH,this._emitChars(`-`);break;case W.LESS_THAN_SIGN:this.state=X.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case W.NULL:this._err(G.unexpectedNullCharacter),this._emitChars(`�`);break;case W.EOF:this._err(G.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataEscapedDash(e){switch(e){case W.HYPHEN_MINUS:this.state=X.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars(`-`);break;case W.LESS_THAN_SIGN:this.state=X.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case W.NULL:this._err(G.unexpectedNullCharacter),this.state=X.SCRIPT_DATA_ESCAPED,this._emitChars(`�`);break;case W.EOF:this._err(G.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=X.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedDashDash(e){switch(e){case W.HYPHEN_MINUS:this._emitChars(`-`);break;case W.LESS_THAN_SIGN:this.state=X.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case W.GREATER_THAN_SIGN:this.state=X.SCRIPT_DATA,this._emitChars(`>`);break;case W.NULL:this._err(G.unexpectedNullCharacter),this.state=X.SCRIPT_DATA_ESCAPED,this._emitChars(`�`);break;case W.EOF:this._err(G.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=X.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedLessThanSign(e){e===W.SOLIDUS?this.state=X.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:Dy(e)?(this._emitChars(`<`),this.state=X.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(e)):(this._emitChars(`<`),this.state=X.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagOpen(e){Dy(e)?(this.state=X.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(e)):(this._emitChars(`</`),this.state=X.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars(`</`),this.state=X.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscapeStart(e){if(this.preprocessor.startsWith(Hv.SCRIPT,!1)&&jy(this.preprocessor.peek(Hv.SCRIPT.length))){this._emitCodePoint(e);for(let e=0;e<Hv.SCRIPT.length;e++)this._emitCodePoint(this._consume());this.state=X.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=X.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscaped(e){switch(e){case W.HYPHEN_MINUS:this.state=X.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars(`-`);break;case W.LESS_THAN_SIGN:this.state=X.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars(`<`);break;case W.NULL:this._err(G.unexpectedNullCharacter),this._emitChars(`�`);break;case W.EOF:this._err(G.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDash(e){switch(e){case W.HYPHEN_MINUS:this.state=X.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars(`-`);break;case W.LESS_THAN_SIGN:this.state=X.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars(`<`);break;case W.NULL:this._err(G.unexpectedNullCharacter),this.state=X.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(`�`);break;case W.EOF:this._err(G.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=X.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDashDash(e){switch(e){case W.HYPHEN_MINUS:this._emitChars(`-`);break;case W.LESS_THAN_SIGN:this.state=X.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars(`<`);break;case W.GREATER_THAN_SIGN:this.state=X.SCRIPT_DATA,this._emitChars(`>`);break;case W.NULL:this._err(G.unexpectedNullCharacter),this.state=X.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(`�`);break;case W.EOF:this._err(G.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=X.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedLessThanSign(e){e===W.SOLIDUS?(this.state=X.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars(`/`)):(this.state=X.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateScriptDataDoubleEscapeEnd(e){if(this.preprocessor.startsWith(Hv.SCRIPT,!1)&&jy(this.preprocessor.peek(Hv.SCRIPT.length))){this._emitCodePoint(e);for(let e=0;e<Hv.SCRIPT.length;e++)this._emitCodePoint(this._consume());this.state=X.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=X.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateBeforeAttributeName(e){switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:break;case W.SOLIDUS:case W.GREATER_THAN_SIGN:case W.EOF:this.state=X.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case W.EQUALS_SIGN:this._err(G.unexpectedEqualsSignBeforeAttributeName),this._createAttr(`=`),this.state=X.ATTRIBUTE_NAME;break;default:this._createAttr(``),this.state=X.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateAttributeName(e){switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:case W.SOLIDUS:case W.GREATER_THAN_SIGN:case W.EOF:this._leaveAttrName(),this.state=X.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case W.EQUALS_SIGN:this._leaveAttrName(),this.state=X.BEFORE_ATTRIBUTE_VALUE;break;case W.QUOTATION_MARK:case W.APOSTROPHE:case W.LESS_THAN_SIGN:this._err(G.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(e);break;case W.NULL:this._err(G.unexpectedNullCharacter),this.currentAttr.name+=`�`;break;default:this.currentAttr.name+=String.fromCodePoint(Ty(e)?ky(e):e)}}_stateAfterAttributeName(e){switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:break;case W.SOLIDUS:this.state=X.SELF_CLOSING_START_TAG;break;case W.EQUALS_SIGN:this.state=X.BEFORE_ATTRIBUTE_VALUE;break;case W.GREATER_THAN_SIGN:this.state=X.DATA,this.emitCurrentTagToken();break;case W.EOF:this._err(G.eofInTag),this._emitEOFToken();break;default:this._createAttr(``),this.state=X.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateBeforeAttributeValue(e){switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:break;case W.QUOTATION_MARK:this.state=X.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break;case W.APOSTROPHE:this.state=X.ATTRIBUTE_VALUE_SINGLE_QUOTED;break;case W.GREATER_THAN_SIGN:this._err(G.missingAttributeValue),this.state=X.DATA,this.emitCurrentTagToken();break;default:this.state=X.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(e)}}_stateAttributeValueDoubleQuoted(e){switch(e){case W.QUOTATION_MARK:this.state=X.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case W.AMPERSAND:this._startCharacterReference();break;case W.NULL:this._err(G.unexpectedNullCharacter),this.currentAttr.value+=`�`;break;case W.EOF:this._err(G.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueSingleQuoted(e){switch(e){case W.APOSTROPHE:this.state=X.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case W.AMPERSAND:this._startCharacterReference();break;case W.NULL:this._err(G.unexpectedNullCharacter),this.currentAttr.value+=`�`;break;case W.EOF:this._err(G.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueUnquoted(e){switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:this._leaveAttrValue(),this.state=X.BEFORE_ATTRIBUTE_NAME;break;case W.AMPERSAND:this._startCharacterReference();break;case W.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=X.DATA,this.emitCurrentTagToken();break;case W.NULL:this._err(G.unexpectedNullCharacter),this.currentAttr.value+=`�`;break;case W.QUOTATION_MARK:case W.APOSTROPHE:case W.LESS_THAN_SIGN:case W.EQUALS_SIGN:case W.GRAVE_ACCENT:this._err(G.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(e);break;case W.EOF:this._err(G.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAfterAttributeValueQuoted(e){switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:this._leaveAttrValue(),this.state=X.BEFORE_ATTRIBUTE_NAME;break;case W.SOLIDUS:this._leaveAttrValue(),this.state=X.SELF_CLOSING_START_TAG;break;case W.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=X.DATA,this.emitCurrentTagToken();break;case W.EOF:this._err(G.eofInTag),this._emitEOFToken();break;default:this._err(G.missingWhitespaceBetweenAttributes),this.state=X.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateSelfClosingStartTag(e){switch(e){case W.GREATER_THAN_SIGN:{let e=this.currentToken;e.selfClosing=!0,this.state=X.DATA,this.emitCurrentTagToken();break}case W.EOF:this._err(G.eofInTag),this._emitEOFToken();break;default:this._err(G.unexpectedSolidusInTag),this.state=X.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateBogusComment(e){let t=this.currentToken;switch(e){case W.GREATER_THAN_SIGN:this.state=X.DATA,this.emitCurrentComment(t);break;case W.EOF:this.emitCurrentComment(t),this._emitEOFToken();break;case W.NULL:this._err(G.unexpectedNullCharacter),t.data+=`�`;break;default:t.data+=String.fromCodePoint(e)}}_stateMarkupDeclarationOpen(e){this._consumeSequenceIfMatch(Hv.DASH_DASH,!0)?(this._createCommentToken(Hv.DASH_DASH.length+1),this.state=X.COMMENT_START):this._consumeSequenceIfMatch(Hv.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(Hv.DOCTYPE.length+1),this.state=X.DOCTYPE):this._consumeSequenceIfMatch(Hv.CDATA_START,!0)?this.inForeignNode?this.state=X.CDATA_SECTION:(this._err(G.cdataInHtmlContent),this._createCommentToken(Hv.CDATA_START.length+1),this.currentToken.data=`[CDATA[`,this.state=X.BOGUS_COMMENT):this._ensureHibernation()||(this._err(G.incorrectlyOpenedComment),this._createCommentToken(2),this.state=X.BOGUS_COMMENT,this._stateBogusComment(e))}_stateCommentStart(e){switch(e){case W.HYPHEN_MINUS:this.state=X.COMMENT_START_DASH;break;case W.GREATER_THAN_SIGN:{this._err(G.abruptClosingOfEmptyComment),this.state=X.DATA;let e=this.currentToken;this.emitCurrentComment(e);break}default:this.state=X.COMMENT,this._stateComment(e)}}_stateCommentStartDash(e){let t=this.currentToken;switch(e){case W.HYPHEN_MINUS:this.state=X.COMMENT_END;break;case W.GREATER_THAN_SIGN:this._err(G.abruptClosingOfEmptyComment),this.state=X.DATA,this.emitCurrentComment(t);break;case W.EOF:this._err(G.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=`-`,this.state=X.COMMENT,this._stateComment(e)}}_stateComment(e){let t=this.currentToken;switch(e){case W.HYPHEN_MINUS:this.state=X.COMMENT_END_DASH;break;case W.LESS_THAN_SIGN:t.data+=`<`,this.state=X.COMMENT_LESS_THAN_SIGN;break;case W.NULL:this._err(G.unexpectedNullCharacter),t.data+=`�`;break;case W.EOF:this._err(G.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=String.fromCodePoint(e)}}_stateCommentLessThanSign(e){let t=this.currentToken;switch(e){case W.EXCLAMATION_MARK:t.data+=`!`,this.state=X.COMMENT_LESS_THAN_SIGN_BANG;break;case W.LESS_THAN_SIGN:t.data+=`<`;break;default:this.state=X.COMMENT,this._stateComment(e)}}_stateCommentLessThanSignBang(e){e===W.HYPHEN_MINUS?this.state=X.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=X.COMMENT,this._stateComment(e))}_stateCommentLessThanSignBangDash(e){e===W.HYPHEN_MINUS?this.state=X.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=X.COMMENT_END_DASH,this._stateCommentEndDash(e))}_stateCommentLessThanSignBangDashDash(e){e!==W.GREATER_THAN_SIGN&&e!==W.EOF&&this._err(G.nestedComment),this.state=X.COMMENT_END,this._stateCommentEnd(e)}_stateCommentEndDash(e){let t=this.currentToken;switch(e){case W.HYPHEN_MINUS:this.state=X.COMMENT_END;break;case W.EOF:this._err(G.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=`-`,this.state=X.COMMENT,this._stateComment(e)}}_stateCommentEnd(e){let t=this.currentToken;switch(e){case W.GREATER_THAN_SIGN:this.state=X.DATA,this.emitCurrentComment(t);break;case W.EXCLAMATION_MARK:this.state=X.COMMENT_END_BANG;break;case W.HYPHEN_MINUS:t.data+=`-`;break;case W.EOF:this._err(G.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=`--`,this.state=X.COMMENT,this._stateComment(e)}}_stateCommentEndBang(e){let t=this.currentToken;switch(e){case W.HYPHEN_MINUS:t.data+=`--!`,this.state=X.COMMENT_END_DASH;break;case W.GREATER_THAN_SIGN:this._err(G.incorrectlyClosedComment),this.state=X.DATA,this.emitCurrentComment(t);break;case W.EOF:this._err(G.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=`--!`,this.state=X.COMMENT,this._stateComment(e)}}_stateDoctype(e){switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:this.state=X.BEFORE_DOCTYPE_NAME;break;case W.GREATER_THAN_SIGN:this.state=X.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e);break;case W.EOF:{this._err(G.eofInDoctype),this._createDoctypeToken(null);let e=this.currentToken;e.forceQuirks=!0,this.emitCurrentDoctype(e),this._emitEOFToken();break}default:this._err(G.missingWhitespaceBeforeDoctypeName),this.state=X.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e)}}_stateBeforeDoctypeName(e){if(Ty(e))this._createDoctypeToken(String.fromCharCode(ky(e))),this.state=X.DOCTYPE_NAME;else switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:break;case W.NULL:this._err(G.unexpectedNullCharacter),this._createDoctypeToken(`�`),this.state=X.DOCTYPE_NAME;break;case W.GREATER_THAN_SIGN:{this._err(G.missingDoctypeName),this._createDoctypeToken(null);let e=this.currentToken;e.forceQuirks=!0,this.emitCurrentDoctype(e),this.state=X.DATA;break}case W.EOF:{this._err(G.eofInDoctype),this._createDoctypeToken(null);let e=this.currentToken;e.forceQuirks=!0,this.emitCurrentDoctype(e),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(e)),this.state=X.DOCTYPE_NAME}}_stateDoctypeName(e){let t=this.currentToken;switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:this.state=X.AFTER_DOCTYPE_NAME;break;case W.GREATER_THAN_SIGN:this.state=X.DATA,this.emitCurrentDoctype(t);break;case W.NULL:this._err(G.unexpectedNullCharacter),t.name+=`�`;break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.name+=String.fromCodePoint(Ty(e)?ky(e):e)}}_stateAfterDoctypeName(e){let t=this.currentToken;switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:break;case W.GREATER_THAN_SIGN:this.state=X.DATA,this.emitCurrentDoctype(t);break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._consumeSequenceIfMatch(Hv.PUBLIC,!1)?this.state=X.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(Hv.SYSTEM,!1)?this.state=X.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(G.invalidCharacterSequenceAfterDoctypeName),t.forceQuirks=!0,this.state=X.BOGUS_DOCTYPE,this._stateBogusDoctype(e))}}_stateAfterDoctypePublicKeyword(e){let t=this.currentToken;switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:this.state=X.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break;case W.QUOTATION_MARK:this._err(G.missingWhitespaceAfterDoctypePublicKeyword),t.publicId=``,this.state=X.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case W.APOSTROPHE:this._err(G.missingWhitespaceAfterDoctypePublicKeyword),t.publicId=``,this.state=X.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case W.GREATER_THAN_SIGN:this._err(G.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=X.DATA,this.emitCurrentDoctype(t);break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(G.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=X.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypePublicIdentifier(e){let t=this.currentToken;switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:break;case W.QUOTATION_MARK:t.publicId=``,this.state=X.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case W.APOSTROPHE:t.publicId=``,this.state=X.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case W.GREATER_THAN_SIGN:this._err(G.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=X.DATA,this.emitCurrentDoctype(t);break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(G.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=X.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypePublicIdentifierDoubleQuoted(e){let t=this.currentToken;switch(e){case W.QUOTATION_MARK:this.state=X.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case W.NULL:this._err(G.unexpectedNullCharacter),t.publicId+=`�`;break;case W.GREATER_THAN_SIGN:this._err(G.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=X.DATA;break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.publicId+=String.fromCodePoint(e)}}_stateDoctypePublicIdentifierSingleQuoted(e){let t=this.currentToken;switch(e){case W.APOSTROPHE:this.state=X.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case W.NULL:this._err(G.unexpectedNullCharacter),t.publicId+=`�`;break;case W.GREATER_THAN_SIGN:this._err(G.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=X.DATA;break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.publicId+=String.fromCodePoint(e)}}_stateAfterDoctypePublicIdentifier(e){let t=this.currentToken;switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:this.state=X.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break;case W.GREATER_THAN_SIGN:this.state=X.DATA,this.emitCurrentDoctype(t);break;case W.QUOTATION_MARK:this._err(G.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId=``,this.state=X.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case W.APOSTROPHE:this._err(G.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId=``,this.state=X.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(G.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=X.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBetweenDoctypePublicAndSystemIdentifiers(e){let t=this.currentToken;switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:break;case W.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=X.DATA;break;case W.QUOTATION_MARK:t.systemId=``,this.state=X.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case W.APOSTROPHE:t.systemId=``,this.state=X.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(G.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=X.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateAfterDoctypeSystemKeyword(e){let t=this.currentToken;switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:this.state=X.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break;case W.QUOTATION_MARK:this._err(G.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId=``,this.state=X.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case W.APOSTROPHE:this._err(G.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId=``,this.state=X.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case W.GREATER_THAN_SIGN:this._err(G.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=X.DATA,this.emitCurrentDoctype(t);break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(G.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=X.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypeSystemIdentifier(e){let t=this.currentToken;switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:break;case W.QUOTATION_MARK:t.systemId=``,this.state=X.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case W.APOSTROPHE:t.systemId=``,this.state=X.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case W.GREATER_THAN_SIGN:this._err(G.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=X.DATA,this.emitCurrentDoctype(t);break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(G.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=X.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypeSystemIdentifierDoubleQuoted(e){let t=this.currentToken;switch(e){case W.QUOTATION_MARK:this.state=X.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case W.NULL:this._err(G.unexpectedNullCharacter),t.systemId+=`�`;break;case W.GREATER_THAN_SIGN:this._err(G.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=X.DATA;break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.systemId+=String.fromCodePoint(e)}}_stateDoctypeSystemIdentifierSingleQuoted(e){let t=this.currentToken;switch(e){case W.APOSTROPHE:this.state=X.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case W.NULL:this._err(G.unexpectedNullCharacter),t.systemId+=`�`;break;case W.GREATER_THAN_SIGN:this._err(G.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=X.DATA;break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.systemId+=String.fromCodePoint(e)}}_stateAfterDoctypeSystemIdentifier(e){let t=this.currentToken;switch(e){case W.SPACE:case W.LINE_FEED:case W.TABULATION:case W.FORM_FEED:break;case W.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=X.DATA;break;case W.EOF:this._err(G.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(G.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=X.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBogusDoctype(e){let t=this.currentToken;switch(e){case W.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=X.DATA;break;case W.NULL:this._err(G.unexpectedNullCharacter);break;case W.EOF:this.emitCurrentDoctype(t),this._emitEOFToken()}}_stateCdataSection(e){switch(e){case W.RIGHT_SQUARE_BRACKET:this.state=X.CDATA_SECTION_BRACKET;break;case W.EOF:this._err(G.eofInCdata),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateCdataSectionBracket(e){e===W.RIGHT_SQUARE_BRACKET?this.state=X.CDATA_SECTION_END:(this._emitChars(`]`),this.state=X.CDATA_SECTION,this._stateCdataSection(e))}_stateCdataSectionEnd(e){switch(e){case W.GREATER_THAN_SIGN:this.state=X.DATA;break;case W.RIGHT_SQUARE_BRACKET:this._emitChars(`]`);break;default:this._emitChars(`]]`),this.state=X.CDATA_SECTION,this._stateCdataSection(e)}}_stateCharacterReference(){let e=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(e<0){if(this.preprocessor.lastChunkWritten)e=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}}e===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(W.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&Oy(this.preprocessor.peek(1))?X.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(e){Oy(e)?this._flushCodePointConsumedAsCharacterReference(e):(e===W.SEMICOLON&&this._err(G.unknownNamedCharacterReference),this.state=this.returnState,this._callState(e))}},Py=new Set([J.DD,J.DT,J.LI,J.OPTGROUP,J.OPTION,J.P,J.RB,J.RP,J.RT,J.RTC]),Fy=new Set([...Py,J.CAPTION,J.COLGROUP,J.TBODY,J.TD,J.TFOOT,J.TH,J.THEAD,J.TR]),Iy=new Set([J.APPLET,J.CAPTION,J.HTML,J.MARQUEE,J.OBJECT,J.TABLE,J.TD,J.TEMPLATE,J.TH]),Ly=new Set([...Iy,J.OL,J.UL]),Ry=new Set([...Iy,J.BUTTON]),zy=new Set([J.ANNOTATION_XML,J.MI,J.MN,J.MO,J.MS,J.MTEXT]),By=new Set([J.DESC,J.FOREIGN_OBJECT,J.TITLE]),Vy=new Set([J.TR,J.TEMPLATE,J.HTML]),Hy=new Set([J.TBODY,J.TFOOT,J.THEAD,J.TEMPLATE,J.HTML]),Uy=new Set([J.TABLE,J.TEMPLATE,J.HTML]),Wy=new Set([J.TD,J.TH]),Gy=class{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(e,t,n){this.treeAdapter=t,this.handler=n,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=J.UNKNOWN,this.current=e}_indexOf(e){return this.items.lastIndexOf(e,this.stackTop)}_isInTemplate(){return this.currentTagId===J.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===K.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(e,t){this.stackTop++,this.items[this.stackTop]=e,this.current=e,this.tagIDs[this.stackTop]=t,this.currentTagId=t,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(e,t,!0)}pop(){let e=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!0)}replace(e,t){let n=this._indexOf(e);this.items[n]=t,n===this.stackTop&&(this.current=t)}insertAfter(e,t,n){let r=this._indexOf(e)+1;this.items.splice(r,0,t),this.tagIDs.splice(r,0,n),this.stackTop++,r===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,r===this.stackTop)}popUntilTagNamePopped(e){let t=this.stackTop+1;do t=this.tagIDs.lastIndexOf(e,t-1);while(t>0&&this.treeAdapter.getNamespaceURI(this.items[t])!==K.HTML);this.shortenToLength(Math.max(t,0))}shortenToLength(e){for(;this.stackTop>=e;){let t=this.current;this.tmplCount>0&&this._isInTemplate()&&--this.tmplCount,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,this.stackTop<e)}}popUntilElementPopped(e){let t=this._indexOf(e);this.shortenToLength(Math.max(t,0))}popUntilPopped(e,t){let n=this._indexOfTagNames(e,t);this.shortenToLength(Math.max(n,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(Sy,K.HTML)}popUntilTableCellPopped(){this.popUntilPopped(Wy,K.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(e,t){for(let n=this.stackTop;n>=0;n--)if(e.has(this.tagIDs[n])&&this.treeAdapter.getNamespaceURI(this.items[n])===t)return n;return-1}clearBackTo(e,t){let n=this._indexOfTagNames(e,t);this.shortenToLength(n+1)}clearBackToTableContext(){this.clearBackTo(Uy,K.HTML)}clearBackToTableBodyContext(){this.clearBackTo(Hy,K.HTML)}clearBackToTableRowContext(){this.clearBackTo(Vy,K.HTML)}remove(e){let t=this._indexOf(e);t>=0&&(t===this.stackTop?this.pop():(this.items.splice(t,1),this.tagIDs.splice(t,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===J.BODY?this.items[1]:null}contains(e){return this._indexOf(e)>-1}getCommonAncestor(e){let t=this._indexOf(e)-1;return t>=0?this.items[t]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===J.HTML}hasInDynamicScope(e,t){for(let n=this.stackTop;n>=0;n--){let r=this.tagIDs[n];switch(this.treeAdapter.getNamespaceURI(this.items[n])){case K.HTML:if(r===e)return!0;if(t.has(r))return!1;break;case K.SVG:if(By.has(r))return!1;break;case K.MATHML:if(zy.has(r))return!1}}return!0}hasInScope(e){return this.hasInDynamicScope(e,Iy)}hasInListItemScope(e){return this.hasInDynamicScope(e,Ly)}hasInButtonScope(e){return this.hasInDynamicScope(e,Ry)}hasNumberedHeaderInScope(){for(let e=this.stackTop;e>=0;e--){let t=this.tagIDs[e];switch(this.treeAdapter.getNamespaceURI(this.items[e])){case K.HTML:if(Sy.has(t))return!0;if(Iy.has(t))return!1;break;case K.SVG:if(By.has(t))return!1;break;case K.MATHML:if(zy.has(t))return!1}}return!0}hasInTableScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===K.HTML)switch(this.tagIDs[t]){case e:return!0;case J.TABLE:case J.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let e=this.stackTop;e>=0;e--)if(this.treeAdapter.getNamespaceURI(this.items[e])===K.HTML)switch(this.tagIDs[e]){case J.TBODY:case J.THEAD:case J.TFOOT:return!0;case J.TABLE:case J.HTML:return!1}return!0}hasInSelectScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===K.HTML)switch(this.tagIDs[t]){case e:return!0;case J.OPTION:case J.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&Py.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&Fy.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(e){for(;this.currentTagId!==void 0&&this.currentTagId!==e&&Fy.has(this.currentTagId);)this.pop()}},Ky=3,qy;(function(e){e[e.Marker=0]=`Marker`,e[e.Element=1]=`Element`})(qy||={});var Jy={type:qy.Marker},Yy=class{constructor(e){this.treeAdapter=e,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(e,t){let n=[],r=t.length,i=this.treeAdapter.getTagName(e),a=this.treeAdapter.getNamespaceURI(e);for(let e=0;e<this.entries.length;e++){let t=this.entries[e];if(t.type===qy.Marker)break;let{element:o}=t;if(this.treeAdapter.getTagName(o)===i&&this.treeAdapter.getNamespaceURI(o)===a){let t=this.treeAdapter.getAttrList(o);t.length===r&&n.push({idx:e,attrs:t})}}return n}_ensureNoahArkCondition(e){if(this.entries.length<Ky)return;let t=this.treeAdapter.getAttrList(e),n=this._getNoahArkConditionCandidates(e,t);if(n.length<Ky)return;let r=new Map(t.map(e=>[e.name,e.value])),i=0;for(let e=0;e<n.length;e++){let t=n[e];t.attrs.every(e=>r.get(e.name)===e.value)&&(i+=1,i>=Ky&&this.entries.splice(t.idx,1))}}insertMarker(){this.entries.unshift(Jy)}pushElement(e,t){this._ensureNoahArkCondition(e),this.entries.unshift({type:qy.Element,element:e,token:t})}insertElementAfterBookmark(e,t){let n=this.entries.indexOf(this.bookmark);this.entries.splice(n,0,{type:qy.Element,element:e,token:t})}removeEntry(e){let t=this.entries.indexOf(e);t!==-1&&this.entries.splice(t,1)}clearToLastMarker(){let e=this.entries.indexOf(Jy);e===-1?this.entries.length=0:this.entries.splice(0,e+1)}getElementEntryInScopeWithTagName(e){let t=this.entries.find(t=>t.type===qy.Marker||this.treeAdapter.getTagName(t.element)===e);return t&&t.type===qy.Element?t:null}getElementEntry(e){return this.entries.find(t=>t.type===qy.Element&&t.element===e)}},Xy={createDocument(){return{nodeName:`#document`,mode:vy.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:`#document-fragment`,childNodes:[]}},createElement(e,t,n){return{nodeName:e,tagName:e,attrs:n,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:`#comment`,data:e,parentNode:null}},createTextNode(e){return{nodeName:`#text`,value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,n){let r=e.childNodes.indexOf(n);e.childNodes.splice(r,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,r){let i=e.childNodes.find(e=>e.nodeName===`#documentType`);if(i)i.name=t,i.publicId=n,i.systemId=r;else{let i={nodeName:`#documentType`,name:t,publicId:n,systemId:r,parentNode:null};Xy.appendChild(e,i)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){let t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){let n=e.childNodes[e.childNodes.length-1];if(Xy.isTextNode(n)){n.value+=t;return}}Xy.appendChild(e,Xy.createTextNode(t))},insertTextBefore(e,t,n){let r=e.childNodes[e.childNodes.indexOf(n)-1];r&&Xy.isTextNode(r)?r.value+=t:Xy.insertBefore(e,Xy.createTextNode(t),n)},adoptAttributes(e,t){let n=new Set(e.attrs.map(e=>e.name));for(let r=0;r<t.length;r++)n.has(t[r].name)||e.attrs.push(t[r])},getFirstChild(e){return e.childNodes[0]},getChildNodes(e){return e.childNodes},getParentNode(e){return e.parentNode},getAttrList(e){return e.attrs},getTagName(e){return e.tagName},getNamespaceURI(e){return e.namespaceURI},getTextNodeContent(e){return e.value},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){return e.name},getDocumentTypeNodePublicId(e){return e.publicId},getDocumentTypeNodeSystemId(e){return e.systemId},isTextNode(e){return e.nodeName===`#text`},isCommentNode(e){return e.nodeName===`#comment`},isDocumentTypeNode(e){return e.nodeName===`#documentType`},isElementNode(e){return Object.prototype.hasOwnProperty.call(e,`tagName`)},setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}},Zy=`html`,Qy=`about:legacy-compat`,$y=`http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd`,eb=`+//silmaril//dtd html pro v0r11 19970101//,-//as//dtd html 3.0 aswedit + extensions//,-//advasoft ltd//dtd html 3.0 aswedit + extensions//,-//ietf//dtd html 2.0 level 1//,-//ietf//dtd html 2.0 level 2//,-//ietf//dtd html 2.0 strict level 1//,-//ietf//dtd html 2.0 strict level 2//,-//ietf//dtd html 2.0 strict//,-//ietf//dtd html 2.0//,-//ietf//dtd html 2.1e//,-//ietf//dtd html 3.0//,-//ietf//dtd html 3.2 final//,-//ietf//dtd html 3.2//,-//ietf//dtd html 3//,-//ietf//dtd html level 0//,-//ietf//dtd html level 1//,-//ietf//dtd html level 2//,-//ietf//dtd html level 3//,-//ietf//dtd html strict level 0//,-//ietf//dtd html strict level 1//,-//ietf//dtd html strict level 2//,-//ietf//dtd html strict level 3//,-//ietf//dtd html strict//,-//ietf//dtd html//,-//metrius//dtd metrius presentational//,-//microsoft//dtd internet explorer 2.0 html strict//,-//microsoft//dtd internet explorer 2.0 html//,-//microsoft//dtd internet explorer 2.0 tables//,-//microsoft//dtd internet explorer 3.0 html strict//,-//microsoft//dtd internet explorer 3.0 html//,-//microsoft//dtd internet explorer 3.0 tables//,-//netscape comm. corp.//dtd html//,-//netscape comm. corp.//dtd strict html//,-//o'reilly and associates//dtd html 2.0//,-//o'reilly and associates//dtd html extended 1.0//,-//o'reilly and associates//dtd html extended relaxed 1.0//,-//sq//dtd html 2.0 hotmetal + extensions//,-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//,-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//,-//spyglass//dtd html 2.0 extended//,-//sun microsystems corp.//dtd hotjava html//,-//sun microsystems corp.//dtd hotjava strict html//,-//w3c//dtd html 3 1995-03-24//,-//w3c//dtd html 3.2 draft//,-//w3c//dtd html 3.2 final//,-//w3c//dtd html 3.2//,-//w3c//dtd html 3.2s draft//,-//w3c//dtd html 4.0 frameset//,-//w3c//dtd html 4.0 transitional//,-//w3c//dtd html experimental 19960712//,-//w3c//dtd html experimental 970421//,-//w3c//dtd w3 html//,-//w3o//dtd w3 html 3.0//,-//webtechs//dtd mozilla html 2.0//,-//webtechs//dtd mozilla html//`.split(`,`),tb=[...eb,`-//w3c//dtd html 4.01 frameset//`,`-//w3c//dtd html 4.01 transitional//`],nb=new Set([`-//w3o//dtd w3 html strict 3.0//en//`,`-/w3c/dtd html 4.0 transitional/en`,`html`]),rb=[`-//w3c//dtd xhtml 1.0 frameset//`,`-//w3c//dtd xhtml 1.0 transitional//`],ib=[...rb,`-//w3c//dtd html 4.01 frameset//`,`-//w3c//dtd html 4.01 transitional//`];function ab(e,t){return t.some(t=>e.startsWith(t))}function ob(e){return e.name===Zy&&e.publicId===null&&(e.systemId===null||e.systemId===Qy)}function sb(e){if(e.name!==Zy)return vy.QUIRKS;let{systemId:t}=e;if(t&&t.toLowerCase()===$y)return vy.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),nb.has(n))return vy.QUIRKS;let e=t===null?tb:eb;if(ab(n,e))return vy.QUIRKS;if(e=t===null?rb:ib,ab(n,e))return vy.LIMITED_QUIRKS}return vy.NO_QUIRKS}var cb={TEXT_HTML:`text/html`,APPLICATION_XML:`application/xhtml+xml`},lb=`definitionurl`,ub=`definitionURL`,db=new Map(`attributeName.attributeType.baseFrequency.baseProfile.calcMode.clipPathUnits.diffuseConstant.edgeMode.filterUnits.glyphRef.gradientTransform.gradientUnits.kernelMatrix.kernelUnitLength.keyPoints.keySplines.keyTimes.lengthAdjust.limitingConeAngle.markerHeight.markerUnits.markerWidth.maskContentUnits.maskUnits.numOctaves.pathLength.patternContentUnits.patternTransform.patternUnits.pointsAtX.pointsAtY.pointsAtZ.preserveAlpha.preserveAspectRatio.primitiveUnits.refX.refY.repeatCount.repeatDur.requiredExtensions.requiredFeatures.specularConstant.specularExponent.spreadMethod.startOffset.stdDeviation.stitchTiles.surfaceScale.systemLanguage.tableValues.targetX.targetY.textLength.viewBox.viewTarget.xChannelSelector.yChannelSelector.zoomAndPan`.split(`.`).map(e=>[e.toLowerCase(),e])),fb=new Map([[`xlink:actuate`,{prefix:`xlink`,name:`actuate`,namespace:K.XLINK}],[`xlink:arcrole`,{prefix:`xlink`,name:`arcrole`,namespace:K.XLINK}],[`xlink:href`,{prefix:`xlink`,name:`href`,namespace:K.XLINK}],[`xlink:role`,{prefix:`xlink`,name:`role`,namespace:K.XLINK}],[`xlink:show`,{prefix:`xlink`,name:`show`,namespace:K.XLINK}],[`xlink:title`,{prefix:`xlink`,name:`title`,namespace:K.XLINK}],[`xlink:type`,{prefix:`xlink`,name:`type`,namespace:K.XLINK}],[`xml:lang`,{prefix:`xml`,name:`lang`,namespace:K.XML}],[`xml:space`,{prefix:`xml`,name:`space`,namespace:K.XML}],[`xmlns`,{prefix:``,name:`xmlns`,namespace:K.XMLNS}],[`xmlns:xlink`,{prefix:`xmlns`,name:`xlink`,namespace:K.XMLNS}]]),pb=new Map(`altGlyph.altGlyphDef.altGlyphItem.animateColor.animateMotion.animateTransform.clipPath.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.foreignObject.glyphRef.linearGradient.radialGradient.textPath`.split(`.`).map(e=>[e.toLowerCase(),e])),mb=new Set([J.B,J.BIG,J.BLOCKQUOTE,J.BODY,J.BR,J.CENTER,J.CODE,J.DD,J.DIV,J.DL,J.DT,J.EM,J.EMBED,J.H1,J.H2,J.H3,J.H4,J.H5,J.H6,J.HEAD,J.HR,J.I,J.IMG,J.LI,J.LISTING,J.MENU,J.META,J.NOBR,J.OL,J.P,J.PRE,J.RUBY,J.S,J.SMALL,J.SPAN,J.STRONG,J.STRIKE,J.SUB,J.SUP,J.TABLE,J.TT,J.U,J.UL,J.VAR]);function hb(e){let t=e.tagID;return t===J.FONT&&e.attrs.some(({name:e})=>e===_y.COLOR||e===_y.SIZE||e===_y.FACE)||mb.has(t)}function gb(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===lb){e.attrs[t].name=ub;break}}function _b(e){for(let t=0;t<e.attrs.length;t++){let n=db.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function vb(e){for(let t=0;t<e.attrs.length;t++){let n=fb.get(e.attrs[t].name);n&&(e.attrs[t].prefix=n.prefix,e.attrs[t].name=n.name,e.attrs[t].namespace=n.namespace)}}function yb(e){let t=pb.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=by(e.tagName))}function bb(e,t){return t===K.MATHML&&(e===J.MI||e===J.MO||e===J.MN||e===J.MS||e===J.MTEXT)}function xb(e,t,n){if(t===K.MATHML&&e===J.ANNOTATION_XML){for(let e=0;e<n.length;e++)if(n[e].name===_y.ENCODING){let t=n[e].value.toLowerCase();return t===cb.TEXT_HTML||t===cb.APPLICATION_XML}}return t===K.SVG&&(e===J.FOREIGN_OBJECT||e===J.DESC||e===J.TITLE)}function Sb(e,t,n,r){return(!r||r===K.HTML)&&xb(e,t,n)||(!r||r===K.MATHML)&&bb(e,t)}var Cb=`hidden`,wb=8,Tb=3,Z;(function(e){e[e.INITIAL=0]=`INITIAL`,e[e.BEFORE_HTML=1]=`BEFORE_HTML`,e[e.BEFORE_HEAD=2]=`BEFORE_HEAD`,e[e.IN_HEAD=3]=`IN_HEAD`,e[e.IN_HEAD_NO_SCRIPT=4]=`IN_HEAD_NO_SCRIPT`,e[e.AFTER_HEAD=5]=`AFTER_HEAD`,e[e.IN_BODY=6]=`IN_BODY`,e[e.TEXT=7]=`TEXT`,e[e.IN_TABLE=8]=`IN_TABLE`,e[e.IN_TABLE_TEXT=9]=`IN_TABLE_TEXT`,e[e.IN_CAPTION=10]=`IN_CAPTION`,e[e.IN_COLUMN_GROUP=11]=`IN_COLUMN_GROUP`,e[e.IN_TABLE_BODY=12]=`IN_TABLE_BODY`,e[e.IN_ROW=13]=`IN_ROW`,e[e.IN_CELL=14]=`IN_CELL`,e[e.IN_SELECT=15]=`IN_SELECT`,e[e.IN_SELECT_IN_TABLE=16]=`IN_SELECT_IN_TABLE`,e[e.IN_TEMPLATE=17]=`IN_TEMPLATE`,e[e.AFTER_BODY=18]=`AFTER_BODY`,e[e.IN_FRAMESET=19]=`IN_FRAMESET`,e[e.AFTER_FRAMESET=20]=`AFTER_FRAMESET`,e[e.AFTER_AFTER_BODY=21]=`AFTER_AFTER_BODY`,e[e.AFTER_AFTER_FRAMESET=22]=`AFTER_AFTER_FRAMESET`})(Z||={});var Eb={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},Db=new Set([J.TABLE,J.TBODY,J.TFOOT,J.THEAD,J.TR]),Ob={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:Xy,onParseError:null},kb=class{constructor(e,t,n=null,r=null){this.fragmentContext=n,this.scriptHandler=r,this.currentToken=null,this.stopped=!1,this.insertionMode=Z.INITIAL,this.originalInsertionMode=Z.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...Ob,...e},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=t??this.treeAdapter.createDocument(),this.tokenizer=new Ny(this.options,this),this.activeFormattingElements=new Yy(this.treeAdapter),this.fragmentContextID=n?by(this.treeAdapter.getTagName(n)):J.UNKNOWN,this._setContextModes(n??this.document,this.fragmentContextID),this.openElements=new Gy(this.document,this.treeAdapter,this)}static parse(e,t){let n=new this(t);return n.tokenizer.write(e,!0),n.document}static getFragmentParser(e,t){let n={...Ob,...t};e??=n.treeAdapter.createElement(q.TEMPLATE,K.HTML,[]);let r=n.treeAdapter.createElement(`documentmock`,K.HTML,[]),i=new this(n,r,e);return i.fragmentContextID===J.TEMPLATE&&i.tmplInsertionModeStack.unshift(Z.IN_TEMPLATE),i._initTokenizerForFragmentParsing(),i._insertFakeRootElement(),i._resetInsertionMode(),i._findFormInFragmentContext(),i}getFragment(){let e=this.treeAdapter.getFirstChild(this.document),t=this.treeAdapter.createDocumentFragment();return this._adoptNodes(e,t),t}_err(e,t,n){if(!this.onParseError)return;let r=e.location??Eb,i={code:t,startLine:r.startLine,startCol:r.startCol,startOffset:r.startOffset,endLine:n?r.startLine:r.endLine,endCol:n?r.startCol:r.endCol,endOffset:n?r.startOffset:r.endOffset};this.onParseError(i)}onItemPush(e,t,n){var r,i;(i=(r=this.treeAdapter).onItemPush)==null||i.call(r,e),n&&this.openElements.stackTop>0&&this._setContextModes(e,t)}onItemPop(e,t){var n,r;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(e,this.currentToken),(r=(n=this.treeAdapter).onItemPop)==null||r.call(n,e,this.openElements.current),t){let e,t;this.openElements.stackTop===0&&this.fragmentContext?(e=this.fragmentContext,t=this.fragmentContextID):{current:e,currentTagId:t}=this.openElements,this._setContextModes(e,t)}}_setContextModes(e,t){let n=e===this.document||e&&this.treeAdapter.getNamespaceURI(e)===K.HTML;this.currentNotInHTML=!n,this.tokenizer.inForeignNode=!n&&e!==void 0&&t!==void 0&&!this._isIntegrationPoint(t,e)}_switchToTextParsing(e,t){this._insertElement(e,K.HTML),this.tokenizer.state=t,this.originalInsertionMode=this.insertionMode,this.insertionMode=Z.TEXT}switchToPlaintextParsing(){this.insertionMode=Z.TEXT,this.originalInsertionMode=Z.IN_BODY,this.tokenizer.state=Cy.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let e=this.fragmentContext;for(;e;){if(this.treeAdapter.getTagName(e)===q.FORM){this.formElement=e;break}e=this.treeAdapter.getParentNode(e)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==K.HTML))switch(this.fragmentContextID){case J.TITLE:case J.TEXTAREA:this.tokenizer.state=Cy.RCDATA;break;case J.STYLE:case J.XMP:case J.IFRAME:case J.NOEMBED:case J.NOFRAMES:case J.NOSCRIPT:this.tokenizer.state=Cy.RAWTEXT;break;case J.SCRIPT:this.tokenizer.state=Cy.SCRIPT_DATA;break;case J.PLAINTEXT:this.tokenizer.state=Cy.PLAINTEXT}}_setDocumentType(e){let t=e.name||``,n=e.publicId||``,r=e.systemId||``;if(this.treeAdapter.setDocumentType(this.document,t,n,r),e.location){let t=this.treeAdapter.getChildNodes(this.document).find(e=>this.treeAdapter.isDocumentTypeNode(e));t&&this.treeAdapter.setNodeSourceCodeLocation(t,e.location)}}_attachElementToTree(e,t){if(this.options.sourceCodeLocationInfo){let n=t&&{...t,startTag:t};this.treeAdapter.setNodeSourceCodeLocation(e,n)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(e);else{let t=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(t??this.document,e)}}_appendElement(e,t){let n=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(n,e.location)}_insertElement(e,t){let n=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(n,e.location),this.openElements.push(n,e.tagID)}_insertFakeElement(e,t){let n=this.treeAdapter.createElement(e,K.HTML,[]);this._attachElementToTree(n,null),this.openElements.push(n,t)}_insertTemplate(e){let t=this.treeAdapter.createElement(e.tagName,K.HTML,e.attrs),n=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(t,n),this._attachElementToTree(t,e.location),this.openElements.push(t,e.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,null)}_insertFakeRootElement(){let e=this.treeAdapter.createElement(q.HTML,K.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(e,null),this.treeAdapter.appendChild(this.openElements.current,e),this.openElements.push(e,J.HTML)}_appendCommentNode(e,t){let n=this.treeAdapter.createCommentNode(e.data);this.treeAdapter.appendChild(t,n),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,e.location)}_insertCharacters(e){let t,n;if(this._shouldFosterParentOnInsertion()?({parent:t,beforeElement:n}=this._findFosterParentingLocation(),n?this.treeAdapter.insertTextBefore(t,e.chars,n):this.treeAdapter.insertText(t,e.chars)):(t=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(t,e.chars)),!e.location)return;let r=this.treeAdapter.getChildNodes(t),i=r[(n?r.lastIndexOf(n):r.length)-1];if(this.treeAdapter.getNodeSourceCodeLocation(i)){let{endLine:t,endCol:n,endOffset:r}=e.location;this.treeAdapter.updateNodeSourceCodeLocation(i,{endLine:t,endCol:n,endOffset:r})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,e.location)}_adoptNodes(e,t){for(let n=this.treeAdapter.getFirstChild(e);n;n=this.treeAdapter.getFirstChild(e))this.treeAdapter.detachNode(n),this.treeAdapter.appendChild(t,n)}_setEndLocation(e,t){if(this.treeAdapter.getNodeSourceCodeLocation(e)&&t.location){let n=t.location,r=this.treeAdapter.getTagName(e),i=t.type===Xv.END_TAG&&r===t.tagName?{endTag:{...n},endLine:n.endLine,endCol:n.endCol,endOffset:n.endOffset}:{endLine:n.startLine,endCol:n.startCol,endOffset:n.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(e,i)}}shouldProcessStartTagTokenInForeignContent(e){if(!this.currentNotInHTML)return!1;let t,n;return this.openElements.stackTop===0&&this.fragmentContext?(t=this.fragmentContext,n=this.fragmentContextID):{current:t,currentTagId:n}=this.openElements,e.tagID===J.SVG&&this.treeAdapter.getTagName(t)===q.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(t)===K.MATHML?!1:this.tokenizer.inForeignNode||(e.tagID===J.MGLYPH||e.tagID===J.MALIGNMARK)&&n!==void 0&&!this._isIntegrationPoint(n,t,K.HTML)}_processToken(e){switch(e.type){case Xv.CHARACTER:this.onCharacter(e);break;case Xv.NULL_CHARACTER:this.onNullCharacter(e);break;case Xv.COMMENT:this.onComment(e);break;case Xv.DOCTYPE:this.onDoctype(e);break;case Xv.START_TAG:this._processStartTag(e);break;case Xv.END_TAG:this.onEndTag(e);break;case Xv.EOF:this.onEof(e);break;case Xv.WHITESPACE_CHARACTER:this.onWhitespaceCharacter(e)}}_isIntegrationPoint(e,t,n){return Sb(e,this.treeAdapter.getNamespaceURI(t),this.treeAdapter.getAttrList(t),n)}_reconstructActiveFormattingElements(){let e=this.activeFormattingElements.entries.length;if(e){let t=this.activeFormattingElements.entries.findIndex(e=>e.type===qy.Marker||this.openElements.contains(e.element)),n=t===-1?e-1:t-1;for(let e=n;e>=0;e--){let t=this.activeFormattingElements.entries[e];this._insertElement(t.token,this.treeAdapter.getNamespaceURI(t.element)),t.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=Z.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(J.P),this.openElements.popUntilTagNamePopped(J.P)}_resetInsertionMode(){for(let e=this.openElements.stackTop;e>=0;e--)switch(e===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[e]){case J.TR:this.insertionMode=Z.IN_ROW;return;case J.TBODY:case J.THEAD:case J.TFOOT:this.insertionMode=Z.IN_TABLE_BODY;return;case J.CAPTION:this.insertionMode=Z.IN_CAPTION;return;case J.COLGROUP:this.insertionMode=Z.IN_COLUMN_GROUP;return;case J.TABLE:this.insertionMode=Z.IN_TABLE;return;case J.BODY:this.insertionMode=Z.IN_BODY;return;case J.FRAMESET:this.insertionMode=Z.IN_FRAMESET;return;case J.SELECT:this._resetInsertionModeForSelect(e);return;case J.TEMPLATE:this.insertionMode=this.tmplInsertionModeStack[0];return;case J.HTML:this.insertionMode=this.headElement?Z.AFTER_HEAD:Z.BEFORE_HEAD;return;case J.TD:case J.TH:if(e>0){this.insertionMode=Z.IN_CELL;return}break;case J.HEAD:if(e>0){this.insertionMode=Z.IN_HEAD;return}}this.insertionMode=Z.IN_BODY}_resetInsertionModeForSelect(e){if(e>0)for(let t=e-1;t>0;t--){let e=this.openElements.tagIDs[t];if(e===J.TEMPLATE)break;if(e===J.TABLE){this.insertionMode=Z.IN_SELECT_IN_TABLE;return}}this.insertionMode=Z.IN_SELECT}_isElementCausesFosterParenting(e){return Db.has(e)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this.openElements.currentTagId!==void 0&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let e=this.openElements.stackTop;e>=0;e--){let t=this.openElements.items[e];switch(this.openElements.tagIDs[e]){case J.TEMPLATE:if(this.treeAdapter.getNamespaceURI(t)===K.HTML)return{parent:this.treeAdapter.getTemplateContent(t),beforeElement:null};break;case J.TABLE:{let n=this.treeAdapter.getParentNode(t);return n?{parent:n,beforeElement:t}:{parent:this.openElements.items[e-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(e){let t=this._findFosterParentingLocation();t.beforeElement?this.treeAdapter.insertBefore(t.parent,e,t.beforeElement):this.treeAdapter.appendChild(t.parent,e)}_isSpecialElement(e,t){return xy[this.treeAdapter.getNamespaceURI(e)].has(t)}onCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){qS(this,e);return}switch(this.insertionMode){case Z.INITIAL:Hb(this,e);break;case Z.BEFORE_HTML:Gb(this,e);break;case Z.BEFORE_HEAD:Jb(this,e);break;case Z.IN_HEAD:Qb(this,e);break;case Z.IN_HEAD_NO_SCRIPT:tx(this,e);break;case Z.AFTER_HEAD:ix(this,e);break;case Z.IN_BODY:case Z.IN_CAPTION:case Z.IN_CELL:case Z.IN_TEMPLATE:sx(this,e);break;case Z.TEXT:case Z.IN_SELECT:case Z.IN_SELECT_IN_TABLE:this._insertCharacters(e);break;case Z.IN_TABLE:case Z.IN_TABLE_BODY:case Z.IN_ROW:nS(this,e);break;case Z.IN_TABLE_TEXT:hS(this,e);break;case Z.IN_COLUMN_GROUP:SS(this,e);break;case Z.AFTER_BODY:RS(this,e);break;case Z.AFTER_AFTER_BODY:WS(this,e)}}onNullCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){KS(this,e);return}switch(this.insertionMode){case Z.INITIAL:Hb(this,e);break;case Z.BEFORE_HTML:Gb(this,e);break;case Z.BEFORE_HEAD:Jb(this,e);break;case Z.IN_HEAD:Qb(this,e);break;case Z.IN_HEAD_NO_SCRIPT:tx(this,e);break;case Z.AFTER_HEAD:ix(this,e);break;case Z.TEXT:this._insertCharacters(e);break;case Z.IN_TABLE:case Z.IN_TABLE_BODY:case Z.IN_ROW:nS(this,e);break;case Z.IN_COLUMN_GROUP:SS(this,e);break;case Z.AFTER_BODY:RS(this,e);break;case Z.AFTER_AFTER_BODY:WS(this,e)}}onComment(e){if(this.skipNextNewLine=!1,this.currentNotInHTML){Lb(this,e);return}switch(this.insertionMode){case Z.INITIAL:case Z.BEFORE_HTML:case Z.BEFORE_HEAD:case Z.IN_HEAD:case Z.IN_HEAD_NO_SCRIPT:case Z.AFTER_HEAD:case Z.IN_BODY:case Z.IN_TABLE:case Z.IN_CAPTION:case Z.IN_COLUMN_GROUP:case Z.IN_TABLE_BODY:case Z.IN_ROW:case Z.IN_CELL:case Z.IN_SELECT:case Z.IN_SELECT_IN_TABLE:case Z.IN_TEMPLATE:case Z.IN_FRAMESET:case Z.AFTER_FRAMESET:Lb(this,e);break;case Z.IN_TABLE_TEXT:gS(this,e);break;case Z.AFTER_BODY:Rb(this,e);break;case Z.AFTER_AFTER_BODY:case Z.AFTER_AFTER_FRAMESET:zb(this,e)}}onDoctype(e){switch(this.skipNextNewLine=!1,this.insertionMode){case Z.INITIAL:Vb(this,e);break;case Z.BEFORE_HEAD:case Z.IN_HEAD:case Z.IN_HEAD_NO_SCRIPT:case Z.AFTER_HEAD:this._err(e,G.misplacedDoctype);break;case Z.IN_TABLE_TEXT:gS(this,e)}}onStartTag(e){this.skipNextNewLine=!1,this.currentToken=e,this._processStartTag(e),e.selfClosing&&!e.ackSelfClosing&&this._err(e,G.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(e){this.shouldProcessStartTagTokenInForeignContent(e)?YS(this,e):this._startTagOutsideForeignContent(e)}_startTagOutsideForeignContent(e){switch(this.insertionMode){case Z.INITIAL:Hb(this,e);break;case Z.BEFORE_HTML:Ub(this,e);break;case Z.BEFORE_HEAD:Kb(this,e);break;case Z.IN_HEAD:Yb(this,e);break;case Z.IN_HEAD_NO_SCRIPT:$b(this,e);break;case Z.AFTER_HEAD:nx(this,e);break;case Z.IN_BODY:Bx(this,e);break;case Z.IN_TABLE:dS(this,e);break;case Z.IN_TABLE_TEXT:gS(this,e);break;case Z.IN_CAPTION:vS(this,e);break;case Z.IN_COLUMN_GROUP:bS(this,e);break;case Z.IN_TABLE_BODY:CS(this,e);break;case Z.IN_ROW:TS(this,e);break;case Z.IN_CELL:DS(this,e);break;case Z.IN_SELECT:kS(this,e);break;case Z.IN_SELECT_IN_TABLE:jS(this,e);break;case Z.IN_TEMPLATE:NS(this,e);break;case Z.AFTER_BODY:IS(this,e);break;case Z.IN_FRAMESET:zS(this,e);break;case Z.AFTER_FRAMESET:VS(this,e);break;case Z.AFTER_AFTER_BODY:US(this,e);break;case Z.AFTER_AFTER_FRAMESET:GS(this,e)}}onEndTag(e){this.skipNextNewLine=!1,this.currentToken=e,this.currentNotInHTML?XS(this,e):this._endTagOutsideForeignContent(e)}_endTagOutsideForeignContent(e){switch(this.insertionMode){case Z.INITIAL:Hb(this,e);break;case Z.BEFORE_HTML:Wb(this,e);break;case Z.BEFORE_HEAD:qb(this,e);break;case Z.IN_HEAD:Xb(this,e);break;case Z.IN_HEAD_NO_SCRIPT:ex(this,e);break;case Z.AFTER_HEAD:rx(this,e);break;case Z.IN_BODY:Qx(this,e);break;case Z.TEXT:eS(this,e);break;case Z.IN_TABLE:fS(this,e);break;case Z.IN_TABLE_TEXT:gS(this,e);break;case Z.IN_CAPTION:yS(this,e);break;case Z.IN_COLUMN_GROUP:xS(this,e);break;case Z.IN_TABLE_BODY:wS(this,e);break;case Z.IN_ROW:ES(this,e);break;case Z.IN_CELL:OS(this,e);break;case Z.IN_SELECT:AS(this,e);break;case Z.IN_SELECT_IN_TABLE:MS(this,e);break;case Z.IN_TEMPLATE:PS(this,e);break;case Z.AFTER_BODY:LS(this,e);break;case Z.IN_FRAMESET:BS(this,e);break;case Z.AFTER_FRAMESET:HS(this,e);break;case Z.AFTER_AFTER_BODY:WS(this,e)}}onEof(e){switch(this.insertionMode){case Z.INITIAL:Hb(this,e);break;case Z.BEFORE_HTML:Gb(this,e);break;case Z.BEFORE_HEAD:Jb(this,e);break;case Z.IN_HEAD:Qb(this,e);break;case Z.IN_HEAD_NO_SCRIPT:tx(this,e);break;case Z.AFTER_HEAD:ix(this,e);break;case Z.IN_BODY:case Z.IN_TABLE:case Z.IN_CAPTION:case Z.IN_COLUMN_GROUP:case Z.IN_TABLE_BODY:case Z.IN_ROW:case Z.IN_CELL:case Z.IN_SELECT:case Z.IN_SELECT_IN_TABLE:$x(this,e);break;case Z.TEXT:tS(this,e);break;case Z.IN_TABLE_TEXT:gS(this,e);break;case Z.IN_TEMPLATE:FS(this,e);break;case Z.AFTER_BODY:case Z.IN_FRAMESET:case Z.AFTER_FRAMESET:case Z.AFTER_AFTER_BODY:case Z.AFTER_AFTER_FRAMESET:Bb(this,e)}}onWhitespaceCharacter(e){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,e.chars.charCodeAt(0)===W.LINE_FEED)){if(e.chars.length===1)return;e.chars=e.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(e);return}switch(this.insertionMode){case Z.IN_HEAD:case Z.IN_HEAD_NO_SCRIPT:case Z.AFTER_HEAD:case Z.TEXT:case Z.IN_COLUMN_GROUP:case Z.IN_SELECT:case Z.IN_SELECT_IN_TABLE:case Z.IN_FRAMESET:case Z.AFTER_FRAMESET:this._insertCharacters(e);break;case Z.IN_BODY:case Z.IN_CAPTION:case Z.IN_CELL:case Z.IN_TEMPLATE:case Z.AFTER_BODY:case Z.AFTER_AFTER_BODY:case Z.AFTER_AFTER_FRAMESET:ox(this,e);break;case Z.IN_TABLE:case Z.IN_TABLE_BODY:case Z.IN_ROW:nS(this,e);break;case Z.IN_TABLE_TEXT:mS(this,e)}}};function Ab(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return n?e.openElements.contains(n.element)?e.openElements.hasInScope(t.tagID)||(n=null):(e.activeFormattingElements.removeEntry(n),n=null):Zx(e,t),n}function jb(e,t){let n=null,r=e.openElements.stackTop;for(;r>=0;r--){let i=e.openElements.items[r];if(i===t.element)break;e._isSpecialElement(i,e.openElements.tagIDs[r])&&(n=i)}return n||(e.openElements.shortenToLength(Math.max(r,0)),e.activeFormattingElements.removeEntry(t)),n}function Mb(e,t,n){let r=t,i=e.openElements.getCommonAncestor(t);for(let a=0,o=i;o!==n;a++,o=i){i=e.openElements.getCommonAncestor(o);let n=e.activeFormattingElements.getElementEntry(o),s=n&&a>=Tb;!n||s?(s&&e.activeFormattingElements.removeEntry(n),e.openElements.remove(o)):(o=Nb(e,n),r===t&&(e.activeFormattingElements.bookmark=n),e.treeAdapter.detachNode(r),e.treeAdapter.appendChild(o,r),r=o)}return r}function Nb(e,t){let n=e.treeAdapter.getNamespaceURI(t.element),r=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,r),t.element=r,r}function Pb(e,t,n){let r=by(e.treeAdapter.getTagName(t));if(e._isElementCausesFosterParenting(r))e._fosterParentElement(n);else{let i=e.treeAdapter.getNamespaceURI(t);r===J.TEMPLATE&&i===K.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function Fb(e,t,n){let r=e.treeAdapter.getNamespaceURI(n.element),{token:i}=n,a=e.treeAdapter.createElement(i.tagName,r,i.attrs);e._adoptNodes(t,a),e.treeAdapter.appendChild(t,a),e.activeFormattingElements.insertElementAfterBookmark(a,i),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,a,i.tagID)}function Ib(e,t){for(let n=0;n<wb;n++){let n=Ab(e,t);if(!n)break;let r=jb(e,n);if(!r)break;e.activeFormattingElements.bookmark=n;let i=Mb(e,r,n.element),a=e.openElements.getCommonAncestor(n.element);e.treeAdapter.detachNode(i),a&&Pb(e,a,i),Fb(e,r,n)}}function Lb(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function Rb(e,t){e._appendCommentNode(t,e.openElements.items[0])}function zb(e,t){e._appendCommentNode(t,e.document)}function Bb(e,t){if(e.stopped=!0,t.location){let n=e.fragmentContext?0:2;for(let r=e.openElements.stackTop;r>=n;r--)e._setEndLocation(e.openElements.items[r],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){let n=e.openElements.items[0],r=e.treeAdapter.getNodeSourceCodeLocation(n);if(r&&!r.endTag&&(e._setEndLocation(n,t),e.openElements.stackTop>=1)){let n=e.openElements.items[1],r=e.treeAdapter.getNodeSourceCodeLocation(n);r&&!r.endTag&&e._setEndLocation(n,t)}}}}function Vb(e,t){e._setDocumentType(t);let n=t.forceQuirks?vy.QUIRKS:sb(t);ob(t)||e._err(t,G.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=Z.BEFORE_HTML}function Hb(e,t){e._err(t,G.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,vy.QUIRKS),e.insertionMode=Z.BEFORE_HTML,e._processToken(t)}function Ub(e,t){t.tagID===J.HTML?(e._insertElement(t,K.HTML),e.insertionMode=Z.BEFORE_HEAD):Gb(e,t)}function Wb(e,t){let n=t.tagID;(n===J.HTML||n===J.HEAD||n===J.BODY||n===J.BR)&&Gb(e,t)}function Gb(e,t){e._insertFakeRootElement(),e.insertionMode=Z.BEFORE_HEAD,e._processToken(t)}function Kb(e,t){switch(t.tagID){case J.HTML:Bx(e,t);break;case J.HEAD:e._insertElement(t,K.HTML),e.headElement=e.openElements.current,e.insertionMode=Z.IN_HEAD;break;default:Jb(e,t)}}function qb(e,t){let n=t.tagID;n===J.HEAD||n===J.BODY||n===J.HTML||n===J.BR?Jb(e,t):e._err(t,G.endTagWithoutMatchingOpenElement)}function Jb(e,t){e._insertFakeElement(q.HEAD,J.HEAD),e.headElement=e.openElements.current,e.insertionMode=Z.IN_HEAD,e._processToken(t)}function Yb(e,t){switch(t.tagID){case J.HTML:Bx(e,t);break;case J.BASE:case J.BASEFONT:case J.BGSOUND:case J.LINK:case J.META:e._appendElement(t,K.HTML),t.ackSelfClosing=!0;break;case J.TITLE:e._switchToTextParsing(t,Cy.RCDATA);break;case J.NOSCRIPT:e.options.scriptingEnabled?e._switchToTextParsing(t,Cy.RAWTEXT):(e._insertElement(t,K.HTML),e.insertionMode=Z.IN_HEAD_NO_SCRIPT);break;case J.NOFRAMES:case J.STYLE:e._switchToTextParsing(t,Cy.RAWTEXT);break;case J.SCRIPT:e._switchToTextParsing(t,Cy.SCRIPT_DATA);break;case J.TEMPLATE:e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=Z.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(Z.IN_TEMPLATE);break;case J.HEAD:e._err(t,G.misplacedStartTagForHeadElement);break;default:Qb(e,t)}}function Xb(e,t){switch(t.tagID){case J.HEAD:e.openElements.pop(),e.insertionMode=Z.AFTER_HEAD;break;case J.BODY:case J.BR:case J.HTML:Qb(e,t);break;case J.TEMPLATE:Zb(e,t);break;default:e._err(t,G.endTagWithoutMatchingOpenElement)}}function Zb(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==J.TEMPLATE&&e._err(t,G.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(J.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,G.endTagWithoutMatchingOpenElement)}function Qb(e,t){e.openElements.pop(),e.insertionMode=Z.AFTER_HEAD,e._processToken(t)}function $b(e,t){switch(t.tagID){case J.HTML:Bx(e,t);break;case J.BASEFONT:case J.BGSOUND:case J.HEAD:case J.LINK:case J.META:case J.NOFRAMES:case J.STYLE:Yb(e,t);break;case J.NOSCRIPT:e._err(t,G.nestedNoscriptInHead);break;default:tx(e,t)}}function ex(e,t){switch(t.tagID){case J.NOSCRIPT:e.openElements.pop(),e.insertionMode=Z.IN_HEAD;break;case J.BR:tx(e,t);break;default:e._err(t,G.endTagWithoutMatchingOpenElement)}}function tx(e,t){let n=t.type===Xv.EOF?G.openElementsLeftAfterEof:G.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=Z.IN_HEAD,e._processToken(t)}function nx(e,t){switch(t.tagID){case J.HTML:Bx(e,t);break;case J.BODY:e._insertElement(t,K.HTML),e.framesetOk=!1,e.insertionMode=Z.IN_BODY;break;case J.FRAMESET:e._insertElement(t,K.HTML),e.insertionMode=Z.IN_FRAMESET;break;case J.BASE:case J.BASEFONT:case J.BGSOUND:case J.LINK:case J.META:case J.NOFRAMES:case J.SCRIPT:case J.STYLE:case J.TEMPLATE:case J.TITLE:e._err(t,G.abandonedHeadElementChild),e.openElements.push(e.headElement,J.HEAD),Yb(e,t),e.openElements.remove(e.headElement);break;case J.HEAD:e._err(t,G.misplacedStartTagForHeadElement);break;default:ix(e,t)}}function rx(e,t){switch(t.tagID){case J.BODY:case J.HTML:case J.BR:ix(e,t);break;case J.TEMPLATE:Zb(e,t);break;default:e._err(t,G.endTagWithoutMatchingOpenElement)}}function ix(e,t){e._insertFakeElement(q.BODY,J.BODY),e.insertionMode=Z.IN_BODY,ax(e,t)}function ax(e,t){switch(t.type){case Xv.CHARACTER:sx(e,t);break;case Xv.WHITESPACE_CHARACTER:ox(e,t);break;case Xv.COMMENT:Lb(e,t);break;case Xv.START_TAG:Bx(e,t);break;case Xv.END_TAG:Qx(e,t);break;case Xv.EOF:$x(e,t)}}function ox(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function sx(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function cx(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function lx(e,t){let n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function ux(e,t){let n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,K.HTML),e.insertionMode=Z.IN_FRAMESET)}function dx(e,t){e.openElements.hasInButtonScope(J.P)&&e._closePElement(),e._insertElement(t,K.HTML)}function fx(e,t){e.openElements.hasInButtonScope(J.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&Sy.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,K.HTML)}function px(e,t){e.openElements.hasInButtonScope(J.P)&&e._closePElement(),e._insertElement(t,K.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function mx(e,t){let n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(J.P)&&e._closePElement(),e._insertElement(t,K.HTML),n||(e.formElement=e.openElements.current))}function hx(e,t){e.framesetOk=!1;let n=t.tagID;for(let t=e.openElements.stackTop;t>=0;t--){let r=e.openElements.tagIDs[t];if(n===J.LI&&r===J.LI||(n===J.DD||n===J.DT)&&(r===J.DD||r===J.DT)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.popUntilTagNamePopped(r);break}if(r!==J.ADDRESS&&r!==J.DIV&&r!==J.P&&e._isSpecialElement(e.openElements.items[t],r))break}e.openElements.hasInButtonScope(J.P)&&e._closePElement(),e._insertElement(t,K.HTML)}function gx(e,t){e.openElements.hasInButtonScope(J.P)&&e._closePElement(),e._insertElement(t,K.HTML),e.tokenizer.state=Cy.PLAINTEXT}function _x(e,t){e.openElements.hasInScope(J.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(J.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,K.HTML),e.framesetOk=!1}function vx(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(q.A);n&&(Ib(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,K.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function yx(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,K.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function bx(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(J.NOBR)&&(Ib(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,K.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function xx(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,K.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function Sx(e,t){e.treeAdapter.getDocumentMode(e.document)!==vy.QUIRKS&&e.openElements.hasInButtonScope(J.P)&&e._closePElement(),e._insertElement(t,K.HTML),e.framesetOk=!1,e.insertionMode=Z.IN_TABLE}function Cx(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,K.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function wx(e){let t=Zv(e,_y.TYPE);return t!=null&&t.toLowerCase()===Cb}function Tx(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,K.HTML),wx(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function Ex(e,t){e._appendElement(t,K.HTML),t.ackSelfClosing=!0}function Dx(e,t){e.openElements.hasInButtonScope(J.P)&&e._closePElement(),e._appendElement(t,K.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Ox(e,t){t.tagName=q.IMG,t.tagID=J.IMG,Cx(e,t)}function kx(e,t){e._insertElement(t,K.HTML),e.skipNextNewLine=!0,e.tokenizer.state=Cy.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=Z.TEXT}function Ax(e,t){e.openElements.hasInButtonScope(J.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,Cy.RAWTEXT)}function jx(e,t){e.framesetOk=!1,e._switchToTextParsing(t,Cy.RAWTEXT)}function Mx(e,t){e._switchToTextParsing(t,Cy.RAWTEXT)}function Nx(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,K.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===Z.IN_TABLE||e.insertionMode===Z.IN_CAPTION||e.insertionMode===Z.IN_TABLE_BODY||e.insertionMode===Z.IN_ROW||e.insertionMode===Z.IN_CELL?Z.IN_SELECT_IN_TABLE:Z.IN_SELECT}function Px(e,t){e.openElements.currentTagId===J.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,K.HTML)}function Fx(e,t){e.openElements.hasInScope(J.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,K.HTML)}function Ix(e,t){e.openElements.hasInScope(J.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(J.RTC),e._insertElement(t,K.HTML)}function Lx(e,t){e._reconstructActiveFormattingElements(),gb(t),vb(t),t.selfClosing?e._appendElement(t,K.MATHML):e._insertElement(t,K.MATHML),t.ackSelfClosing=!0}function Rx(e,t){e._reconstructActiveFormattingElements(),_b(t),vb(t),t.selfClosing?e._appendElement(t,K.SVG):e._insertElement(t,K.SVG),t.ackSelfClosing=!0}function zx(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,K.HTML)}function Bx(e,t){switch(t.tagID){case J.I:case J.S:case J.B:case J.U:case J.EM:case J.TT:case J.BIG:case J.CODE:case J.FONT:case J.SMALL:case J.STRIKE:case J.STRONG:yx(e,t);break;case J.A:vx(e,t);break;case J.H1:case J.H2:case J.H3:case J.H4:case J.H5:case J.H6:fx(e,t);break;case J.P:case J.DL:case J.OL:case J.UL:case J.DIV:case J.DIR:case J.NAV:case J.MAIN:case J.MENU:case J.ASIDE:case J.CENTER:case J.FIGURE:case J.FOOTER:case J.HEADER:case J.HGROUP:case J.DIALOG:case J.DETAILS:case J.ADDRESS:case J.ARTICLE:case J.SEARCH:case J.SECTION:case J.SUMMARY:case J.FIELDSET:case J.BLOCKQUOTE:case J.FIGCAPTION:dx(e,t);break;case J.LI:case J.DD:case J.DT:hx(e,t);break;case J.BR:case J.IMG:case J.WBR:case J.AREA:case J.EMBED:case J.KEYGEN:Cx(e,t);break;case J.HR:Dx(e,t);break;case J.RB:case J.RTC:Fx(e,t);break;case J.RT:case J.RP:Ix(e,t);break;case J.PRE:case J.LISTING:px(e,t);break;case J.XMP:Ax(e,t);break;case J.SVG:Rx(e,t);break;case J.HTML:cx(e,t);break;case J.BASE:case J.LINK:case J.META:case J.STYLE:case J.TITLE:case J.SCRIPT:case J.BGSOUND:case J.BASEFONT:case J.TEMPLATE:Yb(e,t);break;case J.BODY:lx(e,t);break;case J.FORM:mx(e,t);break;case J.NOBR:bx(e,t);break;case J.MATH:Lx(e,t);break;case J.TABLE:Sx(e,t);break;case J.INPUT:Tx(e,t);break;case J.PARAM:case J.TRACK:case J.SOURCE:Ex(e,t);break;case J.IMAGE:Ox(e,t);break;case J.BUTTON:_x(e,t);break;case J.APPLET:case J.OBJECT:case J.MARQUEE:xx(e,t);break;case J.IFRAME:jx(e,t);break;case J.SELECT:Nx(e,t);break;case J.OPTION:case J.OPTGROUP:Px(e,t);break;case J.NOEMBED:case J.NOFRAMES:Mx(e,t);break;case J.FRAMESET:ux(e,t);break;case J.TEXTAREA:kx(e,t);break;case J.NOSCRIPT:e.options.scriptingEnabled?Mx(e,t):zx(e,t);break;case J.PLAINTEXT:gx(e,t);break;case J.COL:case J.TH:case J.TD:case J.TR:case J.HEAD:case J.FRAME:case J.TBODY:case J.TFOOT:case J.THEAD:case J.CAPTION:case J.COLGROUP:break;default:zx(e,t)}}function Vx(e,t){if(e.openElements.hasInScope(J.BODY)&&(e.insertionMode=Z.AFTER_BODY,e.options.sourceCodeLocationInfo)){let n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function Hx(e,t){e.openElements.hasInScope(J.BODY)&&(e.insertionMode=Z.AFTER_BODY,LS(e,t))}function Ux(e,t){let n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function Wx(e){let t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(J.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(J.FORM):n&&e.openElements.remove(n))}function Gx(e){e.openElements.hasInButtonScope(J.P)||e._insertFakeElement(q.P,J.P),e._closePElement()}function Kx(e){e.openElements.hasInListItemScope(J.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(J.LI),e.openElements.popUntilTagNamePopped(J.LI))}function qx(e,t){let n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function Jx(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function Yx(e,t){let n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function Xx(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(q.BR,J.BR),e.openElements.pop(),e.framesetOk=!1}function Zx(e,t){let n=t.tagName,r=t.tagID;for(let t=e.openElements.stackTop;t>0;t--){let i=e.openElements.items[t],a=e.openElements.tagIDs[t];if(r===a&&(r!==J.UNKNOWN||e.treeAdapter.getTagName(i)===n)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.stackTop>=t&&e.openElements.shortenToLength(t);break}if(e._isSpecialElement(i,a))break}}function Qx(e,t){switch(t.tagID){case J.A:case J.B:case J.I:case J.S:case J.U:case J.EM:case J.TT:case J.BIG:case J.CODE:case J.FONT:case J.NOBR:case J.SMALL:case J.STRIKE:case J.STRONG:Ib(e,t);break;case J.P:Gx(e);break;case J.DL:case J.UL:case J.OL:case J.DIR:case J.DIV:case J.NAV:case J.PRE:case J.MAIN:case J.MENU:case J.ASIDE:case J.BUTTON:case J.CENTER:case J.FIGURE:case J.FOOTER:case J.HEADER:case J.HGROUP:case J.DIALOG:case J.ADDRESS:case J.ARTICLE:case J.DETAILS:case J.SEARCH:case J.SECTION:case J.SUMMARY:case J.LISTING:case J.FIELDSET:case J.BLOCKQUOTE:case J.FIGCAPTION:Ux(e,t);break;case J.LI:Kx(e);break;case J.DD:case J.DT:qx(e,t);break;case J.H1:case J.H2:case J.H3:case J.H4:case J.H5:case J.H6:Jx(e);break;case J.BR:Xx(e);break;case J.BODY:Vx(e,t);break;case J.HTML:Hx(e,t);break;case J.FORM:Wx(e);break;case J.APPLET:case J.OBJECT:case J.MARQUEE:Yx(e,t);break;case J.TEMPLATE:Zb(e,t);break;default:Zx(e,t)}}function $x(e,t){e.tmplInsertionModeStack.length>0?FS(e,t):Bb(e,t)}function eS(e,t){var n;t.tagID===J.SCRIPT&&((n=e.scriptHandler)==null||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function tS(e,t){e._err(t,G.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function nS(e,t){if(e.openElements.currentTagId!==void 0&&Db.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=Z.IN_TABLE_TEXT,t.type){case Xv.CHARACTER:hS(e,t);break;case Xv.WHITESPACE_CHARACTER:mS(e,t)}else pS(e,t)}function rS(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,K.HTML),e.insertionMode=Z.IN_CAPTION}function iS(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,K.HTML),e.insertionMode=Z.IN_COLUMN_GROUP}function aS(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(q.COLGROUP,J.COLGROUP),e.insertionMode=Z.IN_COLUMN_GROUP,bS(e,t)}function oS(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,K.HTML),e.insertionMode=Z.IN_TABLE_BODY}function sS(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(q.TBODY,J.TBODY),e.insertionMode=Z.IN_TABLE_BODY,CS(e,t)}function cS(e,t){e.openElements.hasInTableScope(J.TABLE)&&(e.openElements.popUntilTagNamePopped(J.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function lS(e,t){wx(t)?e._appendElement(t,K.HTML):pS(e,t),t.ackSelfClosing=!0}function uS(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,K.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function dS(e,t){switch(t.tagID){case J.TD:case J.TH:case J.TR:sS(e,t);break;case J.STYLE:case J.SCRIPT:case J.TEMPLATE:Yb(e,t);break;case J.COL:aS(e,t);break;case J.FORM:uS(e,t);break;case J.TABLE:cS(e,t);break;case J.TBODY:case J.TFOOT:case J.THEAD:oS(e,t);break;case J.INPUT:lS(e,t);break;case J.CAPTION:rS(e,t);break;case J.COLGROUP:iS(e,t);break;default:pS(e,t)}}function fS(e,t){switch(t.tagID){case J.TABLE:e.openElements.hasInTableScope(J.TABLE)&&(e.openElements.popUntilTagNamePopped(J.TABLE),e._resetInsertionMode());break;case J.TEMPLATE:Zb(e,t);break;case J.BODY:case J.CAPTION:case J.COL:case J.COLGROUP:case J.HTML:case J.TBODY:case J.TD:case J.TFOOT:case J.TH:case J.THEAD:case J.TR:break;default:pS(e,t)}}function pS(e,t){let n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,ax(e,t),e.fosterParentingEnabled=n}function mS(e,t){e.pendingCharacterTokens.push(t)}function hS(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function gS(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)pS(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}var _S=new Set([J.CAPTION,J.COL,J.COLGROUP,J.TBODY,J.TD,J.TFOOT,J.TH,J.THEAD,J.TR]);function vS(e,t){let n=t.tagID;_S.has(n)?e.openElements.hasInTableScope(J.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(J.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Z.IN_TABLE,dS(e,t)):Bx(e,t)}function yS(e,t){let n=t.tagID;switch(n){case J.CAPTION:case J.TABLE:e.openElements.hasInTableScope(J.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(J.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Z.IN_TABLE,n===J.TABLE&&fS(e,t));break;case J.BODY:case J.COL:case J.COLGROUP:case J.HTML:case J.TBODY:case J.TD:case J.TFOOT:case J.TH:case J.THEAD:case J.TR:break;default:Qx(e,t)}}function bS(e,t){switch(t.tagID){case J.HTML:Bx(e,t);break;case J.COL:e._appendElement(t,K.HTML),t.ackSelfClosing=!0;break;case J.TEMPLATE:Yb(e,t);break;default:SS(e,t)}}function xS(e,t){switch(t.tagID){case J.COLGROUP:e.openElements.currentTagId===J.COLGROUP&&(e.openElements.pop(),e.insertionMode=Z.IN_TABLE);break;case J.TEMPLATE:Zb(e,t);break;case J.COL:break;default:SS(e,t)}}function SS(e,t){e.openElements.currentTagId===J.COLGROUP&&(e.openElements.pop(),e.insertionMode=Z.IN_TABLE,e._processToken(t))}function CS(e,t){switch(t.tagID){case J.TR:e.openElements.clearBackToTableBodyContext(),e._insertElement(t,K.HTML),e.insertionMode=Z.IN_ROW;break;case J.TH:case J.TD:e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(q.TR,J.TR),e.insertionMode=Z.IN_ROW,TS(e,t);break;case J.CAPTION:case J.COL:case J.COLGROUP:case J.TBODY:case J.TFOOT:case J.THEAD:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=Z.IN_TABLE,dS(e,t));break;default:dS(e,t)}}function wS(e,t){let n=t.tagID;switch(t.tagID){case J.TBODY:case J.TFOOT:case J.THEAD:e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=Z.IN_TABLE);break;case J.TABLE:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=Z.IN_TABLE,fS(e,t));break;case J.BODY:case J.CAPTION:case J.COL:case J.COLGROUP:case J.HTML:case J.TD:case J.TH:case J.TR:break;default:fS(e,t)}}function TS(e,t){switch(t.tagID){case J.TH:case J.TD:e.openElements.clearBackToTableRowContext(),e._insertElement(t,K.HTML),e.insertionMode=Z.IN_CELL,e.activeFormattingElements.insertMarker();break;case J.CAPTION:case J.COL:case J.COLGROUP:case J.TBODY:case J.TFOOT:case J.THEAD:case J.TR:e.openElements.hasInTableScope(J.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Z.IN_TABLE_BODY,CS(e,t));break;default:dS(e,t)}}function ES(e,t){switch(t.tagID){case J.TR:e.openElements.hasInTableScope(J.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Z.IN_TABLE_BODY);break;case J.TABLE:e.openElements.hasInTableScope(J.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Z.IN_TABLE_BODY,wS(e,t));break;case J.TBODY:case J.TFOOT:case J.THEAD:(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(J.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Z.IN_TABLE_BODY,wS(e,t));break;case J.BODY:case J.CAPTION:case J.COL:case J.COLGROUP:case J.HTML:case J.TD:case J.TH:break;default:fS(e,t)}}function DS(e,t){let n=t.tagID;_S.has(n)?(e.openElements.hasInTableScope(J.TD)||e.openElements.hasInTableScope(J.TH))&&(e._closeTableCell(),TS(e,t)):Bx(e,t)}function OS(e,t){let n=t.tagID;switch(n){case J.TD:case J.TH:e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Z.IN_ROW);break;case J.TABLE:case J.TBODY:case J.TFOOT:case J.THEAD:case J.TR:e.openElements.hasInTableScope(n)&&(e._closeTableCell(),ES(e,t));break;case J.BODY:case J.CAPTION:case J.COL:case J.COLGROUP:case J.HTML:break;default:Qx(e,t)}}function kS(e,t){switch(t.tagID){case J.HTML:Bx(e,t);break;case J.OPTION:e.openElements.currentTagId===J.OPTION&&e.openElements.pop(),e._insertElement(t,K.HTML);break;case J.OPTGROUP:e.openElements.currentTagId===J.OPTION&&e.openElements.pop(),e.openElements.currentTagId===J.OPTGROUP&&e.openElements.pop(),e._insertElement(t,K.HTML);break;case J.HR:e.openElements.currentTagId===J.OPTION&&e.openElements.pop(),e.openElements.currentTagId===J.OPTGROUP&&e.openElements.pop(),e._appendElement(t,K.HTML),t.ackSelfClosing=!0;break;case J.INPUT:case J.KEYGEN:case J.TEXTAREA:case J.SELECT:e.openElements.hasInSelectScope(J.SELECT)&&(e.openElements.popUntilTagNamePopped(J.SELECT),e._resetInsertionMode(),t.tagID!==J.SELECT&&e._processStartTag(t));break;case J.SCRIPT:case J.TEMPLATE:Yb(e,t)}}function AS(e,t){switch(t.tagID){case J.OPTGROUP:e.openElements.stackTop>0&&e.openElements.currentTagId===J.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===J.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===J.OPTGROUP&&e.openElements.pop();break;case J.OPTION:e.openElements.currentTagId===J.OPTION&&e.openElements.pop();break;case J.SELECT:e.openElements.hasInSelectScope(J.SELECT)&&(e.openElements.popUntilTagNamePopped(J.SELECT),e._resetInsertionMode());break;case J.TEMPLATE:Zb(e,t)}}function jS(e,t){let n=t.tagID;n===J.CAPTION||n===J.TABLE||n===J.TBODY||n===J.TFOOT||n===J.THEAD||n===J.TR||n===J.TD||n===J.TH?(e.openElements.popUntilTagNamePopped(J.SELECT),e._resetInsertionMode(),e._processStartTag(t)):kS(e,t)}function MS(e,t){let n=t.tagID;n===J.CAPTION||n===J.TABLE||n===J.TBODY||n===J.TFOOT||n===J.THEAD||n===J.TR||n===J.TD||n===J.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(J.SELECT),e._resetInsertionMode(),e.onEndTag(t)):AS(e,t)}function NS(e,t){switch(t.tagID){case J.BASE:case J.BASEFONT:case J.BGSOUND:case J.LINK:case J.META:case J.NOFRAMES:case J.SCRIPT:case J.STYLE:case J.TEMPLATE:case J.TITLE:Yb(e,t);break;case J.CAPTION:case J.COLGROUP:case J.TBODY:case J.TFOOT:case J.THEAD:e.tmplInsertionModeStack[0]=Z.IN_TABLE,e.insertionMode=Z.IN_TABLE,dS(e,t);break;case J.COL:e.tmplInsertionModeStack[0]=Z.IN_COLUMN_GROUP,e.insertionMode=Z.IN_COLUMN_GROUP,bS(e,t);break;case J.TR:e.tmplInsertionModeStack[0]=Z.IN_TABLE_BODY,e.insertionMode=Z.IN_TABLE_BODY,CS(e,t);break;case J.TD:case J.TH:e.tmplInsertionModeStack[0]=Z.IN_ROW,e.insertionMode=Z.IN_ROW,TS(e,t);break;default:e.tmplInsertionModeStack[0]=Z.IN_BODY,e.insertionMode=Z.IN_BODY,Bx(e,t)}}function PS(e,t){t.tagID===J.TEMPLATE&&Zb(e,t)}function FS(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(J.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):Bb(e,t)}function IS(e,t){t.tagID===J.HTML?Bx(e,t):RS(e,t)}function LS(e,t){if(t.tagID===J.HTML){if(e.fragmentContext||(e.insertionMode=Z.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===J.HTML){e._setEndLocation(e.openElements.items[0],t);let n=e.openElements.items[1];n&&!e.treeAdapter.getNodeSourceCodeLocation(n)?.endTag&&e._setEndLocation(n,t)}}else RS(e,t)}function RS(e,t){e.insertionMode=Z.IN_BODY,ax(e,t)}function zS(e,t){switch(t.tagID){case J.HTML:Bx(e,t);break;case J.FRAMESET:e._insertElement(t,K.HTML);break;case J.FRAME:e._appendElement(t,K.HTML),t.ackSelfClosing=!0;break;case J.NOFRAMES:Yb(e,t)}}function BS(e,t){t.tagID===J.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==J.FRAMESET&&(e.insertionMode=Z.AFTER_FRAMESET))}function VS(e,t){switch(t.tagID){case J.HTML:Bx(e,t);break;case J.NOFRAMES:Yb(e,t)}}function HS(e,t){t.tagID===J.HTML&&(e.insertionMode=Z.AFTER_AFTER_FRAMESET)}function US(e,t){t.tagID===J.HTML?Bx(e,t):WS(e,t)}function WS(e,t){e.insertionMode=Z.IN_BODY,ax(e,t)}function GS(e,t){switch(t.tagID){case J.HTML:Bx(e,t);break;case J.NOFRAMES:Yb(e,t)}}function KS(e,t){t.chars=`�`,e._insertCharacters(t)}function qS(e,t){e._insertCharacters(t),e.framesetOk=!1}function JS(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==K.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function YS(e,t){if(hb(t))JS(e),e._startTagOutsideForeignContent(t);else{let n=e._getAdjustedCurrentElement(),r=e.treeAdapter.getNamespaceURI(n);r===K.MATHML?gb(t):r===K.SVG&&(yb(t),_b(t)),vb(t),t.selfClosing?e._appendElement(t,r):e._insertElement(t,r),t.ackSelfClosing=!0}}function XS(e,t){if(t.tagID===J.P||t.tagID===J.BR){JS(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){let r=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(r)===K.HTML){e._endTagOutsideForeignContent(t);break}let i=e.treeAdapter.getTagName(r);if(i.toLowerCase()===t.tagName){t.tagName=i,e.openElements.shortenToLength(n);break}}}q.AREA,q.BASE,q.BASEFONT,q.BGSOUND,q.BR,q.COL,q.EMBED,q.FRAME,q.HR,q.IMG,q.INPUT,q.KEYGEN,q.LINK,q.META,q.PARAM,q.SOURCE,q.TRACK,q.WBR;function ZS(e,t){return kb.parse(e,t)}async function QS(e){if(!e)return!1;if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>`u`||!document.body)return!1;let t=document.activeElement,n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t:null,r=n?.selectionStart??null,i=n?.selectionEnd??null,a=document.getSelection(),o=a?.rangeCount?a.getRangeAt(0).cloneRange():null,s=document.createElement(`textarea`);s.value=e,s.style.position=`fixed`,s.style.left=`-999999px`,s.style.top=`-999999px`,s.style.opacity=`0`,document.body.appendChild(s),s.focus(),s.select();try{return document.execCommand(`copy`)}finally{s.remove(),t&&t.isConnected&&(t.focus({preventScroll:!0}),n&&r!==null&&i!==null&&n.setSelectionRange(r,i)),a&&o&&(a.removeAllRanges(),a.addRange(o))}}catch{return!1}}function $S(e){if(!e)return``;let t=ZS(e),n=e=>`tagName`in e,r=t.childNodes.find(e=>n(e)&&e.tagName===`html`),i=r&&n(r)?r.childNodes.find(e=>n(e)&&e.tagName===`body`):null;if(!i||!n(i))return``;let a=new Set([`address`,`article`,`blockquote`,`div`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`li`,`p`,`pre`,`section`,`tr`]),o=``,s=()=>{o&&!o.endsWith(`
39
39
  `)&&(o+=`
40
- `)},c=e=>{if(`value`in e){o+=e.value;return}if(!n(e)||[`script`,`style`,`template`].includes(e.tagName))return;if(e.tagName===`br`){s();return}let t=a.has(e.tagName);t&&s(),e.childNodes.forEach(c),t&&s()};return i.childNodes.forEach(c),o.replace(/^\n+|\n+$/g,``)}async function eC(){if(typeof navigator>`u`||!navigator.clipboard)throw Error(`Clipboard unavailable`);try{let e=await navigator.clipboard.readText();if(e)return e}catch{}if(!navigator.clipboard.read)throw Error(`Clipboard text unavailable`);let e=await navigator.clipboard.read();for(let t of e){if(t.types.includes(`text/plain`)){let e=await(await t.getType(`text/plain`)).text();if(e)return e}if(t.types.includes(`text/html`)){let e=$S(await(await t.getType(`text/html`)).text());if(e)return e}}return``}var tC=e=>e===`antigravity`?`Antigravity`:e===`claude`?`Claude Code`:e===`codex`?`OpenAI Codex`:`GitHub Copilot`,nC=e=>e===`claude`?`warning`:e===`codex`?`success`:e===`antigravity`?`accent`:`info`,rC=(e,t)=>{switch(e){case`antigravity`:return`agy --conversation ${t}`;case`claude`:return`claude --resume ${t}`;case`codex`:return`codex resume ${t}`;case`copilot`:return`copilot --resume ${t}`;case`cursor`:return`cursor-agent --resume ${t}`;default:return`agy --conversation ${t}`}};function iC({activeSession:e,transcript:t,transcriptLoading:n,setActiveSession:r,workspaces:i,workspace:a,handleOpenDesktopSession:o,showToast:s}){let c=Et(),l=Rt(),u=c.data?.find(e=>e.id===`codex-desktop`),d=u?.available===!0,f=c.isLoading?`Checking whether Codex Desktop is available…`:c.isError?`Could not check whether Codex Desktop is available.`:u?.unavailableReason??`Codex Desktop is not available on this computer.`,p=(0,V.useRef)(!1),m=(0,V.useRef)(!1),h=(0,V.useRef)(null),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(!1);(0,V.useEffect)(()=>{!n&&t.length>0&&h.current?.scrollIntoView({behavior:`auto`})},[n,t]);let b=()=>a??Gn(i,e.workspacePath),x=async()=>{if(!d||p.current)return;let t=b();if(!t){s(`Could not match this session to a workspace — it may have been removed.`,`error`);return}p.current=!0,_(!0);try{await o(t,e.id,e.assistant)&&r(null)}finally{p.current=!1,_(!1)}},S=async()=>{if(m.current)return;let t=b();if(!t){s(`Could not match this session to a workspace.`,`error`);return}m.current=!0,y(!0);try{await l.mutateAsync({workspaceId:t.branchName,assistant:e.assistant,sessionId:e.id,cwd:e.workspacePath}),s(`Opened ${tC(e.assistant)} inside ContextSpace.`,`success`),r(null)}catch{let t=rC(e.assistant,e.id);await QS(t)?s(`Could not open terminal automatically. Copied command to clipboard:\n\n${t}`,`info`):s(`Could not open terminal automatically. Run manually:\n\n${t}`,`error`)}finally{y(!1),m.current=!1}};return(0,H.jsx)(Ov,{open:!0,onOpenChange:e=>!e&&r(null),children:(0,H.jsxs)(Mv,{className:`h-[80vh] max-w-4xl`,children:[(0,H.jsx)(Nv,{children:(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,H.jsx)(Bv,{tone:nC(e.assistant),children:tC(e.assistant)}),(0,H.jsxs)(`span`,{className:`text-[10px] font-mono bg-muted/60 text-muted-foreground px-1.5 py-0.5 rounded`,children:[`Read-Only Transcript · `,t.length,` turns`]}),(0,H.jsxs)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:[`ID: `,e.id.slice(0,8)]})]}),(0,H.jsx)(Fv,{className:`max-w-xl truncate text-sm`,title:e.title,children:e.title}),(0,H.jsxs)(Iv,{className:`sr-only`,children:[`Read-only transcript log and resume options for session `,e.id]})]})}),(0,H.jsxs)(Lv,{className:`space-y-4`,children:[n?(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2`,children:[(0,H.jsx)(Rv,{className:`size-6 text-primary`}),(0,H.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Loading conversation history...`})]}):t.length===0?(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center text-xs text-muted-foreground`,children:`No messages found in this transcript.`}):t.map((t,n)=>(0,H.jsxs)(`div`,{className:`flex flex-col ${t.role===`user`?`items-end`:`items-start`}`,children:[(0,H.jsxs)(`div`,{className:`mb-1 px-1 text-[10px] text-muted-foreground`,children:[t.role===`user`?`Developer`:e.assistant===`antigravity`?`Antigravity`:e.assistant===`claude`?`Claude`:e.assistant===`codex`?`Codex`:`Copilot`,t.timestamp&&` • ${new Date(t.timestamp).toLocaleTimeString()}`]}),(0,H.jsx)(`div`,{className:`max-w-[85%] rounded-xl border px-4 py-3 text-xs leading-relaxed ${t.role===`user`?`rounded-tr-none border-primary/30 bg-primary/10 text-foreground dark:border-primary/40 dark:bg-primary/20`:`rounded-tl-none border-border bg-card text-foreground shadow-xs dark:bg-muted/30`}`,children:(0,H.jsx)(Dv,{content:t.content})})]},n)),(0,H.jsx)(`div`,{ref:h})]}),(0,H.jsxs)(Pv,{className:`sm:justify-between`,children:[(0,H.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Read-only transcript. Interactive coding happens in your terminal or IDE.`}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsxs)(yn,{variant:`outline`,size:`sm`,onClick:async()=>{let t=rC(e.assistant,e.id);await QS(t),s(`Copied run command to clipboard:\n\n${t}`,`success`)},children:[(0,H.jsx)(Mr,{size:13}),` Copy CLI Command`]}),(0,H.jsxs)(yn,{size:`sm`,variant:`default`,disabled:v,onClick:()=>void S(),children:[v?(0,H.jsx)(Rv,{className:`size-3`}):(0,H.jsx)(xi,{size:12}),`Resume in Terminal`]}),e.assistant===`codex`&&(0,H.jsxs)(yn,{variant:`outline`,size:`sm`,disabled:!d||g,title:d?`Open this exact thread in Codex Desktop`:f,"aria-label":d?`Open in Codex Desktop`:`Codex Desktop unavailable: ${f}`,onClick:()=>void x(),children:[g?(0,H.jsx)(Rv,{className:`size-3`}):(0,H.jsx)(Bn,{size:12}),g?`Opening…`:`Open in Codex Desktop`]})]})]})]})})}function aC({files:e,renderFile:t,label:n,revealPath:r,revealKey:i}){let a=(0,V.useRef)(null),o=(0,V.useMemo)(()=>{let t={directories:new Map,files:[]};for(let n of e){let e=n.file.split(`/`),r=t;for(let t of e.slice(0,-1))r.directories.has(t)||r.directories.set(t,{directories:new Map,files:[]}),r=r.directories.get(t);r.files.push(n)}return t},[e]);(0,V.useEffect)(()=>{if(r)for(let e of a.current?.querySelectorAll(`details[data-path]`)??[])r.startsWith(`${e.dataset.path}/`)&&(e.open=!0)},[r,i]);let s=(e,n=``)=>(0,H.jsxs)(`ul`,{className:`min-w-0 space-y-0.5`,children:[[...e.directories].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`details`,{open:!0,"data-path":n?`${n}/${e}`:e,className:`min-w-0`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer rounded px-2 py-1 text-xs hover:bg-accent focus-visible:outline focus-visible:outline-primary`,children:[(0,H.jsx)(Lr,{className:`mr-1 inline size-3.5`,"aria-hidden":`true`}),e]}),(0,H.jsx)(`div`,{className:`ml-3 border-l border-border pl-2`,children:s(t,n?`${n}/${e}`:e)})]})},`dir:${e}`)),[...e.files].sort((e,t)=>e.file.localeCompare(t.file)).map(e=>(0,H.jsx)(`li`,{children:t(e)},`file:${e.file}`))]});return(0,H.jsx)(`nav`,{ref:a,"aria-label":n,children:s(o)})}var oC=class extends V.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[DiffErrorBoundary] Caught error in diff viewer:`,e,t)}handleReset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?(0,H.jsxs)(`div`,{className:`p-4 rounded-lg border border-destructive/40 bg-destructive/10 text-foreground space-y-3 my-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-xs text-destructive`,children:[(0,H.jsx)(Si,{className:`size-4 shrink-0`}),(0,H.jsxs)(`span`,{children:[`Failed to render diff editor for `,this.props.filePath||`file`]})]}),(0,H.jsx)(`div`,{className:`font-mono text-[11px] text-muted-foreground break-all bg-background/80 p-2 rounded border border-border/60`,children:this.state.error?.message||`Unknown diff rendering error`}),(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsxs)(`button`,{type:`button`,onClick:this.handleReset,className:`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded border border-border bg-card hover:bg-accent text-foreground cursor-pointer transition-colors font-mono`,children:[(0,H.jsx)(li,{className:`size-3`}),(0,H.jsx)(`span`,{children:`Retry Render`})]})}),this.props.fallbackContent&&(0,H.jsxs)(`div`,{className:`mt-3`,children:[(0,H.jsx)(`div`,{className:`text-[10px] uppercase font-mono tracking-wider text-muted-foreground mb-1`,children:`Raw Diff Content`}),(0,H.jsx)(`pre`,{className:`font-mono text-[11px] bg-background/90 text-foreground p-3 rounded border border-border max-h-72 overflow-auto whitespace-pre`,children:this.props.fallbackContent})]})]}):this.props.children}};function sC(e){if(!e||!e.trim())return{originalContent:``,modifiedContent:``,hunks:[],isNewFile:!1,isDeletedFile:!1};let t=e.split(/\r?\n/),n=[],r=[],i=[],a=!1,o=!1,s=null,c=0;for(let e=0;e<t.length;e++){let l=t[e];if(l.startsWith(`--- /dev/null`)){a=!0;continue}if(l.startsWith(`+++ /dev/null`)){o=!0;continue}let u=l.match(/^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@(.*)$/);if(u){s&&n.push(s),c++;let e=parseInt(u[1],10),t=u[2]===void 0?1:parseInt(u[2],10),r=parseInt(u[3],10),i=u[4]===void 0?1:parseInt(u[4],10);s={id:`hunk-${c}`,hunkIndex:c-1,type:`accept`,startLineOriginal:e,lineCountOriginal:t,startLineModified:r,lineCountModified:i,patchHeader:l,enclosingDeclaration:u[5]?.trim()||void 0,lines:[]};continue}if(s){if(s.lines.push(l),l.startsWith(` `)){let e=l.slice(1);r.push(e),i.push(e)}else if(l.startsWith(`-`))r.push(l.slice(1));else if(l.startsWith(`+`))i.push(l.slice(1));else if(l.startsWith(`\\`))continue}}return s&&n.push(s),{originalContent:r.join(`
40
+ `)},c=e=>{if(`value`in e){o+=e.value;return}if(!n(e)||[`script`,`style`,`template`].includes(e.tagName))return;if(e.tagName===`br`){s();return}let t=a.has(e.tagName);t&&s(),e.childNodes.forEach(c),t&&s()};return i.childNodes.forEach(c),o.replace(/^\n+|\n+$/g,``)}async function eC(){if(typeof navigator>`u`||!navigator.clipboard)throw Error(`Clipboard unavailable`);try{let e=await navigator.clipboard.readText();if(e)return e}catch{}if(!navigator.clipboard.read)throw Error(`Clipboard text unavailable`);let e=await navigator.clipboard.read();for(let t of e){if(t.types.includes(`text/plain`)){let e=await(await t.getType(`text/plain`)).text();if(e)return e}if(t.types.includes(`text/html`)){let e=$S(await(await t.getType(`text/html`)).text());if(e)return e}}return``}var tC=e=>e===`antigravity`?`Antigravity`:e===`claude`?`Claude Code`:e===`codex`?`OpenAI Codex`:`GitHub Copilot`,nC=e=>e===`claude`?`warning`:e===`codex`?`success`:e===`antigravity`?`accent`:`info`,rC=(e,t)=>{switch(e){case`antigravity`:return`agy --conversation ${t}`;case`claude`:return`claude --resume ${t}`;case`codex`:return`codex resume ${t}`;case`copilot`:return`copilot --resume ${t}`;case`cursor`:return`cursor-agent --resume ${t}`;default:return`agy --conversation ${t}`}};function iC({activeSession:e,transcript:t,transcriptLoading:n,setActiveSession:r,workspaces:i,workspace:a,handleOpenDesktopSession:o,showToast:s}){let c=Et(),l=Rt(),u=c.data?.find(e=>e.id===`codex-desktop`),d=u?.available===!0,f=c.isLoading?`Checking whether Codex Desktop is available…`:c.isError?`Could not check whether Codex Desktop is available.`:u?.unavailableReason??`Codex Desktop is not available on this computer.`,p=(0,V.useRef)(!1),m=(0,V.useRef)(!1),h=(0,V.useRef)(null),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(!1),b=(0,V.useMemo)(()=>{let n=t.reduce((e,t)=>e+(t.usage?.totalTokens??(t.usage?.inputTokens??0)+(t.usage?.outputTokens??0)),0);return n>0?n:e?.usage?e.usage.totalTokens??(e.usage.inputTokens??0)+(e.usage.outputTokens??0):0},[t,e?.usage]);(0,V.useEffect)(()=>{!n&&t.length>0&&h.current?.scrollIntoView({behavior:`auto`})},[n,t]);let x=()=>a??Gn(i,e.workspacePath),S=async()=>{if(!d||p.current)return;let t=x();if(!t){s(`Could not match this session to a workspace — it may have been removed.`,`error`);return}p.current=!0,_(!0);try{await o(t,e.id,e.assistant)&&r(null)}finally{p.current=!1,_(!1)}},C=async()=>{if(m.current)return;let t=x();if(!t){s(`Could not match this session to a workspace.`,`error`);return}m.current=!0,y(!0);try{await l.mutateAsync({workspaceId:t.branchName,assistant:e.assistant,sessionId:e.id,cwd:e.workspacePath}),s(`Opened ${tC(e.assistant)} inside ContextSpace.`,`success`),r(null)}catch{let t=rC(e.assistant,e.id);await QS(t)?s(`Could not open terminal automatically. Copied command to clipboard:\n\n${t}`,`info`):s(`Could not open terminal automatically. Run manually:\n\n${t}`,`error`)}finally{y(!1),m.current=!1}};return(0,H.jsx)(Ov,{open:!0,onOpenChange:e=>!e&&r(null),children:(0,H.jsxs)(Mv,{className:`h-[80vh] max-w-4xl`,children:[(0,H.jsx)(Nv,{children:(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,H.jsx)(Bv,{tone:nC(e.assistant),children:tC(e.assistant)}),(0,H.jsxs)(`span`,{className:`text-[10px] font-mono bg-muted/60 text-muted-foreground px-1.5 py-0.5 rounded`,children:[`Read-Only Transcript · `,t.length,` turns`,b>0?` · ${b.toLocaleString()} tokens`:``]}),(0,H.jsxs)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:[`ID: `,e.id.slice(0,8)]})]}),(0,H.jsx)(Fv,{className:`max-w-xl truncate text-sm`,title:e.title,children:e.title}),(0,H.jsxs)(Iv,{className:`sr-only`,children:[`Read-only transcript log and resume options for session `,e.id]})]})}),(0,H.jsxs)(Lv,{className:`space-y-4`,children:[n?(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2`,children:[(0,H.jsx)(Rv,{className:`size-6 text-primary`}),(0,H.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Loading conversation history...`})]}):t.length===0?(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center text-xs text-muted-foreground`,children:`No messages found in this transcript.`}):t.map((t,n)=>(0,H.jsxs)(`div`,{className:`flex flex-col ${t.role===`user`?`items-end`:`items-start`}`,children:[(0,H.jsxs)(`div`,{className:`mb-1 px-1 text-[10px] text-muted-foreground`,children:[t.role===`user`?`Developer`:e.assistant===`antigravity`?`Antigravity`:e.assistant===`claude`?`Claude`:e.assistant===`codex`?`Codex`:`Copilot`,t.timestamp&&` • ${new Date(t.timestamp).toLocaleTimeString()}`]}),(0,H.jsxs)(`div`,{className:`max-w-[85%] rounded-xl border px-4 py-3 text-xs leading-relaxed ${t.role===`user`?`rounded-tr-none border-primary/30 bg-primary/10 text-foreground dark:border-primary/40 dark:bg-primary/20`:`rounded-tl-none border-border bg-card text-foreground shadow-xs dark:bg-muted/30`}`,children:[(0,H.jsx)(Dv,{content:t.content}),t.usage&&(0,H.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 border-t border-border/40 pt-1.5 text-[10px] text-muted-foreground font-mono`,children:[(0,H.jsxs)(`span`,{children:[(t.usage.inputTokens??0).toLocaleString(),` in`]}),(0,H.jsx)(`span`,{children:`/`}),(0,H.jsxs)(`span`,{children:[(t.usage.outputTokens??0).toLocaleString(),` out`]}),typeof t.usage.cachedInputTokens==`number`&&t.usage.cachedInputTokens>0&&(0,H.jsxs)(`span`,{children:[`(`,t.usage.cachedInputTokens.toLocaleString(),` cached)`]}),typeof t.usage.costUsdEstimate==`number`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`•`}),(0,H.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[`~$`,t.usage.costUsdEstimate.toFixed(3)]})]})]})]})]},n)),(0,H.jsx)(`div`,{ref:h})]}),(0,H.jsxs)(Pv,{className:`sm:justify-between`,children:[(0,H.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Read-only transcript. Interactive coding happens in your terminal or IDE.`}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsxs)(yn,{variant:`outline`,size:`sm`,onClick:async()=>{let t=rC(e.assistant,e.id);await QS(t),s(`Copied run command to clipboard:\n\n${t}`,`success`)},children:[(0,H.jsx)(Mr,{size:13}),` Copy CLI Command`]}),(0,H.jsxs)(yn,{size:`sm`,variant:`default`,disabled:v,onClick:()=>void C(),children:[v?(0,H.jsx)(Rv,{className:`size-3`}):(0,H.jsx)(xi,{size:12}),`Resume in Terminal`]}),e.assistant===`codex`&&(0,H.jsxs)(yn,{variant:`outline`,size:`sm`,disabled:!d||g,title:d?`Open this exact thread in Codex Desktop`:f,"aria-label":d?`Open in Codex Desktop`:`Codex Desktop unavailable: ${f}`,onClick:()=>void S(),children:[g?(0,H.jsx)(Rv,{className:`size-3`}):(0,H.jsx)(Bn,{size:12}),g?`Opening…`:`Open in Codex Desktop`]})]})]})]})})}function aC({files:e,renderFile:t,label:n,revealPath:r,revealKey:i}){let a=(0,V.useRef)(null),o=(0,V.useMemo)(()=>{let t={directories:new Map,files:[]};for(let n of e){let e=n.file.split(`/`),r=t;for(let t of e.slice(0,-1))r.directories.has(t)||r.directories.set(t,{directories:new Map,files:[]}),r=r.directories.get(t);r.files.push(n)}return t},[e]);(0,V.useEffect)(()=>{if(r)for(let e of a.current?.querySelectorAll(`details[data-path]`)??[])r.startsWith(`${e.dataset.path}/`)&&(e.open=!0)},[r,i]);let s=(e,n=``)=>(0,H.jsxs)(`ul`,{className:`min-w-0 space-y-0.5`,children:[[...e.directories].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`details`,{open:!0,"data-path":n?`${n}/${e}`:e,className:`min-w-0`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer rounded px-2 py-1 text-xs hover:bg-accent focus-visible:outline focus-visible:outline-primary`,children:[(0,H.jsx)(Lr,{className:`mr-1 inline size-3.5`,"aria-hidden":`true`}),e]}),(0,H.jsx)(`div`,{className:`ml-3 border-l border-border pl-2`,children:s(t,n?`${n}/${e}`:e)})]})},`dir:${e}`)),[...e.files].sort((e,t)=>e.file.localeCompare(t.file)).map(e=>(0,H.jsx)(`li`,{children:t(e)},`file:${e.file}`))]});return(0,H.jsx)(`nav`,{ref:a,"aria-label":n,children:s(o)})}var oC=class extends V.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[DiffErrorBoundary] Caught error in diff viewer:`,e,t)}handleReset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?(0,H.jsxs)(`div`,{className:`p-4 rounded-lg border border-destructive/40 bg-destructive/10 text-foreground space-y-3 my-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-xs text-destructive`,children:[(0,H.jsx)(Si,{className:`size-4 shrink-0`}),(0,H.jsxs)(`span`,{children:[`Failed to render diff editor for `,this.props.filePath||`file`]})]}),(0,H.jsx)(`div`,{className:`font-mono text-[11px] text-muted-foreground break-all bg-background/80 p-2 rounded border border-border/60`,children:this.state.error?.message||`Unknown diff rendering error`}),(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsxs)(`button`,{type:`button`,onClick:this.handleReset,className:`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded border border-border bg-card hover:bg-accent text-foreground cursor-pointer transition-colors font-mono`,children:[(0,H.jsx)(li,{className:`size-3`}),(0,H.jsx)(`span`,{children:`Retry Render`})]})}),this.props.fallbackContent&&(0,H.jsxs)(`div`,{className:`mt-3`,children:[(0,H.jsx)(`div`,{className:`text-[10px] uppercase font-mono tracking-wider text-muted-foreground mb-1`,children:`Raw Diff Content`}),(0,H.jsx)(`pre`,{className:`font-mono text-[11px] bg-background/90 text-foreground p-3 rounded border border-border max-h-72 overflow-auto whitespace-pre`,children:this.props.fallbackContent})]})]}):this.props.children}};function sC(e){if(!e||!e.trim())return{originalContent:``,modifiedContent:``,hunks:[],isNewFile:!1,isDeletedFile:!1};let t=e.split(/\r?\n/),n=[],r=[],i=[],a=!1,o=!1,s=null,c=0;for(let e=0;e<t.length;e++){let l=t[e];if(l.startsWith(`--- /dev/null`)){a=!0;continue}if(l.startsWith(`+++ /dev/null`)){o=!0;continue}let u=l.match(/^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@(.*)$/);if(u){s&&n.push(s),c++;let e=parseInt(u[1],10),t=u[2]===void 0?1:parseInt(u[2],10),r=parseInt(u[3],10),i=u[4]===void 0?1:parseInt(u[4],10);s={id:`hunk-${c}`,hunkIndex:c-1,type:`accept`,startLineOriginal:e,lineCountOriginal:t,startLineModified:r,lineCountModified:i,patchHeader:l,enclosingDeclaration:u[5]?.trim()||void 0,lines:[]};continue}if(s){if(s.lines.push(l),l.startsWith(` `)){let e=l.slice(1);r.push(e),i.push(e)}else if(l.startsWith(`-`))r.push(l.slice(1));else if(l.startsWith(`+`))i.push(l.slice(1));else if(l.startsWith(`\\`))continue}}return s&&n.push(s),{originalContent:r.join(`
41
41
  `),modifiedContent:i.join(`
42
- `),hunks:n,isNewFile:a,isDeletedFile:o}}function cC(e,t){let n=1;for(let r of t){let t=r.startLineModified;for(let i of r.lines||[])if(!(i.startsWith(`-`)||i.startsWith(`\\`))){if(t===e)return n;n++,t++}}return null}var lC=({patchText:e,targetLine:t,jumpNonce:n})=>{let r=(0,V.useRef)(null),i=(0,V.useRef)(void 0);(0,V.useEffect)(()=>{!r.current||!t||t<=0||i.current!==n&&(i.current=n,(r.current.querySelector(`[data-mod-line="${t}"]`)||r.current.querySelector(`[data-is-target="true"]`))?.scrollIntoView({behavior:`smooth`,block:`center`}))},[t,n]);let a=(0,V.useMemo)(()=>{if(!e||!e.trim())return[];let n=e.split(/\r?\n/),r=0;return n.map((e,n)=>{let i=``,a=`text-muted-foreground`,o;if(e.startsWith(`@@`)){i=`bg-sky-500/15`,a=`text-sky-400 font-bold italic`;let t=e.match(/\+(\d+)/);t&&t[1]&&(r=parseInt(t[1],10)-1)}else e.startsWith(`+`)&&!e.startsWith(`+++`)?(i=`bg-emerald-500/15`,a=`text-emerald-400 font-semibold`,r++,o=r):e.startsWith(`-`)&&!e.startsWith(`---`)?(i=`bg-rose-500/15`,a=`text-rose-400 font-semibold`):e.startsWith(` `)&&(r++,o=r);return{idx:n,line:e,lineModNum:o,isTarget:t!==void 0&&o===t,bgClass:i,textClass:a}})},[e,t]);return!e||!e.trim()?(0,H.jsx)(`div`,{className:`p-4 font-mono text-xs italic text-muted-foreground`,children:`No diff changes recorded.`}):(0,H.jsx)(`div`,{ref:r,className:`custom-scrollbar h-full min-h-0 overflow-auto rounded-lg border border-border/80 bg-muted/20 font-mono text-xs leading-relaxed select-text`,children:a.map(e=>(0,H.jsxs)(`div`,{"data-mod-line":e.lineModNum,"data-is-target":e.isTarget?`true`:void 0,className:`flex px-3 py-0.5 hover:bg-accent/40 ${e.isTarget?`bg-primary/25 border-l-2 border-primary font-bold`:e.bgClass}`,children:[(0,H.jsx)(`span`,{className:`w-10 select-none text-right pr-3 text-[10px] text-muted-foreground/60`,children:e.lineModNum??e.idx+1}),(0,H.jsx)(`span`,{className:`whitespace-pre flex-1 ${e.textClass}`,children:e.line})]},e.idx))})};function uC(e){switch(e){case`code-insiders`:case`vscode-insiders`:return`VS Code Insiders`;case`cursor`:return`Cursor`;case`windsurf`:return`Windsurf`;case`antigravity`:return`Antigravity`;default:return`VS Code`}}function dC(e){switch(e){case`code-insiders`:case`vscode-insiders`:return`code-insiders`;case`cursor`:return`cursor`;case`windsurf`:return`windsurf`;case`antigravity`:return`antigravity`;default:return`code`}}function fC(e){switch(e){case`code-insiders`:case`vscode-insiders`:return`vscode-insiders`;case`cursor`:return`cursor`;case`windsurf`:return`windsurf`;case`antigravity`:return`antigravity`;default:return`vscode`}}function pC(e,t,n=1,r=1,i){let a=e.replace(/\\/g,`/`).replace(/\/+$/,``),o=t.replace(/\\/g,`/`),s;if(/^[a-zA-Z]:\//.test(o)||o.startsWith(`/`))s=o;else{let e=o.replace(/^\/+/,``);s=a?`${a}/${e}`:e}let c=s.replace(/^\/+/,``);return`${fC(i)}://file/${encodeURI(c)}:${n}:${r}`}async function mC(e,t,n){let r=dC(n),i=uC(n);try{let n=await fetch(`/api/open-editor`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({workspacePath:e,command:r,filePath:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Failed to launch ${i}`)}return!0}catch(e){return console.error(`Failed to launch external diff tool:`,e),!1}}function hC(e,t,n=1,r=1,i){let a=pC(e,t,n,r,i);typeof window<`u`&&window.open&&window.open(a,`_blank`)}function gC(e){if(e?.editor)return e;if(typeof window<`u`&&window.monaco?.editor)return window.monaco}function _C(e){return e.replace(/\\/g,`/`).replace(/^\//,``)}function vC(e){return e.replace(/\\/g,`/`).replace(/^\//,``).replace(/\/$/,``)}function yC(e,t,n){let r=vC(e),i=_C(t),a=`file:///${r}/${i}`,o=gC(n);if(o?.Uri?.parse)return o.Uri.parse(a);let s=`/${r}/${i}`;return{scheme:`file`,authority:``,path:s,query:``,fragment:``,fsPath:s,with:()=>({}),toString:()=>a,toJSON:()=>a}}function bC(e,t,n){let r=vC(e),i=_C(t),a=`diff-original:///${r}/${i}`,o=gC(n);if(o?.Uri?.parse)return o.Uri.parse(a);let s=`/${r}/${i}`;return{scheme:`diff-original`,authority:``,path:s,query:``,fragment:``,fsPath:s,with:()=>({}),toString:()=>a,toJSON:()=>a}}function xC(e,t,n,r){let i=gC(r);if(!i?.editor)return null;try{let r=i.editor.getModel(e);return!r||r.isDisposed()?r=i.editor.createModel(t,n,e):r.getValue()!==t&&r.setValue(t),r}catch(r){console.warn(`[changesetModelStore] Error in getOrCreateTextModel:`,r);try{return i.editor.getModel(e)||i.editor.createModel(t,n)}catch{return null}}}function SC(e,t){let n=gC(t);if(!n?.editor?.registerEditorOpener)return{dispose:()=>{}};try{return n.editor.registerEditorOpener({openCodeEditor(t,n,r){if(!n||n.scheme!==`file`)return!1;let i=n.path.replace(/^\//,``),a=i.indexOf(`/`);if(a===-1)return!1;let o=i.substring(0,a),s=i.substring(a+1),c;return r&&(`lineNumber`in r&&typeof r.lineNumber==`number`?c=r.lineNumber:`startLineNumber`in r&&typeof r.startLineNumber==`number`&&(c=r.startLineNumber)),e(o,s,c),!0}})}catch(e){return console.warn(`[changesetModelStore] Failed to register editor opener:`,e),{dispose:()=>{}}}}var CC={File:0,Module:1,Namespace:2,Package:3,Class:4,Method:5,Property:6,Field:7,Constructor:8,Enum:9,Interface:10,Function:11,Variable:12,Constant:13,String:14,Number:15,Boolean:16,Array:17,Object:18,Key:19,Null:20,EnumMember:21,Struct:22,Event:23,Operator:24,TypeParameter:25};function wC(e){switch(e.split(`.`).pop()?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`mjs`:case`cjs`:return`ts`;case`py`:return`python`;case`go`:return`go`;case`rs`:return`rust`;case`cs`:return`csharp`;default:return`other`}}var TC=[{regex:/^\s*(?:(?:public|private|protected|internal|sealed|abstract|static|partial)\s+)*class\s+([A-Za-z0-9_]+)/,kind:CC.Class,label:`class`},{regex:/^\s*(?:(?:public|private|protected|internal|partial)\s+)*interface\s+([A-Za-z0-9_]+)/,kind:CC.Interface,label:`interface`},{regex:/^\s*(?:(?:public|private|protected|internal|sealed|abstract|static|partial|readonly)\s+)*record(?:\s+(?:class|struct))?\s+([A-Za-z0-9_]+)/,kind:CC.Class,label:`class`},{regex:/^\s*(?:(?:public|private|protected|internal|readonly|ref|partial)\s+)*struct\s+([A-Za-z0-9_]+)/,kind:CC.Struct,label:`class`},{regex:/^\s*(?:(?:public|private|protected|internal)\s+)*enum\s+([A-Za-z0-9_]+)/,kind:CC.Enum,label:`enum`},{regex:/^\s*(?:(?:public|private|protected|internal)\s+)+([A-Z][A-Za-z0-9_]*)\s*\(/,kind:CC.Constructor,label:`constructor`},{regex:/^\s*(?:(?:public|private|protected|internal|static|async|virtual|override|abstract|sealed|new)\s+)+(?:void|[A-Za-z0-9_<>?[\]\s,]+)\s+([A-Za-z0-9_]+)\s*(?:<[^>]+>)?\s*\(/,kind:CC.Method,label:`method`},{regex:/^\s*(?:(?:async|static)\s+)?(?:void|Task(?:<[^>]+>)?|IActionResult|ActionResult(?:<[^>]+>)?)\s+([A-Za-z0-9_]+)\s*(?:<[^>]+>)?\s*\(/,kind:CC.Method,label:`method`},{regex:/^\s*(?:(?:public|private|protected|internal|virtual|override|abstract|required|static)\s+)+[A-Za-z0-9_<>?[\]\s,]+\s+([A-Za-z0-9_]+)\s*\{\s*(?:get|set|init)/,kind:CC.Property,label:`property`},{regex:/^\s*(?:(?:public|private|protected|internal|virtual|override|abstract|static)\s+)+[A-Za-z0-9_<>?[\]\s,]+\s+([A-Za-z0-9_]+)\s*=>/,kind:CC.Property,label:`property`}],EC=[{regex:/^\s*(?:export\s+(?:default\s+)?)?(?:async\s+)?function\s*(?:\*\s*)?([A-Za-z0-9_$]+)/,kind:CC.Function,label:`function`},{regex:/^\s*(?:(?:public|private|protected)\s+)?(constructor)\s*\(/,kind:CC.Constructor,label:`constructor`},{regex:/^\s*(?:(?:public|private|protected|static|abstract|override|async)\s+)+([A-Za-z0-9_$]+)\s*(?:<[^>]+>)?\s*\(/,kind:CC.Method,label:`method`},{regex:/^\s*(?:export\s+)?(?:const|let|var)\s+([A-Za-z0-9_$]+)\s*(?::\s*[^=]+)?\s*=\s*(?:async\s*)?(?:\([^)]*\)|[A-Za-z0-9_$]+|\()(?:\s*:\s*[^=]+)?\s*(?:=>)?/,kind:CC.Function,label:`function`},{regex:/^\s*(?:export\s+)?(?:const|let|var)\s+([A-Za-z0-9_$]+)\s*(?::\s*[^=]+)?\s*=\s*(?:async\s*)?function/,kind:CC.Function,label:`function`},{regex:/^\s*(?:export\s+(?:default\s+)?)?(?:abstract\s+)?class\s+([A-Za-z0-9_$]+)/,kind:CC.Class,label:`class`},{regex:/^\s*(?:export\s+)?interface\s+([A-Za-z0-9_$]+)/,kind:CC.Interface,label:`interface`},{regex:/^\s*(?:export\s+)?type\s+([A-Za-z0-9_$]+)\s*(?:<[^>]*>)?\s*=/,kind:CC.TypeParameter,label:`type`},{regex:/^\s*(?:export\s+)?(?:const\s+)?enum\s+([A-Za-z0-9_$]+)/,kind:CC.Enum,label:`enum`},{regex:/^\s*(?:export\s+)?(?:const|let|var)\s+([A-Za-z0-9_$]+)\s*(?::\s*[^=]+)?\s*=/,kind:CC.Variable,label:`variable`}],DC=[{regex:/^\s*(?:async\s+)?def\s+([A-Za-z0-9_]+)\s*\(/,kind:CC.Function,label:`function`},{regex:/^\s*class\s+([A-Za-z0-9_]+)(?:\s*\([^)]*\))?\s*:/,kind:CC.Class,label:`class`}],OC=[{regex:/^\s*func\s+(?:\([^)]+\)\s+)?([A-Za-z0-9_]+)\s*\(/,kind:CC.Function,label:`function`},{regex:/^\s*type\s+([A-Za-z0-9_]+)\s+(?:struct|interface)/,kind:CC.Class,label:`type`}],kC=[{regex:/^\s*(?:pub(?:\([^)]+\))?\s+)?(?:async\s+)?(?:unsafe\s+)?fn\s+([A-Za-z0-9_]+)/,kind:CC.Function,label:`function`},{regex:/^\s*(?:pub(?:\([^)]+\))?\s+)?struct\s+([A-Za-z0-9_]+)/,kind:CC.Class,label:`class`},{regex:/^\s*(?:pub(?:\([^)]+\))?\s+)?enum\s+([A-Za-z0-9_]+)/,kind:CC.Enum,label:`enum`},{regex:/^\s*(?:pub(?:\([^)]+\))?\s+)?trait\s+([A-Za-z0-9_]+)/,kind:CC.Interface,label:`interface`}],AC=new class{symbols=[];symbolMap=new Map;listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}onIndexUpdated(e){return this.subscribe(e)}notify(){for(let e of this.listeners)try{e()}catch(e){console.error(`Error in changeset symbol index listener:`,e)}}clear(){this.symbols=[],this.symbolMap.clear(),this.notify()}removeFile(e,t){let n=t.replace(/\\/g,`/`).replace(/^\//,``);this.symbols=this.symbols.filter(t=>t.repoName!==e||t.filePath!==n),this.rebuildMap(),this.notify()}indexFile(e,t,n,r=[],i,a){let o=t.replace(/\\/g,`/`).replace(/^\//,``),s=e.replace(/\\/g,`/`).replace(/^\//,``).replace(/\/$/,``),c=`file:///${s}/${o}`,l=this.symbols.filter(t=>t.repoName!==e||t.filePath!==o),u=wC(o),d=EC;u===`python`?d=DC:u===`go`?d=OC:u===`rust`?d=kC:u===`csharp`?d=TC:u===`other`&&(d=[]);let f=[];if(r&&r.length>0)for(let e of r){let t=0;for(let n of e.lines||[]){if(n.startsWith(`-`)||n.startsWith(`\\`))continue;let r=n.startsWith(`+`);f.push({lineNum:e.startLineModified+t,hunk:e,isAdded:r}),t++}}let p=n.split(/\r?\n/),m=f.length>0&&p.length===f.length,h=[];if(a&&a.length>0)for(let t of a){let n=t.lineNumber,a,l=!1,u=t.lineNumber,d=t.endLineNumber||t.lineNumber;if(m){let e=f.find(e=>e.lineNum>=u&&e.lineNum<=d);e?(n=e.lineNum,a=e.hunk,l=e.isAdded):a=r.find(e=>{let t=e.startLineModified,n=e.startLineModified+Math.max(e.lineCountModified,1)-1;return t<=d&&n>=u})}else a=r.find(e=>{let t=e.startLineModified,n=e.startLineModified+Math.max(e.lineCountModified,1)-1;return t<=d&&n>=u});let p=`context`;if(a){if(m)p=l?`added`:`modified`;else{p=`modified`;let e=a.startLineModified,n=e+Math.max(a.lineCountModified,1)-1;(t.lineNumber>=e&&t.lineNumber<=n&&a.lines&&a.lines.some(e=>e.startsWith(`+`)&&e.includes(t.name))||a.lines&&a.lines.length>0&&a.lines.every(e=>!e.startsWith(`-`)&&!e.startsWith(` `)))&&(p=`added`)}}let g={id:`${s}:${o}:${n}:${t.name}`,name:t.name,kind:t.kind,kindLabel:t.kindLabel,repoName:e,repoPath:i||(s.includes(`/`)||s.includes(`\\`)?s:void 0),filePath:o,uriString:c,lineNumber:n,endLineNumber:t.endLineNumber,column:t.column||1,containerName:t.containerName,isModifiedInChangeset:!!a,changeType:a?p:`context`,hunkIndex:a?.hunkIndex,hunkId:a?.id};h.push(g)}else if(p.forEach((t,n)=>{let a,l,u=!1;if(m){let e=f[n];a=e.lineNum,l=e.hunk,u=e.isAdded}else a=n+1,l=r.find(e=>{let t=e.startLineModified,n=e.startLineModified+Math.max(e.lineCountModified,1)-1;return a>=t&&a<=n});for(let n of d){let r=t.match(n.regex);if(r&&r[1]){let d=r[1],f=t.indexOf(d)+1,p=`context`;l&&(m?p=u?`added`:`modified`:(p=`modified`,l.lines&&l.lines.some(e=>e.startsWith(`+`)&&e.includes(d))&&(p=`added`)));let g={id:`${s}:${o}:${a}:${d}`,name:d,kind:n.kind,kindLabel:n.label,repoName:e,repoPath:i||(s.includes(`/`)||s.includes(`\\`)?s:void 0),filePath:o,uriString:c,lineNumber:a,column:f>0?f:1,isModifiedInChangeset:!!l,changeType:l?p:`context`,hunkIndex:l?.hunkIndex,hunkId:l?.id};h.push(g);break}}}),r&&r.length>0){for(let t of r)if(t.enclosingDeclaration)for(let n of d){let r=t.enclosingDeclaration.match(n.regex);if(r&&r[1]){let a=r[1];h.some(e=>e.name===a)||h.push({id:`${s}:${o}:${t.startLineModified}:${a}`,name:a,kind:n.kind,kindLabel:n.label,repoName:e,repoPath:i||(s.includes(`/`)||s.includes(`\\`)?s:void 0),filePath:o,uriString:c,lineNumber:t.startLineModified,column:1,isModifiedInChangeset:!0,changeType:`modified`,hunkIndex:t.hunkIndex,hunkId:t.id});break}}}if(r&&r.length>0){for(let e of r)if(e.enclosingDeclaration)for(let t of h)e.enclosingDeclaration.includes(t.name)&&!t.isModifiedInChangeset&&(t.isModifiedInChangeset=!0,t.changeType=`modified`,t.hunkIndex=e.hunkIndex,t.hunkId=e.id)}return this.symbols=[...l,...h],this.rebuildMap(),this.notify(),h}rebuildMap(){this.symbolMap.clear();for(let e of this.symbols){let t=this.symbolMap.get(e.name)||[];t.push(e),this.symbolMap.set(e.name,t)}}getAllSymbols(){return this.symbols}getModifiedSymbols(){return this.symbols.filter(e=>e.isModifiedInChangeset)}findDefinitions(e){return this.symbolMap.get(e)||[]}findSymbolsInFile(e){let t=e.replace(/\\/g,`/`).replace(/^\//,``);return this.symbols.filter(e=>e.filePath===t)}};function jC(e=AC){return(0,V.useSyncExternalStore)(t=>e.subscribe(t),()=>e.getAllSymbols(),()=>[])}function MC(e,t){let n=[];for(let r of e){if(r.uri.scheme!==`file`)continue;let e=r.findMatches(t,!0,!1,!0,` \`~!@#%^&*()-=+[{]}\\|;:'",.<>/?`,!1);for(let t of e)n.push({uri:r.uri,range:t.range})}return n}var NC=!1;function PC(e){let t=e||(typeof window<`u`?window.monaco:void 0);if(!t||NC)return{dispose:()=>{}};let n=[`typescript`,`javascript`,`python`,`rust`,`go`,`csharp`],r=[];for(let e of n)r.push(t.languages.registerDefinitionProvider(e,{provideDefinition(e,n){let r=e.getWordAtPosition(n);if(!r)return null;let i=r.word,a=AC.findDefinitions(i);return a.length===0?null:a.map(e=>({uri:yC(e.repoName,e.filePath,t),range:{startLineNumber:e.lineNumber,startColumn:e.column,endLineNumber:e.lineNumber,endColumn:e.column+e.name.length}}))}})),r.push(t.languages.registerReferenceProvider(e,{provideReferences(e,n){let r=e.getWordAtPosition(n);return r?MC(t.editor.getModels(),r.word):null}})),r.push(t.languages.registerDocumentSymbolProvider(e,{provideDocumentSymbols(e){let t=e.uri.toString();return AC.getAllSymbols().filter(e=>e.uriString===t).map(e=>({name:e.name,detail:e.kindLabel,kind:e.kind,tags:[],range:{startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column+e.name.length},selectionRange:{startLineNumber:e.lineNumber,startColumn:e.column,endLineNumber:e.lineNumber,endColumn:e.column+e.name.length}}))}}));return NC=!0,{dispose(){r.forEach(e=>e.dispose()),NC=!1}}}var FC=[{id:`all`,label:`All`,short:`All`},{id:`modified`,label:`Modified Only`,short:`Mod`},{id:`function`,label:`Functions`,short:`fn`},{id:`method`,label:`Methods`,short:`meth`},{id:`constructor`,label:`Constructors`,short:`ctor`},{id:`class`,label:`Classes`,short:`cls`},{id:`interface`,label:`Interfaces`,short:`iface`},{id:`type`,label:`Types`,short:`type`},{id:`enum`,label:`Enums`,short:`enum`},{id:`property`,label:`Properties`,short:`prop`},{id:`variable`,label:`Variables`,short:`var`}],IC=e=>e.kind===CC.Constructor||e.kindLabel===`constructor`?`constructor`:e.kind===CC.Method||e.kindLabel===`method`?`method`:e.kind===CC.Property||e.kindLabel===`property`?`property`:e.kindLabel,LC=e=>{let t=IC(e);switch(t){case`constructor`:return`[CTOR]`;case`method`:return`[METH]`;case`function`:return`[FUNC]`;case`class`:return`[CLAS]`;case`interface`:return`[IFAC]`;case`type`:return`[TYPE]`;case`enum`:return`[ENUM]`;case`property`:return`[PROP]`;case`variable`:return`[VAR]`;default:return`[${String(t).slice(0,4).toUpperCase()}]`}},RC=e=>{switch(IC(e)){case`constructor`:return`border-orange-500/40 bg-orange-500/15 text-orange-400`;case`method`:return`border-cyan-500/40 bg-cyan-500/15 text-cyan-400`;case`function`:return`border-emerald-500/40 bg-emerald-500/15 text-emerald-400`;case`class`:return`border-purple-500/40 bg-purple-500/15 text-purple-400`;case`interface`:return`border-sky-500/40 bg-sky-500/15 text-sky-400`;case`type`:return`border-amber-500/40 bg-amber-500/15 text-amber-400`;case`enum`:return`border-pink-500/40 bg-pink-500/15 text-pink-400`;case`property`:return`border-teal-500/40 bg-teal-500/15 text-teal-400`;case`variable`:return`border-slate-500/40 bg-slate-500/15 text-slate-400`;default:return`border-border bg-muted text-muted-foreground`}},zC=({symbols:e,activeFilePath:t,activeLine:n,editorLabel:r=`VS Code`,onSelectSymbol:i,onOpenInVsCode:a,onClose:o,className:s})=>{let[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(`all`),f=(0,V.useMemo)(()=>{let t=e;if(u===`modified`?t=t.filter(e=>e.isModifiedInChangeset):u!==`all`&&(t=t.filter(e=>IC(e)===u)),c.trim()){let e=c.toLowerCase();t=t.filter(t=>t.name.toLowerCase().includes(e)||t.filePath.toLowerCase().includes(e)||t.kindLabel.toLowerCase().includes(e)||IC(t).toLowerCase().includes(e))}return t.sort((e,t)=>e.isModifiedInChangeset===t.isModifiedInChangeset?e.filePath===t.filePath?e.lineNumber-t.lineNumber:e.filePath.localeCompare(t.filePath):e.isModifiedInChangeset?-1:1)},[e,u,c]),p=(0,V.useMemo)(()=>{let t={all:e.length,modified:e.filter(e=>e.isModifiedInChangeset).length};for(let n of e){let e=IC(n);t[e]=(t[e]||0)+1}return t},[e]);return(0,H.jsxs)(`div`,{className:B(`flex flex-col rounded-xl border border-border/90 bg-card/95 backdrop-blur-md shadow-lg overflow-hidden text-xs`,s),children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2.5 border-b border-border/70 bg-muted/25`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,H.jsx)(Ar,{size:14,className:`text-primary shrink-0`}),(0,H.jsx)(`span`,{className:`font-mono text-xs font-bold text-foreground`,children:`Changeset Symbols`}),(0,H.jsxs)(`span`,{className:`rounded-full bg-primary/10 border border-primary/20 px-1.5 py-0.2 font-mono text-[10px] text-primary font-semibold`,children:[f.length,` / `,e.length]})]}),o&&(0,H.jsx)(`button`,{type:`button`,onClick:o,className:`p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors cursor-pointer`,title:`Close Symbol Navigator`,children:(0,H.jsx)(Ei,{size:13})})]}),(0,H.jsxs)(`div`,{className:`p-2 space-y-2 border-b border-border/60 bg-background/50`,children:[(0,H.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,H.jsx)(Ct,{size:13,className:`absolute left-2.5 text-muted-foreground pointer-events-none`}),(0,H.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`Search functions, classes, types, files...`,className:`w-full rounded-lg border border-border bg-background/90 pl-8 pr-7 py-1.5 font-mono text-xs text-foreground placeholder:text-muted-foreground focus:outline-hidden focus:ring-1 focus:ring-primary`}),c&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>l(``),className:`absolute right-2 text-muted-foreground hover:text-foreground`,children:(0,H.jsx)(Ei,{size:12})})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 overflow-x-auto pb-0.5 scrollbar-none select-none`,children:[(0,H.jsx)(Rr,{size:11,className:`text-muted-foreground shrink-0 ml-0.5 mr-0.5`}),FC.map(e=>{let t=p[e.id]||0,n=u===e.id;return e.id!==`all`&&e.id!==`modified`&&t===0?null:(0,H.jsxs)(`button`,{type:`button`,onClick:()=>d(e.id),className:B(`inline-flex items-center gap-1 px-2 py-0.5 rounded-md font-mono text-[10px] transition-colors cursor-pointer shrink-0 border`,n?`border-primary/50 bg-primary/15 text-primary font-bold`:`border-border/60 bg-card hover:bg-accent text-muted-foreground hover:text-foreground`),children:[(0,H.jsx)(`span`,{children:e.label}),(0,H.jsxs)(`span`,{className:`text-[9px] opacity-70`,children:[`(`,t,`)`]})]},e.id)})]})]}),(0,H.jsx)(`div`,{className:`max-h-64 overflow-y-auto divide-y divide-border/40 scrollbar-thin`,children:e.length===0?(0,H.jsxs)(`div`,{className:`py-8 px-4 text-center text-muted-foreground`,children:[(0,H.jsx)(`p`,{className:`font-mono text-xs font-semibold text-foreground`,children:`No code symbols detected in this changeset`}),(0,H.jsx)(`p`,{className:`text-[11px] mt-1.5 max-w-sm mx-auto text-muted-foreground/80 leading-relaxed`,children:`Symbols (functions, classes, interfaces, types, enums, variables) are automatically extracted from modified code files in supported languages (TypeScript, JavaScript, Python, Go, Rust).`})]}):f.length===0?(0,H.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,H.jsxs)(`p`,{className:`font-mono text-xs`,children:[`No symbols match "`,c||u,`"`]}),(0,H.jsx)(`p`,{className:`text-[10px] mt-1 text-muted-foreground/70`,children:`Try searching by name or selecting "All"`})]}):f.map(e=>{let o=t&&e.filePath.endsWith(t)&&n===e.lineNumber;return(0,H.jsxs)(`div`,{onClick:()=>i(e),className:B(`group flex items-center justify-between gap-2 px-3 py-2 cursor-pointer transition-colors`,o?`bg-primary/15 border-l-2 border-l-primary`:`hover:bg-accent/50`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,H.jsx)(`span`,{className:B(`px-1.5 py-0.2 rounded font-mono text-[9px] font-bold border uppercase shrink-0`,RC(e)),children:LC(e)}),(0,H.jsx)(`span`,{className:`font-mono text-xs font-bold text-foreground truncate group-hover:text-primary transition-colors`,children:e.name}),e.isModifiedInChangeset&&(0,H.jsx)(`span`,{className:B(`px-1 py-0.2 rounded font-mono text-[9px] font-bold border shrink-0`,e.changeType===`added`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-400`:`border-amber-500/30 bg-amber-500/10 text-amber-400`),title:e.changeType===`added`?`Added in this changeset`:`Modified in this changeset`,children:e.changeType===`added`?`+add`:`~mod`})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:`truncate max-w-[150px] text-muted-foreground/80`,title:e.filePath,children:e.filePath.split(`/`).pop()}),(0,H.jsxs)(`span`,{className:`text-foreground/70`,children:[`:`,e.lineNumber]}),e.hunkIndex!==void 0&&(0,H.jsxs)(`span`,{className:`bg-muted px-1 rounded text-[9px] border border-border/40`,children:[`H#`,e.hunkIndex+1]}),o&&(0,H.jsx)(Or,{size:12,className:`text-primary shrink-0`}),a&&(0,H.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(e)},className:`p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent opacity-0 group-hover:opacity-100 transition-opacity`,title:`Open symbol definition in desktop ${r}`,children:(0,H.jsx)(Bn,{size:11})})]})]},e.id)})})]})},BC=(0,V.lazy)(()=>Kn(()=>import(`./MonacoDiffAdapter-ClvAYSFE.js`).then(e=>({default:e.MonacoDiffAdapter})),__vite__mapDeps([0,1,2,3,4]))),VC=({filePath:e,repoName:t,repoPath:n=``,patchText:r,fullFileContent:i,fullOriginalContent:a,defaultEditor:o,viewMode:s,initialTargetLine:c,changesetSymbols:l,preExtractedSymbols:u,onToggleViewMode:d,showToast:f,onHunkAction:p,onRequestRefine:m,onOpenFile:h,onSelectSymbol:g,onNextFile:_,onPrevFile:v,fillContainer:y=!1})=>{let[b,x]=(0,V.useState)(`side-by-side`),S=s??b,[C,w]=(0,V.useState)(!1),[T,E]=(0,V.useState)(`monaco`),[D,ee]=(0,V.useState)(0),[O,k]=(0,V.useState)({}),[A,te]=(0,V.useState)(!1),[j,M]=(0,V.useState)(``),[N,ne]=(0,V.useState)(!1),[re,ie]=(0,V.useState)(c),[P,F]=(0,V.useState)(0),I=uC(o),L=(0,V.useMemo)(()=>sC(r),[r]),ae=L.hunks,R=ae[D]||null,[oe,z]=(0,V.useState)([]);(0,V.useEffect)(()=>{let r=i||L.modifiedContent;z(AC.indexFile(t,e,r,ae,n,u))},[t,e,i,L.modifiedContent,ae,n,u]);let se=(0,V.useRef)(``);(0,V.useEffect)(()=>{if(c&&c>0){let t=`${e}:${c}`;if(se.current===t)return;se.current=t;let n=c;if(!i){let e=cC(c,ae);e!==null&&(n=e)}ie(n),F(e=>e+1);let r=ae.findIndex(e=>c>=e.startLineModified&&c<=e.startLineModified+Math.max(e.lineCountModified,1)-1);r!==-1&&ee(r)}},[c,e,ae,i]);let ce=()=>{d?d():x(e=>e===`side-by-side`?`unified`:`side-by-side`)},le=(0,V.useRef)(null),ue=(0,V.useCallback)(e=>{e>=0&&e<ae.length&&ae[e]&&(ee(e),ie(Math.max(1,ae[e].startLineModified)),F(e=>e+1))},[ae]),de=(0,V.useCallback)(()=>{D<ae.length-1?ue(D+1):_&&_()},[D,ae.length,ue,_]),fe=(0,V.useCallback)(()=>{D>0?ue(D-1):v&&v()},[D,ue,v]),pe=(0,V.useCallback)(async()=>{!R||!p||(await p({...R,type:`accept`}),k(e=>({...e,[R.id]:`accepted`})),f?.(`Accepted hunk #${D+1}`,`success`),de())},[R,D,f,p,de]),me=(0,V.useCallback)(async()=>{!R||!p||(await p({...R,type:`reject`}),k(e=>({...e,[R.id]:`rejected`})),f?.(`Rejected hunk #${D+1}`,`info`),de())},[R,D,f,p,de]),he=()=>{M(``),te(!0)},ge=async()=>{if(!(!R||!j.trim()||!m))try{await m({...R,type:`refine`},j.trim()),te(!1)}catch(e){f?.(e instanceof Error?e.message:`Could not open refinement in chat.`,`error`)}},_e=t=>{let r=e.replace(/\\/g,`/`).replace(/^\//,``);if(t.filePath===r){let r=t.lineNumber;if(!i){let i=cC(t.lineNumber,ae);if(i!==null)r=i;else{f?.(`"${t.name}" is outside diff hunks (line ${t.lineNumber})`,`info`),hC(n,e,t.lineNumber,t.column,o);return}}ie(r),F(e=>e+1);let a=ae.findIndex(e=>t.lineNumber>=e.startLineModified&&t.lineNumber<=e.startLineModified+Math.max(e.lineCountModified,1)-1);a!==-1&&ee(a)}else g?.(t),h?.(t.repoName,t.filePath,t.lineNumber)},ve=(0,V.useCallback)(e=>{let t=ae.findIndex(t=>e>=t.startLineModified&&e<=t.startLineModified+Math.max(t.lineCountModified,1)-1);t!==-1&&t!==D&&ee(t)},[ae,D]);(0,V.useEffect)(()=>{le.current&&le.current.querySelector(`[data-active-tab="true"]`)?.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`})},[D]),(0,V.useEffect)(()=>{let e=e=>{let t=e.target;t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable||(e.key===`j`||e.key===`n`?de():e.key===`k`||e.key===`p`?fe():e.key===`a`?pe():e.key===`r`&&me())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[de,fe,pe,me]);let ye=l&&l.length>0?l:oe;return(0,H.jsxs)(`div`,{className:B(`flex flex-col overflow-hidden`,y?`h-full w-full min-h-0 bg-background border-0 rounded-none shadow-none my-0`:`rounded-xl border border-border/80 bg-card/60 backdrop-blur-md shadow-sm my-2`),children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-3 py-2 border-b border-border/60 bg-muted/20 text-xs shrink-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,H.jsx)(Ir,{size:13,className:`text-primary shrink-0`}),(0,H.jsx)(`span`,{className:`font-mono text-xs font-semibold text-foreground truncate`,title:e,children:e}),(0,H.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground bg-muted px-1.5 py-0.2 rounded border border-border/40`,children:t}),ae.length>0&&(0,H.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground/80`,children:[ae.length,` `,ae.length===1?`hunk`:`hunks`]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>ne(e=>!e),className:B(`inline-flex items-center gap-1 font-mono text-[11px] px-2 py-1 rounded border transition-colors cursor-pointer`,N?`border-primary/50 bg-primary/15 text-primary font-semibold`:`border-border bg-card/60 hover:bg-accent text-muted-foreground hover:text-foreground`),title:`Toggle Changeset Symbol Navigator`,children:[(0,H.jsx)(Gr,{size:12}),(0,H.jsx)(`span`,{children:`Symbols`}),ye.length>0&&(0,H.jsxs)(`span`,{className:`text-[10px] opacity-75`,children:[`(`,ye.length,`)`]})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:ce,className:`inline-flex items-center gap-1 font-mono text-[11px] px-2 py-1 rounded border border-border bg-card/60 hover:bg-accent text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Toggle between Side-by-Side and Unified Diff view`,children:[(0,H.jsx)(jr,{size:12}),(0,H.jsx)(`span`,{children:S===`side-by-side`?`Split`:`Unified`})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>w(e=>!e),className:B(`font-mono text-[11px] px-2 py-1 rounded border transition-colors cursor-pointer`,C?`border-primary/40 bg-primary/10 text-primary font-semibold`:`border-border bg-card/60 text-muted-foreground hover:bg-accent hover:text-foreground`),title:`Ignore whitespace changes in diff comparison`,children:[`Trim WS: `,C?`ON`:`OFF`]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>E(e=>e===`monaco`?`fallback`:`monaco`),className:`inline-flex items-center gap-1 font-mono text-[11px] px-2 py-1 rounded border border-border bg-card/60 hover:bg-accent text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Toggle between Monaco Diff Editor and Lightweight Fallback`,children:[(0,H.jsx)(Ar,{size:12}),(0,H.jsx)(`span`,{children:T===`monaco`?`Monaco`:`Fallback`})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:async()=>{await mC(n,e,o)?f?.(`Opened ${e} in ${I} diff`,`success`):(hC(n,e,1,1,o),f?.(`Opened ${e} in ${I}`,`info`))},className:`inline-flex items-center gap-1 font-mono text-[11px] px-2 py-1 rounded border border-border bg-card/60 hover:bg-accent text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Open file in desktop ${I} Diff`,children:[(0,H.jsx)(Bn,{size:12}),(0,H.jsx)(`span`,{className:`hidden sm:inline`,children:I})]})]})]}),ae.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-1.5 px-3 py-1.5 border-b border-border/60 bg-muted/15 text-xs select-none`,children:[(0,H.jsxs)(`div`,{ref:le,role:`tablist`,"aria-label":`Change sections`,className:`flex items-center gap-1 min-w-[130px] flex-1 overflow-x-auto py-0.5`,children:[(0,H.jsxs)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mr-1 shrink-0`,children:[`Changes (`,ae.length,`):`]}),ae.map((e,t)=>{let n=e.lines?e.lines.filter(e=>e.startsWith(`+`)&&!e.startsWith(`+++`)).length:0,r=e.lines?e.lines.filter(e=>e.startsWith(`-`)&&!e.startsWith(`---`)).length:0,i=t===D;return(0,H.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":i,"data-active-tab":i?`true`:void 0,onClick:()=>ue(t),className:B(`px-2 py-0.5 rounded text-[11px] font-mono transition-colors cursor-pointer border whitespace-nowrap shrink-0`,i?`bg-primary text-primary-foreground border-primary font-semibold shadow-xs`:`bg-card/70 text-muted-foreground hover:text-foreground hover:bg-accent border-border/60`),title:`Jump to change section #${t+1}: line ${e.startLineModified}${e.enclosingDeclaration?` (${e.enclosingDeclaration})`:``}`,children:[(0,H.jsxs)(`span`,{children:[`Section `,t+1]}),(n>0||r>0)&&(0,H.jsxs)(`span`,{className:`ml-1 text-[9px] opacity-80`,children:[n>0&&(0,H.jsxs)(`span`,{className:`text-emerald-300`,children:[`+`,n]}),r>0&&(0,H.jsxs)(`span`,{className:`text-rose-300`,children:[`-`,r]})]})]},e.id)})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 ml-auto`,children:[(0,H.jsxs)(`button`,{type:`button`,disabled:D<=0&&!v,onClick:fe,className:`inline-flex items-center gap-0.5 px-2 py-0.5 rounded text-[11px] font-mono border border-border bg-card/60 hover:bg-accent disabled:opacity-35 transition-colors cursor-pointer`,title:D<=0&&v?`Previous file`:`Previous change section (k / p)`,"aria-label":D<=0&&v?`Previous file`:`Previous section`,children:[(0,H.jsx)(Tr,{size:12}),(0,H.jsx)(`span`,{children:D<=0&&v?`Prev File`:`Prev`})]}),(0,H.jsxs)(`button`,{type:`button`,disabled:D>=ae.length-1&&!_,onClick:de,className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded text-[11px] font-mono font-medium border border-primary/50 bg-primary/15 text-primary hover:bg-primary/25 disabled:opacity-35 transition-colors cursor-pointer shadow-2xs`,title:D>=ae.length-1&&_?`Next file`:`Next change section (j / n)`,"aria-label":D>=ae.length-1&&_?`Next file`:`Next section`,children:[(0,H.jsx)(`span`,{children:D>=ae.length-1&&_?`Next File`:`Next Section`}),(0,H.jsx)(Er,{size:12})]})]})]}),N&&(0,H.jsx)(`div`,{className:`p-3 border-b border-border/70 bg-muted/20 shrink-0`,children:(0,H.jsx)(zC,{symbols:ye,activeFilePath:e,activeLine:re||(R?R.startLineModified:void 0),editorLabel:I,onSelectSymbol:_e,onOpenInVsCode:e=>{hC(n,e.filePath,e.lineNumber,e.column,o),f?.(`Opened ${e.filePath}:${e.lineNumber} in ${I}`,`success`)},onClose:()=>ne(!1)})}),(0,H.jsx)(`div`,{className:B(`bg-background/50`,y?`flex-1 min-h-0 p-1 flex flex-col`:`p-2`),children:T===`monaco`?(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`div`,{role:`status`,className:`p-4 text-xs text-muted-foreground`,children:`Loading diff editor…`}),children:(0,H.jsx)(BC,{filePath:e,repoName:t,repoPath:n,originalContent:a||L.originalContent,modifiedContent:i||L.modifiedContent,patchText:r,viewMode:S,ignoreWhitespace:C,height:y?`100%`:460,targetLine:re,jumpNonce:P,onOpenFile:h,onLineSelect:ve})}):(0,H.jsx)(lC,{filePath:e,repoPath:n,originalContent:a||L.originalContent,modifiedContent:i||L.modifiedContent,patchText:r,viewMode:S,ignoreWhitespace:C,targetLine:re,jumpNonce:P})}),ae.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-3 py-2 border-t border-border/60 bg-muted/15 text-xs select-none`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 font-mono text-[11px]`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:D<=0,onClick:fe,className:`p-1 rounded border border-border bg-card/60 hover:bg-accent disabled:opacity-35 transition-colors cursor-pointer`,title:`Previous hunk (Shortcut: k)`,children:(0,H.jsx)(Tr,{size:13})}),(0,H.jsxs)(`span`,{className:`px-1.5 text-muted-foreground`,children:[`Hunk `,(0,H.jsx)(`strong`,{className:`text-foreground`,children:D+1}),` of `,ae.length,R&&(0,H.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/70 ml-1`,children:[`(Orig L`,R.startLineOriginal,` → Mod L`,R.startLineModified,`)`]})]}),(0,H.jsx)(`button`,{type:`button`,disabled:D>=ae.length-1,onClick:de,className:`p-1 rounded border border-border bg-card/60 hover:bg-accent disabled:opacity-35 transition-colors cursor-pointer`,title:`Next hunk (Shortcut: j)`,children:(0,H.jsx)(Er,{size:13})}),R&&O[R.id]&&(0,H.jsx)(`span`,{className:B(`font-mono text-[9px] px-1.5 py-0.5 rounded font-bold uppercase ml-1 border`,O[R.id]===`accepted`?`border-emerald-500/30 bg-emerald-500/15 text-emerald-400`:O[R.id]===`rejected`?`border-rose-500/30 bg-rose-500/15 text-rose-400`:`border-amber-500/30 bg-amber-500/15 text-amber-400`),children:O[R.id]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[R&&(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{hC(n,e,R.startLineModified,1,o),f?.(`Opened ${e}:${R.startLineModified} in ${I}`,`success`)},className:`inline-flex items-center gap-1 font-mono text-[10px] px-2 py-1 rounded border border-border bg-card/60 hover:bg-accent text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Open in desktop ${I} at modified line ${R.startLineModified}`,children:[(0,H.jsx)(Bn,{size:11}),(0,H.jsxs)(`span`,{children:[I,` :L`,R.startLineModified]})]}),p&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>void pe(),className:`inline-flex items-center gap-1 px-2.5 py-1 rounded text-xs font-semibold bg-emerald-500/15 hover:bg-emerald-500/25 text-emerald-400 border border-emerald-500/30 transition-colors cursor-pointer shadow-2xs`,title:`Accept this hunk (Shortcut: a)`,children:[(0,H.jsx)(wr,{size:12}),(0,H.jsx)(`span`,{children:`Accept (a)`})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>void me(),className:`inline-flex items-center gap-1 px-2.5 py-1 rounded text-xs font-semibold bg-rose-500/15 hover:bg-rose-500/25 text-rose-400 border border-rose-500/30 transition-colors cursor-pointer shadow-2xs`,title:`Reject this hunk (Shortcut: r)`,children:[(0,H.jsx)(Ei,{size:12}),(0,H.jsx)(`span`,{children:`Reject (r)`})]})]}),m&&(0,H.jsxs)(`button`,{type:`button`,onClick:he,className:`inline-flex items-center gap-1 px-2.5 py-1 rounded text-xs font-semibold bg-amber-500/15 hover:bg-amber-500/25 text-amber-400 border border-amber-500/30 transition-colors cursor-pointer shadow-2xs`,title:`Prepare refinement instructions in AI chat`,children:[(0,H.jsx)(li,{size:11}),(0,H.jsx)(`span`,{children:`Refine`})]})]})]}),A&&(0,H.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-xs p-4 animate-in fade-in`,children:(0,H.jsxs)(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-card p-4 shadow-2xl space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Xr,{size:16,className:`text-primary`}),(0,H.jsxs)(`h3`,{className:`text-xs font-bold text-foreground`,children:[`Request Refinement for Hunk #`,D+1]})]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>te(!1),className:`p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent`,children:(0,H.jsx)(Ei,{size:14})})]}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Add instructions for this hunk. They will open as a draft in AI chat for you to send:`}),(0,H.jsx)(`textarea`,{value:j,onChange:e=>M(e.target.value),placeholder:`e.g. Ensure null safety when calculating vacation debt...`,rows:3,autoFocus:!0,className:`w-full rounded-lg border border-border bg-background px-3 py-1.5 text-xs text-foreground placeholder:text-muted-foreground focus:outline-hidden focus:ring-1 focus:ring-primary resize-none`}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t border-border/60`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>te(!1),className:`px-3 py-1 text-xs text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg`,children:`Cancel`}),(0,H.jsx)(`button`,{type:`button`,disabled:!j.trim(),onClick:()=>void ge(),className:`px-3 py-1 text-xs font-semibold text-primary-foreground bg-primary hover:bg-primary/90 disabled:opacity-50 rounded-lg transition-colors`,children:`Open in AI chat`})]})]})})]})};function HC(e,t){let n=e.replaceAll(`\\`,`/`).replace(/^\.\//,``),r=n.startsWith(`/`)||/^[a-z]:\//i.test(n),i=/^[a-z]:\//i.test(n)||n.startsWith(`//`),a=[];for(let e of t)for(let t of e.files){let o=t.file.replaceAll(`\\`,`/`),s=`${e.repoName}/${o}`,c=`${e.repoPath.replaceAll(`\\`,`/`).replace(/\/$/,``)}/${o}`;(r?i?c.toLowerCase()===n.toLowerCase():c===n:n===o||n===s||o.endsWith(`/${n}`))&&a.push({repoName:e.repoName,repoPath:e.repoPath,file:t.file})}return a.length===1?{file:a[0]}:{error:a.length?`“${e}” matches more than one workspace file. Select it from the Files tree.`:`“${e}” is not in this workspace's file tree.`}}function UC({workspace:e,active:t,openReference:n,onClose:r}){let[i,a]=(0,V.useState)(`changes`),[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(``),[m,h]=(0,V.useState)(``),[g,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(0),[S,C]=(0,V.useState)(!1),w=(0,V.useRef)(0),T=(0,V.useRef)(null),E=(0,V.useRef)(``),D=`/api/workspace/${encodeURIComponent(e)}`;(0,V.useEffect)(()=>{n&&n.id!==w.current&&a(`files`)},[n]),(0,V.useEffect)(()=>{if(!t)return;let e=window.setInterval(()=>x(e=>e+1),1e4);return()=>window.clearInterval(e)},[t]),(0,V.useEffect)(()=>{if(!t)return;let e=!1;return y(!0),p(``),sr(`${D}/changes${i===`files`?`?include=all`:``}`).then(t=>{if(!e){if(s(e=>JSON.stringify(e)===JSON.stringify(t.changes)?e:t.changes),i===`files`&&n&&n.id!==w.current){w.current=n.id;let e=HC(n.path,t.changes);_(e.error??``),d(null),E.current=``,l(e.file?{...e.file,line:n.line}:null)}else l(e=>e&&t.changes.some(t=>t.repoName===e.repoName&&t.files.some(t=>t.file===e.file))?e:null)}}).catch(t=>{e||p(t.message)}).finally(()=>{e||y(!1)}),()=>{e=!0}},[D,i,b,t,n]),(0,V.useEffect)(()=>{if(!t||!c){d(null);return}let e=!1;h(``);let n=new URLSearchParams({repo:c.repoName,file:c.file});return sr(`${D}/changes/diff?${n}`).then(t=>{e||d(e=>e&&e.diff===t.diff&&e.fileContent===t.fileContent&&e.originalContent===t.originalContent?e:t)}).catch(t=>{e||h(t.message)}),()=>{e=!0}},[D,c,b,t]),(0,V.useEffect)(()=>{if(!c?.line||!u||u.diff||!T.current)return;let e=`${c.repoName}/${c.file}:${c.line}`;if(E.current===e)return;E.current=e;let t=Number.parseFloat(getComputedStyle(T.current).lineHeight)||16;T.current.parentElement?.scrollTo({top:Math.max(0,(c.line-1)*t-32)})},[c,u]);let ee=(0,V.useMemo)(()=>o.flatMap(e=>e.files.map(t=>({repoName:e.repoName,repoPath:e.repoPath,file:t.file}))),[o]),O=(0,V.useMemo)(()=>c?ee.findIndex(e=>e.repoName===c.repoName&&e.file===c.file):-1,[ee,c]),k=(0,V.useCallback)(()=>{if(O>=0&&O<ee.length-1){let e=ee[O+1];e&&(_(``),d(null),E.current=``,l(e))}},[O,ee]),A=(0,V.useCallback)(()=>{if(O>0){let e=ee[O-1];e&&(_(``),d(null),E.current=``,l(e))}},[O,ee]);return(0,H.jsxs)(`section`,{"aria-label":`Workspace code`,className:`flex h-full min-h-0 min-w-0 flex-col bg-background overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border p-2 bg-muted/20 shrink-0`,children:[(0,H.jsx)(`span`,{className:`mr-1 text-[11px] font-semibold text-foreground shrink-0`,children:`ContextSpace code`}),(0,H.jsx)(yn,{size:`xs`,variant:i===`changes`?`secondary`:`ghost`,"aria-pressed":i===`changes`,onClick:()=>a(`changes`),children:`Changes`}),(0,H.jsx)(yn,{size:`xs`,variant:i===`files`?`secondary`:`ghost`,"aria-pressed":i===`files`,onClick:()=>a(`files`),children:`Files`}),(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,"aria-label":`Refresh code`,onClick:()=>x(e=>e+1),disabled:v,children:(0,H.jsx)(li,{className:B(`size-3`,v&&`animate-spin`)})}),(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,className:`p-1 size-6 shrink-0`,title:S?`Show file tree sidebar`:`Hide file tree sidebar`,"aria-label":S?`Show file tree sidebar`:`Hide file tree sidebar`,onClick:()=>C(e=>!e),children:S?(0,H.jsx)(ri,{className:`size-3.5 text-muted-foreground`}):(0,H.jsx)(ti,{className:`size-3.5 text-muted-foreground`})}),(0,H.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground font-mono shrink-0`,children:v?`Refreshing…`:`${o.reduce((e,t)=>e+t.files.length,0)} files`}),r&&(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,className:`p-1 size-6 shrink-0 ml-1`,title:`Close code panel`,onClick:r,children:(0,H.jsx)(Ei,{className:`size-3.5 text-muted-foreground`})})]}),f&&(0,H.jsxs)(`p`,{role:`alert`,className:`p-2 text-xs text-destructive shrink-0 border-b border-border`,children:[f,` `,(0,H.jsx)(`button`,{className:`underline`,onClick:()=>x(e=>e+1),children:`Retry`})]}),g&&(0,H.jsx)(`p`,{role:`alert`,className:`p-2 text-xs text-destructive shrink-0 border-b border-border`,children:g}),(0,H.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 flex flex-row overflow-hidden`,children:[(0,H.jsx)(`aside`,{className:B(`flex flex-col border-r border-border shrink-0 bg-muted/10 overflow-hidden select-text`,S?`w-0 border-r-0`:`w-[32%] min-w-[115px] max-w-[240px] transition-[width] duration-150`),children:(0,H.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-2`,children:[o.map(e=>(0,H.jsxs)(`details`,{open:!0,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer py-1 text-xs font-semibold select-none`,children:e.repoName}),e.error?(0,H.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:e.error}):(0,H.jsx)(aC,{label:`${e.repoName} ${i}`,files:e.files,revealPath:c?.repoName===e.repoName?c.file:void 0,renderFile:t=>(0,H.jsxs)(`button`,{className:B(`flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-xs hover:bg-accent transition-colors cursor-pointer`,c?.repoName===e.repoName&&c.file===t.file&&`bg-accent font-medium text-foreground`),"aria-pressed":c?.repoName===e.repoName&&c.file===t.file,title:t.file,onClick:()=>{c?.repoName===e.repoName&&c.file===t.file&&!c.line||(_(``),d(null),E.current=``,l({repoName:e.repoName,repoPath:e.repoPath,file:t.file}))},children:[(0,H.jsx)(Fr,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`truncate`,children:t.file.split(`/`).at(-1)}),t.type!==`unchanged`&&(0,H.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground font-mono`,children:t.type})]})})]},e.repoName)),!v&&!f&&!o.some(e=>e.files.length||e.error)&&(0,H.jsx)(`p`,{className:`p-2 text-xs text-muted-foreground`,children:i===`changes`?`No uncommitted changes.`:`No repository files.`})]})}),(0,H.jsxs)(`main`,{className:`flex-1 min-w-0 min-h-0 flex flex-col bg-background overflow-hidden select-text`,children:[c?(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/10 px-2 py-1 shrink-0`,children:[(0,H.jsxs)(`p`,{className:`break-all font-mono text-xs font-semibold text-foreground`,children:[c.repoName,`/`,c.file,c.line?`:${c.line}`:``]}),i===`changes`&&ee.length>1&&(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 ml-2`,children:[(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,disabled:O<=0,onClick:A,title:`Previous changed file`,className:`h-5 px-1 text-[10px]`,children:(0,H.jsx)(Tr,{className:`size-3`})}),(0,H.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:[O+1,`/`,ee.length]}),(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,disabled:O>=ee.length-1,onClick:k,title:`Next changed file`,className:`h-5 px-1 text-[10px]`,children:(0,H.jsx)(Er,{className:`size-3`})})]})]}):(0,H.jsx)(`div`,{className:`border-b border-border bg-muted/10 p-2 shrink-0`,children:(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Select a file`})}),(0,H.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 flex flex-col overflow-hidden`,children:c?m?(0,H.jsxs)(`p`,{role:`alert`,className:`p-3 text-xs text-destructive`,children:[m,` `,(0,H.jsx)(`button`,{className:`underline`,onClick:()=>x(e=>e+1),children:`Retry`})]}):u?u.diff?(0,H.jsx)(oC,{children:(0,H.jsx)(VC,{filePath:c.file,repoName:c.repoName,repoPath:c.repoPath,patchText:u.diff,fullFileContent:u.fileContent,fullOriginalContent:u.originalContent,initialTargetLine:c.line,viewMode:`unified`,fillContainer:!0,onNextFile:k,onPrevFile:A})},`${e}/${c.repoName}/${c.file}`):(0,H.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`px-3 py-1 border-b border-border/40 bg-muted/10 text-[11px] text-muted-foreground flex items-center justify-between shrink-0`,children:[(0,H.jsx)(`span`,{children:`Clean file (no uncommitted diff)`}),c.line&&(0,H.jsxs)(`span`,{className:`font-mono text-primary font-medium`,children:[`Line `,c.line]})]}),(0,H.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,H.jsx)(`pre`,{ref:T,className:`p-3 font-mono text-xs whitespace-pre leading-relaxed select-text`,children:u.fileContent||`Empty file or no text content.`})})]}):(0,H.jsx)(`p`,{role:`status`,className:`p-3 text-xs text-muted-foreground`,children:`Loading file…`}):(0,H.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center p-6 text-center text-muted-foreground gap-2`,children:[(0,H.jsx)(Fr,{className:`size-8 opacity-35`}),(0,H.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Select a file to inspect its code and changes alongside the CLI chat.`})]})})]})]})]})}var WC=Object.defineProperty,GC=Object.getOwnPropertyDescriptor,KC=(e,t)=>{for(var n in t)WC(e,n,{get:t[n],enumerable:!0})},qC=(e,t,n,r)=>{for(var i=r>1?void 0:r?GC(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&WC(t,n,i),i},JC=(e,t)=>(n,r)=>t(n,r,e),YC=`Terminal input`,XC={get:()=>YC,set:e=>YC=e},ZC=`Too much output to announce, navigate to rows manually to read`,QC={get:()=>ZC,set:e=>ZC=e};function $C(e){return e.replace(/\r?\n/g,`\r`)}function ew(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function tw(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function nw(e,t,n,r){e.stopPropagation(),e.clipboardData&&rw(e.clipboardData.getData(`text/plain`),t,n,r)}function rw(e,t,n,r){e=$C(e),e=ew(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function iw(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function aw(e,t,n,r,i){iw(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function ow(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function sw(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var cw=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},lw=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},uw=``,dw=` `,fw=class e{constructor(){this.fg=0,this.bg=0,this.extended=new pw}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},pw=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},mw=class e extends fw{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new pw,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ow(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},hw=`di$target`,gw=`di$dependencies`,_w=new Map;function vw(e){return e[gw]||[]}function yw(e){if(_w.has(e))return _w.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);bw(t,e,r)};return t._id=e,_w.set(e,t),t}function bw(e,t,n){t[hw]===t?t[gw].push({id:e,index:n}):(t[gw]=[{id:e,index:n}],t[hw]=t)}var xw=yw(`BufferService`),Sw=yw(`CoreMouseService`),Cw=yw(`CoreService`),ww=yw(`CharsetService`),Tw=yw(`InstantiationService`),Ew=yw(`LogService`),Dw=yw(`OptionsService`),Ow=yw(`OscLinkService`),kw=yw(`UnicodeService`),Aw=yw(`DecorationService`),jw=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new mw,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Mw(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};jw=qC([JC(0,xw),JC(1,Dw),JC(2,Ow)],jw);function Mw(e,t){if(confirm(`Do you want to navigate to ${t}?
42
+ `),hunks:n,isNewFile:a,isDeletedFile:o}}function cC(e,t){let n=1;for(let r of t){let t=r.startLineModified;for(let i of r.lines||[])if(!(i.startsWith(`-`)||i.startsWith(`\\`))){if(t===e)return n;n++,t++}}return null}var lC=({patchText:e,targetLine:t,jumpNonce:n})=>{let r=(0,V.useRef)(null),i=(0,V.useRef)(void 0);(0,V.useEffect)(()=>{!r.current||!t||t<=0||i.current!==n&&(i.current=n,(r.current.querySelector(`[data-mod-line="${t}"]`)||r.current.querySelector(`[data-is-target="true"]`))?.scrollIntoView({behavior:`smooth`,block:`center`}))},[t,n]);let a=(0,V.useMemo)(()=>{if(!e||!e.trim())return[];let n=e.split(/\r?\n/),r=0;return n.map((e,n)=>{let i=``,a=`text-muted-foreground`,o;if(e.startsWith(`@@`)){i=`bg-sky-500/15`,a=`text-sky-400 font-bold italic`;let t=e.match(/\+(\d+)/);t&&t[1]&&(r=parseInt(t[1],10)-1)}else e.startsWith(`+`)&&!e.startsWith(`+++`)?(i=`bg-emerald-500/15`,a=`text-emerald-400 font-semibold`,r++,o=r):e.startsWith(`-`)&&!e.startsWith(`---`)?(i=`bg-rose-500/15`,a=`text-rose-400 font-semibold`):e.startsWith(` `)&&(r++,o=r);return{idx:n,line:e,lineModNum:o,isTarget:t!==void 0&&o===t,bgClass:i,textClass:a}})},[e,t]);return!e||!e.trim()?(0,H.jsx)(`div`,{className:`p-4 font-mono text-xs italic text-muted-foreground`,children:`No diff changes recorded.`}):(0,H.jsx)(`div`,{ref:r,className:`custom-scrollbar h-full min-h-0 overflow-auto rounded-lg border border-border/80 bg-muted/20 font-mono text-xs leading-relaxed select-text`,children:a.map(e=>(0,H.jsxs)(`div`,{"data-mod-line":e.lineModNum,"data-is-target":e.isTarget?`true`:void 0,className:`flex px-3 py-0.5 hover:bg-accent/40 ${e.isTarget?`bg-primary/25 border-l-2 border-primary font-bold`:e.bgClass}`,children:[(0,H.jsx)(`span`,{className:`w-10 select-none text-right pr-3 text-[10px] text-muted-foreground/60`,children:e.lineModNum??e.idx+1}),(0,H.jsx)(`span`,{className:`whitespace-pre flex-1 ${e.textClass}`,children:e.line})]},e.idx))})};function uC(e){switch(e){case`code-insiders`:case`vscode-insiders`:return`VS Code Insiders`;case`cursor`:return`Cursor`;case`windsurf`:return`Windsurf`;case`antigravity`:return`Antigravity`;default:return`VS Code`}}function dC(e){switch(e){case`code-insiders`:case`vscode-insiders`:return`code-insiders`;case`cursor`:return`cursor`;case`windsurf`:return`windsurf`;case`antigravity`:return`antigravity`;default:return`code`}}function fC(e){switch(e){case`code-insiders`:case`vscode-insiders`:return`vscode-insiders`;case`cursor`:return`cursor`;case`windsurf`:return`windsurf`;case`antigravity`:return`antigravity`;default:return`vscode`}}function pC(e,t,n=1,r=1,i){let a=e.replace(/\\/g,`/`).replace(/\/+$/,``),o=t.replace(/\\/g,`/`),s;if(/^[a-zA-Z]:\//.test(o)||o.startsWith(`/`))s=o;else{let e=o.replace(/^\/+/,``);s=a?`${a}/${e}`:e}let c=s.replace(/^\/+/,``);return`${fC(i)}://file/${encodeURI(c)}:${n}:${r}`}async function mC(e,t,n){let r=dC(n),i=uC(n);try{let n=await fetch(`/api/open-editor`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({workspacePath:e,command:r,filePath:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Failed to launch ${i}`)}return!0}catch(e){return console.error(`Failed to launch external diff tool:`,e),!1}}function hC(e,t,n=1,r=1,i){let a=pC(e,t,n,r,i);typeof window<`u`&&window.open&&window.open(a,`_blank`)}function gC(e){if(e?.editor)return e;if(typeof window<`u`&&window.monaco?.editor)return window.monaco}function _C(e){return e.replace(/\\/g,`/`).replace(/^\//,``)}function vC(e){return e.replace(/\\/g,`/`).replace(/^\//,``).replace(/\/$/,``)}function yC(e,t,n){let r=vC(e),i=_C(t),a=`file:///${r}/${i}`,o=gC(n);if(o?.Uri?.parse)return o.Uri.parse(a);let s=`/${r}/${i}`;return{scheme:`file`,authority:``,path:s,query:``,fragment:``,fsPath:s,with:()=>({}),toString:()=>a,toJSON:()=>a}}function bC(e,t,n){let r=vC(e),i=_C(t),a=`diff-original:///${r}/${i}`,o=gC(n);if(o?.Uri?.parse)return o.Uri.parse(a);let s=`/${r}/${i}`;return{scheme:`diff-original`,authority:``,path:s,query:``,fragment:``,fsPath:s,with:()=>({}),toString:()=>a,toJSON:()=>a}}function xC(e,t,n,r){let i=gC(r);if(!i?.editor)return null;try{let r=i.editor.getModel(e);return!r||r.isDisposed()?r=i.editor.createModel(t,n,e):r.getValue()!==t&&r.setValue(t),r}catch(r){console.warn(`[changesetModelStore] Error in getOrCreateTextModel:`,r);try{return i.editor.getModel(e)||i.editor.createModel(t,n)}catch{return null}}}function SC(e,t){let n=gC(t);if(!n?.editor?.registerEditorOpener)return{dispose:()=>{}};try{return n.editor.registerEditorOpener({openCodeEditor(t,n,r){if(!n||n.scheme!==`file`)return!1;let i=n.path.replace(/^\//,``),a=i.indexOf(`/`);if(a===-1)return!1;let o=i.substring(0,a),s=i.substring(a+1),c;return r&&(`lineNumber`in r&&typeof r.lineNumber==`number`?c=r.lineNumber:`startLineNumber`in r&&typeof r.startLineNumber==`number`&&(c=r.startLineNumber)),e(o,s,c),!0}})}catch(e){return console.warn(`[changesetModelStore] Failed to register editor opener:`,e),{dispose:()=>{}}}}var CC={File:0,Module:1,Namespace:2,Package:3,Class:4,Method:5,Property:6,Field:7,Constructor:8,Enum:9,Interface:10,Function:11,Variable:12,Constant:13,String:14,Number:15,Boolean:16,Array:17,Object:18,Key:19,Null:20,EnumMember:21,Struct:22,Event:23,Operator:24,TypeParameter:25};function wC(e){switch(e.split(`.`).pop()?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`mjs`:case`cjs`:return`ts`;case`py`:return`python`;case`go`:return`go`;case`rs`:return`rust`;case`cs`:return`csharp`;default:return`other`}}var TC=[{regex:/^\s*(?:(?:public|private|protected|internal|sealed|abstract|static|partial)\s+)*class\s+([A-Za-z0-9_]+)/,kind:CC.Class,label:`class`},{regex:/^\s*(?:(?:public|private|protected|internal|partial)\s+)*interface\s+([A-Za-z0-9_]+)/,kind:CC.Interface,label:`interface`},{regex:/^\s*(?:(?:public|private|protected|internal|sealed|abstract|static|partial|readonly)\s+)*record(?:\s+(?:class|struct))?\s+([A-Za-z0-9_]+)/,kind:CC.Class,label:`class`},{regex:/^\s*(?:(?:public|private|protected|internal|readonly|ref|partial)\s+)*struct\s+([A-Za-z0-9_]+)/,kind:CC.Struct,label:`class`},{regex:/^\s*(?:(?:public|private|protected|internal)\s+)*enum\s+([A-Za-z0-9_]+)/,kind:CC.Enum,label:`enum`},{regex:/^\s*(?:(?:public|private|protected|internal)\s+)+([A-Z][A-Za-z0-9_]*)\s*\(/,kind:CC.Constructor,label:`constructor`},{regex:/^\s*(?:(?:public|private|protected|internal|static|async|virtual|override|abstract|sealed|new)\s+)+(?:void|[A-Za-z0-9_<>?[\]\s,]+)\s+([A-Za-z0-9_]+)\s*(?:<[^>]+>)?\s*\(/,kind:CC.Method,label:`method`},{regex:/^\s*(?:(?:async|static)\s+)?(?:void|Task(?:<[^>]+>)?|IActionResult|ActionResult(?:<[^>]+>)?)\s+([A-Za-z0-9_]+)\s*(?:<[^>]+>)?\s*\(/,kind:CC.Method,label:`method`},{regex:/^\s*(?:(?:public|private|protected|internal|virtual|override|abstract|required|static)\s+)+[A-Za-z0-9_<>?[\]\s,]+\s+([A-Za-z0-9_]+)\s*\{\s*(?:get|set|init)/,kind:CC.Property,label:`property`},{regex:/^\s*(?:(?:public|private|protected|internal|virtual|override|abstract|static)\s+)+[A-Za-z0-9_<>?[\]\s,]+\s+([A-Za-z0-9_]+)\s*=>/,kind:CC.Property,label:`property`}],EC=[{regex:/^\s*(?:export\s+(?:default\s+)?)?(?:async\s+)?function\s*(?:\*\s*)?([A-Za-z0-9_$]+)/,kind:CC.Function,label:`function`},{regex:/^\s*(?:(?:public|private|protected)\s+)?(constructor)\s*\(/,kind:CC.Constructor,label:`constructor`},{regex:/^\s*(?:(?:public|private|protected|static|abstract|override|async)\s+)+([A-Za-z0-9_$]+)\s*(?:<[^>]+>)?\s*\(/,kind:CC.Method,label:`method`},{regex:/^\s*(?:export\s+)?(?:const|let|var)\s+([A-Za-z0-9_$]+)\s*(?::\s*[^=]+)?\s*=\s*(?:async\s*)?(?:\([^)]*\)|[A-Za-z0-9_$]+|\()(?:\s*:\s*[^=]+)?\s*(?:=>)?/,kind:CC.Function,label:`function`},{regex:/^\s*(?:export\s+)?(?:const|let|var)\s+([A-Za-z0-9_$]+)\s*(?::\s*[^=]+)?\s*=\s*(?:async\s*)?function/,kind:CC.Function,label:`function`},{regex:/^\s*(?:export\s+(?:default\s+)?)?(?:abstract\s+)?class\s+([A-Za-z0-9_$]+)/,kind:CC.Class,label:`class`},{regex:/^\s*(?:export\s+)?interface\s+([A-Za-z0-9_$]+)/,kind:CC.Interface,label:`interface`},{regex:/^\s*(?:export\s+)?type\s+([A-Za-z0-9_$]+)\s*(?:<[^>]*>)?\s*=/,kind:CC.TypeParameter,label:`type`},{regex:/^\s*(?:export\s+)?(?:const\s+)?enum\s+([A-Za-z0-9_$]+)/,kind:CC.Enum,label:`enum`},{regex:/^\s*(?:export\s+)?(?:const|let|var)\s+([A-Za-z0-9_$]+)\s*(?::\s*[^=]+)?\s*=/,kind:CC.Variable,label:`variable`}],DC=[{regex:/^\s*(?:async\s+)?def\s+([A-Za-z0-9_]+)\s*\(/,kind:CC.Function,label:`function`},{regex:/^\s*class\s+([A-Za-z0-9_]+)(?:\s*\([^)]*\))?\s*:/,kind:CC.Class,label:`class`}],OC=[{regex:/^\s*func\s+(?:\([^)]+\)\s+)?([A-Za-z0-9_]+)\s*\(/,kind:CC.Function,label:`function`},{regex:/^\s*type\s+([A-Za-z0-9_]+)\s+(?:struct|interface)/,kind:CC.Class,label:`type`}],kC=[{regex:/^\s*(?:pub(?:\([^)]+\))?\s+)?(?:async\s+)?(?:unsafe\s+)?fn\s+([A-Za-z0-9_]+)/,kind:CC.Function,label:`function`},{regex:/^\s*(?:pub(?:\([^)]+\))?\s+)?struct\s+([A-Za-z0-9_]+)/,kind:CC.Class,label:`class`},{regex:/^\s*(?:pub(?:\([^)]+\))?\s+)?enum\s+([A-Za-z0-9_]+)/,kind:CC.Enum,label:`enum`},{regex:/^\s*(?:pub(?:\([^)]+\))?\s+)?trait\s+([A-Za-z0-9_]+)/,kind:CC.Interface,label:`interface`}],AC=new class{symbols=[];symbolMap=new Map;listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}onIndexUpdated(e){return this.subscribe(e)}notify(){for(let e of this.listeners)try{e()}catch(e){console.error(`Error in changeset symbol index listener:`,e)}}clear(){this.symbols=[],this.symbolMap.clear(),this.notify()}removeFile(e,t){let n=t.replace(/\\/g,`/`).replace(/^\//,``);this.symbols=this.symbols.filter(t=>t.repoName!==e||t.filePath!==n),this.rebuildMap(),this.notify()}indexFile(e,t,n,r=[],i,a){let o=t.replace(/\\/g,`/`).replace(/^\//,``),s=e.replace(/\\/g,`/`).replace(/^\//,``).replace(/\/$/,``),c=`file:///${s}/${o}`,l=this.symbols.filter(t=>t.repoName!==e||t.filePath!==o),u=wC(o),d=EC;u===`python`?d=DC:u===`go`?d=OC:u===`rust`?d=kC:u===`csharp`?d=TC:u===`other`&&(d=[]);let f=[];if(r&&r.length>0)for(let e of r){let t=0;for(let n of e.lines||[]){if(n.startsWith(`-`)||n.startsWith(`\\`))continue;let r=n.startsWith(`+`);f.push({lineNum:e.startLineModified+t,hunk:e,isAdded:r}),t++}}let p=n.split(/\r?\n/),m=f.length>0&&p.length===f.length,h=[];if(a&&a.length>0)for(let t of a){let n=t.lineNumber,a,l=!1,u=t.lineNumber,d=t.endLineNumber||t.lineNumber;if(m){let e=f.find(e=>e.lineNum>=u&&e.lineNum<=d);e?(n=e.lineNum,a=e.hunk,l=e.isAdded):a=r.find(e=>{let t=e.startLineModified,n=e.startLineModified+Math.max(e.lineCountModified,1)-1;return t<=d&&n>=u})}else a=r.find(e=>{let t=e.startLineModified,n=e.startLineModified+Math.max(e.lineCountModified,1)-1;return t<=d&&n>=u});let p=`context`;if(a){if(m)p=l?`added`:`modified`;else{p=`modified`;let e=a.startLineModified,n=e+Math.max(a.lineCountModified,1)-1;(t.lineNumber>=e&&t.lineNumber<=n&&a.lines&&a.lines.some(e=>e.startsWith(`+`)&&e.includes(t.name))||a.lines&&a.lines.length>0&&a.lines.every(e=>!e.startsWith(`-`)&&!e.startsWith(` `)))&&(p=`added`)}}let g={id:`${s}:${o}:${n}:${t.name}`,name:t.name,kind:t.kind,kindLabel:t.kindLabel,repoName:e,repoPath:i||(s.includes(`/`)||s.includes(`\\`)?s:void 0),filePath:o,uriString:c,lineNumber:n,endLineNumber:t.endLineNumber,column:t.column||1,containerName:t.containerName,isModifiedInChangeset:!!a,changeType:a?p:`context`,hunkIndex:a?.hunkIndex,hunkId:a?.id};h.push(g)}else if(p.forEach((t,n)=>{let a,l,u=!1;if(m){let e=f[n];a=e.lineNum,l=e.hunk,u=e.isAdded}else a=n+1,l=r.find(e=>{let t=e.startLineModified,n=e.startLineModified+Math.max(e.lineCountModified,1)-1;return a>=t&&a<=n});for(let n of d){let r=t.match(n.regex);if(r&&r[1]){let d=r[1],f=t.indexOf(d)+1,p=`context`;l&&(m?p=u?`added`:`modified`:(p=`modified`,l.lines&&l.lines.some(e=>e.startsWith(`+`)&&e.includes(d))&&(p=`added`)));let g={id:`${s}:${o}:${a}:${d}`,name:d,kind:n.kind,kindLabel:n.label,repoName:e,repoPath:i||(s.includes(`/`)||s.includes(`\\`)?s:void 0),filePath:o,uriString:c,lineNumber:a,column:f>0?f:1,isModifiedInChangeset:!!l,changeType:l?p:`context`,hunkIndex:l?.hunkIndex,hunkId:l?.id};h.push(g);break}}}),r&&r.length>0){for(let t of r)if(t.enclosingDeclaration)for(let n of d){let r=t.enclosingDeclaration.match(n.regex);if(r&&r[1]){let a=r[1];h.some(e=>e.name===a)||h.push({id:`${s}:${o}:${t.startLineModified}:${a}`,name:a,kind:n.kind,kindLabel:n.label,repoName:e,repoPath:i||(s.includes(`/`)||s.includes(`\\`)?s:void 0),filePath:o,uriString:c,lineNumber:t.startLineModified,column:1,isModifiedInChangeset:!0,changeType:`modified`,hunkIndex:t.hunkIndex,hunkId:t.id});break}}}if(r&&r.length>0){for(let e of r)if(e.enclosingDeclaration)for(let t of h)e.enclosingDeclaration.includes(t.name)&&!t.isModifiedInChangeset&&(t.isModifiedInChangeset=!0,t.changeType=`modified`,t.hunkIndex=e.hunkIndex,t.hunkId=e.id)}return this.symbols=[...l,...h],this.rebuildMap(),this.notify(),h}rebuildMap(){this.symbolMap.clear();for(let e of this.symbols){let t=this.symbolMap.get(e.name)||[];t.push(e),this.symbolMap.set(e.name,t)}}getAllSymbols(){return this.symbols}getModifiedSymbols(){return this.symbols.filter(e=>e.isModifiedInChangeset)}findDefinitions(e){return this.symbolMap.get(e)||[]}findSymbolsInFile(e){let t=e.replace(/\\/g,`/`).replace(/^\//,``);return this.symbols.filter(e=>e.filePath===t)}};function jC(e=AC){return(0,V.useSyncExternalStore)(t=>e.subscribe(t),()=>e.getAllSymbols(),()=>[])}function MC(e,t){let n=[];for(let r of e){if(r.uri.scheme!==`file`)continue;let e=r.findMatches(t,!0,!1,!0,` \`~!@#%^&*()-=+[{]}\\|;:'",.<>/?`,!1);for(let t of e)n.push({uri:r.uri,range:t.range})}return n}var NC=!1;function PC(e){let t=e||(typeof window<`u`?window.monaco:void 0);if(!t||NC)return{dispose:()=>{}};let n=[`typescript`,`javascript`,`python`,`rust`,`go`,`csharp`],r=[];for(let e of n)r.push(t.languages.registerDefinitionProvider(e,{provideDefinition(e,n){let r=e.getWordAtPosition(n);if(!r)return null;let i=r.word,a=AC.findDefinitions(i);return a.length===0?null:a.map(e=>({uri:yC(e.repoName,e.filePath,t),range:{startLineNumber:e.lineNumber,startColumn:e.column,endLineNumber:e.lineNumber,endColumn:e.column+e.name.length}}))}})),r.push(t.languages.registerReferenceProvider(e,{provideReferences(e,n){let r=e.getWordAtPosition(n);return r?MC(t.editor.getModels(),r.word):null}})),r.push(t.languages.registerDocumentSymbolProvider(e,{provideDocumentSymbols(e){let t=e.uri.toString();return AC.getAllSymbols().filter(e=>e.uriString===t).map(e=>({name:e.name,detail:e.kindLabel,kind:e.kind,tags:[],range:{startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column+e.name.length},selectionRange:{startLineNumber:e.lineNumber,startColumn:e.column,endLineNumber:e.lineNumber,endColumn:e.column+e.name.length}}))}}));return NC=!0,{dispose(){r.forEach(e=>e.dispose()),NC=!1}}}var FC=[{id:`all`,label:`All`,short:`All`},{id:`modified`,label:`Modified Only`,short:`Mod`},{id:`function`,label:`Functions`,short:`fn`},{id:`method`,label:`Methods`,short:`meth`},{id:`constructor`,label:`Constructors`,short:`ctor`},{id:`class`,label:`Classes`,short:`cls`},{id:`interface`,label:`Interfaces`,short:`iface`},{id:`type`,label:`Types`,short:`type`},{id:`enum`,label:`Enums`,short:`enum`},{id:`property`,label:`Properties`,short:`prop`},{id:`variable`,label:`Variables`,short:`var`}],IC=e=>e.kind===CC.Constructor||e.kindLabel===`constructor`?`constructor`:e.kind===CC.Method||e.kindLabel===`method`?`method`:e.kind===CC.Property||e.kindLabel===`property`?`property`:e.kindLabel,LC=e=>{let t=IC(e);switch(t){case`constructor`:return`[CTOR]`;case`method`:return`[METH]`;case`function`:return`[FUNC]`;case`class`:return`[CLAS]`;case`interface`:return`[IFAC]`;case`type`:return`[TYPE]`;case`enum`:return`[ENUM]`;case`property`:return`[PROP]`;case`variable`:return`[VAR]`;default:return`[${String(t).slice(0,4).toUpperCase()}]`}},RC=e=>{switch(IC(e)){case`constructor`:return`border-orange-500/40 bg-orange-500/15 text-orange-400`;case`method`:return`border-cyan-500/40 bg-cyan-500/15 text-cyan-400`;case`function`:return`border-emerald-500/40 bg-emerald-500/15 text-emerald-400`;case`class`:return`border-purple-500/40 bg-purple-500/15 text-purple-400`;case`interface`:return`border-sky-500/40 bg-sky-500/15 text-sky-400`;case`type`:return`border-amber-500/40 bg-amber-500/15 text-amber-400`;case`enum`:return`border-pink-500/40 bg-pink-500/15 text-pink-400`;case`property`:return`border-teal-500/40 bg-teal-500/15 text-teal-400`;case`variable`:return`border-slate-500/40 bg-slate-500/15 text-slate-400`;default:return`border-border bg-muted text-muted-foreground`}},zC=({symbols:e,activeFilePath:t,activeLine:n,editorLabel:r=`VS Code`,onSelectSymbol:i,onOpenInVsCode:a,onClose:o,className:s})=>{let[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(`all`),f=(0,V.useMemo)(()=>{let t=e;if(u===`modified`?t=t.filter(e=>e.isModifiedInChangeset):u!==`all`&&(t=t.filter(e=>IC(e)===u)),c.trim()){let e=c.toLowerCase();t=t.filter(t=>t.name.toLowerCase().includes(e)||t.filePath.toLowerCase().includes(e)||t.kindLabel.toLowerCase().includes(e)||IC(t).toLowerCase().includes(e))}return t.sort((e,t)=>e.isModifiedInChangeset===t.isModifiedInChangeset?e.filePath===t.filePath?e.lineNumber-t.lineNumber:e.filePath.localeCompare(t.filePath):e.isModifiedInChangeset?-1:1)},[e,u,c]),p=(0,V.useMemo)(()=>{let t={all:e.length,modified:e.filter(e=>e.isModifiedInChangeset).length};for(let n of e){let e=IC(n);t[e]=(t[e]||0)+1}return t},[e]);return(0,H.jsxs)(`div`,{className:B(`flex flex-col rounded-xl border border-border/90 bg-card/95 backdrop-blur-md shadow-lg overflow-hidden text-xs`,s),children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2.5 border-b border-border/70 bg-muted/25`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,H.jsx)(Ar,{size:14,className:`text-primary shrink-0`}),(0,H.jsx)(`span`,{className:`font-mono text-xs font-bold text-foreground`,children:`Changeset Symbols`}),(0,H.jsxs)(`span`,{className:`rounded-full bg-primary/10 border border-primary/20 px-1.5 py-0.2 font-mono text-[10px] text-primary font-semibold`,children:[f.length,` / `,e.length]})]}),o&&(0,H.jsx)(`button`,{type:`button`,onClick:o,className:`p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors cursor-pointer`,title:`Close Symbol Navigator`,children:(0,H.jsx)(Ei,{size:13})})]}),(0,H.jsxs)(`div`,{className:`p-2 space-y-2 border-b border-border/60 bg-background/50`,children:[(0,H.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,H.jsx)(Ct,{size:13,className:`absolute left-2.5 text-muted-foreground pointer-events-none`}),(0,H.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`Search functions, classes, types, files...`,className:`w-full rounded-lg border border-border bg-background/90 pl-8 pr-7 py-1.5 font-mono text-xs text-foreground placeholder:text-muted-foreground focus:outline-hidden focus:ring-1 focus:ring-primary`}),c&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>l(``),className:`absolute right-2 text-muted-foreground hover:text-foreground`,children:(0,H.jsx)(Ei,{size:12})})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 overflow-x-auto pb-0.5 scrollbar-none select-none`,children:[(0,H.jsx)(Rr,{size:11,className:`text-muted-foreground shrink-0 ml-0.5 mr-0.5`}),FC.map(e=>{let t=p[e.id]||0,n=u===e.id;return e.id!==`all`&&e.id!==`modified`&&t===0?null:(0,H.jsxs)(`button`,{type:`button`,onClick:()=>d(e.id),className:B(`inline-flex items-center gap-1 px-2 py-0.5 rounded-md font-mono text-[10px] transition-colors cursor-pointer shrink-0 border`,n?`border-primary/50 bg-primary/15 text-primary font-bold`:`border-border/60 bg-card hover:bg-accent text-muted-foreground hover:text-foreground`),children:[(0,H.jsx)(`span`,{children:e.label}),(0,H.jsxs)(`span`,{className:`text-[9px] opacity-70`,children:[`(`,t,`)`]})]},e.id)})]})]}),(0,H.jsx)(`div`,{className:`max-h-64 overflow-y-auto divide-y divide-border/40 scrollbar-thin`,children:e.length===0?(0,H.jsxs)(`div`,{className:`py-8 px-4 text-center text-muted-foreground`,children:[(0,H.jsx)(`p`,{className:`font-mono text-xs font-semibold text-foreground`,children:`No code symbols detected in this changeset`}),(0,H.jsx)(`p`,{className:`text-[11px] mt-1.5 max-w-sm mx-auto text-muted-foreground/80 leading-relaxed`,children:`Symbols (functions, classes, interfaces, types, enums, variables) are automatically extracted from modified code files in supported languages (TypeScript, JavaScript, Python, Go, Rust).`})]}):f.length===0?(0,H.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,H.jsxs)(`p`,{className:`font-mono text-xs`,children:[`No symbols match "`,c||u,`"`]}),(0,H.jsx)(`p`,{className:`text-[10px] mt-1 text-muted-foreground/70`,children:`Try searching by name or selecting "All"`})]}):f.map(e=>{let o=t&&e.filePath.endsWith(t)&&n===e.lineNumber;return(0,H.jsxs)(`div`,{onClick:()=>i(e),className:B(`group flex items-center justify-between gap-2 px-3 py-2 cursor-pointer transition-colors`,o?`bg-primary/15 border-l-2 border-l-primary`:`hover:bg-accent/50`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,H.jsx)(`span`,{className:B(`px-1.5 py-0.2 rounded font-mono text-[9px] font-bold border uppercase shrink-0`,RC(e)),children:LC(e)}),(0,H.jsx)(`span`,{className:`font-mono text-xs font-bold text-foreground truncate group-hover:text-primary transition-colors`,children:e.name}),e.isModifiedInChangeset&&(0,H.jsx)(`span`,{className:B(`px-1 py-0.2 rounded font-mono text-[9px] font-bold border shrink-0`,e.changeType===`added`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-400`:`border-amber-500/30 bg-amber-500/10 text-amber-400`),title:e.changeType===`added`?`Added in this changeset`:`Modified in this changeset`,children:e.changeType===`added`?`+add`:`~mod`})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:`truncate max-w-[150px] text-muted-foreground/80`,title:e.filePath,children:e.filePath.split(`/`).pop()}),(0,H.jsxs)(`span`,{className:`text-foreground/70`,children:[`:`,e.lineNumber]}),e.hunkIndex!==void 0&&(0,H.jsxs)(`span`,{className:`bg-muted px-1 rounded text-[9px] border border-border/40`,children:[`H#`,e.hunkIndex+1]}),o&&(0,H.jsx)(Or,{size:12,className:`text-primary shrink-0`}),a&&(0,H.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(e)},className:`p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent opacity-0 group-hover:opacity-100 transition-opacity`,title:`Open symbol definition in desktop ${r}`,children:(0,H.jsx)(Bn,{size:11})})]})]},e.id)})})]})},BC=(0,V.lazy)(()=>Kn(()=>import(`./MonacoDiffAdapter-DHYIkG2a.js`).then(e=>({default:e.MonacoDiffAdapter})),__vite__mapDeps([0,1,2,3,4]))),VC=({filePath:e,repoName:t,repoPath:n=``,patchText:r,fullFileContent:i,fullOriginalContent:a,defaultEditor:o,viewMode:s,initialTargetLine:c,changesetSymbols:l,preExtractedSymbols:u,onToggleViewMode:d,showToast:f,onHunkAction:p,onRequestRefine:m,onOpenFile:h,onSelectSymbol:g,onNextFile:_,onPrevFile:v,fillContainer:y=!1})=>{let[b,x]=(0,V.useState)(`side-by-side`),S=s??b,[C,w]=(0,V.useState)(!1),[T,E]=(0,V.useState)(`monaco`),[D,ee]=(0,V.useState)(0),[O,k]=(0,V.useState)({}),[A,te]=(0,V.useState)(!1),[j,M]=(0,V.useState)(``),[N,ne]=(0,V.useState)(!1),[re,ie]=(0,V.useState)(c),[P,F]=(0,V.useState)(0),I=uC(o),L=(0,V.useMemo)(()=>sC(r),[r]),ae=L.hunks,R=ae[D]||null,[oe,z]=(0,V.useState)([]);(0,V.useEffect)(()=>{let r=i||L.modifiedContent;z(AC.indexFile(t,e,r,ae,n,u))},[t,e,i,L.modifiedContent,ae,n,u]);let se=(0,V.useRef)(``);(0,V.useEffect)(()=>{if(c&&c>0){let t=`${e}:${c}`;if(se.current===t)return;se.current=t;let n=c;if(!i){let e=cC(c,ae);e!==null&&(n=e)}ie(n),F(e=>e+1);let r=ae.findIndex(e=>c>=e.startLineModified&&c<=e.startLineModified+Math.max(e.lineCountModified,1)-1);r!==-1&&ee(r)}},[c,e,ae,i]);let ce=()=>{d?d():x(e=>e===`side-by-side`?`unified`:`side-by-side`)},le=(0,V.useRef)(null),ue=(0,V.useCallback)(e=>{e>=0&&e<ae.length&&ae[e]&&(ee(e),ie(Math.max(1,ae[e].startLineModified)),F(e=>e+1))},[ae]),de=(0,V.useCallback)(()=>{D<ae.length-1?ue(D+1):_&&_()},[D,ae.length,ue,_]),fe=(0,V.useCallback)(()=>{D>0?ue(D-1):v&&v()},[D,ue,v]),pe=(0,V.useCallback)(async()=>{!R||!p||(await p({...R,type:`accept`}),k(e=>({...e,[R.id]:`accepted`})),f?.(`Accepted hunk #${D+1}`,`success`),de())},[R,D,f,p,de]),me=(0,V.useCallback)(async()=>{!R||!p||(await p({...R,type:`reject`}),k(e=>({...e,[R.id]:`rejected`})),f?.(`Rejected hunk #${D+1}`,`info`),de())},[R,D,f,p,de]),he=()=>{M(``),te(!0)},ge=async()=>{if(!(!R||!j.trim()||!m))try{await m({...R,type:`refine`},j.trim()),te(!1)}catch(e){f?.(e instanceof Error?e.message:`Could not open refinement in chat.`,`error`)}},_e=t=>{let r=e.replace(/\\/g,`/`).replace(/^\//,``);if(t.filePath===r){let r=t.lineNumber;if(!i){let i=cC(t.lineNumber,ae);if(i!==null)r=i;else{f?.(`"${t.name}" is outside diff hunks (line ${t.lineNumber})`,`info`),hC(n,e,t.lineNumber,t.column,o);return}}ie(r),F(e=>e+1);let a=ae.findIndex(e=>t.lineNumber>=e.startLineModified&&t.lineNumber<=e.startLineModified+Math.max(e.lineCountModified,1)-1);a!==-1&&ee(a)}else g?.(t),h?.(t.repoName,t.filePath,t.lineNumber)},ve=(0,V.useCallback)(e=>{let t=ae.findIndex(t=>e>=t.startLineModified&&e<=t.startLineModified+Math.max(t.lineCountModified,1)-1);t!==-1&&t!==D&&ee(t)},[ae,D]);(0,V.useEffect)(()=>{le.current&&le.current.querySelector(`[data-active-tab="true"]`)?.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`})},[D]),(0,V.useEffect)(()=>{let e=e=>{let t=e.target;t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable||(e.key===`j`||e.key===`n`?de():e.key===`k`||e.key===`p`?fe():e.key===`a`?pe():e.key===`r`&&me())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[de,fe,pe,me]);let ye=l&&l.length>0?l:oe;return(0,H.jsxs)(`div`,{className:B(`flex flex-col overflow-hidden`,y?`h-full w-full min-h-0 bg-background border-0 rounded-none shadow-none my-0`:`rounded-xl border border-border/80 bg-card/60 backdrop-blur-md shadow-sm my-2`),children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-3 py-2 border-b border-border/60 bg-muted/20 text-xs shrink-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,H.jsx)(Ir,{size:13,className:`text-primary shrink-0`}),(0,H.jsx)(`span`,{className:`font-mono text-xs font-semibold text-foreground truncate`,title:e,children:e}),(0,H.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground bg-muted px-1.5 py-0.2 rounded border border-border/40`,children:t}),ae.length>0&&(0,H.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground/80`,children:[ae.length,` `,ae.length===1?`hunk`:`hunks`]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>ne(e=>!e),className:B(`inline-flex items-center gap-1 font-mono text-[11px] px-2 py-1 rounded border transition-colors cursor-pointer`,N?`border-primary/50 bg-primary/15 text-primary font-semibold`:`border-border bg-card/60 hover:bg-accent text-muted-foreground hover:text-foreground`),title:`Toggle Changeset Symbol Navigator`,children:[(0,H.jsx)(Gr,{size:12}),(0,H.jsx)(`span`,{children:`Symbols`}),ye.length>0&&(0,H.jsxs)(`span`,{className:`text-[10px] opacity-75`,children:[`(`,ye.length,`)`]})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:ce,className:`inline-flex items-center gap-1 font-mono text-[11px] px-2 py-1 rounded border border-border bg-card/60 hover:bg-accent text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Toggle between Side-by-Side and Unified Diff view`,children:[(0,H.jsx)(jr,{size:12}),(0,H.jsx)(`span`,{children:S===`side-by-side`?`Split`:`Unified`})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>w(e=>!e),className:B(`font-mono text-[11px] px-2 py-1 rounded border transition-colors cursor-pointer`,C?`border-primary/40 bg-primary/10 text-primary font-semibold`:`border-border bg-card/60 text-muted-foreground hover:bg-accent hover:text-foreground`),title:`Ignore whitespace changes in diff comparison`,children:[`Trim WS: `,C?`ON`:`OFF`]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>E(e=>e===`monaco`?`fallback`:`monaco`),className:`inline-flex items-center gap-1 font-mono text-[11px] px-2 py-1 rounded border border-border bg-card/60 hover:bg-accent text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Toggle between Monaco Diff Editor and Lightweight Fallback`,children:[(0,H.jsx)(Ar,{size:12}),(0,H.jsx)(`span`,{children:T===`monaco`?`Monaco`:`Fallback`})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:async()=>{await mC(n,e,o)?f?.(`Opened ${e} in ${I} diff`,`success`):(hC(n,e,1,1,o),f?.(`Opened ${e} in ${I}`,`info`))},className:`inline-flex items-center gap-1 font-mono text-[11px] px-2 py-1 rounded border border-border bg-card/60 hover:bg-accent text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Open file in desktop ${I} Diff`,children:[(0,H.jsx)(Bn,{size:12}),(0,H.jsx)(`span`,{className:`hidden sm:inline`,children:I})]})]})]}),ae.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-1.5 px-3 py-1.5 border-b border-border/60 bg-muted/15 text-xs select-none`,children:[(0,H.jsxs)(`div`,{ref:le,role:`tablist`,"aria-label":`Change sections`,className:`flex items-center gap-1 min-w-[130px] flex-1 overflow-x-auto py-0.5`,children:[(0,H.jsxs)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mr-1 shrink-0`,children:[`Changes (`,ae.length,`):`]}),ae.map((e,t)=>{let n=e.lines?e.lines.filter(e=>e.startsWith(`+`)&&!e.startsWith(`+++`)).length:0,r=e.lines?e.lines.filter(e=>e.startsWith(`-`)&&!e.startsWith(`---`)).length:0,i=t===D;return(0,H.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":i,"data-active-tab":i?`true`:void 0,onClick:()=>ue(t),className:B(`px-2 py-0.5 rounded text-[11px] font-mono transition-colors cursor-pointer border whitespace-nowrap shrink-0`,i?`bg-primary text-primary-foreground border-primary font-semibold shadow-xs`:`bg-card/70 text-muted-foreground hover:text-foreground hover:bg-accent border-border/60`),title:`Jump to change section #${t+1}: line ${e.startLineModified}${e.enclosingDeclaration?` (${e.enclosingDeclaration})`:``}`,children:[(0,H.jsxs)(`span`,{children:[`Section `,t+1]}),(n>0||r>0)&&(0,H.jsxs)(`span`,{className:`ml-1 text-[9px] opacity-80`,children:[n>0&&(0,H.jsxs)(`span`,{className:`text-emerald-300`,children:[`+`,n]}),r>0&&(0,H.jsxs)(`span`,{className:`text-rose-300`,children:[`-`,r]})]})]},e.id)})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 ml-auto`,children:[(0,H.jsxs)(`button`,{type:`button`,disabled:D<=0&&!v,onClick:fe,className:`inline-flex items-center gap-0.5 px-2 py-0.5 rounded text-[11px] font-mono border border-border bg-card/60 hover:bg-accent disabled:opacity-35 transition-colors cursor-pointer`,title:D<=0&&v?`Previous file`:`Previous change section (k / p)`,"aria-label":D<=0&&v?`Previous file`:`Previous section`,children:[(0,H.jsx)(Tr,{size:12}),(0,H.jsx)(`span`,{children:D<=0&&v?`Prev File`:`Prev`})]}),(0,H.jsxs)(`button`,{type:`button`,disabled:D>=ae.length-1&&!_,onClick:de,className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded text-[11px] font-mono font-medium border border-primary/50 bg-primary/15 text-primary hover:bg-primary/25 disabled:opacity-35 transition-colors cursor-pointer shadow-2xs`,title:D>=ae.length-1&&_?`Next file`:`Next change section (j / n)`,"aria-label":D>=ae.length-1&&_?`Next file`:`Next section`,children:[(0,H.jsx)(`span`,{children:D>=ae.length-1&&_?`Next File`:`Next Section`}),(0,H.jsx)(Er,{size:12})]})]})]}),N&&(0,H.jsx)(`div`,{className:`p-3 border-b border-border/70 bg-muted/20 shrink-0`,children:(0,H.jsx)(zC,{symbols:ye,activeFilePath:e,activeLine:re||(R?R.startLineModified:void 0),editorLabel:I,onSelectSymbol:_e,onOpenInVsCode:e=>{hC(n,e.filePath,e.lineNumber,e.column,o),f?.(`Opened ${e.filePath}:${e.lineNumber} in ${I}`,`success`)},onClose:()=>ne(!1)})}),(0,H.jsx)(`div`,{className:B(`bg-background/50`,y?`flex-1 min-h-0 p-1 flex flex-col`:`p-2`),children:T===`monaco`?(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`div`,{role:`status`,className:`p-4 text-xs text-muted-foreground`,children:`Loading diff editor…`}),children:(0,H.jsx)(BC,{filePath:e,repoName:t,repoPath:n,originalContent:a||L.originalContent,modifiedContent:i||L.modifiedContent,patchText:r,viewMode:S,ignoreWhitespace:C,height:y?`100%`:460,targetLine:re,jumpNonce:P,onOpenFile:h,onLineSelect:ve})}):(0,H.jsx)(lC,{filePath:e,repoPath:n,originalContent:a||L.originalContent,modifiedContent:i||L.modifiedContent,patchText:r,viewMode:S,ignoreWhitespace:C,targetLine:re,jumpNonce:P})}),ae.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-3 py-2 border-t border-border/60 bg-muted/15 text-xs select-none`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 font-mono text-[11px]`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:D<=0,onClick:fe,className:`p-1 rounded border border-border bg-card/60 hover:bg-accent disabled:opacity-35 transition-colors cursor-pointer`,title:`Previous hunk (Shortcut: k)`,children:(0,H.jsx)(Tr,{size:13})}),(0,H.jsxs)(`span`,{className:`px-1.5 text-muted-foreground`,children:[`Hunk `,(0,H.jsx)(`strong`,{className:`text-foreground`,children:D+1}),` of `,ae.length,R&&(0,H.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/70 ml-1`,children:[`(Orig L`,R.startLineOriginal,` → Mod L`,R.startLineModified,`)`]})]}),(0,H.jsx)(`button`,{type:`button`,disabled:D>=ae.length-1,onClick:de,className:`p-1 rounded border border-border bg-card/60 hover:bg-accent disabled:opacity-35 transition-colors cursor-pointer`,title:`Next hunk (Shortcut: j)`,children:(0,H.jsx)(Er,{size:13})}),R&&O[R.id]&&(0,H.jsx)(`span`,{className:B(`font-mono text-[9px] px-1.5 py-0.5 rounded font-bold uppercase ml-1 border`,O[R.id]===`accepted`?`border-emerald-500/30 bg-emerald-500/15 text-emerald-400`:O[R.id]===`rejected`?`border-rose-500/30 bg-rose-500/15 text-rose-400`:`border-amber-500/30 bg-amber-500/15 text-amber-400`),children:O[R.id]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[R&&(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{hC(n,e,R.startLineModified,1,o),f?.(`Opened ${e}:${R.startLineModified} in ${I}`,`success`)},className:`inline-flex items-center gap-1 font-mono text-[10px] px-2 py-1 rounded border border-border bg-card/60 hover:bg-accent text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Open in desktop ${I} at modified line ${R.startLineModified}`,children:[(0,H.jsx)(Bn,{size:11}),(0,H.jsxs)(`span`,{children:[I,` :L`,R.startLineModified]})]}),p&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>void pe(),className:`inline-flex items-center gap-1 px-2.5 py-1 rounded text-xs font-semibold bg-emerald-500/15 hover:bg-emerald-500/25 text-emerald-400 border border-emerald-500/30 transition-colors cursor-pointer shadow-2xs`,title:`Accept this hunk (Shortcut: a)`,children:[(0,H.jsx)(wr,{size:12}),(0,H.jsx)(`span`,{children:`Accept (a)`})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>void me(),className:`inline-flex items-center gap-1 px-2.5 py-1 rounded text-xs font-semibold bg-rose-500/15 hover:bg-rose-500/25 text-rose-400 border border-rose-500/30 transition-colors cursor-pointer shadow-2xs`,title:`Reject this hunk (Shortcut: r)`,children:[(0,H.jsx)(Ei,{size:12}),(0,H.jsx)(`span`,{children:`Reject (r)`})]})]}),m&&(0,H.jsxs)(`button`,{type:`button`,onClick:he,className:`inline-flex items-center gap-1 px-2.5 py-1 rounded text-xs font-semibold bg-amber-500/15 hover:bg-amber-500/25 text-amber-400 border border-amber-500/30 transition-colors cursor-pointer shadow-2xs`,title:`Prepare refinement instructions in AI chat`,children:[(0,H.jsx)(li,{size:11}),(0,H.jsx)(`span`,{children:`Refine`})]})]})]}),A&&(0,H.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-xs p-4 animate-in fade-in`,children:(0,H.jsxs)(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-card p-4 shadow-2xl space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Xr,{size:16,className:`text-primary`}),(0,H.jsxs)(`h3`,{className:`text-xs font-bold text-foreground`,children:[`Request Refinement for Hunk #`,D+1]})]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>te(!1),className:`p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent`,children:(0,H.jsx)(Ei,{size:14})})]}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Add instructions for this hunk. They will open as a draft in AI chat for you to send:`}),(0,H.jsx)(`textarea`,{value:j,onChange:e=>M(e.target.value),placeholder:`e.g. Ensure null safety when calculating vacation debt...`,rows:3,autoFocus:!0,className:`w-full rounded-lg border border-border bg-background px-3 py-1.5 text-xs text-foreground placeholder:text-muted-foreground focus:outline-hidden focus:ring-1 focus:ring-primary resize-none`}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t border-border/60`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>te(!1),className:`px-3 py-1 text-xs text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg`,children:`Cancel`}),(0,H.jsx)(`button`,{type:`button`,disabled:!j.trim(),onClick:()=>void ge(),className:`px-3 py-1 text-xs font-semibold text-primary-foreground bg-primary hover:bg-primary/90 disabled:opacity-50 rounded-lg transition-colors`,children:`Open in AI chat`})]})]})})]})};function HC(e,t){let n=e.replaceAll(`\\`,`/`).replace(/^\.\//,``),r=n.startsWith(`/`)||/^[a-z]:\//i.test(n),i=/^[a-z]:\//i.test(n)||n.startsWith(`//`),a=[];for(let e of t)for(let t of e.files){let o=t.file.replaceAll(`\\`,`/`),s=`${e.repoName}/${o}`,c=`${e.repoPath.replaceAll(`\\`,`/`).replace(/\/$/,``)}/${o}`;(r?i?c.toLowerCase()===n.toLowerCase():c===n:n===o||n===s||o.endsWith(`/${n}`))&&a.push({repoName:e.repoName,repoPath:e.repoPath,file:t.file})}return a.length===1?{file:a[0]}:{error:a.length?`“${e}” matches more than one workspace file. Select it from the Files tree.`:`“${e}” is not in this workspace's file tree.`}}function UC({workspace:e,active:t,openReference:n,onClose:r}){let[i,a]=(0,V.useState)(`changes`),[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(``),[m,h]=(0,V.useState)(``),[g,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(0),[S,C]=(0,V.useState)(!1),w=(0,V.useRef)(0),T=(0,V.useRef)(null),E=(0,V.useRef)(``),D=`/api/workspace/${encodeURIComponent(e)}`;(0,V.useEffect)(()=>{n&&n.id!==w.current&&a(`files`)},[n]),(0,V.useEffect)(()=>{if(!t)return;let e=window.setInterval(()=>x(e=>e+1),1e4);return()=>window.clearInterval(e)},[t]),(0,V.useEffect)(()=>{if(!t)return;let e=!1;return y(!0),p(``),sr(`${D}/changes${i===`files`?`?include=all`:``}`).then(t=>{if(!e){if(s(e=>JSON.stringify(e)===JSON.stringify(t.changes)?e:t.changes),i===`files`&&n&&n.id!==w.current){w.current=n.id;let e=HC(n.path,t.changes);_(e.error??``),d(null),E.current=``,l(e.file?{...e.file,line:n.line}:null)}else l(e=>e&&t.changes.some(t=>t.repoName===e.repoName&&t.files.some(t=>t.file===e.file))?e:null)}}).catch(t=>{e||p(t.message)}).finally(()=>{e||y(!1)}),()=>{e=!0}},[D,i,b,t,n]),(0,V.useEffect)(()=>{if(!t||!c){d(null);return}let e=!1;h(``);let n=new URLSearchParams({repo:c.repoName,file:c.file});return sr(`${D}/changes/diff?${n}`).then(t=>{e||d(e=>e&&e.diff===t.diff&&e.fileContent===t.fileContent&&e.originalContent===t.originalContent?e:t)}).catch(t=>{e||h(t.message)}),()=>{e=!0}},[D,c,b,t]),(0,V.useEffect)(()=>{if(!c?.line||!u||u.diff||!T.current)return;let e=`${c.repoName}/${c.file}:${c.line}`;if(E.current===e)return;E.current=e;let t=Number.parseFloat(getComputedStyle(T.current).lineHeight)||16;T.current.parentElement?.scrollTo({top:Math.max(0,(c.line-1)*t-32)})},[c,u]);let ee=(0,V.useMemo)(()=>o.flatMap(e=>e.files.map(t=>({repoName:e.repoName,repoPath:e.repoPath,file:t.file}))),[o]),O=(0,V.useMemo)(()=>c?ee.findIndex(e=>e.repoName===c.repoName&&e.file===c.file):-1,[ee,c]),k=(0,V.useCallback)(()=>{if(O>=0&&O<ee.length-1){let e=ee[O+1];e&&(_(``),d(null),E.current=``,l(e))}},[O,ee]),A=(0,V.useCallback)(()=>{if(O>0){let e=ee[O-1];e&&(_(``),d(null),E.current=``,l(e))}},[O,ee]);return(0,H.jsxs)(`section`,{"aria-label":`Workspace code`,className:`flex h-full min-h-0 min-w-0 flex-col bg-background overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border p-2 bg-muted/20 shrink-0`,children:[(0,H.jsx)(`span`,{className:`mr-1 text-[11px] font-semibold text-foreground shrink-0`,children:`ContextSpace code`}),(0,H.jsx)(yn,{size:`xs`,variant:i===`changes`?`secondary`:`ghost`,"aria-pressed":i===`changes`,onClick:()=>a(`changes`),children:`Changes`}),(0,H.jsx)(yn,{size:`xs`,variant:i===`files`?`secondary`:`ghost`,"aria-pressed":i===`files`,onClick:()=>a(`files`),children:`Files`}),(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,"aria-label":`Refresh code`,onClick:()=>x(e=>e+1),disabled:v,children:(0,H.jsx)(li,{className:B(`size-3`,v&&`animate-spin`)})}),(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,className:`p-1 size-6 shrink-0`,title:S?`Show file tree sidebar`:`Hide file tree sidebar`,"aria-label":S?`Show file tree sidebar`:`Hide file tree sidebar`,onClick:()=>C(e=>!e),children:S?(0,H.jsx)(ri,{className:`size-3.5 text-muted-foreground`}):(0,H.jsx)(ti,{className:`size-3.5 text-muted-foreground`})}),(0,H.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground font-mono shrink-0`,children:v?`Refreshing…`:`${o.reduce((e,t)=>e+t.files.length,0)} files`}),r&&(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,className:`p-1 size-6 shrink-0 ml-1`,title:`Close code panel`,onClick:r,children:(0,H.jsx)(Ei,{className:`size-3.5 text-muted-foreground`})})]}),f&&(0,H.jsxs)(`p`,{role:`alert`,className:`p-2 text-xs text-destructive shrink-0 border-b border-border`,children:[f,` `,(0,H.jsx)(`button`,{className:`underline`,onClick:()=>x(e=>e+1),children:`Retry`})]}),g&&(0,H.jsx)(`p`,{role:`alert`,className:`p-2 text-xs text-destructive shrink-0 border-b border-border`,children:g}),(0,H.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 flex flex-row overflow-hidden`,children:[(0,H.jsx)(`aside`,{className:B(`flex flex-col border-r border-border shrink-0 bg-muted/10 overflow-hidden select-text`,S?`w-0 border-r-0`:`w-[32%] min-w-[115px] max-w-[240px] transition-[width] duration-150`),children:(0,H.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-2`,children:[o.map(e=>(0,H.jsxs)(`details`,{open:!0,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer py-1 text-xs font-semibold select-none`,children:e.repoName}),e.error?(0,H.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:e.error}):(0,H.jsx)(aC,{label:`${e.repoName} ${i}`,files:e.files,revealPath:c?.repoName===e.repoName?c.file:void 0,renderFile:t=>(0,H.jsxs)(`button`,{className:B(`flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-xs hover:bg-accent transition-colors cursor-pointer`,c?.repoName===e.repoName&&c.file===t.file&&`bg-accent font-medium text-foreground`),"aria-pressed":c?.repoName===e.repoName&&c.file===t.file,title:t.file,onClick:()=>{c?.repoName===e.repoName&&c.file===t.file&&!c.line||(_(``),d(null),E.current=``,l({repoName:e.repoName,repoPath:e.repoPath,file:t.file}))},children:[(0,H.jsx)(Fr,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`truncate`,children:t.file.split(`/`).at(-1)}),t.type!==`unchanged`&&(0,H.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground font-mono`,children:t.type})]})})]},e.repoName)),!v&&!f&&!o.some(e=>e.files.length||e.error)&&(0,H.jsx)(`p`,{className:`p-2 text-xs text-muted-foreground`,children:i===`changes`?`No uncommitted changes.`:`No repository files.`})]})}),(0,H.jsxs)(`main`,{className:`flex-1 min-w-0 min-h-0 flex flex-col bg-background overflow-hidden select-text`,children:[c?(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/10 px-2 py-1 shrink-0`,children:[(0,H.jsxs)(`p`,{className:`break-all font-mono text-xs font-semibold text-foreground`,children:[c.repoName,`/`,c.file,c.line?`:${c.line}`:``]}),i===`changes`&&ee.length>1&&(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 ml-2`,children:[(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,disabled:O<=0,onClick:A,title:`Previous changed file`,className:`h-5 px-1 text-[10px]`,children:(0,H.jsx)(Tr,{className:`size-3`})}),(0,H.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:[O+1,`/`,ee.length]}),(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,disabled:O>=ee.length-1,onClick:k,title:`Next changed file`,className:`h-5 px-1 text-[10px]`,children:(0,H.jsx)(Er,{className:`size-3`})})]})]}):(0,H.jsx)(`div`,{className:`border-b border-border bg-muted/10 p-2 shrink-0`,children:(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Select a file`})}),(0,H.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 flex flex-col overflow-hidden`,children:c?m?(0,H.jsxs)(`p`,{role:`alert`,className:`p-3 text-xs text-destructive`,children:[m,` `,(0,H.jsx)(`button`,{className:`underline`,onClick:()=>x(e=>e+1),children:`Retry`})]}):u?u.diff?(0,H.jsx)(oC,{children:(0,H.jsx)(VC,{filePath:c.file,repoName:c.repoName,repoPath:c.repoPath,patchText:u.diff,fullFileContent:u.fileContent,fullOriginalContent:u.originalContent,initialTargetLine:c.line,viewMode:`unified`,fillContainer:!0,onNextFile:k,onPrevFile:A})},`${e}/${c.repoName}/${c.file}`):(0,H.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`px-3 py-1 border-b border-border/40 bg-muted/10 text-[11px] text-muted-foreground flex items-center justify-between shrink-0`,children:[(0,H.jsx)(`span`,{children:`Clean file (no uncommitted diff)`}),c.line&&(0,H.jsxs)(`span`,{className:`font-mono text-primary font-medium`,children:[`Line `,c.line]})]}),(0,H.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,H.jsx)(`pre`,{ref:T,className:`p-3 font-mono text-xs whitespace-pre leading-relaxed select-text`,children:u.fileContent||`Empty file or no text content.`})})]}):(0,H.jsx)(`p`,{role:`status`,className:`p-3 text-xs text-muted-foreground`,children:`Loading file…`}):(0,H.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center p-6 text-center text-muted-foreground gap-2`,children:[(0,H.jsx)(Fr,{className:`size-8 opacity-35`}),(0,H.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:`Select a file to inspect its code and changes alongside the CLI chat.`})]})})]})]})]})}var WC=Object.defineProperty,GC=Object.getOwnPropertyDescriptor,KC=(e,t)=>{for(var n in t)WC(e,n,{get:t[n],enumerable:!0})},qC=(e,t,n,r)=>{for(var i=r>1?void 0:r?GC(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&WC(t,n,i),i},JC=(e,t)=>(n,r)=>t(n,r,e),YC=`Terminal input`,XC={get:()=>YC,set:e=>YC=e},ZC=`Too much output to announce, navigate to rows manually to read`,QC={get:()=>ZC,set:e=>ZC=e};function $C(e){return e.replace(/\r?\n/g,`\r`)}function ew(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function tw(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function nw(e,t,n,r){e.stopPropagation(),e.clipboardData&&rw(e.clipboardData.getData(`text/plain`),t,n,r)}function rw(e,t,n,r){e=$C(e),e=ew(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function iw(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function aw(e,t,n,r,i){iw(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function ow(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function sw(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var cw=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},lw=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},uw=``,dw=` `,fw=class e{constructor(){this.fg=0,this.bg=0,this.extended=new pw}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},pw=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},mw=class e extends fw{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new pw,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ow(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},hw=`di$target`,gw=`di$dependencies`,_w=new Map;function vw(e){return e[gw]||[]}function yw(e){if(_w.has(e))return _w.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);bw(t,e,r)};return t._id=e,_w.set(e,t),t}function bw(e,t,n){t[hw]===t?t[gw].push({id:e,index:n}):(t[gw]=[{id:e,index:n}],t[hw]=t)}var xw=yw(`BufferService`),Sw=yw(`CoreMouseService`),Cw=yw(`CoreService`),ww=yw(`CharsetService`),Tw=yw(`InstantiationService`),Ew=yw(`LogService`),Dw=yw(`OptionsService`),Ow=yw(`OscLinkService`),kw=yw(`UnicodeService`),Aw=yw(`DecorationService`),jw=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new mw,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Mw(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};jw=qC([JC(0,xw),JC(1,Dw),JC(2,Ow)],jw);function Mw(e,t){if(confirm(`Do you want to navigate to ${t}?
43
43
 
44
44
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Nw=yw(`CharSizeService`),Pw=yw(`CoreBrowserService`),Fw=yw(`MouseService`),Iw=yw(`RenderService`),Lw=yw(`SelectionService`),Rw=yw(`CharacterJoinerService`),zw=yw(`ThemeService`),Bw=yw(`LinkProviderService`),Vw=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?qw.isErrorNoTelemetry(e)?new qw(e.message+`
45
45
 
@@ -60,12 +60,12 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
60
60
 
61
61
  `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function Kj(e){Jj(e)||Gj.onUnexpectedError(e)}var qj=`Canceled`;function Jj(e){return e instanceof Yj||e instanceof Error&&e.name===qj&&e.message===qj}var Yj=class extends Error{constructor(){super(qj),this.name=this.message}},Xj=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},Zj;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Zj||={});var Qj=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||Zj.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};Qj.empty=new Qj(e=>{});function $j(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var eM;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(eM||={});var tM=null;function nM(e){return tM?.trackDisposable(e),e}function rM(e){tM?.markAsDisposed(e)}function iM(e,t){tM?.setParent(e,t)}function aM(e){if(eM.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function oM(...e){return sM(()=>aM(e))}function sM(e){let t=nM({dispose:$j(()=>{rM(t),e()})});return t}var cM=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,nM(this)}dispose(){this._isDisposed||(rM(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{aM(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return iM(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),iM(e,null))}};cM.DISABLE_DISPOSED_WARNING=!1;var lM=cM,uM=class{constructor(){this._store=new lM,nM(this),iM(this._store,this)}dispose(){rM(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};uM.None=Object.freeze({dispose(){}});var dM=class{constructor(){this._isDisposed=!1,nM(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&iM(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,rM(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&iM(e,null),e}},fM=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};fM.Undefined=new fM(void 0);var pM=globalThis.performance&&typeof globalThis.performance.now==`function`,mM=class e{static create(t){return new e(t)}constructor(e){this._now=pM&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},hM;(e=>{e.None=()=>uM.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(oM(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new DM({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new DM({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new DM({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new DM({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new DM({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new DM;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new DM(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof lM?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(hM||={});var gM=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new mM,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};gM.all=new Set,gM._idPool=0;var _M=gM,vM=-1,yM=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new SM(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};yM._idPool=1;var bM=yM,xM=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
62
62
  `).slice(2).join(`
63
- `))}},SM=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},CM=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},wM=0,TM=class{constructor(e){this.value=e,this.id=wM++}},EM=2,DM=class{constructor(e){this._size=0,this._options=e,this._leakageMon=vM>0||this._options?.leakWarningThreshold?new bM(e?.onListenerError??Kj,this._options?.leakWarningThreshold??vM):void 0,this._perfMon=this._options?._profName?new _M(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new CM(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Kj)(n),uM.None}if(this._disposed)return uM.None;t&&(e=e.bind(t));let r=new TM(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=xM.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof TM?(this._deliveryQueue??=new OM,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=sM(()=>{i?.(),this._removeListener(r)});return n instanceof lM?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*EM<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||Kj;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners){if(this._listeners instanceof TM)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}}this._perfMon?.stop()}hasListeners(){return this._size>0}},OM=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},kM=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),AM;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof jM?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:hM.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:kM})})(AM||={});var jM=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?kM:(this._emitter||=new DM,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},MM=`en`,NM=!1,PM=!1,FM=MM,IM,LM=globalThis,RM;typeof LM.vscode<`u`&&typeof LM.vscode.process<`u`?RM=LM.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(RM=process);var zM=typeof RM?.versions?.electron==`string`&&RM?.type===`renderer`;if(typeof RM==`object`){RM.platform,RM.platform,NM=RM.platform===`linux`,NM&&RM.env.SNAP&&RM.env.SNAP_REVISION,RM.env.CI||RM.env.BUILD_ARTIFACTSTAGINGDIRECTORY,FM=MM;let e=RM.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,FM=t.resolvedLanguage||MM,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!zM?(IM=navigator.userAgent,IM.indexOf(`Windows`),IM.indexOf(`Macintosh`),(IM.indexOf(`Macintosh`)>=0||IM.indexOf(`iPad`)>=0||IM.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,NM=IM.indexOf(`Linux`)>=0,IM?.indexOf(`Mobi`),PM=!0,FM=globalThis._VSCODE_NLS_LANGUAGE||MM,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);PM&&typeof LM.importScripts==`function`&&LM.origin;var BM=IM,VM=FM,HM;(e=>{function t(){return VM}e.value=t;function n(){return VM.length===2?VM===`en`:VM.length>=3&&VM[0]===`e`&&VM[1]===`n`&&VM[2]===`-`}e.isDefaultVariant=n;function r(){return VM===`en`}e.isDefault=r})(HM||={});var UM=typeof LM.postMessage==`function`&&!LM.importScripts;(()=>{if(UM){let e=[];LM.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),LM.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var WM=!!(BM&&BM.indexOf(`Chrome`)>=0);BM&&BM.indexOf(`Firefox`),!WM&&BM&&BM.indexOf(`Safari`),BM&&BM.indexOf(`Edg/`),BM&&BM.indexOf(`Android`);function GM(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=sM(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var KM;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(KM||={});var qM=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new DM,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await hM.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};qM.EMPTY=qM.fromArray([]);var JM=class extends uM{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new dM),this._linesCacheDisposables=this._register(new dM),this._register(sM(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=oM(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=GM(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let n=[],r=[0],i=this._terminal.buffer.active.getLine(e);for(;i;){let a=this._terminal.buffer.active.getLine(e+1),o=a?a.isWrapped:!1,s=i.translateToString(!o&&t);if(o&&a){let e=i.getCell(i.length-1);e&&e.getCode()===0&&e.getWidth()===1&&a.getCell(0)?.getWidth()===2&&(s=s.slice(0,-1))}if(n.push(s),o)r.push(r[r.length-1]+s.length);else break;e++,i=a}return[n.join(``),r]}},YM=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},XM=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,n,r){if(!e||e.length===0){this._terminal.clearSelection();return}if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let i={startRow:t,startCol:n},a=this._findInLine(e,i,r);if(!a)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(i.startRow=n,i.startCol=0,a=this._findInLine(e,i,r),!a);n++);return a}findNextWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=0,a=0;r&&(n===e?(i=r.end.x,a=r.end.y):(i=r.start.x,a=r.start.y)),this._lineCache.initLinesCache();let o={startRow:a,startCol:i},s=this._findInLine(e,o,t);if(!s)for(let n=a+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);if(!s&&a!==0)for(let n=0;n<a&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);return!s&&r&&(o.startRow=r.start.y,o.startCol=0,s=this._findInLine(e,o,t)),s}findPreviousWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=this._terminal.buffer.active.baseY+this._terminal.rows-1,a=this._terminal.cols;this._lineCache.initLinesCache();let o={startRow:i,startCol:a},s;if(r&&(o.startRow=i=r.start.y,o.startCol=a=r.start.x,n!==e&&(s=this._findInLine(e,o,t,!1),s||(o.startRow=i=r.end.y,o.startCol=a=r.end.x))),s||=this._findInLine(e,o,t,!0),!s){o.startCol=Math.max(o.startCol,this._terminal.cols);for(let n=i-1;n>=0&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);}if(!s&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=i&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);return s}_isWholeWord(e,t,n){return(e===0||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e-1]))&&(e+n.length===t.length||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=t.startRow,a=t.startCol;if(this._terminal.buffer.active.getLine(i)?.isWrapped){if(r){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,n)}let o=this._lineCache.getLineFromCache(i);o||(o=this._lineCache.translateBufferLineToStringWithWrap(i,!0),this._lineCache.setLineInCache(i,o));let[s,c]=o,l=this._bufferColsToStringOffset(i,a),u=e,d=s;n.regex||(u=n.caseSensitive?e:e.toLowerCase(),d=n.caseSensitive?s:s.toLowerCase());let f=-1;if(n.regex){let t=RegExp(u,n.caseSensitive?`g`:`gi`),i;if(r)for(;i=t.exec(d.slice(0,l));)f=t.lastIndex-i[0].length,e=i[0],t.lastIndex-=e.length-1;else i=t.exec(d.slice(l)),i&&i[0].length>0&&(f=l+(t.lastIndex-i[0].length),e=i[0])}else r?l-u.length>=0&&(f=d.lastIndexOf(u,l-u.length)):f=d.indexOf(u,l);if(f>=0){if(n.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<c.length-1&&f>=c[t+1];)t++;let r=t;for(;r<c.length-1&&f+e.length>=c[r+1];)r++;let a=f-c[t],o=f+e.length-c[r],s=this._stringLengthToBufferSize(i+t,a),l=this._stringLengthToBufferSize(i+r,o)-s+this._terminal.cols*(r-t);return{term:e,col:s,row:i+t,size:l}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e<t;e++){let r=n.getCell(e);if(!r)break;let i=r.getChars();i.length>1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=e,r=0,i=this._terminal.buffer.active.getLine(n);for(;t>0&&i;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=i.getCell(e);if(!t)break;t.getWidth()&&(r+=t.getCode()===0?1:t.getChars().length)}if(n++,i=this._terminal.buffer.active.getLine(n),i&&!i.isWrapped)break;t-=this._terminal.cols}return r}},ZM=class extends uM{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(sM(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let n of e){let e=this._createResultDecorations(n,t,!1);if(e)for(let t of e)this._storeDecoration(t,n)}}createActiveDecoration(e,t){let n=this._createResultDecorations(e,t,!0);if(n)return{decorations:n,match:e,dispose(){aM(n)}}}clearHighlightDecorations(){aM(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecorations(e,t,n){let r=[],i=e.col,a=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;a>0;){let e=Math.min(this._terminal.cols-i,a);r.push([o,i,e]),i=0,a-=e,o++}let s=[];for(let e of r){let r=this._terminal.registerMarker(e[0]),i=this._terminal.registerDecoration({marker:r,x:e[1],width:e[2],backgroundColor:n?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:n?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:`center`}});if(i){let e=[];e.push(r),e.push(i.onRender(e=>this._applyStyles(e,n?t.activeMatchBorder:t.matchBorder,!1))),e.push(i.onDispose(()=>aM(e))),s.push(i)}}return s.length===0?void 0:s}},QM=class extends uM{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new DM)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&=(this._selectedDecoration.dispose(),void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let n=this._searchResults[t];if(n.row===e.row&&n.col===e.col&&n.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},$M=class extends uM{constructor(e){super(),this._highlightTimeout=this._register(new dM),this._lineCache=this._register(new dM),this._state=new YM,this._resultTracker=this._register(new QM),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new JM(e),this._engine=new XM(e,this._lineCache.value),this._decorationManager=new ZM(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(sM(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=GM(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error(`Cannot use addon until it has been loaded`);if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],r,i=this._engine.find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._engine.find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);this._resultTracker.updateResults(n,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(n,t.decorations)}_findNextAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}findPrevious(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}_selectResult(e,t,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let n=this._decorationManager.createActiveDecoration(e,t);n&&(this._resultTracker.selectedDecoration=n)}if(!n&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}},eN=e=>({codex:`Codex`,antigravity:`Antigravity (agy)`,claude:`Claude Code`,copilot:`GitHub Copilot`,cursor:`Cursor Agent`,pi:`Pi`,shell:`Shell`})[e]??e;function tN({harness:e,className:t=`size-4`}){if(e===`antigravity`)return(0,H.jsx)(Vn,{className:t,alt:``,"aria-hidden":`true`});let n={codex:Hn,claude:zn,copilot:Wn,cursor:Un,pi:ai}[e]??_i;return(0,H.jsx)(n,{className:t,"aria-hidden":`true`})}function nN(e){let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function rN(e){return e.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function iN({session:e}){let t=nN(e.updatedAt),n=nN(e.createdAt);return(0,H.jsxs)(`span`,{className:`inline-flex flex-wrap gap-x-2 gap-y-0.5`,children:[(0,H.jsx)(`span`,{title:t?`Latest recorded activity: ${t.toLocaleString()} (${Intl.DateTimeFormat().resolvedOptions().timeZone}). May include tool or provider events.`:`This harness history has no valid activity timestamp.`,children:t?(0,H.jsxs)(H.Fragment,{children:[`Last activity `,(0,H.jsx)(`time`,{dateTime:t.toISOString(),children:rN(t)})]}):`Last activity unknown`}),n&&(0,H.jsxs)(`span`,{className:`text-muted-foreground`,title:`First recorded activity: ${n.toLocaleString()}`,children:[`Started `,(0,H.jsx)(`time`,{dateTime:n.toISOString(),children:rN(n)})]})]})}function aN({session:e}){let t=e.threadKind===`subagent`,n=t?zr:Xr;return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground`,title:t?`A delegated agent task. Resume its main conversation to continue your work.`:e.threadKind===`main`?`The main conversation you work in. It may delegate tasks to subagents.`:`The harness has not provided a main/subagent classification.`,children:[(0,H.jsx)(n,{className:`size-3`,"aria-hidden":`true`}),t?`Subagent`:e.threadKind===`main`?`Main thread`:`Conversation`]})}function oN(e,t){let n=e,r=new Set;for(;n?.threadKind===`subagent`;){if(!n.parentSessionId||r.has(n.id))return;r.add(n.id);let i=n.parentSessionId;n=t.find(t=>t.assistant===e.assistant&&t.id===i)}return n}function sN({workspace:e,active:t,busy:n,status:r,onResume:i}){let[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(!1),l=on({queryKey:[`terminal-resume-sessions`,e],queryFn:()=>sr(`/api/workspace/${encodeURIComponent(e)}/sessions`),enabled:t,staleTime:15e3}),u=l.data?.sessions??[],d=u.filter(e=>e.threadKind===`subagent`).length,f=u.filter(e=>(s||e.threadKind!==`subagent`)&&`${e.title} ${eN(e.assistant)} ${e.id}`.toLowerCase().includes(a.toLowerCase()));return(0,H.jsxs)(`section`,{"aria-label":`Resume a conversation`,className:`min-h-0 overflow-auto border-b border-border bg-card p-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,H.jsx)(ui,{className:`size-4`}),`Resume a conversation`]}),(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,"aria-label":`Refresh saved sessions`,onClick:()=>void l.refetch(),children:(0,H.jsx)(li,{className:`size-3`})})]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Pick up a session from the Sessions tab. It opens with the harness that created it.`}),(0,H.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`The main thread is your conversation. Subagents handle delegated tasks and report back to it. Older histories may not identify the thread type.`}),(0,H.jsxs)(`div`,{className:`my-2 flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`input`,{"aria-label":`Search saved sessions`,placeholder:`Search conversations or harnesses`,className:`min-w-40 flex-1 rounded border border-border bg-background px-2 py-1 text-xs`,value:a,onChange:e=>o(e.target.value)}),(0,H.jsxs)(`label`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),`Include subagent sessions`,d>0?` (${d})`:``]})]}),l.isLoading&&(0,H.jsx)(`p`,{className:`py-3 text-xs text-muted-foreground`,children:`Loading saved conversations…`}),l.error&&(0,H.jsx)(`p`,{role:`alert`,className:`py-3 text-xs text-destructive`,children:`Could not load sessions. Use Refresh to try again.`}),!l.isLoading&&!l.error&&f.length===0&&(0,H.jsx)(`p`,{className:`py-3 text-xs text-muted-foreground`,children:a?`No matching conversations.`:d&&!s?`Only subagent sessions were found. Include them to inspect their parent links.`:`No saved conversations found for this workspace. Choose a harness above to start one.`}),(0,H.jsx)(`div`,{className:`max-h-72 divide-y divide-border`,children:f.map(e=>{let t=oN(e,u),a=!!r?.available&&!!r.targets.find(t=>t.id===e.assistant)?.available;return(0,H.jsxs)(`div`,{className:`flex items-center gap-2 py-2`,"data-testid":`resume-session-row`,children:[(0,H.jsx)(tN,{harness:e.assistant,className:`size-5 shrink-0`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate text-xs font-medium`,title:e.title,children:e.title}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:eN(e.assistant)}),(0,H.jsx)(aN,{session:e}),(0,H.jsx)(iN,{session:e}),(0,H.jsxs)(`span`,{children:[e.messageCount,` messages`]}),(0,H.jsx)(`span`,{className:`font-mono`,children:e.id.slice(0,8)})]})]}),(0,H.jsxs)(yn,{size:`xs`,variant:`outline`,disabled:n||!a||!t,title:t?a?`Resume ${t.title} in ${eN(t.assistant)}`:`Install this harness, then refresh the harness list`:`Resume the main conversation from the harness`,onClick:()=>t&&i(t),children:[(0,H.jsx)(yr,{className:`size-3`}),e.threadKind===`subagent`?`Main thread`:`Resume`]})]},`${e.assistant}:${e.id}`)})})]})}var cN=``,lN,uN=0;async function dN(){return Date.now()>=uN&&(lN=void 0),lN||=(uN=Date.now()+24e4,fetch(`${cN}/api/terminals/bootstrap`,{method:`POST`,credentials:`include`,headers:{"x-contextspace-terminal":`bootstrap`}}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||`Could not connect to the local terminal service.`);return uN=Math.min(uN,Number(t.expiresAt)-5e3),t.token}).catch(e=>{throw lN=void 0,e})),lN}async function fN(e,t,n={}){for(let r=0;r<2;r++){let i=await dN(),a=await fetch(`${cN}/api/terminals/${encodeURIComponent(e)}/${t}`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,"x-contextspace-terminal":i},body:JSON.stringify(n)}),o=await a.json();if(a.status===403&&r===0){lN=void 0,uN=0;continue}if(!a.ok)throw Error(o.error||`Terminal request failed.`);return o}throw Error(`Terminal authorization expired. Reconnect.`)}function pN(){let e=new URL(`/ws/terminal`,window.location.origin);return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.toString()}function mN(e){let t=[];for(let n=0;n<e.length;){if(/\s/.test(e[n])){n++;continue}let r=n,i=null;for(;n<e.length;){let t=e[n];if(i&&t===i)i=null;else if(!i&&(t===`"`||t===`'`||t==="`")&&/^[([{]*$/.test(e.slice(r,n)))i=t;else if(/\s/.test(t)&&!i)break;n++}let a=e.slice(r,n),o=a.match(/^[('"`[{]*/)?.[0].length??0,s=a.slice(o);for(;/[,'"`\]};.!?)]$/.test(s)&&!/\(\d+(?:,\d+)?\)$/.test(s);)s=s.slice(0,-1);let c=s.match(/:(\d+)(?::\d+)?$/)??s.match(/\((\d+)(?:,\d+)?\)$/),l=Number(c?.[1]),u=Number.isSafeInteger(l)&&l>0?l:void 0,d=(c?s.slice(0,-c[0].length):s).replace(/['"`]$/,``);if(!d||/^(?:[a-z][a-z\d+.-]*:\/\/|mailto:)/i.test(d)||!/[/\\]/.test(d)&&!/^[^.:]+\.[a-z\d]{1,12}$/i.test(d)||/^(?:\.\.?[/\\])?$/.test(d))continue;let f=r+o;t.push({text:s,path:d,line:u,start:f,end:f+s.length})}return t}function hN({workspace:e,active:t,launch:n,consumeLaunch:r,onOpenFileReference:i,codeVisible:a}){let o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(null),[d,f]=(0,V.useState)(null),{harnesses:p,setHarness:m}=Mt(),h=p[e]??``,g=(0,V.useCallback)(t=>m(e,t),[e,m]),[_,v]=(0,V.useState)(!0);(0,V.useEffect)(()=>{a&&v(!1)},[a]);let[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(`Choose a harness or shell`),[C,w]=(0,V.useState)(``),[T,E]=(0,V.useState)(!1),[D,ee]=(0,V.useState)(0),[O,k]=(0,V.useState)(``),[A,te]=(0,V.useState)(!1),[j,M]=(0,V.useState)(null),N=(0,V.useRef)(``),ne=(0,V.useRef)(``),re=(0,V.useRef)(void 0),[ie,P]=(0,V.useState)(void 0),F=(0,V.useRef)(t),I=(0,V.useRef)(i);(0,V.useEffect)(()=>{F.current=t},[t]),(0,V.useEffect)(()=>{I.current=i},[i]);let L=(0,V.useCallback)(e=>{u.current?.readyState===WebSocket.OPEN&&u.current.send(JSON.stringify(e))},[]),ae=(0,V.useCallback)(async()=>{try{let t=await fN(e,`status`);f(t),b(e=>e??t.sessions.find(e=>e.state===`running`)??null),t.available||w(t.reason||`Native terminal support is unavailable.`)}catch(e){w(e.message)}},[e]);(0,V.useEffect)(()=>{ae()},[ae]),(0,V.useEffect)(()=>{y&&!h&&g(y.target)},[y,h,g]),(0,V.useEffect)(()=>{let e=window.setInterval(()=>{dN().catch(()=>{})},24e4);return()=>window.clearInterval(e)},[]),(0,V.useEffect)(()=>{if(!o.current)return;let e=new Vj({cursorBlink:!0,fontFamily:`"JetBrains Mono", monospace`,fontSize:13,scrollback:5e3,allowProposedApi:!1,theme:{background:`#111b18`,foreground:`#e1e9e4`,cursor:`#a3dbae`}}),t=new Wj,n=new $M;e.loadAddon(t),e.loadAddon(n),e.open(o.current);let r=o.current,i=e=>{(e.ctrlKey||e.metaKey)&&!e.altKey&&e.key.toLowerCase()===`v`&&e.stopPropagation()};r.addEventListener(`keydown`,i,!0);let a=t=>{let n=t.clipboardData;if(!n||n.getData(`text/plain`))return;let r=$S(n.getData(`text/html`));r.trim()?(t.preventDefault(),t.stopPropagation(),e.options.disableStdin||e.paste(r)):([...n.items].some(e=>e.type.startsWith(`image/`))||[...n.files].some(e=>e.type.startsWith(`image/`)))&&(t.preventDefault(),t.stopPropagation(),w(`The clipboard contains an image but no text. Use Chat to attach the image, or copy text and paste again.`))};r.addEventListener(`paste`,a,!0),e.attachCustomKeyEventHandler(t=>t.type===`keydown`?(t.ctrlKey||t.metaKey)&&t.key.toLowerCase()===`c`&&(t.shiftKey||e.hasSelection())?(t.preventDefault(),QS(e.getSelection()).then(e=>{w(e?``:`Select terminal output before copying, or check clipboard permissions.`)}),!1):!((t.ctrlKey||t.metaKey)&&t.key.toLowerCase()===`v`):!0);let u=e.registerLinkProvider({provideLinks(t,n){let r=e.buffer.active,i=t-1;for(;i>0&&r.getLine(i)?.isWrapped&&t-i<=20;)i--;if(r.getLine(i)?.isWrapped){n([]);return}let a=t-1;for(;r.getLine(a+1)?.isWrapped&&a-i<20;)a++;if(r.getLine(a+1)?.isWrapped){n([]);return}let o=[];for(let e=i;e<=a;e++){let t=r.getLine(e);if(!t){n([]);return}o.push({line:t,text:t.translateToString(e===a)})}let s=(t,n)=>{let r=0;for(let a=0;a<o.length;a++){let s=o[a].text.length;if(t<r+s||n&&t===r+s||a===o.length-1){let s=Math.max(0,t-r),c=0;for(;c<e.cols&&o[a].line.translateToString(!1,0,c).length<s;)c++;return{x:c+ +!n,y:i+a+1}}r+=s}return{x:1,y:i+1}};n(mN(o.map(e=>e.text).join(``)).map(e=>({text:e.text,range:{start:s(e.start,!1),end:s(e.end,!0)},activate:()=>I.current?.({path:e.path,line:e.line})})))}});s.current=e,c.current=t,l.current=n;let d=e.onData(t=>{if(!e.options.disableStdin)for(let e=0;e<t.length;){let n=Math.min(e+8192,t.length);n<t.length&&/[\uD800-\uDBFF]/.test(t[n-1])&&n--,L({type:`input`,data:t.slice(e,n)}),e=n}});e.options.disableStdin=!0;let f=e.onResize(({cols:t,rows:n})=>{e.options.disableStdin||L({type:`resize`,cols:Math.min(t,500),rows:Math.min(n,300)})}),p=new ResizeObserver(()=>{o.current?.clientWidth&&o.current?.clientHeight&&t.fit()});return p.observe(o.current),()=>{r.removeEventListener(`keydown`,i,!0),r.removeEventListener(`paste`,a,!0),p.disconnect(),u.dispose(),d.dispose(),f.dispose(),e.dispose(),s.current=null}},[L]),(0,V.useEffect)(()=>{if(!t||!y)return;let e=requestAnimationFrame(()=>{!F.current||!o.current?.getClientRects().length||(c.current?.fit(),s.current?.focus())});return()=>cancelAnimationFrame(e)},[t,y]),(0,V.useEffect)(()=>{s.current&&(s.current.options.screenReaderMode=A)},[A]),(0,V.useEffect)(()=>{if(!y)return;let t=!1,n,r=y.state===`exited`,i=s.current;if(i)return i.reset(),i.options.disableStdin=!0,S(`Connecting…`),dN().then(a=>{t||(n=new WebSocket(pN()),u.current=n,n.onopen=()=>n.send(JSON.stringify({type:`attach`,token:a,workspace:e,id:y.id})),n.onmessage=e=>{if(t)return;let a=JSON.parse(String(e.data));a.type===`ready`?(r=a.terminal.state===`exited`,w(a.truncated?`Earlier output was trimmed. This is a partial screen replay; use the harness redraw command if needed.`:``),S(`Restoring terminal…`)):a.type===`output`&&typeof a.data==`string`?i.write(a.data,()=>{!t&&n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify({type:`ack`,count:a.data.length}))}):a.type===`replayed`?i.write(``,()=>{t||(i.options.disableStdin=r,S(r?`Exited`:`Connected`),r||(c.current?.fit(),L({type:`resize`,cols:Math.min(i.cols,500),rows:Math.min(i.rows,300)}),F.current&&i.focus()))}):a.type===`exit`?(r=!0,i.options.disableStdin=!0,S(`Exited${a.exitCode==null?``:` (${a.exitCode})`}`),f(e=>e&&{...e,sessions:e.sessions.map(e=>e.id===y.id?{...e,state:`exited`}:e)})):a.type===`error`&&(w(a.message),i.options.disableStdin=!0)},n.onclose=()=>{t||(i.options.disableStdin=!0,S(r?`Exited`:`Disconnected · input paused`))},n.onerror=()=>{t||w(`Connection failed. Reconnect to the existing terminal; it may still be running.`)})}).catch(e=>{t||(w(e.message),S(`Disconnected · input paused`))}),()=>{t=!0,i.options.disableStdin=!0,n?.close(),u.current===n&&(u.current=null)}},[y?.id,D,e,L]);let R=(0,V.useCallback)(async t=>{re.current=t,P(t),E(!0),w(``),g(t.target);try{let{terminal:n}=await fN(e,`create`,{launchId:t.id,target:t.target,sessionId:t.sessionId,cwd:t.cwd});b(n),v(!1),await ae()}catch(e){w(e.message)}finally{E(!1)}},[e,ae,g]);(0,V.useEffect)(()=>{!n||ne.current===n.id||(ne.current=n.id,R(n).finally(()=>r(n.id)))},[n,R,r]);let oe=async()=>{if(!(!y||!window.confirm(`End this terminal and its running commands?`)))try{await fN(e,`${y.id}/stop`),await ae()}catch(e){w(e.message)}},z=async e=>{try{let t=e||s.current?.getSelection()||``;if(!t){w(`Select terminal output before copying.`);return}await QS(t)?w(``):w(`Could not copy terminal output. Check browser clipboard permissions.`)}finally{requestAnimationFrame(()=>s.current?.focus())}},se=async()=>{M(null);try{let e=await eC();if(!e)throw Error(`Clipboard has no text`);if(!s.current||s.current.options.disableStdin)throw Error(`Reconnect the terminal before pasting.`);s.current.paste(e),s.current.focus(),w(``)}catch{w(`No clipboard text was available. Focus the terminal and press Ctrl+V (or Cmd+V); attach image-only content in Chat.`)}},ce=async()=>{w(``);try{let t=re.current;await sr(`/api/workspace/${encodeURIComponent(e)}/terminal`,{method:`POST`,body:JSON.stringify({...h===`shell`?{}:{assistant:h},...t?.target===h?{sessionId:t.sessionId,cwd:t.cwd}:{}})})}catch(e){w(e.message)}};return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`terminal-pane`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border px-3 py-2`,children:[(0,H.jsxs)(jc,{value:h||null,onValueChange:e=>{typeof e==`string`&&g(e)},children:[(0,H.jsx)(Nc,{"aria-label":`CLI harness`,size:`sm`,className:`w-auto min-w-40 text-xs`,children:h?(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(tN,{harness:h}),eN(h)]}):`Choose a harness`}),(0,H.jsx)(Fc,{children:(d?.targets??[]).map(e=>(0,H.jsx)(Ic,{value:e.id,children:(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(tN,{harness:e.id}),eN(e.id),!e.available&&(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`· Not installed`})]})},e.id))})]}),(0,H.jsxs)(yn,{size:`xs`,onClick:()=>void R({id:crypto.randomUUID(),target:h}),disabled:T||!d?.available||!h||!d.targets.find(e=>e.id===h)?.available,children:[(0,H.jsx)(ci,{className:`size-3`}),T?`Starting…`:`Start session`]}),(0,H.jsxs)(yn,{size:`xs`,variant:_?`secondary`:`ghost`,"aria-pressed":_,onClick:()=>v(e=>!e),children:[(0,H.jsx)(ui,{className:`size-3`}),`Resume session`]}),(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,title:`Refresh installed harnesses`,onClick:()=>void ae(),children:[(0,H.jsx)(li,{className:`size-3`}),`Refresh`]}),(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,disabled:!h,onClick:()=>void ce(),children:[(0,H.jsx)(Bn,{className:`size-3`}),`External terminal`]}),y&&(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,onClick:()=>void oe(),children:[(0,H.jsx)(vi,{className:`size-3`}),`End session`]})]}),_&&(0,H.jsx)(sN,{workspace:e,active:t,busy:T,status:d,onResume:e=>void R({id:crypto.randomUUID(),target:e.assistant,sessionId:e.id,cwd:e.workspacePath})}),!!d?.sessions.length&&(0,H.jsx)(`div`,{className:`px-3 py-1 border-b border-border`,children:(0,H.jsxs)(`select`,{"aria-label":`Terminal sessions`,className:`max-w-full bg-card text-xs`,value:y?.id??``,onChange:e=>{let t=d.sessions.find(t=>t.id===e.target.value)??null;b(t),t&&g(t.target)},children:[(0,H.jsx)(`option`,{value:``,disabled:!0,children:`Select a terminal`}),d.sessions.map(e=>(0,H.jsxs)(`option`,{value:e.id,children:[e.label,` · `,e.state,` · `,e.id.slice(0,8)]},e.id))]})}),C&&(0,H.jsxs)(`div`,{role:`alert`,className:`border-b border-border px-3 py-2 text-xs text-amber-600 break-words`,children:[C,ie&&(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,disabled:T,onClick:()=>void R(ie),children:`Retry launch`})]}),y&&x.startsWith(`Disconnected`)&&(0,H.jsxs)(`div`,{"data-testid":`terminal-disconnected`,role:`alert`,className:`flex flex-wrap items-center gap-2 border-b border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-foreground`,children:[(0,H.jsx)(wi,{className:`size-4 shrink-0 text-amber-600`,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`strong`,{children:`CLI chat disconnected.`}),` Input is paused; the session may still be running.`]}),(0,H.jsxs)(yn,{size:`xs`,variant:`outline`,onClick:()=>ee(e=>e+1),children:[(0,H.jsx)(si,{className:`size-3`}),`Reconnect CLI`]})]}),!y&&(0,H.jsx)(`div`,{className:`flex-1 px-3 py-3 text-xs text-muted-foreground`,children:`Choose a harness for a new session, or resume a saved conversation above. The harness keeps its own login and permissions. Shell opens PowerShell or your Unix shell. Existing API conversations remain under Chat.`}),(0,H.jsxs)(`div`,{className:`relative min-h-0 flex-1 ${y?``:`hidden`}`,onPointerDownCapture:e=>{e.button===2&&(N.current=s.current?.getSelection()??``)},onContextMenu:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();M({x:Math.min(e.clientX-t.left,Math.max(0,t.width-150)),y:Math.min(e.clientY-t.top,Math.max(0,t.height-80))})},children:[(0,H.jsx)(`div`,{ref:o,className:`h-full overflow-hidden bg-[#111b18] p-2`,"aria-label":`Interactive CLI terminal`}),j&&(0,H.jsxs)(`div`,{className:`absolute z-20 min-w-36 rounded border border-border bg-card p-1 shadow-lg`,style:{left:j.x,top:j.y},role:`menu`,onKeyDown:e=>{e.key===`Escape`&&M(null)},children:[(0,H.jsx)(`button`,{role:`menuitem`,className:`block w-full rounded px-2 py-1 text-left text-xs hover:bg-accent`,onClick:()=>{M(null),z(N.current),N.current=``},children:`Copy selection`}),(0,H.jsx)(`button`,{role:`menuitem`,className:`block w-full rounded px-2 py-1 text-left text-xs hover:bg-accent`,onClick:()=>void se(),children:`Paste`})]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border px-3 py-1 text-xs`,children:[(0,H.jsx)(`span`,{role:`status`,children:x}),y&&(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,onClick:()=>ee(e=>e+1),children:[(0,H.jsx)(si,{className:`size-3`}),`Reconnect`]}),(0,H.jsx)(`input`,{"aria-label":`Search terminal output`,placeholder:`Search output`,className:`w-28 rounded border border-border bg-card px-1`,value:O,onChange:e=>k(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l.current?.findNext(O)}}),(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,onClick:()=>l.current?.findNext(O),children:[(0,H.jsx)(Ct,{className:`size-3`}),`Find`]}),(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,onClick:()=>void z(),children:[(0,H.jsx)(Mr,{className:`size-3`}),`Copy selection`]}),(0,H.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>te(e.target.checked)}),`Screen reader`]})]}),(0,H.jsxs)(`div`,{className:`truncate px-3 pb-1 text-[10px] text-muted-foreground`,title:y?.cwd,children:[`Local user permissions · `,y?.cwd??e,` · Hide keeps running; End session stops it.`]})]})}function gN(e){let[t,n]=(0,V.useState)(!1),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(50),[l,u]=(0,V.useState)(!1),d=(0,V.useRef)(null),f=(0,V.useCallback)(e=>{if(e.button!==0)return;let t=d.current;if(!t)return;let n=e.currentTarget;n.setPointerCapture(e.pointerId),u(!0);let r=e=>{let n=t.getBoundingClientRect();if(n.width<=0)return;let r=(e.clientX-n.left)/n.width*100,i=Math.max(20,Math.min(85,100-r));c(Math.round(i)),o(!1)},i=e=>{u(!1);try{n.hasPointerCapture(e.pointerId)&&n.releasePointerCapture(e.pointerId)}catch{}n.removeEventListener(`pointermove`,r),n.removeEventListener(`pointerup`,i),n.removeEventListener(`pointercancel`,i)};n.addEventListener(`pointermove`,r),n.addEventListener(`pointerup`,i),n.addEventListener(`pointercancel`,i)},[]),p=a?`85%`:`${s}%`;return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-2 py-1 bg-muted/10`,children:[(0,H.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:`CLI chat`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t&&(0,H.jsxs)(yn,{size:`xs`,variant:a?`secondary`:`ghost`,onClick:()=>o(e=>!e),title:a?`Restore split view`:`Focus code view (expand width)`,"aria-label":a?`Split view`:`Expand code`,children:[a?(0,H.jsx)(Qr,{className:`size-3`}):(0,H.jsx)(Jr,{className:`size-3`}),a?`Split view`:`Expand code`]}),(0,H.jsxs)(yn,{size:`xs`,variant:t?`secondary`:`ghost`,"aria-pressed":t,onClick:()=>n(e=>!e),children:[(0,H.jsx)(Gr,{className:`size-3`}),t?`Hide code`:`Show code`]})]})]}),(0,H.jsxs)(`div`,{ref:d,className:`flex min-h-0 flex-1 flex-row relative`,children:[(0,H.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:(0,H.jsx)(hN,{...e,codeVisible:t,onOpenFileReference:e=>{i(t=>({...e,id:(t?.id??0)+1})),n(!0)}})}),t&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-valuenow":a?85:s,"aria-valuemin":20,"aria-valuemax":85,"aria-label":`Resize code panel`,onPointerDown:f,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),c(e=>Math.min(85,e+5)),o(!1)):e.key===`ArrowRight`&&(e.preventDefault(),c(e=>Math.max(20,e-5)),o(!1))},className:`w-2 hover:w-2.5 -mx-1 bg-border/60 hover:bg-primary/50 cursor-col-resize select-none flex items-center justify-center group focus-visible:outline-hidden focus-visible:bg-primary/70 z-20 transition-colors ${l?`bg-primary/60 w-2.5`:``}`,title:`Drag or use Left/Right arrow keys to resize code panel`,children:(0,H.jsx)(`div`,{className:`w-0.5 h-6 bg-muted-foreground/30 group-hover:bg-primary rounded`})}),(0,H.jsx)(`div`,{style:{width:p},className:`h-full min-h-0 min-w-0 border-l border-border ${l?``:`transition-[width] duration-150`}`,children:(0,H.jsx)(UC,{workspace:e.workspace,active:e.active,openReference:r,onClose:()=>n(!1)})})]})]})]})}function _N({className:e,size:t=`default`,unstyled:n=!1,...r}){return(0,H.jsx)(`span`,{className:B(!n&&`relative inline-flex w-full rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none has-focus-visible:ring-[3px] not-has-disabled:has-not-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] sm:text-sm dark:bg-input/32 dark:has-aria-invalid:ring-destructive/24 dark:not-has-disabled:has-not-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)]`,e)||void 0,"data-size":t,"data-slot":`textarea-control`,children:(0,H.jsx)(it,{render:e=>(0,H.jsx)(`textarea`,{className:B(`field-sizing-content min-h-17.5 w-full rounded-[inherit] px-[calc(--spacing(3)-1px)] py-[calc(--spacing(1.5)-1px)] outline-none max-sm:min-h-20.5 border-none bg-transparent resize-none h-full`,t===`sm`&&`min-h-16.5 px-[calc(--spacing(2.5)-1px)] py-[calc(--spacing(1)-1px)] max-sm:min-h-19.5`,t===`lg`&&`min-h-18.5 py-[calc(--spacing(2)-1px)] max-sm:min-h-21.5`),"data-slot":`textarea`,...gn(e,r)})})})}function vN(e){return e===`review`||e===`workspace-write`}var yN=e=>`${nr}${e}`,bN=e=>`${tr}${e}`,xN=()=>({v:4,sessions:{},providerId:null,profilesByProvider:{"claude-cli":`review`,"codex-cli":`review`},modelsByProvider:{},effortsByProvider:{},messages:[]});function SN(e){try{let t=localStorage.getItem(yN(e))||localStorage.getItem(bN(e));if(!t)return xN();let n=JSON.parse(t);if(Array.isArray(n))return{...xN(),messages:n.filter(e=>e&&typeof e.content==`string`&&(e.role===`user`||e.role===`assistant`)).map(e=>({role:e.role,content:e.content}))};if(n&&n.v===4&&n.sessions&&Array.isArray(n.messages)){let e=Object.fromEntries(Object.entries(n.profilesByProvider??{}).filter(e=>vN(e[1]))),t=typeof n.modelsByProvider==`object`&&n.modelsByProvider!==null?Object.fromEntries(Object.entries(n.modelsByProvider).filter(e=>typeof e[0]==`string`&&typeof e[1]==`string`)):{},r=typeof n.effortsByProvider==`object`&&n.effortsByProvider!==null?Object.fromEntries(Object.entries(n.effortsByProvider).filter(e=>typeof e[0]==`string`&&typeof e[1]==`string`)):{};return{...xN(),sessions:n.sessions,providerId:typeof n.providerId==`string`?n.providerId:null,profilesByProvider:{...xN().profilesByProvider,...e},modelsByProvider:t,effortsByProvider:r,messages:n.messages}}if(n&&n.v===3&&n.sessions&&Array.isArray(n.messages))return{...xN(),sessions:n.sessions,providerId:typeof n.providerId==`string`?n.providerId:null,messages:n.messages};if(n&&n.v===2&&Array.isArray(n.messages)){let e={};return typeof n.sessionId==`string`&&n.sessionId&&(e[`claude-cli`]={id:n.sessionId,started:!!n.sessionStarted}),{v:4,sessions:e,providerId:typeof n.providerId==`string`?n.providerId:null,profilesByProvider:xN().profilesByProvider,messages:n.messages}}return xN()}catch{return xN()}}var CN=500;async function wN(e){try{let t=await fetch(`/api/chat/thread/${encodeURIComponent(e)}`);if(!t.ok)return null;let n=await t.json();if(n&&n.thread){let e=n.thread;return{v:4,sessions:e.sessions||{},providerId:e.providerId||null,profilesByProvider:{...xN().profilesByProvider,...e.profilesByProvider||{}},modelsByProvider:e.modelsByProvider||{},effortsByProvider:e.effortsByProvider||{},messages:Array.isArray(e.messages)?e.messages:[],isBusy:!!n.isBusy}}return null}catch{return null}}async function TN(e,t){try{let n=t.messages.length>CN?{...t,messages:t.messages.slice(-500)}:t;await fetch(`/api/chat/thread/${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})}catch{}}async function EN(e){try{await fetch(`/api/chat/thread/${encodeURIComponent(e)}`,{method:`DELETE`})}catch{}}function DN(e,t){let n=t.messages.length>CN?{...t,messages:t.messages.slice(-500)}:t;try{localStorage.setItem(yN(e),JSON.stringify(n))}catch(t){try{let t={...n,messages:n.messages.map(e=>{let t={...e};return delete t.images,t})};localStorage.removeItem(yN(e)),localStorage.setItem(yN(e),JSON.stringify(t))}catch{console.error(`Failed to save chat to localStorage`,t)}}TN(e,n)}function ON(e){try{localStorage.removeItem(yN(e)),EN(e),localStorage.removeItem(bN(e))}catch{}}var kN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,AN=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[a-zA-Z0-9_\-.]{1,128})$/i,jN=new Set([`claude-cli`,`codex-cli`,`antigravity-cli`,`copilot-cli`]);function MN(e){return e===`claude`?`claude-cli`:e===`codex`?`codex-cli`:e===`antigravity`?`antigravity-cli`:e===`copilot`?`copilot-cli`:null}function NN(e){if(!e||typeof e!=`object`)return null;let t=e.chatLaunch;if(!t||typeof t!=`object`)return null;let n=t;return!kN.test(n.nonce??``)||!n.providerId||!jN.has(n.providerId)||!vN(n.executionProfile)||n.kickoff!==void 0&&(typeof n.kickoff!=`string`||n.kickoff.length>2e3)||n.model!==void 0&&(typeof n.model!=`string`||n.model.length>100)||n.assistant!==void 0&&MN(n.assistant)!==n.providerId||n.sessionId!==void 0&&(!AN.test(n.sessionId)||!n.assistant)?null:n}function PN({className:e,...t}){return(0,H.jsx)(`div`,{className:B(`flex min-w-0 flex-1 flex-col items-center justify-center gap-6 text-balance p-6 text-center md:p-12`,e),"data-slot":`empty`,...t})}function FN({className:e,...t}){return(0,H.jsx)(`div`,{className:B(`flex max-w-sm flex-col items-center text-center`,e),"data-slot":`empty-header`,...t})}var IN=hn(`flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,{defaultVariants:{variant:`default`},variants:{variant:{default:`bg-transparent`,icon:`relative flex size-9 shrink-0 items-center justify-center rounded-md border bg-card not-dark:bg-clip-padding text-foreground shadow-sm/5 before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-md)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)] [&_svg:not([class*='size-'])]:size-4.5`}}});function LN({className:e,variant:t=`default`,...n}){return(0,H.jsxs)(`div`,{className:B(`relative mb-6`,e),"data-slot":`empty-media`,"data-variant":t,...n,children:[t===`icon`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{"aria-hidden":`true`,className:B(IN({className:e,variant:t}),`-translate-x-0.5 -rotate-10 pointer-events-none absolute bottom-px origin-bottom-left scale-84 shadow-none`)}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:B(IN({className:e,variant:t}),`pointer-events-none absolute bottom-px origin-bottom-right translate-x-0.5 rotate-10 scale-84 shadow-none`)})]}),(0,H.jsx)(`div`,{className:B(IN({className:e,variant:t})),...n})]})}function RN({className:e,...t}){return(0,H.jsx)(`div`,{className:B(`font-heading font-semibold text-xl`,e),"data-slot":`empty-title`,...t})}function zN({className:e,...t}){return(0,H.jsx)(`div`,{className:B(`text-muted-foreground text-sm [&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4 [[data-slot=empty-title]+&]:mt-1`,e),"data-slot":`empty-description`,...t})}function BN({className:e,...t}){return(0,H.jsx)(`div`,{className:B(`animate-skeleton rounded-sm [--skeleton-highlight:--alpha(var(--color-white)/64%)] [background:linear-gradient(120deg,transparent_40%,var(--skeleton-highlight),transparent_60%)_var(--color-muted)_0_0/200%_100%_fixed] dark:[--skeleton-highlight:--alpha(var(--color-white)/4%)]`,e),"data-slot":`skeleton`,...t})}function VN({open:e,onClose:t,ws:n,onPick:r,error:i,pending:a=!1}){let[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(null);(0,V.useEffect)(()=>{e&&(l(!0),d(null),fetch(`/api/workspace/${encodeURIComponent(n.branchName)}/sessions`).then(e=>e.json()).then(e=>{let t=(e.sessions||[]).filter(e=>e.assistant===`claude`||e.assistant===`codex`||e.assistant===`antigravity`||e.assistant===`copilot`);s(t)}).catch(()=>d(`Failed to load sessions.`)).finally(()=>l(!1)))},[e,n.branchName]);let f=e=>{switch(e){case`codex`:return`Codex`;case`antigravity`:return`Antigravity`;case`copilot`:return`Copilot`;default:return`Claude`}};return(0,H.jsx)(Ov,{open:e,onOpenChange:e=>!e&&t(),children:(0,H.jsxs)(Mv,{className:`max-w-lg`,children:[(0,H.jsx)(Nv,{children:(0,H.jsx)(Fv,{children:`Resume a past session`})}),(0,H.jsxs)(Lv,{className:`flex max-h-[60vh] flex-col gap-2`,children:[(i||u)&&(0,H.jsx)(`div`,{className:`rounded-lg border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-foreground`,children:i||u}),c?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(BN,{className:`h-14`}),(0,H.jsx)(BN,{className:`h-14`}),(0,H.jsx)(BN,{className:`h-14`})]}):o.length===0?(0,H.jsx)(PN,{children:(0,H.jsxs)(FN,{children:[(0,H.jsx)(LN,{variant:`icon`,children:(0,H.jsx)(ui,{})}),(0,H.jsx)(RN,{children:`No resumable sessions found`}),(0,H.jsx)(zN,{children:`Past conversations for this workspace will show up here.`})]})}):o.map(e=>(0,H.jsxs)(`button`,{onClick:()=>r(e),disabled:a,className:`cursor-pointer rounded-lg border border-border bg-card p-3 text-left transition-colors hover:border-foreground/15 hover:bg-accent/50 disabled:cursor-wait disabled:opacity-60`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground`,children:f(e.assistant)}),(0,H.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,title:e.title,children:e.title})]}),(0,H.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:a?`Loading transcript…`:new Date(e.updatedAt).toLocaleString()}),(0,H.jsx)(`span`,{children:`·`}),(0,H.jsx)(Xr,{size:11}),(0,H.jsxs)(`span`,{children:[e.messageCount,` messages`]})]})]},e.id))]})]})})}var HN=n(((e,t)=>{var n=[[{color:`0, 0, 0`,class:`ansi-black`},{color:`187, 0, 0`,class:`ansi-red`},{color:`0, 187, 0`,class:`ansi-green`},{color:`187, 187, 0`,class:`ansi-yellow`},{color:`0, 0, 187`,class:`ansi-blue`},{color:`187, 0, 187`,class:`ansi-magenta`},{color:`0, 187, 187`,class:`ansi-cyan`},{color:`255,255,255`,class:`ansi-white`}],[{color:`85, 85, 85`,class:`ansi-bright-black`},{color:`255, 85, 85`,class:`ansi-bright-red`},{color:`0, 255, 0`,class:`ansi-bright-green`},{color:`255, 255, 85`,class:`ansi-bright-yellow`},{color:`85, 85, 255`,class:`ansi-bright-blue`},{color:`255, 85, 255`,class:`ansi-bright-magenta`},{color:`85, 255, 255`,class:`ansi-bright-cyan`},{color:`255, 255, 255`,class:`ansi-bright-white`}]],r=/(https?:\/\/(?:[A-Za-z0-9#;/?:@=+$',_.!~*()[\]-]|&amp;|%[A-Fa-f0-9]{2})+)/gm;t.exports=class e{static escapeForHtml(t){return new e().escapeForHtml(t)}static linkify(t){return new e().linkify(t)}static ansiToHtml(t,n){return new e().ansiToHtml(t,n)}static ansiToJson(t,n){return new e().ansiToJson(t,n)}static ansiToText(t){return new e().ansiToText(t)}constructor(){this.fg=this.bg=this.fg_truecolor=this.bg_truecolor=null,this.bright=0,this.decorations=[]}setupPalette(){this.PALETTE_COLORS=[];for(let e=0;e<2;++e)for(let t=0;t<8;++t)this.PALETTE_COLORS.push(n[e][t].color);let e=[0,95,135,175,215,255],t=(t,n,r)=>e[t]+`, `+e[n]+`, `+e[r];for(let e=0;e<6;++e)for(let n=0;n<6;++n)for(let r=0;r<6;++r)this.PALETTE_COLORS.push(t(e,n,r));let r=8;for(let e=0;e<24;++e,r+=10)this.PALETTE_COLORS.push(r+`, `+r+`, `+r)}escapeForHtml(e){return e.replace(/[&<>\"]/gm,e=>e==`&`?`&amp;`:e==`"`?`&quot;`:e==`<`?`&lt;`:e==`>`?`&gt;`:``)}linkify(e){return e.replace(r,e=>`<a href="${e}">${e}</a>`)}ansiToHtml(e,t){return this.process(e,t,!0)}ansiToJson(e,t){return t||={},t.json=!0,t.clearLine=!1,this.process(e,t,!0)}ansiToText(e){return this.process(e,{},!1)}process(e,t,n){let r=this,i=e.split(/\033\[/),a=i.shift();t??={},t.clearLine=/\r/.test(e);let o=i.map(e=>this.processChunk(e,t,n));if(t&&t.json){let e=r.processChunkJson(``);return e.content=a,e.clearLine=t.clearLine,o.unshift(e),t.remove_empty&&(o=o.filter(e=>!e.isEmpty())),o}return o.unshift(a),o.join(``)}processChunkJson(e,t,r){t=t===void 0?{}:t;let i=t.use_classes=t.use_classes!==void 0&&t.use_classes,a=t.key=i?`class`:`color`,o={content:e,fg:null,bg:null,fg_truecolor:null,bg_truecolor:null,isInverted:!1,clearLine:t.clearLine,decoration:null,decorations:[],was_processed:!1,isEmpty:()=>!o.content},s=e.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);if(!s)return o;o.content=s[4];let c=s[2].split(`;`);if(s[1]!==``||s[3]!==`m`||!r)return o;let l=this;for(;c.length>0;){let e=c.shift(),t=parseInt(e);if(isNaN(t)||t===0)l.fg=l.bg=null,l.decorations=[];else if(t===1)l.decorations.push(`bold`);else if(t===2)l.decorations.push(`dim`);else if(t===3)l.decorations.push(`italic`);else if(t===4)l.decorations.push(`underline`);else if(t===5)l.decorations.push(`blink`);else if(t===7)l.decorations.push(`reverse`);else if(t===8)l.decorations.push(`hidden`);else if(t===9)l.decorations.push(`strikethrough`);else if(t===21)l.removeDecoration(`bold`);else if(t===22)l.removeDecoration(`bold`),l.removeDecoration(`dim`);else if(t===23)l.removeDecoration(`italic`);else if(t===24)l.removeDecoration(`underline`);else if(t===25)l.removeDecoration(`blink`);else if(t===27)l.removeDecoration(`reverse`);else if(t===28)l.removeDecoration(`hidden`);else if(t===29)l.removeDecoration(`strikethrough`);else if(t===39)l.fg=null;else if(t===49)l.bg=null;else if(t>=30&&t<38)l.fg=n[0][t%10][a];else if(t>=90&&t<98)l.fg=n[1][t%10][a];else if(t>=40&&t<48)l.bg=n[0][t%10][a];else if(t>=100&&t<108)l.bg=n[1][t%10][a];else if(t===38||t===48){let e=t===38;if(c.length>=1){let t=c.shift();if(t===`5`&&c.length>=1){let t=parseInt(c.shift());if(t>=0&&t<=255){if(!i)this.PALETTE_COLORS||l.setupPalette(),e?l.fg=this.PALETTE_COLORS[t]:l.bg=this.PALETTE_COLORS[t];else{let r=t>=16?`ansi-palette-`+t:n[+(t>7)][t%8].class;e?l.fg=r:l.bg=r}}}else if(t===`2`&&c.length>=3){let t=parseInt(c.shift()),n=parseInt(c.shift()),r=parseInt(c.shift());if(t>=0&&t<=255&&n>=0&&n<=255&&r>=0&&r<=255){let a=t+`, `+n+`, `+r;i?e?(l.fg=`ansi-truecolor`,l.fg_truecolor=a):(l.bg=`ansi-truecolor`,l.bg_truecolor=a):e?l.fg=a:l.bg=a}}}}}return l.fg===null&&l.bg===null&&l.decorations.length===0?o:(o.fg=l.fg,o.bg=l.bg,o.fg_truecolor=l.fg_truecolor,o.bg_truecolor=l.bg_truecolor,o.decorations=l.decorations,o.decoration=l.decorations.slice(-1).pop()||null,o.was_processed=!0,o)}processChunk(e,t,r){t||={};let i=this.processChunkJson(e,t,r),a=t.use_classes;if(i.decorations=i.decorations.filter(e=>{if(e===`reverse`){i.fg||=n[0][7][a?`class`:`color`],i.bg||=n[0][0][a?`class`:`color`];let e=i.fg;i.fg=i.bg,i.bg=e;let t=i.fg_truecolor;return i.fg_truecolor=i.bg_truecolor,i.bg_truecolor=t,i.isInverted=!0,!1}return!0}),t.json)return i;if(i.isEmpty())return``;if(!i.was_processed)return i.content;let o=[],s=[],c=[],l={},u=e=>{let t=[],n;for(n in e)e.hasOwnProperty(n)&&t.push(`data-`+n+`="`+this.escapeForHtml(e[n])+`"`);return t.length>0?` `+t.join(` `):``};return i.isInverted&&(l[`ansi-is-inverted`]=`true`),i.fg&&(a?(o.push(i.fg+`-fg`),i.fg_truecolor!==null&&(l[`ansi-truecolor-fg`]=i.fg_truecolor,i.fg_truecolor=null)):o.push(`color:rgb(`+i.fg+`)`)),i.bg&&(a?(o.push(i.bg+`-bg`),i.bg_truecolor!==null&&(l[`ansi-truecolor-bg`]=i.bg_truecolor,i.bg_truecolor=null)):o.push(`background-color:rgb(`+i.bg+`)`)),i.decorations.forEach(e=>{if(a){s.push(`ansi-`+e);return}e===`bold`?s.push(`font-weight:bold`):e===`dim`?s.push(`opacity:0.5`):e===`italic`?s.push(`font-style:italic`):e===`hidden`?s.push(`visibility:hidden`):e===`strikethrough`?c.push(`line-through`):c.push(e)}),c.length&&s.push(`text-decoration:`+c.join(` `)),a?`<span class="`+o.concat(s).join(` `)+`"`+u(l)+`>`+i.content+`</span>`:`<span style="`+o.concat(s).join(`;`)+`"`+u(l)+`>`+i.content+`</span>`}removeDecoration(e){let t=this.decorations.indexOf(e);t>=0&&this.decorations.splice(t,1)}}})),UN=n(((e,t)=>{function n(e){if(!e)return``;if(!/\r/.test(e))return e;for(e=e.replace(/\r+\n/gm,`
63
+ `))}},SM=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},CM=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},wM=0,TM=class{constructor(e){this.value=e,this.id=wM++}},EM=2,DM=class{constructor(e){this._size=0,this._options=e,this._leakageMon=vM>0||this._options?.leakWarningThreshold?new bM(e?.onListenerError??Kj,this._options?.leakWarningThreshold??vM):void 0,this._perfMon=this._options?._profName?new _M(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new CM(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Kj)(n),uM.None}if(this._disposed)return uM.None;t&&(e=e.bind(t));let r=new TM(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=xM.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof TM?(this._deliveryQueue??=new OM,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=sM(()=>{i?.(),this._removeListener(r)});return n instanceof lM?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*EM<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||Kj;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners){if(this._listeners instanceof TM)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}}this._perfMon?.stop()}hasListeners(){return this._size>0}},OM=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},kM=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),AM;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof jM?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:hM.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:kM})})(AM||={});var jM=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?kM:(this._emitter||=new DM,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},MM=`en`,NM=!1,PM=!1,FM=MM,IM,LM=globalThis,RM;typeof LM.vscode<`u`&&typeof LM.vscode.process<`u`?RM=LM.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(RM=process);var zM=typeof RM?.versions?.electron==`string`&&RM?.type===`renderer`;if(typeof RM==`object`){RM.platform,RM.platform,NM=RM.platform===`linux`,NM&&RM.env.SNAP&&RM.env.SNAP_REVISION,RM.env.CI||RM.env.BUILD_ARTIFACTSTAGINGDIRECTORY,FM=MM;let e=RM.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,FM=t.resolvedLanguage||MM,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!zM?(IM=navigator.userAgent,IM.indexOf(`Windows`),IM.indexOf(`Macintosh`),(IM.indexOf(`Macintosh`)>=0||IM.indexOf(`iPad`)>=0||IM.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,NM=IM.indexOf(`Linux`)>=0,IM?.indexOf(`Mobi`),PM=!0,FM=globalThis._VSCODE_NLS_LANGUAGE||MM,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);PM&&typeof LM.importScripts==`function`&&LM.origin;var BM=IM,VM=FM,HM;(e=>{function t(){return VM}e.value=t;function n(){return VM.length===2?VM===`en`:VM.length>=3&&VM[0]===`e`&&VM[1]===`n`&&VM[2]===`-`}e.isDefaultVariant=n;function r(){return VM===`en`}e.isDefault=r})(HM||={});var UM=typeof LM.postMessage==`function`&&!LM.importScripts;(()=>{if(UM){let e=[];LM.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),LM.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var WM=!!(BM&&BM.indexOf(`Chrome`)>=0);BM&&BM.indexOf(`Firefox`),!WM&&BM&&BM.indexOf(`Safari`),BM&&BM.indexOf(`Edg/`),BM&&BM.indexOf(`Android`);function GM(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=sM(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var KM;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(KM||={});var qM=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new DM,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await hM.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};qM.EMPTY=qM.fromArray([]);var JM=class extends uM{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new dM),this._linesCacheDisposables=this._register(new dM),this._register(sM(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=oM(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=GM(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let n=[],r=[0],i=this._terminal.buffer.active.getLine(e);for(;i;){let a=this._terminal.buffer.active.getLine(e+1),o=a?a.isWrapped:!1,s=i.translateToString(!o&&t);if(o&&a){let e=i.getCell(i.length-1);e&&e.getCode()===0&&e.getWidth()===1&&a.getCell(0)?.getWidth()===2&&(s=s.slice(0,-1))}if(n.push(s),o)r.push(r[r.length-1]+s.length);else break;e++,i=a}return[n.join(``),r]}},YM=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},XM=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,n,r){if(!e||e.length===0){this._terminal.clearSelection();return}if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let i={startRow:t,startCol:n},a=this._findInLine(e,i,r);if(!a)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(i.startRow=n,i.startCol=0,a=this._findInLine(e,i,r),!a);n++);return a}findNextWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=0,a=0;r&&(n===e?(i=r.end.x,a=r.end.y):(i=r.start.x,a=r.start.y)),this._lineCache.initLinesCache();let o={startRow:a,startCol:i},s=this._findInLine(e,o,t);if(!s)for(let n=a+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);if(!s&&a!==0)for(let n=0;n<a&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);return!s&&r&&(o.startRow=r.start.y,o.startCol=0,s=this._findInLine(e,o,t)),s}findPreviousWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=this._terminal.buffer.active.baseY+this._terminal.rows-1,a=this._terminal.cols;this._lineCache.initLinesCache();let o={startRow:i,startCol:a},s;if(r&&(o.startRow=i=r.start.y,o.startCol=a=r.start.x,n!==e&&(s=this._findInLine(e,o,t,!1),s||(o.startRow=i=r.end.y,o.startCol=a=r.end.x))),s||=this._findInLine(e,o,t,!0),!s){o.startCol=Math.max(o.startCol,this._terminal.cols);for(let n=i-1;n>=0&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);}if(!s&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=i&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);return s}_isWholeWord(e,t,n){return(e===0||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e-1]))&&(e+n.length===t.length||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=t.startRow,a=t.startCol;if(this._terminal.buffer.active.getLine(i)?.isWrapped){if(r){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,n)}let o=this._lineCache.getLineFromCache(i);o||(o=this._lineCache.translateBufferLineToStringWithWrap(i,!0),this._lineCache.setLineInCache(i,o));let[s,c]=o,l=this._bufferColsToStringOffset(i,a),u=e,d=s;n.regex||(u=n.caseSensitive?e:e.toLowerCase(),d=n.caseSensitive?s:s.toLowerCase());let f=-1;if(n.regex){let t=RegExp(u,n.caseSensitive?`g`:`gi`),i;if(r)for(;i=t.exec(d.slice(0,l));)f=t.lastIndex-i[0].length,e=i[0],t.lastIndex-=e.length-1;else i=t.exec(d.slice(l)),i&&i[0].length>0&&(f=l+(t.lastIndex-i[0].length),e=i[0])}else r?l-u.length>=0&&(f=d.lastIndexOf(u,l-u.length)):f=d.indexOf(u,l);if(f>=0){if(n.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<c.length-1&&f>=c[t+1];)t++;let r=t;for(;r<c.length-1&&f+e.length>=c[r+1];)r++;let a=f-c[t],o=f+e.length-c[r],s=this._stringLengthToBufferSize(i+t,a),l=this._stringLengthToBufferSize(i+r,o)-s+this._terminal.cols*(r-t);return{term:e,col:s,row:i+t,size:l}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e<t;e++){let r=n.getCell(e);if(!r)break;let i=r.getChars();i.length>1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=e,r=0,i=this._terminal.buffer.active.getLine(n);for(;t>0&&i;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=i.getCell(e);if(!t)break;t.getWidth()&&(r+=t.getCode()===0?1:t.getChars().length)}if(n++,i=this._terminal.buffer.active.getLine(n),i&&!i.isWrapped)break;t-=this._terminal.cols}return r}},ZM=class extends uM{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(sM(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let n of e){let e=this._createResultDecorations(n,t,!1);if(e)for(let t of e)this._storeDecoration(t,n)}}createActiveDecoration(e,t){let n=this._createResultDecorations(e,t,!0);if(n)return{decorations:n,match:e,dispose(){aM(n)}}}clearHighlightDecorations(){aM(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecorations(e,t,n){let r=[],i=e.col,a=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;a>0;){let e=Math.min(this._terminal.cols-i,a);r.push([o,i,e]),i=0,a-=e,o++}let s=[];for(let e of r){let r=this._terminal.registerMarker(e[0]),i=this._terminal.registerDecoration({marker:r,x:e[1],width:e[2],backgroundColor:n?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:n?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:`center`}});if(i){let e=[];e.push(r),e.push(i.onRender(e=>this._applyStyles(e,n?t.activeMatchBorder:t.matchBorder,!1))),e.push(i.onDispose(()=>aM(e))),s.push(i)}}return s.length===0?void 0:s}},QM=class extends uM{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new DM)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&=(this._selectedDecoration.dispose(),void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let n=this._searchResults[t];if(n.row===e.row&&n.col===e.col&&n.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},$M=class extends uM{constructor(e){super(),this._highlightTimeout=this._register(new dM),this._lineCache=this._register(new dM),this._state=new YM,this._resultTracker=this._register(new QM),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new JM(e),this._engine=new XM(e,this._lineCache.value),this._decorationManager=new ZM(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(sM(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=GM(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error(`Cannot use addon until it has been loaded`);if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],r,i=this._engine.find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._engine.find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);this._resultTracker.updateResults(n,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(n,t.decorations)}_findNextAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}findPrevious(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}_selectResult(e,t,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let n=this._decorationManager.createActiveDecoration(e,t);n&&(this._resultTracker.selectedDecoration=n)}if(!n&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}},eN=e=>({codex:`Codex`,antigravity:`Antigravity (agy)`,claude:`Claude Code`,copilot:`GitHub Copilot`,cursor:`Cursor Agent`,pi:`Pi`,shell:`Shell`})[e]??e;function tN({harness:e,className:t=`size-4`}){if(e===`antigravity`)return(0,H.jsx)(Vn,{className:t,alt:``,"aria-hidden":`true`});let n={codex:Hn,claude:zn,copilot:Wn,cursor:Un,pi:ai}[e]??_i;return(0,H.jsx)(n,{className:t,"aria-hidden":`true`})}function nN(e){let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function rN(e){return e.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function iN({session:e}){let t=nN(e.updatedAt),n=nN(e.createdAt);return(0,H.jsxs)(`span`,{className:`inline-flex flex-wrap gap-x-2 gap-y-0.5`,children:[(0,H.jsx)(`span`,{title:t?`Latest recorded activity: ${t.toLocaleString()} (${Intl.DateTimeFormat().resolvedOptions().timeZone}). May include tool or provider events.`:`This harness history has no valid activity timestamp.`,children:t?(0,H.jsxs)(H.Fragment,{children:[`Last activity `,(0,H.jsx)(`time`,{dateTime:t.toISOString(),children:rN(t)})]}):`Last activity unknown`}),n&&(0,H.jsxs)(`span`,{className:`text-muted-foreground`,title:`First recorded activity: ${n.toLocaleString()}`,children:[`Started `,(0,H.jsx)(`time`,{dateTime:n.toISOString(),children:rN(n)})]})]})}function aN({session:e}){let t=e.threadKind===`subagent`,n=t?zr:Xr;return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground`,title:t?`A delegated agent task. Resume its main conversation to continue your work.`:e.threadKind===`main`?`The main conversation you work in. It may delegate tasks to subagents.`:`The harness has not provided a main/subagent classification.`,children:[(0,H.jsx)(n,{className:`size-3`,"aria-hidden":`true`}),t?`Subagent`:e.threadKind===`main`?`Main thread`:`Conversation`]})}function oN(e,t){let n=e,r=new Set;for(;n?.threadKind===`subagent`;){if(!n.parentSessionId||r.has(n.id))return;r.add(n.id);let i=n.parentSessionId;n=t.find(t=>t.assistant===e.assistant&&t.id===i)}return n}function sN({workspace:e,active:t,busy:n,status:r,onResume:i}){let[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(!1),l=on({queryKey:[`terminal-resume-sessions`,e],queryFn:()=>sr(`/api/workspace/${encodeURIComponent(e)}/sessions`),enabled:t,staleTime:15e3}),u=l.data?.sessions??[],d=u.filter(e=>e.threadKind===`subagent`).length,f=u.filter(e=>(s||e.threadKind!==`subagent`)&&`${e.title} ${eN(e.assistant)} ${e.id}`.toLowerCase().includes(a.toLowerCase()));return(0,H.jsxs)(`section`,{"aria-label":`Resume a conversation`,className:`min-h-0 overflow-auto border-b border-border bg-card p-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,H.jsx)(ui,{className:`size-4`}),`Resume a conversation`]}),(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,"aria-label":`Refresh saved sessions`,onClick:()=>void l.refetch(),children:(0,H.jsx)(li,{className:`size-3`})})]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Pick up a session from the Sessions tab. It opens with the harness that created it.`}),(0,H.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`The main thread is your conversation. Subagents handle delegated tasks and report back to it. Older histories may not identify the thread type.`}),(0,H.jsxs)(`div`,{className:`my-2 flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`input`,{"aria-label":`Search saved sessions`,placeholder:`Search conversations or harnesses`,className:`min-w-40 flex-1 rounded border border-border bg-background px-2 py-1 text-xs`,value:a,onChange:e=>o(e.target.value)}),(0,H.jsxs)(`label`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),`Include subagent sessions`,d>0?` (${d})`:``]})]}),l.isLoading&&(0,H.jsx)(`p`,{className:`py-3 text-xs text-muted-foreground`,children:`Loading saved conversations…`}),l.error&&(0,H.jsx)(`p`,{role:`alert`,className:`py-3 text-xs text-destructive`,children:`Could not load sessions. Use Refresh to try again.`}),!l.isLoading&&!l.error&&f.length===0&&(0,H.jsx)(`p`,{className:`py-3 text-xs text-muted-foreground`,children:a?`No matching conversations.`:d&&!s?`Only subagent sessions were found. Include them to inspect their parent links.`:`No saved conversations found for this workspace. Choose a harness above to start one.`}),(0,H.jsx)(`div`,{className:`max-h-72 divide-y divide-border`,children:f.map(e=>{let t=oN(e,u),a=!!r?.available&&!!r.targets.find(t=>t.id===e.assistant)?.available;return(0,H.jsxs)(`div`,{className:`flex items-center gap-2 py-2`,"data-testid":`resume-session-row`,children:[(0,H.jsx)(tN,{harness:e.assistant,className:`size-5 shrink-0`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate text-xs font-medium`,title:e.title,children:e.title}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:eN(e.assistant)}),(0,H.jsx)(aN,{session:e}),(0,H.jsx)(iN,{session:e}),(0,H.jsxs)(`span`,{children:[e.messageCount,` messages`]}),(0,H.jsx)(`span`,{className:`font-mono`,children:e.id.slice(0,8)})]})]}),(0,H.jsxs)(yn,{size:`xs`,variant:`outline`,disabled:n||!a||!t,title:t?a?`Resume ${t.title} in ${eN(t.assistant)}`:`Install this harness, then refresh the harness list`:`Resume the main conversation from the harness`,onClick:()=>t&&i(t),children:[(0,H.jsx)(yr,{className:`size-3`}),e.threadKind===`subagent`?`Main thread`:`Resume`]})]},`${e.assistant}:${e.id}`)})})]})}var cN=``,lN,uN=0;async function dN(){return Date.now()>=uN&&(lN=void 0),lN||=(uN=Date.now()+24e4,fetch(`${cN}/api/terminals/bootstrap`,{method:`POST`,credentials:`include`,headers:{"x-contextspace-terminal":`bootstrap`}}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||`Could not connect to the local terminal service.`);return uN=Math.min(uN,Number(t.expiresAt)-5e3),t.token}).catch(e=>{throw lN=void 0,e})),lN}async function fN(e,t,n={}){for(let r=0;r<2;r++){let i=await dN(),a=await fetch(`${cN}/api/terminals/${encodeURIComponent(e)}/${t}`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,"x-contextspace-terminal":i},body:JSON.stringify(n)}),o=await a.json();if(a.status===403&&r===0){lN=void 0,uN=0;continue}if(!a.ok)throw Error(o.error||`Terminal request failed.`);return o}throw Error(`Terminal authorization expired. Reconnect.`)}function pN(){let e=new URL(`/ws/terminal`,window.location.origin);return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.toString()}function mN(e){let t=[];for(let n=0;n<e.length;){if(/\s/.test(e[n])){n++;continue}let r=n,i=null;for(;n<e.length;){let t=e[n];if(i&&t===i)i=null;else if(!i&&(t===`"`||t===`'`||t==="`")&&/^[([{]*$/.test(e.slice(r,n)))i=t;else if(/\s/.test(t)&&!i)break;n++}let a=e.slice(r,n),o=a.match(/^[('"`[{]*/)?.[0].length??0,s=a.slice(o);for(;/[,'"`\]};.!?)]$/.test(s)&&!/\(\d+(?:,\d+)?\)$/.test(s);)s=s.slice(0,-1);let c=s.match(/:(\d+)(?::\d+)?$/)??s.match(/\((\d+)(?:,\d+)?\)$/),l=Number(c?.[1]),u=Number.isSafeInteger(l)&&l>0?l:void 0,d=(c?s.slice(0,-c[0].length):s).replace(/['"`]$/,``);if(!d||/^(?:[a-z][a-z\d+.-]*:\/\/|mailto:)/i.test(d)||!/[/\\]/.test(d)&&!/^[^.:]+\.[a-z\d]{1,12}$/i.test(d)||/^(?:\.\.?[/\\])?$/.test(d))continue;let f=r+o;t.push({text:s,path:d,line:u,start:f,end:f+s.length})}return t}function hN({workspace:e,active:t,launch:n,consumeLaunch:r,onOpenFileReference:i,codeVisible:a,onStatusChange:o,onBackgroundOutput:s}){let c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useRef)(null),[p,m]=(0,V.useState)(null),{harnesses:h,setHarness:g}=Mt(),_=h[e]??``,v=(0,V.useCallback)(t=>g(e,t),[e,g]),[y,b]=(0,V.useState)(!0);(0,V.useEffect)(()=>{a&&b(!1)},[a]);let[x,S]=(0,V.useState)(null);(0,V.useEffect)(()=>{x&&b(!1)},[x]);let[C,w]=(0,V.useState)(`Choose a harness or shell`),[T,E]=(0,V.useState)(``),[D,ee]=(0,V.useState)(!1),[O,k]=(0,V.useState)(0),[A,te]=(0,V.useState)(``),[j,M]=(0,V.useState)(!1),[N,ne]=(0,V.useState)(null),re=(0,V.useRef)(``),ie=(0,V.useRef)(``),P=(0,V.useRef)(void 0),[F,I]=(0,V.useState)(void 0),L=(0,V.useRef)(t),ae=(0,V.useRef)(i),R=(0,V.useRef)(o),oe=(0,V.useRef)(s);(0,V.useEffect)(()=>{L.current=t},[t]),(0,V.useEffect)(()=>{ae.current=i},[i]),(0,V.useEffect)(()=>{R.current=o,oe.current=s},[o,s]),(0,V.useEffect)(()=>{let e=C.startsWith(`Connected`)?`running`:C.startsWith(`Exited`)?`exited`:C.startsWith(`Disconnected`)?`disconnected`:`idle`;R.current?.(e)},[C]);let z=(0,V.useCallback)(e=>{f.current?.readyState===WebSocket.OPEN&&f.current.send(JSON.stringify(e))},[]),se=(0,V.useCallback)(async()=>{try{let t=await fN(e,`status`);m(t),S(e=>e??t.sessions.find(e=>e.state===`running`)??null),t.available||E(t.reason||`Native terminal support is unavailable.`)}catch(e){E(e.message)}},[e]);(0,V.useEffect)(()=>{se()},[se]),(0,V.useEffect)(()=>{x&&!_&&v(x.target)},[x,_,v]),(0,V.useEffect)(()=>{let e=window.setInterval(()=>{dN().catch(()=>{})},24e4);return()=>window.clearInterval(e)},[]),(0,V.useEffect)(()=>{if(!c.current)return;let e=new Vj({cursorBlink:!0,fontFamily:`"JetBrains Mono", monospace`,fontSize:13,scrollback:5e3,allowProposedApi:!1,theme:{background:`#111b18`,foreground:`#e1e9e4`,cursor:`#a3dbae`}}),t=new Wj,n=new $M;e.loadAddon(t),e.loadAddon(n),e.open(c.current);let r=c.current,i=e=>{(e.ctrlKey||e.metaKey)&&!e.altKey&&e.key.toLowerCase()===`v`&&e.stopPropagation()};r.addEventListener(`keydown`,i,!0);let a=t=>{let n=t.clipboardData;if(!n||n.getData(`text/plain`))return;let r=$S(n.getData(`text/html`));r.trim()?(t.preventDefault(),t.stopPropagation(),e.options.disableStdin||e.paste(r)):([...n.items].some(e=>e.type.startsWith(`image/`))||[...n.files].some(e=>e.type.startsWith(`image/`)))&&(t.preventDefault(),t.stopPropagation(),E(`The clipboard contains an image but no text. Use Chat to attach the image, or copy text and paste again.`))};r.addEventListener(`paste`,a,!0),e.attachCustomKeyEventHandler(t=>t.type===`keydown`?(t.ctrlKey||t.metaKey)&&t.key.toLowerCase()===`c`&&(t.shiftKey||e.hasSelection())?(t.preventDefault(),QS(e.getSelection()).then(e=>{E(e?``:`Select terminal output before copying, or check clipboard permissions.`)}),!1):!((t.ctrlKey||t.metaKey)&&t.key.toLowerCase()===`v`):!0);let o=e.registerLinkProvider({provideLinks(t,n){let r=e.buffer.active,i=t-1;for(;i>0&&r.getLine(i)?.isWrapped&&t-i<=20;)i--;if(r.getLine(i)?.isWrapped){n([]);return}let a=t-1;for(;r.getLine(a+1)?.isWrapped&&a-i<20;)a++;if(r.getLine(a+1)?.isWrapped){n([]);return}let o=[];for(let e=i;e<=a;e++){let t=r.getLine(e);if(!t){n([]);return}o.push({line:t,text:t.translateToString(e===a)})}let s=(t,n)=>{let r=0;for(let a=0;a<o.length;a++){let s=o[a].text.length;if(t<r+s||n&&t===r+s||a===o.length-1){let s=Math.max(0,t-r),c=0;for(;c<e.cols&&o[a].line.translateToString(!1,0,c).length<s;)c++;return{x:c+ +!n,y:i+a+1}}r+=s}return{x:1,y:i+1}};n(mN(o.map(e=>e.text).join(``)).map(e=>({text:e.text,range:{start:s(e.start,!1),end:s(e.end,!0)},activate:()=>ae.current?.({path:e.path,line:e.line})})))}});l.current=e,u.current=t,d.current=n;let s=e.onData(t=>{if(!e.options.disableStdin)for(let e=0;e<t.length;){let n=Math.min(e+8192,t.length);n<t.length&&/[\uD800-\uDBFF]/.test(t[n-1])&&n--,z({type:`input`,data:t.slice(e,n)}),e=n}});e.options.disableStdin=!0;let f=e.onResize(({cols:t,rows:n})=>{e.options.disableStdin||z({type:`resize`,cols:Math.min(t,500),rows:Math.min(n,300)})}),p=new ResizeObserver(()=>{c.current?.clientWidth&&c.current?.clientHeight&&t.fit()});return p.observe(c.current),()=>{r.removeEventListener(`keydown`,i,!0),r.removeEventListener(`paste`,a,!0),p.disconnect(),o.dispose(),s.dispose(),f.dispose(),e.dispose(),l.current=null}},[z]),(0,V.useEffect)(()=>{if(!t||!x)return;let e=requestAnimationFrame(()=>{!L.current||!c.current?.getClientRects().length||(u.current?.fit(),l.current?.focus())});return()=>cancelAnimationFrame(e)},[t,x]),(0,V.useEffect)(()=>{l.current&&(l.current.options.screenReaderMode=j)},[j]),(0,V.useEffect)(()=>{if(!x)return;let t=!1,n,r=x.state===`exited`,i=!1,a=l.current;if(a)return a.reset(),a.options.disableStdin=!0,w(`Connecting…`),dN().then(o=>{t||(n=new WebSocket(pN()),f.current=n,n.onopen=()=>n.send(JSON.stringify({type:`attach`,token:o,workspace:e,id:x.id})),n.onmessage=e=>{if(t)return;let o=JSON.parse(String(e.data));o.type===`ready`?(r=o.terminal.state===`exited`,E(o.truncated?`Earlier output was trimmed. This is a partial screen replay; use the harness redraw command if needed.`:``),w(`Restoring terminal…`)):o.type===`output`&&typeof o.data==`string`?(i&&!L.current&&oe.current?.(),a.write(o.data,()=>{!t&&n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify({type:`ack`,count:o.data.length}))})):o.type===`replayed`?(i=!0,a.write(``,()=>{t||(a.options.disableStdin=r,w(r?`Exited`:`Connected`),r||(u.current?.fit(),z({type:`resize`,cols:Math.min(a.cols,500),rows:Math.min(a.rows,300)}),L.current&&a.focus()))})):o.type===`exit`?(r=!0,a.options.disableStdin=!0,w(`Exited${o.exitCode==null?``:` (${o.exitCode})`}`),m(e=>e&&{...e,sessions:e.sessions.map(e=>e.id===x.id?{...e,state:`exited`}:e)})):o.type===`error`&&(E(o.message),a.options.disableStdin=!0)},n.onclose=()=>{t||(a.options.disableStdin=!0,w(r?`Exited`:`Disconnected · input paused`))},n.onerror=()=>{t||E(`Connection failed. Reconnect to the existing terminal; it may still be running.`)})}).catch(e=>{t||(E(e.message),w(`Disconnected · input paused`))}),()=>{t=!0,a.options.disableStdin=!0,n?.close(),f.current===n&&(f.current=null)}},[x?.id,O,e,z]);let ce=(0,V.useCallback)(async t=>{P.current=t,I(t),ee(!0),E(``),v(t.target);try{let{terminal:n}=await fN(e,`create`,{launchId:t.id,target:t.target,sessionId:t.sessionId,cwd:t.cwd});S(n),b(!1),await se()}catch(e){E(e.message)}finally{ee(!1)}},[e,se,v]);(0,V.useEffect)(()=>{!n||ie.current===n.id||(ie.current=n.id,ce(n).finally(()=>r(n.id)))},[n,ce,r]);let le=async()=>{if(!(!x||!window.confirm(`End this terminal and its running commands?`)))try{await fN(e,`${x.id}/stop`),await se()}catch(e){E(e.message)}},ue=async e=>{try{let t=e||l.current?.getSelection()||``;if(!t){E(`Select terminal output before copying.`);return}await QS(t)?E(``):E(`Could not copy terminal output. Check browser clipboard permissions.`)}finally{requestAnimationFrame(()=>l.current?.focus())}},de=async()=>{ne(null);try{let e=await eC();if(!e)throw Error(`Clipboard has no text`);if(!l.current||l.current.options.disableStdin)throw Error(`Reconnect the terminal before pasting.`);l.current.paste(e),l.current.focus(),E(``)}catch{E(`No clipboard text was available. Focus the terminal and press Ctrl+V (or Cmd+V); attach image-only content in Chat.`)}},fe=async()=>{E(``);try{let t=P.current;await sr(`/api/workspace/${encodeURIComponent(e)}/terminal`,{method:`POST`,body:JSON.stringify({..._===`shell`?{}:{assistant:_},...t?.target===_?{sessionId:t.sessionId,cwd:t.cwd}:{}})})}catch(e){E(e.message)}};return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`terminal-pane`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border px-3 py-2`,children:[(0,H.jsxs)(jc,{value:_||null,onValueChange:e=>{typeof e==`string`&&v(e)},children:[(0,H.jsx)(Nc,{"aria-label":`CLI harness`,size:`sm`,className:`w-auto min-w-40 text-xs`,children:_?(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(tN,{harness:_}),eN(_)]}):`Choose a harness`}),(0,H.jsx)(Fc,{children:(p?.targets??[]).map(e=>(0,H.jsx)(Ic,{value:e.id,children:(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(tN,{harness:e.id}),eN(e.id),!e.available&&(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`· Not installed`})]})},e.id))})]}),(0,H.jsxs)(yn,{size:`xs`,onClick:()=>void ce({id:crypto.randomUUID(),target:_}),disabled:D||!p?.available||!_||!p.targets.find(e=>e.id===_)?.available,children:[(0,H.jsx)(ci,{className:`size-3`}),D?`Starting…`:`Start session`]}),(0,H.jsxs)(yn,{size:`xs`,variant:y?`secondary`:`ghost`,"aria-pressed":y,onClick:()=>b(e=>!e),children:[(0,H.jsx)(ui,{className:`size-3`}),`Resume session`]}),(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,title:`Refresh installed harnesses`,onClick:()=>void se(),children:[(0,H.jsx)(li,{className:`size-3`}),`Refresh`]}),(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,disabled:!_,onClick:()=>void fe(),children:[(0,H.jsx)(Bn,{className:`size-3`}),`External terminal`]}),x&&(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,onClick:()=>void le(),children:[(0,H.jsx)(vi,{className:`size-3`}),`End session`]})]}),y&&(0,H.jsx)(sN,{workspace:e,active:t,busy:D,status:p,onResume:e=>void ce({id:crypto.randomUUID(),target:e.assistant,sessionId:e.id,cwd:e.workspacePath})}),!!p?.sessions.length&&(0,H.jsx)(`div`,{className:`px-3 py-1 border-b border-border`,children:(0,H.jsxs)(`select`,{"aria-label":`Terminal sessions`,className:`max-w-full bg-card text-xs`,value:x?.id??``,onChange:e=>{let t=p.sessions.find(t=>t.id===e.target.value)??null;S(t),t&&v(t.target)},children:[(0,H.jsx)(`option`,{value:``,disabled:!0,children:`Select a terminal`}),p.sessions.map(e=>(0,H.jsxs)(`option`,{value:e.id,children:[e.label,` · `,e.state,` · `,e.id.slice(0,8)]},e.id))]})}),T&&(0,H.jsxs)(`div`,{role:`alert`,className:`border-b border-border px-3 py-2 text-xs text-amber-600 break-words`,children:[T,F&&(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,disabled:D,onClick:()=>void ce(F),children:`Retry launch`})]}),x&&C.startsWith(`Disconnected`)&&(0,H.jsxs)(`div`,{"data-testid":`terminal-disconnected`,role:`alert`,className:`flex flex-wrap items-center gap-2 border-b border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-foreground`,children:[(0,H.jsx)(wi,{className:`size-4 shrink-0 text-amber-600`,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`strong`,{children:`CLI chat disconnected.`}),` Input is paused; the session may still be running.`]}),(0,H.jsxs)(yn,{size:`xs`,variant:`outline`,onClick:()=>k(e=>e+1),children:[(0,H.jsx)(si,{className:`size-3`}),`Reconnect CLI`]})]}),!x&&(0,H.jsx)(`div`,{className:`flex-1 px-3 py-3 text-xs text-muted-foreground`,children:`Choose a harness for a new session, or resume a saved conversation above. The harness keeps its own login and permissions. Shell opens PowerShell or your Unix shell. Existing API conversations remain under Chat.`}),(0,H.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-[#111b18] p-2 ${x?``:`hidden`}`,onPointerDownCapture:e=>{e.button===2&&(re.current=l.current?.getSelection()??``)},onContextMenu:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();ne({x:Math.min(e.clientX-t.left,Math.max(0,t.width-150)),y:Math.min(e.clientY-t.top,Math.max(0,t.height-80))})},children:[(0,H.jsx)(`div`,{ref:c,className:`h-full overflow-hidden`,"aria-label":`Interactive CLI terminal`}),N&&(0,H.jsxs)(`div`,{className:`absolute z-20 min-w-36 rounded border border-border bg-card p-1 shadow-lg`,style:{left:N.x,top:N.y},role:`menu`,onKeyDown:e=>{e.key===`Escape`&&ne(null)},children:[(0,H.jsx)(`button`,{role:`menuitem`,className:`block w-full rounded px-2 py-1 text-left text-xs hover:bg-accent`,onClick:()=>{ne(null),ue(re.current),re.current=``},children:`Copy selection`}),(0,H.jsx)(`button`,{role:`menuitem`,className:`block w-full rounded px-2 py-1 text-left text-xs hover:bg-accent`,onClick:()=>void de(),children:`Paste`})]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border px-3 py-1 text-xs`,children:[(0,H.jsx)(`span`,{role:`status`,children:C}),x&&(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,onClick:()=>k(e=>e+1),children:[(0,H.jsx)(si,{className:`size-3`}),`Reconnect`]}),(0,H.jsx)(`input`,{"aria-label":`Search terminal output`,placeholder:`Search output`,className:`w-28 rounded border border-border bg-card px-1`,value:A,onChange:e=>te(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d.current?.findNext(A)}}),(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,onClick:()=>d.current?.findNext(A),children:[(0,H.jsx)(Ct,{className:`size-3`}),`Find`]}),(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,onClick:()=>void ue(),children:[(0,H.jsx)(Mr,{className:`size-3`}),`Copy selection`]}),(0,H.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:j,onChange:e=>M(e.target.checked)}),`Screen reader`]})]}),(0,H.jsxs)(`div`,{className:`truncate px-3 pb-1 text-[10px] text-muted-foreground`,title:x?.cwd,children:[`Local user permissions · `,x?.cwd??e,` · Hide keeps running; End session stops it.`]})]})}var gN=(0,V.lazy)(()=>Kn(()=>import(`./DocumentPreview-CtylgIF0.js`).then(e=>e.n).then(e=>({default:e.DocumentPreview})),__vite__mapDeps([5,1,2])));function _N({workspace:e,openDocument:t}){let{isMaximized:n,toggleMaximize:r}=Mt(),i=(0,V.useRef)(0),[a,o]=(0,V.useState)([]),[s,c]=(0,V.useState)([]),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(``),[_,v]=(0,V.useState)(0),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(``),C=`/api/workspace/${encodeURIComponent(e)}`;(0,V.useEffect)(()=>{let e=new AbortController;return S(``),sr(`${C}/documents`,{signal:e.signal}).then(e=>o(e.documents)).catch(t=>{e.signal.aborted||S(t instanceof Error?t.message:`Could not load workspace files.`)}),sr(`${C}/work`,{signal:e.signal}).then(e=>c([...e.guidance.documents,...e.sharedDocuments??[]])).catch(t=>{e.signal.aborted||S(t instanceof Error?t.message:`Could not load source documents.`)}),()=>e.abort()},[C,_]),(0,V.useEffect)(()=>{t&&t.id!==i.current&&a.some(e=>e.name===t.name)&&(i.current=t.id,u({type:`file`,id:t.name}))},[a,t]),(0,V.useEffect)(()=>{let e=new AbortController;return f(null),m(null),b(!1),S(``),l&&(l.type===`file`?sr(`${C}/documents/preview?name=${encodeURIComponent(l.id)}`,{signal:e.signal}).then(f):sr(`${C}/work/documents/${encodeURIComponent(l.id)}`,{signal:e.signal}).then(m)).catch(t=>{e.signal.aborted||S(t instanceof Error?t.message:`Could not open document.`)}),()=>e.abort()},[C,l,_]);let w=(0,V.useMemo)(()=>a.filter(e=>e.name.toLowerCase().includes(h.toLowerCase())),[a,h]),T=(0,V.useMemo)(()=>s.filter(e=>`${e.title} ${e.role} ${e.status}`.toLowerCase().includes(h.toLowerCase())),[s,h]),E=l?.type===`file`?`${C}/documents/file?name=${encodeURIComponent(l.id)}`:``;return(0,H.jsxs)(`section`,{"aria-label":`Workspace documents`,className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border p-2`,children:[(0,H.jsx)(`span`,{className:`text-xs font-semibold`,children:`Documents`}),!n&&(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,onClick:r,children:`Expand chat`}),(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,"aria-label":`Refresh documents`,onClick:()=>v(e=>e+1),children:(0,H.jsx)(li,{className:`size-3`})})]}),(0,H.jsxs)(`div`,{className:`max-h-[38%] min-h-32 space-y-2 overflow-auto border-b border-border p-2`,children:[(0,H.jsx)(Ye,{"aria-label":`Find a document`,placeholder:`Find a document…`,value:h,onChange:e=>g(e.target.value)}),(0,H.jsx)(`p`,{className:`text-[11px] font-semibold text-muted-foreground`,children:`Workspace files`}),w.map(e=>(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":l?.type===`file`&&l.id===e.name,className:`flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-xs hover:bg-accent aria-pressed:bg-accent`,onClick:()=>u({type:`file`,id:e.name}),children:[(0,H.jsx)(Ir,{className:`size-3 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.name})]},e.name)),!w.length&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No matching files.`}),(0,H.jsx)(`p`,{className:`pt-2 text-[11px] font-semibold text-muted-foreground`,children:`Source documents`}),T.map(e=>(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":l?.type===`source`&&l.id===e.id,className:`flex w-full items-center justify-between gap-2 rounded px-2 py-1 text-left text-xs hover:bg-accent aria-pressed:bg-accent`,onClick:()=>u({type:`source`,id:e.id}),children:[(0,H.jsx)(`span`,{className:`truncate`,children:e.title}),(0,H.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:e.status})]},e.id)),!T.length&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No matching sources.`})]}),(0,H.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[!l&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Select a file or source to read beside the CLI session.`}),l&&(0,H.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,H.jsx)(`h3`,{className:`break-all text-xs font-semibold`,children:l.type===`file`?l.id:s.find(e=>e.id===l.id)?.title}),(0,H.jsxs)(`div`,{className:`flex gap-2 text-xs`,children:[(p?.content!==void 0||d&&(d.kind===`html`||d.kind===`markdown`))&&(0,H.jsx)(yn,{size:`xs`,variant:`outline`,onClick:()=>b(e=>!e),children:y?`Rendered`:`Raw`}),l.type===`file`&&(0,H.jsx)(`a`,{className:`text-primary underline`,href:`${E}&download=1`,download:l.id,children:`Download`})]})]}),x&&(0,H.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:x}),d&&(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`p`,{role:`status`,className:`text-xs`,children:`Opening viewer…`}),children:(0,H.jsx)(gN,{preview:d,fileUrl:E,raw:y})}),p?.content!==void 0&&(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`p`,{role:`status`,className:`text-xs`,children:`Opening viewer…`}),children:(0,H.jsx)(gN,{preview:{name:l?.id??`Source document`,kind:`markdown`,content:p.content},fileUrl:``,raw:y})}),p?.content===void 0&&p?.location&&(0,H.jsx)(`a`,{className:`text-xs text-primary underline`,href:p.location,target:`_blank`,rel:`noopener noreferrer`,children:`Open source document`})]})]})}function vN({workspace:e,active:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(0),[c,l]=(0,V.useState)(``);return(0,V.useEffect)(()=>{if(!t)return;let n=new AbortController;return l(``),sr(`/api/workspace/${encodeURIComponent(e)}/work`,{signal:n.signal}).then(e=>r(e.guidance.assignment)).catch(e=>{n.signal.aborted||l(e instanceof Error?e.message:`Could not load the work brief.`)}),()=>n.abort()},[e,t,o]),!n&&!c?null:(0,H.jsxs)(`div`,{className:`border-b border-border bg-muted/20 px-3 py-1.5 text-xs`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`min-w-0 flex-1 truncate text-left hover:text-primary`,title:n?.objective,children:n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`font-semibold capitalize`,children:n.stage}),` · `,n.objective||`No current objective set`]}):`Work brief unavailable`}),(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,"aria-label":`Refresh work brief`,onClick:()=>s(e=>e+1),children:(0,H.jsx)(li,{className:`size-3`})})]}),i&&(0,H.jsxs)(`div`,{className:`space-y-1 pt-2 text-muted-foreground`,children:[c&&(0,H.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:c}),n&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Objective:`}),` `,n.objective||`Not set`]}),(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Expected output:`}),` `,n.expectedOutput||`Not set`]}),(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Stop when:`}),` `,n.stopCondition||`Not set`]})]})]})]})}function yN({workspacePath:e,...t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(50),[f,p]=(0,V.useState)(!1),m=(0,V.useRef)(null),h=(0,V.useRef)(0),g=(0,V.useCallback)(e=>{if(e.button!==0)return;let t=m.current;if(!t)return;let n=e.currentTarget;n.setPointerCapture(e.pointerId),p(!0);let r=e=>{let n=t.getBoundingClientRect();if(n.width<=0)return;let r=(e.clientX-n.left)/n.width*100;d(Math.round(Math.max(20,Math.min(85,100-r)))),l(!1)},i=e=>{p(!1),n.hasPointerCapture(e.pointerId)&&n.releasePointerCapture(e.pointerId),n.removeEventListener(`pointermove`,r),n.removeEventListener(`pointerup`,i),n.removeEventListener(`pointercancel`,i)};n.addEventListener(`pointermove`,r),n.addEventListener(`pointerup`,i),n.addEventListener(`pointercancel`,i)},[]),_=async n=>{let i=++h.current,o=n.path.replaceAll(`\\`,`/`).replace(/^\.\//,``),c=e.replaceAll(`\\`,`/`).replace(/\/$/,``),l=o.startsWith(`${c}/`)?o.slice(c.length+1):o;if(!l.includes(`/`))try{let e=await sr(`/api/workspace/${encodeURIComponent(t.workspace)}/documents`);if(i!==h.current)return;if(e.documents.some(e=>e.name===l)){s(e=>({name:l,id:(e?.id??0)+1})),r(`documents`);return}}catch{}i===h.current&&(a(e=>({...n,id:(e?.id??0)+1})),r(`code`))};return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border bg-muted/10 px-2 py-1`,children:[(0,H.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:`CLI chat`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[n&&(0,H.jsxs)(yn,{size:`xs`,variant:c?`secondary`:`ghost`,onClick:()=>l(e=>!e),"aria-label":c?`Split view`:`Expand ${n} panel`,title:c?`Restore split view`:`Expand ${n} panel`,children:[c?(0,H.jsx)(Qr,{className:`size-3`}):(0,H.jsx)(Jr,{className:`size-3`}),c?`Split view`:`Expand`]}),(0,H.jsxs)(yn,{size:`xs`,variant:n===`code`?`secondary`:`ghost`,"aria-pressed":n===`code`,onClick:()=>r(e=>e===`code`?null:`code`),children:[(0,H.jsx)(Gr,{className:`size-3`}),n===`code`?`Hide code`:`Show code`]}),(0,H.jsxs)(yn,{size:`xs`,variant:n===`documents`?`secondary`:`ghost`,"aria-pressed":n===`documents`,onClick:()=>r(e=>e===`documents`?null:`documents`),children:[(0,H.jsx)(Ir,{className:`size-3`}),`Documents`]})]})]}),(0,H.jsx)(vN,{workspace:t.workspace,active:t.active}),(0,H.jsxs)(`div`,{ref:m,className:`relative flex min-h-0 flex-1 flex-row`,children:[(0,H.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:(0,H.jsx)(hN,{...t,codeVisible:n!==null,onOpenFileReference:e=>{_(e)}})}),n&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-valuenow":c?85:u,"aria-valuemin":20,"aria-valuemax":85,"aria-label":n===`code`?`Resize code panel`:`Resize documents panel`,onPointerDown:g,onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),d(t=>Math.max(20,Math.min(85,t+(e.key===`ArrowLeft`?5:-5)))),l(!1))},className:`group z-20 -mx-1 flex w-2 cursor-col-resize select-none items-center justify-center bg-border/60 transition-colors hover:w-2.5 hover:bg-primary/50 focus-visible:bg-primary/70 focus-visible:outline-hidden ${f?`w-2.5 bg-primary/60`:``}`,title:`Drag or use Left/Right arrow keys to resize the inspector`,children:(0,H.jsx)(`div`,{className:`h-6 w-0.5 rounded bg-muted-foreground/30 group-hover:bg-primary`})}),(0,H.jsx)(`div`,{style:{width:c?`85%`:`${u}%`},className:`h-full min-h-0 min-w-0 border-l border-border ${f?``:`transition-[width] duration-150`}`,children:n===`code`?(0,H.jsx)(UC,{workspace:t.workspace,active:t.active,openReference:i,onClose:()=>r(null)}):(0,H.jsx)(_N,{workspace:t.workspace,openDocument:o})})]})]})]})}function bN({className:e,size:t=`default`,unstyled:n=!1,...r}){return(0,H.jsx)(`span`,{className:B(!n&&`relative inline-flex w-full rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none has-focus-visible:ring-[3px] not-has-disabled:has-not-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] sm:text-sm dark:bg-input/32 dark:has-aria-invalid:ring-destructive/24 dark:not-has-disabled:has-not-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)]`,e)||void 0,"data-size":t,"data-slot":`textarea-control`,children:(0,H.jsx)(it,{render:e=>(0,H.jsx)(`textarea`,{className:B(`field-sizing-content min-h-17.5 w-full rounded-[inherit] px-[calc(--spacing(3)-1px)] py-[calc(--spacing(1.5)-1px)] outline-none max-sm:min-h-20.5 border-none bg-transparent resize-none h-full`,t===`sm`&&`min-h-16.5 px-[calc(--spacing(2.5)-1px)] py-[calc(--spacing(1)-1px)] max-sm:min-h-19.5`,t===`lg`&&`min-h-18.5 py-[calc(--spacing(2)-1px)] max-sm:min-h-21.5`),"data-slot":`textarea`,...gn(e,r)})})})}function xN(e){return e===`review`||e===`workspace-write`}var SN=e=>`${nr}${e}`,CN=e=>`${tr}${e}`,wN=()=>({v:4,sessions:{},providerId:null,profilesByProvider:{"claude-cli":`review`,"codex-cli":`review`},modelsByProvider:{},effortsByProvider:{},messages:[]});function TN(e){try{let t=localStorage.getItem(SN(e))||localStorage.getItem(CN(e));if(!t)return wN();let n=JSON.parse(t);if(Array.isArray(n))return{...wN(),messages:n.filter(e=>e&&typeof e.content==`string`&&(e.role===`user`||e.role===`assistant`)).map(e=>({role:e.role,content:e.content,...e.usage?{usage:e.usage}:{}}))};if(n&&n.v===4&&n.sessions&&Array.isArray(n.messages)){let e=Object.fromEntries(Object.entries(n.profilesByProvider??{}).filter(e=>xN(e[1]))),t=typeof n.modelsByProvider==`object`&&n.modelsByProvider!==null?Object.fromEntries(Object.entries(n.modelsByProvider).filter(e=>typeof e[0]==`string`&&typeof e[1]==`string`)):{},r=typeof n.effortsByProvider==`object`&&n.effortsByProvider!==null?Object.fromEntries(Object.entries(n.effortsByProvider).filter(e=>typeof e[0]==`string`&&typeof e[1]==`string`)):{};return{...wN(),sessions:n.sessions,providerId:typeof n.providerId==`string`?n.providerId:null,profilesByProvider:{...wN().profilesByProvider,...e},modelsByProvider:t,effortsByProvider:r,messages:n.messages}}if(n&&n.v===3&&n.sessions&&Array.isArray(n.messages))return{...wN(),sessions:n.sessions,providerId:typeof n.providerId==`string`?n.providerId:null,messages:n.messages};if(n&&n.v===2&&Array.isArray(n.messages)){let e={};return typeof n.sessionId==`string`&&n.sessionId&&(e[`claude-cli`]={id:n.sessionId,started:!!n.sessionStarted}),{v:4,sessions:e,providerId:typeof n.providerId==`string`?n.providerId:null,profilesByProvider:wN().profilesByProvider,messages:n.messages}}return wN()}catch{return wN()}}var EN=500;async function DN(e){try{let t=await fetch(`/api/chat/thread/${encodeURIComponent(e)}`);if(!t.ok)return null;let n=await t.json();if(n&&n.thread){let e=n.thread;return{v:4,sessions:e.sessions||{},providerId:e.providerId||null,profilesByProvider:{...wN().profilesByProvider,...e.profilesByProvider||{}},modelsByProvider:e.modelsByProvider||{},effortsByProvider:e.effortsByProvider||{},messages:Array.isArray(e.messages)?e.messages:[],isBusy:!!n.isBusy}}return null}catch{return null}}async function ON(e,t){try{let n=t.messages.length>EN?{...t,messages:t.messages.slice(-500)}:t;await fetch(`/api/chat/thread/${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})}catch{}}async function kN(e){try{await fetch(`/api/chat/thread/${encodeURIComponent(e)}`,{method:`DELETE`})}catch{}}function AN(e,t){let n=t.messages.length>EN?{...t,messages:t.messages.slice(-500)}:t;try{localStorage.setItem(SN(e),JSON.stringify(n))}catch(t){try{let t={...n,messages:n.messages.map(e=>{let t={...e};return delete t.images,t})};localStorage.removeItem(SN(e)),localStorage.setItem(SN(e),JSON.stringify(t))}catch{console.error(`Failed to save chat to localStorage`,t)}}ON(e,n)}function jN(e){try{localStorage.removeItem(SN(e)),kN(e),localStorage.removeItem(CN(e))}catch{}}var MN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,NN=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[a-zA-Z0-9_\-.]{1,128})$/i,PN=new Set([`claude-cli`,`codex-cli`,`antigravity-cli`,`copilot-cli`]);function FN(e){return e===`claude`?`claude-cli`:e===`codex`?`codex-cli`:e===`antigravity`?`antigravity-cli`:e===`copilot`?`copilot-cli`:null}function IN(e){if(!e||typeof e!=`object`)return null;let t=e.chatLaunch;if(!t||typeof t!=`object`)return null;let n=t;return!MN.test(n.nonce??``)||!n.providerId||!PN.has(n.providerId)||!xN(n.executionProfile)||n.kickoff!==void 0&&(typeof n.kickoff!=`string`||n.kickoff.length>2e3)||n.model!==void 0&&(typeof n.model!=`string`||n.model.length>100)||n.assistant!==void 0&&FN(n.assistant)!==n.providerId||n.sessionId!==void 0&&(!NN.test(n.sessionId)||!n.assistant)?null:n}function LN({className:e,...t}){return(0,H.jsx)(`div`,{className:B(`flex min-w-0 flex-1 flex-col items-center justify-center gap-6 text-balance p-6 text-center md:p-12`,e),"data-slot":`empty`,...t})}function RN({className:e,...t}){return(0,H.jsx)(`div`,{className:B(`flex max-w-sm flex-col items-center text-center`,e),"data-slot":`empty-header`,...t})}var zN=hn(`flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,{defaultVariants:{variant:`default`},variants:{variant:{default:`bg-transparent`,icon:`relative flex size-9 shrink-0 items-center justify-center rounded-md border bg-card not-dark:bg-clip-padding text-foreground shadow-sm/5 before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-md)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)] [&_svg:not([class*='size-'])]:size-4.5`}}});function BN({className:e,variant:t=`default`,...n}){return(0,H.jsxs)(`div`,{className:B(`relative mb-6`,e),"data-slot":`empty-media`,"data-variant":t,...n,children:[t===`icon`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{"aria-hidden":`true`,className:B(zN({className:e,variant:t}),`-translate-x-0.5 -rotate-10 pointer-events-none absolute bottom-px origin-bottom-left scale-84 shadow-none`)}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:B(zN({className:e,variant:t}),`pointer-events-none absolute bottom-px origin-bottom-right translate-x-0.5 rotate-10 scale-84 shadow-none`)})]}),(0,H.jsx)(`div`,{className:B(zN({className:e,variant:t})),...n})]})}function VN({className:e,...t}){return(0,H.jsx)(`div`,{className:B(`font-heading font-semibold text-xl`,e),"data-slot":`empty-title`,...t})}function HN({className:e,...t}){return(0,H.jsx)(`div`,{className:B(`text-muted-foreground text-sm [&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4 [[data-slot=empty-title]+&]:mt-1`,e),"data-slot":`empty-description`,...t})}function UN({className:e,...t}){return(0,H.jsx)(`div`,{className:B(`animate-skeleton rounded-sm [--skeleton-highlight:--alpha(var(--color-white)/64%)] [background:linear-gradient(120deg,transparent_40%,var(--skeleton-highlight),transparent_60%)_var(--color-muted)_0_0/200%_100%_fixed] dark:[--skeleton-highlight:--alpha(var(--color-white)/4%)]`,e),"data-slot":`skeleton`,...t})}function WN({open:e,onClose:t,ws:n,onPick:r,error:i,pending:a=!1}){let[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(null);(0,V.useEffect)(()=>{e&&(l(!0),d(null),fetch(`/api/workspace/${encodeURIComponent(n.branchName)}/sessions`).then(e=>e.json()).then(e=>{let t=(e.sessions||[]).filter(e=>e.assistant===`claude`||e.assistant===`codex`||e.assistant===`antigravity`||e.assistant===`copilot`);s(t)}).catch(()=>d(`Failed to load sessions.`)).finally(()=>l(!1)))},[e,n.branchName]);let f=e=>{switch(e){case`codex`:return`Codex`;case`antigravity`:return`Antigravity`;case`copilot`:return`Copilot`;default:return`Claude`}};return(0,H.jsx)(Ov,{open:e,onOpenChange:e=>!e&&t(),children:(0,H.jsxs)(Mv,{className:`max-w-lg`,children:[(0,H.jsx)(Nv,{children:(0,H.jsx)(Fv,{children:`Resume a past session`})}),(0,H.jsxs)(Lv,{className:`flex max-h-[60vh] flex-col gap-2`,children:[(i||u)&&(0,H.jsx)(`div`,{className:`rounded-lg border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-foreground`,children:i||u}),c?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(UN,{className:`h-14`}),(0,H.jsx)(UN,{className:`h-14`}),(0,H.jsx)(UN,{className:`h-14`})]}):o.length===0?(0,H.jsx)(LN,{children:(0,H.jsxs)(RN,{children:[(0,H.jsx)(BN,{variant:`icon`,children:(0,H.jsx)(ui,{})}),(0,H.jsx)(VN,{children:`No resumable sessions found`}),(0,H.jsx)(HN,{children:`Past conversations for this workspace will show up here.`})]})}):o.map(e=>(0,H.jsxs)(`button`,{onClick:()=>r(e),disabled:a,className:`cursor-pointer rounded-lg border border-border bg-card p-3 text-left transition-colors hover:border-foreground/15 hover:bg-accent/50 disabled:cursor-wait disabled:opacity-60`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground`,children:f(e.assistant)}),(0,H.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,title:e.title,children:e.title})]}),(0,H.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:a?`Loading transcript…`:new Date(e.updatedAt).toLocaleString()}),(0,H.jsx)(`span`,{children:`·`}),(0,H.jsx)(Xr,{size:11}),(0,H.jsxs)(`span`,{children:[e.messageCount,` messages`]})]})]},e.id))]})]})})}var GN=n(((e,t)=>{var n=[[{color:`0, 0, 0`,class:`ansi-black`},{color:`187, 0, 0`,class:`ansi-red`},{color:`0, 187, 0`,class:`ansi-green`},{color:`187, 187, 0`,class:`ansi-yellow`},{color:`0, 0, 187`,class:`ansi-blue`},{color:`187, 0, 187`,class:`ansi-magenta`},{color:`0, 187, 187`,class:`ansi-cyan`},{color:`255,255,255`,class:`ansi-white`}],[{color:`85, 85, 85`,class:`ansi-bright-black`},{color:`255, 85, 85`,class:`ansi-bright-red`},{color:`0, 255, 0`,class:`ansi-bright-green`},{color:`255, 255, 85`,class:`ansi-bright-yellow`},{color:`85, 85, 255`,class:`ansi-bright-blue`},{color:`255, 85, 255`,class:`ansi-bright-magenta`},{color:`85, 255, 255`,class:`ansi-bright-cyan`},{color:`255, 255, 255`,class:`ansi-bright-white`}]],r=/(https?:\/\/(?:[A-Za-z0-9#;/?:@=+$',_.!~*()[\]-]|&amp;|%[A-Fa-f0-9]{2})+)/gm;t.exports=class e{static escapeForHtml(t){return new e().escapeForHtml(t)}static linkify(t){return new e().linkify(t)}static ansiToHtml(t,n){return new e().ansiToHtml(t,n)}static ansiToJson(t,n){return new e().ansiToJson(t,n)}static ansiToText(t){return new e().ansiToText(t)}constructor(){this.fg=this.bg=this.fg_truecolor=this.bg_truecolor=null,this.bright=0,this.decorations=[]}setupPalette(){this.PALETTE_COLORS=[];for(let e=0;e<2;++e)for(let t=0;t<8;++t)this.PALETTE_COLORS.push(n[e][t].color);let e=[0,95,135,175,215,255],t=(t,n,r)=>e[t]+`, `+e[n]+`, `+e[r];for(let e=0;e<6;++e)for(let n=0;n<6;++n)for(let r=0;r<6;++r)this.PALETTE_COLORS.push(t(e,n,r));let r=8;for(let e=0;e<24;++e,r+=10)this.PALETTE_COLORS.push(r+`, `+r+`, `+r)}escapeForHtml(e){return e.replace(/[&<>\"]/gm,e=>e==`&`?`&amp;`:e==`"`?`&quot;`:e==`<`?`&lt;`:e==`>`?`&gt;`:``)}linkify(e){return e.replace(r,e=>`<a href="${e}">${e}</a>`)}ansiToHtml(e,t){return this.process(e,t,!0)}ansiToJson(e,t){return t||={},t.json=!0,t.clearLine=!1,this.process(e,t,!0)}ansiToText(e){return this.process(e,{},!1)}process(e,t,n){let r=this,i=e.split(/\033\[/),a=i.shift();t??={},t.clearLine=/\r/.test(e);let o=i.map(e=>this.processChunk(e,t,n));if(t&&t.json){let e=r.processChunkJson(``);return e.content=a,e.clearLine=t.clearLine,o.unshift(e),t.remove_empty&&(o=o.filter(e=>!e.isEmpty())),o}return o.unshift(a),o.join(``)}processChunkJson(e,t,r){t=t===void 0?{}:t;let i=t.use_classes=t.use_classes!==void 0&&t.use_classes,a=t.key=i?`class`:`color`,o={content:e,fg:null,bg:null,fg_truecolor:null,bg_truecolor:null,isInverted:!1,clearLine:t.clearLine,decoration:null,decorations:[],was_processed:!1,isEmpty:()=>!o.content},s=e.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);if(!s)return o;o.content=s[4];let c=s[2].split(`;`);if(s[1]!==``||s[3]!==`m`||!r)return o;let l=this;for(;c.length>0;){let e=c.shift(),t=parseInt(e);if(isNaN(t)||t===0)l.fg=l.bg=null,l.decorations=[];else if(t===1)l.decorations.push(`bold`);else if(t===2)l.decorations.push(`dim`);else if(t===3)l.decorations.push(`italic`);else if(t===4)l.decorations.push(`underline`);else if(t===5)l.decorations.push(`blink`);else if(t===7)l.decorations.push(`reverse`);else if(t===8)l.decorations.push(`hidden`);else if(t===9)l.decorations.push(`strikethrough`);else if(t===21)l.removeDecoration(`bold`);else if(t===22)l.removeDecoration(`bold`),l.removeDecoration(`dim`);else if(t===23)l.removeDecoration(`italic`);else if(t===24)l.removeDecoration(`underline`);else if(t===25)l.removeDecoration(`blink`);else if(t===27)l.removeDecoration(`reverse`);else if(t===28)l.removeDecoration(`hidden`);else if(t===29)l.removeDecoration(`strikethrough`);else if(t===39)l.fg=null;else if(t===49)l.bg=null;else if(t>=30&&t<38)l.fg=n[0][t%10][a];else if(t>=90&&t<98)l.fg=n[1][t%10][a];else if(t>=40&&t<48)l.bg=n[0][t%10][a];else if(t>=100&&t<108)l.bg=n[1][t%10][a];else if(t===38||t===48){let e=t===38;if(c.length>=1){let t=c.shift();if(t===`5`&&c.length>=1){let t=parseInt(c.shift());if(t>=0&&t<=255){if(!i)this.PALETTE_COLORS||l.setupPalette(),e?l.fg=this.PALETTE_COLORS[t]:l.bg=this.PALETTE_COLORS[t];else{let r=t>=16?`ansi-palette-`+t:n[+(t>7)][t%8].class;e?l.fg=r:l.bg=r}}}else if(t===`2`&&c.length>=3){let t=parseInt(c.shift()),n=parseInt(c.shift()),r=parseInt(c.shift());if(t>=0&&t<=255&&n>=0&&n<=255&&r>=0&&r<=255){let a=t+`, `+n+`, `+r;i?e?(l.fg=`ansi-truecolor`,l.fg_truecolor=a):(l.bg=`ansi-truecolor`,l.bg_truecolor=a):e?l.fg=a:l.bg=a}}}}}return l.fg===null&&l.bg===null&&l.decorations.length===0?o:(o.fg=l.fg,o.bg=l.bg,o.fg_truecolor=l.fg_truecolor,o.bg_truecolor=l.bg_truecolor,o.decorations=l.decorations,o.decoration=l.decorations.slice(-1).pop()||null,o.was_processed=!0,o)}processChunk(e,t,r){t||={};let i=this.processChunkJson(e,t,r),a=t.use_classes;if(i.decorations=i.decorations.filter(e=>{if(e===`reverse`){i.fg||=n[0][7][a?`class`:`color`],i.bg||=n[0][0][a?`class`:`color`];let e=i.fg;i.fg=i.bg,i.bg=e;let t=i.fg_truecolor;return i.fg_truecolor=i.bg_truecolor,i.bg_truecolor=t,i.isInverted=!0,!1}return!0}),t.json)return i;if(i.isEmpty())return``;if(!i.was_processed)return i.content;let o=[],s=[],c=[],l={},u=e=>{let t=[],n;for(n in e)e.hasOwnProperty(n)&&t.push(`data-`+n+`="`+this.escapeForHtml(e[n])+`"`);return t.length>0?` `+t.join(` `):``};return i.isInverted&&(l[`ansi-is-inverted`]=`true`),i.fg&&(a?(o.push(i.fg+`-fg`),i.fg_truecolor!==null&&(l[`ansi-truecolor-fg`]=i.fg_truecolor,i.fg_truecolor=null)):o.push(`color:rgb(`+i.fg+`)`)),i.bg&&(a?(o.push(i.bg+`-bg`),i.bg_truecolor!==null&&(l[`ansi-truecolor-bg`]=i.bg_truecolor,i.bg_truecolor=null)):o.push(`background-color:rgb(`+i.bg+`)`)),i.decorations.forEach(e=>{if(a){s.push(`ansi-`+e);return}e===`bold`?s.push(`font-weight:bold`):e===`dim`?s.push(`opacity:0.5`):e===`italic`?s.push(`font-style:italic`):e===`hidden`?s.push(`visibility:hidden`):e===`strikethrough`?c.push(`line-through`):c.push(e)}),c.length&&s.push(`text-decoration:`+c.join(` `)),a?`<span class="`+o.concat(s).join(` `)+`"`+u(l)+`>`+i.content+`</span>`:`<span style="`+o.concat(s).join(`;`)+`"`+u(l)+`>`+i.content+`</span>`}removeDecoration(e){let t=this.decorations.indexOf(e);t>=0&&this.decorations.splice(t,1)}}})),KN=n(((e,t)=>{function n(e){if(!e)return``;if(!/\r/.test(e))return e;for(e=e.replace(/\r+\n/gm,`
64
64
  `);/\r./.test(e);)e=e.replace(/^([^\r\n]*)\r+([^\r\n]+)/gm,function(e,t,n){return n+t.slice(n.length)});return e}function r(e){for(var t=0,n=0;n<e.length;n++)e[t].length<=e[n].length&&(t=n);return t}function i(e){if(!/\r/.test(e))return e;for(var t=e.split(`\r`),n=[];t.length>0;){var i=r(t);n.push(t[i]),t=t.slice(i+1)}return n.join(`\r`)}function a(e){if(!e)return``;if(!/\r/.test(e))return e;if(!/\n/.test(e))return i(e);e=e.replace(/\r+\n/gm,`
65
65
  `);var t=e.lastIndexOf(`
66
66
  `);return n(e.slice(0,t))+`
67
- `+i(e.slice(t+1))}t.exports=n,t.exports.escapeCarriageReturn=n,t.exports.escapeCarriageReturnSafe=a})),WN=n((e=>{e.Any=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,e.Cc=/[\0-\x1F\x7F-\x9F]/,e.Cf=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,e.P=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,e.S=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/,e.Z=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/})),GN=n(((e,t)=>{var n=WN();function r(e){let t={};e||={},t.src_Any=n.Any.source,t.src_Cc=n.Cc.source,t.src_Z=n.Z.source,t.src_P=n.P.source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join(`|`),t.src_ZCc=[t.src_Z,t.src_Cc].join(`|`);let r=`[><|]`;return t.src_pseudo_letter=`(?:(?!${r}|${t.src_ZPCc})${t.src_Any})`,t.src_ip4=`(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)`,t.src_auth=`(?:(?:(?!${t.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`,t.src_port=`(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?`,t.src_host_terminator=`(?=$|${r}|${t.src_ZPCc})(?!${e[`---`]?`-(?!--)|`:`-|`}_|:\\d|\\.-|\\.(?!$|${t.src_ZPCc}))`,t.src_path=`(?:[/?#](?:(?!${t.src_ZCc}|${r}|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!${t.src_ZCc}|\\]).)*\\]|\\((?:(?!${t.src_ZCc}|[)]).)*\\)|\\{(?:(?!${t.src_ZCc}|[}]).)*\\}|\\"(?:(?!${t.src_ZCc}|["]).)+\\"|\\'(?:(?!${t.src_ZCc}|[']).)+\\'|\\'(?=${t.src_pseudo_letter}|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!${t.src_ZCc}|[.]|$)|`+(e[`---`]?`\\-(?!--(?:[^-]|$))(?:-*)|`:`\\-+|`)+`,(?!${t.src_ZCc}|$)|;(?!${t.src_ZCc}|$)|\\!+(?!${t.src_ZCc}|[!]|$)|\\?(?!${t.src_ZCc}|[?]|$))+|\\/)?`,t.src_email_name=`[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]{0,63}`,t.src_xn=`xn--[a-z0-9\\-]{1,59}`,t.src_domain_root=`(?:`+t.src_xn+`|${t.src_pseudo_letter}{1,63})`,t.src_domain=`(?:`+t.src_xn+`|(?:${t.src_pseudo_letter})|(?:${t.src_pseudo_letter}(?:-|${t.src_pseudo_letter}){0,61}${t.src_pseudo_letter}))`,t.src_host=`(?:(?:(?:(?:${t.src_domain})\\.)*${t.src_domain}))`,t.tpl_host_fuzzy=`(?:`+t.src_ip4+`|(?:(?:(?:${t.src_domain})\\.)+(?:%TLDS%)))`,t.tpl_host_no_ip_fuzzy=`(?:(?:(?:${t.src_domain})\\.)+(?:%TLDS%))`,t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test=`localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:${t.src_ZPCc}|>|$))`,t.tpl_email_fuzzy=`(^|${r}|"|\\(|${t.src_ZCc})(${t.src_email_name}@${t.tpl_host_fuzzy_strict})`,t.tpl_link_fuzzy=`(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${t.src_ZPCc}))((?![$+<=>^\`|\uff5c])${t.tpl_host_port_fuzzy_strict}${t.src_path})`,t.tpl_link_no_ip_fuzzy=`(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${t.src_ZPCc}))((?![$+<=>^\`|\uff5c])${t.tpl_host_port_no_ip_fuzzy_strict}${t.src_path})`,t}function i(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){t&&Object.keys(t).forEach(function(n){e[n]=t[n]})}),e}function a(e){return Object.prototype.toString.call(e)}function o(e){return a(e)===`[object String]`}function s(e){return a(e)===`[object Object]`}function c(e){return a(e)===`[object RegExp]`}function l(e){return a(e)===`[object Function]`}function u(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,`\\$&`)}var d={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function f(e){return Object.keys(e||{}).reduce(function(e,t){return e||d.hasOwnProperty(t)},!1)}var p={"http:":{validate:function(e,t,n){let r=e.slice(t);return n.re.http||(n.re.http=RegExp(`^\\/\\/${n.re.src_auth}${n.re.src_host_port_strict}${n.re.src_path}`,`i`)),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":`http:`,"ftp:":`http:`,"//":{validate:function(e,t,n){let r=e.slice(t);return n.re.no_http||(n.re.no_http=RegExp(`^`+n.re.src_auth+`(?:localhost|(?:(?:${n.re.src_domain})\\.)+${n.re.src_domain_root})`+n.re.src_port+n.re.src_host_terminator+n.re.src_path,`i`)),n.re.no_http.test(r)?t>=3&&e[t-3]===`:`||t>=3&&e[t-3]===`/`?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){let r=e.slice(t);return n.re.mailto||(n.re.mailto=RegExp(`^${n.re.src_email_name}@${n.re.src_host_strict}`,`i`)),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},m=`a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]`,h=`biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф`.split(`|`);function g(e){return function(t,n){let r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}function _(){return function(e,t){t.normalize(e)}}function v(e){let t=e.re=r(e.__opts__),n=e.__tlds__.slice();e.onCompile(),e.__tlds_replaced__||n.push(m),n.push(t.src_xn),t.src_tlds=n.join(`|`);function i(e){return e.replace(`%TLDS%`,t.src_tlds)}t.email_fuzzy=RegExp(i(t.tpl_email_fuzzy),`i`),t.email_fuzzy_global=RegExp(i(t.tpl_email_fuzzy),`ig`),t.link_fuzzy=RegExp(i(t.tpl_link_fuzzy),`i`),t.link_fuzzy_global=RegExp(i(t.tpl_link_fuzzy),`ig`),t.link_no_ip_fuzzy=RegExp(i(t.tpl_link_no_ip_fuzzy),`i`),t.link_no_ip_fuzzy_global=RegExp(i(t.tpl_link_no_ip_fuzzy),`ig`),t.host_fuzzy_test=RegExp(i(t.tpl_host_fuzzy_test),`i`);let a=[];e.__compiled__={};function d(e,t){throw Error(`(LinkifyIt) Invalid schema "${e}": ${t}`)}Object.keys(e.__schemas__).forEach(function(t){let n=e.__schemas__[t];if(n===null)return;let r={validate:null,link:null};if(e.__compiled__[t]=r,s(n)){c(n.validate)?r.validate=g(n.validate):l(n.validate)?r.validate=n.validate:d(t,n),l(n.normalize)?r.normalize=n.normalize:n.normalize?d(t,n):r.normalize=_();return}if(o(n)){a.push(t);return}d(t,n)}),a.forEach(function(t){e.__compiled__[e.__schemas__[t]]&&(e.__compiled__[t].validate=e.__compiled__[e.__schemas__[t]].validate,e.__compiled__[t].normalize=e.__compiled__[e.__schemas__[t]].normalize)}),e.__compiled__[``]={validate:null,normalize:_()};let f=Object.keys(e.__compiled__).filter(function(t){return t.length>0&&e.__compiled__[t]}).map(u).join(`|`);e.re.schema_test=RegExp(`(^|(?!_)(?:[><\uff5c]|${t.src_ZPCc}))(${f})`,`i`),e.re.schema_search=RegExp(`(^|(?!_)(?:[><\uff5c]|${t.src_ZPCc}))(${f})`,`ig`),e.re.schema_at_start=RegExp(`^${e.re.schema_search.source}`,`i`),e.re.pretest=RegExp(`(${e.re.schema_test.source})|(${e.re.host_fuzzy_test.source})|@`,`i`)}function y(e,t,n,r){let i=e.slice(n,r);this.schema=t.toLowerCase(),this.index=n,this.lastIndex=r,this.raw=i,this.text=i,this.url=i}function b(e,t){if(!(this instanceof b))return new b(e,t);t||f(e)&&(t=e,e={}),this.__opts__=i({},d,t),this.__schemas__=i({},p,e),this.__compiled__={},this.__tlds__=h,this.__tlds_replaced__=!1,this.re={},v(this)}b.prototype.add=function(e,t){return this.__schemas__[e]=t,v(this),this},b.prototype.set=function(e){return this.__opts__=i(this.__opts__,e),this},b.prototype.test=function(e){if(!e.length)return!1;let t,n;if(this.re.schema_test.test(e)){for(n=this.re.schema_search,n.lastIndex=0;(t=n.exec(e))!==null;)if(this.testSchemaAt(e,t[2],n.lastIndex))return!0}return!!(this.__opts__.fuzzyLink&&this.__compiled__[`http:`]&&e.search(this.re.host_fuzzy_test)>=0&&e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy)!==null||this.__opts__.fuzzyEmail&&this.__compiled__[`mailto:`]&&e.indexOf(`@`)>=0&&e.match(this.re.email_fuzzy)!==null)},b.prototype.pretest=function(e){return this.re.pretest.test(e)},b.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},b.prototype.match=function(e){let t=[],n=[],r=[],i=[],a,o,s;function c(e,t){return e?t?e.index===t.index?e.lastIndex>=t.lastIndex?e:t:e.index<t.index?e:t:e:t}if(!e.length)return null;if(this.re.schema_test.test(e))for(s=this.re.schema_search,s.lastIndex=0;(a=s.exec(e))!==null;)o=this.testSchemaAt(e,a[2],s.lastIndex),o&&n.push({schema:a[2],index:a.index+a[1].length,lastIndex:a.index+a[0].length+o});if(this.__opts__.fuzzyLink&&this.__compiled__[`http:`])for(s=this.__opts__.fuzzyIP?this.re.link_fuzzy_global:this.re.link_no_ip_fuzzy_global,s.lastIndex=0;(a=s.exec(e))!==null;)r.push({schema:``,index:a.index+a[1].length,lastIndex:a.index+a[0].length});if(this.__opts__.fuzzyEmail&&this.__compiled__[`mailto:`])for(s=this.re.email_fuzzy_global,s.lastIndex=0;(a=s.exec(e))!==null;)i.push({schema:`mailto:`,index:a.index+a[1].length,lastIndex:a.index+a[0].length});let l=[0,0,0],u=0;for(;;){let a=[n[l[0]],i[l[1]],r[l[2]]],o=c(c(a[0],a[1]),a[2]);if(!o)break;if(o===a[0]?l[0]++:o===a[1]?l[1]++:l[2]++,o.index<u)continue;let s=new y(e,o.schema,o.index,o.lastIndex);this.__compiled__[s.schema].normalize(s,this),t.push(s),u=o.lastIndex}return t.length?t:null},b.prototype.matchAtStart=function(e){if(!e.length)return null;let t=this.re.schema_at_start.exec(e);if(!t)return null;let n=this.testSchemaAt(e,t[2],t[0].length);if(!n)return null;let r=new y(e,t[2],t.index+t[1].length,t.index+t[0].length+n);return this.__compiled__[r.schema].normalize(r,this),r},b.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(e,t,n){return e!==n[t-1]}).reverse(),v(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,v(this),this)},b.prototype.normalize=function(e){e.schema||(e.url=`http://${e.url}`),e.schema===`mailto:`&&!/^mailto:/i.test(e.url)&&(e.url=`mailto:${e.url}`)},b.prototype.onCompile=function(){},t.exports=b})),KN=t(n((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;o<a.length;o++)a[o]!=="default"&&t(i,r,a[o]);return n(i,r),i}})(),a=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=g;var o=a(HN()),s=UN(),c=a(GN()),l=i(r());function u(e,t=!1){return e=(0,s.escapeCarriageReturn)(_(e)),o.default.ansiToJson(e,{json:!0,remove_empty:!0,use_classes:t})}function d(e){let t=``;return e.bg&&(t+=`${e.bg}-bg `),e.fg&&(t+=`${e.fg}-fg `),e.decoration&&(t+=`ansi-${e.decoration} `),t===``?null:(t=t.substring(0,t.length-1),t)}function f(e){let t={};switch(e.bg&&(t.backgroundColor=`rgb(${e.bg})`),e.fg&&(t.color=`rgb(${e.fg})`),e.decoration){case`bold`:t.fontWeight=`bold`;break;case`dim`:t.opacity=`0.5`;break;case`italic`:t.fontStyle=`italic`;break;case`hidden`:t.visibility=`hidden`;break;case`strikethrough`:t.textDecoration=`line-through`;break;case`underline`:t.textDecoration=`underline`;break;case`blink`:t.textDecoration=`blink`}return t}function p(e,t,n,r){let i=t?null:f(n),a=t?d(n):null;return e?e===`fuzzy`?h(n,r,i,a):m(n,r,i,a):l.createElement(`span`,{style:i,key:r,className:a},n.content)}function m(e,t,n,r){let i=[],a=/(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g,o=0,s;for(;(s=a.exec(e.content))!==null;){let[,t,n]=s,r=s.index+t.length;r>o&&i.push(e.content.substring(o,r));let c=n.startsWith(`www.`)?`http://${n}`:n;i.push(l.createElement(`a`,{key:o,href:c,target:`_blank`},`${n}`)),o=a.lastIndex}return o<e.content.length&&i.push(e.content.substring(o)),l.createElement(`span`,{style:n,key:t,className:r},i)}function h(e,t,n,r){let i=(0,c.default)({fuzzyEmail:!1}).tlds([`io`],!0);if(!i.pretest(e.content))return l.createElement(`span`,{style:n,key:t,className:r},e.content);let a=i.match(e.content);if(!a)return l.createElement(`span`,{style:n,key:t,className:r},e.content);let o=[e.content.substring(0,a[0]?.index)];return a.forEach((t,n)=>{o.push(l.createElement(`a`,{href:t.url,target:`_blank`,key:n},e.content.substring(t.index,t.lastIndex))),a[n+1]&&o.push(e.content.substring(a[n].lastIndex,a[n+1]?.index))}),a[a.length-1].lastIndex!==e.content.length&&o.push(e.content.substring(a[a.length-1].lastIndex,e.content.length)),l.createElement(`span`,{style:n,key:t,className:r},o)}function g(e){let{className:t,useClasses:n,children:r,linkify:i}=e;return l.createElement(`code`,{className:t},u(r??``,n??!1).map(p.bind(null,i??!1,n??!1)))}function _(e){let t=e;do e=t,t=e.replace(/[^\n]\x08/gm,``);while(t.length<e.length);return e}}))(),1),qN=KN.default.default||KN.default,JN=[{id:``,label:`Auto Effort`,description:`Model/provider default reasoning depth`},{id:`low`,label:`Low Effort`,description:`Fast responses with lightweight reasoning`},{id:`medium`,label:`Medium Effort`,description:`Balanced reasoning depth and latency`},{id:`high`,label:`High Effort`,description:`Deep multi-step reasoning and verification`},{id:`max`,label:`Max Effort`,description:`Maximum thinking budget for complex tasks`}];function YN(e){return e?e.charAt(0).toUpperCase()+e.slice(1):`Auto`}var XN={"claude-cli":new Set([`npm install -g @anthropic-ai/claude-code`,`claude auth login`,`claude auth status --json`]),"claude-sdk":new Set([`npm install -g @anthropic-ai/claude-code`,`claude auth login`,`claude auth status --json`]),"codex-cli":new Set([`npm install -g @openai/codex`,`codex login`,`codex login status`]),"codex-sdk":new Set([`npm install -g @openai/codex`,`codex login`,`codex login status`]),"antigravity-cli":new Set([`agy`]),"copilot-cli":new Set([`copilot login`,`copilot help`])},ZN=new Set([`native-api`,`cli-print`,`acp`,`sdk`]),QN=new Set([`none`,`client-assigned`,`provider-assigned`]),$N=new Set([`read-only`,`workspace-write`,`harness-managed`]),eP=new Set([`uuid`,`opaque`]),tP=new Set([`missing-cli`,`signed-out`,`probe-failed`]);function nP(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function rP(e){return e===void 0||typeof e==`string`}function iP(e){return!nP(e)||typeof e.transport!=`string`||!ZN.has(e.transport)||typeof e.sessionIdentity!=`string`||!QN.has(e.sessionIdentity)||typeof e.workspaceAccess!=`string`||!$N.has(e.workspaceAccess)||e.sessionIdFormat!==void 0&&(typeof e.sessionIdFormat!=`string`||!eP.has(e.sessionIdFormat))?null:{transport:e.transport,sessionIdentity:e.sessionIdentity,workspaceAccess:e.workspaceAccess,...e.sessionIdFormat===void 0?{}:{sessionIdFormat:e.sessionIdFormat}}}function aP(e){if(!nP(e)||typeof e.id!=`string`||typeof e.name!=`string`||typeof e.isConfigured!=`boolean`||!rP(e.icon)||!rP(e.accessLabel)||!rP(e.message)||!rP(e.recoveryCommand)||!rP(e.recoveryLabel)||e.setupIssue!==void 0&&(typeof e.setupIssue!=`string`||!tP.has(e.setupIssue)))return null;let t=iP(e.capabilities);if(!t)return null;let n;if(e.executionProfiles!==void 0){if(!Array.isArray(e.executionProfiles)||e.executionProfiles.length===0)return null;n=[];let t=new Set;for(let r of e.executionProfiles){if(!nP(r)||!vN(r.id)||typeof r.label!=`string`||typeof r.description!=`string`||t.has(r.id))return null;t.add(r.id),n.push({id:r.id,label:r.label,description:r.description})}}if(e.defaultExecutionProfile!==void 0&&(!vN(e.defaultExecutionProfile)||!n?.some(t=>t.id===e.defaultExecutionProfile))||n&&e.defaultExecutionProfile===void 0||!n&&e.defaultExecutionProfile!==void 0)return null;let r;if(e.models!==void 0){if(!Array.isArray(e.models)||e.models.length===0)return null;r=[];let t=new Set;for(let n of e.models){if(!nP(n)||typeof n.id!=`string`||n.id.length>100||typeof n.label!=`string`||n.label.length===0||n.label.length>100||typeof n.description!=`string`||n.description.length>300||t.has(n.id))return null;t.add(n.id),r.push({id:n.id,label:n.label,description:n.description})}}let i=e.setupIssue!==void 0||e.recoveryCommand!==void 0||e.recoveryLabel!==void 0,a=e.setupIssue!==void 0&&e.recoveryCommand!==void 0&&e.recoveryLabel!==void 0;return i&&!a||e.isConfigured&&i?null:{id:e.id,name:e.name,isConfigured:e.isConfigured,capabilities:t,...e.icon===void 0?{}:{icon:e.icon},...e.accessLabel===void 0?{}:{accessLabel:e.accessLabel},...e.message===void 0?{}:{message:e.message},...e.setupIssue===void 0?{}:{setupIssue:e.setupIssue},...e.recoveryCommand===void 0?{}:{recoveryCommand:e.recoveryCommand},...e.recoveryLabel===void 0?{}:{recoveryLabel:e.recoveryLabel},...n===void 0?{}:{executionProfiles:n},...e.defaultExecutionProfile===void 0?{}:{defaultExecutionProfile:e.defaultExecutionProfile},...r===void 0?{}:{models:r}}}function oP(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){let e=aP(n);if(!e)return null;t.push(e)}return t}function sP(e){return!e.recoveryCommand||!XN[e.id]?.has(e.recoveryCommand)?null:{command:e.recoveryCommand,label:e.recoveryLabel??`Copy recovery command`}}function cP(e){return!e||e.toLowerCase().includes(`review`)?`Review`:e.toLowerCase().includes(`edit`)||e.toLowerCase().includes(`write`)?`Edit`:e}function lP(e,t){if(!t)return`Auto`;let n=e.models?.find(e=>e.id===t);return n?n.label:t}function uP(e,t){let n=!1,r={...e};for(let i of t){let t=e[i.id];t&&i.models&&!i.models.some(e=>e.id===t)&&(delete r[i.id],n=!0)}return n?r:e}var dP=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):null,fP=(0,V.memo)(function({msg:e,idx:t,copied:n,onCopy:r}){if(e.role===`system`)return(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsx)(`span`,{className:B(`rounded-full border px-3 py-1 text-center text-[11px]`,e.kind===`error`?`border-destructive/25 bg-destructive/10 text-destructive-foreground`:`border-border bg-muted text-muted-foreground`),children:e.content})});let i=e.role===`user`,a=!i&&e.content.includes(`\x1B`);return(0,H.jsxs)(`div`,{className:`flex flex-col ${i?`items-end`:`items-start`}`,children:[(0,H.jsx)(`div`,{className:`group relative max-w-[85%] rounded-lg p-3 ${i?`bg-primary text-primary-foreground`:`border border-border bg-card text-foreground`}`,children:i?(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.images&&e.images.length>0&&(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.images.map((e,t)=>(0,H.jsx)(`img`,{src:e,alt:`Attached`,className:`max-h-48 max-w-full rounded-lg border border-white/20 object-contain shadow-xs cursor-pointer hover:opacity-95`,onClick:()=>window.open(e,`_blank`)},t))}),e.content&&(0,H.jsx)(`div`,{className:`whitespace-pre-wrap text-sm`,children:e.content})]}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a?(0,H.jsx)(`div`,{className:`overflow-x-auto whitespace-pre-wrap rounded-md bg-muted/50 p-2 font-mono text-xs text-foreground`,children:(0,H.jsx)(qN,{children:e.content})}):(0,H.jsx)(Dv,{content:e.content}),e.filesChanged&&e.filesChanged.length>0&&(0,H.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5 rounded-md border border-border/70 bg-muted/30 p-2 text-xs`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground`,children:[(0,H.jsx)(Fr,{size:13,className:`text-primary`}),(0,H.jsxs)(`span`,{children:[e.filesChanged.length,` file`,e.filesChanged.length>1?`s`:``,` modified`]})]}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.filesChanged.map((e,t)=>(0,H.jsx)(`span`,{className:`rounded bg-background px-1.5 py-0.5 font-mono text-[10px] text-foreground border border-border/50`,children:e},t))})]}),(0,H.jsx)(`button`,{onClick:()=>r(t,e.content),className:`absolute -right-2.5 -top-2.5 hidden h-6 w-6 cursor-pointer place-items-center rounded-md border border-border bg-card text-muted-foreground shadow-sm hover:text-foreground group-hover:grid`,title:`Copy message`,children:n?(0,H.jsx)(wr,{size:12,className:`text-success-foreground`}):(0,H.jsx)(Mr,{size:12})})]})}),i&&e.executionProfile&&(0,H.jsx)(`span`,{className:`mt-1 rounded border border-border px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.executionProfile===`workspace-write`?`Edit`:`Review`}),e.ts&&(0,H.jsx)(`span`,{className:`mt-1 text-[10px] text-muted-foreground`,children:dP(e.ts)})]})});function pP({ws:e,draft:t,onDraftConsumed:n}){let r=Ft(),i=Lt(),[a,o]=(0,V.useState)([]),[s,c]=(0,V.useState)(!1),[l]=(0,V.useState)(()=>SN(e.branchName)),[u,d]=(0,V.useState)(l.messages),[f,p]=(0,V.useState)(``),m=(0,V.useRef)(null);(0,V.useEffect)(()=>{!t||m.current===t.id||(m.current=t.id,p(e=>e?`${e}\n\n${t.text}`:t.text),n?.(t.id))},[t,n]);let[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(``),[C,w]=(0,V.useState)(l.profilesByProvider),[T,E]=(0,V.useState)(l.modelsByProvider??{}),[D,ee]=(0,V.useState)(l.effortsByProvider??{}),[O,k]=(0,V.useState)(null),[A,te]=(0,V.useState)(!1),[j,M]=(0,V.useState)(l.sessions),[N,ne]=(0,V.useState)(0),[re,ie]=(0,V.useState)(!1),[P,F]=(0,V.useState)(null),[I,L]=(0,V.useState)(!1),[ae,R]=(0,V.useState)(null),[oe,z]=(0,V.useState)(!1),[se,ce]=(0,V.useState)(null),[le,ue]=(0,V.useState)(null),[de,fe]=(0,V.useState)([]),[pe,me]=(0,V.useState)(!1),he=(0,V.useRef)(null),ge=(0,V.useRef)(!1),_e=(0,V.useCallback)((e,t)=>{d(n=>[...n,{role:`system`,content:e,kind:t,ts:Date.now()}])},[]),ve=(0,V.useCallback)(e=>{let t=Array.from(e),n=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]),r=t.filter(e=>!n.has(e.type));r.length>0&&_e(`${r.length} unsupported file(s) ignored. Attach PNG, JPEG, GIF, or WebP images.`,`note`);let i=t.filter(e=>n.has(e.type));if(i.length!==0)for(let e of i){if(e.size>20971520){_e(`Image "${e.name}" exceeds the 20MB limit and was not attached.`,`error`);continue}let t=new FileReader;t.onload=t=>{let n=t.target?.result;typeof n==`string`&&n.startsWith(`data:image/`)?fe(t=>[...t,{id:crypto.randomUUID(),name:e.name||`pasted-image-${Date.now()}.png`,dataUrl:n,file:e}]):_e(`Image "${e.name||`pasted image`}" could not be read.`,`error`)},t.onerror=()=>_e(`Image "${e.name||`pasted image`}" could not be read.`,`error`),t.readAsDataURL(e)}},[_e]),ye=(0,V.useCallback)(e=>{M(t=>{let n=e(t);return we.current=n,n}),ne(e=>e+1)},[]),be=(0,V.useRef)(null),xe=(0,V.useRef)(null),Se=(0,V.useRef)(null),Ce=(0,V.useRef)(!0),we=(0,V.useRef)(l.sessions),Te=(0,V.useRef)([]),Ee=(0,V.useRef)(!1),De=(0,V.useRef)(!1),Oe=(0,V.useRef)({messages:u,agentName:x,profilesByProvider:C,modelsByProvider:T,effortsByProvider:D}),ke=(0,V.useRef)(C),Ae=(0,V.useRef)(null),je=(0,V.useRef)(null),Me=(0,V.useRef)(!0),Ne=(0,V.useRef)(0),Pe=(0,V.useRef)(null),Fe=(0,V.useRef)(!1),Ie=(0,V.useRef)({id:0,controller:null}),Le=(0,V.useMemo)(()=>NN(r.state),[r.state]),[Re,ze]=(0,V.useState)([]),Be=(0,V.useRef)(new Set),Ve=(0,V.useRef)(!1),He=(0,V.useRef)(!1),Ue=(0,V.useRef)(null);(0,V.useEffect)(()=>{Ve.current=_},[_]);let We=(0,V.useCallback)((e,t)=>{let n=be.current;n&&n.readyState===WebSocket.OPEN&&n.send(JSON.stringify({type:`approval_response`,requestId:e,decision:t})),ze(t=>t.filter(t=>t.requestId!==e))},[]);(0,V.useEffect)(()=>{Oe.current={messages:u,agentName:x,profilesByProvider:C,modelsByProvider:T,effortsByProvider:D},ke.current=C},[u,x,C,T,D]);let Ge=(0,V.useCallback)(()=>{Ae.current=null,DN(e.branchName,{v:4,sessions:we.current,providerId:Oe.current.agentName||l.providerId,profilesByProvider:Oe.current.profilesByProvider,modelsByProvider:Oe.current.modelsByProvider,effortsByProvider:Oe.current.effortsByProvider,messages:Oe.current.messages})},[e.branchName,l.providerId]);(0,V.useEffect)(()=>{let e=u[u.length-1];(Ce.current||e?.role===`user`)&&Se.current?.scrollIntoView({behavior:e?.role===`user`?`smooth`:`auto`}),Ae.current&&clearTimeout(Ae.current),Ae.current=setTimeout(Ge,400)},[u,x,C,T,N,Ge]),(0,V.useEffect)(()=>{let e=()=>Ge();return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e),Ae.current&&clearTimeout(Ae.current),Ge()}},[Ge]),(0,V.useEffect)(()=>{let t=!0;return wN(e.branchName).then(e=>{if(!(!t||!e)&&(d(t=>{if(t.length===0&&e.messages.length>0)return e.messages;let n=new Map(e.messages.filter(e=>e.images?.length).map(e=>[`${e.role}:${e.ts??``}:${e.content}`,e.images])),r=!1,i=t.map(e=>{if(e.images?.length)return e;let t=n.get(`${e.role}:${e.ts??``}:${e.content}`);return t?(r=!0,{...e,images:t}):e});return r?i:t}),e.sessions&&Object.keys(e.sessions).length>0&&ye(t=>({...e.sessions,...t})),e.isBusy&&!be.current)){let t=e.providerId||x;t&&Ue.current&&Ue.current(t,{firstMessage:null})}}),()=>{t=!1}},[e.branchName,ye,x]),(0,V.useEffect)(()=>{let t=++Ne.current,n=new AbortController,r=!0;return fetch(`/api/adapters/status`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`,signal:n.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(n=>{if(!r||t!==Ne.current)return;let i=oP(n);if(!i)throw Error(`Invalid provider status response`);o(i),E(e=>uP(e,i)),w(e=>{let t=!1,n={...e};for(let r of i)!r.executionProfiles?.length||!r.defaultExecutionProfile||r.executionProfiles.some(t=>t.id===e[r.id])||(n[r.id]=r.defaultExecutionProfile,t=!0);return t?n:e});let a=e.assistants?.[0]?MN(e.assistants[0]):void 0,s=l.providerId?i.find(e=>e.id===l.providerId):void 0,c=a?i.find(e=>e.id===a&&e.isConfigured):void 0,u=s||c||i.find(e=>e.isConfigured)||i[0];u&&S(e=>e||u.id)}).catch(e=>{r&&e?.name!==`AbortError`&&console.error(`Failed to fetch agent data`,e)}).finally(()=>{r&&t===Ne.current&&c(!0)}),()=>{r=!1,n.abort()}},[l.providerId,e.assistants]),(0,V.useEffect)(()=>(Me.current=!0,()=>{Me.current=!1,Ie.current.id+=1,Ie.current.controller?.abort(),be.current&&be.current.close()}),[e.branchName,e.workspacePath]);let Ke=O??x,qe=a.find(e=>e.id===Ke),Je=qe?.executionProfiles?.find(e=>e.id===C[qe.id])??qe?.executionProfiles?.find(e=>e.id===qe.defaultExecutionProfile),Ye=!!x&&!!qe?.isConfigured&&(!qe?.executionProfiles||!!Je)&&!A&&!re,Xe=(0,V.useCallback)(e=>{_||A||re||(be.current&&=(be.current.close(),null),g(!1),k(null),F(null),S(e),Oe.current.agentName=e,Ae.current&&clearTimeout(Ae.current),Ge())},[_,A,re,Ge]),Ze=(0,V.useCallback)((e,t)=>{let n=t??a.find(t=>t.id===e);if(!n?.executionProfiles?.length)return;let r=ke.current[e];return r&&n.executionProfiles.some(e=>e.id===r)?r:n.defaultExecutionProfile??`review`},[a]),Qe=(0,V.useCallback)(()=>{Ee.current=!1,b(!1)},[]),$e=(0,V.useCallback)(async(t,n,r,i)=>{if(ge.current)return;ge.current=!0;let a=i??de;try{let i=crypto.randomUUID(),o=[],s=[],c=!1;if(a.length>0){let t=await Promise.all(a.map(async t=>{try{let n=await fetch(`/api/chat/upload-attachment`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({dataUrl:t.dataUrl,filename:t.name,workspacePath:e.workspacePath})});if(n.ok){let e=await n.json();if(typeof e.path==`string`&&e.path)return{dataUrl:t.dataUrl,path:e.path};throw Error(`Invalid upload response`)}let r=await n.json().catch(()=>({error:`Upload failed`}));c=!0,_e(`Image "${t.name}" could not be uploaded: ${r.error||n.statusText}`,`error`)}catch(e){console.error(`Failed to upload image attachment`,e),c=!0,_e(`Image "${t.name}" failed to upload.`,`error`)}return{dataUrl:t.dataUrl,path:null}}));if(c){_e(`The message was kept in the composer. Fix or remove the failed image, then try again.`,`note`);return}o=t.map(e=>e.path).filter(e=>!!e),s=t.map(e=>e.dataUrl)}let l=n;if(o.length>0){let e=o.map(e=>`[Attached image: ${e}]`).join(`
68
- `);l=l?`${l}\n\n${e}`:e}let u={role:`user`,content:n,ts:Date.now(),...r?{executionProfile:r}:{},...s.length>0?{images:s}:{}};if(t.readyState!==WebSocket.OPEN||be.current!==t){_e(`The agent disconnected while images were uploading. Your draft and attachments were kept.`,`error`);return}Te.current.push({turnId:i,text:l,message:u});let f=D[x];try{t.send(JSON.stringify({type:`input`,input:l,turnId:i,...r?{executionProfile:r}:{},command:x,cwd:e.workspacePath,...f?{effort:f}:{}}))}catch{Te.current=Te.current.filter(e=>e.turnId!==i),_e(`Failed to send message to the agent. Your draft and attachments were kept.`,`error`);return}d(e=>[...e,u]),p(e=>e.trim()===n?``:e);let m=new Set(a.map(e=>e.id));fe(e=>e.filter(e=>!m.has(e.id))),v(!0),Qe()}finally{ge.current=!1}},[x,_e,de,Qe,D,e.workspacePath]),et=(0,V.useCallback)(()=>{De.current||(De.current=!0,_e(`Session ended`,`note`))},[_e]),tt=(0,V.useCallback)(()=>{He.current=!0;let e=be.current;if(e){if(e.readyState===WebSocket.OPEN)try{e.send(JSON.stringify({type:`stop`}))}catch{}be.current=null,Pe.current=null,k(null),te(!1),e.close(),g(!1),v(!1),Qe(),et()}},[Qe,et]),nt=(0,V.useCallback)((t=x,n={})=>{if(He.current=!1,be.current)return n.onFailure?.(),!1;let r=n.provider??a.find(e=>e.id===t);if(S(t),!r?.isConfigured)return _e(r?.message??`The ${t} provider is unavailable. Check its local CLI installation and login.`,`error`),n.onFailure?.(),!1;let i=n.executionProfile??Ze(t,r),o=i!==void 0&&r.executionProfiles?.some(e=>e.id===i)===!0;if((n.executionProfile!==void 0||r.executionProfiles?.length)&&!o)return _e(`Select a supported execution profile before starting this local CLI.`,`error`),n.onFailure?.(),!1;let s=n.model??T[t];if(s&&r.models&&!r.models.some(e=>e.id===s))return _e(`Select a model advertised by this provider before starting the harness.`,`error`),n.onFailure?.(),!1;let c=``;c=c.startsWith(`http`)?c.replace(`http`,`ws`):window.location.origin.replace(`http`,`ws`),c+=`/ws`,De.current=!1;let l=!1,u=!1,m,h=()=>{u||l||!Me.current||(u=!0,v(!1),te(!1),g(!1),_e(`Could not open the local agent connection. Your current chat was preserved; retry explicitly when ready.`,`error`),n.onFailure?.())};try{m=new WebSocket(c)}catch{return h(),!1}return m.onopen=()=>{if(!Me.current||be.current!==m){m.close();return}let a={type:`start`,command:t,cwd:e.workspacePath};s&&(a.model=s);let o=D[t];o&&(a.effort=o);let c={...we.current};if(n.resetSession&&delete c[t],n.session&&(c[t]=n.session),r.capabilities.sessionIdentity===`client-assigned`){let e=c[t]??{id:crypto.randomUUID(),started:!1};c[t]=e,a.sessionId=e.id,a.resume=e.started}else if(r.capabilities.sessionIdentity===`provider-assigned`){let e=c[t];e?.started&&(a.sessionId=e.id,a.resume=!0)}let u=n.firstMessage===null?``:(n.firstMessage??f).trim(),_;try{if(m.send(JSON.stringify(a)),u){let e=crypto.randomUUID();_={turnId:e,text:u,message:{role:`user`,content:u,ts:Date.now(),...i?{executionProfile:i}:{}}},Te.current.push(_),m.send(JSON.stringify({type:`input`,input:u,turnId:e,...i?{executionProfile:i}:{}}))}}catch{_&&(Te.current=Te.current.filter(e=>e.turnId!==_?.turnId)),h(),be.current=null,Pe.current=null,k(null),te(!1),m.close();return}ye(()=>c),l=!0,te(!1),g(!0),n.resetMessagesOnDispatch&&d([]),u&&(d(e=>[...n.resetMessagesOnDispatch?[]:e,_?.message??{role:`user`,content:u,ts:Date.now(),...i?{executionProfile:i}:{}}]),p(``),v(!0),Qe()),n.onDispatched?.()},m.onmessage=e=>{if(be.current===m)try{let n=JSON.parse(e.data);if(n.type===`stream`){let e=Ee.current;Ee.current=!0,b(!0),d(t=>{let r=t[t.length-1];if(e&&r?.role===`assistant`){let e=[...t];return e[e.length-1]={...r,content:r.content+n.text},e}return[...t,{role:`assistant`,content:n.text,ts:Date.now()}]})}else if(n.type===`session`&&typeof n.id==`string`)/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n.id)&&ye(e=>({...e,[t]:{id:n.id,started:!0}}));else if(n.type===`approval_request`&&typeof n.requestId==`string`)ze(e=>[...e.filter(e=>e.requestId!==n.requestId),{requestId:n.requestId,tool:typeof n.tool==`string`?n.tool:`Tool`,input:n.input&&typeof n.input==`object`?n.input:{},description:typeof n.description==`string`?n.description:void 0}]);else if(n.type===`accepted`&&typeof n.turnId==`string`)Te.current=Te.current.filter(e=>e.turnId!==n.turnId);else if(n.type===`file_changed`){if(Array.isArray(n.paths))for(let e of n.paths)typeof e==`string`&&e.trim()&&Be.current.add(e.trim())}else if(n.type===`status`){if(v(n.state===`busy`),n.state!==`busy`){let e=Array.from(Be.current);Be.current.clear(),e.length>0&&d(t=>{for(let n=t.length-1;n>=0;n--)if(t[n].role===`assistant`){let r=[...t],i=r[n].filesChanged||[],a=Array.from(new Set([...i,...e]));return r[n]={...r[n],filesChanged:a},r}return t}),Qe(),ze([])}}else if(n.type===`system`)_e(n.message,`note`);else if(n.type===`rejected`&&n.reason===`busy`){let e=Te.current.findIndex(e=>e.turnId===n.turnId),t=e===-1?void 0:Te.current.splice(e,1)[0];t&&(d(e=>e.filter(e=>e!==t.message)),p(e=>e?`${t.text}\n\n${e}`:t.text)),_e(typeof n.message==`string`?n.message:`The agent is still processing the current turn.`,`error`)}else n.type===`error`?(Te.current=[],ze([]),Be.current.clear(),typeof n.message==`string`&&n.message.toLowerCase().includes(`session`)&&ye(e=>{let n={...e};return delete n[t],n}),_e(n.message,`error`),v(!1),te(!1),Qe()):n.type===`close`&&(Te.current=[],ze([]),Be.current.clear(),g(!1),te(!1),v(!1),Qe(),et(),m.close(),be.current=null)}catch(e){console.error(`Failed to parse WS message`,e)}},m.onclose=()=>{if(be.current!==m)return;l||h();let e=Ve.current,n=He.current;if(g(!1),te(!1),v(!1),Qe(),be.current=null,Pe.current=null,k(null),e&&Me.current&&!n){_e(`Connection interrupted. Resuming turn...`,`note`),setTimeout(()=>{Me.current&&!He.current&&!be.current&&Ue.current?.(t,{firstMessage:null})},1200);return}l&&et()},m.onerror=()=>{be.current===m&&(h(),v(!1),te(!1),l||(be.current=null,Pe.current=null,k(null),g(!1),m.close()))},be.current=m,Pe.current=t,k(t),te(!0),!0},[x,_e,Qe,D,f,T,et,Ze,a,ye,e.workspacePath]);(0,V.useEffect)(()=>{Ue.current=nt},[nt]);let rt=(0,V.useCallback)(()=>{let e=f.trim();if(!e&&de.length===0||_||Fe.current||ge.current)return;let t=be.current,n=Pe.current||x;if(!h||!t||t.readyState!==WebSocket.OPEN){if(t){try{t.close()}catch{}be.current=null}if(de.length>0){let t=a.find(e=>e.id===n),r=Ze(n,t);if(t?.executionProfiles?.length&&!r)return;let i=e,o=de;nt(n,{firstMessage:null,onDispatched:()=>{let e=be.current;if(!e||e.readyState!==WebSocket.OPEN){_e(`The agent connected, but the pasted message could not be sent. Your draft and attachments were kept.`,`error`);return}$e(e,i,r,o)}})}else nt(n,{firstMessage:e});return}let r=a.find(e=>e.id===n),i=Ze(n,r);r?.executionProfiles?.length&&!i||$e(t,e,i,de)},[x,_e,de,_,h,f,Ze,a,$e,nt]),it=(0,V.useCallback)((e,t)=>{QS(t).then(t=>{if(!t){_e(`Could not copy this message. Check browser clipboard permissions or copy it manually.`,`error`);return}ue(e),setTimeout(()=>ue(t=>t===e?null:t),1500)})},[_e]),at=(0,V.useCallback)(e=>{Ie.current.id===e&&(Ie.current.controller=null,Fe.current=!1,Me.current&&ie(!1))},[]),ot=(0,V.useCallback)(async(e,t=!1)=>{let n=Ie.current.id+1;Ie.current.controller?.abort();let r=new AbortController;Ie.current={id:n,controller:r},Fe.current=!0,ie(!0),ce(null);let i=MN(e.assistant);if(!i)return _e(`This session cannot resume in embedded chat.`,`error`),at(n),!1;let o=a.find(e=>e.id===i);if(!o?.isConfigured)return _e(o?.message??`The ${i} provider is unavailable. Check its local CLI installation and login.`,`error`),at(n),!1;let s=()=>Me.current&&Ie.current.id===n&&!r.signal.aborted;try{let a=await fetch(`/api/session/${encodeURIComponent(e.assistant)}/${encodeURIComponent(e.id)}/transcript`,{signal:r.signal});if(!a.ok)throw Error(`HTTP ${a.status}`);let o=await a.json();if(!s())return!1;let c=(Array.isArray(o.messages)?o.messages:[]).filter(e=>(e.role===`user`||e.role===`assistant`)&&typeof e.content==`string`&&e.content.trim()).map(e=>({role:e.role,content:e.content,ts:e.timestamp&&Date.parse(e.timestamp)||void 0}));if(be.current&&!window.confirm(`Stop the current chat and resume this session?`))return at(n),!1;be.current&&tt(),S(i);let l=()=>{s()&&(w(e=>({...e,[i]:`review`})),d([...c,{role:`system`,kind:`note`,content:`Loaded session — your next message resumes it.`,ts:Date.now()}]),p(``),z(!1),at(n))};return t?nt(i,{firstMessage:null,session:{id:e.id,started:!0},onDispatched:l,onFailure:()=>{s()&&(ce(`Failed to connect to the selected session.`),at(n))}}):(ye(t=>({...t,[i]:{id:e.id,started:!0}})),l(),!0)}catch(e){return!s()||e instanceof DOMException&&e.name===`AbortError`?!1:(ce(`Failed to load the session transcript.`),_e(`Failed to load the session transcript. Your current chat was preserved.`,`error`),at(n),!1)}},[_e,at,a,nt,tt,ye]),st=(0,V.useCallback)(e=>{ot(e)},[ot]),ct=(0,V.useCallback)(async(e,t=!1,n=!1)=>{F(e);let r;if(t){L(!0);try{let t=await fetch(`/api/adapters/status/refresh`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({providerId:e.providerId})});if(!t.ok)throw Error(`HTTP ${t.status}`);let i=oP(await t.json());if(!i)throw Error(`Invalid provider status response`);if(!Me.current)return!1;o(i),E(e=>uP(e,i)),r=i.find(t=>t.id===e.providerId);let a=n&&(r?.setupIssue===`signed-out`||r?.setupIssue===`probe-failed`);if(!r||!r.isConfigured&&!a)return _e(r?.message??`The selected local CLI is still unavailable. Install it and sign in, then retry.`,`error`),!1}catch{return Me.current&&_e(`Could not refresh the local CLI status. The task handoff was not dispatched.`,`error`),!1}finally{Me.current&&L(!1)}}return nt(e.providerId,{firstMessage:e.kickoff,executionProfile:e.executionProfile,provider:r&&n&&(r.setupIssue===`signed-out`||r.setupIssue===`probe-failed`)?{...r,isConfigured:!0}:r,resetSession:!0,resetMessagesOnDispatch:!0,onDispatched:()=>{Me.current&&F(null)},onFailure:()=>{Me.current&&F(e)}})},[_e,nt]);(0,V.useEffect)(()=>{if(!s||!Le)return;let e=je.current===Le.nonce;try{e=e||sessionStorage.getItem(er)===Le.nonce||sessionStorage.getItem(Xn)===Le.nonce,sessionStorage.setItem(er,Le.nonce)}catch{}je.current=Le.nonce;let t=r.state&&typeof r.state==`object`?{...r.state}:{};if(delete t.chatLaunch,i(`${r.pathname}${r.search}`,{replace:!0,state:Object.keys(t).length>0?t:null}),e)return;let n=a.find(e=>e.id===Le.providerId);if(S(Le.providerId),w(e=>({...e,[Le.providerId]:Le.executionProfile})),Le.model&&E(e=>({...e,[Le.providerId]:Le.model})),!n?.isConfigured){_e(n?.message??`The selected local CLI is unavailable. Install it and sign in, then try again.`,`error`),Le.kickoff&&F({providerId:Le.providerId,kickoff:Le.kickoff,executionProfile:Le.executionProfile});return}if(Le.sessionId&&Le.assistant){ot({id:Le.sessionId,assistant:Le.assistant,title:``,createdAt:``,updatedAt:``,messageCount:0},!0);return}be.current&&!window.confirm(`Stop the current chat and continue with the selected local CLI?`)||(be.current&&tt(),Le.kickoff?ct({providerId:Le.providerId,kickoff:Le.kickoff,executionProfile:Le.executionProfile}):nt(Le.providerId,{firstMessage:null}))},[_e,ct,Le,ot,r.pathname,r.search,r.state,i,a,s,nt,tt]);let ut=()=>{window.confirm(`Are you sure you want to clear this chat history? This also starts a new agent session.`)&&(be.current&&tt(),ye(e=>{let t={...e};return delete t[x],t}),De.current=!1,d([]),ON(e.branchName))},dt=_&&!y,ft=qe?sP(qe):null,pt=()=>{if(!qe||!ft)return;let e=()=>_e(`Could not copy the recovery command. Copy the command shown above manually.`,`error`);QS(ft.command).then(t=>{if(!t){e();return}R(qe.id),setTimeout(()=>{Me.current&&R(e=>e===qe.id?null:e)},1500)})},[mt,ht]=(0,V.useState)(!1),gt=j[x]?.id,_t=e=>{QS(e).then(()=>{ht(!0),setTimeout(()=>{Me.current&&ht(!1)},1500)})};return(0,H.jsxs)(`div`,{className:`flex h-full flex-col bg-card`,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border bg-card px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,H.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Chat`}),(0,H.jsx)(Bv,{tone:h?`running`:`idle`,dot:!0,children:h?`${qe?.name||`Connected`}${qe&&T[qe.id]?` (${lP(qe,T[qe.id])})`:``}`:`Disconnected`})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[gt&&(0,H.jsxs)(`button`,{onClick:()=>_t(gt),className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-mono bg-muted/60 hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer border border-border/60`,title:`Session ID: ${gt} (Click to copy)`,children:[(0,H.jsx)(Vr,{size:11,className:`opacity-60`}),(0,H.jsxs)(`span`,{children:[gt.slice(0,8),`...`]}),mt?(0,H.jsx)(wr,{size:11,className:`text-emerald-500`}):(0,H.jsx)(Mr,{size:11,className:`opacity-60`})]}),u.length>0&&(0,H.jsx)(`button`,{onClick:ut,className:`cursor-pointer text-xs text-muted-foreground transition-colors hover:text-destructive-foreground`,children:`Clear`}),(0,H.jsx)(`button`,{onClick:()=>{ce(null),z(!0)},className:`grid h-7 w-7 cursor-pointer place-items-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:`Resume a past session`,children:(0,H.jsx)(ui,{size:14})}),(h||_||A)&&(0,H.jsxs)(yn,{size:`sm`,variant:`outline`,onClick:tt,children:[(0,H.jsx)(vi,{size:14,className:`text-destructive-foreground`}),`Stop`]})]})]}),(0,H.jsx)(VN,{open:oe,onClose:()=>z(!1),ws:e,onPick:st,error:se,pending:re}),(0,H.jsxs)(`div`,{ref:xe,onScroll:()=>{let e=xe.current;e&&(Ce.current=e.scrollHeight-e.scrollTop-e.clientHeight<80)},className:`flex-1 space-y-4 overflow-y-auto p-4`,children:[u.length===0&&!dt&&(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:`No messages yet. Start the agent and say hello.`}),u.map((e,t)=>(0,H.jsx)(fP,{msg:e,idx:t,copied:le===t,onCopy:it},t)),dt&&(0,H.jsx)(`div`,{className:`flex justify-start`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-lg border border-border bg-muted/30 px-4 py-2.5 text-xs text-muted-foreground shadow-xs animate-pulse`,children:[(0,H.jsx)(li,{size:13,className:`animate-spin text-primary`}),(0,H.jsxs)(`span`,{children:[qe?.name||`Agent`,` is thinking and executing...`]})]})}),(0,H.jsx)(`div`,{ref:Se})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-t border-border bg-card p-3`,children:[qe&&!qe.isConfigured&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-foreground`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(`span`,{className:`shrink-0 font-semibold`,children:[qe.name,` provider status:`]}),(0,H.jsx)(`span`,{children:qe.message})]}),ft&&(0,H.jsx)(`code`,{className:`w-fit rounded bg-background/70 px-2 py-1 font-mono text-[11px] text-foreground`,children:ft.command})]}),ft&&(0,H.jsxs)(yn,{size:`sm`,variant:`outline`,onClick:pt,className:`shrink-0`,children:[ae===qe.id?(0,H.jsx)(wr,{size:12}):(0,H.jsx)(Mr,{size:12}),ae===qe.id?`Copied`:ft.label]})]}),P&&!A&&!h&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-warning/25 bg-warning/10 px-3 py-2 text-xs text-foreground`,children:[(0,H.jsxs)(`span`,{children:[`The workspace kickoff was not dispatched (`,P.executionProfile===`workspace-write`?`Edit workspace`:`Review only`,`).`]}),(0,H.jsx)(yn,{size:`sm`,variant:`outline`,onClick:()=>void ct(P,!0),disabled:re||I,children:I?`Checking CLI…`:`Recheck & retry`}),qe?.setupIssue&&qe.setupIssue!==`missing-cli`&&(0,H.jsx)(yn,{size:`sm`,variant:`outline`,onClick:()=>void ct(P,!0,!0),disabled:re||I,children:`Try with existing CLI auth`})]}),Re.map(e=>(0,H.jsxs)(`div`,{role:`alert`,"aria-live":`polite`,className:`flex flex-col gap-2 rounded-xl border border-amber-500/40 bg-amber-500/10 p-3 text-xs shadow-xs animate-fade-in`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 font-semibold text-amber-500`,children:[(0,H.jsx)(mi,{size:14,className:`animate-pulse shrink-0`}),(0,H.jsx)(`span`,{children:`Tool Approval Required`}),(0,H.jsx)(lt,{variant:`outline`,className:`text-[10px] uppercase font-mono border-amber-500/40 text-amber-600 dark:text-amber-400`,children:e.tool}),e.description&&(0,H.jsxs)(`span`,{className:`text-[11px] font-normal text-muted-foreground italic`,children:[`(`,e.description,`)`]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,H.jsxs)(yn,{size:`sm`,variant:`default`,onClick:()=>We(e.requestId,`allow`),className:`h-7 text-xs bg-emerald-600 hover:bg-emerald-700 text-white gap-1 cursor-pointer`,children:[(0,H.jsx)(wr,{size:12}),(0,H.jsx)(`span`,{children:`Approve`})]}),(0,H.jsxs)(yn,{size:`sm`,variant:`outline`,onClick:()=>We(e.requestId,`deny`),className:`h-7 text-xs text-destructive hover:bg-destructive/10 border-border/80 gap-1 cursor-pointer`,children:[(0,H.jsx)(Ei,{size:12}),(0,H.jsx)(`span`,{children:`Deny`})]})]})]}),e.input&&(0,H.jsx)(`div`,{className:`rounded-md bg-background/80 p-2 font-mono text-[11px] text-foreground overflow-x-auto max-h-24 select-text`,children:typeof e.input.command==`string`?`Command: ${e.input.command}`:typeof e.input.path==`string`?`File: ${e.input.path}`:JSON.stringify(e.input,null,2)})]},e.requestId)),(0,H.jsxs)(`div`,{className:`flex w-full flex-col rounded-xl border border-border bg-card shadow-sm`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-1.5 border-b border-border/50 bg-muted/20 px-3 py-2 text-xs`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,H.jsxs)(qa,{children:[(0,H.jsxs)(Ja,{"aria-label":`Select Provider`,disabled:_||A||re,className:`flex cursor-pointer items-center gap-1.5 rounded-md border border-border/60 bg-background/90 px-2.5 py-1 text-xs font-medium text-foreground shadow-2xs transition-colors hover:bg-accent hover:border-border disabled:pointer-events-none disabled:opacity-50`,children:[qe?.icon===`Bot`?(0,H.jsx)(Sr,{size:13,className:`text-primary`}):(0,H.jsx)(Nr,{size:13,className:`text-primary`}),(0,H.jsx)(`span`,{children:qe?.name??`Select Agent`}),(0,H.jsx)(bn,{size:11,className:`opacity-50 ml-0.5`})]}),(0,H.jsx)(Ya,{align:`start`,side:`top`,children:a.filter(e=>e.isConfigured||e.setupIssue!==`missing-cli`).map(e=>(0,H.jsxs)(Xa,{onClick:()=>Xe(e.id),className:B(`flex items-center gap-2 text-xs cursor-pointer`,e.id===Ke&&`font-semibold text-primary`),children:[e.icon===`Bot`?(0,H.jsx)(Sr,{size:14}):(0,H.jsx)(Nr,{size:14}),(0,H.jsx)(`span`,{className:`flex-1`,children:e.name}),e.id===Ke&&(0,H.jsx)(wr,{size:12,className:`text-primary ml-auto`})]},e.id))})]}),qe?.models?.length&&(0,H.jsxs)(qa,{children:[(0,H.jsxs)(Ja,{"aria-label":`Select model`,disabled:h||A||_||re||!!P,className:`flex cursor-pointer items-center gap-1.5 rounded-md border border-border/60 bg-background/90 px-2.5 py-1 text-xs font-medium text-foreground shadow-2xs transition-colors hover:bg-accent hover:border-border disabled:pointer-events-none disabled:opacity-50`,children:[(0,H.jsx)(hi,{size:12,className:`text-amber-500 shrink-0`}),(0,H.jsx)(`span`,{className:`max-w-44 truncate`,children:lP(qe,T[qe.id]??``)}),(0,H.jsx)(bn,{size:11,className:`opacity-50 ml-0.5`})]}),(0,H.jsx)(Ya,{align:`start`,side:`top`,className:`max-w-80`,children:qe.models.map(e=>(0,H.jsx)(Xa,{onClick:()=>E(t=>({...t,[qe.id]:e.id})),children:(0,H.jsxs)(`span`,{className:`flex flex-col`,children:[(0,H.jsxs)(`span`,{className:`font-medium flex items-center gap-1.5`,children:[(0,H.jsx)(hi,{size:11,className:`text-amber-500`}),e.label]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.description})]})},e.id))})]}),qe?.executionProfiles?.length&&Je&&(0,H.jsxs)(qa,{children:[(0,H.jsxs)(Ja,{"aria-label":`Select execution profile`,disabled:A||_||re||!!P,className:`flex cursor-pointer items-center gap-1.5 rounded-md border border-border/60 bg-background/90 px-2.5 py-1 text-xs font-medium text-foreground shadow-2xs transition-colors hover:bg-accent hover:border-border disabled:pointer-events-none disabled:opacity-50`,title:Je.description,children:[(0,H.jsx)(mi,{size:12,className:Je.id===`workspace-write`?`text-amber-500 shrink-0`:`text-emerald-500 shrink-0`}),(0,H.jsx)(`span`,{children:cP(Je.label)}),(0,H.jsx)(bn,{size:11,className:`opacity-50 ml-0.5`})]}),(0,H.jsx)(Ya,{align:`start`,side:`top`,className:`max-w-80`,children:qe.executionProfiles.map(e=>(0,H.jsx)(Xa,{onClick:()=>w(t=>({...t,[qe.id]:e.id})),children:(0,H.jsxs)(`span`,{className:`flex flex-col`,children:[(0,H.jsxs)(`span`,{className:`font-medium flex items-center gap-1.5`,children:[(0,H.jsx)(mi,{size:12,className:e.id===`workspace-write`?`text-amber-500`:`text-emerald-500`}),e.label]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.description})]})},e.id))})]}),qe&&(0,H.jsxs)(qa,{children:[(0,H.jsxs)(Ja,{"aria-label":`Select reasoning effort`,disabled:h||A||_||re||!!P,className:`flex cursor-pointer items-center gap-1.5 rounded-md border border-border/60 bg-background/90 px-2.5 py-1 text-xs font-medium text-foreground shadow-2xs transition-colors hover:bg-accent hover:border-border disabled:pointer-events-none disabled:opacity-50`,children:[(0,H.jsx)(Di,{size:12,className:D[qe.id]?`text-amber-500 fill-amber-500/20 shrink-0`:`text-muted-foreground shrink-0`}),(0,H.jsx)(`span`,{children:YN(D[qe.id]??``)}),(0,H.jsx)(bn,{size:11,className:`opacity-50 ml-0.5`})]}),(0,H.jsx)(Ya,{align:`start`,side:`top`,className:`max-w-72`,children:JN.map(e=>(0,H.jsx)(Xa,{onClick:()=>ee(t=>({...t,[qe.id]:e.id})),children:(0,H.jsxs)(`span`,{className:`flex flex-col`,children:[(0,H.jsxs)(`span`,{className:`font-medium flex items-center gap-1.5`,children:[e.id&&(0,H.jsx)(Di,{size:12,className:`text-amber-500`}),e.label]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.description})]})},e.id))})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,H.jsx)(`input`,{type:`file`,ref:he,accept:`image/png,image/jpeg,image/gif,image/webp`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files?.length&&ve(e.target.files),e.target.value=``}}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>he.current?.click(),disabled:_||re,className:`flex cursor-pointer items-center justify-center rounded-md border border-border/60 bg-background/90 p-1.5 text-muted-foreground shadow-2xs transition-colors hover:bg-accent hover:text-foreground hover:border-border disabled:pointer-events-none disabled:opacity-50`,title:`Attach image (or paste / drop into chat)`,children:(0,H.jsx)(Hr,{size:14,className:`text-primary`})})]})]}),de.length>0&&(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2 border-b border-border/40 px-3 py-2 bg-muted/20`,children:de.map(e=>(0,H.jsxs)(`div`,{className:`group relative flex items-center rounded-lg border border-border/80 bg-card p-1 shadow-xs`,children:[(0,H.jsx)(`img`,{src:e.dataUrl,alt:e.name,className:`h-14 w-14 rounded-md object-cover`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>fe(t=>t.filter(t=>t.id!==e.id)),className:`absolute -top-1.5 -right-1.5 flex h-4 w-4 cursor-pointer items-center justify-center rounded-full bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90 transition-colors`,title:`Remove image`,children:(0,H.jsx)(Ei,{size:10})})]},e.id))}),(0,H.jsxs)(`div`,{className:B(`flex items-end gap-2 p-2`,pe&&`ring-2 ring-primary ring-inset rounded-b-xl bg-accent/30`),onDragOver:e=>{e.preventDefault(),me(!0)},onDragLeave:()=>me(!1),onDrop:e=>{e.preventDefault(),me(!1),e.dataTransfer?.files?.length&&ve(e.dataTransfer.files)},children:[(0,H.jsx)(_N,{value:f,disabled:re,onPaste:e=>{if(e.clipboardData?.getData(`text/plain`))return;let t=$S(e.clipboardData?.getData(`text/html`)??``);if(t.trim()){e.preventDefault();let n=e.currentTarget,r=n.selectionStart,i=n.selectionEnd;p(e=>`${e.slice(0,r)}${t}${e.slice(i)}`),requestAnimationFrame(()=>{n.focus();let e=r+t.length;n.setSelectionRange(e,e)});return}let n=e.clipboardData?.items,r=[];if(n){for(let e=0;e<n.length;e++)if(n[e].type.startsWith(`image/`)){let t=n[e].getAsFile();t&&r.push(t)}}if(r.length===0&&e.clipboardData?.files?.length)for(let t of Array.from(e.clipboardData.files))t.type.startsWith(`image/`)&&r.push(t);r.length>0&&(e.preventDefault(),ve(r))},onChange:e=>{p(e.target.value);let t=e.target;t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`},onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),_||A||Fe.current)return;h?rt():Ye&&(f.trim()||de.length?rt():nt());let t=e.currentTarget;t.style.height=`auto`}},placeholder:h?`Message the agent... (Shift+Enter for new line)`:`Start the agent or press Enter...`,unstyled:!0,className:`flex-1 [&_[data-slot=textarea]]:max-h-[200px] [&_[data-slot=textarea]]:min-h-11 [&_[data-slot=textarea]]:resize-none [&_[data-slot=textarea]]:text-sm`,rows:1}),h?(0,H.jsxs)(yn,{className:`h-11 shrink-0 rounded-lg`,onClick:rt,disabled:!f.trim()&&de.length===0||_||re,children:[_?(0,H.jsx)(li,{size:14,className:`animate-spin`}):(0,H.jsx)(fi,{size:14}),`Send`]}):(0,H.jsxs)(yn,{className:`h-11 shrink-0 rounded-lg`,onClick:()=>{f.trim()||de.length?rt():nt()},disabled:!Ye,children:[(0,H.jsx)(gi,{size:14}),`Start`]})]})]})]})]})}function mP({visible:e,...t}){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{e&&r(!0)},[e]),(0,H.jsx)(`div`,{className:B(`h-full min-h-0`,!e&&`hidden`),children:(n||e)&&(0,H.jsx)(pP,{...t})})}function hP({workspaces:e}){let{isOpen:t,isMinimized:n,isMaximized:r,openTabs:i,activeTab:a,position:o,size:s,close:c,minimize:l,restore:u,toggleMaximize:d,addTab:f,removeTab:p,setActiveTab:m,setPosition:h,setSize:g,drafts:_,consumeDraft:v,modes:y,setMode:b,terminalLaunches:x,consumeTerminalLaunch:S,harnesses:C}=Mt(),[w,T]=(0,V.useState)(``),E=(0,V.useRef)(null),D=(0,V.useRef)(null),ee=(0,V.useRef)(null),O=(0,V.useMemo)(()=>new Map(e.map(e=>[e.branchName,e])),[e]),k=a?O.get(a):void 0,A=(0,V.useMemo)(()=>{let t=w.trim().toLowerCase();return t?e.filter(e=>e.branchName.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)):e},[e,w]),te=(0,V.useCallback)(e=>{if(e.button!==0||r)return;let t=e.target;if(t.closest(`button`)||t.closest(`[role="tab"]`)||t.closest(`[data-no-drag]`))return;let n=o||{x:Math.max(20,window.innerWidth-s.width-24),y:Math.max(20,window.innerHeight-s.height-24)};E.current={startX:e.clientX,startY:e.clientY,startPosX:n.x,startPosY:n.y},e.currentTarget.setPointerCapture(e.pointerId)},[r,o,s]),j=(0,V.useCallback)(e=>{if(!E.current)return;let t=e.clientX-E.current.startX,n=e.clientY-E.current.startY,r=Math.max(0,window.innerWidth-s.width-20),i=Math.max(0,window.innerHeight-s.height-20),a=Math.min(Math.max(10,E.current.startPosX+t),r),o=Math.min(Math.max(10,E.current.startPosY+n),i);h({x:a,y:o})},[s,h]),M=(0,V.useCallback)(e=>{if(E.current){E.current=null;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}},[]),N=(0,V.useCallback)(e=>{e.button!==0||r||(e.stopPropagation(),e.preventDefault(),D.current={startX:e.clientX,startY:e.clientY,startW:s.width,startH:s.height},e.currentTarget.setPointerCapture(e.pointerId))},[r,s]),ne=(0,V.useCallback)(e=>{if(!D.current)return;let t=e.clientX-D.current.startX,n=e.clientY-D.current.startY,r=Math.max(380,Math.min(D.current.startW+t,window.innerWidth-40)),i=Math.max(420,Math.min(D.current.startH+n,window.innerHeight-40));g({width:r,height:i})},[g]),re=(0,V.useCallback)(e=>{if(D.current){D.current=null;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}},[]),ie=(0,V.useMemo)(()=>{if(!r)return o?{left:`${o.x}px`,top:`${o.y}px`,width:`${s.width}px`,height:`${s.height}px`}:{right:`24px`,bottom:`24px`,width:`${s.width}px`,height:`${s.height}px`}},[r,o,s]);return(0,H.jsxs)(H.Fragment,{children:[t&&n&&(0,H.jsx)(`div`,{className:`fixed bottom-5 right-6 z-50 animate-fade-in`,children:(0,H.jsxs)(`button`,{onClick:u,className:`flex items-center gap-2.5 px-4 py-2.5 rounded-full bg-card/95 backdrop-blur-md border border-border shadow-xl hover:border-primary/50 text-foreground transition-all duration-200 cursor-pointer group`,title:`Restore floating workspace chat`,children:[(0,H.jsx)(`div`,{className:`size-7 rounded-full bg-primary/10 grid place-items-center text-primary group-hover:scale-105 transition-transform`,children:(0,H.jsx)(Zr,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`flex flex-col items-start text-left`,children:[(0,H.jsxs)(`span`,{className:`text-xs font-semibold leading-tight flex items-center gap-1.5`,children:[`Workspace Chat`,i.length>0&&(0,H.jsx)(`span`,{className:`px-1.5 py-0.2 rounded-full bg-primary/20 text-primary text-[10px] font-bold`,children:i.length})]}),(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground leading-tight max-w-[140px] truncate`,children:k?.branchName||`No active tab`})]}),(0,H.jsx)(Jr,{className:`size-3.5 text-muted-foreground group-hover:text-foreground ml-1`})]})}),(0,H.jsxs)(`div`,{ref:ee,style:{...ie,display:!t||n?`none`:void 0},role:`region`,"aria-label":`Workspace Chat`,className:B(`fixed z-50 flex flex-col overflow-hidden bg-card/98 backdrop-blur-xl border border-border/80 shadow-2xl rounded-2xl transition-[border-color] duration-150`,r&&`inset-0 w-auto h-auto rounded-none`),children:[(0,H.jsxs)(`div`,{onPointerDown:te,onPointerMove:j,onPointerUp:M,className:B(`flex items-center justify-between px-3 py-2 border-b border-border/80 bg-muted/40 select-none shrink-0`,!r&&`cursor-grab active:cursor-grabbing`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 pr-2`,children:[!r&&(0,H.jsx)(Br,{className:`size-4 text-muted-foreground/50 shrink-0`}),(0,H.jsx)(`div`,{className:`size-5 rounded-md bg-primary/15 grid place-items-center text-primary shrink-0`,children:(0,H.jsx)(Zr,{className:`size-3.5`})}),(0,H.jsx)(`span`,{className:`text-xs font-bold text-foreground shrink-0`,children:`ContextSpace`}),(0,H.jsx)(`span`,{className:`text-muted-foreground/70`,"aria-hidden":`true`,children:`/`}),(0,H.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-xs font-semibold text-primary shrink-0`,children:a&&y[a]===`chat`?`Agent chat`:`CLI chat`}),k&&(0,H.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:k.branchName,children:k.branchName})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,"data-no-drag":!0,children:[(0,H.jsx)(`button`,{onClick:l,className:`p-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-colors cursor-pointer`,title:`Minimize`,"aria-label":`Minimize floating chat`,children:(0,H.jsx)($r,{className:`size-3.5`})}),(0,H.jsx)(`button`,{onClick:d,className:`p-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-colors cursor-pointer`,title:r?`Restore down`:`Maximize`,"aria-label":r?`Restore down floating chat`:`Maximize floating chat`,children:r?(0,H.jsx)(Qr,{className:`size-3.5`}):(0,H.jsx)(Jr,{className:`size-3.5`})}),(0,H.jsx)(`button`,{onClick:c,className:`p-1.5 rounded-lg text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors cursor-pointer`,title:`Close`,"aria-label":`Close floating chat`,children:(0,H.jsx)(Ei,{className:`size-3.5`})})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 px-2.5 py-1.5 border-b border-border/60 bg-muted/20 overflow-x-auto no-scrollbar shrink-0`,"data-no-drag":!0,children:[i.map(e=>{let t=e===a;return(0,H.jsxs)(`div`,{role:`tab`,"aria-selected":t,onClick:()=>m(e),className:B(`group flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-medium transition-all duration-150 cursor-pointer border shrink-0 max-w-[170px]`,t?`bg-card border-border shadow-xs text-foreground font-semibold`:`border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:e,children:[(0,H.jsx)(Ut,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`truncate`,children:e}),y[e]!==`chat`&&C[e]&&(0,H.jsx)(`span`,{title:eN(C[e]),children:(0,H.jsx)(tN,{harness:C[e],className:`size-3`})}),(0,H.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),p(e)},className:`size-3.5 rounded grid place-items-center text-muted-foreground/60 hover:text-destructive hover:bg-destructive/10 opacity-0 group-hover:opacity-100 transition-opacity ml-0.5`,title:`Close ${e} tab`,"aria-label":`Close ${e} tab`,children:(0,H.jsx)(Ei,{className:`size-2.5`})})]},e)}),(0,H.jsxs)(qa,{children:[(0,H.jsxs)(Ja,{className:`flex items-center gap-1 px-2 py-1 rounded-lg text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 border border-dashed border-border/70 hover:border-border transition-colors cursor-pointer shrink-0`,children:[(0,H.jsx)(ci,{className:`size-3`}),(0,H.jsx)(`span`,{children:`Add Workspace`})]}),(0,H.jsxs)(Ya,{align:`start`,className:`w-64 p-1.5`,children:[(0,H.jsx)(`div`,{className:`px-2 py-1 mb-1`,children:(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(Ct,{className:`size-3.5 absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground`}),(0,H.jsx)(`input`,{type:`text`,placeholder:`Search workspaces...`,value:w,onChange:e=>T(e.target.value),className:`w-full pl-7 pr-2 py-1 text-xs rounded-md bg-muted/50 border border-border focus:outline-hidden focus:border-primary/50 text-foreground placeholder:text-muted-foreground`,autoFocus:!0})]})}),(0,H.jsx)(`div`,{className:`max-h-56 overflow-y-auto space-y-0.5`,children:A.length===0?(0,H.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No workspaces found`}):A.map(e=>{let t=i.includes(e.branchName);return(0,H.jsxs)(Xa,{onClick:()=>{t?m(e.branchName):f(e.branchName),T(``)},className:B(`flex items-center gap-2 px-2 py-1.5 text-xs rounded-md cursor-pointer`,e.branchName===a&&`bg-accent/70 font-semibold`),children:[(0,H.jsx)(Ut,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.branchName}),e.description&&(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate`,children:e.description})]}),t&&(0,H.jsx)(`span`,{className:`text-[10px] text-primary font-medium px-1.5 py-0.5 rounded bg-primary/10`,children:`Open`})]},e.branchName)})})]})]})]}),a&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-1`,"data-no-drag":!0,children:[(0,H.jsxs)(yn,{size:`xs`,variant:(y[a]??`cli`)===`cli`?`secondary`:`ghost`,"aria-pressed":(y[a]??`cli`)===`cli`,onClick:()=>b(a,`cli`),children:[(0,H.jsx)(_i,{className:`size-3`}),`CLI`]}),(0,H.jsxs)(yn,{size:`xs`,variant:y[a]===`chat`?`secondary`:`ghost`,"aria-pressed":y[a]===`chat`,onClick:()=>b(a,`chat`),children:[(0,H.jsx)(Xr,{className:`size-3`}),`Chat`]}),(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:(y[a]??`cli`)===`cli`?`Direct harness sessions`:`Existing API and structured chat`})]}),(0,H.jsx)(`div`,{className:`flex-1 min-h-0 relative overflow-hidden bg-card`,"data-no-drag":!0,children:i.length===0?(0,H.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center p-6 text-center text-muted-foreground gap-3`,children:[(0,H.jsx)(`div`,{className:`size-12 rounded-2xl bg-muted/50 border border-border grid place-items-center text-muted-foreground`,children:(0,H.jsx)(Xr,{className:`size-6 text-primary`})}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`No Workspace Tab Open`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs`,children:`Select a workspace to run a CLI harness or open your existing chat.`})]}),(0,H.jsx)(`div`,{className:`flex flex-wrap justify-center gap-1.5 mt-2 max-w-sm`,children:e.slice(0,5).map(e=>(0,H.jsxs)(yn,{variant:`outline`,size:`sm`,onClick:()=>f(e.branchName),className:`text-xs h-7 gap-1.5`,children:[(0,H.jsx)(Ut,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:e.branchName})]},e.branchName))})]}):i.map(e=>{let r=O.get(e);if(!r)return null;let i=e===a;return(0,H.jsxs)(`div`,{className:B(`h-full flex flex-col`,!i&&`hidden`),children:[(0,H.jsx)(`div`,{className:B(`h-full min-h-0`,y[e]===`chat`&&`hidden`),children:(0,H.jsx)(gN,{workspace:e,active:t&&!n&&i&&y[e]!==`chat`,launch:x[e],consumeLaunch:t=>S(e,t)})}),(0,H.jsx)(mP,{visible:y[e]===`chat`,ws:r,draft:_[e],onDraftConsumed:t=>v(e,t)})]},e)})}),!r&&(0,H.jsx)(`div`,{onPointerDown:N,onPointerMove:ne,onPointerUp:re,className:`absolute bottom-0 right-0 size-4 cursor-nwse-resize z-10 grid place-items-center opacity-30 hover:opacity-100 transition-opacity`,title:`Drag to resize`,children:(0,H.jsx)(`div`,{className:`size-2 border-r-2 border-b-2 border-muted-foreground rounded-br-xs`})})]})]})}function gP(){let{isOpen:e,isMinimized:t,openTabs:n,open:r}=Mt();return e&&!t||t?null:(0,H.jsx)(`div`,{className:`fixed bottom-6 right-6 z-40 animate-fade-in`,children:(0,H.jsxs)(`button`,{onClick:()=>r(),className:B(`group relative flex items-center justify-center gap-2 h-11 px-4 rounded-full`,`bg-primary text-primary-foreground shadow-lg shadow-primary/25`,`hover:scale-105 hover:shadow-xl hover:shadow-primary/35 active:scale-95`,`transition-all duration-200 cursor-pointer border border-primary/20`),title:`Open Floating Workspace Chat`,"aria-label":`Open Floating Workspace Chat`,children:[(0,H.jsx)(Zr,{className:`size-4`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`text-xs font-medium`,children:`Chat & CLI`}),n.length>0&&(0,H.jsx)(`span`,{className:`absolute -top-1 -right-1 size-5 rounded-full bg-emerald-500 text-white text-[10px] font-bold grid place-items-center shadow-md border-2 border-background`,children:n.length})]})})}function _P({workspaceName:e,open:t,onClose:n,onConfirm:r,loading:i=!1}){let[a,o]=(0,V.useState)(``);if(!e)return null;let s=a.trim()===e.trim(),c=()=>{o(``),n()},l=async()=>{!s||i||(await r(e),o(``))};return(0,H.jsx)(Ov,{open:t,onOpenChange:e=>!e&&c(),children:(0,H.jsxs)(Mv,{className:`max-w-md`,children:[(0,H.jsxs)(Nv,{children:[(0,H.jsx)(Fv,{className:`text-destructive`,children:`Delete workspace`}),(0,H.jsxs)(Iv,{children:[`This action cannot be undone. This will force-remove all git worktrees and delete the entire folder for`,` `,(0,H.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),`.`]})]}),(0,H.jsx)(Lv,{className:`space-y-4`,children:(0,H.jsxs)(`label`,{className:`block`,children:[(0,H.jsxs)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:[`Please type `,(0,H.jsx)(`strong`,{className:`font-mono text-foreground`,children:e}),` to confirm:`]}),(0,H.jsx)(Ye,{value:a,onChange:e=>o(e.target.value),placeholder:e,autoFocus:!0,className:`font-mono text-sm`,onKeyDown:e=>{e.key===`Enter`&&s&&!i&&l()}})]})}),(0,H.jsxs)(Pv,{children:[(0,H.jsx)(yn,{variant:`outline`,onClick:c,disabled:i,children:`Cancel`}),(0,H.jsx)(yn,{variant:`destructive`,onClick:()=>void l(),disabled:!s||i,children:i?`Deleting…`:`Delete workspace`})]})]})})}var vP=(0,V.lazy)(()=>Kn(()=>import(`./DashboardPage-D2LQg1es.js`).then(e=>({default:e.DashboardPage})),__vite__mapDeps([5,1,2,6,7,3,4,8,9,10,11]))),yP=(0,V.lazy)(()=>Kn(()=>import(`./ProjectsPage-DdFVpbr7.js`).then(e=>({default:e.ProjectsPage})),__vite__mapDeps([12,1,2,13,7,6,3,4,8,9,14,15,16,17,18]))),bP=(0,V.lazy)(()=>Kn(()=>import(`./SettingsPage-BtRA38LZ.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([19,1,2,13,7,15,16,11,20,21]))),xP=(0,V.lazy)(()=>Kn(()=>import(`./SkillsPage-Dc8TrRyw.js`).then(e=>({default:e.SkillsPage})),__vite__mapDeps([22,1,2,13,7,6,3,4,8,9,23,24,25,17,11,20]))),SP=(0,V.lazy)(()=>Kn(()=>import(`./AgentsPage-vWomDhqY.js`).then(e=>({default:e.AgentsPage})),__vite__mapDeps([26,1,2,13,7,6,3,4,8,9,17,18,11,20]))),CP=(0,V.lazy)(()=>Kn(()=>import(`./WorkroomsPage-DZVZcvUV.js`).then(e=>({default:e.WorkroomsPage})),__vite__mapDeps([27,1,2,13,7,25,17,28,29,15,8,9,11,20,21]))),wP=(0,V.lazy)(()=>Kn(()=>import(`./StartWorkPage-BJ7EYD7t.js`).then(e=>({default:e.StartWorkPage})),__vite__mapDeps([30,1,2,13,7,6,3,4,8,9,23,10,14,15,16,31]))),TP=(0,V.lazy)(()=>Kn(()=>import(`./StrategiesPage-GkFROjyC.js`).then(e=>({default:e.StrategiesPage})),__vite__mapDeps([32,1,2,13,7,33,17,11,20]))),EP=(0,V.lazy)(()=>Kn(()=>import(`./WorkspacesPage-DefIfu1l.js`).then(e=>({default:e.WorkspacesPage})),__vite__mapDeps([34,1,2,13,7,6,3,4,8,9,23,29,15,24,10,25,31,17,28,11,20]))),DP=(0,V.lazy)(()=>Kn(()=>import(`./GettingStartedPage-BYPdHlcN.js`).then(e=>({default:e.GettingStartedPage})),__vite__mapDeps([35,2,1,7,33,8]))),OP=new URLSearchParams(window.location.search).get(`env`)===`vscode`,kP=typeof window<`u`?window.contextspaceBridge?.updates||window.nexusBridge?.updates:void 0,AP=0;function jP(){let e=Lt(),t=Ft(),[n,r]=(0,V.useState)([]),i=(e,t=`info`,n=5e3)=>{let i=`toast-${++AP}`;r(r=>[...r,{id:i,message:e,type:t,duration:n}]),setTimeout(()=>{r(e=>e.filter(e=>e.id!==i))},n)},[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!0),[l,u]=(0,V.useState)(!0),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)([]),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(``),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(!1),[C,w]=(0,V.useState)(null),T=Tt(),E=Qt(),D=Kt(),ee=At(),O=T.data??[],k=E.data??[],A=D.data??[],te=ee.data??[],[j,M]=(0,V.useState)(!1),[N,ne]=(0,V.useState)(`idle`),[re,ie]=(0,V.useState)(null),[P,F]=(0,V.useState)(null),[I,L]=(0,V.useState)(!1),[ae,R]=(0,V.useState)(``),[oe,z]=(0,V.useState)(``),[se,ce]=(0,V.useState)(null),[le,ue]=(0,V.useState)(!1),[de,fe]=(0,V.useState)(!1),[pe,me]=(0,V.useState)(!1),[he,ge]=(0,V.useState)(`antigravity`),_e=(0,V.useRef)(!1);(0,V.useEffect)(()=>{if(_e.current||!E.data)return;let e=E.data.find(e=>e.detected&&e.command);e&&(_e.current=!0,ge(e.name))},[E.data]);let[ve,ye]=(0,V.useState)(null),[be,xe]=(0,V.useState)(``),Se=[`/`,`/overview`,`/dashboard`].includes(t.pathname)||t.pathname.startsWith(`/workspaces`),Ce=cn(),we=wt(),Te=Nt({enabled:l&&!s,intervalMs:Se?15e3:!1}),Ee=we.data??[],De=we.isLoading,Oe=Te.data??{},[ke,Ae]=(0,V.useState)(null),[je,Me]=(0,V.useState)(`overview`),[Ne,Pe]=(0,V.useState)([]),[Fe,Ie]=(0,V.useState)(!1),[Le,Re]=(0,V.useState)(null),[ze,Be]=(0,V.useState)([]),[Ve,He]=(0,V.useState)(!1),[Ue,We]=(0,V.useState)([]),[Ge,Ke]=(0,V.useState)(!1),[qe,Je]=(0,V.useState)(``),[Ye,Xe]=(0,V.useState)(!1),[Ze,Qe]=(0,V.useState)(null),[$e,et]=(0,V.useState)(!1),[tt,nt]=(0,V.useState)(``),[rt,it]=(0,V.useState)(!1),[at,ot]=(0,V.useState)(null),[st,ct]=(0,V.useState)(``),[lt,ut]=(0,V.useState)(!1),[dt,ft]=(0,V.useState)(null),pt=(0,V.useRef)(null),mt=(0,V.useRef)(0),ht=(0,V.useRef)(0),gt=(0,V.useRef)(0),_t=(0,V.useRef)(``),vt=(0,V.useRef)(!1),[yt,bt]=(0,V.useState)(!1),[xt,St]=(0,V.useState)(null),[Ct,Et]=(0,V.useState)(``),[Dt,kt]=(0,V.useState)(!1),[jt,Mt]=(0,V.useState)(!1),[Pt,Rt]=(0,V.useState)(null),[zt,Bt]=(0,V.useState)(null),[Vt,Ht]=(0,V.useState)(!1),Ut=e=>{_t.current=e,nt(e)},Wt=e=>{vt.current=e,et(e)},[Gt,qt]=(0,V.useState)([]),[Jt,Yt]=(0,V.useState)(!1),[Xt,Zt]=(0,V.useState)(null),$t=!(!a||!a.devDir||a.devDir.trim()===``||!a.workspacesDir||a.workspacesDir.trim()===``),en=e=>{let t=[`available`,`downloading`,`downloaded`,`error`].includes(e.status)&&!!e.version;g({currentVersion:e.currentVersion,latestVersion:e.version||e.currentVersion,updateAvailable:t,releaseNotes:e.releaseNotes,nativeStatus:e.status,progress:e.progress,error:e.error,releaseUrl:$n}),v(e.currentVersion),e.status===`error`?w(e.error||`${rr} could not check or download the update.`):e.status!==`checking`&&w(null),M(e.status===`checking`||e.status===`downloading`),ne(e.status===`checking`?`checking`:e.status===`downloading`?`downloading`:e.status===`downloaded`?`downloaded`:e.status===`error`?`error`:`idle`),e.status===`available`&&S(!1)},tn=async(e=!0)=>{try{if(kP){let t=await kP.getStatus();en(t),e&&t.status!==`unsupported`&&en(await kP.check());return}let t=await fetch(`/api/update-status`);if(t.ok){let e=await t.json();g(e),w(null),e.currentVersion&&v(e.currentVersion)}else throw Error(`Update check failed with HTTP ${t.status}.`)}catch(e){w(e instanceof Error?e.message:`${rr} could not check for updates.`),console.error(`Failed to fetch update status:`,e)}},rn=async()=>{w(null),h?.nativeStatus===`downloaded`&&S(!1),await tn(!0)},an=async()=>{if(!kP){i(`Native installation is available in the ${rr} desktop app. Open the release page to install it.`,`info`);return}M(!0),ne(`downloading`);try{let e=await kP.download();en(e),e.status===`downloaded`?i(`Update downloaded. Restart ${rr} when you are ready to install it.`,`success`):i(`Update failed: ${e.error||`The download did not complete.`}`,`error`)}catch(e){console.error(`Update failed:`,e),ne(`error`),M(!1),i(`Update failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}},on=async()=>{if(kP)try{en(await kP.restart())}catch(e){let t=e instanceof Error?e.message:`Unknown error`;g(e=>e&&{...e,nativeStatus:`error`,error:t,updateAvailable:!!e.latestVersion}),w(t),ne(`error`),i(`Could not restart for update: ${t}`,`error`),M(!1)}},sn=async()=>{try{let e=await(await fetch(`/api/adapters`)).json();e.adapters&&m(e.adapters)}catch(e){console.error(`Failed to fetch adapters:`,e)}},ln=async()=>{sn();try{let e=await(await fetch(`/api/config`)).json();o(e.config),u(e.exists),e.exists&&e.config.devDir||(b({devDir:e.config.devDir||``,workspacesDir:e.config.workspacesDir||``}),o({version:`1.0.0`,devDir:``,workspacesDir:``,defaultAssistant:null,scanDepth:2}))}catch(e){console.error(e)}finally{c(!1)}},un=async e=>{try{(await fetch(`/api/config`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).ok?(f(`success`),o(e),u(!0),Ce.invalidateQueries({queryKey:[`repos`]}),dn()):f(`error`)}catch{f(`error`)}setTimeout(()=>f(null),3e3)},dn=async()=>{await Promise.all([Ce.invalidateQueries({queryKey:[`workspaces`]}),Ce.invalidateQueries({queryKey:[`workspaces-status`]})])},fn=async()=>{if(!ae.trim()||!oe.trim()){i(`Name and content are required.`,`error`);return}fe(!0);try{let e=await fetch(`/api/workflows/templates`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:P,name:ae,content:oe})});if(e.ok){let t=await e.json();i(`Strategy template saved successfully!`,`success`),await Ce.invalidateQueries({queryKey:[`workflow-templates`]}),F(t.template.id),L(!1),ce(null)}else{let t=await e.json();i(t.error||`Failed to save template`,`error`)}}catch(e){i(e.message||`Error saving template`,`error`)}finally{fe(!1)}},pn=async e=>{if(window.confirm(`Are you sure you want to delete this custom strategy template?`)){me(!0);try{let t=await fetch(`/api/workflows/templates/${encodeURIComponent(e)}`,{method:`DELETE`});if(t.ok)i(`Strategy template deleted successfully!`,`success`),await Ce.invalidateQueries({queryKey:[`workflow-templates`]}),F(null),ce(null);else{let e=await t.json();i(e.error||`Failed to delete template`,`error`)}}catch(e){i(e.message||`Error deleting template`,`error`)}finally{me(!1)}}},mn=async(e,t,n)=>{ue(!0),ce(null),ye(null);try{let r=await fetch(`/api/workflows/templates/${encodeURIComponent(e)}/analyze`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:t,assistant:n,comment:be})});if(r.ok){let e=await r.json();ce(e.analysis),ye(e.suggestedImprovement||null),i(`Strategy analysis completed successfully!`,`success`)}else{let e=await r.json();i(e.error||`Failed to analyze template using the selected assistant harness.`,`error`)}}catch(e){i(e.message||`Error analyzing template`,`error`)}finally{ue(!1)}},hn=async e=>{Ke(!0);try{let t=await(await fetch(`/api/workspace/${encodeURIComponent(e)}/changes`)).json();We(t.changes||[])}catch(e){console.error(e)}finally{Ke(!1)}},gn=async e=>{Ie(!0);try{let t=await(await fetch(`/api/workspace/${encodeURIComponent(e)}/sessions`)).json();Pe(t.sessions||[])}catch(e){console.error(e)}finally{Ie(!1)}},_n=async(e,t)=>{He(!0);try{let n=await(await fetch(`/api/session/${e}/${t}/transcript`)).json();Be(n.messages||[])}catch(e){console.error(e)}finally{He(!1)}},vn=async e=>{let t=++mt.current,n=()=>pt.current===e&&mt.current===t;Xe(!0),Qe(null);try{let t=await fetch(`/api/workspace/${encodeURIComponent(e)}/knowledge`);if(!t.ok)throw Error(`knowledge request failed`);let r=await t.json();if(!r||typeof r!=`object`||typeof r.content!=`string`)throw Error(`knowledge response was malformed`);if(!n())return;let i=r.content;Je(i),vt.current||(_t.current=i,nt(i)),Qe(null)}catch(e){if(!n())return;console.error(`Failed to load workspace knowledge:`,e),Qe(`Could not load Knowledge. Existing content and your draft were kept. Retry when ready.`)}finally{n()&&Xe(!1)}},yn=async e=>{let t=++gt.current,n=_t.current,r=()=>pt.current===e&&gt.current===t;it(!0),ot(null);try{let t=await fetch(`/api/workspace/${encodeURIComponent(e)}/knowledge`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})});if(!t.ok)throw Error(`knowledge save request failed`);let i=await t.json();if(!i||typeof i!=`object`||i.success!==!0)throw Error(`knowledge save response was not confirmed`);if(!r())return;mt.current+=1,Xe(!1),Je(n),Qe(null),ot(null),vt.current&&_t.current===n&&Wt(!1)}catch(e){if(!r())return;console.error(`Failed to save workspace knowledge:`,e),ot(`Could not save Knowledge. Your draft is still open. Retry the save.`)}finally{r()&&it(!1)}},bn=async e=>{let t=++ht.current,n=()=>pt.current===e&&ht.current===t;ut(!0),ft(null);try{let t=await fetch(`/api/workspace/${encodeURIComponent(e)}/plan`);if(!t.ok)throw Error(`plan request failed`);let r=await t.json();if(!r||typeof r!=`object`||typeof r.content!=`string`)throw Error(`plan response was malformed`);if(!n())return;ct(r.content),ft(null)}catch(e){if(!n())return;console.error(`Failed to load workspace plan:`,e),ft(`Could not load Plan. Existing content was kept. Retry when ready.`)}finally{n()&&ut(!1)}},xn=async e=>{bt(!0),St(null);try{let t=await(await fetch(`/api/workspace/${encodeURIComponent(e)}/sync`,{method:`POST`})).json();St(t.results||[]),hn(e)}catch(e){console.error(e)}finally{bt(!1)}},Sn=async e=>{if(Ct.trim()){Mt(!0),Rt(null);try{let t=await(await fetch(`/api/workspace/${encodeURIComponent(e)}/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:Ct})})).json();Rt(t.results||[]),Et(``),kt(!1),hn(e)}catch(e){console.error(e)}finally{Mt(!1)}}},Cn=async(e,t,n)=>{if(n!==`codex`){let e=n===`claude`?`claude --resume ${t}`:`agy --conversation ${t}`;return await QS(e),i(`Copied ${n} resume command to clipboard:\n\n${e}`,`info`),!0}try{return await sr(`/api/workspace/${encodeURIComponent(e.branchName)}/launch`,{method:`POST`,body:JSON.stringify({targetId:`codex-desktop`,action:`resume`,sessionId:t})}),i(`Sent the existing session to Codex Desktop.`,`success`),!0}catch(e){return i(e instanceof Error?e.message:String(e),`error`),!1}},wn=async e=>{if(!ke)return;let t=Ee.find(e=>e.branchName===ke);if(t){if(OP){window.parent.postMessage({type:`executeTerminalCommand`,command:e,cwd:t.workspacePath},`*`);return}try{await sr(`/api/workspace/${encodeURIComponent(t.branchName)}/terminal`,{method:`POST`,body:JSON.stringify({command:e})})}catch(e){i(`Terminal error: ${e instanceof Error?e.message:String(e)}`,`error`)}}};(0,V.useEffect)(()=>{ln(),tn();let t=new URLSearchParams(window.location.search).get(`workspaceId`);t&&e(`/workspaces/${encodeURIComponent(t)}`)},[]),(0,V.useEffect)(()=>{if(kP)return kP.onEvent(en)},[]),(0,V.useEffect)(()=>{let e=t.pathname;if(e.startsWith(`/workspaces`)){let t=e.split(`/`).filter(Boolean);Ae(t[1]?decodeURIComponent(t[1]):null);let n=t[2];Me(n&&[`overview`,`plan`,`documents`,`changes`,`services`,`sessions`,`knowledge`,`skills`].includes(n)?n:`overview`)}else Ae(null)},[t.pathname]);let Tn=async(e=!1)=>{Yt(!0);try{let t=await fetch(`/api/updates/tools${e?`?force=true`:``}`);t.ok&&qt(await t.json())}catch(e){console.error(`Failed to fetch tools status:`,e)}finally{Yt(!1)}},En=async e=>{Zt(e);try{let t=await fetch(`/api/updates/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({toolId:e})}),n=await t.json();t.ok&&n.success?(i(`${e} updated successfully!\n\nOutput:\n${n.output}`,`success`),Tn(!0),tn()):i(`Error: ${n.error||`Failed to update tool`}`,`error`)}catch(e){console.error(e),i(`Network error when updating tool.`,`error`)}finally{Zt(null)}};(0,V.useEffect)(()=>{t.pathname.startsWith(`/settings`)&&Tn()},[t.pathname]),(0,V.useEffect)(()=>{pt.current=ke,mt.current+=1,ht.current+=1,gt.current+=1,Pe([]),We([]),Je(``),Qe(null),Xe(!1),ot(null),it(!1),_t.current=``,vt.current=!1,nt(``),et(!1),ct(``),ft(null),ut(!1)},[ke]),(0,V.useEffect)(()=>{ke&&(je===`changes`||je===`overview`)&&hn(ke)},[ke,je]),(0,V.useEffect)(()=>{ke&&(je===`sessions`||je===`overview`)&&gn(ke)},[ke,je]),(0,V.useEffect)(()=>{ke&&je===`knowledge`&&vn(ke)},[ke,je]),(0,V.useEffect)(()=>{ke&&(je===`overview`||je===`plan`)&&bn(ke)},[ke,je]);let Dn=async e=>{let t=e.repos.map(e=>e.split(/[\\/]/).pop()).join(`, `);await QS(`You are an AI assistant helping with feature development.
67
+ `+i(e.slice(t+1))}t.exports=n,t.exports.escapeCarriageReturn=n,t.exports.escapeCarriageReturnSafe=a})),qN=n((e=>{e.Any=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,e.Cc=/[\0-\x1F\x7F-\x9F]/,e.Cf=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,e.P=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,e.S=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/,e.Z=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/})),JN=n(((e,t)=>{var n=qN();function r(e){let t={};e||={},t.src_Any=n.Any.source,t.src_Cc=n.Cc.source,t.src_Z=n.Z.source,t.src_P=n.P.source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join(`|`),t.src_ZCc=[t.src_Z,t.src_Cc].join(`|`);let r=`[><|]`;return t.src_pseudo_letter=`(?:(?!${r}|${t.src_ZPCc})${t.src_Any})`,t.src_ip4=`(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)`,t.src_auth=`(?:(?:(?!${t.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`,t.src_port=`(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?`,t.src_host_terminator=`(?=$|${r}|${t.src_ZPCc})(?!${e[`---`]?`-(?!--)|`:`-|`}_|:\\d|\\.-|\\.(?!$|${t.src_ZPCc}))`,t.src_path=`(?:[/?#](?:(?!${t.src_ZCc}|${r}|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!${t.src_ZCc}|\\]).)*\\]|\\((?:(?!${t.src_ZCc}|[)]).)*\\)|\\{(?:(?!${t.src_ZCc}|[}]).)*\\}|\\"(?:(?!${t.src_ZCc}|["]).)+\\"|\\'(?:(?!${t.src_ZCc}|[']).)+\\'|\\'(?=${t.src_pseudo_letter}|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!${t.src_ZCc}|[.]|$)|`+(e[`---`]?`\\-(?!--(?:[^-]|$))(?:-*)|`:`\\-+|`)+`,(?!${t.src_ZCc}|$)|;(?!${t.src_ZCc}|$)|\\!+(?!${t.src_ZCc}|[!]|$)|\\?(?!${t.src_ZCc}|[?]|$))+|\\/)?`,t.src_email_name=`[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]{0,63}`,t.src_xn=`xn--[a-z0-9\\-]{1,59}`,t.src_domain_root=`(?:`+t.src_xn+`|${t.src_pseudo_letter}{1,63})`,t.src_domain=`(?:`+t.src_xn+`|(?:${t.src_pseudo_letter})|(?:${t.src_pseudo_letter}(?:-|${t.src_pseudo_letter}){0,61}${t.src_pseudo_letter}))`,t.src_host=`(?:(?:(?:(?:${t.src_domain})\\.)*${t.src_domain}))`,t.tpl_host_fuzzy=`(?:`+t.src_ip4+`|(?:(?:(?:${t.src_domain})\\.)+(?:%TLDS%)))`,t.tpl_host_no_ip_fuzzy=`(?:(?:(?:${t.src_domain})\\.)+(?:%TLDS%))`,t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test=`localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:${t.src_ZPCc}|>|$))`,t.tpl_email_fuzzy=`(^|${r}|"|\\(|${t.src_ZCc})(${t.src_email_name}@${t.tpl_host_fuzzy_strict})`,t.tpl_link_fuzzy=`(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${t.src_ZPCc}))((?![$+<=>^\`|\uff5c])${t.tpl_host_port_fuzzy_strict}${t.src_path})`,t.tpl_link_no_ip_fuzzy=`(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${t.src_ZPCc}))((?![$+<=>^\`|\uff5c])${t.tpl_host_port_no_ip_fuzzy_strict}${t.src_path})`,t}function i(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){t&&Object.keys(t).forEach(function(n){e[n]=t[n]})}),e}function a(e){return Object.prototype.toString.call(e)}function o(e){return a(e)===`[object String]`}function s(e){return a(e)===`[object Object]`}function c(e){return a(e)===`[object RegExp]`}function l(e){return a(e)===`[object Function]`}function u(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,`\\$&`)}var d={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function f(e){return Object.keys(e||{}).reduce(function(e,t){return e||d.hasOwnProperty(t)},!1)}var p={"http:":{validate:function(e,t,n){let r=e.slice(t);return n.re.http||(n.re.http=RegExp(`^\\/\\/${n.re.src_auth}${n.re.src_host_port_strict}${n.re.src_path}`,`i`)),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":`http:`,"ftp:":`http:`,"//":{validate:function(e,t,n){let r=e.slice(t);return n.re.no_http||(n.re.no_http=RegExp(`^`+n.re.src_auth+`(?:localhost|(?:(?:${n.re.src_domain})\\.)+${n.re.src_domain_root})`+n.re.src_port+n.re.src_host_terminator+n.re.src_path,`i`)),n.re.no_http.test(r)?t>=3&&e[t-3]===`:`||t>=3&&e[t-3]===`/`?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){let r=e.slice(t);return n.re.mailto||(n.re.mailto=RegExp(`^${n.re.src_email_name}@${n.re.src_host_strict}`,`i`)),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},m=`a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]`,h=`biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф`.split(`|`);function g(e){return function(t,n){let r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}function _(){return function(e,t){t.normalize(e)}}function v(e){let t=e.re=r(e.__opts__),n=e.__tlds__.slice();e.onCompile(),e.__tlds_replaced__||n.push(m),n.push(t.src_xn),t.src_tlds=n.join(`|`);function i(e){return e.replace(`%TLDS%`,t.src_tlds)}t.email_fuzzy=RegExp(i(t.tpl_email_fuzzy),`i`),t.email_fuzzy_global=RegExp(i(t.tpl_email_fuzzy),`ig`),t.link_fuzzy=RegExp(i(t.tpl_link_fuzzy),`i`),t.link_fuzzy_global=RegExp(i(t.tpl_link_fuzzy),`ig`),t.link_no_ip_fuzzy=RegExp(i(t.tpl_link_no_ip_fuzzy),`i`),t.link_no_ip_fuzzy_global=RegExp(i(t.tpl_link_no_ip_fuzzy),`ig`),t.host_fuzzy_test=RegExp(i(t.tpl_host_fuzzy_test),`i`);let a=[];e.__compiled__={};function d(e,t){throw Error(`(LinkifyIt) Invalid schema "${e}": ${t}`)}Object.keys(e.__schemas__).forEach(function(t){let n=e.__schemas__[t];if(n===null)return;let r={validate:null,link:null};if(e.__compiled__[t]=r,s(n)){c(n.validate)?r.validate=g(n.validate):l(n.validate)?r.validate=n.validate:d(t,n),l(n.normalize)?r.normalize=n.normalize:n.normalize?d(t,n):r.normalize=_();return}if(o(n)){a.push(t);return}d(t,n)}),a.forEach(function(t){e.__compiled__[e.__schemas__[t]]&&(e.__compiled__[t].validate=e.__compiled__[e.__schemas__[t]].validate,e.__compiled__[t].normalize=e.__compiled__[e.__schemas__[t]].normalize)}),e.__compiled__[``]={validate:null,normalize:_()};let f=Object.keys(e.__compiled__).filter(function(t){return t.length>0&&e.__compiled__[t]}).map(u).join(`|`);e.re.schema_test=RegExp(`(^|(?!_)(?:[><\uff5c]|${t.src_ZPCc}))(${f})`,`i`),e.re.schema_search=RegExp(`(^|(?!_)(?:[><\uff5c]|${t.src_ZPCc}))(${f})`,`ig`),e.re.schema_at_start=RegExp(`^${e.re.schema_search.source}`,`i`),e.re.pretest=RegExp(`(${e.re.schema_test.source})|(${e.re.host_fuzzy_test.source})|@`,`i`)}function y(e,t,n,r){let i=e.slice(n,r);this.schema=t.toLowerCase(),this.index=n,this.lastIndex=r,this.raw=i,this.text=i,this.url=i}function b(e,t){if(!(this instanceof b))return new b(e,t);t||f(e)&&(t=e,e={}),this.__opts__=i({},d,t),this.__schemas__=i({},p,e),this.__compiled__={},this.__tlds__=h,this.__tlds_replaced__=!1,this.re={},v(this)}b.prototype.add=function(e,t){return this.__schemas__[e]=t,v(this),this},b.prototype.set=function(e){return this.__opts__=i(this.__opts__,e),this},b.prototype.test=function(e){if(!e.length)return!1;let t,n;if(this.re.schema_test.test(e)){for(n=this.re.schema_search,n.lastIndex=0;(t=n.exec(e))!==null;)if(this.testSchemaAt(e,t[2],n.lastIndex))return!0}return!!(this.__opts__.fuzzyLink&&this.__compiled__[`http:`]&&e.search(this.re.host_fuzzy_test)>=0&&e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy)!==null||this.__opts__.fuzzyEmail&&this.__compiled__[`mailto:`]&&e.indexOf(`@`)>=0&&e.match(this.re.email_fuzzy)!==null)},b.prototype.pretest=function(e){return this.re.pretest.test(e)},b.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},b.prototype.match=function(e){let t=[],n=[],r=[],i=[],a,o,s;function c(e,t){return e?t?e.index===t.index?e.lastIndex>=t.lastIndex?e:t:e.index<t.index?e:t:e:t}if(!e.length)return null;if(this.re.schema_test.test(e))for(s=this.re.schema_search,s.lastIndex=0;(a=s.exec(e))!==null;)o=this.testSchemaAt(e,a[2],s.lastIndex),o&&n.push({schema:a[2],index:a.index+a[1].length,lastIndex:a.index+a[0].length+o});if(this.__opts__.fuzzyLink&&this.__compiled__[`http:`])for(s=this.__opts__.fuzzyIP?this.re.link_fuzzy_global:this.re.link_no_ip_fuzzy_global,s.lastIndex=0;(a=s.exec(e))!==null;)r.push({schema:``,index:a.index+a[1].length,lastIndex:a.index+a[0].length});if(this.__opts__.fuzzyEmail&&this.__compiled__[`mailto:`])for(s=this.re.email_fuzzy_global,s.lastIndex=0;(a=s.exec(e))!==null;)i.push({schema:`mailto:`,index:a.index+a[1].length,lastIndex:a.index+a[0].length});let l=[0,0,0],u=0;for(;;){let a=[n[l[0]],i[l[1]],r[l[2]]],o=c(c(a[0],a[1]),a[2]);if(!o)break;if(o===a[0]?l[0]++:o===a[1]?l[1]++:l[2]++,o.index<u)continue;let s=new y(e,o.schema,o.index,o.lastIndex);this.__compiled__[s.schema].normalize(s,this),t.push(s),u=o.lastIndex}return t.length?t:null},b.prototype.matchAtStart=function(e){if(!e.length)return null;let t=this.re.schema_at_start.exec(e);if(!t)return null;let n=this.testSchemaAt(e,t[2],t[0].length);if(!n)return null;let r=new y(e,t[2],t.index+t[1].length,t.index+t[0].length+n);return this.__compiled__[r.schema].normalize(r,this),r},b.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(e,t,n){return e!==n[t-1]}).reverse(),v(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,v(this),this)},b.prototype.normalize=function(e){e.schema||(e.url=`http://${e.url}`),e.schema===`mailto:`&&!/^mailto:/i.test(e.url)&&(e.url=`mailto:${e.url}`)},b.prototype.onCompile=function(){},t.exports=b})),YN=t(n((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;o<a.length;o++)a[o]!=="default"&&t(i,r,a[o]);return n(i,r),i}})(),a=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=g;var o=a(GN()),s=KN(),c=a(JN()),l=i(r());function u(e,t=!1){return e=(0,s.escapeCarriageReturn)(_(e)),o.default.ansiToJson(e,{json:!0,remove_empty:!0,use_classes:t})}function d(e){let t=``;return e.bg&&(t+=`${e.bg}-bg `),e.fg&&(t+=`${e.fg}-fg `),e.decoration&&(t+=`ansi-${e.decoration} `),t===``?null:(t=t.substring(0,t.length-1),t)}function f(e){let t={};switch(e.bg&&(t.backgroundColor=`rgb(${e.bg})`),e.fg&&(t.color=`rgb(${e.fg})`),e.decoration){case`bold`:t.fontWeight=`bold`;break;case`dim`:t.opacity=`0.5`;break;case`italic`:t.fontStyle=`italic`;break;case`hidden`:t.visibility=`hidden`;break;case`strikethrough`:t.textDecoration=`line-through`;break;case`underline`:t.textDecoration=`underline`;break;case`blink`:t.textDecoration=`blink`}return t}function p(e,t,n,r){let i=t?null:f(n),a=t?d(n):null;return e?e===`fuzzy`?h(n,r,i,a):m(n,r,i,a):l.createElement(`span`,{style:i,key:r,className:a},n.content)}function m(e,t,n,r){let i=[],a=/(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g,o=0,s;for(;(s=a.exec(e.content))!==null;){let[,t,n]=s,r=s.index+t.length;r>o&&i.push(e.content.substring(o,r));let c=n.startsWith(`www.`)?`http://${n}`:n;i.push(l.createElement(`a`,{key:o,href:c,target:`_blank`},`${n}`)),o=a.lastIndex}return o<e.content.length&&i.push(e.content.substring(o)),l.createElement(`span`,{style:n,key:t,className:r},i)}function h(e,t,n,r){let i=(0,c.default)({fuzzyEmail:!1}).tlds([`io`],!0);if(!i.pretest(e.content))return l.createElement(`span`,{style:n,key:t,className:r},e.content);let a=i.match(e.content);if(!a)return l.createElement(`span`,{style:n,key:t,className:r},e.content);let o=[e.content.substring(0,a[0]?.index)];return a.forEach((t,n)=>{o.push(l.createElement(`a`,{href:t.url,target:`_blank`,key:n},e.content.substring(t.index,t.lastIndex))),a[n+1]&&o.push(e.content.substring(a[n].lastIndex,a[n+1]?.index))}),a[a.length-1].lastIndex!==e.content.length&&o.push(e.content.substring(a[a.length-1].lastIndex,e.content.length)),l.createElement(`span`,{style:n,key:t,className:r},o)}function g(e){let{className:t,useClasses:n,children:r,linkify:i}=e;return l.createElement(`code`,{className:t},u(r??``,n??!1).map(p.bind(null,i??!1,n??!1)))}function _(e){let t=e;do e=t,t=e.replace(/[^\n]\x08/gm,``);while(t.length<e.length);return e}}))(),1),XN=YN.default.default||YN.default;function ZN(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:e.toLocaleString()}function QN(e){return e?e.planType===`plan-included`?`Plan: Included`:e.contextWindow?.utilizationPercent===void 0?e.tokens?.remaining===void 0?e.requests?.remaining===void 0?e.label?e.label:`Quota: OK`:`Quota: ${e.requests.remaining} req`:`Quota: ${ZN(e.tokens.remaining)}`:`Context: ${e.contextWindow.utilizationPercent.toFixed(1)}%`:`Quota: Unmonitored`}var $N=[{id:``,label:`Auto Effort`,description:`Model/provider default reasoning depth`},{id:`low`,label:`Low Effort`,description:`Fast responses with lightweight reasoning`},{id:`medium`,label:`Medium Effort`,description:`Balanced reasoning depth and latency`},{id:`high`,label:`High Effort`,description:`Deep multi-step reasoning and verification`},{id:`max`,label:`Max Effort`,description:`Maximum thinking budget for complex tasks`}];function eP(e){return e?e.charAt(0).toUpperCase()+e.slice(1):`Auto`}var tP={"claude-cli":new Set([`npm install -g @anthropic-ai/claude-code`,`claude auth login`,`claude auth status --json`]),"claude-sdk":new Set([`npm install -g @anthropic-ai/claude-code`,`claude auth login`,`claude auth status --json`]),"codex-cli":new Set([`npm install -g @openai/codex`,`codex login`,`codex login status`]),"codex-sdk":new Set([`npm install -g @openai/codex`,`codex login`,`codex login status`]),"antigravity-cli":new Set([`agy`]),"copilot-cli":new Set([`copilot login`,`copilot help`])},nP=new Set([`native-api`,`cli-print`,`acp`,`sdk`]),rP=new Set([`none`,`client-assigned`,`provider-assigned`]),iP=new Set([`read-only`,`workspace-write`,`harness-managed`]),aP=new Set([`uuid`,`opaque`]),oP=new Set([`missing-cli`,`signed-out`,`probe-failed`]);function sP(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function cP(e){return e===void 0||typeof e==`string`}function lP(e){return!sP(e)||typeof e.transport!=`string`||!nP.has(e.transport)||typeof e.sessionIdentity!=`string`||!rP.has(e.sessionIdentity)||typeof e.workspaceAccess!=`string`||!iP.has(e.workspaceAccess)||e.sessionIdFormat!==void 0&&(typeof e.sessionIdFormat!=`string`||!aP.has(e.sessionIdFormat))?null:{transport:e.transport,sessionIdentity:e.sessionIdentity,workspaceAccess:e.workspaceAccess,...e.sessionIdFormat===void 0?{}:{sessionIdFormat:e.sessionIdFormat}}}function uP(e){if(!sP(e)||typeof e.id!=`string`||typeof e.name!=`string`||typeof e.isConfigured!=`boolean`||!cP(e.icon)||!cP(e.accessLabel)||!cP(e.message)||!cP(e.recoveryCommand)||!cP(e.recoveryLabel)||e.setupIssue!==void 0&&(typeof e.setupIssue!=`string`||!oP.has(e.setupIssue)))return null;let t=lP(e.capabilities);if(!t)return null;let n;if(e.executionProfiles!==void 0){if(!Array.isArray(e.executionProfiles)||e.executionProfiles.length===0)return null;n=[];let t=new Set;for(let r of e.executionProfiles){if(!sP(r)||!xN(r.id)||typeof r.label!=`string`||typeof r.description!=`string`||t.has(r.id))return null;t.add(r.id),n.push({id:r.id,label:r.label,description:r.description})}}if(e.defaultExecutionProfile!==void 0&&(!xN(e.defaultExecutionProfile)||!n?.some(t=>t.id===e.defaultExecutionProfile))||n&&e.defaultExecutionProfile===void 0||!n&&e.defaultExecutionProfile!==void 0)return null;let r;if(e.models!==void 0){if(!Array.isArray(e.models)||e.models.length===0)return null;r=[];let t=new Set;for(let n of e.models){if(!sP(n)||typeof n.id!=`string`||n.id.length>100||typeof n.label!=`string`||n.label.length===0||n.label.length>100||typeof n.description!=`string`||n.description.length>300||t.has(n.id))return null;t.add(n.id),r.push({id:n.id,label:n.label,description:n.description})}}let i=e.setupIssue!==void 0||e.recoveryCommand!==void 0||e.recoveryLabel!==void 0,a=e.setupIssue!==void 0&&e.recoveryCommand!==void 0&&e.recoveryLabel!==void 0;return i&&!a||e.isConfigured&&i?null:{id:e.id,name:e.name,isConfigured:e.isConfigured,capabilities:t,...e.icon===void 0?{}:{icon:e.icon},...e.accessLabel===void 0?{}:{accessLabel:e.accessLabel},...e.message===void 0?{}:{message:e.message},...e.setupIssue===void 0?{}:{setupIssue:e.setupIssue},...e.recoveryCommand===void 0?{}:{recoveryCommand:e.recoveryCommand},...e.recoveryLabel===void 0?{}:{recoveryLabel:e.recoveryLabel},...n===void 0?{}:{executionProfiles:n},...e.defaultExecutionProfile===void 0?{}:{defaultExecutionProfile:e.defaultExecutionProfile},...r===void 0?{}:{models:r}}}function dP(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){let e=uP(n);if(!e)return null;t.push(e)}return t}function fP(e){return!e.recoveryCommand||!tP[e.id]?.has(e.recoveryCommand)?null:{command:e.recoveryCommand,label:e.recoveryLabel??`Copy recovery command`}}function pP(e){return!e||e.toLowerCase().includes(`review`)?`Review`:e.toLowerCase().includes(`edit`)||e.toLowerCase().includes(`write`)?`Edit`:e}function mP(e,t){if(!t)return`Auto`;let n=e.models?.find(e=>e.id===t);return n?n.label:t}function hP(e,t){let n=!1,r={...e};for(let i of t){let t=e[i.id];t&&i.models&&!i.models.some(e=>e.id===t)&&(delete r[i.id],n=!0)}return n?r:e}var gP=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):null,_P=(0,V.memo)(function({msg:e,idx:t,copied:n,onCopy:r}){if(e.role===`system`)return(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsx)(`span`,{className:B(`rounded-full border px-3 py-1 text-center text-[11px]`,e.kind===`error`?`border-destructive/25 bg-destructive/10 text-destructive-foreground`:`border-border bg-muted text-muted-foreground`),children:e.content})});let i=e.role===`user`,a=!i&&e.content.includes(`\x1B`);return(0,H.jsxs)(`div`,{className:`flex flex-col ${i?`items-end`:`items-start`}`,children:[(0,H.jsx)(`div`,{className:`group relative max-w-[85%] rounded-lg p-3 ${i?`bg-primary text-primary-foreground`:`border border-border bg-card text-foreground`}`,children:i?(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.images&&e.images.length>0&&(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.images.map((e,t)=>(0,H.jsx)(`img`,{src:e,alt:`Attached`,className:`max-h-48 max-w-full rounded-lg border border-white/20 object-contain shadow-xs cursor-pointer hover:opacity-95`,onClick:()=>window.open(e,`_blank`)},t))}),e.content&&(0,H.jsx)(`div`,{className:`whitespace-pre-wrap text-sm`,children:e.content})]}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a?(0,H.jsx)(`div`,{className:`overflow-x-auto whitespace-pre-wrap rounded-md bg-muted/50 p-2 font-mono text-xs text-foreground`,children:(0,H.jsx)(XN,{children:e.content})}):(0,H.jsx)(Dv,{content:e.content}),e.filesChanged&&e.filesChanged.length>0&&(0,H.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5 rounded-md border border-border/70 bg-muted/30 p-2 text-xs`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground`,children:[(0,H.jsx)(Fr,{size:13,className:`text-primary`}),(0,H.jsxs)(`span`,{children:[e.filesChanged.length,` file`,e.filesChanged.length>1?`s`:``,` modified`]})]}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.filesChanged.map((e,t)=>(0,H.jsx)(`span`,{className:`rounded bg-background px-1.5 py-0.5 font-mono text-[10px] text-foreground border border-border/50`,children:e},t))})]}),e.usage&&(0,H.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2 text-[10px] text-muted-foreground font-mono`,children:(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 bg-muted/60 px-1.5 py-0.5 rounded border border-border/40`,children:[(0,H.jsx)(Di,{size:10,className:`text-amber-500 shrink-0`}),(0,H.jsxs)(`span`,{children:[e.usage.inputTokens.toLocaleString(),` in`]}),typeof e.usage.cachedInputTokens==`number`&&e.usage.cachedInputTokens>0&&(0,H.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[`(`,e.usage.cachedInputTokens.toLocaleString(),` cached)`]}),(0,H.jsx)(`span`,{children:`·`}),(0,H.jsxs)(`span`,{children:[e.usage.outputTokens.toLocaleString(),` out`]}),e.usage.costUsdEstimate!==void 0&&e.usage.costUsdEstimate>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`·`}),(0,H.jsxs)(`span`,{children:[`~$`,e.usage.costUsdEstimate<.01?e.usage.costUsdEstimate.toFixed(4):e.usage.costUsdEstimate.toFixed(3)]})]})]})}),(0,H.jsx)(`button`,{onClick:()=>r(t,e.content),className:`absolute -right-2.5 -top-2.5 hidden h-6 w-6 cursor-pointer place-items-center rounded-md border border-border bg-card text-muted-foreground shadow-sm hover:text-foreground group-hover:grid`,title:`Copy message`,children:n?(0,H.jsx)(wr,{size:12,className:`text-success-foreground`}):(0,H.jsx)(Mr,{size:12})})]})}),i&&e.executionProfile&&(0,H.jsx)(`span`,{className:`mt-1 rounded border border-border px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.executionProfile===`workspace-write`?`Edit`:`Review`}),e.ts&&(0,H.jsx)(`span`,{className:`mt-1 text-[10px] text-muted-foreground`,children:gP(e.ts)})]})});function vP({ws:e,draft:t,onDraftConsumed:n}){let r=Ft(),i=Lt(),[a,o]=(0,V.useState)([]),[s,c]=(0,V.useState)(!1),[l]=(0,V.useState)(()=>TN(e.branchName)),[u,d]=(0,V.useState)(l.messages),[f,p]=(0,V.useState)(``),m=(0,V.useRef)(null);(0,V.useEffect)(()=>{!t||m.current===t.id||(m.current=t.id,p(e=>e?`${e}\n\n${t.text}`:t.text),n?.(t.id))},[t,n]);let[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(``),[C,w]=(0,V.useState)(l.profilesByProvider),[T,E]=(0,V.useState)(l.modelsByProvider??{}),[D,ee]=(0,V.useState)(l.effortsByProvider??{}),[O,k]=(0,V.useState)(null),[A,te]=(0,V.useState)(!1),[j,M]=(0,V.useState)(l.sessions),[N,ne]=(0,V.useState)(0),[re,ie]=(0,V.useState)(!1),[P,F]=(0,V.useState)(null),[I,L]=(0,V.useState)(null),[ae,R]=(0,V.useState)(null),[oe,z]=(0,V.useState)(!1),[se,ce]=(0,V.useState)(null),[le,ue]=(0,V.useState)(!1),[de,fe]=(0,V.useState)(null),[pe,me]=(0,V.useState)(null),[he,ge]=(0,V.useState)([]),[_e,ve]=(0,V.useState)(!1),ye=(0,V.useRef)(null),be=(0,V.useRef)(!1),xe=(0,V.useCallback)((e,t)=>{d(n=>[...n,{role:`system`,content:e,kind:t,ts:Date.now()}])},[]),Se=(0,V.useCallback)(e=>{let t=Array.from(e),n=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]),r=t.filter(e=>!n.has(e.type));r.length>0&&xe(`${r.length} unsupported file(s) ignored. Attach PNG, JPEG, GIF, or WebP images.`,`note`);let i=t.filter(e=>n.has(e.type));if(i.length!==0)for(let e of i){if(e.size>20971520){xe(`Image "${e.name}" exceeds the 20MB limit and was not attached.`,`error`);continue}let t=new FileReader;t.onload=t=>{let n=t.target?.result;typeof n==`string`&&n.startsWith(`data:image/`)?ge(t=>[...t,{id:crypto.randomUUID(),name:e.name||`pasted-image-${Date.now()}.png`,dataUrl:n,file:e}]):xe(`Image "${e.name||`pasted image`}" could not be read.`,`error`)},t.onerror=()=>xe(`Image "${e.name||`pasted image`}" could not be read.`,`error`),t.readAsDataURL(e)}},[xe]),Ce=(0,V.useCallback)(e=>{M(t=>{let n=e(t);return Oe.current=n,n}),ne(e=>e+1)},[]),we=(0,V.useRef)(null),Te=(0,V.useRef)(null),Ee=(0,V.useRef)(null),De=(0,V.useRef)(!0),Oe=(0,V.useRef)(l.sessions),ke=(0,V.useRef)([]),Ae=(0,V.useRef)(!1),je=(0,V.useRef)(!1),Me=(0,V.useRef)({messages:u,agentName:x,profilesByProvider:C,modelsByProvider:T,effortsByProvider:D}),Ne=(0,V.useRef)(C),Pe=(0,V.useRef)(null),Fe=(0,V.useRef)(null),Ie=(0,V.useRef)(!0),Le=(0,V.useRef)(0),Re=(0,V.useRef)(null),ze=(0,V.useRef)(!1),Be=(0,V.useRef)({id:0,controller:null}),Ve=(0,V.useMemo)(()=>IN(r.state),[r.state]),[He,Ue]=(0,V.useState)([]),We=(0,V.useRef)(new Set),Ge=(0,V.useRef)(!1),Ke=(0,V.useRef)(!1),qe=(0,V.useRef)(null);(0,V.useEffect)(()=>{Ge.current=_},[_]);let Je=(0,V.useCallback)((e,t)=>{let n=we.current;n&&n.readyState===WebSocket.OPEN&&n.send(JSON.stringify({type:`approval_response`,requestId:e,decision:t})),Ue(t=>t.filter(t=>t.requestId!==e))},[]);(0,V.useEffect)(()=>{Me.current={messages:u,agentName:x,profilesByProvider:C,modelsByProvider:T,effortsByProvider:D},Ne.current=C},[u,x,C,T,D]);let Ye=(0,V.useCallback)(()=>{Pe.current=null,AN(e.branchName,{v:4,sessions:Oe.current,providerId:Me.current.agentName||l.providerId,profilesByProvider:Me.current.profilesByProvider,modelsByProvider:Me.current.modelsByProvider,effortsByProvider:Me.current.effortsByProvider,messages:Me.current.messages})},[e.branchName,l.providerId]);(0,V.useEffect)(()=>{let e=u[u.length-1];(De.current||e?.role===`user`)&&Ee.current?.scrollIntoView({behavior:e?.role===`user`?`smooth`:`auto`}),Pe.current&&clearTimeout(Pe.current),Pe.current=setTimeout(Ye,400)},[u,x,C,T,N,Ye]),(0,V.useEffect)(()=>{let e=()=>Ye();return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e),Pe.current&&clearTimeout(Pe.current),Ye()}},[Ye]),(0,V.useEffect)(()=>{let t=!0;return DN(e.branchName).then(e=>{if(!(!t||!e)&&(d(t=>{if(t.length===0&&e.messages.length>0)return e.messages;let n=new Map(e.messages.filter(e=>e.images?.length).map(e=>[`${e.role}:${e.ts??``}:${e.content}`,e.images])),r=!1,i=t.map(e=>{if(e.images?.length)return e;let t=n.get(`${e.role}:${e.ts??``}:${e.content}`);return t?(r=!0,{...e,images:t}):e});return r?i:t}),e.sessions&&Object.keys(e.sessions).length>0&&Ce(t=>({...e.sessions,...t})),e.isBusy&&!we.current)){let t=e.providerId||x;t&&qe.current&&qe.current(t,{firstMessage:null})}}),()=>{t=!1}},[e.branchName,Ce,x]),(0,V.useEffect)(()=>{let t=++Le.current,n=new AbortController,r=!0;return fetch(`/api/adapters/status`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`,signal:n.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(n=>{if(!r||t!==Le.current)return;let i=dP(n);if(!i)throw Error(`Invalid provider status response`);o(i),E(e=>hP(e,i)),w(e=>{let t=!1,n={...e};for(let r of i)!r.executionProfiles?.length||!r.defaultExecutionProfile||r.executionProfiles.some(t=>t.id===e[r.id])||(n[r.id]=r.defaultExecutionProfile,t=!0);return t?n:e});let a=e.assistants?.[0]?FN(e.assistants[0]):void 0,s=l.providerId?i.find(e=>e.id===l.providerId):void 0,c=a?i.find(e=>e.id===a&&e.isConfigured):void 0,u=s||c||i.find(e=>e.isConfigured)||i[0];u&&S(e=>e||u.id)}).catch(e=>{r&&e?.name!==`AbortError`&&console.error(`Failed to fetch agent data`,e)}).finally(()=>{r&&t===Le.current&&c(!0)}),()=>{r=!1,n.abort()}},[l.providerId,e.assistants]),(0,V.useEffect)(()=>(Ie.current=!0,()=>{Ie.current=!1,Be.current.id+=1,Be.current.controller?.abort(),we.current&&we.current.close()}),[e.branchName,e.workspacePath]);let Xe=O??x,Ze=a.find(e=>e.id===Xe),Qe=Ze?.executionProfiles?.find(e=>e.id===C[Ze.id])??Ze?.executionProfiles?.find(e=>e.id===Ze.defaultExecutionProfile),$e=!!x&&!!Ze?.isConfigured&&(!Ze?.executionProfiles||!!Qe)&&!A&&!re,et=(0,V.useCallback)(e=>{_||A||re||(we.current&&=(we.current.close(),null),g(!1),k(null),R(null),S(e),Me.current.agentName=e,Pe.current&&clearTimeout(Pe.current),Ye())},[_,A,re,Ye]),tt=(0,V.useCallback)((e,t)=>{let n=t??a.find(t=>t.id===e);if(!n?.executionProfiles?.length)return;let r=Ne.current[e];return r&&n.executionProfiles.some(e=>e.id===r)?r:n.defaultExecutionProfile??`review`},[a]),nt=(0,V.useCallback)(()=>{Ae.current=!1,b(!1)},[]),rt=(0,V.useCallback)(async(t,n,r,i)=>{if(be.current)return;be.current=!0;let a=i??he;try{let i=crypto.randomUUID(),o=[],s=[],c=!1;if(a.length>0){let t=await Promise.all(a.map(async t=>{try{let n=await fetch(`/api/chat/upload-attachment`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({dataUrl:t.dataUrl,filename:t.name,workspacePath:e.workspacePath})});if(n.ok){let e=await n.json();if(typeof e.path==`string`&&e.path)return{dataUrl:t.dataUrl,path:e.path};throw Error(`Invalid upload response`)}let r=await n.json().catch(()=>({error:`Upload failed`}));c=!0,xe(`Image "${t.name}" could not be uploaded: ${r.error||n.statusText}`,`error`)}catch(e){console.error(`Failed to upload image attachment`,e),c=!0,xe(`Image "${t.name}" failed to upload.`,`error`)}return{dataUrl:t.dataUrl,path:null}}));if(c){xe(`The message was kept in the composer. Fix or remove the failed image, then try again.`,`note`);return}o=t.map(e=>e.path).filter(e=>!!e),s=t.map(e=>e.dataUrl)}let l=n;if(o.length>0){let e=o.map(e=>`[Attached image: ${e}]`).join(`
68
+ `);l=l?`${l}\n\n${e}`:e}let u={role:`user`,content:n,ts:Date.now(),...r?{executionProfile:r}:{},...s.length>0?{images:s}:{}};if(t.readyState!==WebSocket.OPEN||we.current!==t){xe(`The agent disconnected while images were uploading. Your draft and attachments were kept.`,`error`);return}ke.current.push({turnId:i,text:l,message:u});let f=D[x];try{t.send(JSON.stringify({type:`input`,input:l,turnId:i,...r?{executionProfile:r}:{},command:x,cwd:e.workspacePath,...f?{effort:f}:{}}))}catch{ke.current=ke.current.filter(e=>e.turnId!==i),xe(`Failed to send message to the agent. Your draft and attachments were kept.`,`error`);return}d(e=>[...e,u]),p(e=>e.trim()===n?``:e);let m=new Set(a.map(e=>e.id));ge(e=>e.filter(e=>!m.has(e.id))),v(!0),nt()}finally{be.current=!1}},[x,xe,he,nt,D,e.workspacePath]),it=(0,V.useCallback)(()=>{je.current||(je.current=!0,xe(`Session ended`,`note`))},[xe]),at=(0,V.useCallback)(()=>{Ke.current=!0;let e=we.current;if(e){if(e.readyState===WebSocket.OPEN)try{e.send(JSON.stringify({type:`stop`}))}catch{}we.current=null,Re.current=null,k(null),te(!1),e.close(),g(!1),v(!1),nt(),it()}},[nt,it]),ot=(0,V.useCallback)((t=x,n={})=>{if(Ke.current=!1,we.current)return n.onFailure?.(),!1;let r=n.provider??a.find(e=>e.id===t);if(S(t),!r?.isConfigured)return xe(r?.message??`The ${t} provider is unavailable. Check its local CLI installation and login.`,`error`),n.onFailure?.(),!1;let i=n.executionProfile??tt(t,r),o=i!==void 0&&r.executionProfiles?.some(e=>e.id===i)===!0;if((n.executionProfile!==void 0||r.executionProfiles?.length)&&!o)return xe(`Select a supported execution profile before starting this local CLI.`,`error`),n.onFailure?.(),!1;let s=n.model??T[t];if(s&&r.models&&!r.models.some(e=>e.id===s))return xe(`Select a model advertised by this provider before starting the harness.`,`error`),n.onFailure?.(),!1;let c=``;c=c.startsWith(`http`)?c.replace(`http`,`ws`):window.location.origin.replace(`http`,`ws`),c+=`/ws`,je.current=!1;let l=!1,u=!1,m,h=()=>{u||l||!Ie.current||(u=!0,v(!1),te(!1),g(!1),xe(`Could not open the local agent connection. Your current chat was preserved; retry explicitly when ready.`,`error`),n.onFailure?.())};try{m=new WebSocket(c)}catch{return h(),!1}return m.onopen=()=>{if(!Ie.current||we.current!==m){m.close();return}let a={type:`start`,command:t,cwd:e.workspacePath};s&&(a.model=s);let o=D[t];o&&(a.effort=o);let c={...Oe.current};if(n.resetSession&&delete c[t],n.session&&(c[t]=n.session),r.capabilities.sessionIdentity===`client-assigned`){let e=c[t]??{id:crypto.randomUUID(),started:!1};c[t]=e,a.sessionId=e.id,a.resume=e.started}else if(r.capabilities.sessionIdentity===`provider-assigned`){let e=c[t];e?.started&&(a.sessionId=e.id,a.resume=!0)}let u=n.firstMessage===null?``:(n.firstMessage??f).trim(),_;try{if(m.send(JSON.stringify(a)),u){let e=crypto.randomUUID();_={turnId:e,text:u,message:{role:`user`,content:u,ts:Date.now(),...i?{executionProfile:i}:{}}},ke.current.push(_),m.send(JSON.stringify({type:`input`,input:u,turnId:e,...i?{executionProfile:i}:{}}))}}catch{_&&(ke.current=ke.current.filter(e=>e.turnId!==_?.turnId)),h(),we.current=null,Re.current=null,k(null),te(!1),m.close();return}Ce(()=>c),l=!0,te(!1),g(!0),n.resetMessagesOnDispatch&&d([]),u&&(d(e=>[...n.resetMessagesOnDispatch?[]:e,_?.message??{role:`user`,content:u,ts:Date.now(),...i?{executionProfile:i}:{}}]),p(``),v(!0),nt()),n.onDispatched?.()},m.onmessage=e=>{if(we.current===m)try{let n=JSON.parse(e.data);if(n.type===`stream`){let e=Ae.current;Ae.current=!0,b(!0),d(t=>{let r=t[t.length-1];if(e&&r?.role===`assistant`){let e=[...t];return e[e.length-1]={...r,content:r.content+n.text},e}return[...t,{role:`assistant`,content:n.text,ts:Date.now()}]})}else if(n.type===`session`&&typeof n.id==`string`)/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n.id)&&Ce(e=>({...e,[t]:{id:n.id,started:!0}}));else if(n.type===`approval_request`&&typeof n.requestId==`string`)Ue(e=>[...e.filter(e=>e.requestId!==n.requestId),{requestId:n.requestId,tool:typeof n.tool==`string`?n.tool:`Tool`,input:n.input&&typeof n.input==`object`?n.input:{},description:typeof n.description==`string`?n.description:void 0}]);else if(n.type===`accepted`&&typeof n.turnId==`string`)ke.current=ke.current.filter(e=>e.turnId!==n.turnId);else if(n.type===`file_changed`){if(Array.isArray(n.paths))for(let e of n.paths)typeof e==`string`&&e.trim()&&We.current.add(e.trim())}else if(n.type===`usage`){let e=n.usage,t=n.cumulative,r=n.quota;t&&F(t),r&&L(r),e&&d(t=>{for(let n=t.length-1;n>=0;n--)if(t[n].role===`assistant`){let r=[...t];return r[n]={...r[n],usage:e},r}return t})}else if(n.type===`usage_summary`)n.cumulative&&F(n.cumulative),n.quota&&L(n.quota);else if(n.type===`quota`)n.quota&&L(n.quota);else if(n.type===`status`){if(v(n.state===`busy`),n.state!==`busy`){let e=Array.from(We.current);We.current.clear(),e.length>0&&d(t=>{for(let n=t.length-1;n>=0;n--)if(t[n].role===`assistant`){let r=[...t],i=r[n].filesChanged||[],a=Array.from(new Set([...i,...e]));return r[n]={...r[n],filesChanged:a},r}return t}),nt(),Ue([])}}else if(n.type===`system`)xe(n.message,`note`);else if(n.type===`rejected`&&n.reason===`busy`){let e=ke.current.findIndex(e=>e.turnId===n.turnId),t=e===-1?void 0:ke.current.splice(e,1)[0];t&&(d(e=>e.filter(e=>e!==t.message)),p(e=>e?`${t.text}\n\n${e}`:t.text)),xe(typeof n.message==`string`?n.message:`The agent is still processing the current turn.`,`error`)}else n.type===`error`?(ke.current=[],Ue([]),We.current.clear(),typeof n.message==`string`&&n.message.toLowerCase().includes(`session`)&&Ce(e=>{let n={...e};return delete n[t],n}),xe(n.message,`error`),v(!1),te(!1),nt()):n.type===`close`&&(ke.current=[],Ue([]),We.current.clear(),g(!1),te(!1),v(!1),nt(),it(),m.close(),we.current=null)}catch(e){console.error(`Failed to parse WS message`,e)}},m.onclose=()=>{if(we.current!==m)return;l||h();let e=Ge.current,n=Ke.current;if(g(!1),te(!1),v(!1),nt(),we.current=null,Re.current=null,k(null),e&&Ie.current&&!n){xe(`Connection interrupted. Resuming turn...`,`note`),setTimeout(()=>{Ie.current&&!Ke.current&&!we.current&&qe.current?.(t,{firstMessage:null})},1200);return}l&&it()},m.onerror=()=>{we.current===m&&(h(),v(!1),te(!1),l||(we.current=null,Re.current=null,k(null),g(!1),m.close()))},we.current=m,Re.current=t,k(t),te(!0),!0},[x,xe,nt,D,f,T,it,tt,a,Ce,e.workspacePath]);(0,V.useEffect)(()=>{qe.current=ot},[ot]);let st=(0,V.useCallback)(()=>{let e=f.trim();if(!e&&he.length===0||_||ze.current||be.current)return;let t=we.current,n=Re.current||x;if(!h||!t||t.readyState!==WebSocket.OPEN){if(t){try{t.close()}catch{}we.current=null}if(he.length>0){let t=a.find(e=>e.id===n),r=tt(n,t);if(t?.executionProfiles?.length&&!r)return;let i=e,o=he;ot(n,{firstMessage:null,onDispatched:()=>{let e=we.current;if(!e||e.readyState!==WebSocket.OPEN){xe(`The agent connected, but the pasted message could not be sent. Your draft and attachments were kept.`,`error`);return}rt(e,i,r,o)}})}else ot(n,{firstMessage:e});return}let r=a.find(e=>e.id===n),i=tt(n,r);r?.executionProfiles?.length&&!i||rt(t,e,i,he)},[x,xe,he,_,h,f,tt,a,rt,ot]),ct=(0,V.useCallback)((e,t)=>{QS(t).then(t=>{if(!t){xe(`Could not copy this message. Check browser clipboard permissions or copy it manually.`,`error`);return}me(e),setTimeout(()=>me(t=>t===e?null:t),1500)})},[xe]),ut=(0,V.useCallback)(e=>{Be.current.id===e&&(Be.current.controller=null,ze.current=!1,Ie.current&&ie(!1))},[]),dt=(0,V.useCallback)(async(e,t=!1)=>{let n=Be.current.id+1;Be.current.controller?.abort();let r=new AbortController;Be.current={id:n,controller:r},ze.current=!0,ie(!0),fe(null);let i=FN(e.assistant);if(!i)return xe(`This session cannot resume in embedded chat.`,`error`),ut(n),!1;let o=a.find(e=>e.id===i);if(!o?.isConfigured)return xe(o?.message??`The ${i} provider is unavailable. Check its local CLI installation and login.`,`error`),ut(n),!1;let s=()=>Ie.current&&Be.current.id===n&&!r.signal.aborted;try{let a=await fetch(`/api/session/${encodeURIComponent(e.assistant)}/${encodeURIComponent(e.id)}/transcript`,{signal:r.signal});if(!a.ok)throw Error(`HTTP ${a.status}`);let o=await a.json();if(!s())return!1;let c=(Array.isArray(o.messages)?o.messages:[]).filter(e=>(e.role===`user`||e.role===`assistant`)&&typeof e.content==`string`&&e.content.trim()).map(e=>({role:e.role,content:e.content,ts:e.timestamp&&Date.parse(e.timestamp)||void 0}));if(we.current&&!window.confirm(`Stop the current chat and resume this session?`))return ut(n),!1;we.current&&at(),S(i);let l=()=>{s()&&(w(e=>({...e,[i]:`review`})),d([...c,{role:`system`,kind:`note`,content:`Loaded session — your next message resumes it.`,ts:Date.now()}]),p(``),ue(!1),ut(n))};return t?ot(i,{firstMessage:null,session:{id:e.id,started:!0},onDispatched:l,onFailure:()=>{s()&&(fe(`Failed to connect to the selected session.`),ut(n))}}):(Ce(t=>({...t,[i]:{id:e.id,started:!0}})),l(),!0)}catch(e){return!s()||e instanceof DOMException&&e.name===`AbortError`?!1:(fe(`Failed to load the session transcript.`),xe(`Failed to load the session transcript. Your current chat was preserved.`,`error`),ut(n),!1)}},[xe,ut,a,ot,at,Ce]),ft=(0,V.useCallback)(e=>{dt(e)},[dt]),pt=(0,V.useCallback)(async(e,t=!1,n=!1)=>{R(e);let r;if(t){z(!0);try{let t=await fetch(`/api/adapters/status/refresh`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({providerId:e.providerId})});if(!t.ok)throw Error(`HTTP ${t.status}`);let i=dP(await t.json());if(!i)throw Error(`Invalid provider status response`);if(!Ie.current)return!1;o(i),E(e=>hP(e,i)),r=i.find(t=>t.id===e.providerId);let a=n&&(r?.setupIssue===`signed-out`||r?.setupIssue===`probe-failed`);if(!r||!r.isConfigured&&!a)return xe(r?.message??`The selected local CLI is still unavailable. Install it and sign in, then retry.`,`error`),!1}catch{return Ie.current&&xe(`Could not refresh the local CLI status. The task handoff was not dispatched.`,`error`),!1}finally{Ie.current&&z(!1)}}return ot(e.providerId,{firstMessage:e.kickoff,executionProfile:e.executionProfile,provider:r&&n&&(r.setupIssue===`signed-out`||r.setupIssue===`probe-failed`)?{...r,isConfigured:!0}:r,resetSession:!0,resetMessagesOnDispatch:!0,onDispatched:()=>{Ie.current&&R(null)},onFailure:()=>{Ie.current&&R(e)}})},[xe,ot]);(0,V.useEffect)(()=>{if(!s||!Ve)return;let e=Fe.current===Ve.nonce;try{e=e||sessionStorage.getItem(er)===Ve.nonce||sessionStorage.getItem(Xn)===Ve.nonce,sessionStorage.setItem(er,Ve.nonce)}catch{}Fe.current=Ve.nonce;let t=r.state&&typeof r.state==`object`?{...r.state}:{};if(delete t.chatLaunch,i(`${r.pathname}${r.search}`,{replace:!0,state:Object.keys(t).length>0?t:null}),e)return;let n=a.find(e=>e.id===Ve.providerId);if(S(Ve.providerId),w(e=>({...e,[Ve.providerId]:Ve.executionProfile})),Ve.model&&E(e=>({...e,[Ve.providerId]:Ve.model})),!n?.isConfigured){xe(n?.message??`The selected local CLI is unavailable. Install it and sign in, then try again.`,`error`),Ve.kickoff&&R({providerId:Ve.providerId,kickoff:Ve.kickoff,executionProfile:Ve.executionProfile});return}if(Ve.sessionId&&Ve.assistant){dt({id:Ve.sessionId,assistant:Ve.assistant,title:``,createdAt:``,updatedAt:``,messageCount:0},!0);return}we.current&&!window.confirm(`Stop the current chat and continue with the selected local CLI?`)||(we.current&&at(),Ve.kickoff?pt({providerId:Ve.providerId,kickoff:Ve.kickoff,executionProfile:Ve.executionProfile}):ot(Ve.providerId,{firstMessage:null}))},[xe,pt,Ve,dt,r.pathname,r.search,r.state,i,a,s,ot,at]);let mt=()=>{window.confirm(`Are you sure you want to clear this chat history? This also starts a new agent session.`)&&(we.current&&at(),Ce(e=>{let t={...e};return delete t[x],t}),je.current=!1,d([]),jN(e.branchName))},ht=_&&!y,gt=Ze?fP(Ze):null,_t=()=>{if(!Ze||!gt)return;let e=()=>xe(`Could not copy the recovery command. Copy the command shown above manually.`,`error`);QS(gt.command).then(t=>{if(!t){e();return}ce(Ze.id),setTimeout(()=>{Ie.current&&ce(e=>e===Ze.id?null:e)},1500)})},[vt,yt]=(0,V.useState)(!1),bt=j[x]?.id,xt=e=>{QS(e).then(()=>{yt(!0),setTimeout(()=>{Ie.current&&yt(!1)},1500)})};return(0,H.jsxs)(`div`,{className:`flex h-full flex-col bg-card`,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border bg-card px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,H.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Chat`}),(0,H.jsx)(Bv,{tone:h?`running`:`idle`,dot:!0,children:h?`${Ze?.name||`Connected`}${Ze&&T[Ze.id]?` (${mP(Ze,T[Ze.id])})`:``}`:`Disconnected`})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 flex-wrap justify-end`,children:[P&&(P.inputTokens>0||P.outputTokens>0)&&(0,H.jsxs)(`div`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-mono bg-muted/60 border border-border/60 text-muted-foreground shrink-0`,title:`Session Total: ${P.inputTokens.toLocaleString()} in${P.cachedInputTokens?` (${P.cachedInputTokens.toLocaleString()} cached)`:``} · ${P.outputTokens.toLocaleString()} out${P.costUsdEstimate===void 0?``:` · ~$${P.costUsdEstimate.toFixed(3)}`}`,children:[(0,H.jsx)(Di,{size:11,className:`text-amber-500 shrink-0`}),(0,H.jsx)(`span`,{children:ZN(P.totalTokens??P.inputTokens+P.outputTokens)})]}),I&&(0,H.jsx)(`div`,{className:B(`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-mono border shrink-0`,I.tokens?.status===`exceeded`||I.requests?.status===`exceeded`?`bg-destructive/10 border-destructive/30 text-destructive-foreground`:I.tokens?.status===`approaching_limit`||I.requests?.status===`approaching_limit`?`bg-amber-500/10 border-amber-500/30 text-amber-500`:`bg-muted/60 border-border/60 text-muted-foreground`),title:I.warningMessage||(I.tokens?.resetsAt?`Resets at ${new Date(I.tokens.resetsAt).toLocaleTimeString()}`:I.label),children:(0,H.jsx)(`span`,{children:QN(I)})}),bt&&(0,H.jsxs)(`button`,{onClick:()=>xt(bt),className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-mono bg-muted/60 hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer border border-border/60`,title:`Session ID: ${bt} (Click to copy)`,children:[(0,H.jsx)(Vr,{size:11,className:`opacity-60`}),(0,H.jsxs)(`span`,{children:[bt.slice(0,8),`...`]}),vt?(0,H.jsx)(wr,{size:11,className:`text-emerald-500`}):(0,H.jsx)(Mr,{size:11,className:`opacity-60`})]}),u.length>0&&(0,H.jsx)(`button`,{onClick:mt,className:`cursor-pointer text-xs text-muted-foreground transition-colors hover:text-destructive-foreground`,children:`Clear`}),(0,H.jsx)(`button`,{onClick:()=>{fe(null),ue(!0)},className:`grid h-7 w-7 cursor-pointer place-items-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:`Resume a past session`,children:(0,H.jsx)(ui,{size:14})}),(h||_||A)&&(0,H.jsxs)(yn,{size:`sm`,variant:`outline`,onClick:at,children:[(0,H.jsx)(vi,{size:14,className:`text-destructive-foreground`}),`Stop`]})]})]}),(0,H.jsx)(WN,{open:le,onClose:()=>ue(!1),ws:e,onPick:ft,error:de,pending:re}),(0,H.jsxs)(`div`,{ref:Te,onScroll:()=>{let e=Te.current;e&&(De.current=e.scrollHeight-e.scrollTop-e.clientHeight<80)},className:`flex-1 space-y-4 overflow-y-auto p-4`,children:[u.length===0&&!ht&&(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:`No messages yet. Start the agent and say hello.`}),u.map((e,t)=>(0,H.jsx)(_P,{msg:e,idx:t,copied:pe===t,onCopy:ct},t)),ht&&(0,H.jsx)(`div`,{className:`flex justify-start`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-lg border border-border bg-muted/30 px-4 py-2.5 text-xs text-muted-foreground shadow-xs animate-pulse`,children:[(0,H.jsx)(li,{size:13,className:`animate-spin text-primary`}),(0,H.jsxs)(`span`,{children:[Ze?.name||`Agent`,` is thinking and executing...`]})]})}),(0,H.jsx)(`div`,{ref:Ee})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-t border-border bg-card p-3`,children:[Ze&&!Ze.isConfigured&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-foreground`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(`span`,{className:`shrink-0 font-semibold`,children:[Ze.name,` provider status:`]}),(0,H.jsx)(`span`,{children:Ze.message})]}),gt&&(0,H.jsx)(`code`,{className:`w-fit rounded bg-background/70 px-2 py-1 font-mono text-[11px] text-foreground`,children:gt.command})]}),gt&&(0,H.jsxs)(yn,{size:`sm`,variant:`outline`,onClick:_t,className:`shrink-0`,children:[se===Ze.id?(0,H.jsx)(wr,{size:12}):(0,H.jsx)(Mr,{size:12}),se===Ze.id?`Copied`:gt.label]})]}),ae&&!A&&!h&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-warning/25 bg-warning/10 px-3 py-2 text-xs text-foreground`,children:[(0,H.jsxs)(`span`,{children:[`The workspace kickoff was not dispatched (`,ae.executionProfile===`workspace-write`?`Edit workspace`:`Review only`,`).`]}),(0,H.jsx)(yn,{size:`sm`,variant:`outline`,onClick:()=>void pt(ae,!0),disabled:re||oe,children:oe?`Checking CLI…`:`Recheck & retry`}),Ze?.setupIssue&&Ze.setupIssue!==`missing-cli`&&(0,H.jsx)(yn,{size:`sm`,variant:`outline`,onClick:()=>void pt(ae,!0,!0),disabled:re||oe,children:`Try with existing CLI auth`})]}),He.map(e=>(0,H.jsxs)(`div`,{role:`alert`,"aria-live":`polite`,className:`flex flex-col gap-2 rounded-xl border border-amber-500/40 bg-amber-500/10 p-3 text-xs shadow-xs animate-fade-in`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 font-semibold text-amber-500`,children:[(0,H.jsx)(mi,{size:14,className:`animate-pulse shrink-0`}),(0,H.jsx)(`span`,{children:`Tool Approval Required`}),(0,H.jsx)(lt,{variant:`outline`,className:`text-[10px] uppercase font-mono border-amber-500/40 text-amber-600 dark:text-amber-400`,children:e.tool}),e.description&&(0,H.jsxs)(`span`,{className:`text-[11px] font-normal text-muted-foreground italic`,children:[`(`,e.description,`)`]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,H.jsxs)(yn,{size:`sm`,variant:`default`,onClick:()=>Je(e.requestId,`allow`),className:`h-7 text-xs bg-emerald-600 hover:bg-emerald-700 text-white gap-1 cursor-pointer`,children:[(0,H.jsx)(wr,{size:12}),(0,H.jsx)(`span`,{children:`Approve`})]}),(0,H.jsxs)(yn,{size:`sm`,variant:`outline`,onClick:()=>Je(e.requestId,`deny`),className:`h-7 text-xs text-destructive hover:bg-destructive/10 border-border/80 gap-1 cursor-pointer`,children:[(0,H.jsx)(Ei,{size:12}),(0,H.jsx)(`span`,{children:`Deny`})]})]})]}),e.input&&(0,H.jsx)(`div`,{className:`rounded-md bg-background/80 p-2 font-mono text-[11px] text-foreground overflow-x-auto max-h-24 select-text`,children:typeof e.input.command==`string`?`Command: ${e.input.command}`:typeof e.input.path==`string`?`File: ${e.input.path}`:JSON.stringify(e.input,null,2)})]},e.requestId)),(0,H.jsxs)(`div`,{className:`flex w-full flex-col rounded-xl border border-border bg-card shadow-sm`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-1.5 border-b border-border/50 bg-muted/20 px-3 py-2 text-xs`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,H.jsxs)(qa,{children:[(0,H.jsxs)(Ja,{"aria-label":`Select Provider`,disabled:_||A||re,className:`flex cursor-pointer items-center gap-1.5 rounded-md border border-border/60 bg-background/90 px-2.5 py-1 text-xs font-medium text-foreground shadow-2xs transition-colors hover:bg-accent hover:border-border disabled:pointer-events-none disabled:opacity-50`,children:[Ze?.icon===`Bot`?(0,H.jsx)(Sr,{size:13,className:`text-primary`}):(0,H.jsx)(Nr,{size:13,className:`text-primary`}),(0,H.jsx)(`span`,{children:Ze?.name??`Select Agent`}),(0,H.jsx)(bn,{size:11,className:`opacity-50 ml-0.5`})]}),(0,H.jsx)(Ya,{align:`start`,side:`top`,children:a.filter(e=>e.isConfigured||e.setupIssue!==`missing-cli`).map(e=>(0,H.jsxs)(Xa,{onClick:()=>et(e.id),className:B(`flex items-center gap-2 text-xs cursor-pointer`,e.id===Xe&&`font-semibold text-primary`),children:[e.icon===`Bot`?(0,H.jsx)(Sr,{size:14}):(0,H.jsx)(Nr,{size:14}),(0,H.jsx)(`span`,{className:`flex-1`,children:e.name}),e.id===Xe&&(0,H.jsx)(wr,{size:12,className:`text-primary ml-auto`})]},e.id))})]}),Ze?.models?.length&&(0,H.jsxs)(qa,{children:[(0,H.jsxs)(Ja,{"aria-label":`Select model`,disabled:h||A||_||re||!!ae,className:`flex cursor-pointer items-center gap-1.5 rounded-md border border-border/60 bg-background/90 px-2.5 py-1 text-xs font-medium text-foreground shadow-2xs transition-colors hover:bg-accent hover:border-border disabled:pointer-events-none disabled:opacity-50`,children:[(0,H.jsx)(hi,{size:12,className:`text-amber-500 shrink-0`}),(0,H.jsx)(`span`,{className:`max-w-44 truncate`,children:mP(Ze,T[Ze.id]??``)}),(0,H.jsx)(bn,{size:11,className:`opacity-50 ml-0.5`})]}),(0,H.jsx)(Ya,{align:`start`,side:`top`,className:`max-w-80`,children:Ze.models.map(e=>(0,H.jsx)(Xa,{onClick:()=>E(t=>({...t,[Ze.id]:e.id})),children:(0,H.jsxs)(`span`,{className:`flex flex-col`,children:[(0,H.jsxs)(`span`,{className:`font-medium flex items-center gap-1.5`,children:[(0,H.jsx)(hi,{size:11,className:`text-amber-500`}),e.label]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.description})]})},e.id))})]}),Ze?.executionProfiles?.length&&Qe&&(0,H.jsxs)(qa,{children:[(0,H.jsxs)(Ja,{"aria-label":`Select execution profile`,disabled:A||_||re||!!ae,className:`flex cursor-pointer items-center gap-1.5 rounded-md border border-border/60 bg-background/90 px-2.5 py-1 text-xs font-medium text-foreground shadow-2xs transition-colors hover:bg-accent hover:border-border disabled:pointer-events-none disabled:opacity-50`,title:Qe.description,children:[(0,H.jsx)(mi,{size:12,className:Qe.id===`workspace-write`?`text-amber-500 shrink-0`:`text-emerald-500 shrink-0`}),(0,H.jsx)(`span`,{children:pP(Qe.label)}),(0,H.jsx)(bn,{size:11,className:`opacity-50 ml-0.5`})]}),(0,H.jsx)(Ya,{align:`start`,side:`top`,className:`max-w-80`,children:Ze.executionProfiles.map(e=>(0,H.jsx)(Xa,{onClick:()=>w(t=>({...t,[Ze.id]:e.id})),children:(0,H.jsxs)(`span`,{className:`flex flex-col`,children:[(0,H.jsxs)(`span`,{className:`font-medium flex items-center gap-1.5`,children:[(0,H.jsx)(mi,{size:12,className:e.id===`workspace-write`?`text-amber-500`:`text-emerald-500`}),e.label]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.description})]})},e.id))})]}),Ze&&(0,H.jsxs)(qa,{children:[(0,H.jsxs)(Ja,{"aria-label":`Select reasoning effort`,disabled:h||A||_||re||!!ae,className:`flex cursor-pointer items-center gap-1.5 rounded-md border border-border/60 bg-background/90 px-2.5 py-1 text-xs font-medium text-foreground shadow-2xs transition-colors hover:bg-accent hover:border-border disabled:pointer-events-none disabled:opacity-50`,children:[(0,H.jsx)(Di,{size:12,className:D[Ze.id]?`text-amber-500 fill-amber-500/20 shrink-0`:`text-muted-foreground shrink-0`}),(0,H.jsx)(`span`,{children:eP(D[Ze.id]??``)}),(0,H.jsx)(bn,{size:11,className:`opacity-50 ml-0.5`})]}),(0,H.jsx)(Ya,{align:`start`,side:`top`,className:`max-w-72`,children:$N.map(e=>(0,H.jsx)(Xa,{onClick:()=>ee(t=>({...t,[Ze.id]:e.id})),children:(0,H.jsxs)(`span`,{className:`flex flex-col`,children:[(0,H.jsxs)(`span`,{className:`font-medium flex items-center gap-1.5`,children:[e.id&&(0,H.jsx)(Di,{size:12,className:`text-amber-500`}),e.label]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.description})]})},e.id))})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,H.jsx)(`input`,{type:`file`,ref:ye,accept:`image/png,image/jpeg,image/gif,image/webp`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files?.length&&Se(e.target.files),e.target.value=``}}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>ye.current?.click(),disabled:_||re,className:`flex cursor-pointer items-center justify-center rounded-md border border-border/60 bg-background/90 p-1.5 text-muted-foreground shadow-2xs transition-colors hover:bg-accent hover:text-foreground hover:border-border disabled:pointer-events-none disabled:opacity-50`,title:`Attach image (or paste / drop into chat)`,children:(0,H.jsx)(Hr,{size:14,className:`text-primary`})})]})]}),he.length>0&&(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2 border-b border-border/40 px-3 py-2 bg-muted/20`,children:he.map(e=>(0,H.jsxs)(`div`,{className:`group relative flex items-center rounded-lg border border-border/80 bg-card p-1 shadow-xs`,children:[(0,H.jsx)(`img`,{src:e.dataUrl,alt:e.name,className:`h-14 w-14 rounded-md object-cover`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>ge(t=>t.filter(t=>t.id!==e.id)),className:`absolute -top-1.5 -right-1.5 flex h-4 w-4 cursor-pointer items-center justify-center rounded-full bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90 transition-colors`,title:`Remove image`,children:(0,H.jsx)(Ei,{size:10})})]},e.id))}),(0,H.jsxs)(`div`,{className:B(`flex items-end gap-2 p-2`,_e&&`ring-2 ring-primary ring-inset rounded-b-xl bg-accent/30`),onDragOver:e=>{e.preventDefault(),ve(!0)},onDragLeave:()=>ve(!1),onDrop:e=>{e.preventDefault(),ve(!1),e.dataTransfer?.files?.length&&Se(e.dataTransfer.files)},children:[(0,H.jsx)(bN,{value:f,disabled:re,onPaste:e=>{if(e.clipboardData?.getData(`text/plain`))return;let t=$S(e.clipboardData?.getData(`text/html`)??``);if(t.trim()){e.preventDefault();let n=e.currentTarget,r=n.selectionStart,i=n.selectionEnd;p(e=>`${e.slice(0,r)}${t}${e.slice(i)}`),requestAnimationFrame(()=>{n.focus();let e=r+t.length;n.setSelectionRange(e,e)});return}let n=e.clipboardData?.items,r=[];if(n){for(let e=0;e<n.length;e++)if(n[e].type.startsWith(`image/`)){let t=n[e].getAsFile();t&&r.push(t)}}if(r.length===0&&e.clipboardData?.files?.length)for(let t of Array.from(e.clipboardData.files))t.type.startsWith(`image/`)&&r.push(t);r.length>0&&(e.preventDefault(),Se(r))},onChange:e=>{p(e.target.value);let t=e.target;t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`},onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),_||A||ze.current)return;h?st():$e&&(f.trim()||he.length?st():ot());let t=e.currentTarget;t.style.height=`auto`}},placeholder:h?`Message the agent... (Shift+Enter for new line)`:`Start the agent or press Enter...`,unstyled:!0,className:`flex-1 [&_[data-slot=textarea]]:max-h-[200px] [&_[data-slot=textarea]]:min-h-11 [&_[data-slot=textarea]]:resize-none [&_[data-slot=textarea]]:text-sm`,rows:1}),h?(0,H.jsxs)(yn,{className:`h-11 shrink-0 rounded-lg`,onClick:st,disabled:!f.trim()&&he.length===0||_||re,children:[_?(0,H.jsx)(li,{size:14,className:`animate-spin`}):(0,H.jsx)(fi,{size:14}),`Send`]}):(0,H.jsxs)(yn,{className:`h-11 shrink-0 rounded-lg`,onClick:()=>{f.trim()||he.length?st():ot()},disabled:!$e,children:[(0,H.jsx)(gi,{size:14}),`Start`]})]})]})]})]})}function yP({workspace:e,active:t}){let n=jt(t?e:null),r=Yt(e);if(!n.data?.services.length)return null;let i=n.data.runningState.length;return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[i?(0,H.jsxs)(`span`,{className:`text-[10px] text-emerald-600`,title:`${i} running service${i===1?``:`s`}`,children:[i,` running`]}):(0,H.jsxs)(yn,{size:`xs`,variant:`ghost`,disabled:r.isPending,onClick:()=>r.mutate({action:`start`}),children:[(0,H.jsx)(oi,{className:`size-3`}),`Start services`]}),r.isError&&(0,H.jsx)(`span`,{role:`alert`,className:`max-w-32 truncate text-[10px] text-destructive`,title:r.error.message,children:`Could not start services`})]})}function bP({visible:e,...t}){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{e&&r(!0)},[e]),(0,H.jsx)(`div`,{className:B(`min-h-0 flex-1`,!e&&`hidden`),children:(n||e)&&(0,H.jsx)(vP,{...t})})}function xP({workspaces:e}){let t=Lt(),{isOpen:n,isMinimized:r,isMaximized:i,openTabs:a,activeTab:o,splitTab:s,splitRatio:c,position:l,size:u,close:d,minimize:f,restore:p,toggleMaximize:m,addTab:h,removeTab:g,setActiveTab:_,setSplitTab:v,setSplitRatio:y,setPosition:b,setSize:x,drafts:S,consumeDraft:C,modes:w,setMode:T,terminalLaunches:E,consumeTerminalLaunch:D,harnesses:ee}=Mt(),[O,k]=(0,V.useState)(``),[A,te]=(0,V.useState)({}),[j,M]=(0,V.useState)({}),N=(0,V.useRef)(null),ne=(0,V.useRef)(null),re=(0,V.useRef)(null),ie=(0,V.useRef)(null),P=(0,V.useRef)(!1),[F,I]=(0,V.useState)(()=>window.innerWidth>=900);(0,V.useEffect)(()=>{let e=()=>I(window.innerWidth>=900);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let L=!!(s&&o&&s!==o&&F&&i);(0,V.useEffect)(()=>{if(!n||r)return;let e=[o,L?s:null].filter(e=>!!e);M(t=>{if(!e.some(e=>t[e]&&w[e]!==`chat`))return t;let n={...t};for(let t of e)w[t]!==`chat`&&(n[t]=!1);return n})},[n,r,o,s,L,w]);let ae=(0,V.useCallback)(e=>{if(!P.current||!ie.current)return;let t=ie.current.getBoundingClientRect();y((e.clientX-t.left)/t.width*100)},[y]),R=(0,V.useMemo)(()=>new Map(e.map(e=>[e.branchName,e])),[e]),oe=o?R.get(o):void 0,z=(0,V.useMemo)(()=>{let t=O.trim().toLowerCase();return t?e.filter(e=>e.branchName.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)):e},[e,O]),se=(0,V.useCallback)(e=>{if(e.button!==0||i)return;let t=e.target;if(t.closest(`button`)||t.closest(`[role="tab"]`)||t.closest(`[data-no-drag]`))return;let n=l||{x:Math.max(20,window.innerWidth-u.width-24),y:Math.max(20,window.innerHeight-u.height-24)};N.current={startX:e.clientX,startY:e.clientY,startPosX:n.x,startPosY:n.y},e.currentTarget.setPointerCapture(e.pointerId)},[i,l,u]),ce=(0,V.useCallback)(e=>{if(!N.current)return;let t=e.clientX-N.current.startX,n=e.clientY-N.current.startY,r=Math.max(0,window.innerWidth-u.width-20),i=Math.max(0,window.innerHeight-u.height-20),a=Math.min(Math.max(10,N.current.startPosX+t),r),o=Math.min(Math.max(10,N.current.startPosY+n),i);b({x:a,y:o})},[u,b]),le=(0,V.useCallback)(e=>{if(N.current){N.current=null;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}},[]),ue=(0,V.useCallback)(e=>{e.button!==0||i||(e.stopPropagation(),e.preventDefault(),ne.current={startX:e.clientX,startY:e.clientY,startW:u.width,startH:u.height},e.currentTarget.setPointerCapture(e.pointerId))},[i,u]),de=(0,V.useCallback)(e=>{if(!ne.current)return;let t=e.clientX-ne.current.startX,n=e.clientY-ne.current.startY,r=Math.max(380,Math.min(ne.current.startW+t,window.innerWidth-40)),i=Math.max(420,Math.min(ne.current.startH+n,window.innerHeight-40));x({width:r,height:i})},[x]),fe=(0,V.useCallback)(e=>{if(ne.current){ne.current=null;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}},[]),pe=(0,V.useMemo)(()=>{if(!i)return l?{left:`${l.x}px`,top:`${l.y}px`,width:`${u.width}px`,height:`${u.height}px`}:{right:`24px`,bottom:`24px`,width:`${u.width}px`,height:`${u.height}px`}},[i,l,u]);return(0,H.jsxs)(H.Fragment,{children:[n&&r&&(0,H.jsx)(`div`,{className:`fixed bottom-5 right-6 z-50 animate-fade-in`,children:(0,H.jsxs)(`button`,{onClick:p,className:`flex items-center gap-2.5 px-4 py-2.5 rounded-full bg-card/95 backdrop-blur-md border border-border shadow-xl hover:border-primary/50 text-foreground transition-all duration-200 cursor-pointer group`,title:`Restore floating workspace chat`,children:[(0,H.jsx)(`div`,{className:`size-7 rounded-full bg-primary/10 grid place-items-center text-primary group-hover:scale-105 transition-transform`,children:(0,H.jsx)(Zr,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`flex flex-col items-start text-left`,children:[(0,H.jsxs)(`span`,{className:`text-xs font-semibold leading-tight flex items-center gap-1.5`,children:[`Workspace Chat`,a.length>0&&(0,H.jsx)(`span`,{className:`px-1.5 py-0.2 rounded-full bg-primary/20 text-primary text-[10px] font-bold`,children:a.length})]}),(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground leading-tight max-w-[140px] truncate`,children:oe?.branchName||`No active tab`})]}),(0,H.jsx)(Jr,{className:`size-3.5 text-muted-foreground group-hover:text-foreground ml-1`})]})}),(0,H.jsxs)(`div`,{ref:re,style:{...pe,display:!n||r?`none`:void 0},role:`region`,"aria-label":`Workspace Chat`,className:B(`fixed z-50 flex flex-col overflow-hidden bg-card/98 backdrop-blur-xl border border-border/80 shadow-2xl rounded-2xl transition-[border-color] duration-150`,i&&`inset-0 w-auto h-auto rounded-none`),children:[(0,H.jsxs)(`div`,{onPointerDown:se,onPointerMove:ce,onPointerUp:le,className:B(`flex items-center justify-between px-3 py-2 border-b border-border/80 bg-muted/40 select-none shrink-0`,!i&&`cursor-grab active:cursor-grabbing`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 pr-2`,children:[!i&&(0,H.jsx)(Br,{className:`size-4 text-muted-foreground/50 shrink-0`}),(0,H.jsx)(`div`,{className:`size-5 rounded-md bg-primary/15 grid place-items-center text-primary shrink-0`,children:(0,H.jsx)(Zr,{className:`size-3.5`})}),(0,H.jsx)(`span`,{className:`text-xs font-bold text-foreground shrink-0`,children:`ContextSpace`}),(0,H.jsx)(`span`,{className:`text-muted-foreground/70`,"aria-hidden":`true`,children:`/`}),(0,H.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-xs font-semibold text-primary shrink-0`,children:`Chat & CLI`}),oe&&(0,H.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:oe.branchName,children:oe.branchName})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,"data-no-drag":!0,children:[(0,H.jsx)(`button`,{onClick:f,className:`p-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-colors cursor-pointer`,title:`Minimize`,"aria-label":`Minimize floating chat`,children:(0,H.jsx)($r,{className:`size-3.5`})}),(0,H.jsx)(`button`,{onClick:m,className:`p-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-colors cursor-pointer`,title:i?`Restore down`:`Maximize`,"aria-label":i?`Restore down floating chat`:`Maximize floating chat`,children:i?(0,H.jsx)(Qr,{className:`size-3.5`}):(0,H.jsx)(Jr,{className:`size-3.5`})}),(0,H.jsx)(`button`,{onClick:d,className:`p-1.5 rounded-lg text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors cursor-pointer`,title:`Close`,"aria-label":`Close floating chat`,children:(0,H.jsx)(Ei,{className:`size-3.5`})})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 px-2.5 py-1.5 border-b border-border/60 bg-muted/20 overflow-x-auto no-scrollbar shrink-0`,"data-no-drag":!0,children:[a.map(e=>{let t=e===o;return(0,H.jsxs)(`div`,{className:B(`group flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-medium transition-all duration-150 cursor-pointer border shrink-0 max-w-[170px]`,t||s===e?`bg-card border-border shadow-xs text-foreground font-semibold`:`border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/50`),children:[(0,H.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t||s===e,"aria-label":`Show ${e} in the left pane`,title:e,className:`flex min-w-0 items-center gap-1.5`,onClick:()=>_(e),children:[(0,H.jsx)(Ut,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`truncate`,children:e}),w[e]!==`chat`&&ee[e]&&(0,H.jsx)(`span`,{title:eN(ee[e]),children:(0,H.jsx)(tN,{harness:ee[e],className:`size-3`})}),A[e]&&A[e]!==`idle`&&(0,H.jsx)(`span`,{title:`Terminal ${A[e]}`,className:B(`size-1.5 shrink-0 rounded-full`,A[e]===`running`?`bg-emerald-500`:A[e]===`disconnected`?`bg-amber-500`:`bg-muted-foreground`)}),j[e]&&(0,H.jsx)(`span`,{title:`New terminal output`,className:`size-1.5 shrink-0 rounded-full bg-primary`})]}),(0,H.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),g(e)},className:`size-3.5 rounded grid place-items-center text-muted-foreground/60 hover:text-destructive hover:bg-destructive/10 opacity-70 group-hover:opacity-100 focus-visible:opacity-100 transition-opacity ml-0.5`,title:`Close ${e} tab`,"aria-label":`Close ${e} tab`,children:(0,H.jsx)(Ei,{className:`size-2.5`})})]},e)}),(0,H.jsxs)(qa,{children:[(0,H.jsxs)(Ja,{className:`flex items-center gap-1 px-2 py-1 rounded-lg text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 border border-dashed border-border/70 hover:border-border transition-colors cursor-pointer shrink-0`,children:[(0,H.jsx)(ci,{className:`size-3`}),(0,H.jsx)(`span`,{children:`Add Workspace`})]}),(0,H.jsxs)(Ya,{align:`start`,className:`w-64 p-1.5`,children:[(0,H.jsxs)(Xa,{onClick:()=>{f(),t(`/new?from=chat`)},className:`flex items-center gap-2 px-2 py-1.5 text-xs font-semibold`,children:[(0,H.jsx)(ci,{className:`size-3`}),`New workspace`]}),(0,H.jsx)(`p`,{className:`border-t border-border px-2 pt-2 text-[10px] text-muted-foreground`,children:`Open existing`}),(0,H.jsx)(`div`,{className:`px-2 py-1 mb-1`,children:(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(Ct,{className:`size-3.5 absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground`}),(0,H.jsx)(`input`,{type:`text`,placeholder:`Search workspaces...`,value:O,onChange:e=>k(e.target.value),className:`w-full pl-7 pr-2 py-1 text-xs rounded-md bg-muted/50 border border-border focus:outline-hidden focus:border-primary/50 text-foreground placeholder:text-muted-foreground`,autoFocus:!0})]})}),(0,H.jsx)(`div`,{className:`max-h-56 overflow-y-auto space-y-0.5`,children:z.length===0?(0,H.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No workspaces found`}):z.map(e=>{let t=a.includes(e.branchName);return(0,H.jsxs)(Xa,{onClick:()=>{t?_(e.branchName):h(e.branchName),k(``)},className:B(`flex items-center gap-2 px-2 py-1.5 text-xs rounded-md cursor-pointer`,e.branchName===o&&`bg-accent/70 font-semibold`),children:[(0,H.jsx)(Ut,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.branchName}),e.description&&(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate`,children:e.description})]}),t&&(0,H.jsx)(`span`,{className:`text-[10px] text-primary font-medium px-1.5 py-0.5 rounded bg-primary/10`,children:`Open`})]},e.branchName)})})]})]}),o&&(0,H.jsxs)(qa,{children:[(0,H.jsxs)(Ja,{className:`flex items-center gap-1 px-2 py-1 rounded-lg text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 border border-border/70 cursor-pointer shrink-0`,children:[(0,H.jsx)(jr,{className:`size-3`}),(0,H.jsx)(`span`,{children:s?`Split view`:`Split right`})]}),(0,H.jsxs)(Ya,{align:`start`,className:`w-56 max-h-72 overflow-y-auto p-1.5`,children:[s&&(0,H.jsx)(Xa,{onClick:()=>v(null),className:`text-xs`,children:`Close split`}),e.filter(e=>e.branchName!==o).map(e=>(0,H.jsxs)(Xa,{onClick:()=>v(e.branchName),className:`flex items-center gap-2 text-xs`,children:[(0,H.jsx)(Ut,{className:`size-3`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.branchName}),s===e.branchName&&(0,H.jsx)(`span`,{className:`ml-auto text-primary`,children:`Right`})]},e.branchName)),e.length<2&&(0,H.jsx)(`p`,{className:`p-2 text-xs text-muted-foreground`,children:`Open another workspace to split the view.`})]})]})]}),s&&(!F||!i)&&(0,H.jsx)(`p`,{className:`border-b border-border px-3 py-1 text-xs text-muted-foreground`,children:`Split view is paused. Maximize the window on a wide screen to resume it.`}),(0,H.jsxs)(`div`,{ref:ie,className:`flex flex-1 min-h-0 relative overflow-hidden bg-card`,"data-no-drag":!0,children:[a.length===0?(0,H.jsxs)(`div`,{className:`h-full w-full flex flex-col items-center justify-center p-6 text-center text-muted-foreground gap-3`,children:[(0,H.jsx)(`div`,{className:`size-12 rounded-2xl bg-muted/50 border border-border grid place-items-center text-muted-foreground`,children:(0,H.jsx)(Xr,{className:`size-6 text-primary`})}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`No Workspace Tab Open`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs`,children:`Select a workspace to run a CLI harness or open your existing chat.`})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-1.5 mt-2 max-w-sm`,children:[e.slice(0,5).map(e=>(0,H.jsxs)(yn,{variant:`outline`,size:`sm`,onClick:()=>h(e.branchName),className:`text-xs h-7 gap-1.5`,children:[(0,H.jsx)(Ut,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:e.branchName})]},e.branchName)),(0,H.jsxs)(yn,{variant:`outline`,size:`sm`,onClick:()=>{f(),t(`/new?from=chat`)},className:`text-xs h-7 gap-1.5`,children:[(0,H.jsx)(ci,{className:`size-3`}),`New workspace`]})]})]}):a.map(e=>{let t=R.get(e),i=e===o,a=L&&e===s,l=i||a;return(0,H.jsxs)(`div`,{className:B(`h-full min-w-0 flex-col`,l?`flex`:`hidden`,a&&`border-l border-border`),style:l?{order:i?1:3,flex:L?i?`0 0 ${c}%`:`1 1 0%`:`1 1 100%`}:void 0,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border px-3 py-1`,"data-no-drag":!0,children:[(0,H.jsx)(`span`,{className:`max-w-[32%] truncate text-[10px] font-semibold`,title:e,children:e}),(0,H.jsxs)(yn,{size:`xs`,variant:(w[e]??`cli`)===`cli`?`secondary`:`ghost`,"aria-pressed":(w[e]??`cli`)===`cli`,onClick:()=>T(e,`cli`),children:[(0,H.jsx)(_i,{className:`size-3`}),`CLI`]}),(0,H.jsxs)(yn,{size:`xs`,variant:w[e]===`chat`?`secondary`:`ghost`,"aria-pressed":w[e]===`chat`,onClick:()=>T(e,`chat`),children:[(0,H.jsx)(Xr,{className:`size-3`}),`Chat`]}),t&&(0,H.jsx)(yP,{workspace:e,active:l&&n&&!r}),a&&(0,H.jsx)(yn,{size:`xs`,variant:`ghost`,"aria-label":`Close split view`,onClick:()=>v(null),children:(0,H.jsx)(Ei,{className:`size-3`})})]}),t?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:B(`flex-1 min-h-0`,w[e]===`chat`&&`hidden`),children:(0,H.jsx)(yN,{workspace:e,workspacePath:t.workspacePath,active:n&&!r&&l&&w[e]!==`chat`,launch:E[e],consumeLaunch:t=>D(e,t),onStatusChange:t=>te(n=>n[e]===t?n:{...n,[e]:t}),onBackgroundOutput:()=>M(t=>t[e]?t:{...t,[e]:!0})})}),(0,H.jsx)(bP,{visible:w[e]===`chat`,ws:t,draft:S[e],onDraftConsumed:t=>C(e,t)})]}):(0,H.jsxs)(`div`,{role:`status`,className:`space-y-2 p-4 text-xs text-muted-foreground`,children:[(0,H.jsx)(`p`,{children:`This workspace is unavailable. It may have been removed or is still loading.`}),(0,H.jsx)(yn,{size:`xs`,variant:`outline`,onClick:()=>g(e),children:`Close unavailable tab`})]})]},e)}),L&&(0,H.jsx)(`div`,{role:`separator`,"aria-label":`Resize workspace panes`,"aria-orientation":`vertical`,"aria-valuemin":25,"aria-valuemax":75,"aria-valuenow":Math.round(c),tabIndex:0,className:`order-2 z-10 w-1.5 shrink-0 cursor-col-resize bg-border/70 hover:bg-primary/40 focus-visible:bg-primary/40`,onPointerDown:e=>{P.current=!0,e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:ae,onPointerUp:e=>{P.current=!1,e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:()=>{P.current=!1},onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),y(c+(e.key===`ArrowRight`?5:-5)))}})]}),!i&&(0,H.jsx)(`div`,{onPointerDown:ue,onPointerMove:de,onPointerUp:fe,className:`absolute bottom-0 right-0 size-4 cursor-nwse-resize z-10 grid place-items-center opacity-30 hover:opacity-100 transition-opacity`,title:`Drag to resize`,children:(0,H.jsx)(`div`,{className:`size-2 border-r-2 border-b-2 border-muted-foreground rounded-br-xs`})})]})]})}function SP(){let{isOpen:e,isMinimized:t,openTabs:n,open:r}=Mt();return e&&!t||t?null:(0,H.jsx)(`div`,{className:`fixed bottom-6 right-6 z-40 animate-fade-in`,children:(0,H.jsxs)(`button`,{onClick:()=>r(),className:B(`group relative flex items-center justify-center gap-2 h-11 px-4 rounded-full`,`bg-primary text-primary-foreground shadow-lg shadow-primary/25`,`hover:scale-105 hover:shadow-xl hover:shadow-primary/35 active:scale-95`,`transition-all duration-200 cursor-pointer border border-primary/20`),title:`Open Floating Workspace Chat`,"aria-label":`Open Floating Workspace Chat`,children:[(0,H.jsx)(Zr,{className:`size-4`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`text-xs font-medium`,children:`Chat & CLI`}),n.length>0&&(0,H.jsx)(`span`,{className:`absolute -top-1 -right-1 size-5 rounded-full bg-emerald-500 text-white text-[10px] font-bold grid place-items-center shadow-md border-2 border-background`,children:n.length})]})})}function CP({workspaceName:e,open:t,onClose:n,onConfirm:r,loading:i=!1}){let[a,o]=(0,V.useState)(``);if(!e)return null;let s=a.trim()===e.trim(),c=()=>{o(``),n()},l=async()=>{!s||i||(await r(e),o(``))};return(0,H.jsx)(Ov,{open:t,onOpenChange:e=>!e&&c(),children:(0,H.jsxs)(Mv,{className:`max-w-md`,children:[(0,H.jsxs)(Nv,{children:[(0,H.jsx)(Fv,{className:`text-destructive`,children:`Delete workspace`}),(0,H.jsxs)(Iv,{children:[`This action cannot be undone. This will force-remove all git worktrees and delete the entire folder for`,` `,(0,H.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),`.`]})]}),(0,H.jsx)(Lv,{className:`space-y-4`,children:(0,H.jsxs)(`label`,{className:`block`,children:[(0,H.jsxs)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:[`Please type `,(0,H.jsx)(`strong`,{className:`font-mono text-foreground`,children:e}),` to confirm:`]}),(0,H.jsx)(Ye,{value:a,onChange:e=>o(e.target.value),placeholder:e,autoFocus:!0,className:`font-mono text-sm`,onKeyDown:e=>{e.key===`Enter`&&s&&!i&&l()}})]})}),(0,H.jsxs)(Pv,{children:[(0,H.jsx)(yn,{variant:`outline`,onClick:c,disabled:i,children:`Cancel`}),(0,H.jsx)(yn,{variant:`destructive`,onClick:()=>void l(),disabled:!s||i,children:i?`Deleting…`:`Delete workspace`})]})]})})}var wP=(0,V.lazy)(()=>Kn(()=>import(`./DashboardPage-BwwB7uTm.js`).then(e=>({default:e.DashboardPage})),__vite__mapDeps([6,1,2,7,8,3,4,9,10,11,12]))),TP=(0,V.lazy)(()=>Kn(()=>import(`./ProjectsPage-CNZF11wO.js`).then(e=>({default:e.ProjectsPage})),__vite__mapDeps([13,1,2,14,8,7,3,4,9,10,15,16,17,18,19]))),EP=(0,V.lazy)(()=>Kn(()=>import(`./SettingsPage-S68Q-rBG.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([20,1,2,14,8,16,17,12,21,22]))),DP=(0,V.lazy)(()=>Kn(()=>import(`./SkillsPage-B97Al8vk.js`).then(e=>({default:e.SkillsPage})),__vite__mapDeps([23,1,2,14,8,7,3,4,9,10,24,25,26,18,12,21]))),OP=(0,V.lazy)(()=>Kn(()=>import(`./AgentsPage-B9ejJYsf.js`).then(e=>({default:e.AgentsPage})),__vite__mapDeps([27,1,2,14,8,7,3,4,9,10,18,19,12,21]))),kP=(0,V.lazy)(()=>Kn(()=>import(`./WorkroomsPage-uCiHE87E.js`).then(e=>({default:e.WorkroomsPage})),__vite__mapDeps([28,1,2,14,8,26,18,29,30,16,9,10,12,21,22]))),AP=(0,V.lazy)(()=>Kn(()=>import(`./StartWorkPage-Dq0Ke4hS.js`).then(e=>({default:e.StartWorkPage})),__vite__mapDeps([31,1,2,14,8,7,3,4,9,10,24,11,15,16,17,32]))),jP=(0,V.lazy)(()=>Kn(()=>import(`./StrategiesPage-INv0HW7D.js`).then(e=>({default:e.StrategiesPage})),__vite__mapDeps([33,1,2,14,8,34,18,12,21]))),MP=(0,V.lazy)(()=>Kn(()=>import(`./WorkspacesPage-CAHQrIgk.js`).then(e=>({default:e.WorkspacesPage})),__vite__mapDeps([35,1,2,14,8,7,3,4,9,10,24,30,16,25,11,26,32,18,29,5,12,21]))),NP=(0,V.lazy)(()=>Kn(()=>import(`./GettingStartedPage-BM8m5uir.js`).then(e=>({default:e.GettingStartedPage})),__vite__mapDeps([36,2,1,8,34,9]))),PP=new URLSearchParams(window.location.search).get(`env`)===`vscode`,FP=typeof window<`u`?window.contextspaceBridge?.updates||window.nexusBridge?.updates:void 0,IP=0;function LP(){let e=Lt(),t=Ft(),[n,r]=(0,V.useState)([]),i=(e,t=`info`,n=5e3)=>{let i=`toast-${++IP}`;r(r=>[...r,{id:i,message:e,type:t,duration:n}]),setTimeout(()=>{r(e=>e.filter(e=>e.id!==i))},n)},[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!0),[l,u]=(0,V.useState)(!0),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)([]),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(``),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(!1),[C,w]=(0,V.useState)(null),T=Tt(),E=Qt(),D=Kt(),ee=At(),O=T.data??[],k=E.data??[],A=D.data??[],te=ee.data??[],[j,M]=(0,V.useState)(!1),[N,ne]=(0,V.useState)(`idle`),[re,ie]=(0,V.useState)(null),[P,F]=(0,V.useState)(null),[I,L]=(0,V.useState)(!1),[ae,R]=(0,V.useState)(``),[oe,z]=(0,V.useState)(``),[se,ce]=(0,V.useState)(null),[le,ue]=(0,V.useState)(!1),[de,fe]=(0,V.useState)(!1),[pe,me]=(0,V.useState)(!1),[he,ge]=(0,V.useState)(`antigravity`),_e=(0,V.useRef)(!1);(0,V.useEffect)(()=>{if(_e.current||!E.data)return;let e=E.data.find(e=>e.detected&&e.command);e&&(_e.current=!0,ge(e.name))},[E.data]);let[ve,ye]=(0,V.useState)(null),[be,xe]=(0,V.useState)(``),Se=[`/`,`/overview`,`/dashboard`].includes(t.pathname)||t.pathname.startsWith(`/workspaces`),Ce=cn(),we=wt(),Te=Nt({enabled:l&&!s,intervalMs:Se?15e3:!1}),Ee=we.data??[],De=we.isLoading,Oe=Te.data??{},[ke,Ae]=(0,V.useState)(null),[je,Me]=(0,V.useState)(`overview`),[Ne,Pe]=(0,V.useState)([]),[Fe,Ie]=(0,V.useState)(!1),[Le,Re]=(0,V.useState)(null),[ze,Be]=(0,V.useState)([]),[Ve,He]=(0,V.useState)(!1),[Ue,We]=(0,V.useState)([]),[Ge,Ke]=(0,V.useState)(!1),[qe,Je]=(0,V.useState)(``),[Ye,Xe]=(0,V.useState)(!1),[Ze,Qe]=(0,V.useState)(null),[$e,et]=(0,V.useState)(!1),[tt,nt]=(0,V.useState)(``),[rt,it]=(0,V.useState)(!1),[at,ot]=(0,V.useState)(null),[st,ct]=(0,V.useState)(``),[lt,ut]=(0,V.useState)(!1),[dt,ft]=(0,V.useState)(null),pt=(0,V.useRef)(null),mt=(0,V.useRef)(0),ht=(0,V.useRef)(0),gt=(0,V.useRef)(0),_t=(0,V.useRef)(``),vt=(0,V.useRef)(!1),[yt,bt]=(0,V.useState)(!1),[xt,St]=(0,V.useState)(null),[Ct,Et]=(0,V.useState)(``),[Dt,kt]=(0,V.useState)(!1),[jt,Mt]=(0,V.useState)(!1),[Pt,Rt]=(0,V.useState)(null),[zt,Bt]=(0,V.useState)(null),[Vt,Ht]=(0,V.useState)(!1),Ut=e=>{_t.current=e,nt(e)},Wt=e=>{vt.current=e,et(e)},[Gt,qt]=(0,V.useState)([]),[Jt,Yt]=(0,V.useState)(!1),[Xt,Zt]=(0,V.useState)(null),$t=!(!a||!a.devDir||a.devDir.trim()===``||!a.workspacesDir||a.workspacesDir.trim()===``),en=e=>{let t=[`available`,`downloading`,`downloaded`,`error`].includes(e.status)&&!!e.version;g({currentVersion:e.currentVersion,latestVersion:e.version||e.currentVersion,updateAvailable:t,releaseNotes:e.releaseNotes,nativeStatus:e.status,progress:e.progress,error:e.error,releaseUrl:$n}),v(e.currentVersion),e.status===`error`?w(e.error||`${rr} could not check or download the update.`):e.status!==`checking`&&w(null),M(e.status===`checking`||e.status===`downloading`),ne(e.status===`checking`?`checking`:e.status===`downloading`?`downloading`:e.status===`downloaded`?`downloaded`:e.status===`error`?`error`:`idle`),e.status===`available`&&S(!1)},tn=async(e=!0)=>{try{if(FP){let t=await FP.getStatus();en(t),e&&t.status!==`unsupported`&&en(await FP.check());return}let t=await fetch(`/api/update-status`);if(t.ok){let e=await t.json();g(e),w(null),e.currentVersion&&v(e.currentVersion)}else throw Error(`Update check failed with HTTP ${t.status}.`)}catch(e){w(e instanceof Error?e.message:`${rr} could not check for updates.`),console.error(`Failed to fetch update status:`,e)}},rn=async()=>{w(null),h?.nativeStatus===`downloaded`&&S(!1),await tn(!0)},an=async()=>{if(!FP){i(`Native installation is available in the ${rr} desktop app. Open the release page to install it.`,`info`);return}M(!0),ne(`downloading`);try{let e=await FP.download();en(e),e.status===`downloaded`?i(`Update downloaded. Restart ${rr} when you are ready to install it.`,`success`):i(`Update failed: ${e.error||`The download did not complete.`}`,`error`)}catch(e){console.error(`Update failed:`,e),ne(`error`),M(!1),i(`Update failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}},on=async()=>{if(FP)try{en(await FP.restart())}catch(e){let t=e instanceof Error?e.message:`Unknown error`;g(e=>e&&{...e,nativeStatus:`error`,error:t,updateAvailable:!!e.latestVersion}),w(t),ne(`error`),i(`Could not restart for update: ${t}`,`error`),M(!1)}},sn=async()=>{try{let e=await(await fetch(`/api/adapters`)).json();e.adapters&&m(e.adapters)}catch(e){console.error(`Failed to fetch adapters:`,e)}},ln=async()=>{sn();try{let e=await(await fetch(`/api/config`)).json();o(e.config),u(e.exists),e.exists&&e.config.devDir||(b({devDir:e.config.devDir||``,workspacesDir:e.config.workspacesDir||``}),o({version:`1.0.0`,devDir:``,workspacesDir:``,defaultAssistant:null,scanDepth:2}))}catch(e){console.error(e)}finally{c(!1)}},un=async e=>{try{(await fetch(`/api/config`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).ok?(f(`success`),o(e),u(!0),Ce.invalidateQueries({queryKey:[`repos`]}),dn()):f(`error`)}catch{f(`error`)}setTimeout(()=>f(null),3e3)},dn=async()=>{await Promise.all([Ce.invalidateQueries({queryKey:[`workspaces`]}),Ce.invalidateQueries({queryKey:[`workspaces-status`]})])},fn=async()=>{if(!ae.trim()||!oe.trim()){i(`Name and content are required.`,`error`);return}fe(!0);try{let e=await fetch(`/api/workflows/templates`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:P,name:ae,content:oe})});if(e.ok){let t=await e.json();i(`Strategy template saved successfully!`,`success`),await Ce.invalidateQueries({queryKey:[`workflow-templates`]}),F(t.template.id),L(!1),ce(null)}else{let t=await e.json();i(t.error||`Failed to save template`,`error`)}}catch(e){i(e.message||`Error saving template`,`error`)}finally{fe(!1)}},pn=async e=>{if(window.confirm(`Are you sure you want to delete this custom strategy template?`)){me(!0);try{let t=await fetch(`/api/workflows/templates/${encodeURIComponent(e)}`,{method:`DELETE`});if(t.ok)i(`Strategy template deleted successfully!`,`success`),await Ce.invalidateQueries({queryKey:[`workflow-templates`]}),F(null),ce(null);else{let e=await t.json();i(e.error||`Failed to delete template`,`error`)}}catch(e){i(e.message||`Error deleting template`,`error`)}finally{me(!1)}}},mn=async(e,t,n)=>{ue(!0),ce(null),ye(null);try{let r=await fetch(`/api/workflows/templates/${encodeURIComponent(e)}/analyze`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:t,assistant:n,comment:be})});if(r.ok){let e=await r.json();ce(e.analysis),ye(e.suggestedImprovement||null),i(`Strategy analysis completed successfully!`,`success`)}else{let e=await r.json();i(e.error||`Failed to analyze template using the selected assistant harness.`,`error`)}}catch(e){i(e.message||`Error analyzing template`,`error`)}finally{ue(!1)}},hn=async e=>{Ke(!0);try{let t=await(await fetch(`/api/workspace/${encodeURIComponent(e)}/changes`)).json();We(t.changes||[])}catch(e){console.error(e)}finally{Ke(!1)}},gn=async e=>{Ie(!0);try{let t=await(await fetch(`/api/workspace/${encodeURIComponent(e)}/sessions`)).json();Pe(t.sessions||[])}catch(e){console.error(e)}finally{Ie(!1)}},_n=async(e,t)=>{He(!0);try{let n=await(await fetch(`/api/session/${e}/${t}/transcript`)).json();Be(n.messages||[])}catch(e){console.error(e)}finally{He(!1)}},vn=async e=>{let t=++mt.current,n=()=>pt.current===e&&mt.current===t;Xe(!0),Qe(null);try{let t=await fetch(`/api/workspace/${encodeURIComponent(e)}/knowledge`);if(!t.ok)throw Error(`knowledge request failed`);let r=await t.json();if(!r||typeof r!=`object`||typeof r.content!=`string`)throw Error(`knowledge response was malformed`);if(!n())return;let i=r.content;Je(i),vt.current||(_t.current=i,nt(i)),Qe(null)}catch(e){if(!n())return;console.error(`Failed to load workspace knowledge:`,e),Qe(`Could not load Knowledge. Existing content and your draft were kept. Retry when ready.`)}finally{n()&&Xe(!1)}},yn=async e=>{let t=++gt.current,n=_t.current,r=()=>pt.current===e&&gt.current===t;it(!0),ot(null);try{let t=await fetch(`/api/workspace/${encodeURIComponent(e)}/knowledge`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})});if(!t.ok)throw Error(`knowledge save request failed`);let i=await t.json();if(!i||typeof i!=`object`||i.success!==!0)throw Error(`knowledge save response was not confirmed`);if(!r())return;mt.current+=1,Xe(!1),Je(n),Qe(null),ot(null),vt.current&&_t.current===n&&Wt(!1)}catch(e){if(!r())return;console.error(`Failed to save workspace knowledge:`,e),ot(`Could not save Knowledge. Your draft is still open. Retry the save.`)}finally{r()&&it(!1)}},bn=async e=>{let t=++ht.current,n=()=>pt.current===e&&ht.current===t;ut(!0),ft(null);try{let t=await fetch(`/api/workspace/${encodeURIComponent(e)}/plan`);if(!t.ok)throw Error(`plan request failed`);let r=await t.json();if(!r||typeof r!=`object`||typeof r.content!=`string`)throw Error(`plan response was malformed`);if(!n())return;ct(r.content),ft(null)}catch(e){if(!n())return;console.error(`Failed to load workspace plan:`,e),ft(`Could not load Plan. Existing content was kept. Retry when ready.`)}finally{n()&&ut(!1)}},xn=async e=>{bt(!0),St(null);try{let t=await(await fetch(`/api/workspace/${encodeURIComponent(e)}/sync`,{method:`POST`})).json();St(t.results||[]),hn(e)}catch(e){console.error(e)}finally{bt(!1)}},Sn=async e=>{if(Ct.trim()){Mt(!0),Rt(null);try{let t=await(await fetch(`/api/workspace/${encodeURIComponent(e)}/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:Ct})})).json();Rt(t.results||[]),Et(``),kt(!1),hn(e)}catch(e){console.error(e)}finally{Mt(!1)}}},Cn=async(e,t,n)=>{if(n!==`codex`){let e=n===`claude`?`claude --resume ${t}`:`agy --conversation ${t}`;return await QS(e),i(`Copied ${n} resume command to clipboard:\n\n${e}`,`info`),!0}try{return await sr(`/api/workspace/${encodeURIComponent(e.branchName)}/launch`,{method:`POST`,body:JSON.stringify({targetId:`codex-desktop`,action:`resume`,sessionId:t})}),i(`Sent the existing session to Codex Desktop.`,`success`),!0}catch(e){return i(e instanceof Error?e.message:String(e),`error`),!1}},wn=async e=>{if(!ke)return;let t=Ee.find(e=>e.branchName===ke);if(t){if(PP){window.parent.postMessage({type:`executeTerminalCommand`,command:e,cwd:t.workspacePath},`*`);return}try{await sr(`/api/workspace/${encodeURIComponent(t.branchName)}/terminal`,{method:`POST`,body:JSON.stringify({command:e})})}catch(e){i(`Terminal error: ${e instanceof Error?e.message:String(e)}`,`error`)}}};(0,V.useEffect)(()=>{ln(),tn();let t=new URLSearchParams(window.location.search).get(`workspaceId`);t&&e(`/workspaces/${encodeURIComponent(t)}`)},[]),(0,V.useEffect)(()=>{if(FP)return FP.onEvent(en)},[]),(0,V.useEffect)(()=>{let e=t.pathname;if(e.startsWith(`/workspaces`)){let t=e.split(`/`).filter(Boolean);Ae(t[1]?decodeURIComponent(t[1]):null);let n=t[2];Me(n&&[`overview`,`plan`,`documents`,`changes`,`services`,`sessions`,`knowledge`,`skills`].includes(n)?n:`overview`)}else Ae(null)},[t.pathname]);let Tn=async(e=!1)=>{Yt(!0);try{let t=await fetch(`/api/updates/tools${e?`?force=true`:``}`);t.ok&&qt(await t.json())}catch(e){console.error(`Failed to fetch tools status:`,e)}finally{Yt(!1)}},En=async e=>{Zt(e);try{let t=await fetch(`/api/updates/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({toolId:e})}),n=await t.json();t.ok&&n.success?(i(`${e} updated successfully!\n\nOutput:\n${n.output}`,`success`),Tn(!0),tn()):i(`Error: ${n.error||`Failed to update tool`}`,`error`)}catch(e){console.error(e),i(`Network error when updating tool.`,`error`)}finally{Zt(null)}};(0,V.useEffect)(()=>{t.pathname.startsWith(`/settings`)&&Tn()},[t.pathname]),(0,V.useEffect)(()=>{pt.current=ke,mt.current+=1,ht.current+=1,gt.current+=1,Pe([]),We([]),Je(``),Qe(null),Xe(!1),ot(null),it(!1),_t.current=``,vt.current=!1,nt(``),et(!1),ct(``),ft(null),ut(!1)},[ke]),(0,V.useEffect)(()=>{ke&&(je===`changes`||je===`overview`)&&hn(ke)},[ke,je]),(0,V.useEffect)(()=>{ke&&(je===`sessions`||je===`overview`)&&gn(ke)},[ke,je]),(0,V.useEffect)(()=>{ke&&je===`knowledge`&&vn(ke)},[ke,je]),(0,V.useEffect)(()=>{ke&&(je===`overview`||je===`plan`)&&bn(ke)},[ke,je]);let Dn=async e=>{let t=e.repos.map(e=>e.split(/[\\/]/).pop()).join(`, `);await QS(`You are an AI assistant helping with feature development.
69
69
  We are working in a multi-repository workspace.
70
70
 
71
71
  Workspace Metadata:
@@ -77,4 +77,4 @@ Core Instructions:
77
77
  1. Read "AGENTS.md" at the workspace root first — it names the repos, how they depend on each other, which to change first, and how to verify each.
78
78
  2. Search "${ir}" for decisions and gotchas from earlier sessions rather than reading it whole, and record new ones with \`${Qn} knowledge add\`. "${ar}" carries the phase order when a change spans repos.
79
79
  3. Follow all project-specific rules in "CLAUDE.md", ".cursorrules", or "AGENTS.md" inside sub-repositories.
80
- `)?i(`AI context prompt copied to clipboard!`,`success`):i(`Could not copy prompt to clipboard. Please check browser permissions.`,`error`)},On=async e=>{ie(e)},kn=async t=>{Bt(t);try{let n=await fetch(`/api/workspace/${encodeURIComponent(t)}`,{method:`DELETE`}),r=await n.json();n.ok&&r.success?(ke===t&&e(`/workspaces`),await dn(),i(`Workspace ${t} successfully deleted.`,`success`),ie(null)):i(`Failed to delete workspace: ${r.error||`Unknown error`}`,`error`)}catch(e){console.error(e),i(`Network error while deleting workspace.`,`error`)}finally{Bt(null)}},An=async(e,t)=>{Ht(!0);try{let n=await fetch(`/api/workspace/${encodeURIComponent(e)}/repo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({repoPath:t})}),r=await n.json();n.ok&&r.success?(await dn(),Ce.invalidateQueries({queryKey:[`workspace-services`,e]}),ke===e&&(hn(e),gn(e)),i(`Repository successfully added and configurations updated.`,`success`)):i(`Failed to add repository: ${r.error||`Unknown error`}`,`error`)}catch(e){console.error(e),i(`Network error while adding repository.`,`error`)}finally{Ht(!1)}};if(!l&&a)return(0,H.jsx)(Lc,{config:a,setConfig:o,defaultPaths:y,adapters:p,saveAppConfig:un});if(OP)return(0,H.jsx)(Ns,{activeWsId:ke,setActiveWsId:Ae,appVersion:_,workspaces:Ee,executeTerminal:wn});let jn=a?(0,H.jsx)(vP,{workspaces:Ee,workspaceStatuses:Oe,workspacesLoading:De,onOpenWorkspace:t=>e(`/workspaces/${encodeURIComponent(t)}`),onNewWorkspace:()=>e(`/new`),showToast:i}):null,Mn=a?(0,H.jsx)(DP,{config:a,onCreateWorkspace:()=>e(`/new`),onModifySettings:()=>e(`/settings`)}):null,Nn=a?(0,H.jsx)(wP,{}):null,Pn=a?(0,H.jsx)(yP,{}):null,Fn=(0,H.jsx)(EP,{workspaces:Ee,workspaceStatuses:Oe,workspacesLoading:De,fetchWorkspaces:dn,selectedId:ke,subTab:je,onSelect:t=>e(`/workspaces/${encodeURIComponent(t)}`),onSelectTab:(t,n)=>e(`/workspaces/${encodeURIComponent(t)}/${n}`),handleCopyPrompt:Dn,handleDeleteWorkspace:On,deleteWsLoading:zt,repos:O,addRepoLoading:Vt,handleAddRepo:An,sessionProps:{sessions:Ne,sessionsLoading:Fe,setActiveSession:Re,setTranscript:Be,fetchSessionTranscript:_n,handleOpenDesktopSession:Cn,showToast:i},changesProps:{gitChanges:Ue,gitChangesLoading:Ge,syncLoading:yt,syncResults:xt,commitMessage:Ct,showCommitModal:Dt,commitLoading:jt,commitResults:Pt,setSyncResults:St,setCommitResults:Rt,setCommitMessage:Et,setShowCommitModal:kt,fetchGitChanges:hn,handleSyncAll:xn,handleCommitAll:Sn},knowledgeProps:{knowledgeContent:qe,knowledgeLoading:Ye,knowledgeError:Ze,isEditingKnowledge:$e,editedKnowledge:tt,saveKnowledgeLoading:rt,saveKnowledgeError:at,setEditedKnowledge:Ut,setIsEditingKnowledge:Wt,handleSaveKnowledge:yn,handleRetryKnowledge:vn},planProps:{planContent:st,planLoading:lt,planError:dt,handleRetryPlan:bn},showToast:i}),In=(0,H.jsx)(TP,{workflowTemplates:te,isEditingTemplate:I,setIsEditingTemplate:L,mgtTemplateName:ae,setMgtTemplateName:R,mgtTemplateContent:oe,setMgtTemplateContent:z,selectedMgtTemplateId:P,setSelectedMgtTemplateId:F,analysisResult:se,setAnalysisResult:ce,showToast:i,handleAnalyzeTemplate:mn,handleSaveTemplate:fn,handleDeleteTemplate:pn,aiAssistants:k,analyzingTemplate:le,mgtAnalysisComment:be,setMgtAnalysisComment:xe,suggestedImprovement:ve,setSuggestedImprovement:ye,savingTemplate:de,deletingTemplate:pe,selectedInspectAssistant:he,setSelectedInspectAssistant:ge}),Ln=(0,H.jsx)(xP,{showToast:i}),Rn=(0,H.jsx)(SP,{showToast:i}),zn=(0,H.jsx)(CP,{workspaces:Ee,showToast:i}),Bn=a?(0,H.jsx)(bP,{config:a,setConfig:o,saveStatus:d,editors:A,adapters:p,saveAppConfig:un,isSettingsFormValid:$t,toolsStatus:Gt,toolsLoading:Jt,updatingToolId:Xt,fetchToolsStatus:Tn,handleUpdateTool:En}):null,Vn=ke||(Ee.length>0?Ee[0].branchName:null),Hn=t.pathname.startsWith(`/workspaces`);return(0,H.jsxs)(`div`,{className:`flex min-h-screen bg-transparent text-foreground max-md:pt-12`,children:[(0,H.jsx)(ks,{appVersion:_,workspaces:Ee,workspaceStatuses:Oe,workspacesLoading:De,activeWsId:ke,onSelectWorkspace:t=>e(`/workspaces/${encodeURIComponent(t)}`)}),(0,H.jsx)(`main`,{className:B(`flex-1 min-w-0 h-[calc(100dvh-3rem)] md:h-screen`,Hn?`overflow-hidden flex flex-col`:`overflow-y-auto p-3 sm:p-5 lg:p-6`),children:s?(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-40 gap-4 text-muted-foreground`,children:[(0,H.jsx)(li,{className:`animate-spin text-primary`,size:32}),(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Loading config settings...`})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`mb-4 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 rounded-lg border border-border bg-card/50 px-3 py-2.5 text-xs`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Desktop updates`}),C?(0,H.jsx)(`p`,{className:`mt-0.5 truncate text-red-300`,role:`alert`,children:C}):(0,H.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:`Updates are optional and never install without your confirmation.`})]}),(0,H.jsx)(`button`,{onClick:rn,disabled:[`checking`,`downloading`].includes(h?.nativeStatus??``),className:`shrink-0 rounded-md border border-border px-3 py-1.5 font-semibold text-muted-foreground hover:text-foreground disabled:opacity-50`,children:C?`Check again`:`Check for updates`})]}),h&&h.updateAvailable&&!x&&(0,H.jsxs)(`div`,{className:`mb-6 p-4 bg-gradient-to-r from-amber-500/10 to-orange-600/10 border border-amber-500/30 rounded-xl shadow-lg flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 backdrop-blur-sm`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-amber-500/10 border border-amber-500/20 flex items-center justify-center text-amber-400 shrink-0`,children:j?(0,H.jsx)(li,{size:20,className:`animate-spin text-amber-400`}):(0,H.jsx)(hi,{size:20})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-bold text-amber-300`,children:N===`error`?`${rr} update needs attention`:N===`downloaded`?`Update ready to install`:N===`downloading`?`Downloading update…`:`A new version of ${rr} is available!`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:N===`error`?h.error||`The update could not be completed. You can retry or use the release page.`:N===`downloaded`?`Restart ${rr} when convenient to install it.`:N===`downloading`?`Downloading from GitHub Releases… ${Math.round(h.progress||0)}%`:`Upgrade from v${h.currentVersion} to v${h.latestVersion} to get the latest features and bug fixes.`}),N===`downloading`&&(0,H.jsx)(`div`,{className:`mt-2 h-1.5 w-full max-w-xs overflow-hidden rounded-full bg-amber-950/50`,"aria-label":`Update download progress`,children:(0,H.jsx)(`div`,{className:`h-full bg-amber-400 transition-all`,style:{width:`${Math.max(0,Math.min(100,h.progress||0))}%`}})}),h.releaseNotes&&(0,H.jsxs)(`details`,{className:`mt-2 max-w-xl text-xs text-muted-foreground`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer font-semibold text-amber-200`,children:`Release notes`}),(0,H.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:h.releaseNotes})]})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[kP&&N===`downloaded`&&(0,H.jsx)(`button`,{onClick:on,className:`px-4 py-2 bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-600 hover:to-teal-700 text-white font-bold text-xs rounded-lg transition-all shadow-md cursor-pointer`,children:`Restart & Install`}),kP&&N!==`downloaded`&&(0,H.jsx)(`button`,{onClick:an,disabled:j,className:`px-4 py-2 bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-600 hover:to-teal-700 text-white font-bold text-xs rounded-lg transition-all shadow-md disabled:opacity-50 cursor-pointer flex items-center gap-1.5`,children:N===`error`?`Retry download`:j?`Downloading…`:`Download update`}),(0,H.jsx)(`a`,{href:h.releaseUrl||$n,target:`_blank`,rel:`noreferrer`,className:`px-3 py-2 border border-amber-500/30 text-amber-200 hover:bg-amber-500/10 font-semibold text-xs rounded-lg transition-colors`,children:`View release`}),(0,H.jsx)(`button`,{onClick:()=>S(!0),disabled:j,className:`px-3 py-2 border border-border text-muted-foreground hover:text-foreground font-semibold text-xs rounded-lg transition-colors disabled:opacity-50`,children:`Later`})]})]}),!a&&(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-40 gap-6`,children:[(0,H.jsx)(`div`,{className:`bg-red-500/10 p-6 rounded-full`,children:(0,H.jsx)(Si,{className:`text-red-400`,size:48})}),(0,H.jsxs)(`div`,{className:`text-center max-w-md`,children:[(0,H.jsx)(`h2`,{className:`text-2xl font-bold text-white mb-2`,children:`Backend Unreachable`}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-6`,children:[`The `,rr,` GUI could not connect to the local server. Make sure you started the GUI correctly via `,(0,H.jsxs)(`code`,{children:[Qn,` ui`]}),` or that the backend is running.`]}),(0,H.jsxs)(`button`,{onClick:()=>{c(!0),ln(),Ce.invalidateQueries()},className:`px-4 py-2 bg-primary hover:bg-primary/90 text-white font-medium text-sm rounded-md transition-colors cursor-pointer inline-flex items-center gap-2`,children:[(0,H.jsx)(li,{size:16}),` Try Again`]})]})]}),(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`div`,{className:`flex justify-center py-20`,children:(0,H.jsx)(Rv,{className:`size-6`})}),children:(0,H.jsxs)(It,{children:[(0,H.jsx)(Ot,{path:`/`,element:jn}),(0,H.jsx)(Ot,{path:`/overview`,element:jn}),(0,H.jsx)(Ot,{path:`/dashboard`,element:jn}),(0,H.jsx)(Ot,{path:`/guide`,element:Mn}),(0,H.jsx)(Ot,{path:`/create`,element:Nn}),(0,H.jsx)(Ot,{path:`/new`,element:Nn}),(0,H.jsx)(Ot,{path:`/projects`,element:Pn}),(0,H.jsx)(Ot,{path:`/workspaces`,element:Vn?(0,H.jsx)(nn,{to:`/workspaces/${encodeURIComponent(Vn)}`,replace:!0}):(0,H.jsx)(nn,{to:`/new`,replace:!0})}),(0,H.jsx)(Ot,{path:`/workspaces/:workspaceId`,element:Fn}),(0,H.jsx)(Ot,{path:`/workspaces/:workspaceId/:tab`,element:Fn}),(0,H.jsx)(Ot,{path:`/skills`,element:Ln}),(0,H.jsx)(Ot,{path:`/agents`,element:Rn}),(0,H.jsx)(Ot,{path:`/workrooms`,element:zn}),(0,H.jsx)(Ot,{path:`/settings`,element:Bn}),(0,H.jsx)(Ot,{path:`/workflows`,element:In}),(0,H.jsx)(Ot,{path:`/strategies`,element:In}),(0,H.jsx)(Ot,{path:`*`,element:(0,H.jsx)(nn,{to:`/overview`,replace:!0})})]})})]})}),Le&&(0,H.jsx)(iC,{activeSession:Le,transcript:ze,transcriptLoading:Ve,setActiveSession:Re,workspaces:Ee,workspace:Ee.find(e=>e.branchName===ke),handleOpenDesktopSession:Cn,showToast:i}),(0,H.jsx)(_P,{workspaceName:re,open:re!==null,onClose:()=>ie(null),onConfirm:kn,loading:zt!==null}),(0,H.jsx)(hP,{workspaces:Ee}),(0,H.jsx)(gP,{}),(0,H.jsx)(As,{toasts:n,onDismiss:e=>r(t=>t.filter(t=>t.id!==e))})]})}function MP(){return(0,H.jsx)(Pt,{children:(0,H.jsx)(jP,{})})}var NP=new hr;(0,gr.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(V.StrictMode,{children:(0,H.jsx)(cs,{children:(0,H.jsx)(zt,{client:NP,children:(0,H.jsx)(MP,{})})})}));export{no as $,Cr as $t,Pv as A,di as At,Pc as B,Gr as Bt,oC as C,Si as Ct,Rv as D,hi as Dt,Bv as E,vi as Et,Dv as F,Qr as Ft,ys as G,Mr as Gt,ws as H,zr as Ht,jc as I,Zr as It,vo as J,kr as Jt,Go as K,jr as Kt,Ic as L,Xr as Lt,Lv as M,ci as Mt,Mv as N,oi as Nt,Ov as O,pi as Ot,Fv as P,ii as Pt,oo as Q,wr as Qt,Fc as R,Jr as Rt,sC as S,Ci as St,QS as T,bi as Tt,Es as U,Ir as Ut,Ms as V,Wr as Vt,Ts as W,Nr as Wt,ho as X,Dr as Xt,_o as Y,Or as Yt,so as Z,Er as Zt,xC as _,$i as _t,RN as a,_r as an,Za as at,uC as b,Ei as bt,oN as c,Va as ct,VC as d,xa as dt,Sr as en,to as et,zC as f,pa as ft,yC as g,qi as gt,jC as h,Ki as ht,LN as i,vr as in,Ya as it,Nv as j,li as jt,Iv as k,fi as kt,iN as l,Ra as lt,PC as m,ta as mt,zN as n,br as nn,qa as nt,_N as o,Ja as ot,AC as p,ua as pt,bo as q,Ar as qt,FN as r,yr as rn,Xa as rt,aN as s,Ka as st,PN as t,xr as tn,eo as tt,tN as u,ka as ut,bC as v,Wi as vt,aC as w,xi as wt,hC as x,Ti as xt,SC as y,Di as yt,Nc as z,qr as zt};
80
+ `)?i(`AI context prompt copied to clipboard!`,`success`):i(`Could not copy prompt to clipboard. Please check browser permissions.`,`error`)},On=async e=>{ie(e)},kn=async t=>{Bt(t);try{let n=await fetch(`/api/workspace/${encodeURIComponent(t)}`,{method:`DELETE`}),r=await n.json();n.ok&&r.success?(ke===t&&e(`/workspaces`),await dn(),i(`Workspace ${t} successfully deleted.`,`success`),ie(null)):i(`Failed to delete workspace: ${r.error||`Unknown error`}`,`error`)}catch(e){console.error(e),i(`Network error while deleting workspace.`,`error`)}finally{Bt(null)}},An=async(e,t)=>{Ht(!0);try{let n=await fetch(`/api/workspace/${encodeURIComponent(e)}/repo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({repoPath:t})}),r=await n.json();n.ok&&r.success?(await dn(),Ce.invalidateQueries({queryKey:[`workspace-services`,e]}),ke===e&&(hn(e),gn(e)),i(`Repository successfully added and configurations updated.`,`success`)):i(`Failed to add repository: ${r.error||`Unknown error`}`,`error`)}catch(e){console.error(e),i(`Network error while adding repository.`,`error`)}finally{Ht(!1)}};if(!l&&a)return(0,H.jsx)(Lc,{config:a,setConfig:o,defaultPaths:y,adapters:p,saveAppConfig:un});if(PP)return(0,H.jsx)(Ns,{activeWsId:ke,setActiveWsId:Ae,appVersion:_,workspaces:Ee,executeTerminal:wn});let jn=a?(0,H.jsx)(wP,{workspaces:Ee,workspaceStatuses:Oe,workspacesLoading:De,onOpenWorkspace:t=>e(`/workspaces/${encodeURIComponent(t)}`),onNewWorkspace:()=>e(`/new`),showToast:i}):null,Mn=a?(0,H.jsx)(NP,{config:a,onCreateWorkspace:()=>e(`/new`),onModifySettings:()=>e(`/settings`)}):null,Nn=a?(0,H.jsx)(AP,{}):null,Pn=a?(0,H.jsx)(TP,{}):null,Fn=(0,H.jsx)(MP,{workspaces:Ee,workspaceStatuses:Oe,workspacesLoading:De,fetchWorkspaces:dn,selectedId:ke,subTab:je,onSelect:t=>e(`/workspaces/${encodeURIComponent(t)}`),onSelectTab:(t,n)=>e(`/workspaces/${encodeURIComponent(t)}/${n}`),handleCopyPrompt:Dn,handleDeleteWorkspace:On,deleteWsLoading:zt,repos:O,addRepoLoading:Vt,handleAddRepo:An,sessionProps:{sessions:Ne,sessionsLoading:Fe,setActiveSession:Re,setTranscript:Be,fetchSessionTranscript:_n,handleOpenDesktopSession:Cn,showToast:i},changesProps:{gitChanges:Ue,gitChangesLoading:Ge,syncLoading:yt,syncResults:xt,commitMessage:Ct,showCommitModal:Dt,commitLoading:jt,commitResults:Pt,setSyncResults:St,setCommitResults:Rt,setCommitMessage:Et,setShowCommitModal:kt,fetchGitChanges:hn,handleSyncAll:xn,handleCommitAll:Sn},knowledgeProps:{knowledgeContent:qe,knowledgeLoading:Ye,knowledgeError:Ze,isEditingKnowledge:$e,editedKnowledge:tt,saveKnowledgeLoading:rt,saveKnowledgeError:at,setEditedKnowledge:Ut,setIsEditingKnowledge:Wt,handleSaveKnowledge:yn,handleRetryKnowledge:vn},planProps:{planContent:st,planLoading:lt,planError:dt,handleRetryPlan:bn},showToast:i}),In=(0,H.jsx)(jP,{workflowTemplates:te,isEditingTemplate:I,setIsEditingTemplate:L,mgtTemplateName:ae,setMgtTemplateName:R,mgtTemplateContent:oe,setMgtTemplateContent:z,selectedMgtTemplateId:P,setSelectedMgtTemplateId:F,analysisResult:se,setAnalysisResult:ce,showToast:i,handleAnalyzeTemplate:mn,handleSaveTemplate:fn,handleDeleteTemplate:pn,aiAssistants:k,analyzingTemplate:le,mgtAnalysisComment:be,setMgtAnalysisComment:xe,suggestedImprovement:ve,setSuggestedImprovement:ye,savingTemplate:de,deletingTemplate:pe,selectedInspectAssistant:he,setSelectedInspectAssistant:ge}),Ln=(0,H.jsx)(DP,{showToast:i}),Rn=(0,H.jsx)(OP,{showToast:i}),zn=(0,H.jsx)(kP,{workspaces:Ee,showToast:i}),Bn=a?(0,H.jsx)(EP,{config:a,setConfig:o,saveStatus:d,editors:A,adapters:p,saveAppConfig:un,isSettingsFormValid:$t,toolsStatus:Gt,toolsLoading:Jt,updatingToolId:Xt,fetchToolsStatus:Tn,handleUpdateTool:En}):null,Vn=ke||(Ee.length>0?Ee[0].branchName:null),Hn=t.pathname.startsWith(`/workspaces`);return(0,H.jsxs)(`div`,{className:`flex min-h-screen bg-transparent text-foreground max-md:pt-12`,children:[(0,H.jsx)(ks,{appVersion:_,workspaces:Ee,workspaceStatuses:Oe,workspacesLoading:De,activeWsId:ke,onSelectWorkspace:t=>e(`/workspaces/${encodeURIComponent(t)}`)}),(0,H.jsx)(`main`,{className:B(`flex-1 min-w-0 h-[calc(100dvh-3rem)] md:h-screen`,Hn?`overflow-hidden flex flex-col`:`overflow-y-auto p-3 sm:p-5 lg:p-6`),children:s?(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-40 gap-4 text-muted-foreground`,children:[(0,H.jsx)(li,{className:`animate-spin text-primary`,size:32}),(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Loading config settings...`})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`mb-4 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 rounded-lg border border-border bg-card/50 px-3 py-2.5 text-xs`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Desktop updates`}),C?(0,H.jsx)(`p`,{className:`mt-0.5 truncate text-red-300`,role:`alert`,children:C}):(0,H.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:`Updates are optional and never install without your confirmation.`})]}),(0,H.jsx)(`button`,{onClick:rn,disabled:[`checking`,`downloading`].includes(h?.nativeStatus??``),className:`shrink-0 rounded-md border border-border px-3 py-1.5 font-semibold text-muted-foreground hover:text-foreground disabled:opacity-50`,children:C?`Check again`:`Check for updates`})]}),h&&h.updateAvailable&&!x&&(0,H.jsxs)(`div`,{className:`mb-6 p-4 bg-gradient-to-r from-amber-500/10 to-orange-600/10 border border-amber-500/30 rounded-xl shadow-lg flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 backdrop-blur-sm`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-amber-500/10 border border-amber-500/20 flex items-center justify-center text-amber-400 shrink-0`,children:j?(0,H.jsx)(li,{size:20,className:`animate-spin text-amber-400`}):(0,H.jsx)(hi,{size:20})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-bold text-amber-300`,children:N===`error`?`${rr} update needs attention`:N===`downloaded`?`Update ready to install`:N===`downloading`?`Downloading update…`:`A new version of ${rr} is available!`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:N===`error`?h.error||`The update could not be completed. You can retry or use the release page.`:N===`downloaded`?`Restart ${rr} when convenient to install it.`:N===`downloading`?`Downloading from GitHub Releases… ${Math.round(h.progress||0)}%`:`Upgrade from v${h.currentVersion} to v${h.latestVersion} to get the latest features and bug fixes.`}),N===`downloading`&&(0,H.jsx)(`div`,{className:`mt-2 h-1.5 w-full max-w-xs overflow-hidden rounded-full bg-amber-950/50`,"aria-label":`Update download progress`,children:(0,H.jsx)(`div`,{className:`h-full bg-amber-400 transition-all`,style:{width:`${Math.max(0,Math.min(100,h.progress||0))}%`}})}),h.releaseNotes&&(0,H.jsxs)(`details`,{className:`mt-2 max-w-xl text-xs text-muted-foreground`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer font-semibold text-amber-200`,children:`Release notes`}),(0,H.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:h.releaseNotes})]})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[FP&&N===`downloaded`&&(0,H.jsx)(`button`,{onClick:on,className:`px-4 py-2 bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-600 hover:to-teal-700 text-white font-bold text-xs rounded-lg transition-all shadow-md cursor-pointer`,children:`Restart & Install`}),FP&&N!==`downloaded`&&(0,H.jsx)(`button`,{onClick:an,disabled:j,className:`px-4 py-2 bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-600 hover:to-teal-700 text-white font-bold text-xs rounded-lg transition-all shadow-md disabled:opacity-50 cursor-pointer flex items-center gap-1.5`,children:N===`error`?`Retry download`:j?`Downloading…`:`Download update`}),(0,H.jsx)(`a`,{href:h.releaseUrl||$n,target:`_blank`,rel:`noreferrer`,className:`px-3 py-2 border border-amber-500/30 text-amber-200 hover:bg-amber-500/10 font-semibold text-xs rounded-lg transition-colors`,children:`View release`}),(0,H.jsx)(`button`,{onClick:()=>S(!0),disabled:j,className:`px-3 py-2 border border-border text-muted-foreground hover:text-foreground font-semibold text-xs rounded-lg transition-colors disabled:opacity-50`,children:`Later`})]})]}),!a&&(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-40 gap-6`,children:[(0,H.jsx)(`div`,{className:`bg-red-500/10 p-6 rounded-full`,children:(0,H.jsx)(Si,{className:`text-red-400`,size:48})}),(0,H.jsxs)(`div`,{className:`text-center max-w-md`,children:[(0,H.jsx)(`h2`,{className:`text-2xl font-bold text-white mb-2`,children:`Backend Unreachable`}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-6`,children:[`The `,rr,` GUI could not connect to the local server. Make sure you started the GUI correctly via `,(0,H.jsxs)(`code`,{children:[Qn,` ui`]}),` or that the backend is running.`]}),(0,H.jsxs)(`button`,{onClick:()=>{c(!0),ln(),Ce.invalidateQueries()},className:`px-4 py-2 bg-primary hover:bg-primary/90 text-white font-medium text-sm rounded-md transition-colors cursor-pointer inline-flex items-center gap-2`,children:[(0,H.jsx)(li,{size:16}),` Try Again`]})]})]}),(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`div`,{className:`flex justify-center py-20`,children:(0,H.jsx)(Rv,{className:`size-6`})}),children:(0,H.jsxs)(It,{children:[(0,H.jsx)(Ot,{path:`/`,element:jn}),(0,H.jsx)(Ot,{path:`/overview`,element:jn}),(0,H.jsx)(Ot,{path:`/dashboard`,element:jn}),(0,H.jsx)(Ot,{path:`/guide`,element:Mn}),(0,H.jsx)(Ot,{path:`/create`,element:Nn}),(0,H.jsx)(Ot,{path:`/new`,element:Nn}),(0,H.jsx)(Ot,{path:`/projects`,element:Pn}),(0,H.jsx)(Ot,{path:`/workspaces`,element:Vn?(0,H.jsx)(nn,{to:`/workspaces/${encodeURIComponent(Vn)}`,replace:!0}):(0,H.jsx)(nn,{to:`/new`,replace:!0})}),(0,H.jsx)(Ot,{path:`/workspaces/:workspaceId`,element:Fn}),(0,H.jsx)(Ot,{path:`/workspaces/:workspaceId/:tab`,element:Fn}),(0,H.jsx)(Ot,{path:`/skills`,element:Ln}),(0,H.jsx)(Ot,{path:`/agents`,element:Rn}),(0,H.jsx)(Ot,{path:`/workrooms`,element:zn}),(0,H.jsx)(Ot,{path:`/settings`,element:Bn}),(0,H.jsx)(Ot,{path:`/workflows`,element:In}),(0,H.jsx)(Ot,{path:`/strategies`,element:In}),(0,H.jsx)(Ot,{path:`*`,element:(0,H.jsx)(nn,{to:`/overview`,replace:!0})})]})})]})}),Le&&(0,H.jsx)(iC,{activeSession:Le,transcript:ze,transcriptLoading:Ve,setActiveSession:Re,workspaces:Ee,workspace:Ee.find(e=>e.branchName===ke),handleOpenDesktopSession:Cn,showToast:i}),(0,H.jsx)(CP,{workspaceName:re,open:re!==null,onClose:()=>ie(null),onConfirm:kn,loading:zt!==null}),(0,H.jsx)(xP,{workspaces:Ee}),(0,H.jsx)(SP,{}),(0,H.jsx)(As,{toasts:n,onDismiss:e=>r(t=>t.filter(t=>t.id!==e))})]})}function RP(){return(0,H.jsx)(Pt,{children:(0,H.jsx)(LP,{})})}var zP=new hr;(0,gr.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(V.StrictMode,{children:(0,H.jsx)(cs,{children:(0,H.jsx)(zt,{client:zP,children:(0,H.jsx)(RP,{})})})}));export{so as $,Er as $t,Ov as A,pi as At,Fc as B,Jr as Bt,hC as C,Ti as Ct,QS as D,bi as Dt,aC as E,xi as Et,Mv as F,oi as Ft,Es as G,Ir as Gt,Pc as H,Gr as Ht,Fv as I,ii as It,Go as J,jr as Jt,Ts as K,Nr as Kt,Dv as L,Qr as Lt,Pv as M,di as Mt,Nv as N,li as Nt,Bv as O,vi as Ot,Lv as P,ci as Pt,ho as Q,Dr as Qt,jc as R,Zr as Rt,uC as S,Ei as St,oC as T,Si as Tt,Ms as U,Wr as Ut,Nc as V,qr as Vt,ws as W,zr as Wt,vo as X,kr as Xt,bo as Y,Ar as Yt,_o as Z,Or as Zt,jC as _,Ki as _t,RN as a,yr as an,Xa as at,bC as b,Wi as bt,bN as c,Ja as ct,iN as d,Ra as dt,wr as en,oo as et,tN as f,ka as ft,PC as g,ta as gt,AC as h,ua as ht,HN as i,br as in,qa as it,Iv as j,fi as jt,Rv as k,hi as kt,aN as l,Ka as lt,zC as m,pa as mt,QN as n,Sr as nn,to as nt,BN as o,vr as on,Ya as ot,VC as p,xa as pt,ys as q,Mr as qt,LN as r,xr as rn,eo as rt,VN as s,_r as sn,Za as st,ZN as t,Cr as tn,no as tt,oN as u,Va as ut,yC as v,qi as vt,sC as w,Ci as wt,SC as x,Di as xt,xC as y,$i as yt,Ic as z,Xr as zt};