@straiffi/archon 1.2.8 → 1.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{TestsDialog-XEE4TEv4.js → TestsDialog-BPHhOIWL.js} +1 -1
- package/dist/client/assets/{badge-RYXMXLW8.js → badge-DtLPY3ow.js} +12 -12
- package/dist/client/assets/index-FvaV49M1.js +149 -0
- package/dist/client/assets/index-Qf62KDwt.css +2 -0
- package/dist/client/index.html +3 -3
- package/dist/server/db.js +33 -0
- package/dist/server/db.js.map +1 -1
- package/dist/server/index.js +120 -3
- package/dist/server/index.js.map +1 -1
- package/dist/server/lib/agent.js +2 -2
- package/dist/server/lib/agent.js.map +1 -1
- package/dist/server/lib/attachments.js +202 -0
- package/dist/server/lib/attachments.js.map +1 -0
- package/dist/server/lib/buildFlow.js +1 -1
- package/dist/server/lib/buildFlow.js.map +1 -1
- package/dist/server/lib/chatMessages.js +4 -1
- package/dist/server/lib/chatMessages.js.map +1 -1
- package/dist/server/lib/chatOperations.js +33 -11
- package/dist/server/lib/chatOperations.js.map +1 -1
- package/dist/server/lib/chatTargets.js +11 -0
- package/dist/server/lib/chatTargets.js.map +1 -1
- package/dist/server/lib/chats.js +21 -4
- package/dist/server/lib/chats.js.map +1 -1
- package/dist/server/lib/runtimePaths.js +7 -0
- package/dist/server/lib/runtimePaths.js.map +1 -1
- package/dist/server/lib/thinkingState.js +67 -0
- package/dist/server/lib/thinkingState.js.map +1 -0
- package/dist/server/lib/ticketUndo.js +2 -2
- package/dist/server/lib/ticketUndo.js.map +1 -1
- package/dist/server/lib/ticketWorkflowOperations.js +1 -1
- package/dist/server/lib/ticketWorkflowOperations.js.map +1 -1
- package/dist/server/lib/tickets.js +6 -0
- package/dist/server/lib/tickets.js.map +1 -1
- package/dist/server/workers/build.js +6 -1
- package/dist/server/workers/build.js.map +1 -1
- package/dist/server/workers/chat.js +55 -9
- package/dist/server/workers/chat.js.map +1 -1
- package/dist/server/workers/followUp.js +6 -1
- package/dist/server/workers/followUp.js.map +1 -1
- package/dist/server/workers/plan.js +7 -2
- package/dist/server/workers/plan.js.map +1 -1
- package/dist/server/workers/planFollowUp.js +7 -2
- package/dist/server/workers/planFollowUp.js.map +1 -1
- package/dist/server/workers/review.js +5 -0
- package/dist/server/workers/review.js.map +1 -1
- package/package.json +5 -2
- package/dist/client/assets/index-BAYGY5L6.js +0 -149
- package/dist/client/assets/index-DWMCGEsT.css +0 -2
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TestsDialog-BPHhOIWL.js","assets/rolldown-runtime-BYbx6iT9.js","assets/badge-DtLPY3ow.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-BYbx6iT9.js";import{$ as a,A as o,At as s,B as c,Bt as l,C as u,Ct as d,D as f,Dt as p,E as m,Et as h,F as g,Ft as _,G as v,H as y,I as b,It as x,J as S,K as C,L as w,Lt as T,M as E,Mt as D,N as O,Nt as k,O as A,Ot as j,P as M,Pt as N,Q as P,R as F,Rt as I,S as L,St as R,T as z,Tt as B,U as V,V as ee,Vt as te,W as H,X as ne,Y as U,Z as re,_ as ie,_t as ae,a as oe,at as se,b as ce,bt as le,c as ue,ct as de,d as W,dt as fe,et as pe,f as me,ft as G,g as he,gt as ge,h as _e,ht as ve,i as ye,it as be,j as xe,jt as Se,k as Ce,kt as we,l as K,lt as Te,m as Ee,mt as De,n as Oe,nt as ke,o as Ae,ot as je,p as Me,pt as Ne,q as Pe,r as Fe,rt as Ie,s as Le,st as Re,t as q,tt as ze,u as J,ut as Be,v as Ve,vt as He,w as Ue,wt as We,x as Ge,xt as Ke,y as qe,yt as Je,z as Ye,zt as Xe}from"./badge-DtLPY3ow.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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Ze=i((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,O());else{var t=n(l);t!==null&&j(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&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(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,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),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}}}})),Y=i(((e,t)=>{t.exports=Ze()})),Qe=i((e=>{var t=Y(),n=te(),r=l();function i(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 a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(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 s(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 c(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(o(e)!==e)throw Error(i(188))}function d(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return u(a),e;if(s===r)return u(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,l=a.child;l;){if(l===n){c=!0,n=a,r=s;break}if(l===r){c=!0,r=a,n=s;break}l=l.sibling}if(!c){for(l=s.child;l;){if(l===n){c=!0,n=s,r=a;break}if(l===r){c=!0,r=s,n=a;break}l=l.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(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`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?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?M(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var N=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},L=[],R=-1;function z(e){return{current:e}}function B(e){0>R||(e.current=L[R],L[R]=null,R--)}function V(e,t){R++,L[R]=e.current,e.current=t}var ee=z(null),H=z(null),ne=z(null),U=z(null);function re(e,t){switch(V(ne,t),V(H,e),V(ee,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Hd(t),e=Ud(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(ee),V(ee,e)}function ie(){B(ee),B(H),B(ne)}function ae(e){e.memoizedState!==null&&V(U,e);var t=ee.current,n=Ud(t,e.type);t!==n&&(V(H,e),V(ee,n))}function oe(e){H.current===e&&(B(ee),B(H)),U.current===e&&(B(U),$f._currentValue=I)}var se,ce;function le(e){if(se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);se=t&&t[1]||``,ce=-1<e.stack.indexOf(`
|
|
3
|
+
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
|
+
`+se+e+ce}var ue=!1;function de(e,t){if(!e||ue)return``;ue=!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
|
+
`),l=s.split(`
|
|
6
|
+
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
7
|
+
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{ue=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?le(n):``}function W(e,t){switch(e.tag){case 26:case 27:case 5:return le(e.type);case 16:return le(`Lazy`);case 13:return e.child!==t&&t!==null?le(`Suspense Fallback`):le(`Suspense`);case 19:return le(`SuspenseList`);case 0:case 15:return de(e.type,!1);case 11:return de(e.type.render,!1);case 1:return de(e.type,!0);case 31:return le(`Activity`);default:return``}}function fe(e){try{var t=``,n=null;do t+=W(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
8
|
+
Error generating stack: `+e.message+`
|
|
9
|
+
`+e.stack}}var pe=Object.prototype.hasOwnProperty,me=t.unstable_scheduleCallback,G=t.unstable_cancelCallback,he=t.unstable_shouldYield,ge=t.unstable_requestPaint,_e=t.unstable_now,ve=t.unstable_getCurrentPriorityLevel,ye=t.unstable_ImmediatePriority,be=t.unstable_UserBlockingPriority,xe=t.unstable_NormalPriority,Se=t.unstable_LowPriority,Ce=t.unstable_IdlePriority,we=t.log,K=t.unstable_setDisableYieldValue,Te=null,Ee=null;function De(e){if(typeof we==`function`&&K(e),Ee&&typeof Ee.setStrictMode==`function`)try{Ee.setStrictMode(Te,e)}catch{}}var Oe=Math.clz32?Math.clz32:je,ke=Math.log,Ae=Math.LN2;function je(e){return e>>>=0,e===0?32:31-(ke(e)/Ae|0)|0}var Me=256,Ne=262144,Pe=4194304;function Fe(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ie(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Fe(n))):i=Fe(o):i=Fe(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Fe(n))):i=Fe(o)):i=Fe(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Le(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Re(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function q(){var e=Pe;return Pe<<=1,!(Pe&62914560)&&(Pe=4194304),e}function ze(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function J(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Be(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Oe(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Ve(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Ve(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Oe(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function He(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Oe(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Ue(e,t){var n=t&-t;return n=n&42?1:We(n),(n&(e.suspendedLanes|t))===0?n:0}function We(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Ge(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ke(){var e=F.p;return e===0?(e=window.event,e===void 0?32:hp(e.type)):e}function qe(e,t){var n=F.p;try{return F.p=e,t()}finally{F.p=n}}var Je=Math.random().toString(36).slice(2),Ye=`__reactFiber$`+Je,Xe=`__reactProps$`+Je,Ze=`__reactContainer$`+Je,Qe=`__reactEvents$`+Je,$e=`__reactListeners$`+Je,et=`__reactHandles$`+Je,tt=`__reactResources$`+Je,nt=`__reactMarker$`+Je;function rt(e){delete e[Ye],delete e[Xe],delete e[Qe],delete e[$e],delete e[et]}function it(e){var t=e[Ye];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ze]||n[Ye]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=ff(e);e!==null;){if(n=e[Ye])return n;e=ff(e)}return t}e=n,n=e.parentNode}return null}function at(e){if(e=e[Ye]||e[Ze]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ot(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function st(e){var t=e[tt];return t||=e[tt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function ct(e){e[nt]=!0}var X=new Set,lt={};function ut(e,t){dt(e,t),dt(e+`Capture`,t)}function dt(e,t){for(lt[e]=t,e=0;e<t.length;e++)X.add(t[e])}var ft=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),pt={},mt={};function ht(e){return pe.call(mt,e)?!0:pe.call(pt,e)?!1:ft.test(e)?mt[e]=!0:(pt[e]=!0,!1)}function gt(e,t,n){if(ht(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function _t(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function vt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Z(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function yt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function bt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function xt(e){if(!e._valueTracker){var t=yt(e)?`checked`:`value`;e._valueTracker=bt(e,t,``+e[t])}}function St(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=yt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Ct(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var wt=/[\n"\\]/g;function Tt(e){return e.replace(wt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Et(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Z(t)):e.value!==``+Z(t)&&(e.value=``+Z(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Ot(e,o,Z(n)):Ot(e,o,Z(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Z(s):e.removeAttribute(`name`)}function Dt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){xt(e);return}n=n==null?``:``+Z(n),t=t==null?n:``+Z(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),xt(e)}function Ot(e,t,n){t===`number`&&Ct(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function kt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Z(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function At(e,t,n){if(t!=null&&(t=``+Z(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Z(n)}function jt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(N(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Z(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),xt(e)}function Mt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Nt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Pt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Nt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Ft(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Pt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Pt(e,o,t[o])}function It(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Lt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Rt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function zt(e){return Rt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Bt(){}var Vt=null;function Ht(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ut=null,Wt=null;function Gt(e){var t=at(e);if(t&&(e=t.stateNode)){var n=e[Xe]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Et(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Tt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[Xe]||null;if(!a)throw Error(i(90));Et(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&St(r)}break a;case`textarea`:At(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&kt(e,!!n.multiple,t,!1)}}}var Kt=!1;function qt(e,t,n){if(Kt)return e(t,n);Kt=!0;try{return e(t)}finally{if(Kt=!1,(Ut!==null||Wt!==null)&&(yu(),Ut&&(t=Ut,e=Wt,Wt=Ut=null,Gt(t),e)))for(t=0;t<e.length;t++)Gt(e[t])}}function Jt(e,t){var n=e.stateNode;if(n===null)return null;var r=n[Xe]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var Yt=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),Xt=!1;if(Yt)try{var Zt={};Object.defineProperty(Zt,`passive`,{get:function(){Xt=!0}}),window.addEventListener(`test`,Zt,Zt),window.removeEventListener(`test`,Zt,Zt)}catch{Xt=!1}var Qt=null,$t=null,en=null;function tn(){if(en)return en;var e,t=$t,n=t.length,r,i=`value`in Qt?Qt.value:Qt.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return en=i.slice(e,1<r?1-r:void 0)}function nn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function rn(){return!0}function an(){return!1}function on(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?rn:an,this.isPropagationStopped=an,this}return p(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=rn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=rn)},persist:function(){},isPersistent:rn}),t}var sn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},cn=on(sn),ln=p({},sn,{view:0,detail:0}),un=on(ln),dn,fn,pn,mn=p({},ln,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Tn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==pn&&(pn&&e.type===`mousemove`?(dn=e.screenX-pn.screenX,fn=e.screenY-pn.screenY):fn=dn=0,pn=e),dn)},movementY:function(e){return`movementY`in e?e.movementY:fn}}),hn=on(mn),gn=on(p({},mn,{dataTransfer:0})),_n=on(p({},ln,{relatedTarget:0})),vn=on(p({},sn,{animationName:0,elapsedTime:0,pseudoElement:0})),yn=on(p({},sn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),bn=on(p({},sn,{data:0})),xn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Sn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Cn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function wn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Cn[e])?!!t[e]:!1}function Tn(){return wn}var En=on(p({},ln,{key:function(e){if(e.key){var t=xn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=nn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Sn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Tn,charCode:function(e){return e.type===`keypress`?nn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?nn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Dn=on(p({},mn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),On=on(p({},ln,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Tn})),kn=on(p({},sn,{propertyName:0,elapsedTime:0,pseudoElement:0})),An=on(p({},mn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),jn=on(p({},sn,{newState:0,oldState:0})),Mn=[9,13,27,32],Nn=Yt&&`CompositionEvent`in window,Pn=null;Yt&&`documentMode`in document&&(Pn=document.documentMode);var Fn=Yt&&`TextEvent`in window&&!Pn,In=Yt&&(!Nn||Pn&&8<Pn&&11>=Pn),Ln=` `,Rn=!1;function zn(e,t){switch(e){case`keyup`:return Mn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Bn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Vn=!1;function Hn(e,t){switch(e){case`compositionend`:return Bn(t);case`keypress`:return t.which===32?(Rn=!0,Ln):null;case`textInput`:return e=t.data,e===Ln&&Rn?null:e;default:return null}}function Un(e,t){if(Vn)return e===`compositionend`||!Nn&&zn(e,t)?(e=tn(),en=$t=Qt=null,Vn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return In&&t.locale!==`ko`?null:t.data;default:return null}}var Wn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Gn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Wn[e.type]:t===`textarea`}function Kn(e,t,n,r){Ut?Wt?Wt.push(r):Wt=[r]:Ut=r,t=Ed(t,`onChange`),0<t.length&&(n=new cn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var qn=null,Jn=null;function Yn(e){vd(e,0)}function Xn(e){if(St(ot(e)))return e}function Zn(e,t){if(e===`change`)return t}var Qn=!1;if(Yt){var $n;if(Yt){var er=`oninput`in document;if(!er){var tr=document.createElement(`div`);tr.setAttribute(`oninput`,`return;`),er=typeof tr.oninput==`function`}$n=er}else $n=!1;Qn=$n&&(!document.documentMode||9<document.documentMode)}function nr(){qn&&(qn.detachEvent(`onpropertychange`,rr),Jn=qn=null)}function rr(e){if(e.propertyName===`value`&&Xn(Jn)){var t=[];Kn(t,Jn,e,Ht(e)),qt(Yn,t)}}function ir(e,t,n){e===`focusin`?(nr(),qn=t,Jn=n,qn.attachEvent(`onpropertychange`,rr)):e===`focusout`&&nr()}function ar(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Xn(Jn)}function or(e,t){if(e===`click`)return Xn(t)}function sr(e,t){if(e===`input`||e===`change`)return Xn(t)}function cr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var lr=typeof Object.is==`function`?Object.is:cr;function ur(e,t){if(lr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!pe.call(t,i)||!lr(e[i],t[i]))return!1}return!0}function dr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function fr(e,t){var n=dr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=dr(n)}}function pr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?pr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function mr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ct(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ct(e.document)}return t}function hr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var gr=Yt&&`documentMode`in document&&11>=document.documentMode,_r=null,vr=null,yr=null,br=!1;function xr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;br||_r==null||_r!==Ct(r)||(r=_r,`selectionStart`in r&&hr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),yr&&ur(yr,r)||(yr=r,r=Ed(vr,`onSelect`),0<r.length&&(t=new cn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=_r)))}function Sr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Cr={animationend:Sr(`Animation`,`AnimationEnd`),animationiteration:Sr(`Animation`,`AnimationIteration`),animationstart:Sr(`Animation`,`AnimationStart`),transitionrun:Sr(`Transition`,`TransitionRun`),transitionstart:Sr(`Transition`,`TransitionStart`),transitioncancel:Sr(`Transition`,`TransitionCancel`),transitionend:Sr(`Transition`,`TransitionEnd`)},wr={},Tr={};Yt&&(Tr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Cr.animationend.animation,delete Cr.animationiteration.animation,delete Cr.animationstart.animation),`TransitionEvent`in window||delete Cr.transitionend.transition);function Er(e){if(wr[e])return wr[e];if(!Cr[e])return e;var t=Cr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Tr)return wr[e]=t[n];return e}var Dr=Er(`animationend`),Or=Er(`animationiteration`),kr=Er(`animationstart`),Ar=Er(`transitionrun`),jr=Er(`transitionstart`),Mr=Er(`transitioncancel`),Nr=Er(`transitionend`),Pr=new Map,Fr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Fr.push(`scrollEnd`);function Ir(e,t){Pr.set(e,t),ut(t,[e])}var Lr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Rr=[],zr=0,Br=0;function Vr(){for(var e=zr,t=Br=zr=0;t<e;){var n=Rr[t];Rr[t++]=null;var r=Rr[t];Rr[t++]=null;var i=Rr[t];Rr[t++]=null;var a=Rr[t];if(Rr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Gr(n,i,a)}}function Hr(e,t,n,r){Rr[zr++]=e,Rr[zr++]=t,Rr[zr++]=n,Rr[zr++]=r,Br|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Ur(e,t,n,r){return Hr(e,t,n,r),Kr(e)}function Wr(e,t){return Hr(e,null,null,t),Kr(e)}function Gr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Oe(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Kr(e){if(50<uu)throw uu=0,du=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var qr={};function Jr(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Yr(e,t,n,r){return new Jr(e,t,n,r)}function Xr(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Zr(e,t){var n=e.alternate;return n===null?(n=Yr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Qr(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function $r(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)Xr(e)&&(s=1);else if(typeof e==`string`)s=Wf(e,n,ee.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case D:return e=Yr(31,n,t,a),e.elementType=D,e.lanes=o,e;case _:return ei(n.children,a,o,t);case v:s=8,a|=24;break;case y:return e=Yr(12,n,t,a|2),e.elementType=y,e.lanes=o,e;case C:return e=Yr(13,n,t,a),e.elementType=C,e.lanes=o,e;case w:return e=Yr(19,n,t,a),e.elementType=w,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case x:s=10;break a;case b:s=9;break a;case S:s=11;break a;case T:s=14;break a;case E:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Yr(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function ei(e,t,n,r){return e=Yr(7,e,r,t),e.lanes=n,e}function ti(e,t,n){return e=Yr(6,e,null,t),e.lanes=n,e}function ni(e){var t=Yr(18,null,null,0);return t.stateNode=e,t}function ri(e,t,n){return t=Yr(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ii=new WeakMap;function ai(e,t){if(typeof e==`object`&&e){var n=ii.get(e);return n===void 0?(t={value:e,source:t,stack:fe(t)},ii.set(e,t),t):n}return{value:e,source:t,stack:fe(t)}}var oi=[],si=0,ci=null,li=0,ui=[],di=0,fi=null,pi=1,mi=``;function hi(e,t){oi[si++]=li,oi[si++]=ci,ci=e,li=t}function gi(e,t,n){ui[di++]=pi,ui[di++]=mi,ui[di++]=fi,fi=e;var r=pi;e=mi;var i=32-Oe(r)-1;r&=~(1<<i),n+=1;var a=32-Oe(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,pi=1<<32-Oe(t)+i|n<<i|r,mi=a+e}else pi=1<<a|n<<i|r,mi=e}function _i(e){e.return!==null&&(hi(e,1),gi(e,1,0))}function vi(e){for(;e===ci;)ci=oi[--si],oi[si]=null,li=oi[--si],oi[si]=null;for(;e===fi;)fi=ui[--di],ui[di]=null,mi=ui[--di],ui[di]=null,pi=ui[--di],ui[di]=null}function yi(e,t){ui[di++]=pi,ui[di++]=mi,ui[di++]=fi,pi=t.id,mi=t.overflow,fi=e}var bi=null,xi=null,Si=!1,Ci=null,wi=!1,Ti=Error(i(519));function Ei(e){throw Mi(ai(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ti}function Di(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Ye]=e,t[Xe]=r,n){case`dialog`:yd(`cancel`,t),yd(`close`,t);break;case`iframe`:case`object`:case`embed`:yd(`load`,t);break;case`video`:case`audio`:for(n=0;n<gd.length;n++)yd(gd[n],t);break;case`source`:yd(`error`,t);break;case`img`:case`image`:case`link`:yd(`error`,t),yd(`load`,t);break;case`details`:yd(`toggle`,t);break;case`input`:yd(`invalid`,t),Dt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:yd(`invalid`,t);break;case`textarea`:yd(`invalid`,t),jt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Md(t.textContent,n)?(r.popover!=null&&(yd(`beforetoggle`,t),yd(`toggle`,t)),r.onScroll!=null&&yd(`scroll`,t),r.onScrollEnd!=null&&yd(`scrollend`,t),r.onClick!=null&&(t.onclick=Bt),t=!0):t=!1,t||Ei(e,!0)}function Oi(e){for(bi=e.return;bi;)switch(bi.tag){case 5:case 31:case 13:wi=!1;return;case 27:case 3:wi=!0;return;default:bi=bi.return}}function ki(e){if(e!==bi)return!1;if(!Si)return Oi(e),Si=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Wd(e.type,e.memoizedProps)),n=!n),n&&xi&&Ei(e),Oi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));xi=df(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));xi=df(e)}else t===27?(t=xi,Qd(e.type)?(e=uf,uf=null,xi=e):xi=t):xi=bi?lf(e.stateNode.nextSibling):null;return!0}function Ai(){xi=bi=null,Si=!1}function ji(){var e=Ci;return e!==null&&(Xl===null?Xl=e:Xl.push.apply(Xl,e),Ci=null),e}function Mi(e){Ci===null?Ci=[e]:Ci.push(e)}var Ni=z(null),Pi=null,Fi=null;function Ii(e,t,n){V(Ni,t._currentValue),t._currentValue=n}function Li(e){e._currentValue=Ni.current,B(Ni)}function Ri(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function zi(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Ri(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Ri(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Bi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;lr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===U.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[$f]:e.push($f))}a=a.return}e!==null&&zi(t,e,n,r),t.flags|=262144}function Vi(e){for(e=e.firstContext;e!==null;){if(!lr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Hi(e){Pi=e,Fi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ui(e){return Gi(Pi,e)}function Wi(e,t){return Pi===null&&Hi(e),Gi(e,t)}function Gi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Fi===null){if(e===null)throw Error(i(308));Fi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Fi=Fi.next=t;return n}var Ki=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},qi=t.unstable_scheduleCallback,Ji=t.unstable_NormalPriority,Yi={$$typeof:x,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Xi(){return{controller:new Ki,data:new Map,refCount:0}}function Zi(e){e.refCount--,e.refCount===0&&qi(Ji,function(){e.controller.abort()})}var Qi=null,$i=0,ea=0,ta=null;function na(e,t){if(Qi===null){var n=Qi=[];$i=0,ea=dd(),ta={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return $i++,t.then(ra,ra),t}function ra(){if(--$i===0&&Qi!==null){ta!==null&&(ta.status=`fulfilled`);var e=Qi;Qi=null,ea=0,ta=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ia(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var aa=P.S;P.S=function(e,t){$l=_e(),typeof t==`object`&&t&&typeof t.then==`function`&&na(e,t),aa!==null&&aa(e,t)};var oa=z(null);function sa(){var e=oa.current;return e===null?Pl.pooledCache:e}function ca(e,t){t===null?V(oa,oa.current):V(oa,t.pool)}function la(){var e=sa();return e===null?null:{parent:Yi._currentValue,pool:e}}var ua=Error(i(460)),da=Error(i(474)),fa=Error(i(542)),pa={then:function(){}};function ma(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ha(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Bt,Bt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ya(e),e;default:if(typeof t.status==`string`)t.then(Bt,Bt);else{if(e=Pl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ya(e),e}throw _a=t,ua}}function ga(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(_a=e,ua):e}}var _a=null;function va(){if(_a===null)throw Error(i(459));var e=_a;return _a=null,e}function ya(e){if(e===ua||e===fa)throw Error(i(483))}var ba=null,xa=0;function Sa(e){var t=xa;return xa+=1,ba===null&&(ba=[]),ha(ba,e,t)}function Ca(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function wa(e,t){throw t.$$typeof===m?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ta(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Zr(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ti(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===_?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===E&&ga(i)===t.type)?(t=a(t,n.props),Ca(t,n),t.return=e,t):(t=$r(n.type,n.key,n.props,null,e.mode,r),Ca(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ri(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=ei(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ti(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case h:return n=$r(t.type,t.key,t.props,null,e.mode,n),Ca(n,t),n.return=e,n;case g:return t=ri(t,e.mode,n),t.return=e,t;case E:return t=ga(t),f(e,t,n)}if(N(t)||A(t))return t=ei(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Sa(t),n);if(t.$$typeof===x)return f(e,Wi(e,t),n);wa(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case h:return n.key===i?l(e,t,n,r):null;case g:return n.key===i?u(e,t,n,r):null;case E:return n=ga(n),p(e,t,n,r)}if(N(n)||A(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Sa(n),r);if(n.$$typeof===x)return p(e,t,Wi(e,n),r);wa(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case h:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case g:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case E:return r=ga(r),m(e,t,n,r,i)}if(N(r)||A(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Sa(r),i);if(r.$$typeof===x)return m(e,t,n,Wi(t,r),i);wa(t,r)}return null}function v(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Si&&hi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Si&&hi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Si&&hi(i,h),l}function y(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Si&&hi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Si&&hi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Si&&hi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===_&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case h:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===_){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===E&&ga(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ca(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===_?(c=ei(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=$r(o.type,o.key,o.props,null,e.mode,c),Ca(c,o),c.return=e,e=c)}return s(e);case g:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ri(o,e.mode,c),c.return=e,e=c}return s(e);case E:return o=ga(o),b(e,r,o,c)}if(N(o))return v(e,r,o,c);if(A(o)){if(l=A(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),y(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Sa(o),c);if(o.$$typeof===x)return b(e,r,Wi(e,o),c);wa(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ti(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{xa=0;var i=b(e,t,n,r);return ba=null,i}catch(t){if(t===ua||t===fa)throw t;var a=Yr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ea=Ta(!0),Da=Ta(!1),Oa=!1;function ka(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Aa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ja(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ma(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Nl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Kr(e),Gr(e,null,n),t}return Hr(e,r,t,n),Kr(e)}function Na(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,He(e,n)}}function Pa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Fa=!1;function Ia(){if(Fa){var e=ta;if(e!==null)throw e}}function La(e,t,n,r){Fa=!1;var i=e.updateQueue;Oa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,m=f!==s.lane;if(m?(Il&f)===f:(r&f)===f){f!==0&&f===ea&&(Fa=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=p({},d,f);break a;case 2:Oa=!0}}f=s.callback,f!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[f]:m.push(f))}else m={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Wl|=o,e.lanes=o,e.memoizedState=d}}function Ra(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function za(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ra(n[e],t)}var Ba=z(null),Va=z(0);function Ha(e,t){e=Hl,V(Va,e),V(Ba,t),Hl=e|t.baseLanes}function Ua(){V(Va,Hl),V(Ba,Ba.current)}function Wa(){Hl=Va.current,B(Ba),B(Va)}var Ga=z(null),Ka=null;function qa(e){var t=e.alternate;V(Qa,Qa.current&1),V(Ga,e),Ka===null&&(t===null||Ba.current!==null||t.memoizedState!==null)&&(Ka=e)}function Ja(e){V(Qa,Qa.current),V(Ga,e),Ka===null&&(Ka=e)}function Ya(e){e.tag===22?(V(Qa,Qa.current),V(Ga,e),Ka===null&&(Ka=e)):Xa(e)}function Xa(){V(Qa,Qa.current),V(Ga,Ga.current)}function Za(e){B(Ga),Ka===e&&(Ka=null),B(Qa)}var Qa=z(0);function $a(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||of(n)||sf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var eo=0,to=null,no=null,ro=null,io=!1,ao=!1,oo=!1,so=0,co=0,lo=null,uo=0;function fo(){throw Error(i(321))}function po(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!lr(e[n],t[n]))return!1;return!0}function mo(e,t,n,r,i,a){return eo=a,to=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,P.H=e===null||e.memoizedState===null?js:Ms,oo=!1,a=n(r,i),oo=!1,ao&&(a=go(t,n,r,i)),ho(e),a}function ho(e){P.H=As;var t=no!==null&&no.next!==null;if(eo=0,ro=no=to=null,io=!1,co=0,lo=null,t)throw Error(i(300));e===null||Ys||(e=e.dependencies,e!==null&&Vi(e)&&(Ys=!0))}function go(e,t,n,r){to=e;var a=0;do{if(ao&&(lo=null),co=0,ao=!1,25<=a)throw Error(i(301));if(a+=1,ro=no=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}P.H=Ns,o=t(n,r)}while(ao);return o}function _o(){var e=P.H,t=e.useState()[0];return t=typeof t.then==`function`?wo(t):t,e=e.useState()[0],(no===null?null:no.memoizedState)!==e&&(to.flags|=1024),t}function vo(){var e=so!==0;return so=0,e}function yo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function bo(e){if(io){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}io=!1}eo=0,ro=no=to=null,ao=!1,co=so=0,lo=null}function xo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ro===null?to.memoizedState=ro=e:ro=ro.next=e,ro}function So(){if(no===null){var e=to.alternate;e=e===null?null:e.memoizedState}else e=no.next;var t=ro===null?to.memoizedState:ro.next;if(t!==null)ro=t,no=e;else{if(e===null)throw to.alternate===null?Error(i(467)):Error(i(310));no=e,e={memoizedState:no.memoizedState,baseState:no.baseState,baseQueue:no.baseQueue,queue:no.queue,next:null},ro===null?to.memoizedState=ro=e:ro=ro.next=e}return ro}function Co(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wo(e){var t=co;return co+=1,lo===null&&(lo=[]),e=ha(lo,e,t),t=to,(ro===null?t.memoizedState:ro.next)===null&&(t=t.alternate,P.H=t===null||t.memoizedState===null?js:Ms),e}function To(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return wo(e);if(e.$$typeof===x)return Ui(e)}throw Error(i(438,String(e)))}function Eo(e){var t=null,n=to.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=to.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Co(),to.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=O;return t.index++,n}function Do(e,t){return typeof t==`function`?t(e):t}function Oo(e){return ko(So(),no,e)}function ko(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(eo&f)===f:(Il&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===ea&&(d=!0);else if((eo&p)===p){u=u.next,p===ea&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,to.lanes|=p,Wl|=p;f=u.action,oo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,to.lanes|=f,Wl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!lr(o,e.memoizedState)&&(Ys=!0,d&&(n=ta,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Ao(e){var t=So(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);lr(o,t.memoizedState)||(Ys=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function jo(e,t,n){var r=to,a=So(),o=Si;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!lr((no||a).memoizedState,n);if(s&&(a.memoizedState=n,Ys=!0),a=a.queue,ns(Po.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||ro!==null&&ro.memoizedState.tag&1){if(r.flags|=2048,Zo(9,{destroy:void 0},No.bind(null,r,a,n,t),null),Pl===null)throw Error(i(349));o||eo&127||Mo(r,t,n)}return n}function Mo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=to.updateQueue,t===null?(t=Co(),to.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function No(e,t,n,r){t.value=n,t.getSnapshot=r,Fo(t)&&Io(e)}function Po(e,t,n){return n(function(){Fo(t)&&Io(e)})}function Fo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!lr(e,n)}catch{return!0}}function Io(e){var t=Wr(e,2);t!==null&&mu(t,e,2)}function Lo(e){var t=xo();if(typeof e==`function`){var n=e;if(e=n(),oo){De(!0);try{n()}finally{De(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:e},t}function Ro(e,t,n,r){return e.baseState=n,ko(e,no,typeof r==`function`?r:Do)}function zo(e,t,n,r,a){if(Ds(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};P.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Bo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Bo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=P.T,o={};P.T=o;try{var s=n(i,r),c=P.S;c!==null&&c(o,s),Vo(e,t,s)}catch(n){Uo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),P.T=a}}else try{a=n(i,r),Vo(e,t,a)}catch(n){Uo(e,t,n)}}function Vo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Ho(e,t,n)},function(n){return Uo(e,t,n)}):Ho(e,t,n)}function Ho(e,t,n){t.status=`fulfilled`,t.value=n,Wo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Bo(e,n)))}function Uo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Wo(t),t=t.next;while(t!==r)}e.action=null}function Wo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Go(e,t){return t}function Ko(e,t){if(Si){var n=Pl.formState;if(n!==null){a:{var r=to;if(Si){if(xi){b:{for(var i=xi,a=wi;i.nodeType!==8;){if(!a){i=null;break b}if(i=lf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){xi=lf(i.nextSibling),r=i.data===`F!`;break a}}Ei(r)}r=!1}r&&(t=n[0])}}return n=xo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Go,lastRenderedState:t},n.queue=r,n=ws.bind(null,to,r),r.dispatch=n,r=Lo(!1),a=Es.bind(null,to,!1,r.queue),r=xo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=zo.bind(null,to,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function qo(e){return Jo(So(),no,e)}function Jo(e,t,n){if(t=ko(e,t,Go)[0],e=Oo(Do)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=wo(t)}catch(e){throw e===ua?fa:e}else r=t;t=So();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(to.flags|=2048,Zo(9,{destroy:void 0},Yo.bind(null,i,n),null)),[r,a,e]}function Yo(e,t){e.action=t}function Xo(e){var t=So(),n=no;if(n!==null)return Jo(t,n,e);So(),t=t.memoizedState,n=So();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Zo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=to.updateQueue,t===null&&(t=Co(),to.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Qo(){return So().memoizedState}function $o(e,t,n,r){var i=xo();to.flags|=e,i.memoizedState=Zo(1|t,{destroy:void 0},n,r===void 0?null:r)}function es(e,t,n,r){var i=So();r=r===void 0?null:r;var a=i.memoizedState.inst;no!==null&&r!==null&&po(r,no.memoizedState.deps)?i.memoizedState=Zo(t,a,n,r):(to.flags|=e,i.memoizedState=Zo(1|t,a,n,r))}function ts(e,t){$o(8390656,8,e,t)}function ns(e,t){es(2048,8,e,t)}function rs(e){to.flags|=4;var t=to.updateQueue;if(t===null)t=Co(),to.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function is(e){var t=So().memoizedState;return rs({ref:t,nextImpl:e}),function(){if(Nl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function as(e,t){return es(4,2,e,t)}function os(e,t){return es(4,4,e,t)}function ss(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function cs(e,t,n){n=n==null?null:n.concat([e]),es(4,4,ss.bind(null,t,e),n)}function ls(){}function us(e,t){var n=So();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&po(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ds(e,t){var n=So();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&po(t,r[1]))return r[0];if(r=e(),oo){De(!0);try{e()}finally{De(!1)}}return n.memoizedState=[r,t],r}function fs(e,t,n){return n===void 0||eo&1073741824&&!(Il&261930)?e.memoizedState=t:(e.memoizedState=n,e=pu(),to.lanes|=e,Wl|=e,n)}function ps(e,t,n,r){return lr(n,t)?n:Ba.current===null?!(eo&42)||eo&1073741824&&!(Il&261930)?(Ys=!0,e.memoizedState=n):(e=pu(),to.lanes|=e,Wl|=e,t):(e=fs(e,n,r),lr(e,t)||(Ys=!0),e)}function ms(e,t,n,r,i){var a=F.p;F.p=a!==0&&8>a?a:8;var o=P.T,s={};P.T=s,Es(e,!1,t,n);try{var c=i(),l=P.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ts(e,t,ia(c,r),fu(e)):Ts(e,t,r,fu(e))}catch(n){Ts(e,t,{then:function(){},status:`rejected`,reason:n},fu())}finally{F.p=a,o!==null&&s.types!==null&&(o.types=s.types),P.T=o}}function hs(){}function gs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=_s(e).queue;ms(e,a,t,I,n===null?hs:function(){return vs(e),n(r)})}function _s(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:I},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function vs(e){var t=_s(e);t.next===null&&(t=e.alternate.memoizedState),Ts(e,t.next.queue,{},fu())}function ys(){return Ui($f)}function bs(){return So().memoizedState}function xs(){return So().memoizedState}function Ss(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=fu();e=ja(n);var r=Ma(t,e,n);r!==null&&(mu(r,t,n),Na(r,t,n)),t={cache:Xi()},e.payload=t;return}t=t.return}}function Cs(e,t,n){var r=fu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ds(e)?Os(t,n):(n=Ur(e,t,n,r),n!==null&&(mu(n,e,r),ks(n,t,r)))}function ws(e,t,n){Ts(e,t,n,fu())}function Ts(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ds(e))Os(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,lr(s,o))return Hr(e,t,i,0),Pl===null&&Vr(),!1}catch{}if(n=Ur(e,t,i,r),n!==null)return mu(n,e,r),ks(n,t,r),!0}return!1}function Es(e,t,n,r){if(r={lane:2,revertLane:dd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ds(e)){if(t)throw Error(i(479))}else t=Ur(e,n,r,2),t!==null&&mu(t,e,2)}function Ds(e){var t=e.alternate;return e===to||t!==null&&t===to}function Os(e,t){ao=io=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ks(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,He(e,n)}}var As={readContext:Ui,use:To,useCallback:fo,useContext:fo,useEffect:fo,useImperativeHandle:fo,useLayoutEffect:fo,useInsertionEffect:fo,useMemo:fo,useReducer:fo,useRef:fo,useState:fo,useDebugValue:fo,useDeferredValue:fo,useTransition:fo,useSyncExternalStore:fo,useId:fo,useHostTransitionStatus:fo,useFormState:fo,useActionState:fo,useOptimistic:fo,useMemoCache:fo,useCacheRefresh:fo};As.useEffectEvent=fo;var js={readContext:Ui,use:To,useCallback:function(e,t){return xo().memoizedState=[e,t===void 0?null:t],e},useContext:Ui,useEffect:ts,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),$o(4194308,4,ss.bind(null,t,e),n)},useLayoutEffect:function(e,t){return $o(4194308,4,e,t)},useInsertionEffect:function(e,t){$o(4,2,e,t)},useMemo:function(e,t){var n=xo();t=t===void 0?null:t;var r=e();if(oo){De(!0);try{e()}finally{De(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=xo();if(n!==void 0){var i=n(t);if(oo){De(!0);try{n(t)}finally{De(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Cs.bind(null,to,e),[r.memoizedState,e]},useRef:function(e){var t=xo();return e={current:e},t.memoizedState=e},useState:function(e){e=Lo(e);var t=e.queue,n=ws.bind(null,to,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ls,useDeferredValue:function(e,t){return fs(xo(),e,t)},useTransition:function(){var e=Lo(!1);return e=ms.bind(null,to,e.queue,!0,!1),xo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=to,a=xo();if(Si){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Pl===null)throw Error(i(349));Il&127||Mo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ts(Po.bind(null,r,o,e),[e]),r.flags|=2048,Zo(9,{destroy:void 0},No.bind(null,r,o,n,t),null),n},useId:function(){var e=xo(),t=Pl.identifierPrefix;if(Si){var n=mi,r=pi;n=(r&~(1<<32-Oe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=so++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=uo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:ys,useFormState:Ko,useActionState:Ko,useOptimistic:function(e){var t=xo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Es.bind(null,to,!0,n),n.dispatch=t,[e,t]},useMemoCache:Eo,useCacheRefresh:function(){return xo().memoizedState=Ss.bind(null,to)},useEffectEvent:function(e){var t=xo(),n={impl:e};return t.memoizedState=n,function(){if(Nl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Ms={readContext:Ui,use:To,useCallback:us,useContext:Ui,useEffect:ns,useImperativeHandle:cs,useInsertionEffect:as,useLayoutEffect:os,useMemo:ds,useReducer:Oo,useRef:Qo,useState:function(){return Oo(Do)},useDebugValue:ls,useDeferredValue:function(e,t){return ps(So(),no.memoizedState,e,t)},useTransition:function(){var e=Oo(Do)[0],t=So().memoizedState;return[typeof e==`boolean`?e:wo(e),t]},useSyncExternalStore:jo,useId:bs,useHostTransitionStatus:ys,useFormState:qo,useActionState:qo,useOptimistic:function(e,t){return Ro(So(),no,e,t)},useMemoCache:Eo,useCacheRefresh:xs};Ms.useEffectEvent=is;var Ns={readContext:Ui,use:To,useCallback:us,useContext:Ui,useEffect:ns,useImperativeHandle:cs,useInsertionEffect:as,useLayoutEffect:os,useMemo:ds,useReducer:Ao,useRef:Qo,useState:function(){return Ao(Do)},useDebugValue:ls,useDeferredValue:function(e,t){var n=So();return no===null?fs(n,e,t):ps(n,no.memoizedState,e,t)},useTransition:function(){var e=Ao(Do)[0],t=So().memoizedState;return[typeof e==`boolean`?e:wo(e),t]},useSyncExternalStore:jo,useId:bs,useHostTransitionStatus:ys,useFormState:Xo,useActionState:Xo,useOptimistic:function(e,t){var n=So();return no===null?(n.baseState=e,[e,n.queue.dispatch]):Ro(n,no,e,t)},useMemoCache:Eo,useCacheRefresh:xs};Ns.useEffectEvent=is;function Ps(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:p({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Fs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=fu(),i=ja(r);i.payload=t,n!=null&&(i.callback=n),t=Ma(e,i,r),t!==null&&(mu(t,e,r),Na(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=fu(),i=ja(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ma(e,i,r),t!==null&&(mu(t,e,r),Na(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=fu(),r=ja(n);r.tag=2,t!=null&&(r.callback=t),t=Ma(e,r,n),t!==null&&(mu(t,e,n),Na(t,e,n))}};function Is(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!ur(n,r)||!ur(i,a):!0}function Ls(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Fs.enqueueReplaceState(t,t.state,null)}function Rs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=p({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function zs(e){Lr(e)}function Bs(e){console.error(e)}function Vs(e){Lr(e)}function Hs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Us(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ws(e,t,n){return n=ja(n),n.tag=3,n.payload={element:null},n.callback=function(){Hs(e,t)},n}function Gs(e){return e=ja(e),e.tag=3,e}function Ks(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Us(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Us(t,n,r),typeof i!=`function`&&(nu===null?nu=new Set([this]):nu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function qs(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Bi(t,n,a,!0),n=Ga.current,n!==null){switch(n.tag){case 31:case 13:return Ka===null?Eu():n.alternate===null&&Ul===0&&(Ul=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===pa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Gu(e,r,a)),!1;case 22:return n.flags|=65536,r===pa?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Gu(e,r,a)),!1}throw Error(i(435,n.tag))}return Gu(e,r,a),Eu(),!1}if(Si)return t=Ga.current,t===null?(r!==Ti&&(t=Error(i(423),{cause:r}),Mi(ai(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=ai(r,n),a=Ws(e.stateNode,r,a),Pa(e,a),Ul!==4&&(Ul=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ti&&(e=Error(i(422),{cause:r}),Mi(ai(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=ai(o,n),Yl===null?Yl=[o]:Yl.push(o),Ul!==4&&(Ul=2),t===null)return!0;r=ai(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Ws(n.stateNode,r,e),Pa(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(nu===null||!nu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Gs(a),Ks(a,e,n,r),Pa(n,a),!1}n=n.return}while(n!==null);return!1}var Js=Error(i(461)),Ys=!1;function Xs(e,t,n,r){t.child=e===null?Da(t,null,n,r):Ea(t,e.child,n,r)}function Zs(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Hi(t),r=mo(e,t,n,o,a,i),s=vo(),e!==null&&!Ys?(yo(e,t,i),xc(e,t,i)):(Si&&s&&_i(t),t.flags|=1,Xs(e,t,r,i),t.child)}function Qs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Xr(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,$s(e,t,a,r,i)):(e=$r(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Sc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?ur:n,n(o,r)&&e.ref===t.ref)return xc(e,t,i)}return t.flags|=1,e=Zr(a,r),e.ref=t.ref,e.return=t,t.child=e}function $s(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(ur(a,r)&&e.ref===t.ref)if(Ys=!1,t.pendingProps=r=a,Sc(e,i))e.flags&131072&&(Ys=!0);else return t.lanes=e.lanes,xc(e,t,i)}return sc(e,t,n,r,i)}function ec(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return nc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ca(t,a===null?null:a.cachePool),a===null?Ua():Ha(t,a),Ya(t);else return r=t.lanes=536870912,nc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ca(t,null),Ua(),Xa(t)):(ca(t,a.cachePool),Ha(t,a),Xa(t),t.memoizedState=null);return Xs(e,t,i,n),t.child}function tc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function nc(e,t,n,r,i){var a=sa();return a=a===null?null:{parent:Yi._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ca(t,null),Ua(),Ya(t),e!==null&&Bi(e,t,r,!0),t.childLanes=i,null}function rc(e,t){return t=gc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function ic(e,t,n){return Ea(t,e.child,null,n),e=rc(t,t.pendingProps),e.flags|=2,Za(t),t.memoizedState=null,e}function ac(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Si){if(r.mode===`hidden`)return e=rc(t,r),t.lanes=536870912,tc(null,e);if(Ja(t),(e=xi)?(e=af(e,wi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:fi===null?null:{id:pi,overflow:mi},retryLane:536870912,hydrationErrors:null},n=ni(e),n.return=t,t.child=n,bi=t,xi=null)):e=null,e===null)throw Ei(t);return t.lanes=536870912,null}return rc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Ja(t),a)if(t.flags&256)t.flags&=-257,t=ic(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(Ys||Bi(e,t,n,!1),a=(n&e.childLanes)!==0,Ys||a){if(r=Pl,r!==null&&(s=Ue(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Wr(e,s),mu(r,e,s),Js;Eu(),t=ic(e,t,n)}else e=o.treeContext,xi=lf(s.nextSibling),bi=t,Si=!0,Ci=null,wi=!1,e!==null&&yi(t,e),t=rc(t,r),t.flags|=4096;return t}return e=Zr(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function oc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function sc(e,t,n,r,i){return Hi(t),n=mo(e,t,n,r,void 0,i),r=vo(),e!==null&&!Ys?(yo(e,t,i),xc(e,t,i)):(Si&&r&&_i(t),t.flags|=1,Xs(e,t,n,i),t.child)}function cc(e,t,n,r,i,a){return Hi(t),t.updateQueue=null,n=go(t,r,n,i),ho(e),r=vo(),e!==null&&!Ys?(yo(e,t,a),xc(e,t,a)):(Si&&r&&_i(t),t.flags|=1,Xs(e,t,n,a),t.child)}function lc(e,t,n,r,i){if(Hi(t),t.stateNode===null){var a=qr,o=n.contextType;typeof o==`object`&&o&&(a=Ui(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Fs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},ka(t),o=n.contextType,a.context=typeof o==`object`&&o?Ui(o):qr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ps(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Fs.enqueueReplaceState(a,a.state,null),La(t,r,a,i),Ia(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Rs(n,s);a.props=c;var l=a.context,u=n.contextType;o=qr,typeof u==`object`&&u&&(o=Ui(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Ls(t,a,r,o),Oa=!1;var f=t.memoizedState;a.state=f,La(t,r,a,i),Ia(),l=t.memoizedState,s||f!==l||Oa?(typeof d==`function`&&(Ps(t,n,d,r),l=t.memoizedState),(c=Oa||Is(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Aa(e,t),o=t.memoizedProps,u=Rs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=qr,typeof l==`object`&&l&&(c=Ui(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Ls(t,a,r,c),Oa=!1,f=t.memoizedState,a.state=f,La(t,r,a,i),Ia();var p=t.memoizedState;o!==d||f!==p||Oa||e!==null&&e.dependencies!==null&&Vi(e.dependencies)?(typeof s==`function`&&(Ps(t,n,s,r),p=t.memoizedState),(u=Oa||Is(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Vi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,oc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Ea(t,e.child,null,i),t.child=Ea(t,null,n,i)):Xs(e,t,n,i),t.memoizedState=a.state,e=t.child):e=xc(e,t,i),e}function uc(e,t,n,r){return Ai(),t.flags|=256,Xs(e,t,n,r),t.child}var dc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function fc(e){return{baseLanes:e,cachePool:la()}}function pc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=ql),e}function mc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(Qa.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Si){if(a?qa(t):Xa(t),(e=xi)?(e=af(e,wi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:fi===null?null:{id:pi,overflow:mi},retryLane:536870912,hydrationErrors:null},n=ni(e),n.return=t,t.child=n,bi=t,xi=null)):e=null,e===null)throw Ei(t);return sf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Xa(t),a=t.mode,c=gc({mode:`hidden`,children:c},a),r=ei(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=fc(n),r.childLanes=pc(e,s,n),t.memoizedState=dc,tc(null,r)):(qa(t),hc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(qa(t),t.flags&=-257,t=_c(e,t,n)):t.memoizedState===null?(Xa(t),c=r.fallback,a=t.mode,r=gc({mode:`visible`,children:r.children},a),c=ei(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Ea(t,e.child,null,n),r=t.child,r.memoizedState=fc(n),r.childLanes=pc(e,s,n),t.memoizedState=dc,t=tc(null,r)):(Xa(t),t.child=e.child,t.flags|=128,t=null);else if(qa(t),sf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Mi({value:r,source:null,stack:null}),t=_c(e,t,n)}else if(Ys||Bi(e,t,n,!1),s=(n&e.childLanes)!==0,Ys||s){if(s=Pl,s!==null&&(r=Ue(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Wr(e,r),mu(s,e,r),Js;of(c)||Eu(),t=_c(e,t,n)}else of(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,xi=lf(c.nextSibling),bi=t,Si=!0,Ci=null,wi=!1,e!==null&&yi(t,e),t=hc(t,r.children),t.flags|=4096);return t}return a?(Xa(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=Zr(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=ei(c,a,n,null),c.flags|=2):c=Zr(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,tc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=fc(n):(a=c.cachePool,a===null?a=la():(l=Yi._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=pc(e,s,n),t.memoizedState=dc,tc(e.child,r)):(qa(t),n=e.child,e=n.sibling,n=Zr(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function hc(e,t){return t=gc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function gc(e,t){return e=Yr(22,e,null,t),e.lanes=0,e}function _c(e,t,n){return Ea(t,e.child,null,n),e=hc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function vc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ri(e.return,t,n)}function yc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function bc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Qa.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,V(Qa,o),Xs(e,t,r,n),r=Si?li:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&vc(e,n,t);else if(e.tag===19)vc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&$a(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),yc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&$a(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}yc(t,!0,n,null,a,r);break;case`together`:yc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function xc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Wl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Bi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Zr(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Zr(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Sc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Vi(e))):!0}function Cc(e,t,n){switch(t.tag){case 3:re(t,t.stateNode.containerInfo),Ii(t,Yi,e.memoizedState.cache),Ai();break;case 27:case 5:ae(t);break;case 4:re(t,t.stateNode.containerInfo);break;case 10:Ii(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ja(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(qa(t),e=xc(e,t,n),e===null?null:e.sibling):mc(e,t,n):(qa(t),t.flags|=128,null);qa(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Bi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return bc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),V(Qa,Qa.current),r)break;return null;case 22:return t.lanes=0,ec(e,t,n,t.pendingProps);case 24:Ii(t,Yi,e.memoizedState.cache)}return xc(e,t,n)}function wc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Ys=!0;else{if(!Sc(e,n)&&!(t.flags&128))return Ys=!1,Cc(e,t,n);Ys=!!(e.flags&131072)}else Ys=!1,Si&&t.flags&1048576&&gi(t,li,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=ga(t.elementType),t.type=e,typeof e==`function`)Xr(e)?(r=Rs(e,r),t.tag=1,t=lc(null,t,e,r,n)):(t.tag=0,t=sc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===S){t.tag=11,t=Zs(null,t,e,r,n);break a}else if(a===T){t.tag=14,t=Qs(null,t,e,r,n);break a}}throw t=M(e)||e,Error(i(306,t,``))}}return t;case 0:return sc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Rs(r,t.pendingProps),lc(e,t,r,a,n);case 3:a:{if(re(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Aa(e,t),La(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Ii(t,Yi,r),r!==o.cache&&zi(t,[Yi],n,!0),Ia(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=uc(e,t,r,n);break a}else if(r!==a){a=ai(Error(i(424)),t),Mi(a),t=uc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(xi=lf(e.firstChild),bi=t,Si=!0,Ci=null,wi=!0,n=Da(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ai(),r===a){t=xc(e,t,n);break a}Xs(e,t,r,n)}t=t.child}return t;case 26:return oc(e,t),e===null?(n=Af(t.type,null,t.pendingProps,null))?t.memoizedState=n:Si||(n=t.type,e=t.pendingProps,r=Vd(ne.current).createElement(n),r[Ye]=t,r[Xe]=e,Fd(r,n,e),ct(r),t.stateNode=r):t.memoizedState=Af(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ae(t),e===null&&Si&&(r=t.stateNode=pf(t.type,t.pendingProps,ne.current),bi=t,wi=!0,a=xi,Qd(t.type)?(uf=a,xi=lf(r.firstChild)):xi=a),Xs(e,t,t.pendingProps.children,n),oc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Si&&((a=r=xi)&&(r=nf(r,t.type,t.pendingProps,wi),r===null?a=!1:(t.stateNode=r,bi=t,xi=lf(r.firstChild),wi=!1,a=!0)),a||Ei(t)),ae(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Wd(a,o)?r=null:s!==null&&Wd(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=mo(e,t,_o,null,null,n),$f._currentValue=a),oc(e,t),Xs(e,t,r,n),t.child;case 6:return e===null&&Si&&((e=n=xi)&&(n=rf(n,t.pendingProps,wi),n===null?e=!1:(t.stateNode=n,bi=t,xi=null,e=!0)),e||Ei(t)),null;case 13:return mc(e,t,n);case 4:return re(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ea(t,null,r,n):Xs(e,t,r,n),t.child;case 11:return Zs(e,t,t.type,t.pendingProps,n);case 7:return Xs(e,t,t.pendingProps,n),t.child;case 8:return Xs(e,t,t.pendingProps.children,n),t.child;case 12:return Xs(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Ii(t,t.type,r.value),Xs(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Hi(t),a=Ui(a),r=r(a),t.flags|=1,Xs(e,t,r,n),t.child;case 14:return Qs(e,t,t.type,t.pendingProps,n);case 15:return $s(e,t,t.type,t.pendingProps,n);case 19:return bc(e,t,n);case 31:return ac(e,t,n);case 22:return ec(e,t,n,t.pendingProps);case 24:return Hi(t),r=Ui(Yi),e===null?(a=sa(),a===null&&(a=Pl,o=Xi(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},ka(t),Ii(t,Yi,a)):((e.lanes&n)!==0&&(Aa(e,t),La(t,null,null,n),Ia()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Ii(t,Yi,r),r!==a.cache&&zi(t,[Yi],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ii(t,Yi,r))),Xs(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Tc(e){e.flags|=4}function Ec(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Cu())e.flags|=8192;else throw _a=pa,da}else e.flags&=-16777217}function Dc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Gf(t))if(Cu())e.flags|=8192;else throw _a=pa,da}function Oc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:q(),e.lanes|=t,Jl|=t)}function kc(e,t){if(!Si)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ac(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function jc(e,t,n){var r=t.pendingProps;switch(vi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ac(t),null;case 1:return Ac(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Li(Yi),ie(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ki(t)?Tc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ji())),Ac(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Tc(t),o===null?(Ac(t),Ec(t,a,null,r,n)):(Ac(t),Dc(t,o))):o?o===e.memoizedState?(Ac(t),t.flags&=-16777217):(Tc(t),Ac(t),Dc(t,o)):(e=e.memoizedProps,e!==r&&Tc(t),Ac(t),Ec(t,a,e,r,n)),null;case 27:if(oe(t),n=ne.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ac(t),null}e=ee.current,ki(t)?Di(t,e):(e=pf(a,r,n),t.stateNode=e,Tc(t))}return Ac(t),null;case 5:if(oe(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ac(t),null}if(o=ee.current,ki(t))Di(t,o);else{var s=Vd(ne.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Ye]=t,o[Xe]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Fd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Tc(t)}}return Ac(t),Ec(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ne.current,ki(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=bi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Ye]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Md(e.nodeValue,n)),e||Ei(t,!0)}else e=Vd(e).createTextNode(r),e[Ye]=t,t.stateNode=e}return Ac(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ki(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Ye]=t}else Ai(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ac(t),e=!1}else n=ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Za(t),t):(Za(t),null);if(t.flags&128)throw Error(i(558))}return Ac(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ki(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Ye]=t}else Ai(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ac(t),a=!1}else a=ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Za(t),t):(Za(t),null)}return Za(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Oc(t,t.updateQueue),Ac(t),null);case 4:return ie(),e===null&&Sd(t.stateNode.containerInfo),Ac(t),null;case 10:return Li(t.type),Ac(t),null;case 19:if(B(Qa),r=t.memoizedState,r===null)return Ac(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)kc(r,!1);else{if(Ul!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=$a(e),o!==null){for(t.flags|=128,kc(r,!1),e=o.updateQueue,t.updateQueue=e,Oc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Qr(n,e),n=n.sibling;return V(Qa,Qa.current&1|2),Si&&hi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&_e()>eu&&(t.flags|=128,a=!0,kc(r,!1),t.lanes=4194304)}else{if(!a)if(e=$a(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Oc(t,e),kc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Si)return Ac(t),null}else 2*_e()-r.renderingStartTime>eu&&n!==536870912&&(t.flags|=128,a=!0,kc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Ac(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=_e(),e.sibling=null,n=Qa.current,V(Qa,a?n&1|2:n&1),Si&&hi(t,r.treeForkCount),e);case 22:case 23:return Za(t),Wa(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Ac(t),t.subtreeFlags&6&&(t.flags|=8192)):Ac(t),n=t.updateQueue,n!==null&&Oc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&B(oa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Li(Yi),Ac(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Mc(e,t){switch(vi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Li(Yi),ie(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return oe(t),null;case 31:if(t.memoizedState!==null){if(Za(t),t.alternate===null)throw Error(i(340));Ai()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Za(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ai()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(Qa),null;case 4:return ie(),null;case 10:return Li(t.type),null;case 22:case 23:return Za(t),Wa(),e!==null&&B(oa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Li(Yi),null;case 25:return null;default:return null}}function Nc(e,t){switch(vi(t),t.tag){case 3:Li(Yi),ie();break;case 26:case 27:case 5:oe(t);break;case 4:ie();break;case 31:t.memoizedState!==null&&Za(t);break;case 13:Za(t);break;case 19:B(Qa);break;case 10:Li(t.type);break;case 22:case 23:Za(t),Wa(),e!==null&&B(oa);break;case 24:Li(Yi)}}function Pc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Wu(t,t.return,e)}}function Fc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Wu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Wu(t,t.return,e)}}function Ic(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{za(t,n)}catch(t){Wu(e,e.return,t)}}}function Lc(e,t,n){n.props=Rs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Wu(e,t,n)}}function Rc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Wu(e,t,n)}}function zc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Wu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Wu(e,t,n)}else n.current=null}function Bc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Wu(e,e.return,t)}}function Vc(e,t,n){try{var r=e.stateNode;Id(r,e.type,n,t),r[Xe]=t}catch(t){Wu(e,e.return,t)}}function Hc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Qd(e.type)||e.tag===4}function Uc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Hc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Qd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Wc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Bt));else if(r!==4&&(r===27&&Qd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Wc(e,t,n),e=e.sibling;e!==null;)Wc(e,t,n),e=e.sibling}function Gc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Qd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Gc(e,t,n),e=e.sibling;e!==null;)Gc(e,t,n),e=e.sibling}function Kc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Fd(t,r,n),t[Ye]=e,t[Xe]=n}catch(t){Wu(e,e.return,t)}}var qc=!1,Jc=!1,Yc=!1,Xc=typeof WeakSet==`function`?WeakSet:Set,Zc=null;function Qc(e,t){if(e=e.containerInfo,zd=cp,e=mr(e),hr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Bd={focusedElem:e,selectionRange:n},cp=!1,Zc=t;Zc!==null;)if(t=Zc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Zc=e;else for(;Zc!==null;){switch(t=Zc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Rs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Wu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)tf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:tf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,Zc=e;break}Zc=t.return}}function $c(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ml(e,n),r&4&&Pc(5,n);break;case 1:if(ml(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Wu(n,n.return,e)}else{var i=Rs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Wu(n,n.return,e)}}r&64&&Ic(n),r&512&&Rc(n,n.return);break;case 3:if(ml(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{za(e,t)}catch(e){Wu(n,n.return,e)}}break;case 27:t===null&&r&4&&Kc(n);case 26:case 5:ml(e,n),t===null&&r&4&&Bc(n),r&512&&Rc(n,n.return);break;case 12:ml(e,n);break;case 31:ml(e,n),r&4&&al(e,n);break;case 13:ml(e,n),r&4&&ol(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Ju.bind(null,n),cf(e,n))));break;case 22:if(r=n.memoizedState!==null||qc,!r){t=t!==null&&t.memoizedState!==null||Jc,i=qc;var a=Jc;qc=r,(Jc=t)&&!a?gl(e,n,(n.subtreeFlags&8772)!=0):ml(e,n),qc=i,Jc=a}break;case 30:break;default:ml(e,n)}}function el(e){var t=e.alternate;t!==null&&(e.alternate=null,el(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&rt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var tl=null,nl=!1;function rl(e,t,n){for(n=n.child;n!==null;)il(e,t,n),n=n.sibling}function il(e,t,n){if(Ee&&typeof Ee.onCommitFiberUnmount==`function`)try{Ee.onCommitFiberUnmount(Te,n)}catch{}switch(n.tag){case 26:Jc||zc(n,t),rl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Jc||zc(n,t);var r=tl,i=nl;Qd(n.type)&&(tl=n.stateNode,nl=!1),rl(e,t,n),mf(n.stateNode),tl=r,nl=i;break;case 5:Jc||zc(n,t);case 6:if(r=tl,i=nl,tl=null,rl(e,t,n),tl=r,nl=i,tl!==null)if(nl)try{(tl.nodeType===9?tl.body:tl.nodeName===`HTML`?tl.ownerDocument.body:tl).removeChild(n.stateNode)}catch(e){Wu(n,t,e)}else try{tl.removeChild(n.stateNode)}catch(e){Wu(n,t,e)}break;case 18:tl!==null&&(nl?(e=tl,$d(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Pp(e)):$d(tl,n.stateNode));break;case 4:r=tl,i=nl,tl=n.stateNode.containerInfo,nl=!0,rl(e,t,n),tl=r,nl=i;break;case 0:case 11:case 14:case 15:Fc(2,n,t),Jc||Fc(4,n,t),rl(e,t,n);break;case 1:Jc||(zc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Lc(n,t,r)),rl(e,t,n);break;case 21:rl(e,t,n);break;case 22:Jc=(r=Jc)||n.memoizedState!==null,rl(e,t,n),Jc=r;break;default:rl(e,t,n)}}function al(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Pp(e)}catch(e){Wu(t,t.return,e)}}}function ol(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Pp(e)}catch(e){Wu(t,t.return,e)}}function sl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Xc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Xc),t;default:throw Error(i(435,e.tag))}}function cl(e,t){var n=sl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Yu.bind(null,e,t);t.then(r,r)}})}function ll(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(Qd(c.type)){tl=c.stateNode,nl=!1;break a}break;case 5:tl=c.stateNode,nl=!1;break a;case 3:case 4:tl=c.stateNode.containerInfo,nl=!0;break a}c=c.return}if(tl===null)throw Error(i(160));il(o,s,a),tl=null,nl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)dl(t,e),t=t.sibling}var ul=null;function dl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ll(t,e),fl(e),r&4&&(Fc(3,e,e.return),Pc(3,e),Fc(5,e,e.return));break;case 1:ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),r&64&&qc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=ul;if(ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[nt]||o[Ye]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Fd(o,r,n),o[Ye]=e,ct(o),r=o;break a;case`link`:var s=Hf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Fd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Hf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Fd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[Ye]=e,ct(o),r=o}e.stateNode=r}else Uf(a,e.type,e.stateNode);else e.stateNode=Lf(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Vc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Uf(a,e.type,e.stateNode):Lf(a,r,e.memoizedProps))}break;case 27:ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),n!==null&&r&4&&Vc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),e.flags&32){a=e.stateNode;try{Mt(a,``)}catch(t){Wu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Vc(e,a,n===null?a:n.memoizedProps)),r&1024&&(Yc=!0);break;case 6:if(ll(t,e),fl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Wu(e,e.return,t)}}break;case 3:if(Vf=null,a=ul,ul=_f(t.containerInfo),ll(t,e),ul=a,fl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Pp(t.containerInfo)}catch(t){Wu(e,e.return,t)}Yc&&(Yc=!1,pl(e));break;case 4:r=ul,ul=_f(e.stateNode.containerInfo),ll(t,e),fl(e),ul=r;break;case 12:ll(t,e),fl(e);break;case 31:ll(t,e),fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 13:ll(t,e),fl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Ql=_e()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=qc,d=Jc;if(qc=u||a,Jc=d||l,ll(t,e),Jc=d,qc=u,fl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||qc||Jc||hl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Wu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Wu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?ef(m,!0):ef(l.stateNode,!1)}catch(e){Wu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,cl(e,n))));break;case 19:ll(t,e),fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 30:break;case 21:break;default:ll(t,e),fl(e)}}function fl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Hc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Gc(e,Uc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Mt(o,``),n.flags&=-33),Gc(e,Uc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Wc(e,Uc(e),s);break;default:throw Error(i(161))}}catch(t){Wu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function pl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;pl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function ml(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)$c(e,t.alternate,t),t=t.sibling}function hl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Fc(4,t,t.return),hl(t);break;case 1:zc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Lc(t,t.return,n),hl(t);break;case 27:mf(t.stateNode);case 26:case 5:zc(t,t.return),hl(t);break;case 22:t.memoizedState===null&&hl(t);break;case 30:hl(t);break;default:hl(t)}e=e.sibling}}function gl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:gl(i,a,n),Pc(4,a);break;case 1:if(gl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Wu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ra(c[i],s)}catch(e){Wu(r,r.return,e)}}n&&o&64&&Ic(a),Rc(a,a.return);break;case 27:Kc(a);case 26:case 5:gl(i,a,n),n&&r===null&&o&4&&Bc(a),Rc(a,a.return);break;case 12:gl(i,a,n);break;case 31:gl(i,a,n),n&&o&4&&al(i,a);break;case 13:gl(i,a,n),n&&o&4&&ol(i,a);break;case 22:a.memoizedState===null&&gl(i,a,n),Rc(a,a.return);break;case 30:break;default:gl(i,a,n)}t=t.sibling}}function _l(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Zi(n))}function vl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Zi(e))}function yl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)bl(e,t,n,r),t=t.sibling}function bl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:yl(e,t,n,r),i&2048&&Pc(9,t);break;case 1:yl(e,t,n,r);break;case 3:yl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Zi(e)));break;case 12:if(i&2048){yl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Wu(t,t.return,e)}}else yl(e,t,n,r);break;case 31:yl(e,t,n,r);break;case 13:yl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?yl(e,t,n,r):(a._visibility|=2,xl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?yl(e,t,n,r):Sl(e,t),i&2048&&_l(o,t);break;case 24:yl(e,t,n,r),i&2048&&vl(t.alternate,t);break;default:yl(e,t,n,r)}}function xl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:xl(a,o,s,c,i),Pc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,xl(a,o,s,c,i)):u._visibility&2?xl(a,o,s,c,i):Sl(a,o),i&&l&2048&&_l(o.alternate,o);break;case 24:xl(a,o,s,c,i),i&&l&2048&&vl(o.alternate,o);break;default:xl(a,o,s,c,i)}t=t.sibling}}function Sl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Sl(n,r),i&2048&&_l(r.alternate,r);break;case 24:Sl(n,r),i&2048&&vl(r.alternate,r);break;default:Sl(n,r)}t=t.sibling}}var Cl=8192;function wl(e,t,n){if(e.subtreeFlags&Cl)for(e=e.child;e!==null;)Tl(e,t,n),e=e.sibling}function Tl(e,t,n){switch(e.tag){case 26:wl(e,t,n),e.flags&Cl&&e.memoizedState!==null&&Kf(n,ul,e.memoizedState,e.memoizedProps);break;case 5:wl(e,t,n);break;case 3:case 4:var r=ul;ul=_f(e.stateNode.containerInfo),wl(e,t,n),ul=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Cl,Cl=16777216,wl(e,t,n),Cl=r):wl(e,t,n));break;default:wl(e,t,n)}}function El(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Dl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Zc=r,Al(r,e)}El(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Ol(e),e=e.sibling}function Ol(e){switch(e.tag){case 0:case 11:case 15:Dl(e),e.flags&2048&&Fc(9,e,e.return);break;case 3:Dl(e);break;case 12:Dl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,kl(e)):Dl(e);break;default:Dl(e)}}function kl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Zc=r,Al(r,e)}El(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Fc(8,t,t.return),kl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,kl(t));break;default:kl(t)}e=e.sibling}}function Al(e,t){for(;Zc!==null;){var n=Zc;switch(n.tag){case 0:case 11:case 15:Fc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Zi(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Zc=r;else a:for(n=e;Zc!==null;){r=Zc;var i=r.sibling,a=r.return;if(el(r),r===n){Zc=null;break a}if(i!==null){i.return=a,Zc=i;break a}Zc=a}}}var jl={getCacheForType:function(e){var t=Ui(Yi),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ui(Yi).controller.signal}},Ml=typeof WeakMap==`function`?WeakMap:Map,Nl=0,Pl=null,Fl=null,Il=0,Ll=0,Rl=null,zl=!1,Bl=!1,Vl=!1,Hl=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=0,Jl=0,Yl=null,Xl=null,Zl=!1,Ql=0,$l=0,eu=1/0,tu=null,nu=null,ru=0,iu=null,au=null,ou=0,su=0,cu=null,lu=null,uu=0,du=null;function fu(){return Nl&2&&Il!==0?Il&-Il:P.T===null?Ke():dd()}function pu(){if(ql===0)if(!(Il&536870912)||Si){var e=Ne;Ne<<=1,!(Ne&3932160)&&(Ne=262144),ql=e}else ql=536870912;return e=Ga.current,e!==null&&(e.flags|=32),ql}function mu(e,t,n){(e===Pl&&(Ll===2||Ll===9)||e.cancelPendingCommit!==null)&&(xu(e,0),vu(e,Il,ql,!1)),J(e,n),(!(Nl&2)||e!==Pl)&&(e===Pl&&(!(Nl&2)&&(Gl|=n),Ul===4&&vu(e,Il,ql,!1)),rd(e))}function hu(e,t,n){if(Nl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Le(e,t),a=r?ku(e,t):Du(e,t,!0),o=r;do{if(a===0){Bl&&!r&&vu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!_u(n)){a=Du(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=Yl;var l=c.current.memoizedState.isDehydrated;if(l&&(xu(c,s).flags|=256),s=Du(c,s,!1),s!==2){if(Vl&&!l){c.errorRecoveryDisabledLanes|=o,Gl|=o,a=4;break a}o=Xl,Xl=a,o!==null&&(Xl===null?Xl=o:Xl.push.apply(Xl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){xu(e,0),vu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:vu(r,t,ql,!zl);break a;case 2:Xl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Ql+300-_e(),10<a)){if(vu(r,t,ql,!zl),Ie(r,0,!0)!==0)break a;ou=t,r.timeoutHandle=qd(gu.bind(null,r,n,Xl,tu,Zl,t,ql,Gl,Jl,zl,o,`Throttled`,-0,0),a);break a}gu(r,n,Xl,tu,Zl,t,ql,Gl,Jl,zl,o,null,-0,0)}}break}while(1);rd(e)}function gu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Bt},Tl(t,a,d);var m=(a&62914560)===a?Ql-_e():(a&4194048)===a?$l-_e():0;if(m=Jf(d,m),m!==null){ou=a,e.cancelPendingCommit=m(Iu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),vu(e,a,o,!l);return}}Iu(e,t,a,n,r,i,o,s,c)}function _u(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!lr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function vu(e,t,n,r){t&=~Kl,t&=~Gl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Oe(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Ve(e,n,t)}function yu(){return Nl&6?!0:(id(0,!1),!1)}function bu(){if(Fl!==null){if(Ll===0)var e=Fl.return;else e=Fl,Fi=Pi=null,bo(e),ba=null,xa=0,e=Fl;for(;e!==null;)Nc(e.alternate,e),e=e.return;Fl=null}}function xu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,Jd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),ou=0,bu(),Pl=e,Fl=n=Zr(e.current,null),Il=t,Ll=0,Rl=null,zl=!1,Bl=Le(e,t),Vl=!1,Jl=ql=Kl=Gl=Wl=Ul=0,Xl=Yl=null,Zl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Oe(r),a=1<<i;t|=e[i],r&=~a}return Hl=t,Vr(),n}function Su(e,t){to=null,P.H=As,t===ua||t===fa?(t=va(),Ll=3):t===da?(t=va(),Ll=4):Ll=t===Js?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Rl=t,Fl===null&&(Ul=1,Hs(e,ai(t,e.current)))}function Cu(){var e=Ga.current;return e===null?!0:(Il&4194048)===Il?Ka===null:(Il&62914560)===Il||Il&536870912?e===Ka:!1}function wu(){var e=P.H;return P.H=As,e===null?As:e}function Tu(){var e=P.A;return P.A=jl,e}function Eu(){Ul=4,zl||(Il&4194048)!==Il&&Ga.current!==null||(Bl=!0),!(Wl&134217727)&&!(Gl&134217727)||Pl===null||vu(Pl,Il,ql,!1)}function Du(e,t,n){var r=Nl;Nl|=2;var i=wu(),a=Tu();(Pl!==e||Il!==t)&&(tu=null,xu(e,t)),t=!1;var o=Ul;a:do try{if(Ll!==0&&Fl!==null){var s=Fl,c=Rl;switch(Ll){case 8:bu(),o=6;break a;case 3:case 2:case 9:case 6:Ga.current===null&&(t=!0);var l=Ll;if(Ll=0,Rl=null,Nu(e,s,c,l),n&&Bl){o=0;break a}break;default:l=Ll,Ll=0,Rl=null,Nu(e,s,c,l)}}Ou(),o=Ul;break}catch(t){Su(e,t)}while(1);return t&&e.shellSuspendCounter++,Fi=Pi=null,Nl=r,P.H=i,P.A=a,Fl===null&&(Pl=null,Il=0,Vr()),o}function Ou(){for(;Fl!==null;)ju(Fl)}function ku(e,t){var n=Nl;Nl|=2;var r=wu(),a=Tu();Pl!==e||Il!==t?(tu=null,eu=_e()+500,xu(e,t)):Bl=Le(e,t);a:do try{if(Ll!==0&&Fl!==null){t=Fl;var o=Rl;b:switch(Ll){case 1:Ll=0,Rl=null,Nu(e,t,o,1);break;case 2:case 9:if(ma(o)){Ll=0,Rl=null,Mu(t);break}t=function(){Ll!==2&&Ll!==9||Pl!==e||(Ll=7),rd(e)},o.then(t,t);break a;case 3:Ll=7;break a;case 4:Ll=5;break a;case 7:ma(o)?(Ll=0,Rl=null,Mu(t)):(Ll=0,Rl=null,Nu(e,t,o,7));break;case 5:var s=null;switch(Fl.tag){case 26:s=Fl.memoizedState;case 5:case 27:var c=Fl;if(s?Gf(s):c.stateNode.complete){Ll=0,Rl=null;var l=c.sibling;if(l!==null)Fl=l;else{var u=c.return;u===null?Fl=null:(Fl=u,Pu(u))}break b}}Ll=0,Rl=null,Nu(e,t,o,5);break;case 6:Ll=0,Rl=null,Nu(e,t,o,6);break;case 8:bu(),Ul=6;break a;default:throw Error(i(462))}}Au();break}catch(t){Su(e,t)}while(1);return Fi=Pi=null,P.H=r,P.A=a,Nl=n,Fl===null?(Pl=null,Il=0,Vr(),Ul):0}function Au(){for(;Fl!==null&&!he();)ju(Fl)}function ju(e){var t=wc(e.alternate,e,Hl);e.memoizedProps=e.pendingProps,t===null?Pu(e):Fl=t}function Mu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=cc(n,t,t.pendingProps,t.type,void 0,Il);break;case 11:t=cc(n,t,t.pendingProps,t.type.render,t.ref,Il);break;case 5:bo(t);default:Nc(n,t),t=Fl=Qr(t,Hl),t=wc(n,t,Hl)}e.memoizedProps=e.pendingProps,t===null?Pu(e):Fl=t}function Nu(e,t,n,r){Fi=Pi=null,bo(t),ba=null,xa=0;var i=t.return;try{if(qs(e,i,t,n,Il)){Ul=1,Hs(e,ai(n,e.current)),Fl=null;return}}catch(t){if(i!==null)throw Fl=i,t;Ul=1,Hs(e,ai(n,e.current)),Fl=null;return}t.flags&32768?(Si||r===1?e=!0:Bl||Il&536870912?e=!1:(zl=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ga.current,r!==null&&r.tag===13&&(r.flags|=16384))),Fu(t,e)):Pu(t)}function Pu(e){var t=e;do{if(t.flags&32768){Fu(t,zl);return}e=t.return;var n=jc(t.alternate,t,Hl);if(n!==null){Fl=n;return}if(t=t.sibling,t!==null){Fl=t;return}Fl=t=e}while(t!==null);Ul===0&&(Ul=5)}function Fu(e,t){do{var n=Mc(e.alternate,e);if(n!==null){n.flags&=32767,Fl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Fl=e;return}Fl=e=n}while(e!==null);Ul=6,Fl=null}function Iu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Vu();while(ru!==0);if(Nl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Br,Be(e,n,o,s,c,l),e===Pl&&(Fl=Pl=null,Il=0),au=t,iu=e,ou=n,su=o,cu=a,lu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Xu(xe,function(){return Hu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=P.T,P.T=null,a=F.p,F.p=2,s=Nl,Nl|=4;try{Qc(e,t,n)}finally{Nl=s,F.p=a,P.T=r}}ru=1,Lu(),Ru(),zu()}}function Lu(){if(ru===1){ru=0;var e=iu,t=au,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=P.T,P.T=null;var r=F.p;F.p=2;var i=Nl;Nl|=4;try{dl(t,e);var a=Bd,o=mr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&pr(s.ownerDocument.documentElement,s)){if(c!==null&&hr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=fr(s,h),v=fr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}cp=!!zd,Bd=zd=null}finally{Nl=i,F.p=r,P.T=n}}e.current=t,ru=2}}function Ru(){if(ru===2){ru=0;var e=iu,t=au,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=P.T,P.T=null;var r=F.p;F.p=2;var i=Nl;Nl|=4;try{$c(e,t.alternate,t)}finally{Nl=i,F.p=r,P.T=n}}ru=3}}function zu(){if(ru===4||ru===3){ru=0,ge();var e=iu,t=au,n=ou,r=lu;t.subtreeFlags&10256||t.flags&10256?ru=5:(ru=0,au=iu=null,Bu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(nu=null),Ge(n),t=t.stateNode,Ee&&typeof Ee.onCommitFiberRoot==`function`)try{Ee.onCommitFiberRoot(Te,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=P.T,i=F.p,F.p=2,P.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{P.T=t,F.p=i}}ou&3&&Vu(),rd(e),i=e.pendingLanes,n&261930&&i&42?e===du?uu++:(uu=0,du=e):uu=0,id(0,!1)}}function Bu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Zi(t)))}function Vu(){return Lu(),Ru(),zu(),Hu()}function Hu(){if(ru!==5)return!1;var e=iu,t=su;su=0;var n=Ge(ou),r=P.T,a=F.p;try{F.p=32>n?32:n,P.T=null,n=cu,cu=null;var o=iu,s=ou;if(ru=0,au=iu=null,ou=0,Nl&6)throw Error(i(331));var c=Nl;if(Nl|=4,Ol(o.current),bl(o,o.current,s,n),Nl=c,id(0,!1),Ee&&typeof Ee.onPostCommitFiberRoot==`function`)try{Ee.onPostCommitFiberRoot(Te,o)}catch{}return!0}finally{F.p=a,P.T=r,Bu(e,t)}}function Uu(e,t,n){t=ai(n,t),t=Ws(e.stateNode,t,2),e=Ma(e,t,2),e!==null&&(J(e,2),rd(e))}function Wu(e,t,n){if(e.tag===3)Uu(e,e,n);else for(;t!==null;){if(t.tag===3){Uu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(nu===null||!nu.has(r))){e=ai(n,e),n=Gs(2),r=Ma(t,n,2),r!==null&&(Ks(n,r,t,e),J(r,2),rd(r));break}}t=t.return}}function Gu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ml;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Vl=!0,i.add(n),e=Ku.bind(null,e,t,n),t.then(e,e))}function Ku(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Pl===e&&(Il&n)===n&&(Ul===4||Ul===3&&(Il&62914560)===Il&&300>_e()-Ql?!(Nl&2)&&xu(e,0):Kl|=n,Jl===Il&&(Jl=0)),rd(e)}function qu(e,t){t===0&&(t=q()),e=Wr(e,t),e!==null&&(J(e,t),rd(e))}function Ju(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),qu(e,n)}function Yu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),qu(e,n)}function Xu(e,t){return me(e,t)}var Zu=null,Qu=null,$u=!1,ed=!1,td=!1,nd=0;function rd(e){e!==Qu&&e.next===null&&(Qu===null?Zu=Qu=e:Qu=Qu.next=e),ed=!0,$u||($u=!0,ud())}function id(e,t){if(!td&&ed){td=!0;do for(var n=!1,r=Zu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Oe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,ld(r,a))}else a=Il,a=Ie(r,r===Pl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Le(r,a)||(n=!0,ld(r,a));r=r.next}while(n);td=!1}}function ad(){od()}function od(){ed=$u=!1;var e=0;nd!==0&&Kd()&&(e=nd);for(var t=_e(),n=null,r=Zu;r!==null;){var i=r.next,a=sd(r,t);a===0?(r.next=null,n===null?Zu=i:n.next=i,i===null&&(Qu=n)):(n=r,(e!==0||a&3)&&(ed=!0)),r=i}ru!==0&&ru!==5||id(e,!1),nd!==0&&(nd=0)}function sd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Oe(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Re(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Pl,n=Il,n=Ie(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Ll===2||Ll===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&G(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Le(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&G(r),Ge(n)){case 2:case 8:n=be;break;case 32:n=xe;break;case 268435456:n=Ce;break;default:n=xe}return r=cd.bind(null,e),n=me(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&G(r),e.callbackPriority=2,e.callbackNode=null,2}function cd(e,t){if(ru!==0&&ru!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Vu()&&e.callbackNode!==n)return null;var r=Il;return r=Ie(e,e===Pl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(hu(e,r,t),sd(e,_e()),e.callbackNode!=null&&e.callbackNode===n?cd.bind(null,e):null)}function ld(e,t){if(Vu())return null;hu(e,t,!0)}function ud(){Xd(function(){Nl&6?me(ye,ad):od()})}function dd(){if(nd===0){var e=ea;e===0&&(e=Me,Me<<=1,!(Me&261888)&&(Me=256)),nd=e}return nd}function fd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:zt(``+e)}function pd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function Q(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=fd((i[Xe]||null).action),o=r.submitter;o&&(t=(t=o[Xe]||null)?fd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new cn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(nd!==0){var e=o?pd(i,o):new FormData(i);gs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?pd(i,o):new FormData(i),gs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var md=0;md<Fr.length;md++){var hd=Fr[md];Ir(hd.toLowerCase(),`on`+(hd[0].toUpperCase()+hd.slice(1)))}Ir(Dr,`onAnimationEnd`),Ir(Or,`onAnimationIteration`),Ir(kr,`onAnimationStart`),Ir(`dblclick`,`onDoubleClick`),Ir(`focusin`,`onFocus`),Ir(`focusout`,`onBlur`),Ir(Ar,`onTransitionRun`),Ir(jr,`onTransitionStart`),Ir(Mr,`onTransitionCancel`),Ir(Nr,`onTransitionEnd`),dt(`onMouseEnter`,[`mouseout`,`mouseover`]),dt(`onMouseLeave`,[`mouseout`,`mouseover`]),dt(`onPointerEnter`,[`pointerout`,`pointerover`]),dt(`onPointerLeave`,[`pointerout`,`pointerover`]),ut(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),ut(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),ut(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),ut(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),ut(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),ut(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var gd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),_d=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(gd));function vd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Lr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Lr(e)}i.currentTarget=null,a=c}}}}function yd(e,t){var n=t[Qe];n===void 0&&(n=t[Qe]=new Set);var r=e+`__bubble`;n.has(r)||(Cd(t,e,2,!1),n.add(r))}function bd(e,t,n){var r=0;t&&(r|=4),Cd(n,e,r,t)}var xd=`_reactListening`+Math.random().toString(36).slice(2);function Sd(e){if(!e[xd]){e[xd]=!0,X.forEach(function(t){t!==`selectionchange`&&(_d.has(t)||bd(t,!1,e),bd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[xd]||(t[xd]=!0,bd(`selectionchange`,!1,t))}}function Cd(e,t,n,r){switch(hp(t)){case 2:var i=lp;break;case 8:i=up;break;default:i=dp}n=i.bind(null,t,n,e),i=void 0,!Xt||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function wd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=it(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}qt(function(){var r=a,i=Ht(n),s=[];a:{var c=Pr.get(e);if(c!==void 0){var l=cn,u=e;switch(e){case`keypress`:if(nn(n)===0)break a;case`keydown`:case`keyup`:l=En;break;case`focusin`:u=`focus`,l=_n;break;case`focusout`:u=`blur`,l=_n;break;case`beforeblur`:case`afterblur`:l=_n;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=hn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=gn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=On;break;case Dr:case Or:case kr:l=vn;break;case Nr:l=kn;break;case`scroll`:case`scrollend`:l=un;break;case`wheel`:l=An;break;case`copy`:case`cut`:case`paste`:l=yn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Dn;break;case`toggle`:case`beforetoggle`:l=jn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=Jt(m,p),g!=null&&d.push(Td(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==Vt&&(u=n.relatedTarget||n.fromElement)&&(it(u)||u[Ze]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?it(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=hn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Dn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:ot(l),h=u==null?c:ot(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,it(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Dd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Od(s,c,l,d,!1),u!==null&&f!==null&&Od(s,f,u,d,!0)}}a:{if(c=r?ot(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=Zn;else if(Gn(c))if(Qn)v=sr;else{v=ar;var y=ir}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&It(r.elementType)&&(v=Zn):v=or;if(v&&=v(e,r)){Kn(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Ot(c,`number`,c.value)}switch(y=r?ot(r):window,e){case`focusin`:(Gn(y)||y.contentEditable===`true`)&&(_r=y,vr=r,yr=null);break;case`focusout`:yr=vr=_r=null;break;case`mousedown`:br=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:br=!1,xr(s,n,i);break;case`selectionchange`:if(gr)break;case`keydown`:case`keyup`:xr(s,n,i)}var b;if(Nn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Vn?zn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(In&&n.locale!==`ko`&&(Vn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Vn&&(b=tn()):(Qt=i,$t=`value`in Qt?Qt.value:Qt.textContent,Vn=!0)),y=Ed(r,x),0<y.length&&(x=new bn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=Bn(n),b!==null&&(x.data=b)))),(b=Fn?Hn(e,n):Un(e,n))&&(x=Ed(r,`onBeforeInput`),0<x.length&&(y=new bn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),Q(s,e,r,n,i)}vd(s,t)})}function Td(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ed(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=Jt(e,n),i!=null&&r.unshift(Td(e,i,a)),i=Jt(e,t),i!=null&&r.push(Td(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Dd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Od(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=Jt(n,a),l!=null&&o.unshift(Td(n,l,c))):i||(l=Jt(n,a),l!=null&&o.push(Td(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var kd=/\r\n?/g,Ad=/\u0000|\uFFFD/g;function jd(e){return(typeof e==`string`?e:``+e).replace(kd,`
|
|
10
|
+
`).replace(Ad,``)}function Md(e,t){return t=jd(t),jd(e)===t}function Nd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Mt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Mt(e,``+r);break;case`className`:_t(e,`class`,r);break;case`tabIndex`:_t(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:_t(e,n,r);break;case`style`:Ft(e,r,o);break;case`data`:if(t!==`object`){_t(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=zt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Nd(e,t,`name`,a.name,a,null),Nd(e,t,`formEncType`,a.formEncType,a,null),Nd(e,t,`formMethod`,a.formMethod,a,null),Nd(e,t,`formTarget`,a.formTarget,a,null)):(Nd(e,t,`encType`,a.encType,a,null),Nd(e,t,`method`,a.method,a,null),Nd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=zt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Bt);break;case`onScroll`:r!=null&&yd(`scroll`,e);break;case`onScrollEnd`:r!=null&&yd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=zt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:yd(`beforetoggle`,e),yd(`toggle`,e),gt(e,`popover`,r);break;case`xlinkActuate`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:gt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Lt.get(n)||n,gt(e,n,r))}}function Pd(e,t,n,r,a,o){switch(n){case`style`:Ft(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Mt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Mt(e,``+r);break;case`onScroll`:r!=null&&yd(`scroll`,e);break;case`onScrollEnd`:r!=null&&yd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Bt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!lt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[Xe]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):gt(e,n,r)}}}function Fd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:yd(`error`,e),yd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Nd(e,t,o,s,n,null)}}a&&Nd(e,t,`srcSet`,n.srcSet,n,null),r&&Nd(e,t,`src`,n.src,n,null);return;case`input`:yd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Nd(e,t,r,d,n,null)}}Dt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in yd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Nd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&kt(e,!!r,n,!0):kt(e,!!r,t,!1);return;case`textarea`:for(s in yd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Nd(e,t,s,c,n,null)}jt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Nd(e,t,l,r,n,null)}return;case`dialog`:yd(`beforetoggle`,e),yd(`toggle`,e),yd(`cancel`,e),yd(`close`,e);break;case`iframe`:case`object`:yd(`load`,e);break;case`video`:case`audio`:for(r=0;r<gd.length;r++)yd(gd[r],e);break;case`image`:yd(`error`,e),yd(`load`,e);break;case`details`:yd(`toggle`,e);break;case`embed`:case`source`:case`link`:yd(`error`,e),yd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Nd(e,t,u,r,n,null)}return;default:if(It(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Pd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Nd(e,t,c,r,n,null))}function Id(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Nd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Nd(e,t,p,m,r,f)}}Et(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Nd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Nd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?kt(e,!!n,n?[]:``,!1):kt(e,!!n,t,!0)):kt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Nd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Nd(e,t,s,a,r,o)}At(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Nd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Nd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Nd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Nd(e,t,u,p,r,m)}return;default:if(It(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Pd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Pd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Nd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Nd(e,t,f,p,r,m)}function Ld(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Rd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Ld(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Ld(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var zd=null,Bd=null;function Vd(e){return e.nodeType===9?e:e.ownerDocument}function Hd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Ud(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Wd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Gd=null;function Kd(){var e=window.event;return e&&e.type===`popstate`?e===Gd?!1:(Gd=e,!0):(Gd=null,!1)}var qd=typeof setTimeout==`function`?setTimeout:void 0,Jd=typeof clearTimeout==`function`?clearTimeout:void 0,Yd=typeof Promise==`function`?Promise:void 0,Xd=typeof queueMicrotask==`function`?queueMicrotask:Yd===void 0?qd:function(e){return Yd.resolve(null).then(e).catch(Zd)};function Zd(e){setTimeout(function(){throw e})}function Qd(e){return e===`head`}function $d(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Pp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)mf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,mf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[nt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&mf(e.ownerDocument.body);n=i}while(n);Pp(t)}function ef(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function tf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:tf(n),rt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function nf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[nt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=lf(e.nextSibling),e===null)break}return null}function rf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=lf(e.nextSibling),e===null))return null;return e}function af(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=lf(e.nextSibling),e===null))return null;return e}function of(e){return e.data===`$?`||e.data===`$~`}function sf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function cf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function lf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var uf=null;function df(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return lf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function ff(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function pf(e,t,n){switch(t=Vd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function mf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);rt(e)}var hf=new Map,gf=new Set;function _f(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var vf=F.d;F.d={f:yf,r:bf,D:Cf,C:wf,L:Tf,m:Ef,X:Of,S:Df,M:kf};function yf(){var e=vf.f(),t=yu();return e||t}function bf(e){var t=at(e);t!==null&&t.tag===5&&t.type===`form`?vs(t):vf.r(e)}var xf=typeof document>`u`?null:document;function Sf(e,t,n){var r=xf;if(r&&typeof t==`string`&&t){var i=Tt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),gf.has(i)||(gf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Fd(t,`link`,e),ct(t),r.head.appendChild(t)))}}function Cf(e){vf.D(e),Sf(`dns-prefetch`,e,null)}function wf(e,t){vf.C(e,t),Sf(`preconnect`,e,t)}function Tf(e,t,n){vf.L(e,t,n);var r=xf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Tt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Tt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Tt(n.imageSizes)+`"]`)):i+=`[href="`+Tt(e)+`"]`;var a=i;switch(t){case`style`:a=jf(e);break;case`script`:a=Ff(e)}hf.has(a)||(e=p({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),hf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Mf(a))||t===`script`&&r.querySelector(If(a))||(t=r.createElement(`link`),Fd(t,`link`,e),ct(t),r.head.appendChild(t)))}}function Ef(e,t){vf.m(e,t);var n=xf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Tt(r)+`"][href="`+Tt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Ff(e)}if(!hf.has(a)&&(e=p({rel:`modulepreload`,href:e},t),hf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(If(a)))return}r=n.createElement(`link`),Fd(r,`link`,e),ct(r),n.head.appendChild(r)}}}function Df(e,t,n){vf.S(e,t,n);var r=xf;if(r&&e){var i=st(r).hoistableStyles,a=jf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Mf(a)))s.loading=5;else{e=p({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=hf.get(a))&&zf(e,n);var c=o=r.createElement(`link`);ct(c),Fd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Rf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Of(e,t){vf.X(e,t);var n=xf;if(n&&e){var r=st(n).hoistableScripts,i=Ff(e),a=r.get(i);a||(a=n.querySelector(If(i)),a||(e=p({src:e,async:!0},t),(t=hf.get(i))&&Bf(e,t),a=n.createElement(`script`),ct(a),Fd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t){vf.M(e,t);var n=xf;if(n&&e){var r=st(n).hoistableScripts,i=Ff(e),a=r.get(i);a||(a=n.querySelector(If(i)),a||(e=p({src:e,async:!0,type:`module`},t),(t=hf.get(i))&&Bf(e,t),a=n.createElement(`script`),ct(a),Fd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Af(e,t,n,r){var a=(a=ne.current)?_f(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=jf(n.href),n=st(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=jf(n.href);var o=st(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Mf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),hf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},hf.set(e,n),o||Pf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Ff(n),n=st(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function jf(e){return`href="`+Tt(e)+`"`}function Mf(e){return`link[rel="stylesheet"][`+e+`]`}function Nf(e){return p({},e,{"data-precedence":e.precedence,precedence:null})}function Pf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Fd(t,`link`,n),ct(t),e.head.appendChild(t))}function Ff(e){return`[src="`+Tt(e)+`"]`}function If(e){return`script[async]`+e}function Lf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Tt(n.href)+`"]`);if(r)return t.instance=r,ct(r),r;var a=p({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),ct(r),Fd(r,`style`,a),Rf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=jf(n.href);var o=e.querySelector(Mf(a));if(o)return t.state.loading|=4,t.instance=o,ct(o),o;r=Nf(n),(a=hf.get(a))&&zf(r,a),o=(e.ownerDocument||e).createElement(`link`),ct(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Fd(o,`link`,r),t.state.loading|=4,Rf(o,n.precedence,e),t.instance=o;case`script`:return o=Ff(n.src),(a=e.querySelector(If(o)))?(t.instance=a,ct(a),a):(r=n,(a=hf.get(o))&&(r=p({},n),Bf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),ct(a),Fd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Rf(r,n.precedence,e));return t.instance}function Rf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Bf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Vf=null;function Hf(e,t,n){if(Vf===null){var r=new Map,i=Vf=new Map;i.set(n,r)}else i=Vf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[nt]||a[Ye]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Uf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Wf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Gf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Kf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=jf(r.href),a=t.querySelector(Mf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Yf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,ct(a);return}a=t.ownerDocument||t,r=Nf(r),(i=hf.get(i))&&zf(r,i),a=a.createElement(`link`),ct(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Fd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Yf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var qf=0;function Jf(e,t){return e.stylesheets&&e.count===0&&Zf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Zf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&qf===0&&(qf=62500*Rd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Zf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>qf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Yf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Zf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Xf=null;function Zf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Xf=new Map,t.forEach(Qf,e),Xf=null,Yf.call(e))}function Qf(e,t){if(!(t.state.loading&4)){var n=Xf.get(e);if(n)var r=n.get(null);else{n=new Map,Xf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Yf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var $f={$$typeof:x,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function ep(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ze(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ze(0),this.hiddenUpdates=ze(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function tp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new ep(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Yr(3,null,null,t),e.current=a,a.stateNode=e,t=Xi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},ka(a),e}function np(e){return e?(e=qr,e):qr}function rp(e,t,n,r,i,a){i=np(i),r.context===null?r.context=i:r.pendingContext=i,r=ja(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ma(e,r,t),n!==null&&(mu(n,e,t),Na(n,e,t))}function ip(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ap(e,t){ip(e,t),(e=e.alternate)&&ip(e,t)}function op(e){if(e.tag===13||e.tag===31){var t=Wr(e,67108864);t!==null&&mu(t,e,67108864),ap(e,67108864)}}function sp(e){if(e.tag===13||e.tag===31){var t=fu();t=We(t);var n=Wr(e,t);n!==null&&mu(n,e,t),ap(e,t)}}var cp=!0;function lp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=2,dp(e,t,n,r)}finally{F.p=a,P.T=i}}function up(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=8,dp(e,t,n,r)}finally{F.p=a,P.T=i}}function dp(e,t,n,r){if(cp){var i=fp(r);if(i===null)wd(e,t,r,pp,n),wp(e,r);else if(Ep(i,e,t,n,r))r.stopPropagation();else if(wp(e,r),t&4&&-1<Cp.indexOf(e)){for(;i!==null;){var a=at(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Fe(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Oe(o);s.entanglements[1]|=c,o&=~c}rd(a),!(Nl&6)&&(eu=_e()+500,id(0,!1))}}break;case 31:case 13:s=Wr(a,2),s!==null&&mu(s,a,2),yu(),ap(a,2)}if(a=fp(r),a===null&&wd(e,t,r,pp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else wd(e,t,r,null,n)}}function fp(e){return e=Ht(e),mp(e)}var pp=null;function mp(e){if(pp=null,e=it(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return pp=e,null}function hp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(ve()){case ye:return 2;case be:return 8;case xe:case Se:return 32;case Ce:return 268435456;default:return 32}default:return 32}}var gp=!1,_p=null,vp=null,yp=null,bp=new Map,xp=new Map,Sp=[],Cp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function wp(e,t){switch(e){case`focusin`:case`focusout`:_p=null;break;case`dragenter`:case`dragleave`:vp=null;break;case`mouseover`:case`mouseout`:yp=null;break;case`pointerover`:case`pointerout`:bp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:xp.delete(t.pointerId)}}function Tp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=at(t),t!==null&&op(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ep(e,t,n,r,i){switch(t){case`focusin`:return _p=Tp(_p,e,t,n,r,i),!0;case`dragenter`:return vp=Tp(vp,e,t,n,r,i),!0;case`mouseover`:return yp=Tp(yp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return bp.set(a,Tp(bp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,xp.set(a,Tp(xp.get(a)||null,e,t,n,r,i)),!0}return!1}function Dp(e){var t=it(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,qe(e.priority,function(){sp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,qe(e.priority,function(){sp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Op(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=fp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Vt=r,n.target.dispatchEvent(r),Vt=null}else return t=at(n),t!==null&&op(t),e.blockedOn=n,!1;t.shift()}return!0}function kp(e,t,n){Op(e)&&n.delete(t)}function Ap(){gp=!1,_p!==null&&Op(_p)&&(_p=null),vp!==null&&Op(vp)&&(vp=null),yp!==null&&Op(yp)&&(yp=null),bp.forEach(kp),xp.forEach(kp)}function jp(e,n){e.blockedOn===n&&(e.blockedOn=null,gp||(gp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Ap)))}var Mp=null;function Np(e){Mp!==e&&(Mp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Mp===e&&(Mp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(mp(r||n)===null)continue;break}var a=at(n);a!==null&&(e.splice(t,3),t-=3,gs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Pp(e){function t(t){return jp(t,e)}_p!==null&&jp(_p,e),vp!==null&&jp(vp,e),yp!==null&&jp(yp,e),bp.forEach(t),xp.forEach(t);for(var n=0;n<Sp.length;n++){var r=Sp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Sp.length&&(n=Sp[0],n.blockedOn===null);)Dp(n),n.blockedOn===null&&Sp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[Xe]||null;if(typeof a==`function`)o||Np(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Xe]||null)s=o.formAction;else if(mp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Np(n)}}}function Fp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Ip(e){this._internalRoot=e}Lp.prototype.render=Ip.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;rp(n,fu(),e,t,null,null)},Lp.prototype.unmount=Ip.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;rp(e.current,2,null,e,null,null),yu(),t[Ze]=null}};function Lp(e){this._internalRoot=e}Lp.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ke();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Sp.length&&t!==0&&t<Sp[n].priority;n++);Sp.splice(n,0,e),n===0&&Dp(e)}};var Rp=n.version;if(Rp!==`19.2.5`)throw Error(i(527,Rp,`19.2.5`));F.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=d(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var zp={bundleType:0,version:`19.2.5`,rendererPackageName:`react-dom`,currentDispatcherRef:P,reconcilerVersion:`19.2.5`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Bp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bp.isDisabled&&Bp.supportsFiber)try{Te=Bp.inject(zp),Ee=Bp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=zs,s=Bs,c=Vs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=tp(e,1,!1,null,null,n,r,null,o,s,c,Fp),e[Ze]=t.current,Sd(e),new Ip(t)}})),$e=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Qe()}))(),et=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);st(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},tt={},nt=(e,t,n,r)=>{st(n)&&tt[n]||(st(n)&&(tt[n]=new Date),et(e,t,n,r))},rt=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},it=(e,t,n)=>{e.loadNamespaces(t,rt(e,n))},at=(e,t,n,r)=>{if(st(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return it(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,rt(e,r))},ot=(e,t,n={})=>!t.languages||!t.languages.length?(nt(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),st=e=>typeof e==`string`,ct=e=>typeof e==`object`&&!!e,X=e(te()),lt=(0,X.createContext)(),ut=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},dt=i((e=>{var t=te();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),ft=i(((e,t)=>{t.exports=dt()}))(),pt={t:(e,t)=>{if(st(t))return t;if(ct(t)&&st(t.defaultValue))return t.defaultValue;if(typeof e==`function`)return``;if(Array.isArray(e)){let t=e[e.length-1];return typeof t==`function`?``:t}return e},ready:!1},mt=()=>()=>{},ht=(e,t={})=>{let{i18n:n}=t,{i18n:r,defaultNS:i}=(0,X.useContext)(lt)||{},a=n||r||I();a&&!a.reportNamespaces&&(a.reportNamespaces=new ut),a||nt(a,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next`);let o=(0,X.useMemo)(()=>({...Xe(),...a?.options?.react,...t}),[a,t]),{useSuspense:s,keyPrefix:c}=o,l=e||i||a?.options?.defaultNS,u=st(l)?[l]:l||[`translation`],d=(0,X.useMemo)(()=>u,u);a?.reportNamespaces?.addUsedNamespaces?.(d);let f=(0,X.useRef)(0),p=(0,X.useCallback)(e=>{if(!a)return mt;let{bindI18n:t,bindI18nStore:n}=o,r=()=>{f.current+=1,e()};return t&&a.on(t,r),n&&a.store.on(n,r),()=>{t&&t.split(` `).forEach(e=>a.off(e,r)),n&&n.split(` `).forEach(e=>a.store.off(e,r))}},[a,o]),m=(0,X.useRef)(),h=(0,X.useCallback)(()=>{if(!a)return pt;let e=!!(a.isInitialized||a.initializedStoreOnce)&&d.every(e=>ot(e,a,o)),n=t.lng||a.language,r=f.current,i=m.current;if(i&&i.ready===e&&i.lng===n&&i.keyPrefix===c&&i.revision===r)return i;let s={t:a.getFixedT(n,o.nsMode===`fallback`?d:d[0],c),ready:e,lng:n,keyPrefix:c,revision:r};return m.current=s,s},[a,d,c,o,t.lng]),[g,_]=(0,X.useState)(0),{t:v,ready:y}=(0,ft.useSyncExternalStore)(p,h,h);(0,X.useEffect)(()=>{if(a&&!y&&!s){let e=()=>_(e=>e+1);t.lng?at(a,t.lng,d,e):it(a,d,e)}},[a,t.lng,d,y,s,g]);let b=a||{},x=(0,X.useRef)(null),S=(0,X.useRef)(),C=e=>{let t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;let n=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(n,`__original`))try{Object.defineProperty(n,`__original`,{value:e,writable:!1,enumerable:!1,configurable:!1})}catch{}return n},w=(0,X.useMemo)(()=>{let e=b,t=e?.language,n=e;e&&(x.current&&x.current.__original===e&&S.current===t?n=x.current:(n=C(e),x.current=n,S.current=t));let r=!y&&!s?(...e)=>(nt(a,`USE_T_BEFORE_READY`,`useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.`),v(...e)):v,i=[r,n,y];return i.t=r,i.i18n=n,i.ready=y,i},[v,b,y,b.resolvedLanguage,b.language,b.languages]);if(a&&s&&!y)throw new Promise(e=>{let n=()=>e();t.lng?at(a,t.lng,d,n):it(a,d,n)});return w};function gt({i18n:e,defaultNS:t,children:n}){let r=(0,X.useMemo)(()=>({i18n:e,defaultNS:t}),[e,t]);return(0,X.createElement)(lt.Provider,{value:r},n)}var _t=Se(),vt=(0,X.createContext)(_t),Z=p(),yt=({client:e=_t,children:t})=>(0,Z.jsx)(vt.Provider,{value:e,children:t}),bt=(e,t)=>x(N(`/bundles`,e),{signal:t}),xt=(e,t)=>x(N(`/bundles`,e),{method:`POST`,body:typeof t==`string`?{name:t}:t,fallbackErrorMessage:`Unable to create the bundle right now.`}),St=(e,t,n)=>x(N(`/bundles/${t}/details`,e),{signal:n,fallbackErrorMessage:`Unable to load the bundle right now.`}),Ct=(e,t,n)=>x(N(`/bundles/${t}/conversation`,e),{signal:n,fallbackErrorMessage:`Unable to load the bundle conversation right now.`}),wt=(e,t,n)=>x(N(`/bundles/${t}/pull-request`,e),{method:`POST`,body:n,fallbackErrorMessage:`Unable to create the pull request right now.`}),Tt=(e,t,n)=>x(N(`/bundles/${t}/pull-request-description`,e),{method:`POST`,body:n,fallbackErrorMessage:`Unable to generate the pull request description right now.`}),Et=(e,t)=>x(N(`/bundles/${t}/pull-request/sync`,e),{method:`POST`,fallbackErrorMessage:`Unable to sync the pull request right now.`}),Dt=(e,t)=>x(N(`/bundles/${t}/build`,e),{method:`POST`,fallbackErrorMessage:`Unable to build the bundle right now.`}),Ot=(e,t)=>x(N(`/bundles/${t}/review`,e),{method:`POST`,fallbackErrorMessage:`Unable to review the bundle right now.`}),kt=(e,t)=>x(N(`/bundles/${t}/undo-review`,e),{method:`POST`,fallbackErrorMessage:`Unable to undo the bundle review right now.`}),At=(e,t,n)=>x(N(`/bundles/${t}/follow-up`,e),{method:`POST`,body:{instruction:n},fallbackErrorMessage:`Unable to send the bundle follow-up prompt right now.`}),jt=(e,t,n)=>x(N(`/bundles/${t}/review-findings`,e),{signal:n,fallbackErrorMessage:`Unable to load review findings right now.`}),Mt=(e,t,n)=>x(N(`/bundles/${t}/review-diff`,e),{signal:n,fallbackErrorMessage:`Unable to load the branch diff right now.`}),Nt=(e,t,n)=>x(N(`/bundles/${t}/pull-request/comments`,e),{signal:n,fallbackErrorMessage:`Unable to load GitHub review comments right now.`}),Pt=(e,t)=>x(N(`/bundles/${t}/run`,e),{method:`POST`,fallbackErrorMessage:`Unable to start the bundle run right now.`}),Ft=(e,t)=>x(N(`/bundles/${t}/stop`,e),{method:`POST`,fallbackErrorMessage:`Unable to stop the bundle run right now.`}),It=(e,t)=>_(N(`/bundles/${t}`,e),{method:`DELETE`,fallbackErrorMessage:`Unable to delete the bundle right now.`}),Lt=(e,t)=>x(N(`/preview-status`,e),{signal:t,fallbackErrorMessage:`Unable to load preview status right now.`}),Rt=(e,t)=>x(N(`/run-status`,e),{signal:t,fallbackErrorMessage:`Unable to load run status right now.`}),zt=e=>x(s(`/projects/${e}/run`),{method:`POST`,fallbackErrorMessage:`Unable to start the project run right now.`}),Bt=e=>x(s(`/projects/${e}/stop-run`),{method:`POST`,fallbackErrorMessage:`Unable to stop the project run right now.`}),Vt=(e,t,n={})=>{let r=new URL(N(`/tickets`,e));return r.searchParams.set(`detail`,n.detail??`board`),x(r.toString(),{signal:t})},Ht=(e,t)=>{let n=new URL(N(`/tickets`,e));return n.searchParams.set(`detail`,`board-enrichment`),x(n.toString(),{signal:t})},Ut=(e,t,n)=>x(N(`/tickets/${e}`,t),{signal:n,fallbackErrorMessage:`Unable to load the ticket right now.`}),Wt=e=>x(s(`/tickets`),{method:`POST`,body:e,fallbackErrorMessage:`Unable to create the ticket right now.`}),Gt=e=>x(s(`/planning-agent`),{method:`POST`,body:e,fallbackErrorMessage:`Unable to generate tickets right now.`}),Kt=(e,t,n)=>x(N(`/tickets/${e}`,t),{method:`PATCH`,body:n,fallbackErrorMessage:`Unable to update the ticket right now.`}),qt=(e,t,n)=>x(N(`/tickets/${e}/state`,t),{method:`PATCH`,body:{state:n},fallbackErrorMessage:`Unable to move the ticket right now.`}),Jt=(e,t)=>x(N(`/tickets/${e}/diff`,t),{fallbackErrorMessage:`Unable to load the diff right now.`}),Yt=(e,t,n={})=>{let r=new URL(N(`/tickets/${e}/git-status`,t));return n.refreshRemote&&r.searchParams.set(`refresh_remote`,`true`),x(r.toString(),{fallbackErrorMessage:`Unable to load git status right now.`})},Xt=(e,t,n)=>x(N(`/tickets/${e}/git-commit`,t),{method:`POST`,body:n,fallbackErrorMessage:`Unable to create the commit right now.`}),Zt=(e,t,n)=>x(N(`/tickets/${e}/git-commit-message`,t),{method:`POST`,body:n,fallbackErrorMessage:`Unable to generate a commit message right now.`}),Qt=(e,t)=>x(N(`/tickets/${e}/git-push`,t),{method:`POST`,fallbackErrorMessage:`Unable to push the branch right now.`}),$t=(e,t)=>x(N(`/tickets/${e}/git-commits`,t),{fallbackErrorMessage:`Unable to load local commits right now.`}),en=(e,t)=>x(N(`/tickets/${e}/git-undo-latest`,t),{method:`POST`,fallbackErrorMessage:`Unable to undo the latest local commit right now.`}),tn=(e,t)=>x(N(`/tickets/${e}/build-chain`,t),{method:`POST`,fallbackErrorMessage:`Unable to start the build chain right now.`}),nn=(e,t)=>_(N(`/tickets/${e}/stop-build-chain`,t),{method:`POST`,fallbackErrorMessage:`Unable to stop the build chain right now.`}),rn=(e,t)=>_(N(`/tickets/${e}`,t),{method:`DELETE`,fallbackErrorMessage:`Unable to delete the ticket right now.`}),an=(e,t)=>x(N(`/tickets/${e}/undo`,t),{method:`POST`,fallbackErrorMessage:`Unable to undo the ticket right now.`}),on=(e,t)=>x(N(`/tickets/${e}/park`,t),{method:`PATCH`,fallbackErrorMessage:`Unable to park the ticket right now.`}),sn=(e,t)=>x(N(`/tickets/${e}/unpark`,t),{method:`PATCH`,fallbackErrorMessage:`Unable to return the ticket right now.`}),cn=e=>x(N(`/tickets/delete-parked`,e),{method:`POST`,fallbackErrorMessage:`Unable to empty Done right now.`}),ln=(e,t)=>_(N(`/tickets/${e}/retry`,t),{method:`POST`,fallbackErrorMessage:`Unable to retry the ticket right now.`}),un=(e,t)=>_(N(`/tickets/${e}/run`,t),{method:`POST`,fallbackErrorMessage:`Unable to start the run right now.`}),dn=(e,t)=>_(N(`/tickets/${e}/open-ide`,t),{method:`POST`,fallbackErrorMessage:`Unable to open the IDE right now.`}),fn=(e,t)=>_(N(`/tickets/${e}/stop`,t),{method:`POST`,fallbackErrorMessage:`Unable to stop the run right now.`}),pn=(e,t)=>_(N(`/tickets/${e}/stop-build`,t),{method:`POST`,fallbackErrorMessage:`Unable to stop the build right now.`}),mn=(e,t)=>_(N(`/tickets/${e}/resume-build`,t),{method:`POST`,fallbackErrorMessage:`Unable to resume the build right now.`}),hn=(e,t,n)=>x(N(`/tickets/${e}/follow-up`,t),{method:`POST`,body:{instruction:n},fallbackErrorMessage:`Unable to send the follow-up prompt right now.`}),gn=(e,t)=>x(N(`/tickets/${e}/review`,t),{method:`POST`,fallbackErrorMessage:`Unable to re-run the review right now.`}),_n=(e,t,n)=>x(N(`/tickets/${e}/plan-follow-up`,t),{method:`POST`,body:{instruction:n},fallbackErrorMessage:`Unable to send the planning follow-up prompt right now.`}),vn=(e,t,n)=>_(N(`/tickets/${e}/plan`,t),{method:`POST`,...n===void 0?{}:{body:{worktree_bundle_id:n}},fallbackErrorMessage:`Unable to start AI planning.`}),yn=async(e,t)=>{let n=await x(s(`/models?tool=${e}`),{signal:t,cache:`no-store`});return Array.isArray(n)?n.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&typeof t.label==`string`&&typeof t.provider==`string`&&typeof t.supports_reasoning==`boolean`&&Array.isArray(t.variants)&&t.variants.every(e=>typeof e==`string`)&&(t.context_window==null||typeof t.context_window==`number`)&&(t.max_input_tokens==null||typeof t.max_input_tokens==`number`)&&(t.max_output_tokens==null||typeof t.max_output_tokens==`number`)}):[]},bn=e=>x(s(`/tool`),{signal:e}),xn=e=>x(s(`/tool`),{method:`POST`,body:{tool:e}}),Sn=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Cn=`VisuallyHidden`,wn=X.forwardRef((e,t)=>(0,Z.jsx)(w.span,{...e,ref:t,style:{...Sn,...e.style}}));wn.displayName=Cn;var Tn=wn,En=`Collapsible`,[Dn,On]=b(En),[kn,An]=Dn(En),jn=X.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=xe({prop:r,defaultProp:i??!1,onChange:o,caller:En});return(0,Z.jsx)(kn,{scope:n,disabled:a,contentId:Ce(),open:c,onOpenToggle:X.useCallback(()=>l(e=>!e),[l]),children:(0,Z.jsx)(w.div,{"data-state":Ln(c),"data-disabled":a?``:void 0,...s,ref:t})})});jn.displayName=En;var Mn=`CollapsibleTrigger`,Nn=X.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=An(Mn,n);return(0,Z.jsx)(w.button,{type:`button`,"aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":Ln(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:O(e.onClick,i.onOpenToggle)})});Nn.displayName=Mn;var Pn=`CollapsibleContent`,Fn=X.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=An(Pn,e.__scopeCollapsible);return(0,Z.jsx)(o,{present:n||i.open,children:({present:e})=>(0,Z.jsx)(In,{...r,ref:t,present:e})})});Fn.displayName=Pn;var In=X.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=An(Pn,n),[s,c]=X.useState(r),l=X.useRef(null),u=y(t,l),d=X.useRef(0),f=d.current,p=X.useRef(0),m=p.current,h=o.open||s,g=X.useRef(h),_=X.useRef(void 0);return X.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),E(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,Z.jsx)(w.div,{"data-state":Ln(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})});function Ln(e){return e?`open`:`closed`}var Rn=jn,zn=Nn,Bn=Fn,Vn=`Dialog`,[Hn,Un]=b(Vn),[Wn,Gn]=Hn(Vn),Kn=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=X.useRef(null),c=X.useRef(null),[l,u]=xe({prop:r,defaultProp:i??!1,onChange:a,caller:Vn});return(0,Z.jsx)(Wn,{scope:t,triggerRef:s,contentRef:c,contentId:Ce(),titleId:Ce(),descriptionId:Ce(),open:l,onOpenChange:u,onOpenToggle:X.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};Kn.displayName=Vn;var qn=`DialogTrigger`,Jn=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Gn(qn,n),a=y(t,i.triggerRef);return(0,Z.jsx)(w.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":mr(i.open),...r,ref:a,onClick:O(e.onClick,i.onOpenToggle)})});Jn.displayName=qn;var Yn=`DialogPortal`,[Xn,Zn]=Hn(Yn,{forceMount:void 0}),Qn=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Gn(Yn,t);return(0,Z.jsx)(Xn,{scope:t,forceMount:n,children:X.Children.map(r,e=>(0,Z.jsx)(o,{present:n||a.open,children:(0,Z.jsx)(Ue,{asChild:!0,container:i,children:e})}))})};Qn.displayName=Yn;var $n=`DialogOverlay`,er=X.forwardRef((e,t)=>{let n=Zn($n,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Gn($n,e.__scopeDialog);return a.modal?(0,Z.jsx)(o,{present:r||a.open,children:(0,Z.jsx)(nr,{...i,ref:t})}):null});er.displayName=$n;var tr=Ye(`DialogOverlay.RemoveScroll`),nr=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Gn($n,n);return(0,Z.jsx)(L,{as:tr,allowPinchZoom:!0,shards:[i.contentRef],children:(0,Z.jsx)(w.div,{"data-state":mr(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),rr=`DialogContent`,ir=X.forwardRef((e,t)=>{let n=Zn(rr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Gn(rr,e.__scopeDialog);return(0,Z.jsx)(o,{present:r||a.open,children:a.modal?(0,Z.jsx)(ar,{...i,ref:t}):(0,Z.jsx)(or,{...i,ref:t})})});ir.displayName=rr;var ar=X.forwardRef((e,t)=>{let n=Gn(rr,e.__scopeDialog),r=X.useRef(null),i=y(t,n.contentRef,r);return X.useEffect(()=>{let e=r.current;if(e)return Ge(e)},[]),(0,Z.jsx)(sr,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:O(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:O(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:O(e.onFocusOutside,e=>e.preventDefault())})}),or=X.forwardRef((e,t)=>{let n=Gn(rr,e.__scopeDialog),r=X.useRef(!1),i=X.useRef(!1);return(0,Z.jsx)(sr,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),sr=X.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Gn(rr,n),c=X.useRef(null),l=y(t,c);return u(),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(z,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Z.jsx)(m,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":mr(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(vr,{titleId:s.titleId}),(0,Z.jsx)(br,{contentRef:c,descriptionId:s.descriptionId})]})]})}),cr=`DialogTitle`,lr=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Gn(cr,n);return(0,Z.jsx)(w.h2,{id:i.titleId,...r,ref:t})});lr.displayName=cr;var ur=`DialogDescription`,dr=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Gn(ur,n);return(0,Z.jsx)(w.p,{id:i.descriptionId,...r,ref:t})});dr.displayName=ur;var fr=`DialogClose`,pr=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Gn(fr,n);return(0,Z.jsx)(w.button,{type:`button`,...r,ref:t,onClick:O(e.onClick,()=>i.onOpenChange(!1))})});pr.displayName=fr;function mr(e){return e?`open`:`closed`}var hr=`DialogTitleWarning`,[gr,_r]=g(hr,{contentName:rr,titleName:cr,docsSlug:`dialog`}),vr=({titleId:e})=>{let t=_r(hr),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
11
|
+
|
|
12
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
13
|
+
|
|
14
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return X.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},yr=`DialogDescriptionWarning`,br=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${_r(yr).contentName}}.`;return X.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},xr=Kn,Sr=Qn,Cr=er,wr=ir,Tr=lr,Er=dr,Dr=pr;function Or(e){let t=X.useRef({value:e,previous:e});return X.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var kr=[`Enter`,` `],Ar=[`ArrowDown`,`PageUp`,`Home`],jr=[`ArrowUp`,`PageDown`,`End`],Mr=[...Ar,...jr],Nr={ltr:[...kr,`ArrowRight`],rtl:[...kr,`ArrowLeft`]},Pr={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Fr=`Menu`,[Ir,Lr,Rr]=M(Fr),[zr,Br]=b(Fr,[Rr,qe,Ee]),Vr=qe(),Hr=Ee(),[Ur,Wr]=zr(Fr),[Gr,Kr]=zr(Fr),qr=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Vr(t),[c,l]=X.useState(null),u=X.useRef(!1),d=f(a),p=A(i);return X.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,Z.jsx)(Ve,{...s,children:(0,Z.jsx)(Ur,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,Z.jsx)(Gr,{scope:t,onClose:X.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:p,modal:o,children:r})})})};qr.displayName=Fr;var Jr=`MenuAnchor`,Yr=X.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Vr(n);return(0,Z.jsx)(_e,{...i,...r,ref:t})});Yr.displayName=Jr;var Xr=`MenuPortal`,[Zr,Qr]=zr(Xr,{forceMount:void 0}),$r=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Wr(Xr,t);return(0,Z.jsx)(Zr,{scope:t,forceMount:n,children:(0,Z.jsx)(o,{present:n||a.open,children:(0,Z.jsx)(Ue,{asChild:!0,container:i,children:r})})})};$r.displayName=Xr;var ei=`MenuContent`,[ti,ni]=zr(ei),ri=X.forwardRef((e,t)=>{let n=Qr(ei,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Wr(ei,e.__scopeMenu),s=Kr(ei,e.__scopeMenu);return(0,Z.jsx)(Ir.Provider,{scope:e.__scopeMenu,children:(0,Z.jsx)(o,{present:r||a.open,children:(0,Z.jsx)(Ir.Slot,{scope:e.__scopeMenu,children:s.modal?(0,Z.jsx)(ii,{...i,ref:t}):(0,Z.jsx)(ai,{...i,ref:t})})})})}),ii=X.forwardRef((e,t)=>{let n=Wr(ei,e.__scopeMenu),r=X.useRef(null),i=y(t,r);return X.useEffect(()=>{let e=r.current;if(e)return Ge(e)},[]),(0,Z.jsx)(si,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:O(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),ai=X.forwardRef((e,t)=>{let n=Wr(ei,e.__scopeMenu);return(0,Z.jsx)(si,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),oi=Ye(`MenuContent.ScrollLock`),si=X.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:h,disableOutsideScroll:g,..._}=e,v=Wr(ei,n),b=Kr(ei,n),x=Vr(n),S=Hr(n),C=Lr(n),[w,T]=X.useState(null),E=X.useRef(null),D=y(t,E,v.onContentChange),k=X.useRef(0),A=X.useRef(``),j=X.useRef(0),M=X.useRef(null),N=X.useRef(`right`),P=X.useRef(0),F=g?L:X.Fragment,I=g?{as:oi,allowPinchZoom:!0}:void 0,R=e=>{let t=A.current+e,n=C().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Gi(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){A.current=t,window.clearTimeout(k.current),t!==``&&(k.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};X.useEffect(()=>()=>window.clearTimeout(k.current),[]),u();let B=X.useCallback(e=>N.current===M.current?.side&&qi(e,M.current?.area),[]);return(0,Z.jsx)(ti,{scope:n,searchRef:A,onItemEnter:X.useCallback(e=>{B(e)&&e.preventDefault()},[B]),onItemLeave:X.useCallback(e=>{B(e)||(E.current?.focus(),T(null))},[B]),onTriggerLeave:X.useCallback(e=>{B(e)&&e.preventDefault()},[B]),pointerGraceTimerRef:j,onPointerGraceIntentChange:X.useCallback(e=>{M.current=e},[]),children:(0,Z.jsx)(F,{...I,children:(0,Z.jsx)(z,{asChild:!0,trapped:i,onMountAutoFocus:O(a,e=>{e.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,Z.jsx)(m,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:h,children:(0,Z.jsx)(Me,{asChild:!0,...S,dir:b.dir,orientation:`vertical`,loop:r,currentTabStopId:w,onCurrentTabStopIdChange:T,onEntryFocus:O(c,e=>{b.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,Z.jsx)(ie,{role:`menu`,"aria-orientation":`vertical`,"data-state":Bi(v.open),"data-radix-menu-content":``,dir:b.dir,...x,..._,ref:D,style:{outline:`none`,..._.style},onKeyDown:O(_.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&R(e.key));let i=E.current;if(e.target!==i||!Mr.includes(e.key))return;e.preventDefault();let a=C().filter(e=>!e.disabled).map(e=>e.ref.current);jr.includes(e.key)&&a.reverse(),Ui(a)}),onBlur:O(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(k.current),A.current=``)}),onPointerMove:O(e.onPointerMove,Ji(e=>{let t=e.target,n=P.current!==e.clientX;e.currentTarget.contains(t)&&n&&(N.current=e.clientX>P.current?`right`:`left`,P.current=e.clientX)}))})})})})})})});ri.displayName=ei;var ci=`MenuGroup`,li=X.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,Z.jsx)(w.div,{role:`group`,...r,ref:t})});li.displayName=ci;var ui=`MenuLabel`,di=X.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,Z.jsx)(w.div,{...r,ref:t})});di.displayName=ui;var fi=`MenuItem`,pi=`menu.itemSelect`,mi=X.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=X.useRef(null),o=Kr(fi,e.__scopeMenu),s=ni(fi,e.__scopeMenu),c=y(t,a),l=X.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(pi,{bubbles:!0,cancelable:!0});e.addEventListener(pi,e=>r?.(e),{once:!0}),F(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,Z.jsx)(hi,{...i,ref:c,disabled:n,onClick:O(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:O(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:O(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||kr.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});mi.displayName=fi;var hi=X.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=ni(fi,n),s=Hr(n),c=X.useRef(null),l=y(t,c),[u,d]=X.useState(!1),[f,p]=X.useState(``);return X.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,Z.jsx)(Ir.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,Z.jsx)(me,{asChild:!0,...s,focusable:!r,children:(0,Z.jsx)(w.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:O(e.onPointerMove,Ji(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:O(e.onPointerLeave,Ji(e=>o.onItemLeave(e))),onFocus:O(e.onFocus,()=>d(!0)),onBlur:O(e.onBlur,()=>d(!1))})})})}),gi=`MenuCheckboxItem`,_i=X.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,Z.jsx)(Ti,{scope:e.__scopeMenu,checked:n,children:(0,Z.jsx)(mi,{role:`menuitemcheckbox`,"aria-checked":Vi(n)?`mixed`:n,...i,ref:t,"data-state":Hi(n),onSelect:O(i.onSelect,()=>r?.(Vi(n)?!0:!n),{checkForDefaultPrevented:!1})})})});_i.displayName=gi;var vi=`MenuRadioGroup`,[yi,bi]=zr(vi,{value:void 0,onValueChange:()=>{}}),xi=X.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=f(r);return(0,Z.jsx)(yi,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,Z.jsx)(li,{...i,ref:t})})});xi.displayName=vi;var Si=`MenuRadioItem`,Ci=X.forwardRef((e,t)=>{let{value:n,...r}=e,i=bi(Si,e.__scopeMenu),a=n===i.value;return(0,Z.jsx)(Ti,{scope:e.__scopeMenu,checked:a,children:(0,Z.jsx)(mi,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Hi(a),onSelect:O(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Ci.displayName=Si;var wi=`MenuItemIndicator`,[Ti,Ei]=zr(wi,{checked:!1}),Di=X.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Ei(wi,n);return(0,Z.jsx)(o,{present:r||Vi(a.checked)||a.checked===!0,children:(0,Z.jsx)(w.span,{...i,ref:t,"data-state":Hi(a.checked)})})});Di.displayName=wi;var Oi=`MenuSeparator`,ki=X.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,Z.jsx)(w.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});ki.displayName=Oi;var Ai=`MenuArrow`,ji=X.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Vr(n);return(0,Z.jsx)(he,{...i,...r,ref:t})});ji.displayName=Ai;var Mi=`MenuSub`,[Ni,Pi]=zr(Mi),Fi=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Wr(Mi,t),o=Vr(t),[s,c]=X.useState(null),[l,u]=X.useState(null),d=f(i);return X.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,Z.jsx)(Ve,{...o,children:(0,Z.jsx)(Ur,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,Z.jsx)(Ni,{scope:t,contentId:Ce(),triggerId:Ce(),trigger:s,onTriggerChange:c,children:n})})})};Fi.displayName=Mi;var Ii=`MenuSubTrigger`,Li=X.forwardRef((e,t)=>{let n=Wr(Ii,e.__scopeMenu),r=Kr(Ii,e.__scopeMenu),i=Pi(Ii,e.__scopeMenu),a=ni(Ii,e.__scopeMenu),o=X.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=X.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return X.useEffect(()=>u,[u]),X.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,Z.jsx)(Yr,{asChild:!0,...l,children:(0,Z.jsx)(hi,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Bi(n.open),...e,ref:ee(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:O(e.onPointerMove,Ji(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:O(e.onPointerLeave,Ji(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:O(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Nr[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Li.displayName=Ii;var Ri=`MenuSubContent`,zi=X.forwardRef((e,t)=>{let n=Qr(ei,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Wr(ei,e.__scopeMenu),s=Kr(ei,e.__scopeMenu),c=Pi(Ri,e.__scopeMenu),l=X.useRef(null),u=y(t,l);return(0,Z.jsx)(Ir.Provider,{scope:e.__scopeMenu,children:(0,Z.jsx)(o,{present:r||a.open,children:(0,Z.jsx)(Ir.Slot,{scope:e.__scopeMenu,children:(0,Z.jsx)(si,{id:c.contentId,"aria-labelledby":c.triggerId,...i,ref:u,align:`start`,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:O(e.onFocusOutside,e=>{e.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:O(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:O(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Pr[s.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});zi.displayName=Ri;function Bi(e){return e?`open`:`closed`}function Vi(e){return e===`indeterminate`}function Hi(e){return Vi(e)?`indeterminate`:e?`checked`:`unchecked`}function Ui(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Wi(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Gi(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Wi(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Ki(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function qi(e,t){return t?Ki({x:e.clientX,y:e.clientY},t):!1}function Ji(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Yi=qr,Xi=Yr,Zi=$r,Qi=ri,$i=li,ea=di,ta=mi,na=_i,ra=xi,ia=Ci,aa=Di,oa=ki,sa=ji,ca=Li,la=zi,ua=`DropdownMenu`,[da,fa]=b(ua,[Br]),pa=Br(),[ma,ha]=da(ua),ga=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=pa(t),l=X.useRef(null),[u,d]=xe({prop:i,defaultProp:a??!1,onChange:o,caller:ua});return(0,Z.jsx)(ma,{scope:t,triggerId:Ce(),triggerRef:l,contentId:Ce(),open:u,onOpenChange:d,onOpenToggle:X.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,Z.jsx)(Yi,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};ga.displayName=ua;var _a=`DropdownMenuTrigger`,va=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ha(_a,n),o=pa(n);return(0,Z.jsx)(Xi,{asChild:!0,...o,children:(0,Z.jsx)(w.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:ee(t,a.triggerRef),onPointerDown:O(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:O(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});va.displayName=_a;var ya=`DropdownMenuPortal`,ba=e=>{let{__scopeDropdownMenu:t,...n}=e,r=pa(t);return(0,Z.jsx)(Zi,{...r,...n})};ba.displayName=ya;var xa=`DropdownMenuContent`,Sa=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ha(xa,n),a=pa(n),o=X.useRef(!1);return(0,Z.jsx)(Qi,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:O(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:O(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Sa.displayName=xa;var Ca=`DropdownMenuGroup`,wa=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pa(n);return(0,Z.jsx)($i,{...i,...r,ref:t})});wa.displayName=Ca;var Ta=`DropdownMenuLabel`,Ea=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pa(n);return(0,Z.jsx)(ea,{...i,...r,ref:t})});Ea.displayName=Ta;var Da=`DropdownMenuItem`,Oa=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pa(n);return(0,Z.jsx)(ta,{...i,...r,ref:t})});Oa.displayName=Da;var ka=`DropdownMenuCheckboxItem`,Aa=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pa(n);return(0,Z.jsx)(na,{...i,...r,ref:t})});Aa.displayName=ka;var ja=`DropdownMenuRadioGroup`,Ma=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pa(n);return(0,Z.jsx)(ra,{...i,...r,ref:t})});Ma.displayName=ja;var Na=`DropdownMenuRadioItem`,Pa=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pa(n);return(0,Z.jsx)(ia,{...i,...r,ref:t})});Pa.displayName=Na;var Fa=`DropdownMenuItemIndicator`,Ia=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pa(n);return(0,Z.jsx)(aa,{...i,...r,ref:t})});Ia.displayName=Fa;var La=`DropdownMenuSeparator`,Ra=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pa(n);return(0,Z.jsx)(oa,{...i,...r,ref:t})});Ra.displayName=La;var za=`DropdownMenuArrow`,Ba=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pa(n);return(0,Z.jsx)(sa,{...i,...r,ref:t})});Ba.displayName=za;var Va=`DropdownMenuSubTrigger`,Ha=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pa(n);return(0,Z.jsx)(ca,{...i,...r,ref:t})});Ha.displayName=Va;var Ua=`DropdownMenuSubContent`,Wa=X.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pa(n);return(0,Z.jsx)(la,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Wa.displayName=Ua;var Ga=ga,Ka=va,qa=ba,Ja=Sa,Ya=Oa,Xa=`Label`,Za=X.forwardRef((e,t)=>(0,Z.jsx)(w.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));Za.displayName=Xa;var Qa=Za,$a=`Popover`,[eo,to]=b($a,[qe]),no=qe(),[ro,io]=eo($a),ao=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=no(t),c=X.useRef(null),[l,u]=X.useState(!1),[d,f]=xe({prop:r,defaultProp:i??!1,onChange:a,caller:$a});return(0,Z.jsx)(Ve,{...s,children:(0,Z.jsx)(ro,{scope:t,contentId:Ce(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:X.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:X.useCallback(()=>u(!0),[]),onCustomAnchorRemove:X.useCallback(()=>u(!1),[]),modal:o,children:n})})};ao.displayName=$a;var oo=`PopoverAnchor`,so=X.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=io(oo,n),a=no(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return X.useEffect(()=>(o(),()=>s()),[o,s]),(0,Z.jsx)(_e,{...a,...r,ref:t})});so.displayName=oo;var co=`PopoverTrigger`,lo=X.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=io(co,n),a=no(n),o=y(t,i.triggerRef),s=(0,Z.jsx)(w.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":To(i.open),...r,ref:o,onClick:O(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,Z.jsx)(_e,{asChild:!0,...a,children:s})});lo.displayName=co;var uo=`PopoverPortal`,[fo,po]=eo(uo,{forceMount:void 0}),mo=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=io(uo,t);return(0,Z.jsx)(fo,{scope:t,forceMount:n,children:(0,Z.jsx)(o,{present:n||a.open,children:(0,Z.jsx)(Ue,{asChild:!0,container:i,children:r})})})};mo.displayName=uo;var ho=`PopoverContent`,go=X.forwardRef((e,t)=>{let n=po(ho,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=io(ho,e.__scopePopover);return(0,Z.jsx)(o,{present:r||a.open,children:a.modal?(0,Z.jsx)(vo,{...i,ref:t}):(0,Z.jsx)(yo,{...i,ref:t})})});go.displayName=ho;var _o=Ye(`PopoverContent.RemoveScroll`),vo=X.forwardRef((e,t)=>{let n=io(ho,e.__scopePopover),r=X.useRef(null),i=y(t,r),a=X.useRef(!1);return X.useEffect(()=>{let e=r.current;if(e)return Ge(e)},[]),(0,Z.jsx)(L,{as:_o,allowPinchZoom:!0,children:(0,Z.jsx)(bo,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:O(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:O(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:O(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),yo=X.forwardRef((e,t)=>{let n=io(ho,e.__scopePopover),r=X.useRef(!1),i=X.useRef(!1);return(0,Z.jsx)(bo,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),bo=X.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:d,...f}=e,p=io(ho,n),h=no(n);return u(),(0,Z.jsx)(z,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Z.jsx)(m,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:d,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>p.onOpenChange(!1),children:(0,Z.jsx)(ie,{"data-state":To(p.open),role:`dialog`,id:p.contentId,...h,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),xo=`PopoverClose`,So=X.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=io(xo,n);return(0,Z.jsx)(w.button,{type:`button`,...r,ref:t,onClick:O(e.onClick,()=>i.onOpenChange(!1))})});So.displayName=xo;var Co=`PopoverArrow`,wo=X.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=no(n);return(0,Z.jsx)(he,{...i,...r,ref:t})});wo.displayName=Co;function To(e){return e?`open`:`closed`}var Eo=ao,Do=lo,Oo=mo,ko=go,Ao=`Switch`,[jo,Mo]=b(Ao),[No,Po]=jo(Ao),Fo=X.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=X.useState(null),m=y(t,e=>p(e)),h=X.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=xe({prop:i,defaultProp:a??!1,onChange:l,caller:Ao});return(0,Z.jsxs)(No,{scope:n,checked:_,disabled:s,children:[(0,Z.jsx)(w.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Bo(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:O(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,Z.jsx)(zo,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Fo.displayName=Ao;var Io=`SwitchThumb`,Lo=X.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Po(Io,n);return(0,Z.jsx)(w.span,{"data-state":Bo(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});Lo.displayName=Io;var Ro=`SwitchBubbleInput`,zo=X.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=X.useRef(null),s=y(o,a),c=Or(n),l=ce(t);return X.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,Z.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});zo.displayName=Ro;function Bo(e){return e?`checked`:`unchecked`}var Vo=Fo,Ho=Lo,Uo=`Tabs`,[Wo,Go]=b(Uo,[Ee]),Ko=Ee(),[qo,Jo]=Wo(Uo),Yo=X.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=A(s),[d,f]=xe({prop:r,onChange:i,defaultProp:a??``,caller:Uo});return(0,Z.jsx)(qo,{scope:n,baseId:Ce(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,Z.jsx)(w.div,{dir:u,"data-orientation":o,...l,ref:t})})});Yo.displayName=Uo;var Xo=`TabsList`,Zo=X.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Jo(Xo,n),o=Ko(n);return(0,Z.jsx)(Me,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,Z.jsx)(w.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Zo.displayName=Xo;var Qo=`TabsTrigger`,$o=X.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Jo(Qo,n),s=Ko(n),c=ns(o.baseId,r),l=rs(o.baseId,r),u=r===o.value;return(0,Z.jsx)(me,{asChild:!0,...s,focusable:!i,active:u,children:(0,Z.jsx)(w.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:O(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:O(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:O(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});$o.displayName=Qo;var es=`TabsContent`,ts=X.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...s}=e,c=Jo(es,n),l=ns(c.baseId,r),u=rs(c.baseId,r),d=r===c.value,f=X.useRef(d);return X.useEffect(()=>{let e=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,Z.jsx)(o,{present:i||d,children:({present:n})=>(0,Z.jsx)(w.div,{"data-state":d?`active`:`inactive`,"data-orientation":c.orientation,role:`tabpanel`,"aria-labelledby":l,hidden:!n,id:u,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:f.current?`0s`:void 0},children:n&&a})})});ts.displayName=es;function ns(e,t){return`${e}-trigger-${t}`}function rs(e,t){return`${e}-content-${t}`}var is=Yo,as=Zo,os=$o,ss=ts,cs=`Toggle`,ls=X.forwardRef((e,t)=>{let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=xe({prop:n,onChange:i,defaultProp:r??!1,caller:cs});return(0,Z.jsx)(w.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:O(e.onClick,()=>{e.disabled||s(!o)})})});ls.displayName=cs;var us=`ToggleGroup`,[ds,fs]=b(us,[Ee]),ps=Ee(),ms=X.forwardRef((e,t)=>{let{type:n,...r}=e;if(n===`single`)return(0,Z.jsx)(_s,{...r,ref:t});if(n===`multiple`)return(0,Z.jsx)(vs,{...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${us}\``)});ms.displayName=us;var[hs,gs]=ds(us),_s=X.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=xe({prop:n,defaultProp:r??``,onChange:i,caller:us});return(0,Z.jsx)(hs,{scope:e.__scopeToggleGroup,type:`single`,value:X.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:X.useCallback(()=>s(``),[s]),children:(0,Z.jsx)(xs,{...a,ref:t})})}),vs=X.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=xe({prop:n,defaultProp:r??[],onChange:i,caller:us}),c=X.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=X.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,Z.jsx)(hs,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,Z.jsx)(xs,{...a,ref:t})})});ms.displayName=us;var[ys,bs]=ds(us),xs=X.forwardRef((e,t)=>{let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=ps(n),u=A(o),d={role:`group`,dir:u,...c};return(0,Z.jsx)(ys,{scope:n,rovingFocus:i,disabled:r,children:i?(0,Z.jsx)(Me,{asChild:!0,...l,orientation:a,dir:u,loop:s,children:(0,Z.jsx)(w.div,{...d,ref:t})}):(0,Z.jsx)(w.div,{...d,ref:t})})}),Ss=`ToggleGroupItem`,Cs=X.forwardRef((e,t)=>{let n=gs(Ss,e.__scopeToggleGroup),r=bs(Ss,e.__scopeToggleGroup),i=ps(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=X.useRef(null);return r.rovingFocus?(0,Z.jsx)(me,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,Z.jsx)(ws,{...s,ref:t})}):(0,Z.jsx)(ws,{...s,ref:t})});Cs.displayName=Ss;var ws=X.forwardRef((e,t)=>{let{__scopeToggleGroup:n,value:r,...i}=e,a=gs(Ss,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0};return(0,Z.jsx)(ls,{...a.type===`single`?o:void 0,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})}),Ts=ms,Es=Cs,[Ds,Os]=b(`Tooltip`,[qe]),ks=qe(),As=`TooltipProvider`,js=700,Ms=`tooltip.open`,[Ns,Ps]=Ds(As),Fs=e=>{let{__scopeTooltip:t,delayDuration:n=js,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=X.useRef(!0),s=X.useRef(!1),c=X.useRef(0);return X.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,Z.jsx)(Ns,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:X.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:X.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:X.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Fs.displayName=As;var Is=`Tooltip`,[Ls,Rs]=Ds(Is),zs=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Ps(Is,e.__scopeTooltip),l=ks(t),[u,d]=X.useState(null),f=Ce(),p=X.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=X.useRef(!1),[_,v]=xe({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Ms))):c.onClose(),a?.(e)},caller:Is}),y=X.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=X.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=X.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=X.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return X.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,Z.jsx)(Ve,{...l,children:(0,Z.jsx)(Ls,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:X.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:X.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};zs.displayName=Is;var Bs=`TooltipTrigger`,Vs=X.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Rs(Bs,n),a=Ps(Bs,n),o=ks(n),s=y(t,X.useRef(null),i.onTriggerChange),c=X.useRef(!1),l=X.useRef(!1),u=X.useCallback(()=>c.current=!1,[]);return X.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,Z.jsx)(_e,{asChild:!0,...o,children:(0,Z.jsx)(w.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:O(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:O(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:O(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:O(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:O(e.onBlur,i.onClose),onClick:O(e.onClick,i.onClose)})})});Vs.displayName=Bs;var Hs=`TooltipPortal`,[Us,Ws]=Ds(Hs,{forceMount:void 0}),Gs=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Rs(Hs,t);return(0,Z.jsx)(Us,{scope:t,forceMount:n,children:(0,Z.jsx)(o,{present:n||a.open,children:(0,Z.jsx)(Ue,{asChild:!0,container:i,children:r})})})};Gs.displayName=Hs;var Ks=`TooltipContent`,qs=X.forwardRef((e,t)=>{let n=Ws(Ks,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,s=Rs(Ks,e.__scopeTooltip);return(0,Z.jsx)(o,{present:r||s.open,children:s.disableHoverableContent?(0,Z.jsx)(Qs,{side:i,...a,ref:t}):(0,Z.jsx)(Js,{side:i,...a,ref:t})})}),Js=X.forwardRef((e,t)=>{let n=Rs(Ks,e.__scopeTooltip),r=Ps(Ks,e.__scopeTooltip),i=X.useRef(null),a=y(t,i),[o,s]=X.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=X.useCallback(()=>{s(null),d(!1)},[d]),p=X.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=nc(r,tc(r,n.getBoundingClientRect())),a=rc(t.getBoundingClientRect());s(ac([...i,...a])),d(!0)},[d]);return X.useEffect(()=>()=>f(),[f]),X.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),X.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!ic(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,Z.jsx)(Qs,{...e,ref:a})}),[Ys,Xs]=Ds(Is,{isInside:!1}),Zs=c(`TooltipContent`),Qs=X.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Rs(Ks,n),l=ks(n),{onClose:u}=c;return X.useEffect(()=>(document.addEventListener(Ms,u),()=>document.removeEventListener(Ms,u)),[u]),X.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,Z.jsx)(m,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,Z.jsxs)(ie,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,Z.jsx)(Zs,{children:r}),(0,Z.jsx)(Ys,{scope:n,isInside:!0,children:(0,Z.jsx)(Tn,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});qs.displayName=Ks;var $s=`TooltipArrow`,ec=X.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=ks(n);return Xs($s,n).isInside?null:(0,Z.jsx)(he,{...i,...r,ref:t})});ec.displayName=$s;function tc(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function nc(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function rc(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function ic(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function ac(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),oc(t)}function oc(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var sc=Fs,cc=zs,lc=Vs,uc=Gs,dc=qs,fc=ec,pc=K(`app-window`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),mc=K(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),hc=K(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),gc=K(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),_c=K(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),vc=K(`arrow-up-from-line`,[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),yc=K(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),bc=K(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),xc=K(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Sc=K(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Cc=K(`crosshair`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]]),wc=K(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Tc=K(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Ec=K(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),Dc=K(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Oc=K(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),kc=K(`git-pull-request-arrow`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v12`,key:`ih889a`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}]]),Ac=K(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),jc=K(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Mc=K(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),Nc=K(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Pc=K(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),Fc=K(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),Ic=K(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),Lc=K(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),Rc=K(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),zc=K(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),Bc=K(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Vc=K(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Hc=K(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Uc=K(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Wc=K(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Gc=K(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Kc=K(`square-kanban`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 7v7`,key:`1x2jlm`}],[`path`,{d:`M12 7v4`,key:`xawao1`}],[`path`,{d:`M16 7v9`,key:`1hp2iy`}]]),qc=K(`square-mouse-pointer`,[[`path`,{d:`M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z`,key:`xwnzip`}],[`path`,{d:`M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6`,key:`14rsvq`}]]),Jc=K(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Yc=K(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Xc=K(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Zc=1,Qc=.9,$c=.8,el=.17,tl=.1,nl=.999,rl=.9999,il=.99,al=/[\\\/_+.#"@\[\(\{&]/,ol=/[\\\/_+.#"@\[\(\{&]/g,sl=/[\s-]/,cl=/[\s-]/g;function ll(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Zc:il;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=ll(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Zc:al.test(e.charAt(l-1))?(d*=$c,p=e.slice(i,l-1).match(ol),p&&i>0&&(d*=nl**+p.length)):sl.test(e.charAt(l-1))?(d*=Qc,m=e.slice(i,l-1).match(cl),m&&i>0&&(d*=nl**+m.length)):(d*=el,i>0&&(d*=nl**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=rl)),(d<tl&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=ll(e,t,n,r,l+1,a+2,o),f*tl>d&&(d=f*tl)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function ul(e){return e.toLowerCase().replace(cl,` `)}function dl(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,ll(e,t,ul(e),ul(t),0,0,{})}var fl=`[cmdk-group=""]`,pl=`[cmdk-group-items=""]`,ml=`[cmdk-group-heading=""]`,hl=`[cmdk-item=""]`,gl=`${hl}:not([aria-disabled="true"])`,_l=`cmdk-item-select`,vl=`data-value`,yl=(e,t,n)=>dl(e,t,n),bl=X.createContext(void 0),xl=()=>X.useContext(bl),Sl=X.createContext(void 0),Cl=()=>X.useContext(Sl),wl=X.createContext(void 0),Tl=X.forwardRef((e,t)=>{let n=zl(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=zl(()=>new Set),i=zl(()=>new Map),a=zl(()=>new Map),o=zl(()=>new Set),s=Ll(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Ce(),y=Ce(),b=Ce(),x=X.useRef(null),S=Hl();Rl(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Rl(()=>{S(6,A)},[]);let C=X.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),S(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=j()?.id,C.emit()}),r||S(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=X.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),S(2,()=>{D(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{k(),D(),n.current.value||O(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();S(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function E(e,t){let r=s.current?.filter??yl;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(pl);t?t.appendChild(e.parentElement===t?e:e.closest(`${pl} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${pl} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${fl}[${vl}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(vl);C.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(fl)?.querySelector(ml))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return x.current?.querySelector(`${hl}[aria-selected="true"]`)}function M(){return Array.from(x.current?.querySelectorAll(gl)||[])}function N(e){let t=M()[e];t&&C.setState(`value`,t.getAttribute(vl))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(vl))}function F(e){let t=j()?.closest(fl),n;for(;t&&!n;)t=e>0?Fl(t,fl):Il(t,fl),n=t?.querySelector(gl);n?C.setState(`value`,n.getAttribute(vl)):P(e)}let I=()=>N(M().length-1),L=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},R=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return X.createElement(w.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&L(e);break;case`ArrowDown`:L(e);break;case`p`:case`k`:g&&e.ctrlKey&&R(e);break;case`ArrowUp`:R(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(_l);t.dispatchEvent(e)}}}}},X.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:Gl},c),Wl(e,e=>X.createElement(Sl.Provider,{value:C},X.createElement(bl.Provider,{value:T},e))))}),El=X.forwardRef((e,t)=>{let n=Ce(),r=X.useRef(null),i=X.useContext(wl),a=xl(),o=Ll(e),s=o.current?.forceMount??i?.forceMount;Rl(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Vl(n,r,[e.value,e.children,r],e.keywords),l=Cl(),u=Bl(e=>e.value&&e.value===c.current),d=Bl(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);X.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(_l,f),()=>t.removeEventListener(_l,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return X.createElement(w.div,{ref:ee(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),Dl=X.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Ce(),s=X.useRef(null),c=X.useRef(null),l=Ce(),u=xl(),d=Bl(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);Rl(()=>u.group(o),[]),Vl(o,s,[e.value,e.heading,c]);let f=X.useMemo(()=>({id:o,forceMount:i}),[i]);return X.createElement(w.div,{ref:ee(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&X.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Wl(e,e=>X.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},X.createElement(wl.Provider,{value:f},e))))}),Ol=X.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=X.useRef(null),a=Bl(e=>!e.search);return!n&&!a?null:X.createElement(w.div,{ref:ee(i,t),...r,"cmdk-separator":``,role:`separator`})}),kl=X.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=Cl(),o=Bl(e=>e.search),s=Bl(e=>e.selectedItemId),c=xl();return X.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),X.createElement(w.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Al=X.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=X.useRef(null),o=X.useRef(null),s=Bl(e=>e.selectedItemId),c=xl();return X.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),X.createElement(w.div,{ref:ee(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Wl(e,e=>X.createElement(`div`,{ref:ee(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),jl=X.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return X.createElement(xr,{open:n,onOpenChange:r},X.createElement(Sr,{container:o},X.createElement(Cr,{"cmdk-overlay":``,className:i}),X.createElement(wr,{"aria-label":e.label,"cmdk-dialog":``,className:a},X.createElement(Tl,{ref:t,...s}))))}),Ml=X.forwardRef((e,t)=>Bl(e=>e.filtered.count===0)?X.createElement(w.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Nl=X.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return X.createElement(w.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Wl(e,e=>X.createElement(`div`,{"aria-hidden":!0},e)))}),Pl=Object.assign(Tl,{List:Al,Item:El,Input:kl,Group:Dl,Separator:Ol,Dialog:jl,Empty:Ml,Loading:Nl});function Fl(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Il(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Ll(e){let t=X.useRef(e);return Rl(()=>{t.current=e}),t}var Rl=typeof window>`u`?X.useEffect:X.useLayoutEffect;function zl(e){let t=X.useRef();return t.current===void 0&&(t.current=e()),t}function Bl(e){let t=Cl(),n=()=>e(t.snapshot());return X.useSyncExternalStore(t.subscribe,n,n)}function Vl(e,t,n,r=[]){let i=X.useRef(),a=xl();return Rl(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(vl,s),i.current=s}),i}var Hl=()=>{let[e,t]=X.useState(),n=zl(()=>new Map);return Rl(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Ul(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Wl({asChild:e,children:t},n){return e&&X.isValidElement(t)?X.cloneElement(Ul(t),{ref:t.ref},n(t.props.children)):n(t)}var Gl={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},Kl=e=>(0,Z.jsx)(xr,{"data-slot":`dialog`,...e}),ql=e=>(0,Z.jsx)(Sr,{"data-slot":`dialog-portal`,...e}),Jl=e=>(0,Z.jsx)(Dr,{"data-slot":`dialog-close`,...e}),Yl=({className:e,...t})=>(0,Z.jsx)(Cr,{"data-slot":`dialog-overlay`,className:W(`fixed inset-0 isolate z-50 bg-black/70 duration-100 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t}),Xl=({className:e,children:t,showCloseButton:n=!0,overlayClassName:r,...i})=>(0,Z.jsxs)(ql,{children:[(0,Z.jsx)(Yl,{className:r}),(0,Z.jsxs)(wr,{"data-slot":`dialog-content`,className:W(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-2xl border border-border bg-card p-6 text-sm text-card-foreground shadow-2xl shadow-black/30 duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...i,children:[t,n&&(0,Z.jsx)(Dr,{"data-slot":`dialog-close`,asChild:!0,children:(0,Z.jsxs)(J,{variant:`ghost`,className:`absolute top-4 right-4`,size:`icon-sm`,children:[(0,Z.jsx)(Le,{}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]}),Zl=({className:e,...t})=>(0,Z.jsx)(`div`,{"data-slot":`dialog-header`,className:W(`flex flex-col gap-1.5`,e),...t}),Ql=({className:e,showCloseButton:t=!1,children:n,...r})=>(0,Z.jsxs)(`div`,{"data-slot":`dialog-footer`,className:W(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,Z.jsx)(Dr,{asChild:!0,children:(0,Z.jsx)(J,{variant:`outline`,children:`Close`})})]}),$l=({className:e,...t})=>(0,Z.jsx)(Tr,{"data-slot":`dialog-title`,className:W(`font-heading text-base leading-none font-medium`,e),...t}),eu=({className:e,...t})=>(0,Z.jsx)(Er,{"data-slot":`dialog-description`,className:W(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t}),tu=(0,X.forwardRef)(({className:e,...t},n)=>(0,Z.jsx)(`textarea`,{ref:n,"data-slot":`textarea`,className:W(`flex min-h-24 w-full resize-none rounded-xl border border-input bg-input/40 px-3 py-2.5 text-sm text-foreground transition-[border-color,box-shadow,background-color] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20`,e),...t}));tu.displayName=`Textarea`;function nu({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:W(`group/input-group relative flex h-9 w-full min-w-0 items-center rounded-4xl border border-transparent bg-input/50 transition-[color,box-shadow,background-color] outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-data-[align=block-end]:rounded-3xl has-data-[align=block-start]:rounded-3xl has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/30 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[textarea]:rounded-2xl has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,e),...t})}var ru=V(`flex h-auto cursor-text items-center justify-center gap-2 py-2 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 **:data-[slot=kbd]:rounded-3xl **:data-[slot=kbd]:bg-muted-foreground/10 **:data-[slot=kbd]:px-1.5 [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-3 has-[>button]:-ml-1 has-[>kbd]:-ml-1`,"inline-end":`order-last pr-3 has-[>button]:-mr-1 has-[>kbd]:-mr-1`,"block-start":`order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-3.5 [.border-b]:pb-3.5`,"block-end":`order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-3.5 [.border-t]:pt-3.5`}},defaultVariants:{align:`inline-start`}});function iu({className:e,align:t=`inline-start`,...n}){return(0,Z.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:W(ru({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}var au=V(`flex items-center gap-2 rounded-4xl text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-xl px-1.5 [&>svg:not([class*='size-'])]:size-3.5`,sm:``,"icon-xs":`size-6 rounded-xl p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function ou({className:e,type:t=`button`,variant:n=`ghost`,size:r=`xs`,...i}){return(0,Z.jsx)(J,{type:t,"data-size":r,variant:n,className:W(au({size:r}),e),...i})}function su({className:e,...t}){return(0,Z.jsx)(Ae,{"data-slot":`input-group-control`,className:W(`flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent`,e),...t})}function cu({className:e,...t}){return(0,Z.jsx)(Pl,{"data-slot":`command`,className:W(`flex size-full flex-col overflow-hidden rounded-4xl bg-popover p-1 text-popover-foreground`,e),...t})}function lu({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`command-input-wrapper`,className:`p-1 pb-0`,children:(0,Z.jsxs)(nu,{className:`h-9 bg-input/50`,children:[(0,Z.jsx)(Pl.Input,{"data-slot":`command-input`,className:W(`w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,e),...t}),(0,Z.jsx)(iu,{children:(0,Z.jsx)(Wc,{className:`size-4 shrink-0 opacity-50`})})]})})}function uu({className:e,...t}){return(0,Z.jsx)(Pl.List,{"data-slot":`command-list`,className:W(`no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none`,e),onWheelCapture:e=>{e.stopPropagation(),t.onWheelCapture?.(e)},...t})}function du({className:e,...t}){return(0,Z.jsx)(Pl.Empty,{"data-slot":`command-empty`,className:W(`py-6 text-center text-sm`,e),...t})}function fu({className:e,...t}){return(0,Z.jsx)(Pl.Group,{"data-slot":`command-group`,className:W(`overflow-hidden p-1.5 text-foreground **:[[cmdk-group-heading]]:px-3 **:[[cmdk-group-heading]]:py-2 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function pu({className:e,children:t,...n}){return(0,Z.jsxs)(Pl.Item,{"data-slot":`command-item`,className:W(`group/command-item relative flex cursor-pointer items-center gap-2 rounded-2xl px-3 py-2 text-sm font-medium outline-hidden select-none in-data-[slot=dialog-content]:rounded-3xl data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground`,e),...n,children:[t,(0,Z.jsx)(xc,{className:`ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100`})]})}function mu({className:e,...t}){return(0,Z.jsx)(Qa,{"data-slot":`label`,className:W(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var hu=e=>(0,Z.jsx)(Eo,{"data-slot":`popover`,...e}),gu=e=>(0,Z.jsx)(Do,{"data-slot":`popover-trigger`,...e}),_u=({className:e,align:t=`center`,sideOffset:n=4,...r})=>(0,Z.jsx)(Oo,{children:(0,Z.jsx)(ko,{"data-slot":`popover-content`,align:t,sideOffset:n,className:W(`z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2 rounded-xl border border-border bg-popover p-2 text-sm text-popover-foreground shadow-2xl shadow-black/30 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})}),vu=({className:e,...t})=>(0,Z.jsx)(`div`,{"data-slot":`popover-header`,className:W(`flex flex-col gap-1 text-sm`,e),...t}),yu=({className:e,...t})=>(0,Z.jsx)(`div`,{"data-slot":`popover-title`,className:W(`font-heading text-base font-medium`,e),...t}),bu=/[\s\-_/.:]+/,xu=/\d(?:[._:-]*\d)+/g,Su=e=>e.toLowerCase().trim().split(bu).filter(Boolean),Cu=(e,t)=>t===e?300:t.startsWith(e)?200:e.length>=3&&t.includes(e)?100:0,wu=e=>(e.toLowerCase().match(xu)??[]).map(e=>e.replace(/\D/g,``)).filter(e=>e.length>=2),Tu=e=>/^\d+$/.test(e),Eu=(e,t)=>{let n=0;for(let r of t){if(r===e){n=Math.max(n,250);continue}r.startsWith(e)&&(n=Math.max(n,150))}return n},Du=(e,t)=>{let n=Su(e);if(n.length===0)return 1;let r=t.flatMap(e=>Su(e??``)),i=[...new Set(t.flatMap(e=>wu(e??``)))];if(r.length===0&&i.length===0)return 0;let a=0;for(let e of n){let t=0;for(let n of r){let r=Cu(e,n);r>t&&(t=r)}if(t===0&&Tu(e)&&(t=Eu(e,i)),t===0)return 0;a+=t}return a},Ou=({label:e,triggerLabel:t,triggerAriaLabel:n,selectId:r,groups:i,disabled:a=!1,className:o,labelClassName:s,contentClassName:c,triggerClassName:l,isSelected:u,onSelect:d,closeOnSelect:f=!0})=>{let[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(!1),_=(0,X.useRef)(null),v=i.reduce((e,t)=>e+t.options.length,0)>4,y=(0,X.useCallback)(()=>{let e=_.current?.getBoundingClientRect();if(!e)return!1;let t=window.innerHeight-e.bottom-16,n=e.top-16;return t<320&&n>t},[]);return(0,X.useEffect)(()=>{if(!p)return;let e=()=>{g(y())};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[y,p]),(0,Z.jsxs)(`div`,{className:W(`flex flex-col gap-1.5`,o),children:[e&&(0,Z.jsx)(mu,{className:W(`text-xs font-medium text-muted-foreground`,s),htmlFor:r,children:e}),(0,Z.jsxs)(hu,{open:p,onOpenChange:e=>{e&&g(y()),m(e)},children:[(0,Z.jsx)(`div`,{className:`relative`,ref:_,children:(0,Z.jsx)(gu,{asChild:!0,children:(0,Z.jsxs)(J,{id:r,type:`button`,variant:`outline`,"aria-label":n??t,disabled:a,className:W(`w-full justify-between bg-input/40 px-3 text-left font-normal`,l),children:[(0,Z.jsx)(`span`,{className:`truncate`,children:t}),(0,Z.jsx)(ue,{className:`h-4 w-4 text-muted-foreground`})]})})}),(0,Z.jsx)(_u,{side:h?`top`:`bottom`,align:`start`,className:W(`w-[var(--radix-popover-trigger-width)] p-0`,c),children:(0,Z.jsxs)(cu,{filter:(e,t,n)=>Du(t,[e,...n??[]]),children:[v&&(0,Z.jsx)(lu,{placeholder:`Filter...`}),(0,Z.jsxs)(uu,{className:`max-h-72`,children:[(0,Z.jsx)(du,{children:`No matches`}),i.map((e,t)=>e.options.length===0?null:(0,Z.jsx)(fu,{heading:e.label||void 0,className:W(e.label?`border-t border-border/60 first:border-t-0 first:pt-0`:``),children:e.options.map(t=>(0,Z.jsx)(pu,{value:`${t.label} ${t.value}`,keywords:[t.label,t.value,e.label],disabled:t.disabled,"data-checked":u(t.value),onSelect:()=>{t.disabled||(d(t.value),f&&m(!1))},children:(0,Z.jsx)(`span`,{className:`truncate`,children:t.label})},t.value))},e.label||`group-${t}`))]})]})})]})]})},ku=({label:e,triggerLabel:t,triggerAriaLabel:n,selectId:r,groups:i,selectedValue:a,onChange:o,disabled:s=!1,labelClassName:c,contentClassName:l,triggerClassName:u})=>(0,Z.jsx)(Ou,{label:e,triggerLabel:t,triggerAriaLabel:n,selectId:r,groups:i,disabled:s,labelClassName:c,contentClassName:l,triggerClassName:u,isSelected:e=>a===e,onSelect:o}),Au=({model:e,showModelSelector:t,availableModels:n,onModelChange:r,selectId:i,label:a=`Model`,triggerAriaLabel:o,disabled:s=!1,className:c,triggerClassName:l})=>{let u=(0,X.useMemo)(()=>{let e=new Map;for(let t of n){let n=t.provider;e.has(n)||e.set(n,[]),e.get(n)?.push({value:t.id,label:t.label})}return Array.from(e.entries()).map(([e,t])=>({provider:e,models:t}))},[n]),d=e||`Use default model`;return t?(0,Z.jsx)(`div`,{className:W(c),children:(0,Z.jsx)(ku,{label:a,triggerLabel:d,triggerAriaLabel:o,selectId:i,selectedValue:e,onChange:r,disabled:s,contentClassName:`min-w-[22rem]`,triggerClassName:l,groups:[{label:``,options:[{value:``,label:`Use default model`}]},...u.map(e=>({label:e.provider,options:e.models}))]})}):null},ju=({variant:e,selectedModel:t,showVariantSelector:n,onVariantChange:r,selectId:i,label:a=`Variant`,triggerAriaLabel:o,disabled:s=!1,className:c,triggerClassName:l})=>{if(!n||!t)return null;let u=e||`Use model default`;return(0,Z.jsx)(`div`,{className:W(c),children:(0,Z.jsx)(ku,{label:a,triggerLabel:u,triggerAriaLabel:o,selectId:i,selectedValue:e,onChange:r,disabled:s,contentClassName:`min-w-[22rem]`,triggerClassName:l,groups:[{label:``,options:[{value:``,label:`Use model default`}]},{label:`Available levels`,options:t.variants.map(e=>({value:e,label:e}))}]})})},Mu=({helperModel:e,helperVariant:t,availableModels:n,isLoadingModels:r,onHelperModelChange:i,onHelperVariantChange:a,modelSelectId:o,variantSelectId:s,className:c,compact:l=!1,showHeader:u=!0})=>{let d=n.find(t=>t.id===e)??null,f=n.length>0,p=d!==null&&d.variants.length>0;return(0,Z.jsxs)(`div`,{className:W(`rounded-2xl border border-border/70 bg-background/25 p-4`,c),children:[u&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-foreground`,children:`Helper model`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Used for auto-config and other lightweight project tasks. Leave empty to use the selected tool's default model.`})]}),r?(0,Z.jsx)(`p`,{className:W(`text-sm text-muted-foreground`,u?`mt-4`:``),children:`Loading OpenCode models...`}):f?(0,Z.jsxs)(`div`,{className:W(u?`mt-4`:``,`gap-3`,l?`flex flex-col`:`flex flex-wrap`),children:[(0,Z.jsx)(Au,{model:e,showModelSelector:f,availableModels:n,onModelChange:i,selectId:o,className:l?`min-w-0`:`min-w-[10rem] flex-[1.35_1_10rem]`}),p&&(0,Z.jsx)(ju,{variant:t,selectedModel:d,showVariantSelector:p,onVariantChange:a,selectId:s,className:l?`min-w-0`:`min-w-[7rem] flex-[0.7_1_7rem]`})]}):(0,Z.jsx)(`p`,{className:W(`text-sm text-muted-foreground`,u?`mt-4`:``),children:`OpenCode model discovery is unavailable right now. Leave this empty to use the selected tool's default model.`})]})},Nu=({delayDuration:e=0,...t})=>(0,Z.jsx)(sc,{"data-slot":`tooltip-provider`,delayDuration:e,...t}),Pu=e=>(0,Z.jsx)(cc,{"data-slot":`tooltip`,...e}),Fu=e=>(0,Z.jsx)(lc,{"data-slot":`tooltip-trigger`,...e}),Iu=({className:e,sideOffset:t=8,children:n,...r})=>(0,Z.jsx)(uc,{children:(0,Z.jsxs)(dc,{"data-slot":`tooltip-content`,sideOffset:t,className:W(`pointer-events-none z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) select-none items-center gap-1.5 rounded-md border border-sky-500/20 bg-popover px-2.5 py-1.5 text-xs font-medium text-popover-foreground shadow-lg data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[n,(0,Z.jsx)(fc,{className:`fill-popover`})]})}),Lu=({content:e,children:t,align:n,side:r,sideOffset:i,disabled:a=!1,contentClassName:o,delayDuration:s=0})=>(0,Z.jsx)(Nu,{delayDuration:s,disableHoverableContent:!0,children:(0,Z.jsxs)(Pu,{children:[(0,Z.jsx)(Fu,{asChild:!0,children:t}),a?null:(0,Z.jsx)(Iu,{className:o,align:n,side:r,sideOffset:i??8,children:e})]})}),Ru=({value:e,items:t,onChange:n,disabled:r=!1,className:i})=>(0,Z.jsx)(`div`,{className:W(`flex items-center gap-1 rounded-xl border border-border/70 bg-background/70 p-1 shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]`,i),children:t.map(t=>{let i=t.value===e,a=(0,Z.jsx)(J,{type:`button`,variant:i?t.activeVariant??`default`:`ghost`,size:`sm`,disabled:r,className:W(`h-7 rounded-lg px-2.5 text-xs`,i?t.activeClassName:t.inactiveClassName??`text-muted-foreground hover:text-foreground`),onClick:()=>n(t.value),children:t.label},t.value);return i||!t.inactiveTooltip||r?a:(0,Z.jsx)(Lu,{content:t.inactiveTooltip,children:a},t.value)})}),zu=({activeTool:e,onChange:t})=>(0,Z.jsx)(Ru,{value:e,items:[{value:`opencode`,label:`OpenCode`},{value:`claude`,label:`Claude`}],onChange:t}),Bu=({activeTool:e,availableHelperModels:t,helperModel:n,helperVariant:r,isHelperModelsLoaded:i,isToolLoaded:a,onCreateProject:o,onHelperModelChange:s,onHelperVariantChange:c,onToolChange:l})=>{let{t:u}=ht(`common`);return(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 py-10`,children:(0,Z.jsxs)(`div`,{className:`w-full max-w-3xl overflow-hidden rounded-[2rem] border border-border bg-[radial-gradient(circle_at_top_left,_rgba(52,211,153,0.18),_transparent_42%),linear-gradient(160deg,_rgba(20,24,34,1),_rgba(10,12,18,1))] p-8 shadow-2xl shadow-black/20 sm:p-10`,children:[(0,Z.jsx)(`h2`,{className:`max-w-xl text-3xl font-semibold tracking-tight text-foreground sm:text-4xl`,children:u(`emptyState.title`)}),(0,Z.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u(`emptyState.description`)}),a?(0,Z.jsx)(`div`,{className:`w-fit`,children:(0,Z.jsx)(zu,{activeTool:e,onChange:l})}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u(`emptyState.loadingToolPreference`)}),(0,Z.jsx)(Mu,{helperModel:n,helperVariant:r,availableModels:t,isLoadingModels:!i,onHelperModelChange:s,onHelperVariantChange:c,modelSelectId:`welcome-helper-model`,variantSelectId:`welcome-helper-variant`,compact:!0})]}),(0,Z.jsx)(`div`,{className:`mt-8 flex flex-col gap-3 sm:flex-row sm:items-center`,children:(0,Z.jsx)(J,{type:`button`,onClick:o,variant:`success`,size:`lg`,children:u(`emptyState.createFirstProject`)})})]})})},Vu=({className:e})=>(0,Z.jsx)(Gc,{"aria-hidden":`true`,className:e}),Hu=({activeProjectId:e,projects:t,onEditProject:n,onProjectChange:r})=>{let[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(null),l=t.find(t=>t.id===e)??null,u=t.length>4,d=(0,X.useCallback)(()=>{let e=c.current?.getBoundingClientRect();if(!e)return!1;let t=window.innerHeight-e.bottom-16,n=e.top-16;return t<320&&n>t},[]);return(0,X.useEffect)(()=>{if(!i)return;let e=()=>{s(d())};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[d,i]),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-stretch`,children:[(0,Z.jsxs)(hu,{open:i,onOpenChange:e=>{e&&s(d()),a(e)},children:[(0,Z.jsx)(`div`,{className:`relative min-w-0 flex-1`,ref:c,children:(0,Z.jsx)(gu,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-label":`Active project`,disabled:t.length===0,className:`group flex h-10 w-full min-w-0 cursor-pointer items-center justify-between gap-2 rounded-l-xl rounded-r-none border border-border/70 bg-card/70 px-3 text-left transition-colors hover:border-border hover:bg-accent/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 disabled:cursor-not-allowed disabled:opacity-60`,children:[(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:l?.name??`No projects yet`})}),(0,Z.jsx)(`span`,{className:`flex h-6 w-6 items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground`,children:(0,Z.jsx)(oe,{className:`h-4 w-4`})})]})})}),(0,Z.jsx)(_u,{side:o?`top`:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[22rem] p-0`,children:(0,Z.jsxs)(cu,{filter:(e,t,n)=>Du(t,[e,...n??[]]),children:[u&&(0,Z.jsx)(lu,{placeholder:`Filter projects...`}),(0,Z.jsxs)(uu,{className:`max-h-72`,children:[(0,Z.jsx)(du,{children:`No matches`}),(0,Z.jsx)(fu,{children:t.map(t=>(0,Z.jsx)(pu,{value:`${t.name} ${t.id}`,keywords:[t.name,t.repo_path,t.id],"data-checked":t.id===e,onSelect:()=>{r(t.id),a(!1)},children:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate font-medium text-foreground`,children:t.name}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:t.repo_path})]})},t.id))})]})]})})]}),(0,Z.jsx)(J,{type:`button`,"aria-label":`Edit project settings`,onClick:n,disabled:!e,variant:`outline`,size:`icon-sm`,className:`h-10 rounded-l-none border-l-0 border-border/70 bg-card/70`,children:(0,Z.jsx)(Vu,{className:`h-4 w-4`})})]})};function Uu({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`skeleton`,className:W(`animate-pulse rounded-2xl bg-muted`,e),...t})}var Wu=({className:e=``})=>(0,Z.jsx)(Uu,{"aria-hidden":`true`,className:W(`inline-flex rounded-md bg-[linear-gradient(90deg,_rgba(30,35,49,0.9),_rgba(63,72,98,0.95),_rgba(30,35,49,0.9))]`,e)}),Gu=({stats:e=null,isLoading:t=!1,showFiles:n=!1,className:r=``})=>{if(!e&&!t)return null;if(t)return(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-stats-skeleton`,className:`flex items-center gap-2 text-[11px] font-medium ${r}`.trim(),children:(0,Z.jsx)(Wu,{className:`h-3.5 shrink-0 rounded-full ${n?`w-28`:`w-20`}`})});let i=e.files_changed===1?`1 file`:`${e.files_changed} files`;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-medium ${r}`.trim(),children:[n&&(0,Z.jsx)(`span`,{className:`text-muted-foreground text-nowrap`,children:i}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,e.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,e.deletions]})]})},Ku=({className:e})=>(0,Z.jsx)(Ec,{"aria-hidden":`true`,className:e}),qu=({className:e})=>(0,Z.jsx)(kc,{"aria-hidden":`true`,className:e}),Ju=({className:e})=>(0,Z.jsx)(pc,{"aria-hidden":`true`,className:e}),Yu=({className:e})=>(0,Z.jsx)(Vc,{"aria-hidden":`true`,className:e}),Xu=({className:e})=>(0,Z.jsx)(kc,{"aria-hidden":`true`,className:e}),Zu=({className:e})=>(0,Z.jsx)(Jc,{"aria-hidden":`true`,className:e}),Qu=({className:e})=>(0,Z.jsx)(Yc,{"aria-hidden":`true`,className:e}),$u=e(l(),1);function ed(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var td=e=>{switch(e){case`success`:return id;case`info`:return od;case`warning`:return ad;case`error`:return sd;default:return null}},nd=Array(12).fill(0),rd=({visible:e,className:t})=>X.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},X.createElement(`div`,{className:`sonner-spinner`},nd.map((e,t)=>X.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),id=X.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},X.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),ad=X.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},X.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),od=X.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},X.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),sd=X.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},X.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),cd=X.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},X.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),X.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),ld=()=>{let[e,t]=X.useState(document.hidden);return X.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},ud=1,dd=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:ud++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],X.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(pd(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!X.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!X.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!X.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!X.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||ud++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},fd=(e,t)=>{let n=t?.id||ud++;return dd.addToast({title:e,...t,id:n}),n},pd=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,Q=Object.assign(fd,{success:dd.success,info:dd.info,warning:dd.warning,error:dd.error,custom:dd.custom,message:dd.message,promise:dd.promise,dismiss:dd.dismiss,loading:dd.loading},{getHistory:()=>dd.toasts,getToasts:()=>dd.getActiveToasts()});ed(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function md(e){return e.label!==void 0}var hd=3,gd=`24px`,_d=`16px`,vd=4e3,yd=356,bd=14,xd=45,Sd=200;function Cd(...e){return e.filter(Boolean).join(` `)}function wd(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var Td=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:w,closeButtonAriaLabel:T=`Close toast`}=e,[E,D]=X.useState(null),[O,k]=X.useState(null),[A,j]=X.useState(!1),[M,N]=X.useState(!1),[P,F]=X.useState(!1),[I,L]=X.useState(!1),[R,z]=X.useState(!1),[B,V]=X.useState(0),[ee,te]=X.useState(0),H=X.useRef(n.duration||y||vd),ne=X.useRef(null),U=X.useRef(null),re=c===0,ie=c+1<=o,ae=n.type,oe=n.dismissible!==!1,se=n.className||``,ce=n.descriptionClassName||``,le=X.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),ue=X.useMemo(()=>n.closeButton??p,[n.closeButton,p]),de=X.useMemo(()=>n.duration||y||vd,[n.duration,y]),W=X.useRef(0),fe=X.useRef(0),pe=X.useRef(0),me=X.useRef(null),[G,he]=b.split(`-`),ge=X.useMemo(()=>s.reduce((e,t,n)=>n>=le?e:e+t.height,0),[s,le]),_e=ld(),ve=n.invert||t,ye=ae===`loading`;fe.current=X.useMemo(()=>le*x+ge,[le,ge]),X.useEffect(()=>{H.current=de},[de]),X.useEffect(()=>{j(!0)},[]),X.useEffect(()=>{let e=U.current;if(e){let t=e.getBoundingClientRect().height;return te(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),X.useLayoutEffect(()=>{if(!A)return;let e=U.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,te(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[A,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let be=X.useCallback(()=>{N(!0),V(fe.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},Sd)},[n,d,a,fe]);X.useEffect(()=>{if(n.promise&&ae===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||_e?(()=>{if(pe.current<W.current){let e=new Date().getTime()-W.current;H.current-=e}pe.current=new Date().getTime()})():H.current!==1/0&&(W.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),be()},H.current)),()=>clearTimeout(e)},[u,i,n,ae,_e,be]),X.useEffect(()=>{n.delete&&(be(),n.onDismiss==null||n.onDismiss.call(n,n))},[be,n.delete]);function xe(){return w?.loading?X.createElement(`div`,{className:Cd(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":ae===`loading`},w.loading):X.createElement(rd,{className:Cd(C?.loader,n?.classNames?.loader),visible:ae===`loading`})}let Se=n.icon||w?.[ae]||td(ae);return X.createElement(`li`,{tabIndex:0,ref:U,className:Cd(_,se,C?.toast,n?.classNames?.toast,C?.default,C?.[ae],n?.classNames?.[ae]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":A,"data-promise":!!n.promise,"data-swiped":R,"data-removed":M,"data-visible":ie,"data-y-position":G,"data-x-position":he,"data-index":c,"data-front":re,"data-swiping":P,"data-dismissible":oe,"data-type":ae,"data-invert":ve,"data-swipe-out":I,"data-swipe-direction":O,"data-expanded":!!(u||S&&A),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${M?B:fe.current}px`,"--initial-height":S?`auto`:`${ee}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),me.current=null},onPointerDown:e=>{e.button!==2&&(ye||!oe||(ne.current=new Date,V(fe.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),me.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(I||!oe)return;me.current=null;let e=Number(U.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(U.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-ne.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=xd||a>.11){V(fe.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),be(),L(!0);return}else{var o,s;(o=U.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=U.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}z(!1),F(!1),D(null)},onPointerMove:t=>{var n,r;if(!me.current||!oe||window.getSelection()?.toString().length>0)return;let i=t.clientY-me.current.y,a=t.clientX-me.current.x,o=e.swipeDirections??wd(b);!E&&(Math.abs(a)>1||Math.abs(i)>1)&&D(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(E===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(E===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&z(!0),(n=U.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=U.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},ue&&!n.jsx&&ae!==`loading`?X.createElement(`button`,{"aria-label":T,"data-disabled":ye,"data-close-button":!0,onClick:ye||!oe?()=>{}:()=>{be(),n.onDismiss==null||n.onDismiss.call(n,n)},className:Cd(C?.closeButton,n?.classNames?.closeButton)},w?.close??cd):null,(ae||n.icon||n.promise)&&n.icon!==null&&(w?.[ae]!==null||n.icon)?X.createElement(`div`,{"data-icon":``,className:Cd(C?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||xe():null,n.type===`loading`?null:Se):null,X.createElement(`div`,{"data-content":``,className:Cd(C?.content,n?.classNames?.content)},X.createElement(`div`,{"data-title":``,className:Cd(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?X.createElement(`div`,{"data-description":``,className:Cd(v,ce,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),X.isValidElement(n.cancel)?n.cancel:n.cancel&&md(n.cancel)?X.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{md(n.cancel)&&oe&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),be())},className:Cd(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,X.isValidElement(n.action)?n.action:n.action&&md(n.action)?X.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{md(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&be())},className:Cd(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function Ed(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function Dd(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?_d:gd;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var Od=X.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=hd,toastOptions:g,dir:_=Ed(),gap:v=bd,icons:y,containerAriaLabel:b=`Notifications`}=e,[x,S]=X.useState([]),C=X.useMemo(()=>n?x.filter(e=>e.toasterId===n):x.filter(e=>!e.toasterId),[x,n]),w=X.useMemo(()=>Array.from(new Set([i].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,i]),[T,E]=X.useState([]),[D,O]=X.useState(!1),[k,A]=X.useState(!1),[j,M]=X.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),N=X.useRef(null),P=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),F=X.useRef(null),I=X.useRef(!1),L=X.useCallback(e=>{S(t=>(t.find(t=>t.id===e.id)?.delete||dd.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return X.useEffect(()=>dd.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{$u.flushSync(()=>{S(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[x]),X.useEffect(()=>{if(d!==`system`){M(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?M(`dark`):M(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{M(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{M(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),X.useEffect(()=>{x.length<=1&&O(!1)},[x]),X.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;O(!0),(t=N.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===N.current||N.current?.contains(document.activeElement))&&O(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),X.useEffect(()=>{if(N.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,I.current=!1)}},[N.current]),X.createElement(`section`,{ref:t,"aria-label":`${b} ${P}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},w.map((t,n)=>{let[i,a]=t.split(`-`);return C.length?X.createElement(`ol`,{key:t,dir:_===`auto`?Ed():_,tabIndex:-1,ref:N,className:c,"data-sonner-toaster":!0,"data-sonner-theme":j,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${T[0]?.height||0}px`,"--width":`${yd}px`,"--gap":`${v}px`,...m,...Dd(l,u)},onBlur:e=>{I.current&&!e.currentTarget.contains(e.relatedTarget)&&(I.current=!1,F.current&&=(F.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||I.current||(I.current=!0,F.current=e.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{k||O(!1)},onDragEnd:()=>O(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||A(!0)},onPointerUp:()=>A(!1)},C.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>X.createElement(Td,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:k,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:L,toasts:C.filter(e=>e.position==n.position),heights:T.filter(e=>e.position==n.position),setHeights:E,expandByDefault:o,gap:v,expanded:D,swipeDirections:e.swipeDirections}))):null}))}),kd=[...[`plan`,`build`,`review`],`done`],Ad=e=>[...e].sort((e,t)=>{let n=e.bundle_execution_position??2**53-1,r=t.bundle_execution_position??2**53-1;if(n!==r)return n-r;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let i=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return i===0?e.id.localeCompare(t.id):i}),jd=(e,t)=>{let n=e.worktree_bundle_id?t.get(e.worktree_bundle_id)??null:null;return e.bundle&&n?{...e.bundle,...n,pull_request:n.pull_request??e.bundle.pull_request}:n??e.bundle??null},Md=e=>e.kind===`project_root`?!0:e.has_prepared_worktree!==!1,Nd=e=>e.filter(e=>e.kind!==`project_root`&&Md(e)),Pd=e=>[...e].filter(e=>e.session_id).sort((e,t)=>e.updated_at===t.updated_at?t.id.localeCompare(e.id):t.updated_at.localeCompare(e.updated_at))[0]??null,Fd=e=>[...e].filter(e=>e.state!==`plan`&&e.build_completed_at).sort((e,t)=>{let n=e.build_completed_at??``,r=t.build_completed_at??``;return n===r?e.updated_at===t.updated_at?t.id.localeCompare(e.id):t.updated_at.localeCompare(e.updated_at):r.localeCompare(n)})[0]??null,Id=e=>e.has_worktree??!!(e.bundle?.branch??e.branch),Ld=(e,t={})=>{let n=t.targetTicketId?e.find(e=>e.id===t.targetTicketId)??null:null,r=t.reviewOwnerTicketId?e.find(e=>e.id===t.reviewOwnerTicketId)??null:null,i=Fd(e),a=t.latestSessionTicketId?e.find(e=>e.id===t.latestSessionTicketId&&e.session_id)??null:Pd(e),o=t.latestSessionTicketId?e.find(e=>e.id===t.latestSessionTicketId)??null:null;return n??r??i??a??o??e.find(e=>Id(e))??e.find(e=>e.state!==`plan`)??e[0]??null},Rd=(e,t,n)=>{let r=new Map(t.map(e=>[e.id,e])),i=e.filter(e=>n===`done`?e.parked_at!==null:e.state===n&&e.parked_at===null),a=new Map;for(let e of i){if(!e.worktree_bundle_id)continue;let t=a.get(e.worktree_bundle_id);if(t){t.push(e);continue}a.set(e.worktree_bundle_id,[e])}let o=new Set;return i.flatMap(e=>{if(!e.worktree_bundle_id)return[{kind:`ticket`,ticket:e}];if(o.has(e.worktree_bundle_id))return[];o.add(e.worktree_bundle_id);let t=a.get(e.worktree_bundle_id)??[e];if(t.length===1)return[{kind:`ticket`,ticket:t[0]}];let i=jd(t[0],r);return i?[{kind:`bundle`,group:{id:`${i.id}:${n}`,bundle:i,column:n,tickets:Ad(t)}}]:t.map(e=>({kind:`ticket`,ticket:e}))})},zd=e=>`bundle-group:${e.id}`,Bd=e=>{if(!e.startsWith(`bundle-group:`))return null;let t=e.slice(13),n=t.lastIndexOf(`:`);if(n<=0)return null;let r=t.slice(0,n),i=t.slice(n+1);return kd.includes(i)?{bundleId:r,column:i}:null},Vd=e=>{let t=e.trim();for(;t!==``;){let e=t.match(/^(.*?) \(([^()]+)\)$/);if(!e)return t;let n=e[1]?.trim()??``,r=e[2]?.trim()??``,i=n.toLowerCase(),a=r.toLowerCase();if(i===a){t=n;continue}if(i.endsWith(` (${a})`)){t=n;continue}return t}return e.trim()},Hd=(e,t)=>{let n=Vd(e),r=t.trim();if(n===``||r===``)return n;let i=` (${r})`,a=n;for(;a.toLowerCase().endsWith(i.toLowerCase());)a=a.slice(0,-i.length).trimEnd();return a||n},Ud=e=>{if(e.kind===`project_root`)return e.branch===`__project_root__`?e.name??``:e.branch??``;let t=Vd(e.name||e.branch||``);return e.branch?Hd(t,e.branch):t},Wd=e=>{if(e.kind===`project_root`)return e.branch===`__project_root__`?`Project root`:`Project root (${e.branch})`;let t=Ud(e),n=e.branch??``,r=t.trim().toLowerCase(),i=n.trim().toLowerCase();return t===``||n===``?t||n:r===i?t:`${t} (${n})`},Gd=({className:e})=>(0,Z.jsx)(Oc,{"aria-hidden":`true`,className:e}),Kd=`Selected bundle`,qd=e=>!e||e.status===`loading`?null:e.status===`ready`&&e.branch?e.branch:e.status===`detached`?`Detached HEAD`:`Unknown branch`,Jd=(e,t,n)=>{if(e.active_target_kind===`bundle`&&e.active_target_bundle_id){let t=n.find(t=>t.id===e.active_target_bundle_id)??null;return t?Ud(t):Kd}return qd(t)??`Loading target...`},Yd=e=>{let t=qd(e);return t?`Repo root (${t})`:`Repo root`},Xd=(e,t,n)=>e.active_target_kind===`bundle`?n===null?`text-[#8d92aa]`:n?`text-amber-300`:`text-emerald-200`:t?.status===`ready`?t.canPull?`text-amber-300`:`text-emerald-200`:`text-[#8d92aa]`,Zd=({activeProject:e,branchState:t,bundles:n,branchSuggestions:r,activeTargetCanPull:i=null,isBundleLoading:a=!1,isLoading:o,onOpenChange:s,onSelectBundle:c,onSelectRepoRoot:l,onManageBundles:u})=>{let[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(!1),_=e.active_target_kind!==`bundle`,v=(0,X.useMemo)(()=>Nd(n),[n]),y=(0,X.useMemo)(()=>e.active_target_kind!==`bundle`||!e.active_target_bundle_id?null:n.find(t=>t.id===e.active_target_bundle_id)??null,[e.active_target_bundle_id,e.active_target_kind,n]),b=(0,X.useMemo)(()=>Jd(e,t,n),[e,t,n]),x=(0,X.useMemo)(()=>Yd(t),[t]),S=(0,X.useMemo)(()=>Xd(e,t,i),[e,i,t]),C=o||a,w=e.active_target_kind===`bundle`&&!!e.active_target_bundle_id&&y===null&&a,T=_&&t?.status===`loading`||w,E=(0,X.useMemo)(()=>{let e=r.current_branch;return[{key:`default`,label:`Default branch`,branch:r.default_branch},{key:`previous`,label:`Previous branch`,branch:r.previous_branch}].filter(t=>t.branch?t.branch!==e:!1).filter((e,t,n)=>n.findIndex(t=>t.branch===e.branch)===t)},[r]);(0,X.useEffect)(()=>{d&&m(t?.branch??``)},[t?.branch,d]);let D=e=>{f(e),s?.(e)},O=async e=>{g(!0);try{await c(e)&&f(!1)}catch(e){Q.error(e instanceof Error?e.message:`Unable to switch to that bundle right now.`)}finally{g(!1)}},k=async(e,t)=>{g(!0);try{await l(e,t)&&f(!1)}catch(e){Q.error(e instanceof Error?e.message:`Unable to switch the repo root target right now.`)}finally{g(!1)}};return(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsxs)(hu,{open:d,onOpenChange:D,children:[(0,Z.jsx)(gu,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-busy":T,className:`flex max-w-full cursor-pointer items-center overflow-hidden rounded-xl border border-border/70 bg-card/70 px-3 py-2 text-left shadow-sm transition hover:border-border hover:bg-accent/25 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60`,"data-testid":`active-project-branch`,children:T?(0,Z.jsx)(Wu,{className:`h-3.5 w-20`}):(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 ${S}`,children:[(0,Z.jsx)(Gd,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:b})]})})}),(0,Z.jsx)(_u,{align:`start`,className:`w-[26rem] max-w-[calc(100vw-2rem)] p-4`,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:`Project target`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Choose the repo root or a prepared bundle for new chat sessions.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(mu,{className:`text-xs font-medium text-muted-foreground`,children:`Target`}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border/70 bg-background/40 p-2`,children:[(0,Z.jsx)(J,{type:`button`,variant:_?`secondary`:`ghost`,className:`w-full justify-start`,disabled:h,onClick:()=>{k(null)},children:x}),(0,Z.jsxs)(`div`,{className:`relative min-h-10`,"data-testid":`project-target-options`,children:[C&&(0,Z.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-10 text-muted-foreground`,"data-testid":`project-target-options-spinner`,children:(0,Z.jsx)(ye,{className:`h-3.5 w-3.5 animate-spin`})}),(0,Z.jsx)(`div`,{className:`max-h-40 overflow-y-auto pr-7`,children:v.length===0&&!C?(0,Z.jsx)(`p`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:`No bundles loaded yet.`}):v.map(t=>(0,Z.jsx)(J,{type:`button`,variant:e.active_target_kind===`bundle`&&e.active_target_bundle_id===t.id?`secondary`:`ghost`,className:`w-full justify-start`,disabled:h,onClick:()=>{O(t.id)},children:Ud(t)},t.id))})]})]}),u&&(0,Z.jsx)(J,{type:`button`,disabled:h,onClick:()=>{f(!1),u()},className:`w-full`,children:`Manage bundles`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(mu,{className:`text-xs font-medium text-muted-foreground`,children:`Repo root branch`}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border/70 bg-background/40 p-3`,children:[(0,Z.jsx)(`div`,{className:`space-y-2`,children:E.length>0?E.map(({key:e,label:t,branch:n})=>(0,Z.jsxs)(J,{type:`button`,variant:`outline`,className:`w-full justify-between`,disabled:!_||h||!n,onClick:()=>{k(n)},children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n})]},e)):(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?`Loading branch suggestions...`:`No suggested branches available.`})}),(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsx)(mu,{htmlFor:`project-target-branch-input`,className:`text-xs text-muted-foreground`,children:`Switch or create branch`}),(0,Z.jsx)(Ae,{id:`project-target-branch-input`,value:p,disabled:!_||h,onChange:e=>m(e.target.value),placeholder:`feature/quick-fix`})]}),(0,Z.jsx)(J,{type:`button`,disabled:!_||!p.trim()||h,onClick:()=>{k(p)},children:`Switch`})]})]})]})]})})]})})},Qd=(e,t=!1)=>e?e.status===`loading`?{kind:`loading`}:e.status===`ready`&&e.branch?{kind:`text`,toneClassName:t?`text-amber-300`:`text-emerald-200`,value:e.branch}:e.status===`detached`?{kind:`text`,toneClassName:`text-[#8d92aa]`,value:``,translationKey:`projectFooter.detachedHead`}:{kind:`text`,toneClassName:`text-[#8d92aa]`,value:``,translationKey:`projectFooter.unknownBranch`}:null,$d=({activeProject:e,activeRun:t,branchState:n,targetGitStatus:r,isBoardLoadedForActiveProject:i,isProjectSyncing:a,isProjectIdeAvailable:o,isProjectRunAvailable:s,isRunStatusLoadedForActiveProject:c,isTerminalOpen:l,hasConfiguredTests:u,targetBundles:d,targetBranchSuggestions:f,isTargetBundleLoading:p,isTargetSelectorLoading:m,isTargetGitStatusLoading:h,onProjectChangesOpen:g,onProjectTestsOpen:_,onProjectPull:v,onProjectRunToggle:y,onTerminalToggle:b,onProjectIdeOpen:x,onTargetSelectorOpenChange:S,onSelectBundleTarget:C,onSelectRepoRootTarget:w,onManageBundles:T})=>{let{t:E}=ht(`common`),D=!!(e&&r&&r.behind>0),O=(()=>{let e=Qd(n,D);return e?.kind!==`text`||!e.translationKey?e:{...e,value:E(e.translationKey)}})(),k=O?.kind===`loading`,A=!!(e&&r&&r.branch&&r.behind>0&&!a),j=(r?.behind??0)>0&&(r?.ahead??0)>0?E(`projectFooter.sync`):E(`projectFooter.pull`),M=!!e,N=!!(e&&n?.diffStats?.is_dirty),P=E(l?`workspaceControls.hideTerminalAriaLabel`:`workspaceControls.openTerminalAriaLabel`),F=e?.active_target_kind??`repo_root`,I=e?.active_target_bundle_id??null,L=e!==null&&t?.kind===`project`&&t.project_id===e.id&&(t.target_kind??`repo_root`)===F&&((t.target_kind??`repo_root`)!==`bundle`||t.target_bundle_id===I),R=e!==null&&!L&&(!i||!c),z=!e||!L&&(!s||t!==null||R),B=E(L?`projectFooter.stop`:`projectFooter.run`),V=(()=>{if(!e)return E(`projectFooter.selectProjectFirst`);if(!L){if(!s)return E(`projectFooter.addRunConfig`);if(R)return E(`projectFooter.loadingProjectStatus`);if(t?.kind===`project`)return E(`projectFooter.stopSelectedTargetRun`);if(t?.kind===`ticket`)return E(`projectFooter.stopTicketBeforeSelectedTargetRun`)}})();return(0,Z.jsx)(`footer`,{className:`border-t border-border bg-background/95 px-6 py-3 backdrop-blur`,"data-testid":`project-footer`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-3 overflow-hidden px-1 text-xs text-muted-foreground sm:gap-4`,children:[e&&O&&(0,Z.jsx)(`div`,{className:`flex max-w-full items-center overflow-hidden`,children:(0,Z.jsx)(Zd,{activeProject:e,branchState:n,bundles:d,branchSuggestions:f,activeTargetCanPull:e?.active_target_kind===`bundle`?r?r.behind>0:h?null:!1:null,isBundleLoading:p,isLoading:m||k,onOpenChange:S,onSelectBundle:C,onSelectRepoRoot:w,onManageBundles:T})}),D&&(0,Z.jsxs)(J,{type:`button`,onClick:v,disabled:!A,variant:`outline`,className:`h-8 gap-2 px-3 text-xs`,children:[a?(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Xu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:a?j===E(`projectFooter.sync`)?E(`projectFooter.syncing`):E(`projectFooter.pulling`):j})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-3 sm:gap-4`,children:[N&&n?.diffStats&&(0,Z.jsx)(Gu,{stats:n.diffStats,showFiles:!0,className:`text-xs`}),M&&(0,Z.jsxs)(J,{type:`button`,"aria-label":E(`workspaceControls.changes`),onClick:g,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(qu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:E(`workspaceControls.changes`)})]}),u&&(0,Z.jsxs)(J,{type:`button`,"aria-label":E(`workspaceControls.tests`),onClick:_,disabled:!e,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Ku,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:E(`workspaceControls.tests`)})]}),(0,Z.jsxs)(J,{type:`button`,"aria-label":P,"aria-pressed":l,onClick:b,disabled:!e,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Qu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:E(`workspaceControls.terminal`)})]}),e&&o&&(0,Z.jsxs)(J,{type:`button`,onClick:x,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Ju,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:E(`workspaceControls.openIde`)})]}),(0,Z.jsxs)(J,{type:`button`,"data-testid":`project-root-run-button`,disabled:z,title:V,onClick:y,variant:L?`destructive`:`secondary`,className:[`gap-2`,L?``:`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white`,z?`bg-slate-700 text-slate-400 hover:bg-slate-700 hover:text-slate-400`:``].join(` `),children:[L&&(0,Z.jsx)(`span`,{className:`h-2 w-2 flex-shrink-0 rounded-full bg-emerald-400 animate-pulse`,"data-testid":`project-root-run-indicator`}),L?(0,Z.jsx)(Zu,{className:`h-4 w-4`}):(0,Z.jsx)(Yu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:B})]})]})]})})},ef=({state:e,className:t})=>e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-activity-indicator":`true`,"data-state":e,"data-testid":`workspace-activity-indicator`,className:W(`h-2 w-2 flex-shrink-0 rounded-full`,e===`running`?`animate-pulse bg-amber-300`:e===`inactive`?`bg-zinc-500/70 ring-1 ring-zinc-400/20`:e===`interrupted`?`bg-amber-400/80 ring-1 ring-amber-400/30`:e===`error`?`bg-rose-400/90 ring-1 ring-rose-400/30`:`bg-emerald-400/80 ring-1 ring-emerald-400/30`,t)}):null,tf=({className:e})=>(0,Z.jsx)(Hc,{"aria-hidden":`true`,className:e}),nf={"X-Archon-Desktop-Action":`mobile-access`},rf=e=>x(s(`/mobile-access/status`),{signal:e}),af=e=>x(s(`/mobile-access/enable`),{method:`POST`,headers:nf,body:e}),of=()=>x(s(`/mobile-access/disable`),{method:`POST`,headers:nf}),sf=e=>x(s(`/mobile-access/regenerate-pairing`),{method:`POST`,headers:nf,body:{preferred_project_id:e??null}}),cf=e=>x(s(`/mobile-access/sessions/${encodeURIComponent(e)}/revoke`),{method:`POST`,headers:nf}),lf=new Set,uf=null,df=null,ff=()=>{for(let e of lf)e(uf)},pf=()=>{df!==null&&(window.clearTimeout(df),df=null)},mf=e=>{if(typeof window>`u`||(pf(),e?.state!==`awaiting_pairing`||!e.pairing))return;let t=new Date(e.pairing.expires_at).getTime();if(Number.isNaN(t))return;let n=()=>{uf?.state!==`awaiting_pairing`||uf.pairing?.expires_at!==e.pairing?.expires_at||hf({...uf,state:`expired`,pairing:null})},r=t-Date.now();if(r<=0){n();return}df=window.setTimeout(n,r)},hf=e=>{uf=e,mf(e),ff()},gf=async e=>{let t=await rf(e);return hf(t),t},_f=()=>{let[e,t]=(0,X.useState)(uf);return(0,X.useEffect)(()=>(lf.add(t),()=>{lf.delete(t)}),[]),e},vf=e=>{(0,X.useEffect)(()=>{if(!e)return;let t=null,n=()=>{t?.abort(),t=new AbortController;let e=t;gf(e.signal).catch(e=>{k(e)}).finally(()=>{t===e&&(t=null)})};n();let r=e=>{hf(e)},i=()=>{n()};return e.on(`mobile-access:status`,r),e.on(`connect`,i),()=>{t?.abort(),e.off(`mobile-access:status`,r),e.off(`connect`,i)}},[e])},yf=e=>!e||e.state===`disabled`?`inactive`:e.state===`awaiting_pairing`?`running`:e.state===`connected`?`finished`:e.state===`expired`?`interrupted`:`error`,bf=e=>!e||e.state===`disabled`?`Mobile access disabled`:e.state===`awaiting_pairing`?`Mobile access ready to pair`:e.state===`connected`?`Mobile access connected`:e.state===`expired`?`Mobile pairing expired`:e.error??`Mobile access unavailable`,xf=e=>e?.state===`awaiting_pairing`?`border-amber-400/30 bg-amber-500/10 text-amber-100 hover:bg-amber-500/15 hover:text-amber-50`:e?.state===`connected`?`border-emerald-400/30 bg-emerald-500/10 text-emerald-100 hover:bg-emerald-500/15 hover:text-emerald-50`:e?.state===`expired`?`border-amber-400/20 bg-amber-500/6 text-amber-100/90 hover:bg-amber-500/12 hover:text-amber-50`:e?.state===`error`?`border-rose-400/30 bg-rose-500/10 text-rose-100 hover:bg-rose-500/15 hover:text-rose-50`:`border-border/70 bg-background/70 text-muted-foreground hover:bg-accent/20 hover:text-foreground`,Sf=({activeTool:e,onCreateProject:t,onMobileAccessOpen:n,onToolChange:r})=>{let i=_f();return(0,Z.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-start gap-3 sm:justify-end`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-1 rounded-xl border border-border/70 bg-background/70 p-1 shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]`,children:[`opencode`,`claude`].map(t=>{let n=e===t;return(0,Z.jsx)(J,{type:`button`,variant:n?`secondary`:`ghost`,size:`xs`,className:n?`rounded-lg px-2.5 text-xs text-foreground`:`rounded-lg px-2.5 text-xs text-muted-foreground hover:text-foreground`,onClick:()=>r(t),children:t===`opencode`?`OpenCode`:`Claude`},t)})}),n&&(0,Z.jsx)(Lu,{content:bf(i),children:(0,Z.jsxs)(J,{type:`button`,"aria-label":`Open mobile access`,onClick:n,variant:`ghost`,className:`h-8 gap-2 rounded-xl border px-3 text-sm font-medium ${xf(i)}`,children:[(0,Z.jsx)(ef,{state:yf(i),className:`mt-0`}),(0,Z.jsx)(`span`,{children:`Mobile`})]})})]}),(0,Z.jsxs)(J,{type:`button`,onClick:t,variant:`ghost`,className:`h-8 gap-2 rounded-xl border border-border/70 px-3 text-foreground hover:bg-accent/20`,children:[(0,Z.jsx)(tf,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`New project`})]})]})},Cf=()=>(0,Z.jsx)(Od,{closeButton:!0,expand:!0,theme:`dark`,position:`top-left`,richColors:!0,toastOptions:{classNames:{toast:`border border-border bg-card text-card-foreground shadow-2xl shadow-black/35`,title:`text-sm font-medium text-card-foreground`,description:`text-xs text-muted-foreground`,closeButton:`border border-border bg-secondary text-secondary-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,error:`border-red-500/30 bg-destructive/20 text-red-100`,success:`border-emerald-500/30 bg-emerald-500/15 text-emerald-100`,warning:`border-amber-500/30 bg-amber-500/15 text-amber-100`,info:`border-sky-500/30 bg-sky-500/15 text-sky-100`}}}),wf=[],Tf=!1,Ef=()=>{if(!(typeof window>`u`)){if(wf.length===0){Tf&&=(window.removeEventListener(`keydown`,Df),!1);return}Tf||=(window.addEventListener(`keydown`,Df),!0)}},Df=e=>{if(e.key!==`Escape`)return;let t=wf[wf.length-1];t&&t.onClose()},Of=(e,t={})=>{let{disabled:n=!1}=t,r=(0,X.useRef)(e);(0,X.useEffect)(()=>{r.current=e},[e]),(0,X.useEffect)(()=>{if(n)return;let e={id:Symbol(`escape-close`),onClose:()=>r.current()};return wf.push(e),Ef(),()=>{let t=wf.findIndex(t=>t.id===e.id);t!==-1&&wf.splice(t,1),Ef()}},[n])},kf=(...e)=>e.filter(Boolean).join(` `),Af=({children:e,onClose:t,overlayClassName:n,panelClassName:r,closeButtonClassName:i,closeButtonLabel:a=`Close modal`,renderContent:o})=>{Of(t);let s=(0,Z.jsx)(J,{type:`button`,"aria-label":a,variant:`ghost`,size:`icon-sm`,onClick:t,className:kf(`cursor-pointer text-muted-foreground hover:text-foreground`,i),children:(0,Z.jsx)(Fe,{className:`h-4 w-4`})});return(0,Z.jsx)(`div`,{className:kf(`fixed inset-0 z-50 flex items-center justify-center`,n),children:(0,Z.jsx)(`div`,{className:kf(`relative flex flex-col`,r),role:`dialog`,"aria-modal":`true`,onClick:e=>e.stopPropagation(),children:o?o({closeButton:s}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`absolute top-4 right-4 z-10`,children:s}),e]})})})},jf=({title:e,description:t,confirmLabel:n,cancelLabel:r,confirmVariant:i=`default`,onConfirm:a,onCancel:o})=>(0,Z.jsxs)(Af,{onClose:o,overlayClassName:`bg-black/60`,panelClassName:`max-w-md rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,Z.jsx)(`p`,{className:`mb-6 text-sm text-foreground whitespace-pre-line`,children:t}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(J,{type:`button`,variant:`ghost`,onClick:o,children:r}),(0,Z.jsx)(J,{type:`button`,variant:i,onClick:a,children:n})]})]}),Mf=({isSubmitting:e,onCreateInitialCommit:t})=>(0,Z.jsx)(`div`,{className:`mx-6 mt-4 mb-4 w-fit max-w-[calc(100%-3rem)] rounded-2xl border border-amber-500/35 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,role:`alert`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-4 lg:flex-row lg:items-center`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`This repository needs an initial commit before Archon can prepare bundle worktrees.`}),(0,Z.jsx)(`p`,{className:`text-xs leading-5 text-amber-100/90`,children:`Repo root chat still works. Create an initial commit to unblock bundle worktrees.`})]}),(0,Z.jsx)(J,{type:`button`,variant:`warning`,className:`shrink-0`,disabled:e,onClick:t,children:e?`Creating initial commit...`:`Create initial commit`})]})}),Nf=(0,X.forwardRef)(({className:e,size:t=`default`,...n},r)=>(0,Z.jsx)(`div`,{ref:r,"data-slot":`card`,"data-size":t,className:W(`flex flex-col gap-5 rounded-2xl border border-border/70 bg-card text-sm text-card-foreground shadow-xl shadow-black/10 data-[size=sm]:gap-4`,e),...n}));Nf.displayName=`Card`;var Pf=({className:e,...t})=>(0,Z.jsx)(`div`,{"data-slot":`card-header`,className:W(`grid auto-rows-min items-start gap-1.5 px-5 pt-5 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-5 data-[size=sm]:px-4 data-[size=sm]:pt-4`,e),...t}),Ff=({className:e,...t})=>(0,Z.jsx)(`div`,{"data-slot":`card-title`,className:W(`font-heading text-base font-medium`,e),...t}),If=({className:e,...t})=>(0,Z.jsx)(`div`,{"data-slot":`card-description`,className:W(`text-sm text-muted-foreground`,e),...t}),Lf=({className:e,...t})=>(0,Z.jsx)(`div`,{"data-slot":`card-action`,className:W(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t}),Rf=({className:e,...t})=>(0,Z.jsx)(`div`,{"data-slot":`card-content`,className:W(`px-5 pb-5 data-[size=sm]:px-4 data-[size=sm]:pb-4`,e),...t}),zf=({className:e,...t})=>(0,Z.jsx)(`div`,{"data-slot":`card-footer`,className:W(`flex items-center px-5 pb-5 data-[size=sm]:px-4 data-[size=sm]:pb-4 [.border-t]:pt-5`,e),...t}),Bf=({label:e,htmlFor:t,description:n,error:r,className:i,children:a})=>(0,Z.jsxs)(`div`,{className:W(`flex flex-col gap-1.5`,i),children:[(0,Z.jsx)(mu,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,htmlFor:t,children:e}),a,n&&(0,Z.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:n}),r&&(0,Z.jsx)(`p`,{className:`text-sm text-red-300`,children:r})]}),Vf=({className:e})=>(0,Z.jsx)(Xc,{"aria-hidden":`true`,className:e}),Hf=(e,t)=>e instanceof Error&&e.message?e.message:t,Uf=({bundles:e,selectedBundleId:t,activeTargetBundleId:n=null,onSelectBundle:r,onCreateBundle:i,onDeleteBundle:a,onClose:o})=>{let{t:s}=ht(`common`),c=Nd(e),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(null),_=async e=>{e.preventDefault();let t=l.trim();if(!(!t||d)){f(!0);try{r((await i(t)).id),o()}catch(e){Q.error(Hf(e,s(`manageBundlesModal.createError`)),{id:`manage-bundles-error`}),f(!1)}}},v=async e=>{if(!(e.kind===`project_root`||e.ticket_count>0||h)){g(e.id);try{await a(e.id),t===e.id&&r(null),m(null)}catch(e){Q.error(Hf(e,s(`manageBundlesModal.deleteError`)),{id:`manage-bundles-error`})}finally{g(null)}}};return(0,Z.jsx)(Af,{onClose:d?()=>{}:o,overlayClassName:`bg-black/70 px-4 py-8`,panelClassName:`w-full max-w-2xl rounded-3xl border border-[#2a2a38] bg-[#16161f] shadow-2xl`,renderContent:({closeButton:e})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-border px-6 py-5`,children:[(0,Z.jsx)(`h2`,{className:`text-2xl font-semibold text-foreground`,children:s(`manageBundlesModal.title`)}),d?null:e]}),(0,Z.jsxs)(`div`,{className:`flex max-h-[70vh] flex-col gap-6 px-6 py-5`,children:[(0,Z.jsxs)(Nf,{className:`rounded-3xl border-border bg-card/70 shadow-none`,children:[(0,Z.jsx)(Pf,{children:(0,Z.jsx)(Ff,{className:`text-sm font-semibold uppercase tracking-[0.24em] text-foreground`,children:s(`manageBundlesModal.createTitle`)})}),(0,Z.jsx)(Rf,{children:d?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-emerald-500/20 bg-emerald-500/5 px-4 py-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(`div`,{className:`mt-0.5 rounded-full bg-emerald-500/10 p-2 text-emerald-300`,children:(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`})}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:s(`manageBundlesModal.createPendingTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`manageBundlesModal.createPendingDescription`)})]})]})}):(0,Z.jsxs)(`form`,{onSubmit:_,className:`flex min-w-0 flex-col gap-4 sm:flex-row sm:items-end`,children:[(0,Z.jsx)(Bf,{label:s(`manageBundlesModal.bundleNameLabel`),className:`min-w-0 flex-1`,children:(0,Z.jsx)(Ae,{"aria-label":s(`manageBundlesModal.bundleNameAriaLabel`),type:`text`,value:l,onChange:e=>u(e.target.value),autoFocus:!0,placeholder:s(`manageBundlesModal.bundleNamePlaceholder`)})}),(0,Z.jsx)(J,{type:`submit`,disabled:!l.trim()||d,variant:`success`,size:`lg`,className:`sm:shrink-0`,children:s(`manageBundlesModal.createAction`)})]})})]}),(0,Z.jsxs)(Nf,{className:`flex min-h-0 flex-1 flex-col rounded-3xl border-border bg-card/70 shadow-none ${d?`opacity-60`:``}`,children:[(0,Z.jsx)(Pf,{children:(0,Z.jsx)(Ff,{className:`text-sm font-semibold uppercase tracking-[0.24em] text-foreground`,children:s(`manageBundlesModal.existingTitle`)})}),(0,Z.jsx)(Rf,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(`div`,{className:`space-y-3`,children:c.length===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border px-4 py-5 text-sm text-muted-foreground`,children:s(`manageBundlesModal.empty`)}):c.map(e=>{let r=t===e.id,i=n===e.id,a=e.kind===`project_root`||e.ticket_count>0||i||h!==null,o=p===e.id;return(0,Z.jsx)(Nf,{size:`sm`,className:`rounded-2xl border-border/80 bg-background/30 shadow-none`,children:(0,Z.jsx)(Rf,{className:`p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:Ud(e)}),r&&(0,Z.jsx)(q,{variant:`info`,children:s(`manageBundlesModal.selected`)}),i&&(0,Z.jsx)(q,{variant:`info`,children:s(`manageBundlesModal.currentTarget`)})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.kind===`project_root`?s(`manageBundlesModal.projectRootDescription`,{branch:e.branch}):i?s(`manageBundlesModal.switchTargetDescription`):e.ticket_count>0?s(`manageBundlesModal.inUseDescription`,{ticketCount:s(`manageBundlesModal.ticketCount`,{count:e.ticket_count})}):s(`manageBundlesModal.unusedDescription`)})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2 sm:shrink-0`,children:o?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(J,{type:`button`,onClick:()=>m(null),variant:`ghost`,children:s(`manageBundlesModal.cancel`)}),(0,Z.jsx)(J,{type:`button`,onClick:()=>void v(e),disabled:a,variant:`destructive`,children:h===e.id?s(`manageBundlesModal.deleting`):s(`manageBundlesModal.deleteBundle`)})]}):(0,Z.jsx)(J,{type:`button`,onClick:()=>m(e.id),disabled:a,variant:`destructive`,children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Z.jsx)(Vf,{className:`h-3.5 w-3.5`}),s(`manageBundlesModal.delete`)]})})})]})})},e.id)})})})]})]}),(0,Z.jsx)(`div`,{className:`border-t border-border px-6 py-4`,children:(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(J,{type:`button`,onClick:o,disabled:d,variant:`ghost`,children:s(`manageBundlesModal.close`)})})})]})})},Wf=i(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),Gf=i((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),Kf=i((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),qf=i(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Jf=i(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Yf=i((e=>{var t=Gf().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Xf=i((e=>{var t=Gf().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Zf=i((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),Qf=i((e=>{var t=Kf(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),$f=i((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),ep=i((e=>{var t=$f();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),tp=i(((e,t)=>{var n=ep();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),np=i((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),rp=i((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
15
|
+
]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),ip=i((e=>{var t=np(),n=rp();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),ap=i((e=>{var t=Gf(),n=Qf(),r=Kf(),i=ip(),a=np(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),op=i((e=>{var t=Gf(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),sp=i(((e,t)=>{var n=ip();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),cp=i(((e,t)=>{var n=ip(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),lp=i(((e,t)=>{var n=ip();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),up=i(((e,t)=>{var n=ip(),r=Gf();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
|
|
16
|
+
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),dp=i(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),fp=i((e=>{var t=ip(),n=sp(),r=cp(),i=lp(),a=up(),o=rp(),s=Gf(),c=dp();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
|
|
17
|
+
Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),pp=i((e=>{var t=Gf(),n=Kf(),r=qf(),i=Jf(),a=Yf(),o=Xf(),s=Zf(),c=Qf(),l=tp(),u=ap(),d=op(),f=ip(),p=fp();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
|
|
18
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
19
|
+
Minimum version required to store current data is: `+c+`.
|
|
20
|
+
`);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),mp=i((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),hp=i((e=>{var t=mp();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),gp=i((e=>{var t=mp();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
|
|
21
|
+
`;return typeof a==`function`&&a(null,p),p}})),_p=e(i((e=>{var t=Wf(),n=pp(),r=hp(),i=gp();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1),vp=e=>(0,Z.jsx)(Rn,{"data-slot":`collapsible`,...e}),yp=e=>(0,Z.jsx)(zn,{"data-slot":`collapsible-trigger`,...e}),bp=e=>(0,Z.jsx)(Bn,{"data-slot":`collapsible-content`,...e}),xp=`archon.mobile-access.custom-url`,Sp=`archon.mobile-access.mode`,Cp=`archon.mobile-access.guidance-open`,wp=`http://127.0.0.1:43111`,Tp=`Enter a valid HTTPS origin without a path, query, or fragment.`,Ep=e=>e.trim().length>0?`custom_public_url`:`lan`,Dp=()=>typeof window>`u`?``:window.localStorage.getItem(xp)??``,Op=e=>{if(!(typeof window>`u`)){if(e.length===0){window.localStorage.removeItem(xp);return}window.localStorage.setItem(xp,e)}},kp=e=>{if(typeof window>`u`)return Ep(e);let t=window.localStorage.getItem(Sp);return t===`lan`||t===`custom_public_url`||t===`ngrok`?t:Ep(e)},Ap=e=>{typeof window>`u`||window.localStorage.setItem(Sp,e)},jp=e=>`${Cp}:${e}`,Mp=e=>{if(typeof window>`u`)return!0;let t=window.localStorage.getItem(jp(e));return t===`true`?!0:t!==`false`},Np=(e,t)=>{typeof window>`u`||window.localStorage.setItem(jp(e),String(t))},Pp=e=>{let t=e.trim();if(t.length===0)return null;try{let e=new URL(t);return e.protocol!==`https:`||!e.host||e.pathname!==`/`||e.search.length>0||e.hash.length>0||e.username.length>0||e.password.length>0?Tp:null}catch{return Tp}},Fp=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()},Ip=(e,t)=>{let n=new Date(e).getTime();if(Number.isNaN(n))return`Expires ${e}`;let r=Math.max(0,Math.ceil((n-t)/1e3));if(r<=0)return`Expired`;let i=Math.floor(r/60),a=r%60;return i===0?`Expires in ${a}s`:`Expires in ${i}m ${a.toString().padStart(2,`0`)}s`},Lp=e=>e?e.state===`awaiting_pairing`?`Awaiting pairing`:e.state===`connected`?`Connected`:e.state===`expired`?`Pairing expired`:e.state===`error`?`Error`:`Disabled`:`Loading`,Rp=e=>e?.state===`connected`?`default`:e?.state===`awaiting_pairing`?`secondary`:e?.state===`error`?`destructive`:`outline`,zp=e=>e===`custom_public_url`?`Public HTTPS URL`:e===`ngrok`?`Managed ngrok`:`Trusted private LAN`,Bp=({mode:e})=>(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm text-amber-100`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:e===`custom_public_url`?`Use mobile access only through a public HTTPS URL you trust.`:e===`ngrok`?`Use mobile access only through the ngrok tunnel Archon starts for you.`:`Use mobile access only on a trusted private network.`}),(0,Z.jsx)(`p`,{className:`mt-1 text-amber-100/80`,children:e===`custom_public_url`?`The configured public origin should expose only the dedicated mobile listener. Paired devices can control Archon over the internet until you revoke them.`:e===`ngrok`?`Archon will start and stop ngrok automatically, but the tunnel still exposes only the dedicated mobile listener. Paired devices can control Archon over the internet until you revoke them.`:`Paired devices can control Archon until you revoke them.`})]}),Vp=({value:e,disabled:t,onChange:n})=>(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-2xl border border-border bg-background/70 p-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Access mode`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Choose whether the phone connects over your private LAN or through a public HTTPS origin.`})]}),(0,Z.jsx)(Ru,{className:`w-fit self-start`,value:e,disabled:t,onChange:n,items:[{value:`lan`,label:`Private LAN`},{value:`custom_public_url`,label:`Public URL`},{value:`ngrok`,label:`ngrok`}]})]}),Hp=({value:e,disabled:t,error:n,onChange:r})=>(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-2xl border border-border bg-background/70 p-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(mu,{htmlFor:`mobile-access-custom-url`,className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Custom public URL`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Saved locally on this desktop so you can reuse or edit it before future connections.`})]}),(0,Z.jsx)(Ae,{id:`mobile-access-custom-url`,type:`url`,inputMode:`url`,autoComplete:`url`,placeholder:`https://archon.example.com`,value:e,disabled:t,onChange:e=>{r(e.target.value)}}),n&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-xs text-red-200`,children:n})]}),Up=({mode:e,isOpen:t,onOpenChange:n})=>{let r=e===`ngrok`?`ngrok requirements`:`Tunnel requirements`,i=e===`ngrok`?`Archon will manage the ngrok tunnel lifecycle after you enable mobile access.`:`Make sure your tunnel or reverse proxy is set up like this before you enable public access.`,a=e===`ngrok`?["Install the `ngrok` binary on this machine and make sure it is available on PATH.",`Authenticate ngrok ahead of time so it can create tunnels without prompting.`,`The tunnel still needs websocket support so live mobile status updates keep working.`]:["Use a full HTTPS origin such as `https://archon.example.com`.",`Point that public origin at Archon's dedicated mobile listener only, not the desktop API.`,`Publish the mobile listener at the origin root, not under a subpath.`,`Ensure websocket upgrades are supported so live mobile status updates keep working.`];return(0,Z.jsx)(vp,{open:t,onOpenChange:n,children:(0,Z.jsxs)(`div`,{className:`space-y-3 rounded-2xl border border-border bg-background/70 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:r}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i})]}),(0,Z.jsx)(yp,{asChild:!0,children:(0,Z.jsxs)(J,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 gap-1.5 px-2 text-xs text-muted-foreground`,children:[t?`Hide instructions`:`Show instructions`,(0,Z.jsx)(oe,{className:W(`h-3.5 w-3.5 transition-transform`,t&&`rotate-180`)})]})})]}),(0,Z.jsx)(bp,{className:`space-y-2`,children:(0,Z.jsx)(`ul`,{className:`space-y-2 text-sm text-muted-foreground`,children:a.map(e=>(0,Z.jsx)(`li`,{children:e},e))})})]})})},Wp=({localListenerUrl:e,isExpected:t,mode:n})=>{let[r,i]=(0,X.useState)(`idle`);return(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-2xl border border-border bg-background/70 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Local tunnel target`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?n===`ngrok`?`Archon will start ngrok against this local target when you enable managed public access.`:`Start your tunnel to this local target before enabling public mobile access.`:`Point your tunnel or reverse proxy at this local mobile listener.`})]}),(0,Z.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{if(!navigator.clipboard?.writeText){i(`error`);return}navigator.clipboard.writeText(e).then(()=>i(`copied`)).catch(()=>i(`error`))},children:r===`copied`?`Copied`:`Copy local target`})]}),(0,Z.jsx)(`p`,{className:`break-all rounded-xl border border-border bg-card px-3 py-2 font-mono text-xs text-muted-foreground`,children:e}),r===`error`&&(0,Z.jsx)(`p`,{className:`text-xs text-red-200`,children:`Copy failed. Select and copy the local target manually.`})]})},Gp=({pairingUrl:e})=>{let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{let t=!0;return n(null),i(!1),_p.toDataURL(e,{errorCorrectionLevel:`M`,margin:2,width:192,color:{dark:`#020617`,light:`#ffffff`}}).then(e=>{t&&n(e)}).catch(()=>{t&&i(!0)}),()=>{t=!1}},[e]),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Scan to pair`}),(0,Z.jsxs)(`div`,{"data-testid":`mobile-pairing-qr-frame`,className:`inline-flex w-fit items-center justify-center overflow-hidden rounded-2xl border border-border bg-white shadow-sm`,children:[t&&(0,Z.jsx)(`img`,{src:t,alt:`Mobile pairing QR code`,className:`size-48`}),!t&&!r&&(0,Z.jsx)(`span`,{className:`text-xs text-slate-500`,children:`Generating QR...`}),r&&(0,Z.jsx)(`span`,{className:`text-xs text-slate-500`,children:`QR unavailable`})]})]})},Kp=({pairingUrl:e})=>{let[t,n]=(0,X.useState)(`idle`);return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Full pairing link`}),(0,Z.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{if(!navigator.clipboard?.writeText){n(`error`);return}navigator.clipboard.writeText(e).then(()=>n(`copied`)).catch(()=>n(`error`))},children:t===`copied`?`Copied`:`Copy pairing link`})]}),(0,Z.jsx)(`p`,{className:`break-all rounded-xl border border-border bg-card px-3 py-2 font-mono text-xs text-muted-foreground`,children:e}),(0,Z.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:`Open this full link on the phone if scanning is not available.`}),t===`error`&&(0,Z.jsx)(`p`,{className:`text-xs text-red-200`,children:`Copy failed. Select and copy the full link manually.`})]})},qp=({mobileUrl:e})=>{let[t,n]=(0,X.useState)(`idle`);return(0,Z.jsxs)(`div`,{className:`flex flex-col items-end gap-2`,children:[(0,Z.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{if(!navigator.clipboard?.writeText){n(`error`);return}navigator.clipboard.writeText(e).then(()=>n(`copied`)).catch(()=>n(`error`))},children:t===`copied`?`Copied`:`Copy mobile link`}),t===`error`&&(0,Z.jsx)(`p`,{className:`text-xs text-red-200`,children:`Copy failed. Select and copy the mobile link manually.`})]})},Jp=({status:e,currentTimeMs:t})=>(0,Z.jsxs)(`div`,{className:`space-y-3 rounded-2xl border border-border bg-background/70 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Verification code`}),(0,Z.jsx)(`p`,{className:`mt-1 font-mono text-2xl font-semibold tracking-[0.16em] text-foreground`,children:e.pairing?.display_code})]}),e.pairing&&(0,Z.jsx)(`div`,{className:`text-right`,children:(0,Z.jsx)(q,{variant:`secondary`,children:Ip(e.pairing.expires_at,t)})})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[16rem_minmax(0,1fr)]`,children:[e.pairing&&(0,Z.jsx)(Gp,{pairingUrl:e.pairing.qr_url}),(0,Z.jsx)(`div`,{className:`space-y-4`,children:e.pairing&&(0,Z.jsx)(Kp,{pairingUrl:e.pairing.qr_url})})]})]}),Yp=({session:e,actionState:t,onRevoke:n})=>{let r=t===`revoke:${e.id}`;return(0,Z.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-2xl border border-border bg-background/70 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground`,children:e.user_agent||`Paired mobile browser`}),(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Paired `,Fp(e.paired_at),` · Last seen `,Fp(e.last_seen_at)]}),e.remote_address&&(0,Z.jsx)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:e.remote_address})]}),(0,Z.jsx)(J,{type:`button`,variant:`destructive`,size:`sm`,disabled:t!==`idle`,onClick:()=>n(e.id),children:r?`Revoking...`:`Revoke`})]})},Xp=({sessions:e,actionState:t,onRevoke:n})=>(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Paired sessions`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Revoke any phone that should no longer control Archon.`})]}),e.length===0&&(0,Z.jsx)(`p`,{className:`rounded-2xl border border-dashed border-border p-4 text-sm text-muted-foreground`,children:`No phones are paired yet.`}),e.length>0&&(0,Z.jsx)(`ul`,{className:`max-h-56 space-y-2 overflow-y-auto pr-1`,children:e.map(e=>(0,Z.jsx)(Yp,{session:e,actionState:t,onRevoke:n},e.id))})]}),Zp=({activeProjectId:e,open:t,onOpenChange:n})=>{let r=_f(),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(`idle`),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(()=>Date.now()),[f,p]=(0,X.useState)(()=>Dp()),[m,h]=(0,X.useState)(()=>kp(Dp())),[g,_]=(0,X.useState)(()=>Mp(kp(Dp()))),[v,y]=(0,X.useState)(!1),b=(0,X.useRef)(null);(0,X.useEffect)(()=>{Op(f)},[f]),(0,X.useEffect)(()=>{Ap(m)},[m]);let x=(0,X.useCallback)(e=>{hf(e)},[]),S=(0,X.useCallback)(async e=>{a(!0),l(null);try{await gf(e)}catch(e){k(e)||l(e instanceof we?e.message:`Failed to load mobile access status.`)}finally{a(!1)}},[]),C=(0,X.useCallback)(async(e,t)=>{s(e),l(null);try{x(await t())}catch(e){l(e instanceof we?e.message:`Mobile access action failed.`)}finally{s(`idle`)}},[x]),w=r?.pairing?.expires_at??null,T=!!(r&&r.state!==`disabled`&&r.state!==`error`),E=T?r?.mode??m:m,D=m!==`lan`,O=m===`custom_public_url`,A=T||o!==`idle`,j=f.trim(),M=O?Pp(j):null,N=r?.mode===`custom_public_url`&&r.local_listener_url?r.local_listener_url:wp,P=!(r?.mode===`custom_public_url`&&r.local_listener_url);(0,X.useEffect)(()=>{if(!t)return;let e=new AbortController;return S(e.signal),()=>e.abort()},[S,t]),(0,X.useEffect)(()=>{r?.mode&&h(r.mode)},[r?.mode]),(0,X.useEffect)(()=>{_(Mp(m))},[m]),(0,X.useEffect)(()=>{if(!t||!w)return;d(Date.now());let e=window.setInterval(()=>{d(Date.now())},1e3);return()=>window.clearInterval(e)},[t,w]),(0,X.useEffect)(()=>{!t||!v||!r?.pairing?.qr_url||(b.current?.scrollIntoView({behavior:`smooth`,block:`start`}),y(!1))},[t,v,r?.pairing?.qr_url]),(0,X.useEffect)(()=>{t||y(!1)},[t]);let F=()=>{let t=m===`custom_public_url`?{mode:`custom_public_url`,public_base_url:j,preferred_project_id:e}:m===`ngrok`?{mode:`ngrok`,preferred_project_id:e}:{mode:`lan`,preferred_project_id:e};y(!0),C(`enable`,()=>af(t))},I=()=>{C(`disable`,of)},L=()=>{C(`regenerate`,()=>sf(e))},R=e=>{C(`revoke:${e}`,()=>cf(e))},z=e=>{_(e),Np(m,e)},B=!!(r&&(r.state===`awaiting_pairing`||r.state===`expired`||r.state===`connected`)),V=o!==`idle`||O&&(j.length===0||M!==null);return(0,Z.jsx)(Kl,{open:t,onOpenChange:n,children:(0,Z.jsxs)(Xl,{className:`flex max-h-[min(50rem,calc(100vh-2rem))] flex-col overflow-hidden sm:max-w-3xl`,children:[(0,Z.jsx)(Zl,{className:`shrink-0 pr-12`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)($l,{children:`Mobile access`}),(0,Z.jsxs)(eu,{children:[`Pair your mobile device with Archon over `,zp(E).toLowerCase(),`.`]})]}),(0,Z.jsx)(q,{variant:Rp(r),children:Lp(r)})]})}),(0,Z.jsxs)(`div`,{className:`min-h-0 space-y-5 overflow-y-auto pr-1`,children:[(0,Z.jsx)(Vp,{value:m,disabled:A,onChange:h}),(0,Z.jsx)(Bp,{mode:E}),O&&(0,Z.jsx)(Hp,{value:f,disabled:A,error:M,onChange:p}),D&&(0,Z.jsx)(Up,{mode:E,isOpen:g,onOpenChange:z}),E===`custom_public_url`&&(0,Z.jsx)(Wp,{localListenerUrl:N,isExpected:P,mode:E}),c&&(0,Z.jsx)(`p`,{role:`alert`,className:`rounded-2xl border border-destructive/30 bg-destructive/10 p-3 text-sm text-red-200`,children:c}),r?.error&&(0,Z.jsx)(`p`,{role:`alert`,className:`rounded-2xl border border-destructive/30 bg-destructive/10 p-3 text-sm text-red-200`,children:r.error}),i&&!r&&(0,Z.jsx)(`p`,{className:`rounded-2xl border border-border p-4 text-sm text-muted-foreground`,children:`Loading mobile access status...`}),r?.pairing&&(0,Z.jsx)(`div`,{ref:b,"data-testid":`mobile-pairing-details`,children:(0,Z.jsx)(Jp,{status:r,currentTimeMs:u})}),r?.state===`connected`&&r.url&&(0,Z.jsx)(qp,{mobileUrl:r.url}),r&&(0,Z.jsx)(Xp,{sessions:r.sessions,actionState:o,onRevoke:R})]}),(0,Z.jsxs)(Ql,{className:`shrink-0 border-t border-border pt-4`,children:[T&&(0,Z.jsx)(J,{type:`button`,variant:`destructive`,disabled:o!==`idle`,onClick:I,children:o===`disable`?`Disabling...`:`Disable mobile`}),B&&(0,Z.jsx)(J,{type:`button`,variant:`outline`,disabled:o!==`idle`,onClick:L,children:o===`regenerate`?`Regenerating...`:`Regenerate pairing`}),!T&&(0,Z.jsx)(J,{type:`button`,disabled:V,onClick:F,children:o===`enable`?`Enabling...`:`Enable mobile`})]})]})})},Qp=e=>(0,Z.jsx)(is,{"data-slot":`tabs`,...e}),$p=({className:e,...t})=>(0,Z.jsx)(as,{"data-slot":`tabs-list`,className:W(`inline-flex h-auto items-stretch justify-start gap-1 rounded-2xl border border-border/70 bg-background/40 p-1 text-muted-foreground`,e),...t}),em=({className:e,...t})=>(0,Z.jsx)(os,{"data-slot":`tabs-trigger`,className:W(`inline-flex cursor-pointer items-center justify-center rounded-xl border border-transparent px-3 py-2 text-sm font-medium whitespace-nowrap transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/60 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:border-border/70 data-[state=active]:bg-card data-[state=active]:text-foreground data-[state=active]:shadow-sm`,e),...t}),tm=({className:e,...t})=>(0,Z.jsx)(ss,{"data-slot":`tabs-content`,className:W(`outline-none`,e),...t}),nm=(e,t)=>x(N(`/integrations`,e),{signal:t,fallbackErrorMessage:`Unable to load integrations right now.`}),rm=(e,t)=>x(N(`/integrations/jira/connect`,e),{method:`POST`,body:t,fallbackErrorMessage:`Unable to connect Jira right now.`}),im=e=>x(N(`/integrations/jira/disconnect`,e),{method:`POST`,fallbackErrorMessage:`Unable to disconnect Jira right now.`}),am=(e,t)=>x(N(`/integrations/github/connect`,e),{method:`POST`,body:t,fallbackErrorMessage:`Unable to connect GitHub right now.`}),om=e=>x(N(`/integrations/github/disconnect`,e),{method:`POST`,fallbackErrorMessage:`Unable to disconnect GitHub right now.`}),sm=(e,t)=>x(N(`/integrations/jira/resolve/issue`,e),{method:`POST`,body:t,fallbackErrorMessage:`Unable to load the Jira issue right now.`}),cm=({className:e,...t})=>(0,Z.jsx)(Vo,{"data-slot":`switch`,className:W(`peer inline-flex h-6 w-10 shrink-0 cursor-pointer items-center rounded-full border border-transparent bg-input/70 transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary`,e),...t,children:(0,Z.jsx)(Ho,{"data-slot":`switch-thumb`,className:`pointer-events-none block h-5 w-5 rounded-full bg-white shadow-sm ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`})}),lm=({className:e})=>(0,Z.jsx)(bc,{"aria-hidden":`true`,className:e}),um=({disabled:e,isLoading:t,onAutoConfig:n})=>{let{t:r}=ht(`projects`);return(0,Z.jsx)(`div`,{className:`rounded-2xl border border-emerald-400/25 bg-emerald-500/10 p-4 shadow-[0_0_0_1px_rgba(16,185,129,0.06)]`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(q,{variant:`success`,className:`border-emerald-300/30 bg-emerald-300/12 text-emerald-100`,children:r(`advanced.autoConfigPanel.badge`)}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-emerald-50/95`,children:r(`advanced.autoConfigPanel.description`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-emerald-100/75`,children:r(`advanced.autoConfigPanel.note`)})]}),(0,Z.jsxs)(J,{type:`button`,onClick:n,disabled:e,variant:`secondary`,className:`shrink-0 gap-2 border border-emerald-300/25 bg-emerald-300/15 text-emerald-50 hover:bg-emerald-300/25 hover:text-white disabled:bg-emerald-300/10`,children:[t?(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(lm,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:r(t?`advanced.autoConfigPanel.loading`:`advanced.autoConfigPanel.action`)})]})]})})},dm=({className:e})=>(0,Z.jsx)(Mc,{"aria-hidden":`true`,className:e}),fm=({label:e,triggerLabel:t,triggerAriaLabel:n,selectId:r,groups:i,selectedValues:a,onToggle:o,disabled:s=!1,labelClassName:c,contentClassName:l,triggerClassName:u})=>(0,Z.jsx)(Ou,{label:e,triggerLabel:t,triggerAriaLabel:n,selectId:r,groups:i,disabled:s,labelClassName:c,contentClassName:l,triggerClassName:u,isSelected:e=>a.includes(e),onSelect:o,closeOnSelect:!1}),pm=({linkedProjectOptions:e,selectedLinkedProjectNames:t,selectedValues:n,triggerLabel:r,onToggle:i})=>{let{t:a}=ht(`projects`);return(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border/70 bg-background/30 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(`div`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-background/60 text-muted-foreground`,children:(0,Z.jsx)(dm,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:a(`advanced.linkedProjects.title`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:a(`advanced.linkedProjects.description`)})]})]}),(0,Z.jsx)(q,{variant:`ghost`,className:`shrink-0 px-0 text-xs text-muted-foreground`,children:t.length===0?a(`advanced.linkedProjects.selectedNone`):a(`advanced.linkedProjects.selectedCount`,{count:t.length})})]}),(0,Z.jsx)(`div`,{className:`mt-4`,children:e.length===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border px-4 py-5 text-sm text-muted-foreground`,children:a(`advanced.linkedProjects.noneAvailable`)}):(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(fm,{label:a(`advanced.linkedProjects.title`),labelClassName:`sr-only`,triggerLabel:r,triggerAriaLabel:a(`advanced.linkedProjects.triggerAriaLabel`),selectId:`linked-projects`,selectedValues:n,onToggle:i,groups:[{label:``,options:e.map(e=>({value:e.id,label:e.name}))}]}),t.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,Z.jsx)(q,{variant:`outline`,className:`border-sky-400/30 bg-sky-500/10 text-sky-100`,children:e},e))})]})})]})},mm=({index:e,value:t,error:n,onChange:r,onRemove:i})=>{let{t:a}=ht(`projects`),o=e+1;return(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border/80 bg-background/35 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-background/60 text-muted-foreground`,children:(0,Z.jsx)(Qu,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:a(`serviceRow.title`,{index:o})}),(0,Z.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:a(`serviceRow.description`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 self-start`,children:[t.cwd.trim()!==``&&(0,Z.jsx)(q,{variant:`outline`,className:`border-border/80 bg-background/50 text-muted-foreground`,children:t.cwd.trim()}),(0,Z.jsx)(J,{type:`button`,onClick:()=>i(e),variant:`ghost`,size:`sm`,children:a(`serviceRow.remove`)})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,0.8fr)_minmax(0,1.5fr)_minmax(0,0.9fr)] lg:items-start`,children:[(0,Z.jsx)(Bf,{label:a(`serviceRow.fields.nameLabel`),description:a(`serviceRow.fields.nameDescription`),children:(0,Z.jsx)(Ae,{"aria-label":a(`serviceRow.fields.nameAriaLabel`,{index:o}),value:t.name,onChange:t=>r(e,`name`,t.target.value),placeholder:a(`serviceRow.fields.namePlaceholder`)})}),(0,Z.jsx)(Bf,{label:a(`serviceRow.fields.commandLabel`),error:n?.cmd,children:(0,Z.jsx)(Ae,{"aria-label":a(`serviceRow.fields.commandAriaLabel`,{index:o}),value:t.cmd,onChange:t=>r(e,`cmd`,t.target.value),placeholder:a(`serviceRow.fields.commandPlaceholder`)})}),(0,Z.jsx)(Bf,{label:a(`serviceRow.fields.workingDirectoryLabel`),description:a(`serviceRow.fields.workingDirectoryDescription`),children:(0,Z.jsx)(Ae,{"aria-label":a(`serviceRow.fields.workingDirectoryAriaLabel`,{index:o}),value:t.cwd,onChange:t=>r(e,`cwd`,t.target.value),placeholder:a(`serviceRow.fields.workingDirectoryPlaceholder`)})})]})]})})},hm=`h-10 w-full min-w-0 rounded-xl border border-input bg-input/40 px-3 py-2 text-sm text-foreground transition-[border-color,box-shadow,background-color] outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,gm=({index:e,value:t,error:n,onChange:r,onRemove:i})=>{let{t:a}=ht(`projects`),o=e+1;return(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border/80 bg-background/35 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-background/60 text-muted-foreground`,children:(0,Z.jsx)(Yu,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:a(`testCommandRow.title`,{index:o})}),(0,Z.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:a(`testCommandRow.description`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 self-start`,children:[(0,Z.jsx)(q,{variant:`outline`,className:`border-border/80 bg-background/50 text-muted-foreground`,children:a(`testCommandRow.fields.runnerOptions.${t.runner}`)}),(0,Z.jsx)(J,{type:`button`,onClick:()=>i(e),variant:`ghost`,size:`sm`,children:a(`testCommandRow.remove`)})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.45fr)_minmax(0,0.85fr)_minmax(0,0.75fr)] xl:items-start`,children:[(0,Z.jsx)(Bf,{label:a(`testCommandRow.fields.nameLabel`),error:n?.name,children:(0,Z.jsx)(Ae,{"aria-label":a(`testCommandRow.fields.nameAriaLabel`,{index:o}),value:t.name,onChange:t=>r(e,`name`,t.target.value),placeholder:a(`testCommandRow.fields.namePlaceholder`)})}),(0,Z.jsx)(Bf,{label:a(`testCommandRow.fields.commandLabel`),error:n?.command,children:(0,Z.jsx)(Ae,{"aria-label":a(`testCommandRow.fields.commandAriaLabel`,{index:o}),value:t.command,onChange:t=>r(e,`command`,t.target.value),placeholder:a(`testCommandRow.fields.commandPlaceholder`)})}),(0,Z.jsx)(Bf,{label:a(`testCommandRow.fields.directoryLabel`),description:a(`testCommandRow.fields.directoryDescription`),children:(0,Z.jsx)(Ae,{"aria-label":a(`testCommandRow.fields.directoryAriaLabel`,{index:o}),value:t.cwd,onChange:t=>r(e,`cwd`,t.target.value),placeholder:a(`testCommandRow.fields.directoryPlaceholder`)})}),(0,Z.jsx)(Bf,{label:a(`testCommandRow.fields.runnerLabel`),description:a(`testCommandRow.fields.runnerDescription`),children:(0,Z.jsxs)(`select`,{"aria-label":a(`testCommandRow.fields.runnerAriaLabel`,{index:o}),className:hm,value:t.runner,onChange:t=>r(e,`runner`,t.target.value),children:[(0,Z.jsx)(`option`,{value:`auto`,children:a(`testCommandRow.fields.runnerOptions.auto`)}),(0,Z.jsx)(`option`,{value:`vitest`,children:a(`testCommandRow.fields.runnerOptions.vitest`)}),(0,Z.jsx)(`option`,{value:`jest`,children:a(`testCommandRow.fields.runnerOptions.jest`)}),(0,Z.jsx)(`option`,{value:`unknown`,children:a(`testCommandRow.fields.runnerOptions.unknown`)})]})})]})]})})},_m=`h-10 w-full min-w-0 rounded-xl border border-input bg-input/40 px-3 py-2 text-sm text-foreground transition-[border-color,box-shadow,background-color] outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,vm=({index:e,value:t,error:n,onChange:r,onRemove:i})=>{let{t:a}=ht(`projects`),o=e+1;return(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border/80 bg-background/35 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-background/60 text-muted-foreground`,children:(0,Z.jsx)(Gd,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:a(`syncRow.title`,{index:o})}),(0,Z.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:a(`syncRow.description`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 self-start`,children:[(0,Z.jsx)(q,{variant:`outline`,className:`border-border/80 bg-background/50 text-muted-foreground`,children:a(`syncRow.fields.modeOptions.${t.mode}`)}),(0,Z.jsx)(J,{type:`button`,onClick:()=>i(e),variant:`ghost`,size:`sm`,children:a(`syncRow.remove`)})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,1.3fr)_minmax(0,1.3fr)_minmax(0,0.8fr)] lg:items-start`,children:[(0,Z.jsx)(Bf,{label:a(`syncRow.fields.sourceLabel`),error:n?.source,children:(0,Z.jsx)(Ae,{"aria-label":a(`syncRow.fields.sourceAriaLabel`,{index:o}),value:t.source,onChange:t=>r(e,`source`,t.target.value),placeholder:a(`syncRow.fields.sourcePlaceholder`)})}),(0,Z.jsx)(Bf,{label:a(`syncRow.fields.targetLabel`),description:a(`syncRow.fields.targetDescription`),children:(0,Z.jsx)(Ae,{"aria-label":a(`syncRow.fields.targetAriaLabel`,{index:o}),value:t.target,onChange:t=>r(e,`target`,t.target.value),placeholder:a(`syncRow.fields.targetPlaceholder`)})}),(0,Z.jsx)(Bf,{label:a(`syncRow.fields.modeLabel`),children:(0,Z.jsxs)(`select`,{"aria-label":a(`syncRow.fields.modeAriaLabel`,{index:o}),className:_m,value:t.mode,onChange:t=>r(e,`mode`,t.target.value),children:[(0,Z.jsx)(`option`,{value:`copy`,children:a(`syncRow.fields.modeOptions.copy`)}),(0,Z.jsx)(`option`,{value:`symlink`,children:a(`syncRow.fields.modeOptions.symlink`)})]})})]})]})})},ym=({title:e,description:t,summary:n,accentClassName:r,children:i})=>(0,Z.jsxs)(`div`,{className:W(`rounded-2xl border border-border/70 bg-background/25 p-4`,r),children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-foreground`,children:e}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:t})]}),(0,Z.jsx)(q,{variant:`ghost`,className:`self-start px-0 text-xs text-muted-foreground`,children:n})]}),(0,Z.jsx)(`div`,{className:`mt-4`,children:i})]}),bm=({onAutoConfig:e,isAutoConfigDisabled:t,isAutoConfiguring:n,helperModel:r,helperVariant:i,availableHelperModels:a,isLoadingHelperModels:o,onHelperModelChange:s,onHelperVariantChange:c,commitMessageRules:l,onCommitMessageRulesChange:u,linkedProjectOptions:d,selectedLinkedProjectNames:f,linkedProjectTriggerLabel:p,linkedProjectIds:m,onToggleLinkedProject:h,runSetupText:g,onRunSetupChange:_,runIde:v,onRunIdeChange:y,autoParkStaleTickets:b,onAutoParkStaleTicketsChange:x})=>{let{t:S}=ht(`projects`),C=g.split(`
|
|
22
|
+
`).map(e=>e.trim()).filter(e=>e.length>0).length,w=C===0?S(`advanced.summary.none`):S(`advanced.summary.commandCount`,{count:C}),T=v.trim()===``?S(`advanced.summary.none`):S(`advanced.summary.configured`),E=S(b?`advanced.summary.autoParkOn`:`advanced.summary.manualOnly`),D=r===``?S(`advanced.summary.toolDefault`):a.find(e=>e.id===r)?.label??r,O=l.trim()===``?S(`advanced.summary.default`):S(`advanced.summary.customRules`);return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[e&&(0,Z.jsx)(um,{disabled:t,isLoading:n,onAutoConfig:e}),(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border/70 bg-background/25 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-foreground`,children:S(`advanced.helperModel.title`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:S(`advanced.helperModel.description`)})]}),(0,Z.jsx)(q,{variant:`ghost`,className:`self-start px-0 text-xs text-muted-foreground`,children:D})]}),(0,Z.jsx)(Mu,{helperModel:r,helperVariant:i,availableModels:a,isLoadingModels:o,onHelperModelChange:s,onHelperVariantChange:c,modelSelectId:`project-helper-model`,variantSelectId:`project-helper-variant`,className:`mt-4 border-0 bg-transparent p-0`,showHeader:!1})]}),(0,Z.jsx)(ym,{title:S(`advanced.commitMessages.title`),description:S(`advanced.commitMessages.description`),summary:O,children:(0,Z.jsx)(Bf,{label:S(`advanced.commitMessages.fieldLabel`),description:S(`advanced.commitMessages.fieldDescription`),children:(0,Z.jsx)(tu,{"aria-label":S(`advanced.commitMessages.ariaLabel`),value:l,onChange:e=>u(e.target.value),rows:5,placeholder:S(`advanced.commitMessages.placeholder`)})})})]}),(0,Z.jsx)(pm,{linkedProjectOptions:d,selectedLinkedProjectNames:f,selectedValues:m,triggerLabel:p,onToggle:h}),(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsx)(ym,{title:S(`advanced.setupCommands.title`),description:S(`advanced.setupCommands.description`),summary:w,children:(0,Z.jsx)(Bf,{label:S(`advanced.setupCommands.fieldLabel`),description:S(`advanced.setupCommands.fieldDescription`),children:(0,Z.jsx)(tu,{"aria-label":S(`advanced.setupCommands.ariaLabel`),value:g,onChange:e=>_(e.target.value),rows:6,placeholder:S(`advanced.setupCommands.placeholder`)})})}),(0,Z.jsx)(ym,{title:S(`advanced.ideCommand.title`),description:S(`advanced.ideCommand.description`),summary:T,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl border border-border/70 bg-background/20 p-4`,children:[(0,Z.jsx)(`div`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-background/60 text-muted-foreground`,children:(0,Z.jsx)(Ju,{className:`h-4 w-4`})}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Bf,{label:S(`advanced.ideCommand.fieldLabel`),description:S(`advanced.ideCommand.fieldDescription`),children:(0,Z.jsx)(Ae,{"aria-label":S(`advanced.ideCommand.ariaLabel`),value:v,onChange:e=>y(e.target.value),placeholder:S(`advanced.ideCommand.placeholder`)})})})]})})]}),(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border/70 bg-background/25 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-foreground`,children:S(`advanced.staleHandling.title`)}),(0,Z.jsx)(q,{variant:`ghost`,className:`self-start px-0 text-xs text-muted-foreground`,children:E})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:S(`advanced.staleHandling.description`)}),(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-2xl border border-border/70 bg-background/40 px-4 py-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:S(`advanced.staleHandling.toggleLabel`)}),(0,Z.jsx)(cm,{"aria-label":S(`advanced.staleHandling.toggleAriaLabel`),checked:b,onCheckedChange:x})]})})]})]})},xm=({runServices:e,runServiceErrors:t,previewServiceName:n,previewPath:r,previewCapabilityMode:i,previewServiceNameError:a,onAddServiceRow:o,onServiceChange:s,onPreviewServiceNameChange:c,onPreviewPathChange:l,onPreviewCapabilityModeChange:u,onRemoveServiceRow:d})=>{let{t:f}=ht(`projects`),p=e.length===0?f(`advanced.summary.none`):f(`advanced.summary.serviceCount`,{count:e.length}),m=e.map(e=>e.name.trim()).filter(e=>e.length>0),h=n.trim()===``?f(`advanced.summary.disabled`):f(`advanced.summary.watching`,{name:n.trim()});return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(ym,{title:f(`advanced.services.title`),description:f(`advanced.services.description`),summary:p,children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs uppercase tracking-[0.22em] text-muted-foreground`,children:[(0,Z.jsx)(Qu,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:f(`advanced.services.backgroundProcesses`)})]}),(0,Z.jsx)(J,{type:`button`,onClick:o,variant:`success`,children:f(`advanced.services.addService`)})]}),e.length===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border px-4 py-5 text-sm text-muted-foreground`,children:f(`advanced.services.empty`)}):(0,Z.jsx)(`div`,{className:`space-y-3`,children:e.map((e,n)=>(0,Z.jsx)(mm,{index:n,value:e,error:t[n],onChange:s,onRemove:d},n))})]})}),(0,Z.jsx)(ym,{title:f(`advanced.preview.title`),description:f(`advanced.preview.description`),summary:h,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-3`,children:[(0,Z.jsx)(Bf,{label:f(`advanced.preview.previewServiceLabel`),error:a,description:f(`advanced.preview.previewServiceDescription`),children:(0,Z.jsxs)(`select`,{"aria-label":f(`advanced.preview.previewServiceAriaLabel`),value:n,onChange:e=>c(e.target.value),className:`h-10 rounded-xl border border-border/70 bg-background/70 px-3 text-sm text-foreground outline-none focus:border-ring`,children:[(0,Z.jsx)(`option`,{value:``,children:f(`advanced.preview.noPreviewService`)}),m.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})}),(0,Z.jsx)(Bf,{label:f(`advanced.preview.previewPathLabel`),description:f(`advanced.preview.previewPathDescription`),children:(0,Z.jsx)(Ae,{"aria-label":f(`advanced.preview.previewPathAriaLabel`),value:r,onChange:e=>l(e.target.value),placeholder:f(`advanced.preview.previewPathPlaceholder`)})}),(0,Z.jsx)(Bf,{label:f(`advanced.preview.capabilityModeLabel`),description:f(`advanced.preview.capabilityModeDescription`),children:(0,Z.jsxs)(`select`,{"aria-label":f(`advanced.preview.capabilityModeAriaLabel`),value:i,onChange:e=>{let t=e.target.value;(t===`auto`||t===`force_web`||t===`force_disabled`)&&u(t)},className:`h-10 rounded-xl border border-border/70 bg-background/70 px-3 text-sm text-foreground outline-none focus:border-ring`,children:[(0,Z.jsx)(`option`,{value:`auto`,children:f(`advanced.preview.capabilityMode.auto`)}),(0,Z.jsx)(`option`,{value:`force_web`,children:f(`advanced.preview.capabilityMode.forceWeb`)}),(0,Z.jsx)(`option`,{value:`force_disabled`,children:f(`advanced.preview.capabilityMode.forceDisabled`)})]})})]})})]})},Sm=({testCommands:e,testCommandErrors:t,onAddTestCommandRow:n,onTestCommandChange:r,onRemoveTestCommandRow:i})=>{let{t:a}=ht(`projects`),o=e.length===0?a(`advanced.summary.none`):a(`advanced.summary.commandCount`,{count:e.length});return(0,Z.jsx)(ym,{title:a(`advanced.tests.title`),description:a(`advanced.tests.description`),summary:o,children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs uppercase tracking-[0.22em] text-muted-foreground`,children:[(0,Z.jsx)(Qu,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:a(`advanced.tests.title`)})]}),(0,Z.jsx)(J,{type:`button`,onClick:n,variant:`success`,children:a(`advanced.tests.addCommand`)})]}),e.length===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border px-4 py-5 text-sm text-muted-foreground`,children:a(`advanced.tests.empty`)}):(0,Z.jsx)(`div`,{className:`space-y-3`,children:e.map((e,n)=>(0,Z.jsx)(gm,{index:n,value:e,error:t[n],onChange:r,onRemove:i},e.id))})]})})},Cm=({worktreeSync:e,worktreeSyncErrors:t,onAddWorktreeSyncRow:n,onWorktreeSyncChange:r,onRemoveWorktreeSyncRow:i})=>{let{t:a}=ht(`projects`),o=e.length===0?a(`advanced.summary.none`):a(`advanced.summary.ruleCount`,{count:e.length});return(0,Z.jsx)(ym,{title:a(`advanced.sync.title`),description:a(`advanced.sync.description`),summary:o,children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs uppercase tracking-[0.22em] text-muted-foreground`,children:[(0,Z.jsx)(Gd,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:a(`advanced.sync.title`)})]}),(0,Z.jsx)(J,{type:`button`,onClick:n,variant:`success`,children:a(`advanced.sync.addRule`)})]}),e.length===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border px-4 py-5 text-sm text-muted-foreground`,children:a(`advanced.sync.empty`)}):(0,Z.jsx)(`div`,{className:`space-y-3`,children:e.map((e,n)=>(0,Z.jsx)(vm,{index:n,value:e,error:t[n],onChange:r,onRemove:i},n))})]})})},wm=({className:e})=>(0,Z.jsx)(Dc,{"aria-hidden":`true`,className:e}),Tm=({validation:e})=>{let{t}=ht(`projects`);return e.status===`idle`?null:e.status===`checking`?(0,Z.jsx)(`span`,{"aria-label":t(`basics.repoPathStatus.checking.ariaLabel`),title:t(`basics.repoPathStatus.checking.title`),role:`status`,className:`pointer-events-none absolute top-1/2 right-3 -translate-y-1/2 text-amber-300`,children:(0,Z.jsx)(ye,{className:`h-3.5 w-3.5 animate-spin`})}):e.status===`valid`?(0,Z.jsx)(`span`,{"aria-label":t(`basics.repoPathStatus.valid.ariaLabel`),title:t(`basics.repoPathStatus.valid.title`),className:`pointer-events-none absolute top-1/2 right-3 h-2.5 w-2.5 -translate-y-1/2 rounded-full bg-emerald-400 shadow-[0_0_0_2px_rgba(16,185,129,0.18)]`}):e.status===`initializable`?(0,Z.jsx)(`span`,{"aria-label":t(`basics.repoPathStatus.initializable.ariaLabel`),title:e.message,className:`pointer-events-none absolute top-1/2 right-3 h-2.5 w-2.5 -translate-y-1/2 rounded-full bg-amber-300 shadow-[0_0_0_2px_rgba(252,211,77,0.16)]`}):e.status===`invalid`?(0,Z.jsx)(`span`,{"aria-label":t(`basics.repoPathStatus.invalid.ariaLabel`),title:e.error,className:`pointer-events-none absolute top-1/2 right-3 h-2.5 w-2.5 -translate-y-1/2 rounded-full bg-red-400 shadow-[0_0_0_2px_rgba(248,113,113,0.16)]`}):null},Em=({name:e,repoPath:t,repoPathLocked:n,repoPathLockedMessage:r,repoPathDescription:i=null,isBrowsingRepoPath:a=!1,repoPathValidation:o={status:`idle`},nameError:s,repoPathError:c,onNameChange:l,onRepoPathChange:u,onBrowseRepoPath:d})=>{let{t:f}=ht(`projects`);return(0,Z.jsxs)(Nf,{className:`rounded-3xl border-border bg-card/70 shadow-none`,children:[(0,Z.jsx)(Pf,{className:`gap-3 border-b border-border/70 pb-5`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(`div`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-2xl border border-border/80 bg-background/60 text-muted-foreground`,children:(0,Z.jsx)(qu,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(Ff,{className:`text-base font-semibold text-foreground`,children:f(`basics.cardTitle`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:f(`basics.cardDescription`)})]})]}),(0,Z.jsx)(q,{variant:`outline`,className:`mt-0.5 shrink-0 border-emerald-400/25 bg-emerald-500/10 text-emerald-200`,children:f(`basics.requiredBadge`)})]})}),(0,Z.jsx)(Rf,{children:(0,Z.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Z.jsx)(Bf,{label:f(`basics.fields.projectName.label`),description:f(`basics.fields.projectName.description`),error:s,children:(0,Z.jsx)(Ae,{"aria-label":f(`basics.fields.projectName.ariaLabel`),value:e,onChange:e=>l(e.target.value),placeholder:f(`basics.fields.projectName.placeholder`),autoFocus:!0})}),(0,Z.jsx)(Bf,{label:f(`basics.fields.repositoryPath.label`),description:i??r??f(`basics.fields.repositoryPath.defaultDescription`),error:c,children:(0,Z.jsx)(`div`,{className:`space-y-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Z.jsx)(Ae,{"aria-label":f(`basics.fields.repositoryPath.ariaLabel`),value:t,onChange:e=>u(e.target.value),placeholder:f(`basics.fields.repositoryPath.placeholder`),disabled:n,className:`pr-9`}),(0,Z.jsx)(Tm,{validation:o})]}),(0,Z.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,className:`shrink-0`,onClick:d,disabled:n||a||!d,children:[(0,Z.jsx)(wm,{className:`h-4 w-4`}),f(a?`basics.fields.repositoryPath.opening`:`basics.fields.repositoryPath.browse`)]})]})})})]})})]})},Dm=({projectName:e,deleteBlockedMessage:t,isDeleteDisabled:n,isDeleting:r,showDeleteConfirm:i,onDeleteConfirmToggle:a,onDelete:o})=>{let{t:s}=ht(`projects`),c=e.trim();return(0,Z.jsx)(Nf,{className:`rounded-3xl border-red-500/25 bg-destructive/10 shadow-none`,children:(0,Z.jsxs)(Rf,{className:`p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold uppercase tracking-[0.24em] text-red-200`,children:s(`danger.cardTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-red-100/80`,children:s(`danger.cardDescription`)})]}),(0,Z.jsx)(`div`,{className:`mt-5 rounded-2xl border border-red-500/20 bg-black/15 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:c===``?s(`danger.deleteTitleFallback`):s(`danger.deleteTitle`,{projectName:c})}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-red-200/80`,children:t??s(`danger.deleteAvailable`)})]}),i&&!t?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsx)(J,{type:`button`,onClick:()=>{a(!1)},variant:`ghost`,children:s(`danger.cancel`)}),(0,Z.jsx)(J,{type:`button`,onClick:o,disabled:n,variant:`destructive`,children:s(r?`danger.deleteBusy`:`danger.deleteAction`)})]}):(0,Z.jsx)(J,{type:`button`,onClick:()=>{a(!0)},disabled:n,variant:`destructive`,children:s(`danger.deleteAction`)})]})})]})})},Om=new Set,km=e=>{e&&Om.forEach(t=>t(e))},Am=e=>{let[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(0),s=(0,X.useRef)(0);return(0,X.useEffect)(()=>{if(!e)return;let t=t=>{t===e&&(s.current+=1,n(!1),i(null),o(e=>e+1))};return Om.add(t),()=>{Om.delete(t)}},[e]),(0,X.useEffect)(()=>{if(!e||typeof fetch!=`function`){s.current+=1;return}let t=new AbortController,r=s.current+1;return s.current=r,(async()=>{try{let a=await nm(e,t.signal);if(t.signal.aborted||r!==s.current)return;n(a.connections.some(e=>e.provider===`github`&&e.status===`connected`)),i(e)}catch(t){!k(t)&&r===s.current&&(n(!1),i(e))}})(),()=>{t.abort()}},[e,a]),{isGitHubConnected:e?r===e&&t:!1}},jm=new Set,Mm=e=>{e&&jm.forEach(t=>t(e))},Nm=e=>{let[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(0),s=(0,X.useRef)(0),c=e&&r===e&&t?`enabled`:`hidden`;(0,X.useEffect)(()=>{if(!e)return;let t=t=>{t===e&&(s.current+=1,n(!1),i(null),o(e=>e+1))};return jm.add(t),()=>{jm.delete(t)}},[e]),(0,X.useEffect)(()=>{if(!e||typeof fetch!=`function`){s.current+=1;return}let t=new AbortController,r=s.current+1;return s.current=r,(async()=>{try{let a=await nm(e,t.signal);if(t.signal.aborted||r!==s.current)return;n(a.connections.some(e=>e.provider===`jira`&&e.status===`connected`)),i(e)}catch(t){!k(t)&&r===s.current&&(n(!1),i(e))}})(),()=>{t.abort()}},[e,a]);let l=(0,X.useCallback)(async t=>{if(!e)throw Error(`A project is required to import from Jira.`);return(await sm(e,{issue:t})).draft},[e]);return{jiraImportState:c,importFromJira:e?l:void 0}},Pm=({className:e})=>(0,Z.jsx)(Ic,{"aria-hidden":`true`,className:e}),Fm=({className:e})=>(0,Z.jsx)(Pc,{"aria-hidden":`true`,className:e}),Im={connected:`bg-emerald-500/15 text-emerald-200 border-emerald-400/30`,disconnected:`bg-muted text-muted-foreground border-border`,error:`bg-red-500/15 text-red-200 border-red-400/30`},Lm=e=>e?.status??`disconnected`,Rm=e=>e.find(e=>e.provider===`jira`)??null,zm=e=>e.find(e=>e.provider===`github`)??null,Bm=({title:e,description:t,status:n,isOpen:r,onOpenChange:i,children:a})=>{let{t:o}=ht(`projects`);return(0,Z.jsx)(Nf,{className:`rounded-3xl border-border bg-card/70 shadow-none`,children:(0,Z.jsx)(Rf,{className:`p-5`,children:(0,Z.jsxs)(vp,{open:r,onOpenChange:i,children:[(0,Z.jsx)(yp,{asChild:!0,children:(0,Z.jsxs)(J,{type:`button`,"aria-label":o(`integrations.card.toggleAriaLabel`,{title:e}),variant:`ghost`,className:`flex h-auto w-full min-w-0 items-start justify-between gap-4 whitespace-normal rounded-2xl p-0 text-left hover:bg-transparent`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 pr-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:e}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),(0,Z.jsx)(q,{variant:`outline`,className:Im[n],children:o(`integrations.status.${n}`)})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsx)(q,{variant:`outline`,className:`mt-0.5 shrink-0 px-3 py-1 text-xs uppercase tracking-[0.24em]`,children:o(r?`integrations.card.hide`:`integrations.card.show`)}),r?(0,Z.jsx)(Pm,{className:`mt-0.5 h-4 w-4 text-muted-foreground`}):(0,Z.jsx)(Fm,{className:`mt-0.5 h-4 w-4 text-muted-foreground`})]})]})}),(0,Z.jsx)(bp,{className:`mt-5 border-t border-border pt-5`,children:a})]})})})},Vm=({projectId:e,onEnabledCountChange:t})=>{let{t:n}=ht(`projects`),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(!1),s=(0,X.useRef)(!1),c=(0,X.useRef)(!1),l=(0,X.useRef)(!1),u=(0,X.useRef)(!1),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(!0),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(``),[C,w]=(0,X.useState)(``),[T,E]=(0,X.useState)(``),[D,O]=(0,X.useState)(``),[A,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(`direct`),[I,L]=(0,X.useState)(``),[R,z]=(0,X.useState)(``);(0,X.useEffect)(()=>{let t=new AbortController;return(async()=>{g(!0);try{let n=await nm(e,t.signal);if(t.signal.aborted)return;let r=Rm(n.connections),a=zm(n.connections);f(r),m(a),S(r?.config?.base_url??``),w(r?.config?.email??``),O(r?.config?.included_field_names.join(`
|
|
23
|
+
`)??``),z(a?.config?.default_base_branch??``),F(a?.config?.connection_mode??`direct`),s.current||=(l.current||i(r?.status===`connected`),!0),c.current||=(u.current||o(a?.status===`connected`),!0)}catch(e){k(e)||(Q.error(e instanceof we?e.message:n(`integrations.messages.loadError`),{id:`integrations-load-error`}),s.current||=(l.current||i(!1),!0),c.current||=(u.current||o(!1),!0))}finally{t.signal.aborted||g(!1)}})(),()=>{t.abort()}},[e,n]);let B=Lm(d),V=Lm(p),ee=B===`connected`,te=V===`connected`,H=Number(ee)+Number(te);(0,X.useEffect)(()=>{h||t?.(H)},[H,h,t]);let ne=(0,X.useMemo)(()=>!x.trim()||!C.trim()?!1:ee||T.trim().length>0,[ee,T,x,C]),U=(0,X.useMemo)(()=>P===`gh`?!0:te&&p?.config?.connection_mode===`direct`||I.trim().length>0,[I,p,P,te]),re=async()=>{if(ne){v(!0);try{let t=await rm(e,{base_url:x.trim(),email:C.trim(),api_token:T.trim(),included_field_names:D.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)}),r=t.connection?.provider===`jira`?t.connection:null;f(r),S(r?.config?.base_url??x.trim()),w(r?.config?.email??C.trim()),O(r?.config?.included_field_names.join(`
|
|
24
|
+
`)??``),E(``),Mm(e),Q.success(n(ee?`integrations.messages.jiraSaveSuccess`:`integrations.messages.jiraConnectSuccess`),{id:`jira-connect-success`})}catch(e){Q.error(e instanceof we?e.message:n(`integrations.messages.jiraConnectError`),{id:`jira-connect-error`})}finally{v(!1)}}},ie=async()=>{b(!0);try{await im(e),f(null),S(``),w(``),E(``),O(``),Mm(e),Q.success(n(`integrations.messages.jiraDisconnectSuccess`),{id:`jira-disconnect-success`})}catch(e){Q.error(e instanceof we?e.message:n(`integrations.messages.jiraDisconnectError`),{id:`jira-disconnect-error`})}finally{b(!1)}},ae=async()=>{if(U){j(!0);try{let t=await am(e,{connection_mode:P,api_token:P===`direct`?I.trim():``,default_base_branch:R.trim()||null}),r=t.connection?.provider===`github`?t.connection:null;m(r),F(r?.config?.connection_mode??P),z(r?.config?.default_base_branch??R.trim()),L(``),km(e),Q.success(n(te?`integrations.messages.githubSaveSuccess`:`integrations.messages.githubConnectSuccess`),{id:`github-connect-success`})}catch(e){Q.error(e instanceof we?e.message:n(`integrations.messages.githubConnectError`),{id:`github-connect-error`})}finally{j(!1)}}},oe=async()=>{N(!0);try{await om(e),m(null),F(`direct`),L(``),z(``),km(e),Q.success(n(`integrations.messages.githubDisconnectSuccess`),{id:`github-disconnect-success`})}catch(e){Q.error(e instanceof we?e.message:n(`integrations.messages.githubDisconnectError`),{id:`github-disconnect-error`})}finally{N(!1)}};return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(Bm,{title:n(`integrations.jira.title`),description:n(`integrations.jira.description`),status:B,isOpen:r,onOpenChange:e=>{l.current=!0,i(e)},children:[d?.config&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-border/80 bg-card/70 px-3 py-2 text-xs text-muted-foreground`,children:n(`integrations.jira.connectedSummary`,{baseUrl:d.config.base_url,email:d.config.email})}),(0,Z.jsxs)(`div`,{className:`mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)(Bf,{label:n(`integrations.jira.fields.urlLabel`),htmlFor:`jira-base-url`,children:(0,Z.jsx)(Ae,{id:`jira-base-url`,value:x,onChange:e=>S(e.target.value),placeholder:n(`integrations.jira.fields.urlPlaceholder`),disabled:h||_||y})}),(0,Z.jsx)(Bf,{label:n(`integrations.jira.fields.emailLabel`),htmlFor:`jira-email`,children:(0,Z.jsx)(Ae,{id:`jira-email`,value:C,onChange:e=>w(e.target.value),placeholder:n(`integrations.jira.fields.emailPlaceholder`),disabled:h||_||y})})]}),(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(Bf,{label:n(`integrations.jira.fields.apiTokenLabel`),htmlFor:`jira-api-token`,children:(0,Z.jsx)(Ae,{id:`jira-api-token`,type:`password`,value:T,onChange:e=>E(e.target.value),placeholder:n(d?`integrations.jira.fields.apiTokenPlaceholderConnected`:`integrations.jira.fields.apiTokenPlaceholderEmpty`),disabled:h||_||y})})}),(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(Bf,{label:n(`integrations.jira.fields.additionalFieldsLabel`),htmlFor:`jira-included-field-names`,description:n(`integrations.jira.fields.additionalFieldsDescription`),children:(0,Z.jsx)(tu,{id:`jira-included-field-names`,value:D,onChange:e=>O(e.target.value),placeholder:n(`integrations.jira.fields.additionalFieldsPlaceholder`),disabled:h||_||y,className:`min-h-24`})})}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2`,children:[d&&(0,Z.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>{ie()},disabled:y||_,children:n(y?`integrations.jira.actions.disconnecting`:`integrations.jira.actions.disconnect`)}),(0,Z.jsx)(J,{type:`button`,onClick:()=>{re()},disabled:!ne||_||h,children:n(_?`integrations.jira.actions.saving`:d?`integrations.jira.actions.save`:`integrations.jira.actions.connect`)})]})]}),(0,Z.jsxs)(Bm,{title:n(`integrations.github.title`),description:n(`integrations.github.description`),status:V,isOpen:a,onOpenChange:e=>{u.current=!0,o(e)},children:[p?.config&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-border/80 bg-card/70 px-3 py-2 text-xs text-muted-foreground`,children:n(`integrations.github.connectedSummary`,{repoOwner:p.config.repo_owner,repoName:p.config.repo_name,host:p.config.host,mode:n(`integrations.connectionMode.${p.config.connection_mode}Summary`)})}),(0,Z.jsxs)(`div`,{className:`mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)(Bf,{label:n(`integrations.github.fields.connectionMethodLabel`),htmlFor:`github-connection-mode`,description:n(`integrations.github.fields.connectionMethodDescription`),children:(0,Z.jsxs)(`select`,{id:`github-connection-mode`,value:P,onChange:e=>F(e.target.value),disabled:h||A||M,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,Z.jsx)(`option`,{value:`direct`,children:n(`integrations.connectionMode.directOption`)}),(0,Z.jsx)(`option`,{value:`gh`,children:n(`integrations.connectionMode.ghOption`)})]})}),(0,Z.jsx)(Bf,{label:n(`integrations.github.fields.defaultBaseBranchLabel`),htmlFor:`github-default-base-branch`,description:n(`integrations.github.fields.defaultBaseBranchDescription`),children:(0,Z.jsx)(Ae,{id:`github-default-base-branch`,value:R,onChange:e=>z(e.target.value),placeholder:n(`integrations.github.fields.defaultBaseBranchPlaceholder`),disabled:h||A||M})})]}),P===`direct`&&(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(Bf,{label:n(`integrations.github.fields.apiTokenLabel`),htmlFor:`github-api-token`,description:n(`integrations.github.fields.apiTokenDescription`),children:(0,Z.jsx)(Ae,{id:`github-api-token`,type:`password`,value:I,onChange:e=>L(e.target.value),placeholder:p?.config?.connection_mode===`direct`?n(`integrations.github.fields.apiTokenPlaceholderConnected`):n(`integrations.github.fields.apiTokenPlaceholderEmpty`),disabled:h||A||M})})}),P===`gh`&&(0,Z.jsx)(`div`,{className:`mt-3 rounded-xl border border-border/80 bg-muted/40 px-3 py-2 text-xs text-muted-foreground`,children:n(`integrations.github.ghNotice`)}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2`,children:[p&&(0,Z.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>{oe()},disabled:M||A,children:n(M?`integrations.github.actions.disconnecting`:`integrations.github.actions.disconnect`)}),(0,Z.jsx)(J,{type:`button`,onClick:()=>{ae()},disabled:!U||A||h,children:n(A?`integrations.github.actions.saving`:p?`integrations.github.actions.save`:`integrations.github.actions.connect`)})]})]})]})},Hm=({className:e})=>(0,Z.jsx)(Bc,{"aria-hidden":`true`,className:e}),Um=({className:e})=>(0,Z.jsx)(vc,{"aria-hidden":`true`,className:e}),Wm=({className:e})=>(0,Z.jsx)(hc,{"aria-hidden":`true`,className:e}),Gm=({className:e})=>(0,Z.jsx)(Uc,{"aria-hidden":`true`,className:e}),Km=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`],qm=3e3,Jm=(e,t)=>e(t===`decision`?`memory.editor.decision`:`memory.editor.convention`),Ym=(e,t)=>e(`memory.stageLabels.${t}`),Xm=(e,t)=>e(`memory.priorityLabels.${t}`),Zm=(e,t)=>e(`memory.injectionModeLabels.${t}`),Qm=(e=`decision`)=>({kind:e,title:``,scope:``,content:``,rationale:``,implicationsText:``,stages:[],priority:`normal`,injectionMode:`relevant`}),$m=e=>[...e].sort((e,t)=>e.status===t.status?t.updated_at.localeCompare(e.updated_at):e.status===`active`?-1:1),eh=e=>[...e].sort((e,t)=>e.status===t.status?t.updated_at.localeCompare(e.updated_at):e.status===`accepted`?-1:1),th=(e,t)=>$m([t,...e.filter(e=>e.id!==t.id)]),nh=(e,t)=>eh([t,...e.filter(e=>e.id!==t.id)]),rh=e=>e.split(`
|
|
25
|
+
`).map(e=>e.trim()).filter(Boolean),ih=e=>({kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implicationsText:``,stages:e.stages,priority:e.priority,injectionMode:e.injection_mode}),ah=e=>({kind:`decision`,title:e.title,scope:e.scope??``,content:e.decision,rationale:e.rationale??``,implicationsText:e.implications.join(`
|
|
26
|
+
`),stages:[],priority:`normal`}),oh=(e,t)=>e(t===`superseded`?`memory.savedStateLabels.superseded`:t===`archived`?`memory.savedStateLabels.archived`:`memory.savedStateLabels.active`),sh=e=>e!==`active`&&e!==`accepted`,ch=e=>e?.scan?.status===`pending`||e?.scan?.status===`running`,lh=(e,t)=>{let n=t?.scan?.status;return e(n?n===`pending`?`memory.scanStatus.pending`:n===`running`?`memory.scanStatus.running`:n===`done`?`memory.scanStatus.done`:`memory.scanStatus.error`:`memory.scanStatus.notScanned`)},uh=e=>e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),dh=e=>e.trim().toLowerCase().replaceAll(`_`,` `).replace(/\s+/g,` `),fh=e=>[...e].sort((e,t)=>{let n=dh(e.title)===`architecture`||dh(e.kind)===`architecture`;return n===(dh(t.title)===`architecture`||dh(t.kind)===`architecture`)?0:n?-1:1}),ph=e=>{let t=uh(e.kind),n=e.title.trim(),r=dh(t)===dh(n),i=r&&t.length>n.length?t:n,a=dh(t);return{title:i,categoryLabel:r||a===`conventions`||a===`risks`?null:t}},mh=e=>{let t=dh(e);return t!==`conventions`&&t!==`risks`},hh=async(e,t)=>{let[n,r]=await Promise.all([be(e,t),fe(e,t)]);return{context:n,artifacts:r.artifacts}},gh=e=>({id:e.id,project_id:e.project_id,title:e.title,scope:e.scope,instruction:e.content,rationale:e.rationale,stages:e.stages,priority:e.priority??`normal`,injection_mode:e.injection_mode??`relevant`,status:e.state===`archived`?`archived`:`active`,created_at:e.created_at,updated_at:e.updated_at}),_h=e=>{let t=e.state===`archived`?`archived`:e.state===`superseded`?`superseded`:`accepted`;return{id:e.id,project_id:e.project_id,title:e.title,scope:e.scope,decision:e.content,rationale:e.rationale,implications:e.implications,status:t,created_at:e.created_at,updated_at:e.updated_at}},vh=e=>e.state===`suggested`,yh=async(e,t)=>{let n=await Ne(e,t);return{conventions:$m(n.memories.filter(e=>e.kind===`convention`).map(gh)),decisions:eh(n.memories.filter(e=>e.kind===`decision`&&e.source===`manual`).map(_h)),suggestions:n.memories.filter(vh),generatedContext:n.generated_context}},bh=(e,t)=>t.conflicts.length===0?e(`memory.import.noTitleConflicts`):e(`memory.import.titleConflictCount`,{count:t.conflicts.length}),xh=async(e,t)=>typeof e.text==`function`?await e.text():await new Promise((n,r)=>{let i=new FileReader;i.onerror=()=>{r(Error(t))},i.onload=()=>{n(typeof i.result==`string`?i.result:``)},i.readAsText(e)}),Sh=({value:e,onChange:t})=>{let{t:n}=ht(`projects`);return(0,Z.jsx)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:Km.map(r=>{let i=e.includes(r);return(0,Z.jsxs)(`label`,{className:`flex min-w-0 items-start gap-2 rounded-xl border border-border/70 bg-background/30 px-3 py-2 text-sm text-foreground`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:i,className:`mt-0.5 shrink-0`,onChange:()=>{t(i?e.filter(e=>e!==r):[...e,r])}}),(0,Z.jsx)(`span`,{className:`min-w-0 break-words leading-5`,children:Ym(n,r)})]},r)})})},Ch=({title:e,meta:t,preview:n,ariaLabel:r,onClick:i,archived:a=!1,accentClassName:o})=>(0,Z.jsxs)(`button`,{type:`button`,onClick:i,"aria-label":r,className:W(`group relative flex min-h-40 cursor-pointer flex-col justify-between overflow-hidden rounded-xl border border-border/80 bg-background/55 p-4 text-left transition hover:-translate-y-0.5 hover:border-foreground/20 hover:bg-background/72 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60`,a&&`border-border/55 bg-background/30`),children:[(0,Z.jsx)(`span`,{className:W(`absolute inset-y-0 left-0 w-px bg-border/70`,o)}),(0,Z.jsxs)(`div`,{className:`space-y-3 pl-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,Z.jsx)(q,{variant:`outline`,className:`h-5 rounded-md border-border/70 bg-background/80 px-1.5 text-[10px] uppercase tracking-[0.16em] text-muted-foreground`,children:e},e))}),(0,Z.jsx)(`h4`,{className:`line-clamp-2 text-sm font-semibold leading-5 text-foreground`,children:e})]}),(0,Z.jsx)(`span`,{className:`mt-0.5 rounded-md border border-border/70 bg-background/80 p-1.5 text-muted-foreground transition group-hover:border-foreground/20 group-hover:text-foreground`,children:(0,Z.jsx)(Hm,{className:`size-3.5`})})]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 whitespace-pre-wrap text-sm leading-5 text-muted-foreground`,children:n})]})]}),wh=({artifact:e,onClick:t})=>{let{t:n}=ht(`projects`),r=ph(e);return(0,Z.jsxs)(`button`,{type:`button`,onClick:t,"aria-label":n(`memory.artifact.openAriaLabel`,{title:r.title}),className:`grid w-full cursor-pointer gap-1 border-t border-border/60 py-3 text-left transition first:border-t-0 first:pt-0 last:pb-0 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60`,children:[r.categoryLabel&&(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:r.categoryLabel}),(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-foreground`,children:r.title}),(0,Z.jsx)(`p`,{className:`line-clamp-2 whitespace-pre-wrap text-sm leading-5 text-muted-foreground`,children:e.content_markdown?.trim()||n(`memory.artifact.emptyNotes`)})]})},Th=({draft:e,onChange:t,onCancel:n,onSubmit:r,isSaving:i,submitLabel:a,layout:o=`inline`,secondaryActions:s,allowKindChange:c=!0})=>{let{t:l}=ht(`projects`),u=e.kind===`convention`;return(0,Z.jsxs)(`div`,{className:W(`space-y-4`,o===`inline`&&`rounded-2xl border border-border/70 bg-background/25 p-4`),children:[(0,Z.jsx)(Bf,{label:l(`memory.editor.typeLabel`),children:(0,Z.jsx)(ku,{label:``,triggerLabel:Jm(l,e.kind),triggerAriaLabel:l(`memory.editor.typeAriaLabel`),selectId:`memory-type`,selectedValue:e.kind,onChange:n=>{c&&t({...Qm(n),title:e.title,scope:e.scope,content:e.content,rationale:e.rationale})},disabled:!c,groups:[{label:``,options:[{value:`decision`,label:l(`memory.editor.decision`)},{value:`convention`,label:l(`memory.editor.convention`)}]}]})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,Z.jsx)(Bf,{label:l(`memory.editor.titleLabel`),children:(0,Z.jsx)(Ae,{"aria-label":l(`memory.editor.titleAriaLabel`),value:e.title,onChange:n=>t({...e,title:n.target.value}),placeholder:l(u?`memory.editor.titlePlaceholderConvention`:`memory.editor.titlePlaceholderDecision`)})}),(0,Z.jsx)(Bf,{label:l(`memory.editor.scopeLabel`),description:l(`memory.editor.scopeDescription`),children:(0,Z.jsx)(Ae,{"aria-label":l(`memory.editor.scopeAriaLabel`),value:e.scope,onChange:n=>t({...e,scope:n.target.value}),placeholder:l(u?`memory.editor.scopePlaceholderConvention`:`memory.editor.scopePlaceholderDecision`)})})]}),(0,Z.jsx)(Bf,{label:l(`memory.editor.contentLabel`),children:(0,Z.jsx)(tu,{"aria-label":l(`memory.editor.contentAriaLabel`),value:e.content,onChange:n=>t({...e,content:n.target.value}),rows:3,placeholder:l(u?`memory.editor.contentPlaceholderConvention`:`memory.editor.contentPlaceholderDecision`)})}),(0,Z.jsx)(Bf,{label:l(`memory.editor.rationaleLabel`),description:l(`memory.editor.rationaleDescription`),children:(0,Z.jsx)(tu,{"aria-label":l(`memory.editor.rationaleAriaLabel`),value:e.rationale,onChange:n=>t({...e,rationale:n.target.value}),rows:2,placeholder:l(u?`memory.editor.rationalePlaceholderConvention`:`memory.editor.rationalePlaceholderDecision`)})}),u?(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2 xl:items-start`,children:[(0,Z.jsx)(Bf,{label:l(`memory.editor.priorityLabel`),children:(0,Z.jsx)(ku,{label:``,triggerLabel:Xm(l,e.priority),triggerAriaLabel:l(`memory.editor.priorityAriaLabel`),selectId:`memory-priority`,selectedValue:e.priority,onChange:n=>t({...e,priority:n}),groups:[{label:``,options:[`critical`,`normal`,`low`].map(e=>({value:e,label:Xm(l,e)}))}]})}),(0,Z.jsx)(Bf,{label:l(`memory.editor.injectionModeLabel`),children:(0,Z.jsx)(ku,{label:``,triggerLabel:Zm(l,e.injectionMode),triggerAriaLabel:l(`memory.editor.injectionModeAriaLabel`),selectId:`memory-injection-mode`,selectedValue:e.injectionMode,onChange:n=>t({...e,injectionMode:n}),groups:[{label:``,options:[`always`,`relevant`].map(e=>({value:e,label:Zm(l,e)}))}]})}),(0,Z.jsx)(Bf,{label:l(`memory.editor.stagesLabel`),description:l(`memory.editor.stagesDescription`),className:`xl:col-span-2`,children:(0,Z.jsx)(Sh,{value:e.stages,onChange:n=>t({...e,stages:n})})})]}):(0,Z.jsx)(Bf,{label:l(`memory.editor.implicationsLabel`),description:l(`memory.editor.implicationsDescription`),children:(0,Z.jsx)(tu,{"aria-label":l(`memory.editor.implicationsAriaLabel`),value:e.implicationsText,onChange:n=>t({...e,implicationsText:n.target.value}),rows:3,placeholder:l(`memory.editor.implicationsPlaceholder`)})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:s}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Z.jsx)(J,{type:`button`,variant:`ghost`,onClick:n,children:l(`memory.editor.cancel`)}),(0,Z.jsx)(J,{type:`button`,variant:`success`,onClick:r,disabled:i,children:i?l(`memory.editor.saving`):a})]})]})]})},Eh=e=>({kind:e.kind,title:e.title,scope:e.scope??``,content:e.content,rationale:e.rationale??``,implicationsText:e.implications.join(`
|
|
27
|
+
`),stages:e.stages,priority:e.priority??`normal`,injectionMode:e.injection_mode??`relevant`}),Dh=({memory:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let{t:a}=ht(`projects`);return(0,Z.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h5`,{className:`text-sm font-semibold text-foreground`,children:e.title}),(0,Z.jsx)(q,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,children:a(`memory.suggested.badge`,{kind:e.kind})}),e.duplicate_match&&(0,Z.jsx)(q,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`,children:a(`memory.suggested.duplicateBadge`)})]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:e.content})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:a(`memory.suggested.review`)}),(0,Z.jsx)(J,{type:`button`,size:`sm`,disabled:t,onClick:()=>{r(e)},children:e.duplicate_match&&e.kind===`decision`?a(`memory.suggested.saveAsNewDecision`):a(`memory.suggested.accept`)}),(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>{i(e)},children:a(`memory.suggested.dismiss`)})]})]})})},Oh=({memory:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onDraftChange:o,onStartEdit:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{let{t:d}=ht(`projects`);return e?(0,Z.jsx)(Kl,{open:t,onOpenChange:a,children:(0,Z.jsxs)(Xl,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Z.jsxs)(Zl,{children:[(0,Z.jsx)($l,{children:e.title}),(0,Z.jsx)(eu,{children:d(`memory.suggested.reviewDescription`,{kind:e.kind})})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[e.duplicate_match&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-amber-50`,children:d(`memory.suggested.duplicateTitle`)}),(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[e.duplicate_match.title,`:`]}),` `,e.duplicate_match.content]})]}),n?(0,Z.jsx)(Th,{draft:i,onChange:o,onCancel:c,onSubmit:()=>{l(e,!1)},isSaving:r,submitLabel:e.duplicate_match&&e.kind===`decision`?d(`memory.suggested.saveAsNewDecision`):d(`memory.suggested.acceptAs`,{kind:e.kind}),layout:`dialog`,allowKindChange:!1,secondaryActions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(J,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>{u(e)},children:d(`memory.suggested.dismissKind`,{kind:e.kind})}),e.kind===`decision`&&e.duplicate_match&&(0,Z.jsx)(J,{type:`button`,variant:`outline`,disabled:r,onClick:()=>{l(e,!0)},children:d(`memory.suggested.updateExistingDecision`)})]})}):(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-3 text-sm text-foreground`,children:e.content}),(0,Z.jsxs)(`div`,{className:`space-y-2 text-xs leading-5 text-muted-foreground`,children:[e.scope&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:d(`memory.suggested.scope`)}),` `,e.scope]}),e.rationale&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:d(`memory.suggested.why`)}),` `,e.rationale]}),e.kind===`decision`&&e.implications.length>0&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:d(`memory.suggested.implications`)}),` `,e.implications.join(`; `)]}),e.kind===`convention`&&e.stages.length>0&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:d(`memory.suggested.stages`)}),` `,e.stages.map(e=>Ym(d,e)).join(`, `)]}),e.kind===`convention`&&e.priority&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:d(`memory.suggested.priority`)}),` `,Xm(d,e.priority)]}),e.kind===`convention`&&e.injection_mode&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:d(`memory.suggested.injection`)}),` `,Zm(d,e.injection_mode)]})]})]})]}),!n&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-border pt-4`,children:[(0,Z.jsx)(J,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>a(!1),children:d(`memory.suggested.close`)}),(0,Z.jsx)(J,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>{u(e)},children:d(`memory.suggested.dismissKind`,{kind:e.kind})}),(0,Z.jsx)(J,{type:`button`,variant:`outline`,disabled:r,onClick:()=>s(e),children:d(`memory.suggested.edit`)}),e.kind===`decision`&&e.duplicate_match&&(0,Z.jsx)(J,{type:`button`,variant:`outline`,disabled:r,onClick:()=>{l(e,!0)},children:d(`memory.suggested.updateExistingDecision`)}),(0,Z.jsx)(J,{type:`button`,disabled:r,onClick:()=>{l(e,!1)},children:e.duplicate_match&&e.kind===`decision`?d(`memory.suggested.saveAsNewDecision`):d(`memory.suggested.acceptAs`,{kind:e.kind})})]})]})}):null},kh=({mode:e,projectId:t,memoryEnabled:n,persistedMemoryEnabled:r,onMemoryEnabledChange:i,showActivationControls:a=!0,archiveLayout:o=!1})=>{let{t:s}=ht(`projects`),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)([]),[m,h]=(0,X.useState)([]),[g,_]=(0,X.useState)(!1),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),[w,T]=(0,X.useState)(null),[E,D]=(0,X.useState)(Qm),[O,k]=(0,X.useState)(Qm),[A,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(null),[F,I]=(0,X.useState)(!1),[L,R]=(0,X.useState)(null),[z,B]=(0,X.useState)([]),[V,ee]=(0,X.useState)(!1),[te,ne]=(0,X.useState)(!1),[U,re]=(0,X.useState)(null),[ie,ae]=(0,X.useState)(!1),[oe,se]=(0,X.useState)(!1),[ce,ue]=(0,X.useState)(!1),[de,W]=(0,X.useState)(null),me=(0,X.useRef)(null),G=o&&e===`edit`&&!!t&&n&&r,he=e===`edit`&&!!t,ge=e===`create`&&n,_e=e===`edit`&&n&&!r,ve=!n;(0,X.useEffect)(()=>{if(!G||!t){d([]),p([]),h([]),l(null),S(null),T(null),b(null),W(null),R(null),B([]),re(null),ne(!1);return}let e=new AbortController;return _(!0),ne(!0),b(null),re(null),yh(t,e.signal).then(t=>{e.signal.aborted||(b(null),d(t.conventions),p(t.decisions),h(t.suggestions),R(t.generatedContext?.context??null),B(t.generatedContext?.artifacts??[]))}).catch(t=>{e.signal.aborted||b(t instanceof Error?t.message:s(`memory.messages.loadError`))}).finally(()=>{e.signal.aborted||(_(!1),ne(!1))}),()=>{e.abort()}},[G,t,s]),(0,X.useEffect)(()=>{if(!t||!G||!ch(L))return;ne(!0);let e=window.setInterval(()=>{hh(t).then(e=>{re(null),R(e.context),B(e.artifacts),ne(!1)}).catch(e=>{re(e instanceof Error?e.message:s(`memory.messages.refreshContextError`)),ne(!1)})},qm);return()=>{window.clearInterval(e),ne(!1)}},[G,L,t,s]);let be=(0,X.useMemo)(()=>F?u:u.filter(e=>e.status===`active`),[u,F]),xe=(0,X.useMemo)(()=>F?f:f.filter(e=>e.status===`accepted`),[f,F]),Se=(0,X.useMemo)(()=>{let e=be.map(e=>{let t=[s(`memory.editor.convention`),Xm(s,e.priority),Zm(s,e.injection_mode),oh(s,e.status)];return e.stages.length>0&&t.push(e.stages.length===1?Ym(s,e.stages[0]):s(`memory.archive.stageCount`,{count:e.stages.length})),{id:e.id,kind:`convention`,title:e.title,preview:e.instruction,meta:t,archived:sh(e.status),updatedAt:e.updated_at}}),t=xe.map(e=>({id:e.id,kind:`decision`,title:e.title,preview:e.decision,meta:[s(`memory.editor.decision`),oh(s,e.status)],archived:sh(e.status),updatedAt:e.updated_at}));return[...e,...t].sort((e,t)=>e.archived===t.archived?t.updatedAt.localeCompare(e.updatedAt)||e.kind.localeCompare(t.kind)||e.id.localeCompare(t.id):e.archived?1:-1)},[s,be,xe]),Ce=(0,X.useMemo)(()=>m,[m]),K=(0,X.useMemo)(()=>fh(z),[z]),Ee=()=>{l(null),D(Qm())},De=()=>{T(null),k(Qm())},Oe=async()=>{if(t){j(!0);try{if(E.kind===`convention`){let e={kind:`convention`,title:E.title.trim(),scope:E.scope.trim()||null,instruction:E.content.trim(),rationale:E.rationale.trim()||null,stages:E.stages,priority:E.priority,injection_mode:E.injectionMode},n=c?.id?await We(t,c.id,e):await P(t,e);d(e=>th(e,gh(n.memory)))}else{let e={kind:`decision`,title:E.title.trim(),scope:E.scope.trim()||null,decision:E.content.trim(),rationale:E.rationale.trim()||null,implications:rh(E.implicationsText)},n=c?.id?await We(t,c.id,e):await P(t,e);p(e=>nh(e,_h(n.memory)))}Ee()}catch(e){Q.error(e instanceof Error?e.message:s(`memory.messages.saveError`),{id:`project-memory-save-error`})}finally{j(!1)}}},ke=e=>{l({kind:`convention`,id:e.id}),D(ih(e))},Ae=()=>{l({kind:`decision`,id:null}),D(Qm(`decision`))},je=e=>{l({kind:`decision`,id:e.id}),D(ah(e))},Me=e=>{w&&w!==e.id&&De(),S(e.id)},Ne=e=>{e||(S(null),De())},Pe=e=>{S(e.id),T(e.id),k(Eh(e))},Fe=async(e,n)=>{if(!t)return;let r=w===e.id?O:Eh(e),i=e.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:rh(r.implicationsText)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:r.stages,priority:r.priority,injection_mode:r.injectionMode};N(e.id);try{if(n&&!e.duplicate_match)throw Error(s(`memory.messages.noExistingDecision`));if(n&&e.kind!==`decision`)throw Error(s(`memory.messages.onlyDecisionSuggestionsCanUpdate`));let r=n?await v(t,e.id,e.duplicate_match?.memory_id??``,i):await H(t,e.id,i);r.memory.kind===`decision`?p(e=>nh(e,_h(r.memory))):d(e=>th(e,gh(r.memory))),h(t=>t.filter(t=>t.id!==e.id)),S(null),De()}catch(e){Q.error(e instanceof Error?e.message:s(`memory.messages.saveSuggestionError`),{id:`project-memory-suggestion-error`})}finally{N(null)}},Ie=async e=>{if(t){N(e.id);try{await pe(t,e.id),h(t=>t.filter(t=>t.id!==e.id)),x===e.id&&S(null),w===e.id&&De()}catch(e){Q.error(e instanceof Error?e.message:s(`memory.messages.dismissSuggestionError`),{id:`project-memory-suggestion-error`})}finally{N(null)}}},Le=async(e,n)=>{if(!t)return!1;try{let r=n===`archive`?await C(t,e.id):await Je(t,e.id);return d(e=>th(e,gh(r.memory))),!0}catch(e){return Q.error(e instanceof Error?e.message:s(n===`archive`?`memory.messages.archiveConventionError`:`memory.messages.restoreConventionError`),{id:n===`archive`?`project-memory-convention-archive-error`:`project-memory-convention-restore-error`}),!1}},Re=async(e,n)=>{if(!t)return!1;try{let r=n===`archive`?await C(t,e.id):n===`supersede`?await le(t,e.id):await Je(t,e.id);return p(e=>nh(e,_h(r.memory))),!0}catch(e){let t=s(n===`archive`?`memory.messages.archiveDecisionError`:n===`supersede`?`memory.messages.supersedeDecisionError`:`memory.messages.restoreDecisionError`),r=n===`archive`?`project-memory-decision-archive-error`:n===`supersede`?`project-memory-decision-supersede-error`:`project-memory-decision-restore-error`;return Q.error(e instanceof Error?e.message:t,{id:r}),!1}},Be=c!==null,Ve=L?.scan??null,He=c?.kind===`convention`&&c.id?u.find(e=>e.id===c.id)??null:null,Ue=c?.kind===`decision`&&c.id?f.find(e=>e.id===c.id)??null:null,Ge=x?m.find(e=>e.id===x)??null:null,qe=ch(L),Ye=u.length+f.length+m.length,Xe=Ve?.status??null,Ze=!o||Xe!==`done`,Y=()=>{t&&(ae(!0),re(null),Ke(t).then(async e=>{R(e),B((await fe(t)).artifacts),Q.success(s(`memory.messages.scanStarted`),{id:`project-context-scan-started`})}).catch(async e=>{if(e instanceof we&&e.status===409){Q.error(s(`memory.messages.scanConflict`),{id:`project-context-scan-conflict`});try{let e=await hh(t);R(e.context),B(e.artifacts)}catch(e){re(e instanceof Error?e.message:s(`memory.messages.refreshContextError`))}return}Q.error(e instanceof Error?e.message:s(`memory.messages.scanStartError`),{id:`project-context-scan-error`})}).finally(()=>{ae(!1)}))},Qe=async()=>{if(t){se(!0);try{let{filename:e,archive:n}=await ze(t),r=new Blob([JSON.stringify(n,null,2)],{type:`application/json;charset=utf-8`}),i=window.URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,a.click(),window.URL.revokeObjectURL(i),Q.success(s(`memory.messages.exportSuccess`),{id:`project-memory-export-success`})}catch(e){Q.error(e instanceof Error?e.message:s(`memory.messages.exportError`),{id:`project-memory-export-error`})}finally{se(!1)}}},$e=async e=>{if(!t){e.target.value=``;return}let n=e.target.files?.[0];if(e.target.value=``,n){ue(!0);try{let e=await Te(t,JSON.parse(await xh(n,s(`memory.import.readFileError`))));if(G){let e=await yh(t);d(e.conventions),p(e.decisions),h(e.suggestions),R(e.generatedContext?.context??null),B(e.generatedContext?.artifacts??[]),b(null),re(null)}W(e),Q.success(s(`memory.messages.importSuccess`),{id:`project-memory-import-success`})}catch(e){Q.error(e instanceof Error?e.message:s(`memory.messages.importError`),{id:`project-memory-import-error`})}finally{ue(!1)}}},et=(0,Z.jsxs)(`div`,{className:o?`rounded-lg border border-border/70 bg-background/35 p-4`:`rounded-2xl border border-border/70 bg-background/25 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-foreground`,children:s(`memory.transfer.title`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:s(`memory.transfer.description`)}),!he&&(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:s(`memory.transfer.createProjectFirst`)})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 self-start`,children:[(0,Z.jsxs)(J,{type:`button`,variant:`outline`,onClick:()=>{Qe()},disabled:!he||oe||ce,children:[(0,Z.jsx)(Um,{className:`h-3.5 w-3.5`}),s(oe?`memory.transfer.exporting`:`memory.transfer.export`)]}),(0,Z.jsxs)(J,{type:`button`,variant:`outline`,onClick:()=>{me.current?.click()},disabled:!he||oe||ce,children:[(0,Z.jsx)(Wm,{className:`h-3.5 w-3.5`}),s(ce?`memory.transfer.importing`:`memory.transfer.import`)]})]})]}),(0,Z.jsx)(`input`,{ref:me,type:`file`,accept:`application/json,.json`,className:`hidden`,"aria-label":s(`memory.transfer.importAriaLabel`),onChange:e=>{$e(e)}}),de&&(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,Z.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background/35 px-3 py-2 text-sm text-muted-foreground`,children:s(`memory.transfer.importedConventions`,{imported:de.summary.conventions_imported,skipped:de.summary.conventions_skipped})}),(0,Z.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background/35 px-3 py-2 text-sm text-muted-foreground`,children:s(`memory.transfer.importedDecisions`,{imported:de.summary.decisions_imported,skipped:de.summary.decisions_skipped})}),(0,Z.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background/35 px-3 py-2 text-sm text-muted-foreground`,children:s(`memory.transfer.importedScans`,{imported:de.summary.scans_imported,skipped:de.summary.scans_skipped})}),(0,Z.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background/35 px-3 py-2 text-sm text-muted-foreground`,children:s(`memory.transfer.importedArtifacts`,{imported:de.summary.artifacts_imported,skipped:de.summary.artifacts_skipped})}),(0,Z.jsx)(`div`,{className:`sm:col-span-2 xl:col-span-4 rounded-lg border border-border/60 bg-background/35 px-3 py-2 text-sm text-muted-foreground`,children:bh(s,de)})]})]}),tt=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[Ze&&(0,Z.jsx)(q,{variant:`outline`,className:`px-3 py-1 text-xs uppercase tracking-[0.24em]`,children:lh(s,L)}),L?.stale&&(0,Z.jsx)(q,{variant:`outline`,className:`px-3 py-1 text-xs uppercase tracking-[0.24em] text-amber-300`,children:s(`memory.archive.stale`)})]}),nt=(0,Z.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,className:`min-w-[7.5rem] shrink-0 justify-center`,disabled:ie||qe,onClick:Y,children:[ie||qe?(0,Z.jsx)(ye,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(Gm,{className:`size-3.5`}),s(ie||qe?`memory.archive.scanning`:`memory.archive.scanNow`)]});return o?(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[ve&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground`,children:s(`memory.archive.disabledNote`)}),ge&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground`,children:s(`memory.archive.createNote`)}),_e&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground`,children:s(`memory.archive.saveFirstNote`)}),G&&(0,Z.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[18rem_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`space-y-4 rounded-xl border border-border/70 bg-background/35 p-4 xl:sticky xl:top-4 xl:self-start`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-border/60 pb-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground`,children:s(`memory.archive.generatedContext`)}),(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:s(`memory.archive.scanArchive`)})]}),(0,Z.jsx)(`div`,{className:`pt-0.5`,children:nt})]}),(0,Z.jsx)(`div`,{className:`mt-3`,children:tt})]}),U&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-red-300`,children:U}),te?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-4 text-sm text-muted-foreground`,children:s(`memory.archive.loadingLatestScanStatus`)}):Ve?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[Ve.error&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-red-300`,children:Ve.error}),L?.stale&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-200`,children:s(`memory.archive.staleWarning`)}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:s(`memory.archive.scanArtifactsCount`,{count:K.length})}),qe&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,Z.jsx)(ye,{className:`size-3.5 animate-spin`}),s(`memory.archive.updating`)]})]}),(0,Z.jsxs)(`div`,{className:`relative rounded-lg border border-border/60 bg-background/35 p-3`,children:[K.length===0?(0,Z.jsx)(`div`,{className:`flex min-h-32 items-center justify-center rounded-md border border-dashed border-border/70 bg-background/30 px-4 text-sm text-muted-foreground`,children:s(`memory.archive.noScanArtifactsYet`)}):(0,Z.jsx)(`div`,{className:`space-y-0`,children:K.map(e=>(0,Z.jsx)(wh,{artifact:e,onClick:()=>ee(!0)},e.id))}),qe&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-3 z-10 rounded-md border border-border/70 bg-background/78 backdrop-blur-sm`})]})]})]}):(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-4 text-sm text-muted-foreground`,children:s(`memory.archive.noScanYet`)})]}),(0,Z.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-border/70 bg-card/55 shadow-[0_18px_40px_rgba(0,0,0,0.16)]`,children:[y&&(0,Z.jsx)(`div`,{className:`m-4 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-red-300`,children:y}),(0,Z.jsxs)(`div`,{className:`border-b border-border/60 px-5 py-4`,children:[(0,Z.jsx)(`div`,{className:`flex flex-col gap-4 xl:flex-row xl:items-end xl:justify-between`,children:(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground`,children:s(`memory.archive.memoryLabel`)}),(0,Z.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:s(`memory.archive.memoriesTitle`)})]})}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:s(`memory.archive.summaryMemories`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-foreground`,children:Ye})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:s(`memory.archive.summarySuggested`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-foreground`,children:Ce.length})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:s(`memory.archive.summarySaved`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-foreground`,children:Se.length})]})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-8 px-5 py-5`,children:[(0,Z.jsxs)(`section`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-foreground`,children:s(`memory.archive.suggestedMemoriesTitle`)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s(`memory.archive.itemsCount`,{count:Ce.length})})]}),g?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-4 text-sm text-muted-foreground`,children:s(`memory.archive.loadingSuggestedMemories`)}):Ce.length>0?(0,Z.jsx)(`ul`,{className:`space-y-3`,children:Ce.map(e=>(0,Z.jsx)(Dh,{memory:e,isPending:M===e.id,onReview:Me,onAccept:async e=>{await Fe(e,!1)},onDismiss:Ie},e.id))}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`memory.archive.noSuggestedMemories`)})]}),(0,Z.jsxs)(`section`,{className:`space-y-4 border-t border-border/60 pt-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-foreground`,children:s(`memory.archive.savedMemoriesTitle`)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s(`memory.archive.itemsCount`,{count:Se.length})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(cm,{id:`memory-show-archived-memories`,checked:F,onCheckedChange:I,"aria-label":s(`memory.archive.showArchivedAriaLabel`)}),(0,Z.jsx)(mu,{htmlFor:`memory-show-archived-memories`,className:`text-sm text-muted-foreground`,children:s(`memory.archive.showArchivedLabel`)})]}),(0,Z.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:Ae,children:[(0,Z.jsx)(tf,{className:`size-3.5`}),s(`memory.archive.newMemory`)]})]})]}),g?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-4 text-sm text-muted-foreground`,children:s(`memory.archive.loadingSavedMemories`)}):(0,Z.jsx)(`div`,{className:`grid gap-3 xl:grid-cols-2`,children:Se.map(e=>(0,Z.jsx)(Ch,{title:e.title,meta:e.meta,preview:e.preview,archived:e.archived,ariaLabel:s(`memory.archive.openMemoryAriaLabel`,{kind:e.kind,title:e.title}),onClick:()=>{if(e.kind===`convention`){let t=u.find(t=>t.id===e.id);t&&ke(t);return}let t=f.find(t=>t.id===e.id);t&&je(t)},accentClassName:e.kind===`convention`?`bg-sky-300/50`:`bg-amber-300/45`},e.id))}),!g&&Se.length===0&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`memory.archive.noSavedMemories`)})]})]})]})]}),(0,Z.jsx)(Kl,{open:Be,onOpenChange:e=>{e||Ee()},children:(0,Z.jsxs)(Xl,{className:`max-h-[85vh] overflow-y-auto sm:max-w-3xl`,onInteractOutside:e=>e.preventDefault(),children:[(0,Z.jsxs)(Zl,{children:[(0,Z.jsx)($l,{children:c?.id?s(`memory.archive.editMemory`):s(`memory.archive.createMemory`)}),(0,Z.jsx)(eu,{children:s(`memory.archive.editorDescription`)})]}),(0,Z.jsx)(Th,{draft:E,onChange:D,onCancel:Ee,onSubmit:()=>{Oe()},isSaving:A,submitLabel:c?.id?s(`memory.archive.saveMemory`):s(`memory.archive.createMemory`),layout:`dialog`,allowKindChange:c?.id==null,secondaryActions:He?He.status===`active`?(0,Z.jsx)(J,{type:`button`,variant:`warning`,onClick:()=>{Le(He,`archive`).then(e=>{e&&Ee()})},children:s(`memory.archive.archive`)}):(0,Z.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>{Le(He,`restore`).then(e=>{e&&Ee()})},children:s(`memory.archive.restore`)}):Ue?Ue.status===`accepted`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>{Re(Ue,`supersede`).then(e=>{e&&Ee()})},children:s(`memory.archive.supersede`)}),(0,Z.jsx)(J,{type:`button`,variant:`warning`,onClick:()=>{Re(Ue,`archive`).then(e=>{e&&Ee()})},children:s(`memory.archive.archive`)})]}):(0,Z.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>{Re(Ue,`restore`).then(e=>{e&&Ee()})},children:s(`memory.archive.restore`)}):null})]})}),(0,Z.jsx)(Oh,{memory:Ge,isOpen:Ge!==null,isEditing:w!==null,isPending:M===Ge?.id,draft:O,onOpenChange:Ne,onDraftChange:k,onStartEdit:Pe,onCancelEdit:De,onAccept:Fe,onDismiss:Ie}),(0,Z.jsx)(Kl,{open:V,onOpenChange:ee,children:(0,Z.jsx)(Xl,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Zl,{children:[(0,Z.jsx)($l,{children:s(`memory.archive.scanArchiveDialogTitle`)}),(0,Z.jsx)(eu,{className:`sr-only`,children:s(`memory.archive.scanArchiveDialogDescription`)})]}),K.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-4 text-sm text-muted-foreground`,children:s(`memory.archive.noScanArtifactsYet`)}):(0,Z.jsx)(`div`,{className:`space-y-4`,children:K.map(e=>{let t=ph(e),n=mh(t.title);return(0,Z.jsxs)(`section`,{className:`space-y-2 rounded-lg border border-border/70 bg-background/40 px-4 py-3`,children:[(n||t.categoryLabel)&&(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[n&&(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-foreground`,children:t.title}),t.categoryLabel&&(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:t.categoryLabel})]}),(0,Z.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-6 text-foreground`,children:e.content_markdown?.trim()||s(`memory.artifact.emptyNotes`)})]},e.id)})})]})})})]}):(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[a&&(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border/70 bg-background/25 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:s(`memory.activation.title`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:s(`memory.activation.description`)})]}),(0,Z.jsx)(cm,{"aria-label":s(`memory.activation.ariaLabel`),checked:n,onCheckedChange:i})]})}),et]})},Ah=({title:e,description:t,headerAccessory:n,children:r})=>(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-border/60 pb-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:e}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),n]}),r]}),jh=({label:e,summary:t,tone:n=`default`})=>(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start text-left`,children:(0,Z.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:W(`text-sm font-medium`,n===`danger`?`text-red-200`:`text-foreground`),children:e}),(0,Z.jsx)(`span`,{className:W(`shrink-0 text-[10px] font-semibold uppercase tracking-[0.18em]`,n===`danger`?`text-red-300/80`:`text-muted-foreground`),children:t})]})}),Mh=()=>({name:``,cmd:``,cwd:``}),Nh=()=>({source:``,target:``,mode:`copy`}),Ph=()=>({id:`test-command-${crypto.randomUUID()}`,name:``,command:``,cwd:``,runner:`auto`}),Fh=()=>({name:``,repoPath:``,linkedProjectIds:[],runSetup:[],runServices:[],testCommands:[],runIde:``,previewServiceName:``,previewPath:``,previewCapabilityMode:`auto`,helperModel:``,helperVariant:``,commitMessageRules:``,autoParkStaleTickets:!1,memoryEnabled:!1,worktreeSync:[]}),Ih=e=>({name:e.name,repoPath:e.repoPath,linkedProjectIds:e.linkedProjectIds,runSetupText:e.runSetup.join(`
|
|
28
|
+
`),runServices:e.runServices.length>0?e.runServices.map(e=>({name:e.name??``,cmd:e.cmd??``,cwd:e.cwd??``})):[],testCommands:(e.testCommands??[]).length>0?(e.testCommands??[]).map(e=>({id:e.id,name:e.name??``,command:e.command??``,cwd:e.cwd??``,runner:e.runner??`auto`})):[],runIde:e.runIde,previewServiceName:e.previewServiceName??``,previewPath:e.previewPath??``,previewCapabilityMode:e.previewCapabilityMode??`auto`,helperModel:e.helperModel,helperVariant:e.helperVariant,commitMessageRules:e.commitMessageRules,autoParkStaleTickets:e.autoParkStaleTickets,memoryEnabled:e.memoryEnabled,worktreeSync:e.worktreeSync.length>0?e.worktreeSync.map(e=>({source:e.source??``,target:e.target??``,mode:e.mode})):[]}),Lh=(e,t,n)=>e(`modal.${t}`,n),Rh=e=>e.split(`
|
|
29
|
+
`).map(e=>e.trim()).filter(e=>e.length>0),zh=e=>e.cmd.trim()!==``||e.cwd.trim()!==``,Bh=e=>e.filter(zh).map(e=>({...e.name.trim()===``?{}:{name:e.name.trim()},cmd:e.cmd.trim(),cwd:e.cwd.trim()})),Vh=e=>e.name.trim()!==``||e.command.trim()!==``||e.cwd.trim()!==``,Hh=(e,t)=>t===1?`tests`:e.cwd.trim()===``?`repo tests`:`${e.cwd.trim()} tests`,Uh=e=>e.filter(Vh).map(e=>({id:e.id,name:e.name.trim(),command:e.command.trim(),cwd:e.cwd.trim(),runner:e.runner})).map((e,t,n)=>{if(e.name!==``)return e;let r=Hh(e,n.length),i=n.slice(0,t).filter(e=>(e.name===``?Hh(e,n.length):e.name)===r).length;return{...e,name:i===0?r:`${r} ${i+1}`}}),Wh=e=>e.source.trim()!==``||e.target.trim()!==``,Gh=e=>e.filter(Wh).map(e=>({source:e.source.trim(),target:e.target.trim(),mode:e.mode})),Kh=e=>Rh(e).length===0,qh=e=>!e.some(zh),Jh=e=>!e.some(Vh),Yh=e=>!e.some(Wh),Xh=(e,t)=>t.length===0?Lh(e,`linkedProjects.none`):t.length===1?t[0]:Lh(e,`linkedProjects.count`,{count:t.length}),Zh=e=>e.name||e.repoPath||e.previewServiceName?!0:e.runServices.some(e=>!!e.cmd)||e.testCommands.some(e=>!!e.command)||e.worktreeSync.some(e=>!!e.source),Qh=e=>e.name||e.repoPath?`general`:e.previewServiceName||e.runServices.some(e=>!!e.cmd)?`services`:e.testCommands.some(e=>!!e.command)?`tests`:e.worktreeSync.some(e=>!!e.source)?`sync`:`general`,$h=(e,t)=>{let n=e.runServices.map(e=>zh(e)&&e.cmd.trim()===``?{cmd:Lh(t,`validation.serviceCommandRequired`)}:{}),r=e.worktreeSync.map(e=>Wh(e)&&e.source.trim()===``?{source:Lh(t,`validation.syncSourceRequired`)}:{}),i=e.testCommands.map(e=>Vh(e)?{command:e.command.trim()===``?Lh(t,`validation.testCommandRequired`):void 0}:{}),a=Bh(e.runServices),o=e.previewServiceName.trim(),s=o!==``&&!a.some(e=>e.name===o)?Lh(t,`validation.previewServiceRequired`):void 0;return{name:e.name.trim()===``?Lh(t,`validation.projectNameRequired`):void 0,repoPath:e.repoPath.trim()===``?Lh(t,`validation.repositoryPathRequired`):void 0,previewServiceName:s,runServices:n,testCommands:i,worktreeSync:r}},eg=({mode:e=`create`,projectId:t=null,initialValues:n=Fh(),availableHelperModels:r=[],isLoadingHelperModels:i=!1,linkedProjectOptions:a=[],isAutoConfigReady:o=!1,repoPathLocked:s=!1,repoPathLockedMessage:c=null,deleteBlockedMessage:l=null,onAutoConfig:u,onBrowseRepoPath:d,onValidateRepoPath:f,onClose:p,onSubmit:m,onDelete:h})=>{let{t:g}=ht(`projects`),[_,v]=(0,X.useState)(()=>Ih(n)),[y,b]=(0,X.useState)({runServices:[],testCommands:[],worktreeSync:[]}),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)({status:`idle`}),[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(e===`edit`&&t?null:0),F=(0,X.useRef)(n.repoPath.trim()),I=(0,X.useRef)(0),L=(0,X.useRef)(null),R=(0,X.useRef)(n.repoPath.trim()||null),z=(0,X.useRef)(n.repoPath.trim()||null),B=(0,X.useRef)(null),[V,ee]=(0,X.useState)(`general`),te=_.repoPath.trim(),H=s?te!==``:f?te!==``&&(te===F.current||e===`create`&&T.status===`initializable`||T.status===`valid`&&z.current===te):te!==``,ne=j||_.name.trim()===``||!H,U=D||!!l,re=x||_.repoPath.trim()===``||!o||T.status===`initializable`,ie=T.status===`initializable`?T.message:null,ae=new Map(a.map(e=>[e.id,e.name])),oe=_.linkedProjectIds.map(e=>ae.get(e)).filter(e=>typeof e==`string`),se=e===`edit`,ce=[{value:`general`,label:Lh(g,`navigation.general`),summary:Lh(g,`navigation.summary.required`)},{value:`automation`,label:Lh(g,`navigation.automation`),summary:_.helperModel||_.commitMessageRules.trim()||_.runSetupText.trim()||_.runIde.trim()||_.linkedProjectIds.length>0||_.autoParkStaleTickets?Lh(g,`navigation.summary.configured`):Lh(g,`navigation.summary.optional`)},{value:`services`,label:Lh(g,`navigation.services`),summary:_.runServices.length===0?Lh(g,`navigation.summary.none`):Lh(g,`navigation.summary.count`,{count:_.runServices.length})},{value:`tests`,label:Lh(g,`navigation.tests`),summary:_.testCommands.length===0?Lh(g,`navigation.summary.none`):Lh(g,`navigation.summary.count`,{count:_.testCommands.length})},{value:`sync`,label:Lh(g,`navigation.sync`),summary:_.worktreeSync.length===0?Lh(g,`navigation.summary.none`):Lh(g,`navigation.summary.count`,{count:_.worktreeSync.length})},{value:`memory`,label:Lh(g,`navigation.memory`),summary:_.memoryEnabled?Lh(g,`navigation.summary.enabled`):Lh(g,`navigation.summary.disabled`)},...e===`edit`&&t?[{value:`integrations`,label:Lh(g,`navigation.integrations`),summary:N===null?Lh(g,`navigation.summary.loading`):Lh(g,`navigation.summary.integrationsCount`,{count:N})}]:[],...e===`edit`&&h?[{value:`danger`,label:Lh(g,`navigation.danger`),summary:l?Lh(g,`navigation.summary.blocked`):Lh(g,`navigation.summary.ready`),tone:`danger`}]:[]],le=(0,X.useCallback)(()=>{L.current!==null&&(window.clearTimeout(L.current),L.current=null)},[]);(0,X.useEffect)(()=>{if(e!==`edit`||!t){P(0);return}let n=new AbortController;return P(null),nm(t,n.signal).then(e=>{if(n.signal.aborted)return;let t=e.connections.filter(e=>e.status===`connected`).length;P(t)}).catch(()=>{n.signal.aborted||P(0)}),()=>{n.abort()}},[e,t]);let ue=(0,X.useCallback)(async t=>{if(!f){E({status:`idle`});return}let n=t.trim();if(n===``){R.current=null,z.current=null,E({status:`idle`});return}let r=I.current+1;I.current=r,R.current=n,E({status:`checking`});try{let t=await f(n);if(I.current!==r)return;if(t.valid&&t.repoRoot){z.current=n,E({status:`valid`,repoRoot:t.repoRoot});return}if(t.willInitialize&&e===`create`){z.current=null,E({status:`initializable`,message:Lh(g,`repoPath.initializable`)});return}z.current=null,E({status:`invalid`,error:t.error??Lh(g,`repoPath.invalid`)})}catch(e){if(I.current!==r)return;let t=e instanceof Error?e.message:Lh(g,`repoPath.validateFailed`);z.current=null,E({status:`invalid`,error:t})}},[e,f,g]);(0,X.useEffect)(()=>{if(le(),s){I.current+=1,R.current=te||null,z.current=te||null,E(te===``?{status:`idle`}:{status:`valid`,repoRoot:te});return}if(!f||te===``){I.current+=1,R.current=null,z.current=null,E({status:`idle`});return}if(te===F.current){I.current+=1,R.current=te,z.current=te,E({status:`valid`,repoRoot:te});return}if(B.current===te){B.current=null;return}if(R.current!==te)return E({status:`idle`}),L.current=window.setTimeout(()=>{ue(te)},350),()=>{le()}},[le,f,s,ue,te,_.repoPath]);let de=(e,t)=>{v(n=>({...n,[e]:t})),(e===`name`||e===`repoPath`)&&b(t=>({...t,[e]:void 0}))},fe=(e,t,n)=>{v(r=>({...r,runServices:r.runServices.map((r,i)=>i===e?{...r,[t]:n}:r)})),b(t=>({...t,runServices:t.runServices.map((t,n)=>n===e?{...t,cmd:void 0}:t)}))},pe=(e,t,n)=>{v(r=>({...r,testCommands:r.testCommands.map((r,i)=>i!==e||t===`runner`&&n!==`auto`&&n!==`vitest`&&n!==`jest`&&n!==`unknown`?r:{...r,[t]:n})})),b(t=>({...t,testCommands:t.testCommands.map((t,n)=>n===e?{...t,command:void 0}:t)}))},me=(e,t,n)=>{v(r=>({...r,worktreeSync:r.worktreeSync.map((r,i)=>i!==e||t===`mode`&&n!==`copy`&&n!==`symlink`?r:{...r,[t]:n})})),b(t=>({...t,worktreeSync:t.worktreeSync.map((t,n)=>n===e?{...t,source:void 0}:t)}))},G=e=>{v(t=>({...t,linkedProjectIds:t.linkedProjectIds.includes(e)?t.linkedProjectIds.filter(t=>t!==e):[...t.linkedProjectIds,e].sort((e,t)=>e.localeCompare(t))}))},he=()=>{v(e=>({...e,runServices:[...e.runServices,Mh()]})),b(e=>({...e,runServices:[...e.runServices,{}]}))},ge=e=>{v(t=>({...t,runServices:t.runServices.filter((t,n)=>n!==e)})),b(t=>({...t,runServices:t.runServices.filter((t,n)=>n!==e)}))},_e=()=>{v(e=>({...e,worktreeSync:[...e.worktreeSync,Nh()]})),b(e=>({...e,worktreeSync:[...e.worktreeSync,{}]}))},ve=e=>{v(t=>({...t,worktreeSync:t.worktreeSync.filter((t,n)=>n!==e)})),b(t=>({...t,worktreeSync:t.worktreeSync.filter((t,n)=>n!==e)}))},ye=()=>{v(e=>({...e,testCommands:[...e.testCommands,Ph()]})),b(e=>({...e,testCommands:[...e.testCommands,{}]}))},be=e=>{v(t=>({...t,testCommands:t.testCommands.filter((t,n)=>n!==e)})),b(t=>({...t,testCommands:t.testCommands.filter((t,n)=>n!==e)}))},xe=async e=>{if(e.preventDefault(),j)return;let t=$h(_,g);if(b(t),Zh(t)){ee(Qh(t));return}M(!0);let n=Uh(_.testCommands),r=await m({name:_.name.trim(),repoPath:_.repoPath.trim(),linkedProjectIds:_.linkedProjectIds,runSetup:Rh(_.runSetupText),runServices:Bh(_.runServices),...n.length>0?{testCommands:n}:{},runIde:_.runIde.trim(),..._.previewServiceName.trim()===``?{}:{previewServiceName:_.previewServiceName.trim()},..._.previewPath.trim()===``?{}:{previewPath:_.previewPath.trim()},..._.previewServiceName.trim()!==``||_.previewPath.trim()!==``||_.previewCapabilityMode!==`auto`?{previewCapabilityMode:_.previewCapabilityMode}:{},helperModel:_.helperModel,helperVariant:_.helperVariant,commitMessageRules:_.commitMessageRules.trim(),autoParkStaleTickets:_.autoParkStaleTickets,memoryEnabled:_.memoryEnabled,worktreeSync:Gh(_.worktreeSync)});r&&(Q.error(r,{id:`project-modal-submit-error`}),M(!1))},Se=async()=>{if(!h||U)return;O(!0);let e=await h();e&&(Q.error(e,{id:`project-modal-delete-error`}),O(!1))},Ce=async()=>{if(!(!u||re)){S(!0);try{let e=await u(_.repoPath.trim(),_.helperModel,_.helperVariant),t=[];v(n=>{let r={...n};return Kh(n.runSetupText)&&e.run_setup.length>0&&(r.runSetupText=e.run_setup.join(`
|
|
30
|
+
`),t.push(`setup commands`)),qh(n.runServices)&&e.run_services.length>0&&(r.runServices=e.run_services.map(e=>({name:e.name??``,cmd:e.cmd,cwd:e.cwd??``})),t.push(`services`)),Jh(n.testCommands)&&(e.test_commands??[]).length>0&&(r.testCommands=(e.test_commands??[]).map(e=>({id:e.id,name:e.name,command:e.command,cwd:e.cwd??``,runner:e.runner})),t.push(`tests`)),Yh(n.worktreeSync)&&e.worktree_sync.length>0&&(r.worktreeSync=e.worktree_sync.map(e=>({source:e.source,target:e.target??``,mode:e.mode})),t.push(`worktree sync`)),r}),b(e=>({...e,runServices:t.includes(`services`)?[]:e.runServices,testCommands:t.includes(`tests`)?[]:e.testCommands,worktreeSync:t.includes(`worktree sync`)?[]:e.worktreeSync})),t.length>0?Q.success(Lh(g,`autoConfig.applied`),{id:`project-modal-auto-config-success`}):Q.info(Lh(g,`autoConfig.noop`),{id:`project-modal-auto-config-noop`})}catch{Q.error(Lh(g,`autoConfig.failed`),{id:`project-modal-auto-config-error`})}finally{S(!1)}}},we=async()=>{if(!(!d||C||s)){w(!0);try{let e=await d();e&&(B.current=e.trim(),de(`repoPath`,e),ue(e))}catch(e){let t=e instanceof Error?e.message:Lh(g,`repoPath.browseFailed`);Q.error(t,{id:`project-modal-browse-repo-path-error`})}finally{w(!1)}}};return(0,Z.jsx)(Kl,{open:!0,onOpenChange:e=>{e||p()},children:(0,Z.jsxs)(Xl,{showCloseButton:!1,overlayClassName:`bg-black/70`,className:`flex h-[calc(100vh-1.5rem)] max-h-[58rem] w-full max-w-[calc(100%-1rem)] flex-col gap-0 overflow-hidden rounded-3xl border border-[#2a2a38] bg-[#16161f] p-0 shadow-2xl sm:max-w-6xl`,onInteractOutside:e=>e.preventDefault(),children:[(0,Z.jsx)($l,{className:`sr-only`,children:se?Lh(g,`dialogTitle.edit`):Lh(g,`dialogTitle.create`)}),(0,Z.jsx)(eu,{className:`sr-only`,children:Lh(g,`dialogDescription`)}),(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-border px-6 py-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h2`,{className:`text-2xl font-semibold text-foreground`,children:se?Lh(g,`header.title.edit`):Lh(g,`header.title.create`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:se?Lh(g,`header.description.edit`):Lh(g,`header.description.create`)})]}),(0,Z.jsx)(Jl,{asChild:!0,children:(0,Z.jsx)(J,{type:`button`,"aria-label":Lh(g,`header.close`),variant:`ghost`,size:`icon-sm`,className:`cursor-pointer text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(Fe,{className:`h-4 w-4`})})})]}),(0,Z.jsxs)(`form`,{onSubmit:xe,className:`flex flex-1 flex-col overflow-hidden`,children:[(0,Z.jsxs)(Qp,{value:V,onValueChange:e=>ee(e),orientation:`vertical`,className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,Z.jsxs)(`aside`,{className:`border-b border-border/70 px-4 py-4 md:w-[18rem] md:border-r md:border-b-0 md:px-5 md:py-5`,children:[(0,Z.jsx)(`p`,{className:`px-2 text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground`,children:Lh(g,`navigation.title`)}),(0,Z.jsx)($p,{className:`mt-3 flex w-full flex-col items-stretch gap-1 border-0 bg-transparent p-0 shadow-none`,children:ce.map(e=>(0,Z.jsx)(em,{value:e.value,className:W(`h-auto w-full justify-start whitespace-normal border-transparent bg-transparent px-3 py-3 text-left shadow-none hover:bg-background/50 data-[state=active]:border-border/70 data-[state=active]:bg-card/90`,e.tone===`danger`&&`data-[state=active]:border-red-500/30 data-[state=active]:bg-destructive/10`),children:(0,Z.jsx)(jh,{label:e.label,summary:e.summary,tone:e.tone})},e.value))})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,Z.jsx)(tm,{value:`general`,className:`mt-0`,children:(0,Z.jsx)(Ah,{title:Lh(g,`sections.general.title`),description:Lh(g,`sections.general.description`),children:(0,Z.jsx)(Em,{name:_.name,repoPath:_.repoPath,repoPathLocked:s,repoPathLockedMessage:c,repoPathDescription:ie,isBrowsingRepoPath:C,repoPathValidation:T,nameError:y.name,repoPathError:y.repoPath,onNameChange:e=>de(`name`,e),onRepoPathChange:e=>de(`repoPath`,e),onBrowseRepoPath:d?()=>{we()}:void 0})})}),(0,Z.jsx)(tm,{value:`automation`,className:`mt-0`,children:(0,Z.jsx)(Ah,{title:Lh(g,`sections.automation.title`),description:Lh(g,`sections.automation.description`),children:(0,Z.jsx)(bm,{onAutoConfig:u?()=>{Ce()}:void 0,isAutoConfigDisabled:re,isAutoConfiguring:x,helperModel:_.helperModel,helperVariant:_.helperVariant,availableHelperModels:r,isLoadingHelperModels:i,onHelperModelChange:e=>{v(t=>({...t,helperModel:e,helperVariant:e===t.helperModel?t.helperVariant:``}))},onHelperVariantChange:e=>{v(t=>({...t,helperVariant:e}))},commitMessageRules:_.commitMessageRules,onCommitMessageRulesChange:e=>de(`commitMessageRules`,e),linkedProjectOptions:a,selectedLinkedProjectNames:oe,linkedProjectTriggerLabel:Xh(g,oe),linkedProjectIds:_.linkedProjectIds,onToggleLinkedProject:G,runSetupText:_.runSetupText,onRunSetupChange:e=>de(`runSetupText`,e),runIde:_.runIde,onRunIdeChange:e=>de(`runIde`,e),autoParkStaleTickets:_.autoParkStaleTickets,onAutoParkStaleTicketsChange:e=>{v(t=>({...t,autoParkStaleTickets:e}))}})})}),(0,Z.jsx)(tm,{value:`services`,className:`mt-0`,children:(0,Z.jsx)(Ah,{title:Lh(g,`sections.services.title`),description:Lh(g,`sections.services.description`),children:(0,Z.jsx)(xm,{runServices:_.runServices,runServiceErrors:y.runServices,previewServiceName:_.previewServiceName,previewPath:_.previewPath,previewCapabilityMode:_.previewCapabilityMode,previewServiceNameError:y.previewServiceName,onAddServiceRow:he,onServiceChange:fe,onPreviewServiceNameChange:e=>{v(t=>({...t,previewServiceName:e})),b(e=>({...e,previewServiceName:void 0}))},onPreviewPathChange:e=>{v(t=>({...t,previewPath:e}))},onPreviewCapabilityModeChange:e=>{v(t=>({...t,previewCapabilityMode:e}))},onRemoveServiceRow:ge})})}),(0,Z.jsx)(tm,{value:`tests`,className:`mt-0`,children:(0,Z.jsx)(Ah,{title:Lh(g,`sections.tests.title`),description:Lh(g,`sections.tests.description`),children:(0,Z.jsx)(Sm,{testCommands:_.testCommands,testCommandErrors:y.testCommands,onAddTestCommandRow:ye,onTestCommandChange:pe,onRemoveTestCommandRow:be})})}),(0,Z.jsx)(tm,{value:`sync`,className:`mt-0`,children:(0,Z.jsx)(Ah,{title:Lh(g,`sections.sync.title`),description:Lh(g,`sections.sync.description`),children:(0,Z.jsx)(Cm,{worktreeSync:_.worktreeSync,worktreeSyncErrors:y.worktreeSync,onAddWorktreeSyncRow:_e,onWorktreeSyncChange:me,onRemoveWorktreeSyncRow:ve})})}),(0,Z.jsx)(tm,{value:`memory`,className:`mt-0`,children:(0,Z.jsx)(Ah,{title:Lh(g,`sections.memory.title`),description:Lh(g,`sections.memory.description`),headerAccessory:(0,Z.jsx)(q,{variant:`outline`,className:`self-start px-3 py-1 text-xs uppercase tracking-[0.24em]`,children:_.memoryEnabled?Lh(g,`navigation.summary.enabled`):Lh(g,`navigation.summary.disabled`)}),children:(0,Z.jsx)(kh,{mode:e,projectId:t,memoryEnabled:_.memoryEnabled,persistedMemoryEnabled:n.memoryEnabled,onMemoryEnabledChange:e=>{v(t=>({...t,memoryEnabled:e}))}})})}),e===`edit`&&t&&(0,Z.jsx)(tm,{value:`integrations`,className:`mt-0`,children:(0,Z.jsx)(Ah,{title:Lh(g,`sections.integrations.title`),description:Lh(g,`sections.integrations.description`),children:(0,Z.jsx)(Vm,{projectId:t,onEnabledCountChange:P})})}),e===`edit`&&h&&(0,Z.jsx)(tm,{value:`danger`,className:`mt-0`,children:(0,Z.jsx)(Ah,{title:Lh(g,`sections.danger.title`),description:Lh(g,`sections.danger.description`),children:(0,Z.jsx)(Dm,{projectName:_.name,deleteBlockedMessage:l,isDeleteDisabled:U,isDeleting:D,showDeleteConfirm:k,onDeleteConfirmToggle:A,onDelete:()=>{Se()}})})})]})]}),(0,Z.jsx)(`div`,{className:`border-t border-border px-6 py-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-end`,children:[(0,Z.jsx)(J,{type:`button`,onClick:p,variant:`ghost`,children:Lh(g,`actions.cancel`)}),(0,Z.jsx)(J,{type:`submit`,disabled:ne,variant:`success`,children:j?se?Lh(g,`actions.saveChangesBusy`):Lh(g,`actions.createProjectBusy`):se?Lh(g,`actions.saveChanges`):Lh(g,`actions.createProject`)})]})})]})]})})},tg=({compactAt:e,tightAt:t,width:n})=>n<=0?`wide`:n<=t?`tight`:n<=e?`compact`:`wide`,ng=({compactAt:e,tightAt:t})=>{let[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(`wide`),o=(0,X.useCallback)(n=>{r(n);let i=n?Math.round(n.getBoundingClientRect().width):0;a(n=>{let r=tg({compactAt:e,tightAt:t,width:i});return n===r?n:r})},[e,t]);return(0,X.useEffect)(()=>{if(!n)return;let r=()=>{let r=Math.round(n.getBoundingClientRect().width);a(n=>{let i=tg({compactAt:e,tightAt:t,width:r});return n===i?n:i})};if(r(),typeof ResizeObserver!=`function`)return;let i=new ResizeObserver(()=>{r()});return i.observe(n),()=>{i.disconnect()}},[e,n,t]),{ref:o,mode:i}},rg=e=>!Number.isFinite(e)||e<=0?`0 B`:e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${Math.round(e)} B`,ig=({attachment:e,onClose:t})=>{let{t:n}=ht(`common`);if(!e)return null;let r=T(e.content_url);return(0,Z.jsx)(Kl,{open:!0,onOpenChange:e=>{e||t()},children:(0,Z.jsxs)(Xl,{showCloseButton:!1,overlayClassName:`bg-black/80 supports-backdrop-filter:backdrop-blur-md`,className:`flex h-[calc(100vh-1rem)] max-h-[calc(100vh-1rem)] w-[calc(100vw-1rem)] max-w-[calc(100vw-1rem)] sm:max-w-[calc(100vw-1rem)] flex-col gap-0 overflow-hidden border-border/80 bg-background/95 p-0 shadow-2xl`,children:[(0,Z.jsx)($l,{className:`sr-only`,children:n(`attachmentPreviewDialog.title`,{name:e.original_name})}),(0,Z.jsx)(eu,{className:`sr-only`,children:n(`attachmentPreviewDialog.description`,{name:e.original_name})}),(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-border/70 px-4 py-2.5 sm:px-5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground sm:text-base`,children:e.original_name}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:rg(e.size_bytes)})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsx)(J,{asChild:!0,variant:`outline`,size:`sm`,children:(0,Z.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,children:n(`attachmentPreviewDialog.openInNewTab`)})}),(0,Z.jsx)(Jl,{asChild:!0,children:(0,Z.jsx)(J,{type:`button`,"aria-label":n(`attachmentPreviewDialog.closeAriaLabel`),variant:`ghost`,size:`icon-sm`,className:`cursor-pointer text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(Fe,{className:`h-4 w-4`})})})]})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-black/35 p-2 sm:p-3`,children:(0,Z.jsx)(`img`,{src:r,alt:n(`attachmentPreviewDialog.imageAlt`,{name:e.original_name}),className:`h-auto max-h-full w-auto max-w-full rounded-xl object-contain`})})]})})},ag=120,og=160,sg=(e,t)=>t===0?0:e<0?t-1:e>=t?0:e,cg=e=>({start:e.selectionStart??0,end:e.selectionEnd??0}),lg=e=>e?`${e.replaceStart}:${e.replaceEnd}:${e.query}`:null,ug=({value:e,selection:t})=>{if(t.start!==t.end)return null;let n=t.start;for(;n>0&&!/\s/.test(e[n-1]??``);)--n;let r=t.end;for(;r<e.length&&!/\s/.test(e[r]??``);)r+=1;return!e.slice(n,r).startsWith(`@`)||n>0&&!/\s/.test(e[n-1]??``)?null:{query:e.slice(n+1,t.start),replaceStart:n,replaceEnd:r}},dg=(e,t)=>{if(e){if(typeof e==`function`){e(t);return}e.current=t}},fg=e=>{let t=Number.parseFloat(e);return Number.isNaN(t)?0:t},pg=e=>{let t=fg(e.lineHeight);if(t>0)return t;let n=fg(e.fontSize);return n>0?n*1.2:20},mg=(e,t)=>{let n=window.getComputedStyle(e),r=document.createElement(`div`),i=document.createElement(`span`),a=e.value.slice(0,t),o=`borderBottomWidth.borderLeftWidth.borderRightWidth.borderTopWidth.boxSizing.fontFamily.fontFeatureSettings.fontKerning.fontSize.fontStretch.fontStyle.fontVariant.fontVariationSettings.fontWeight.letterSpacing.lineHeight.paddingBottom.paddingLeft.paddingRight.paddingTop.tabSize.textIndent.textTransform.whiteSpace.width.wordBreak.wordSpacing.overflowWrap`.split(`.`);r.setAttribute(`aria-hidden`,`true`),Object.assign(r.style,{position:`absolute`,visibility:`hidden`,top:`0`,left:`-9999px`,overflow:`hidden`,whiteSpace:`pre-wrap`,wordWrap:`break-word`,pointerEvents:`none`}),o.forEach(e=>{r.style[e]=n[e]}),r.textContent=a,i.textContent=``,r.append(i),document.body.append(r);let s=fg(n.borderTopWidth),c=pg(n),l=i.offsetTop+s-e.scrollTop;return r.remove(),{top:l,lineHeight:c}},hg=(0,X.forwardRef)(({projectId:e,suggestionTicketId:t=null,value:n,onValueChange:r,onKeyDown:i,onBlur:a,onFocus:o,onScroll:s,onSelect:c,suggestionAnchor:l=`edge`,suggestionPlacement:u=`below`,wrapperClassName:d,className:f,...p},m)=>{let h=(0,X.useRef)(null),g=(0,X.useRef)(null),[_,v]=(0,X.useState)({start:0,end:0}),[y,b]=(0,X.useState)([]),[x,S]=(0,X.useState)(0),[C,w]=(0,X.useState)(null),[T,E]=(0,X.useState)(!1),[D,O]=(0,X.useState)(null),[A,j]=(0,X.useState)(null),M=(0,X.useId)(),N=(0,X.useMemo)(()=>ug({value:n,selection:_}),[_,n]),P=lg(N),F=y.length>0,I=D===P,L=T&&F&&!I,R=!!e&&!!P&&C!==P&&(F||T||I);(0,X.useEffect)(()=>{let e=g.current;if(e===null)return;let t=h.current;if(!t)return;let n=requestAnimationFrame(()=>{let n=Math.min(e,t.value.length);t.focus(),t.setSelectionRange(n,n),v({start:n,end:n}),g.current=null});return()=>{cancelAnimationFrame(n)}},[n]),(0,X.useEffect)(()=>{if(!e||!P){w(null),b([]),O(null),E(!1),S(0);return}if(C===P)return;E(!0);let n=new AbortController,r=window.setTimeout(async()=>{try{let r=await G(e,N?.query??``,{signal:n.signal,ticketId:t});if(n.signal.aborted)return;b(r),O(P),S(0)}catch(e){k(e)||(b([]),O(P),S(0))}finally{n.signal.aborted||E(!1)}},ag);return()=>{n.abort(),window.clearTimeout(r)}},[N?.query,P,C,e,t]),(0,X.useEffect)(()=>{S(e=>sg(e,y.length))},[y]),(0,X.useLayoutEffect)(()=>{if(!R||l!==`caret`){j(null);return}let e=h.current;if(!e){j(null);return}let{top:t,lineHeight:n}=mg(e,_.start),r=t,i=e.clientHeight-(t+n),a=r>=og||r>=i?`above`:`below`,o=a===`above`?Math.max(t-8,0):t+n+8;j(e=>e&&e.placement===a&&Math.abs(e.top-o)<1?e:{placement:a,top:o})},[_.start,R,l,n]),(0,X.useEffect)(()=>{!R||y.length===0||document.getElementById(`${M}-option-${x}`)?.scrollIntoView({block:`nearest`})},[x,M,y.length,R]);let z=()=>{P&&w(P)},B=e=>{if(!e||!N||!I)return;let t=n.slice(N.replaceEnd),i=t.length===0||!/^\s/.test(t),a=`@${e.path}${i?` `:``}`,o=n.slice(0,N.replaceStart)+a+t,s=N.replaceStart+a.length,c=`${N.replaceStart}:${s}:${e.path}`;g.current=s,w(c),O(null),b([]),r(o)},V=e=>{v(cg(e.currentTarget)),r(e.target.value)},ee=e=>{z(),a?.(e)},te=e=>{v(cg(e.currentTarget)),o?.(e)},H=e=>{v(cg(e.currentTarget)),c?.(e)},ne=e=>{v(cg(e.currentTarget)),s?.(e)},U=l===`caret`&&A,re=U?{top:`${A.top}px`,transform:A.placement===`above`?`translateY(-100%)`:void 0}:void 0,ie=e=>{if(R){if(!I&&(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`)){e.preventDefault();return}if(e.key===`ArrowDown`){e.preventDefault(),S(e=>sg(e+1,y.length));return}if(e.key===`ArrowUp`){e.preventDefault(),S(e=>sg(e-1,y.length));return}if(e.key===`Enter`){e.preventDefault();let t=y[x]??null;t&&B(t);return}if(e.key===`Escape`){e.preventDefault(),z();return}}i?.(e)};return(0,Z.jsxs)(`div`,{className:W(`relative min-w-0`,d),children:[(0,Z.jsx)(tu,{...p,ref:e=>{h.current=e,dg(m,e)},value:n,onChange:V,onBlur:ee,onFocus:te,onKeyDown:ie,onScroll:ne,onSelect:H,"aria-activedescendant":R&&y[x]?`${M}-option-${x}`:void 0,"aria-controls":R?M:void 0,"aria-expanded":R,className:f}),R?(0,Z.jsxs)(`div`,{id:M,role:`listbox`,"aria-busy":T,"data-testid":`file-mention-suggestions`,"data-suggestion-anchor":U?`caret`:`edge`,"data-suggestion-placement":U?A.placement:u,className:W(`absolute inset-x-0 z-20 overflow-hidden rounded-xl border border-border bg-popover shadow-2xl shadow-black/30`,!U&&(u===`above`?`bottom-full mb-2`:`top-full mt-2`)),style:re,children:[L?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-10 rounded-full border border-border/80 bg-popover/95 px-2 py-0.5 text-[11px] font-medium text-muted-foreground shadow-sm`,children:`Updating...`}):null,(0,Z.jsx)(`div`,{className:`max-h-72 overflow-y-auto p-1`,children:T&&!F?(0,Z.jsx)(`div`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:`Loading file suggestions...`}):F?y.map((e,t)=>{let n=t===x,r=e.directory?`${e.directory}/`:``;return(0,Z.jsx)(`button`,{id:`${M}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,disabled:!I,className:W(`flex w-full rounded-lg px-3 py-1.5 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`hover:bg-accent/60`,!I&&`cursor-wait opacity-80 disabled:pointer-events-none`),onMouseDown:e=>{e.preventDefault()},onMouseEnter:()=>{I&&S(t)},onClick:()=>{B(e)},children:(0,Z.jsxs)(`span`,{className:`min-w-0 truncate text-sm`,children:[r?(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:r}):null,(0,Z.jsx)(`span`,{className:`font-medium`,children:e.name})]})},e.path)}):(0,Z.jsx)(`div`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:`No matching files found.`})})]}):null]})});hg.displayName=`ProjectFileMentionTextarea`;var gg=({className:e})=>(0,Z.jsx)(yc,{"aria-hidden":`true`,className:e}),_g=({projectId:e,suggestionTicketId:t=null,value:n,attachments:r=[],placeholder:i,disabled:a,isSubmitDisabled:o,isSending:s,isUploadingAttachments:c=!1,canAttachImages:l=!1,disabledReason:u,onValueChange:d,onKeyDown:f,onPaste:p,onUploadAttachments:m,onRemoveAttachment:h,onSubmit:g,textareaRef:_,composerInlineControls:v,composerTheme:y=`default`,composerSize:b=`default`,shellClassName:x})=>{let{t:S}=ht(`common`),C=(0,X.useId)(),w=(0,X.useRef)(null),[E,D]=(0,X.useState)(null),O=y===`plan`?`rounded-l-none border-l-3 border-l-sky-300/25 focus-within:border-l-sky-300/55`:y===`build`?`rounded-l-none border-l-3 border-l-emerald-400/30 focus-within:border-l-emerald-400/65`:null,k=b===`compact-on-laptop`?`min-h-[4.5rem] sm:min-h-16 2xl:min-h-20`:`min-h-[4.5rem] sm:min-h-20`,A=b===`compact-on-laptop`?`px-4 py-2 2xl:py-2.5`:`px-4 py-2.5`,j=b===`compact-on-laptop`?`absolute top-1/2 right-2.5 h-8 w-9 -translate-y-1/2 rounded-lg border-border/80 bg-secondary/80 px-0 text-foreground shadow-sm hover:bg-secondary 2xl:right-3 2xl:h-9 2xl:w-10`:`absolute top-1/2 right-3 h-9 w-10 -translate-y-1/2 rounded-lg border-border/80 bg-secondary/80 px-0 text-foreground shadow-sm hover:bg-secondary`,M=[`h-7 w-7 rounded-md border-border/70 bg-transparent px-0 text-muted-foreground shadow-none`,`hover:border-border hover:bg-background/60 hover:text-foreground`,`focus-visible:border-ring/70 focus-visible:ring-2 focus-visible:ring-ring/20`,`disabled:border-border/40 disabled:bg-transparent disabled:text-muted-foreground/50`].join(` `),N=!!v,P=l||c||r.length>0,F=P||N,I=(n.trim().length>0||r.length>0)&&!s&&!o&&!c;return(0,Z.jsxs)(`div`,{"data-testid":`conversation-composer-shell`,className:W(`relative overflow-visible rounded-[1.35rem] border border-border/80 bg-card/65 transition-[border-color,box-shadow,background-color] shadow-[0_10px_30px_rgba(0,0,0,0.16)]`,`focus-within:border-ring/60 focus-within:bg-card/85 focus-within:ring-2 focus-within:ring-ring/15`,O,x),children:[(0,Z.jsxs)(`div`,{className:W(`relative`,k,A),children:[(0,Z.jsx)(hg,{ref:_,projectId:e,suggestionTicketId:t,value:n,onValueChange:d,onKeyDown:f,onPaste:p,suggestionPlacement:`above`,wrapperClassName:`pr-12`,placeholder:i,disabled:a,"aria-label":S(`promptComposer.followUpPromptAriaLabel`),className:W(k,`border-0 bg-transparent px-0 py-0 text-base leading-6 shadow-none focus-visible:border-transparent focus-visible:ring-0 sm:text-[15px]`)}),(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`secondary`,"aria-label":S(s?`promptComposer.sendingPromptAriaLabel`:`promptComposer.sendPromptAriaLabel`),disabled:!I,title:u,className:W(j,N&&`top-[calc(50%+0.5rem)]`),onClick:g,children:s?(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(gg,{className:`h-4 w-4`})})]}),r.length>0?(0,Z.jsx)(`div`,{className:`px-3 pb-2`,children:(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:r.map(e=>{let t=T(e.content_url);return(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/80 bg-background/70`,children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":S(`attachmentPreviewDialog.previewImageAriaLabel`,{name:e.original_name}),className:`block w-full cursor-zoom-in overflow-hidden rounded-t-xl text-left outline-none transition-opacity hover:opacity-95 focus-visible:ring-2 focus-visible:ring-ring/50`,onClick:()=>{D(e)},children:(0,Z.jsx)(`img`,{src:t,alt:S(`promptComposer.attachmentPreviewAlt`,{name:e.original_name}),className:`h-28 w-full object-cover`,loading:`lazy`})}),(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground`,children:e.original_name}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:rg(e.size_bytes)})]}),(0,Z.jsx)(J,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":S(`promptComposer.removeAttachmentAriaLabel`,{name:e.original_name}),className:`h-8 w-8 shrink-0`,onClick:()=>h?.(e.id),children:(0,Z.jsx)(Fe,{className:`h-4 w-4`})})]})]},e.id)})})}):null,F?(0,Z.jsx)(`div`,{className:`px-3 pb-2.5`,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2.5`,children:[P?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`input`,{id:C,ref:w,"data-testid":`chat-attachment-input`,type:`file`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,className:`sr-only`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);t.length>0&&m?.(t),e.currentTarget.value=``}}),(0,Z.jsx)(Lu,{content:S(`promptComposer.attachImageAriaLabel`),children:(0,Z.jsx)(`span`,{className:`inline-flex`,children:(0,Z.jsx)(J,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":S(c?`promptComposer.uploadingImageAriaLabel`:`promptComposer.attachImageAriaLabel`),disabled:a||o||!l||c,className:M,onClick:()=>{w.current?.click()},children:c?(0,Z.jsx)(ye,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(tf,{className:`h-3.5 w-3.5`})})})})]}):null,v?(0,Z.jsx)(`div`,{className:`min-w-0`,children:v}):null]})}):null,(0,Z.jsx)(ig,{attachment:E,onClose:()=>{D(null)}})]})},vg=({className:e})=>(0,Z.jsx)(Fc,{"aria-hidden":`true`,className:e}),yg=({className:e})=>(0,Z.jsx)(Tc,{"aria-hidden":`true`,className:e}),bg=({className:e})=>(0,Z.jsx)(Cc,{"aria-hidden":`true`,className:e}),xg=new Map,Sg=({projectId:e,reviewCapabilityContextKey:t})=>t?`${e}:${t}`:null,Cg=e=>e.map(e=>({...e})),wg=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return r&&e.id===r.id&&e.comment===r.comment}),Tg=e=>e?Cg(xg.get(e)??[]):[],Eg=({contextKey:e,drafts:t})=>{if(e){if(t.length===0){xg.delete(e);return}xg.set(e,Cg(t))}},Dg=12,Og=20,kg=e=>{let t=Number.parseFloat(e);return Number.isNaN(t)?0:t},Ag=e=>{let t=window.getComputedStyle(e),n=(kg(t.lineHeight)||Og)*Dg+kg(t.paddingTop)+kg(t.paddingBottom)+kg(t.borderTopWidth)+kg(t.borderBottomWidth);e.style.height=`auto`;let r=Math.min(e.scrollHeight,n);e.style.height=`${r}px`,e.style.overflowY=e.scrollHeight>n?`auto`:`hidden`};function jg(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Mg(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?jg(Object(n),!0).forEach((function(t){Ng(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jg(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ng(e,t,n){return(t=function(e){var t=function(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}(e,`string`);return typeof t==`symbol`?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pg(e,t){if(e==null)return{};var n,r,i=function(e,t){if(e==null)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Fg(e,t){return Rg(e)||function(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}(e,t)||Bg(e,t)||Hg()}function Ig(e){return Rg(e)||zg(e)||Bg(e)||Hg()}function Lg(e){return function(e){if(Array.isArray(e))return Vg(e)}(e)||zg(e)||Bg(e)||function(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
31
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Rg(e){if(Array.isArray(e))return e}function zg(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Bg(e,t){if(e){if(typeof e==`string`)return Vg(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Vg(e,t):void 0}}function Vg(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Hg(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
32
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ug(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=Bg(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
33
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}var Wg=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function Gg(e,t){return e(t={exports:{}},t.exports),t.exports}var Kg=Gg((function(e){(function(){var t={}.hasOwnProperty;function n(){for(var e=[],r=0;r<arguments.length;r++){var i=arguments[r];if(i){var a=typeof i;if(a===`string`||a===`number`)e.push(i);else if(Array.isArray(i)){if(i.length){var o=n.apply(null,i);o&&e.push(o)}}else if(a===`object`){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes(`[native code]`)){e.push(i.toString());continue}for(var s in i)t.call(i,s)&&i[s]&&e.push(s)}}}return e.join(` `)}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})),qg={hunkClassName:``,lineClassName:``,gutterClassName:``,codeClassName:``,monotonous:!1,gutterType:`default`,viewType:`split`,widgets:{},hideGutter:!1,selectedChanges:[],generateAnchorID:function(){},generateLineClassName:function(){},renderGutter:function(e){var t=e.renderDefault;return(0,e.wrapInAnchor)(t())},codeEvents:{},gutterEvents:{}},Jg=(0,X.createContext)(qg),Yg=Jg.Provider,Xg=function(){return(0,X.useContext)(Jg)},Zg=Gg((function(e,t){(function(t){function n(e){var t=e.slice(11),n=null,r=null;switch(t.indexOf(`"`)){case-1:n=(o=t.split(` `))[0].slice(2),r=o[1].slice(2);break;case 0:var i=t.indexOf(`"`,2);n=t.slice(3,i);var a=t.indexOf(`"`,i+1);r=a<0?t.slice(i+4):t.slice(a+3,-1);break;default:var o;n=(o=t.split(` `))[0].slice(2),r=o[1].slice(3,-1)}return{oldPath:n,newPath:r}}e.exports={parse:function(e){for(var t,r,i,a,o,s=[],c=2,l=e.split(`
|
|
34
|
+
`),u=l.length,d=0;d<u;){var f=l[d];if(f.indexOf(`diff --git`)===0){t={hunks:[],oldEndingNewLine:!0,newEndingNewLine:!0,oldPath:(o=n(f)).oldPath,newPath:o.newPath},s.push(t);var p,m=null;simiLoop:for(;p=l[++d];){var h=p.indexOf(` `),g=h>-1?p.slice(0,h):g;switch(g){case`diff`:d--;break simiLoop;case`deleted`:case`new`:var _=p.slice(h+1);_.indexOf(`file mode`)===0&&(t[g===`new`?`newMode`:`oldMode`]=_.slice(10));break;case`similarity`:t.similarity=parseInt(p.split(` `)[2],10);break;case`index`:var v=p.slice(h+1).split(` `),y=v[0].split(`..`);t.oldRevision=y[0],t.newRevision=y[1],v[1]&&(t.oldMode=t.newMode=v[1]);break;case`copy`:case`rename`:var b=p.slice(h+1);b.indexOf(`from`)===0?t.oldPath=b.slice(5):t.newPath=b.slice(3),m=g;break;case`---`:var x=p.slice(h+1),S=l[++d].slice(4);x===`/dev/null`?(S=S.slice(2),m=`add`):S===`/dev/null`?(x=x.slice(2),m=`delete`):(m=`modify`,x=x.slice(2),S=S.slice(2)),x&&(t.oldPath=x),S&&(t.newPath=S),c=5;break simiLoop}}t.type=m||`modify`}else if(f.indexOf(`Binary`)===0)t.isBinary=!0,t.type=f.indexOf(`/dev/null and`)>=0?`add`:f.indexOf(`and /dev/null`)>=0?`delete`:`modify`,c=2,t=null;else if(c===5)if(f.indexOf(`@@`)===0){var C=/^@@\s+-([0-9]+)(,([0-9]+))?\s+\+([0-9]+)(,([0-9]+))?/.exec(f);r={content:f,oldStart:C[1]-0,newStart:C[4]-0,oldLines:C[3]-0||1,newLines:C[6]-0||1,changes:[]},t.hunks.push(r),i=r.oldStart,a=r.newStart}else{var w=f.slice(0,1),T={content:f.slice(1)};switch(w){case`+`:T.type=`insert`,T.isInsert=!0,T.lineNumber=a,a++;break;case`-`:T.type=`delete`,T.isDelete=!0,T.lineNumber=i,i++;break;case` `:T.type=`normal`,T.isNormal=!0,T.oldLineNumber=i,T.newLineNumber=a,i++,a++;break;case`\\`:var E=r.changes[r.changes.length-1];E.isDelete||(t.newEndingNewLine=!1),E.isInsert||(t.oldEndingNewLine=!1)}T.type&&r.changes.push(T)}d++}return s}}})()}));function Qg(e){return e.type===`insert`}function $g(e){return e.type===`delete`}function e_(e){return e.type===`normal`}function t_(e,t){var n=t.nearbySequences===`zip`?function(e){return Fg(e.reduce((function(e,t,n){var r=Fg(e,3),i=r[0],a=r[1],o=r[2];return a?Qg(t)&&o>=0?(i.splice(o+1,0,t),[i,t,o+2]):(i.push(t),[i,t,$g(t)&&$g(a)?o:n]):(i.push(t),[i,t,$g(t)?n:-1])}),[[],null,-1]),1)[0]}(e.changes):e.changes;return Mg(Mg({},e),{},{isPlain:!1,changes:n})}function n_(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=function(e){if(e.startsWith(`diff --git`))return e;var t=e.indexOf(`
|
|
35
|
+
`),n=e.indexOf(`
|
|
36
|
+
`,t+1),r=e.slice(0,t),i=e.slice(t+1,n),a=r.split(` `).slice(1,-3).join(` `),o=i.split(` `).slice(1,-3).join(` `);return[`diff --git a/${a} b/${o}`,`index 1111111..2222222 100644`,`--- a/${a}`,`+++ b/${o}`,e.slice(n+1)].join(`
|
|
37
|
+
`)}(e.trimStart());return Zg.parse(n).map((function(e){return function(e,t){var n=e.hunks.map((function(e){return t_(e,t)}));return Mg(Mg({},e),{},{hunks:n})}(e,t)}))}function r_(e){return e[0]}function i_(e){return e[e.length-1]}function a_(e){return[`${e}Start`,`${e}Lines`]}function o_(e){return e===`old`?function(e){return Qg(e)?-1:e_(e)?e.oldLineNumber:e.lineNumber}:function(e){return $g(e)?-1:e_(e)?e.newLineNumber:e.lineNumber}}function s_(e,t){return function(n,r){var i=n[e],a=i+n[t];return r>=i&&r<a}}function c_(e,t){return function(n,r,i){var a=n[e]+n[t],o=r[e];return i>=a&&i<o}}function l_(e){var t=o_(e),n=function(e){var t=Fg(a_(e),2),n=s_(t[0],t[1]);return function(e,t){return e.find((function(e){return n(e,t)}))}}(e);return function(e,r){var i=n(e,r);if(i)return i.changes.find((function(e){return t(e)===r}))}}function u_(e){var t=e===`old`?`new`:`old`,n=Fg(a_(e),2),r=n[0],i=n[1],a=Fg(a_(t),2),o=a[0],s=a[1],c=o_(e),l=o_(t),u=s_(r,i),d=c_(r,i);return function(e,t){var n=r_(e);if(t<n[r]){var a=n[r]-t;return n[o]-a}var f=i_(e);if(f[r]+f[i]<=t){var p=t-f[r]-f[i];return f[o]+f[s]+p}for(var m=0;m<e.length;m++){var h=e[m],g=e[m+1];if(u(h,t)){var _=h.changes.findIndex((function(e){return c(e)===t})),v=h.changes[_];if(e_(v))return l(v);var y=$g(v)?_+1:_-1,b=h.changes[y];if(!b)return-1;var x=Qg(v)?`delete`:`insert`;return b.type===x?l(b):-1}if(d(h,g,t)){var S=t-h[r]-h[i];return h[o]+h[s]+S}}throw Error(`Unexpected line position ${t}`)}}var d_=function(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1},f_=function(){this.__data__=[],this.size=0},p_=function(e,t){return e===t||e!=e&&t!=t},m_=function(e,t){for(var n=e.length;n--;)if(p_(e[n][0],t))return n;return-1},h_=Array.prototype.splice,g_=function(e){var t=this.__data__,n=m_(t,e);return!(n<0)&&(n==t.length-1?t.pop():h_.call(t,n,1),--this.size,!0)},__=function(e){var t=this.__data__,n=m_(t,e);return n<0?void 0:t[n][1]},v_=function(e){return m_(this.__data__,e)>-1},y_=function(e,t){var n=this.__data__,r=m_(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function b_(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}b_.prototype.clear=f_,b_.prototype.delete=g_,b_.prototype.get=__,b_.prototype.has=v_,b_.prototype.set=y_;var x_=b_,S_=function(){this.__data__=new x_,this.size=0},C_=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},w_=function(e){return this.__data__.get(e)},T_=function(e){return this.__data__.has(e)},E_=typeof Wg==`object`&&Wg&&Wg.Object===Object&&Wg,D_=typeof self==`object`&&self&&self.Object===Object&&self,O_=E_||D_||Function(`return this`)(),k_=O_.Symbol,A_=Object.prototype,j_=A_.hasOwnProperty,M_=A_.toString,N_=k_?k_.toStringTag:void 0,P_=function(e){var t=j_.call(e,N_),n=e[N_];try{e[N_]=void 0;var r=!0}catch{}var i=M_.call(e);return r&&(t?e[N_]=n:delete e[N_]),i},F_=Object.prototype.toString,I_=function(e){return F_.call(e)},L_=k_?k_.toStringTag:void 0,R_=function(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:L_&&L_ in Object(e)?P_(e):I_(e)},z_=function(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)},B_=function(e){if(!z_(e))return!1;var t=R_(e);return t==`[object Function]`||t==`[object GeneratorFunction]`||t==`[object AsyncFunction]`||t==`[object Proxy]`},V_=O_[`__core-js_shared__`],H_=function(){var e=/[^.]+$/.exec(V_&&V_.keys&&V_.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),U_=function(e){return!!H_&&H_ in e},W_=Function.prototype.toString,G_=function(e){if(e!=null){try{return W_.call(e)}catch{}try{return e+``}catch{}}return``},K_=/^\[object .+?Constructor\]$/,q_=Function.prototype,J_=Object.prototype,Y_=q_.toString,X_=J_.hasOwnProperty,Z_=RegExp(`^`+Y_.call(X_).replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),Q_=function(e){return!(!z_(e)||U_(e))&&(B_(e)?Z_:K_).test(G_(e))},$_=function(e,t){return e?.[t]},ev=function(e,t){var n=$_(e,t);return Q_(n)?n:void 0},tv=ev(O_,`Map`),nv=ev(Object,`create`),rv=function(){this.__data__=nv?nv(null):{},this.size=0},iv=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t},av=Object.prototype.hasOwnProperty,ov=function(e){var t=this.__data__;if(nv){var n=t[e];return n===`__lodash_hash_undefined__`?void 0:n}return av.call(t,e)?t[e]:void 0},sv=Object.prototype.hasOwnProperty,cv=function(e){var t=this.__data__;return nv?t[e]!==void 0:sv.call(t,e)},lv=function(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=nv&&t===void 0?`__lodash_hash_undefined__`:t,this};function uv(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}uv.prototype.clear=rv,uv.prototype.delete=iv,uv.prototype.get=ov,uv.prototype.has=cv,uv.prototype.set=lv;var dv=uv,fv=function(){this.size=0,this.__data__={hash:new dv,map:new(tv||x_),string:new dv}},pv=function(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null},mv=function(e,t){var n=e.__data__;return pv(t)?n[typeof t==`string`?`string`:`hash`]:n.map},hv=function(e){var t=mv(this,e).delete(e);return this.size-=+!!t,t},gv=function(e){return mv(this,e).get(e)},_v=function(e){return mv(this,e).has(e)},vv=function(e,t){var n=mv(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function yv(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}yv.prototype.clear=fv,yv.prototype.delete=hv,yv.prototype.get=gv,yv.prototype.has=_v,yv.prototype.set=vv;var bv=yv,xv=function(e,t){var n=this.__data__;if(n instanceof x_){var r=n.__data__;if(!tv||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new bv(r)}return n.set(e,t),this.size=n.size,this};function Sv(e){var t=this.__data__=new x_(e);this.size=t.size}Sv.prototype.clear=S_,Sv.prototype.delete=C_,Sv.prototype.get=w_,Sv.prototype.has=T_,Sv.prototype.set=xv;var Cv=Sv,wv=function(e){return this.__data__.set(e,`__lodash_hash_undefined__`),this},Tv=function(e){return this.__data__.has(e)};function Ev(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new bv;++t<n;)this.add(e[t])}Ev.prototype.add=Ev.prototype.push=wv,Ev.prototype.has=Tv;var Dv=Ev,Ov=function(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1},kv=function(e,t){return e.has(t)},Av=function(e,t,n,r,i,a){var o=1&n,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=2&n?new Dv:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!Ov(t,(function(e,t){if(!kv(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)}))){f=!1;break}}else if(m!==h&&!i(m,h,n,r,a)){f=!1;break}}return a.delete(e),a.delete(t),f},jv=O_.Uint8Array,Mv=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n},Nv=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n},Pv=k_?k_.prototype:void 0,Fv=Pv?Pv.valueOf:void 0,Iv=function(e,t,n,r,i,a,o){switch(n){case`[object DataView]`:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case`[object ArrayBuffer]`:return!(e.byteLength!=t.byteLength||!a(new jv(e),new jv(t)));case`[object Boolean]`:case`[object Date]`:case`[object Number]`:return p_(+e,+t);case`[object Error]`:return e.name==t.name&&e.message==t.message;case`[object RegExp]`:case`[object String]`:return e==t+``;case`[object Map]`:var s=Mv;case`[object Set]`:var c=1&r;if(s||=Nv,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=2,o.set(e,t);var u=Av(s(e),s(t),r,i,a,o);return o.delete(e),u;case`[object Symbol]`:if(Fv)return Fv.call(e)==Fv.call(t)}return!1},Lv=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e},Rv=Array.isArray,zv=function(e,t,n){var r=t(e);return Rv(e)?r:Lv(r,n(e))},Bv=function(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a},Vv=function(){return[]},Hv=Object.prototype.propertyIsEnumerable,Uv=Object.getOwnPropertySymbols,Wv=Uv?function(e){return e==null?[]:(e=Object(e),Bv(Uv(e),(function(t){return Hv.call(e,t)})))}:Vv,Gv=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r},Kv=function(e){return typeof e==`object`&&!!e},qv=function(e){return Kv(e)&&R_(e)==`[object Arguments]`},Jv=Object.prototype,Yv=Jv.hasOwnProperty,Xv=Jv.propertyIsEnumerable,Zv=qv(function(){return arguments}())?qv:function(e){return Kv(e)&&Yv.call(e,`callee`)&&!Xv.call(e,`callee`)},Qv=function(){return!1},$v=Gg((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n?O_.Buffer:void 0;e.exports=(i?i.isBuffer:void 0)||Qv})),ey=/^(?:0|[1-9]\d*)$/,ty=function(e,t){var n=typeof e;return!!(t??=9007199254740991)&&(n==`number`||n!=`symbol`&&ey.test(e))&&e>-1&&e%1==0&&e<t},ny=function(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=9007199254740991},ry={};ry[`[object Float32Array]`]=ry[`[object Float64Array]`]=ry[`[object Int8Array]`]=ry[`[object Int16Array]`]=ry[`[object Int32Array]`]=ry[`[object Uint8Array]`]=ry[`[object Uint8ClampedArray]`]=ry[`[object Uint16Array]`]=ry[`[object Uint32Array]`]=!0,ry[`[object Arguments]`]=ry[`[object Array]`]=ry[`[object ArrayBuffer]`]=ry[`[object Boolean]`]=ry[`[object DataView]`]=ry[`[object Date]`]=ry[`[object Error]`]=ry[`[object Function]`]=ry[`[object Map]`]=ry[`[object Number]`]=ry[`[object Object]`]=ry[`[object RegExp]`]=ry[`[object Set]`]=ry[`[object String]`]=ry[`[object WeakMap]`]=!1;var iy=function(e){return Kv(e)&&ny(e.length)&&!!ry[R_(e)]},ay=function(e){return function(t){return e(t)}},oy=Gg((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n&&E_.process;e.exports=function(){try{return r&&r.require&&r.require(`util`).types||i&&i.binding&&i.binding(`util`)}catch{}}()})),sy=oy&&oy.isTypedArray,cy=sy?ay(sy):iy,ly=Object.prototype.hasOwnProperty,uy=function(e,t){var n=Rv(e),r=!n&&Zv(e),i=!n&&!r&&$v(e),a=!n&&!r&&!i&&cy(e),o=n||r||i||a,s=o?Gv(e.length,String):[],c=s.length;for(var l in e)!t&&!ly.call(e,l)||o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||ty(l,c))||s.push(l);return s},dy=Object.prototype,fy=function(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||dy)},py=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),my=Object.prototype.hasOwnProperty,hy=function(e){if(!fy(e))return py(e);var t=[];for(var n in Object(e))my.call(e,n)&&n!=`constructor`&&t.push(n);return t},gy=function(e){return e!=null&&ny(e.length)&&!B_(e)},_y=function(e){return gy(e)?uy(e):hy(e)},vy=function(e){return zv(e,_y,Wv)},yy=Object.prototype.hasOwnProperty,by=function(e,t,n,r,i,a){var o=1&n,s=vy(e),c=s.length;if(c!=vy(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:yy.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){var h=e[u=s[l]],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v==y||!(`constructor`in e)||!(`constructor`in t)||typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y||(p=!1)}return a.delete(e),a.delete(t),p},xy=ev(O_,`DataView`),Sy=ev(O_,`Promise`),Cy=ev(O_,`Set`),wy=ev(O_,`WeakMap`),Ty=G_(xy),Ey=G_(tv),Dy=G_(Sy),Oy=G_(Cy),ky=G_(wy),Ay=R_;(xy&&Ay(new xy(new ArrayBuffer(1)))!=`[object DataView]`||tv&&Ay(new tv)!=`[object Map]`||Sy&&Ay(Sy.resolve())!=`[object Promise]`||Cy&&Ay(new Cy)!=`[object Set]`||wy&&Ay(new wy)!=`[object WeakMap]`)&&(Ay=function(e){var t=R_(e),n=t==`[object Object]`?e.constructor:void 0,r=n?G_(n):``;if(r)switch(r){case Ty:return`[object DataView]`;case Ey:return`[object Map]`;case Dy:return`[object Promise]`;case Oy:return`[object Set]`;case ky:return`[object WeakMap]`}return t});var jy=Ay,My=`[object Object]`,Ny=Object.prototype.hasOwnProperty,Py=function(e,t,n,r,i,a){var o=Rv(e),s=Rv(t),c=o?`[object Array]`:jy(e),l=s?`[object Array]`:jy(t),u=(c=c==`[object Arguments]`?My:c)==My,d=(l=l==`[object Arguments]`?My:l)==My,f=c==l;if(f&&$v(e)){if(!$v(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new Cv,o||cy(e)?Av(e,t,n,r,i,a):Iv(e,t,c,n,r,i,a);if(!(1&n)){var p=u&&Ny.call(e,`__wrapped__`),m=d&&Ny.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new Cv,i(h,g,n,r,a)}}return!!f&&(a||=new Cv,by(e,t,n,r,i,a))},Fy=function e(t,n,r,i,a){return t===n||(t==null||n==null||!Kv(t)&&!Kv(n)?t!=t&&n!=n:Py(t,n,r,i,e,a))},Iy=function(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){var c=(s=n[i])[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new Cv;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?Fy(u,l,3,r,d):f))return!1}}return!0},Ly=function(e){return e==e&&!z_(e)},Ry=function(e){for(var t=_y(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,Ly(i)]}return t},zy=function(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}},By=function(e){var t=Ry(e);return t.length==1&&t[0][2]?zy(t[0][0],t[0][1]):function(n){return n===e||Iy(n,e,t)}},Vy=function(e){return typeof e==`symbol`||Kv(e)&&R_(e)==`[object Symbol]`},Hy=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Uy=/^\w*$/,Wy=function(e,t){if(Rv(e))return!1;var n=typeof e;return!(n!=`number`&&n!=`symbol`&&n!=`boolean`&&e!=null&&!Vy(e))||Uy.test(e)||!Hy.test(e)||t!=null&&e in Object(t)};function Gy(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(`Expected a function`);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(Gy.Cache||bv),n}Gy.Cache=bv;var Ky=Gy,qy=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Jy=/\\(\\)?/g,Yy=function(e){var t=Ky(e,(function(e){return n.size===500&&n.clear(),e})),n=t.cache;return t}((function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(qy,(function(e,n,r,i){t.push(r?i.replace(Jy,`$1`):n||e)})),t})),Xy=function(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i},Zy=k_?k_.prototype:void 0,Qy=Zy?Zy.toString:void 0,$y=function e(t){if(typeof t==`string`)return t;if(Rv(t))return Xy(t,e)+``;if(Vy(t))return Qy?Qy.call(t):``;var n=t+``;return n==`0`&&1/t==-1/0?`-0`:n},eb=function(e){return e==null?``:$y(e)},tb=function(e,t){return Rv(e)?e:Wy(e,t)?[e]:Yy(eb(e))},nb=function(e){if(typeof e==`string`||Vy(e))return e;var t=e+``;return t==`0`&&1/e==-1/0?`-0`:t},rb=function(e,t){for(var n=0,r=(t=tb(t,e)).length;e!=null&&n<r;)e=e[nb(t[n++])];return n&&n==r?e:void 0},ib=function(e,t,n){var r=e==null?void 0:rb(e,t);return r===void 0?n:r},ab=function(e,t){return e!=null&&t in Object(e)},ob=function(e,t,n){for(var r=-1,i=(t=tb(t,e)).length,a=!1;++r<i;){var o=nb(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:!!(i=e==null?0:e.length)&&ny(i)&&ty(o,i)&&(Rv(e)||Zv(e))},sb=function(e,t){return e!=null&&ob(e,t,ab)},cb=function(e,t){return Wy(e)&&Ly(t)?zy(nb(e),t):function(n){var r=ib(n,e);return r===void 0&&r===t?sb(n,e):Fy(t,r,3)}},lb=function(e){return e},ub=function(e){return function(t){return t?.[e]}},db=function(e){return function(t){return rb(t,e)}},fb=function(e){return Wy(e)?ub(nb(e)):db(e)},pb=function(e){return typeof e==`function`?e:e==null?lb:typeof e==`object`?Rv(e)?cb(e[0],e[1]):By(e):fb(e)},mb=/\s/,hb=function(e){for(var t=e.length;t--&&mb.test(e.charAt(t)););return t},gb=/^\s+/,_b=function(e){return e&&e.slice(0,hb(e)+1).replace(gb,``)},vb=/^[-+]0x[0-9a-f]+$/i,yb=/^0b[01]+$/i,bb=/^0o[0-7]+$/i,xb=parseInt,Sb=function(e){if(typeof e==`number`)return e;if(Vy(e))return NaN;if(z_(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=z_(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=_b(e);var n=yb.test(e);return n||bb.test(e)?xb(e.slice(2),n?2:8):vb.test(e)?NaN:+e},Cb=function(e){return e?(e=Sb(e))===1/0||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:e===0?e:0},wb=function(e){var t=Cb(e),n=t%1;return t==t?n?t-n:t:0};function Tb(e){if(!e)throw Error(`change is not provided`);return e_(e)?`N${e.oldLineNumber}`:`${Qg(e)?`I`:`D`}${e.lineNumber}`}u_(`old`);var Eb=o_(`old`),Db=o_(`new`);l_(`old`),l_(`new`),u_(`new`),u_(`old`);var Ob=function(){try{var e=ev(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),kb=function(e,t,n){t==`__proto__`&&Ob?Ob(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},Ab=function(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(!1===n(a[c],c,a))break}return t}}(),jb=function(e,t){return e&&Ab(e,t,_y)},Mb=function(e,t){var n={};return t=pb(t),jb(e,(function(e,r,i){kb(n,r,t(e,r,i))})),n},Nb=[`changeKey`,`text`,`tokens`,`renderToken`],Pb=function e(t,n){var r=t.type,i=t.value,a=t.markType,o=t.properties,s=t.className,c=t.children,l=function(t){return(0,Z.jsx)(`span`,{className:t,children:i||c&&c.map(e)},n)};switch(r){case`text`:return i;case`mark`:return l(`diff-code-mark diff-code-mark-${a}`);case`edit`:return l(`diff-code-edit`);default:var u=o&&o.className;return l(Kg(s||u))}};function Fb(e){if(!Array.isArray(e))return!0;if(e.length>1)return!1;if(e.length===1){var t=Fg(e,1)[0];return t.type===`text`&&!t.value}return!0}function Ib(e){var t=e.changeKey,n=e.text,r=e.tokens,i=e.renderToken,a=Pg(e,Nb),o=i?function(e,t){return i(e,Pb,t)}:Pb;return(0,Z.jsx)(`td`,Mg(Mg({},a),{},{"data-change-key":t,children:r?Fb(r)?` `:r.map(o):n||` `}))}var Lb=(0,X.memo)(Ib);function Rb(e,t){return function(){var n=t===`old`?Eb(e):Db(e);return n===-1?void 0:n}}function zb(e,t){return function(n){return e&&n?(0,Z.jsx)(`a`,{href:t?`#`+t:void 0,children:n}):n}}function Bb(e,t){return t?function(n){e(),t(n)}:e}function Vb(e,t,n,r){return(0,X.useMemo)((function(){var i=Mb(e,(function(e){return function(n){return e&&e(t,n)}}));return i.onMouseEnter=Bb(n,i.onMouseEnter),i.onMouseLeave=Bb(r,i.onMouseLeave),i}),[e,n,r,t])}function Hb(e,t,n,r,i,a,o,s,c){var l={change:t,side:r,inHoverState:s,renderDefault:Rb(t,r),wrapInAnchor:zb(i,a)};return(0,Z.jsx)(`td`,Mg(Mg({className:e},o),{},{"data-change-key":n,children:c(l)}))}function Ub(e){var t,n,r,i=e.change,a=e.selected,o=e.tokens,s=e.className,c=e.generateLineClassName,l=e.gutterClassName,u=e.codeClassName,d=e.gutterEvents,f=e.codeEvents,p=e.hideGutter,m=e.gutterAnchor,h=e.generateAnchorID,g=e.renderToken,_=e.renderGutter,v=i.type,y=i.content,b=Tb(i),x=Fg((t=Fg((0,X.useState)(!1),2),n=t[0],r=t[1],[n,(0,X.useCallback)((function(){return r(!0)}),[]),(0,X.useCallback)((function(){return r(!1)}),[])]),3),S=x[0],C=x[1],w=x[2],T=(0,X.useMemo)((function(){return{change:i}}),[i]),E=Vb(d,T,C,w),D=Vb(f,T,C,w),O=h(i),k=c({changes:[i],defaultGenerate:function(){return s}}),A=Kg(`diff-gutter`,`diff-gutter-${v}`,l,{"diff-gutter-selected":a}),j=Kg(`diff-code`,`diff-code-${v}`,u,{"diff-code-selected":a});return(0,Z.jsxs)(`tr`,{id:O,className:Kg(`diff-line`,k),children:[!p&&Hb(A,i,b,`old`,m,O,E,S,_),!p&&Hb(A,i,b,`new`,m,O,E,S,_),(0,Z.jsx)(Lb,Mg({className:j,changeKey:b,text:y,tokens:o,renderToken:g},D))]})}var Wb=(0,X.memo)(Ub);function Gb(e){var t=e.hideGutter,n=e.element;return(0,Z.jsx)(`tr`,{className:`diff-widget`,children:(0,Z.jsx)(`td`,{colSpan:t?1:3,className:`diff-widget-content`,children:n})})}var Kb=[`hideGutter`,`selectedChanges`,`tokens`,`lineClassName`],qb=[`hunk`,`widgets`,`className`];function Jb(e){var t=e.hunk,n=e.widgets,r=e.className,i=Pg(e,qb),a=function(e,t){return e.reduce((function(e,n){var r=Tb(n);e.push([`change`,r,n]);var i=t[r];return i&&e.push([`widget`,r,i]),e}),[])}(t.changes,n);return(0,Z.jsx)(`tbody`,{className:Kg(`diff-hunk`,r),children:a.map((function(e){return function(e,t){var n=Fg(e,3),r=n[0],i=n[1],a=n[2],o=t.hideGutter,s=t.selectedChanges,c=t.tokens,l=t.lineClassName,u=Pg(t,Kb);if(r===`change`){var d=$g(a)?`old`:`new`,f=$g(a)?Eb(a):Db(a),p=c?c[d][f-1]:null;return(0,Z.jsx)(Wb,Mg({className:l,change:a,hideGutter:o,selected:s.includes(i),tokens:p},u),`change${i}`)}return r===`widget`?(0,Z.jsx)(Gb,{hideGutter:o,element:a},`widget${i}`):null}(e,i)}))})}var Yb=0;function Xb(e,t,n,r){var i=(0,X.useCallback)((function(){return t(e)}),[e,t]),a=(0,X.useCallback)((function(){return t(``)}),[t]);return(0,X.useMemo)((function(){var t=Mb(r,(function(t){return function(r){return t&&t({side:e,change:n},r)}}));return t.onMouseEnter=Bb(i,t.onMouseEnter),t.onMouseLeave=Bb(a,t.onMouseLeave),t}),[n,r,i,e,a])}function Zb(e){var t=e.change,n=e.side,r=e.selected,i=e.tokens,a=e.gutterClassName,o=e.codeClassName,s=e.gutterEvents,c=e.codeEvents,l=e.anchorID,u=e.gutterAnchor,d=e.gutterAnchorTarget,f=e.hideGutter,p=e.hover,m=e.renderToken,h=e.renderGutter;if(!t){var g=Kg(`diff-gutter`,`diff-gutter-omit`,a),_=Kg(`diff-code`,`diff-code-omit`,o);return[!f&&(0,Z.jsx)(`td`,{className:g},`gutter`),(0,Z.jsx)(`td`,{className:_},`code`)]}var v=t.type,y=t.content,b=Tb(t),x=n===Yb?`old`:`new`,S=Mg({id:l||void 0,className:Kg(`diff-gutter`,`diff-gutter-${v}`,Ng({"diff-gutter-selected":r},`diff-line-hover-`+x,p),a),children:h({change:t,side:x,inHoverState:p,renderDefault:Rb(t,x),wrapInAnchor:zb(u,d)})},s),C=Kg(`diff-code`,`diff-code-${v}`,Ng({"diff-code-selected":r},`diff-line-hover-`+x,p),o);return[!f&&(0,Z.jsx)(`td`,Mg(Mg({},S),{},{"data-change-key":b}),`gutter`),(0,Z.jsx)(Lb,Mg({className:C,changeKey:b,text:y,tokens:i,renderToken:m},c),`code`)]}function Qb(e){var t=e.className,n=e.oldChange,r=e.newChange,i=e.oldSelected,a=e.newSelected,o=e.oldTokens,s=e.newTokens,c=e.monotonous,l=e.gutterClassName,u=e.codeClassName,d=e.gutterEvents,f=e.codeEvents,p=e.hideGutter,m=e.generateAnchorID,h=e.generateLineClassName,g=e.gutterAnchor,_=e.renderToken,v=e.renderGutter,y=Fg((0,X.useState)(``),2),b=y[0],x=y[1],S=Xb(`old`,x,n,d),C=Xb(`new`,x,r,d),w=Xb(`old`,x,n,f),T=Xb(`new`,x,r,f),E=n&&m(n),D=r&&m(r),O=h({changes:[n,r],defaultGenerate:function(){return t}}),k={monotonous:c,hideGutter:p,gutterClassName:l,codeClassName:u,gutterEvents:d,codeEvents:f,renderToken:_,renderGutter:v},A=Mg(Mg({},k),{},{change:n,side:Yb,selected:i,tokens:o,gutterEvents:S,codeEvents:w,anchorID:E,gutterAnchor:g,gutterAnchorTarget:E,hover:b===`old`}),j=Mg(Mg({},k),{},{change:r,side:1,selected:a,tokens:s,gutterEvents:C,codeEvents:T,anchorID:n===r?null:D,gutterAnchor:g,gutterAnchorTarget:n===r?E:D,hover:b===`new`});return c?(0,Z.jsx)(`tr`,{className:Kg(`diff-line`,O),children:Zb(n?A:j)}):(0,Z.jsxs)(`tr`,{className:Kg(`diff-line`,function(e,t){return e&&!t?`diff-line-old-only`:!e&&t?`diff-line-new-only`:e===t?`diff-line-normal`:`diff-line-compare`}(n,r),O),children:[Zb(A),Zb(j)]})}var $b=(0,X.memo)(Qb);function ex(e){var t=e.hideGutter,n=e.oldElement,r=e.newElement;return e.monotonous?(0,Z.jsx)(`tr`,{className:`diff-widget`,children:(0,Z.jsx)(`td`,{colSpan:t?1:2,className:`diff-widget-content`,children:n||r})}):n===r?(0,Z.jsx)(`tr`,{className:`diff-widget`,children:(0,Z.jsx)(`td`,{colSpan:t?2:4,className:`diff-widget-content`,children:n})}):(0,Z.jsxs)(`tr`,{className:`diff-widget`,children:[(0,Z.jsx)(`td`,{colSpan:t?1:2,className:`diff-widget-content`,children:n}),(0,Z.jsx)(`td`,{colSpan:t?1:2,className:`diff-widget-content`,children:r})]})}var tx=[`selectedChanges`,`monotonous`,`hideGutter`,`tokens`,`lineClassName`],nx=[`hunk`,`widgets`,`className`];function rx(e,t){return(e?Tb(e):`00`)+(t?Tb(t):`00`)}function ix(e){var t=e.hunk,n=e.widgets,r=e.className,i=Pg(e,nx),a=function(e,t){for(var n=function(e){return e&&t[Tb(e)]||null},r=[],i=0;i<e.length;i++){var a=e[i];if(e_(a))r.push([`change`,rx(a,a),a,a]);else if($g(a)){var o=e[i+1];o&&Qg(o)?(i+=1,r.push([`change`,rx(a,o),a,o])):r.push([`change`,rx(a,null),a,null])}else r.push([`change`,rx(null,a),null,a]);var s=r[r.length-1],c=n(s[2]),l=n(s[3]);if(c||l){var u=s[1];r.push([`widget`,u,c,l])}}return r}(t.changes,n);return(0,Z.jsx)(`tbody`,{className:Kg(`diff-hunk`,r),children:a.map((function(e){return function(e,t){var n=Fg(e,4),r=n[0],i=n[1],a=n[2],o=n[3],s=t.selectedChanges,c=t.monotonous,l=t.hideGutter,u=t.tokens,d=t.lineClassName,f=Pg(t,tx);return r===`change`?(0,Z.jsx)($b,Mg({className:d,oldChange:a,newChange:o,monotonous:c,hideGutter:l,oldSelected:!!a&&s.includes(Tb(a)),newSelected:!!o&&s.includes(Tb(o)),oldTokens:a&&u?u.old[Eb(a)-1]:null,newTokens:o&&u?u.new[Db(o)-1]:null},f),`change${i}`):r===`widget`?(0,Z.jsx)(ex,{monotonous:c,hideGutter:l,oldElement:a,newElement:o},`widget${i}`):null}(e,i)}))})}var ax=[`gutterType`,`hunkClassName`];function ox(e){var t=e.hunk,n=Xg(),r=n.gutterType,i=n.hunkClassName,a=Pg(n,ax),o=r===`none`,s=r===`anchor`;return(0,Z.jsx)(a.viewType===`unified`?Jb:ix,Mg(Mg({},a),{},{hunk:t,hideGutter:o,gutterAnchor:s,className:i}))}function sx(){}function cx(e,t){var n=t?`auto`:`none`;e instanceof HTMLElement&&e.style.userSelect!==n&&(e.style.userSelect=n)}function lx(e){return e.map((function(e){return(0,Z.jsx)(ox,{hunk:e},function(e){return`-${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines}`}(e))}))}function ux(e){var t=e.diffType,n=e.hunks,r=e.optimizeSelection,i=e.className,a=e.hunkClassName,o=a===void 0?qg.hunkClassName:a,s=e.lineClassName,c=s===void 0?qg.lineClassName:s,l=e.generateLineClassName,u=l===void 0?qg.generateLineClassName:l,d=e.gutterClassName,f=d===void 0?qg.gutterClassName:d,p=e.codeClassName,m=p===void 0?qg.codeClassName:p,h=e.gutterType,g=h===void 0?qg.gutterType:h,_=e.viewType,v=_===void 0?qg.viewType:_,y=e.gutterEvents,b=y===void 0?qg.gutterEvents:y,x=e.codeEvents,S=x===void 0?qg.codeEvents:x,C=e.generateAnchorID,w=C===void 0?qg.generateAnchorID:C,T=e.selectedChanges,E=T===void 0?qg.selectedChanges:T,D=e.widgets,O=D===void 0?qg.widgets:D,k=e.renderGutter,A=k===void 0?qg.renderGutter:k,j=e.tokens,M=e.renderToken,N=e.children,P=N===void 0?lx:N,F=(0,X.useRef)(null),I=(0,X.useCallback)((function(e){var t=e.target;if(e.button===0){var n=function(e,t){for(var n=e;n&&n!==document.documentElement&&!n.classList.contains(t);)n=n.parentElement;return n===document.documentElement?null:n}(t,`diff-code`);if(n&&n.parentElement){var r=window.getSelection();r&&r.removeAllRanges();var i=Lg(n.parentElement.children).indexOf(n);if(i===1||i===3){var a,o=Ug(F.current?F.current.querySelectorAll(`.diff-line`):[]);try{for(o.s();!(a=o.n()).done;){var s=a.value.children;cx(s[1],i===1),cx(s[3],i===3)}}catch(e){o.e(e)}finally{o.f()}}}}}),[]),L=g===`none`,R=t===`add`||t===`delete`,z=v===`split`&&!R&&r?I:sx,B=(0,X.useMemo)((function(){return(0,Z.jsxs)(`colgroup`,v===`unified`?{children:[!L&&(0,Z.jsx)(`col`,{className:`diff-gutter-col`}),!L&&(0,Z.jsx)(`col`,{className:`diff-gutter-col`}),(0,Z.jsx)(`col`,{})]}:R?{children:[!L&&(0,Z.jsx)(`col`,{className:`diff-gutter-col`}),(0,Z.jsx)(`col`,{})]}:{children:[!L&&(0,Z.jsx)(`col`,{className:`diff-gutter-col`}),(0,Z.jsx)(`col`,{}),!L&&(0,Z.jsx)(`col`,{className:`diff-gutter-col`}),(0,Z.jsx)(`col`,{})]})}),[v,R,L]);return(0,Z.jsx)(Yg,{value:(0,X.useMemo)((function(){return{hunkClassName:o,lineClassName:c,generateLineClassName:u,gutterClassName:f,codeClassName:m,monotonous:R,hideGutter:L,viewType:v,gutterType:g,codeEvents:S,gutterEvents:b,generateAnchorID:w,selectedChanges:E,widgets:O,renderGutter:A,tokens:j,renderToken:M}}),[m,S,w,f,b,g,L,o,c,u,R,A,M,E,j,v,O]),children:(0,Z.jsxs)(`table`,{ref:F,className:Kg(`diff`,`diff-${v}`,i),onMouseDown:z,children:[B,P(n)]})})}var dx=(0,X.memo)(ux),fx=function(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r},px=function(e,t){return function(n,r){if(n==null)return n;if(!gy(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++a<i)&&!1!==r(o[a],a,o););return n}}(jb),mx=function(e,t,n,r){return px(e,(function(e,i,a){t(r,e,n(e),a)})),r},hx=function(e,t){return function(n,r){var i=Rv(n)?fx:mx,a=t?t():{};return i(n,e,pb(r),a)}},gx=hx((function(e,t,n){kb(e,n,t)})),_x=k_?k_.isConcatSpreadable:void 0,vx=function(e){return Rv(e)||Zv(e)||!!(_x&&e&&e[_x])},yx=function e(t,n,r,i,a){var o=-1,s=t.length;for(r||=vx,a||=[];++o<s;){var c=t[o];n>0&&r(c)?n>1?e(c,n-1,r,i,a):Lv(a,c):i||(a[a.length]=c)}return a},bx=function(e,t){var n=-1,r=gy(e)?Array(e.length):[];return px(e,(function(e,i,a){r[++n]=t(e,i,a)})),r},xx=function(e,t){return(Rv(e)?Xy:bx)(e,pb(t))},Sx=function(e,t){return yx(xx(e,t),1)};function Cx(e,t){var n=t.newStart;return Fg(t.changes.reduce((function(e,t){var n=Fg(e,2),r=n[0],i=n[1];return $g(t)?(r.splice(i,1),[r,i]):(Qg(t)&&r.splice(i,0,t.content),[r,i+1])}),[e,n-1]),1)[0]}function wx(e,t,n){if(!e.length)return[];var r=t===`old`?Eb:Db,i=gx(e,r),a=r(e[e.length-1]);return Array.from({length:a}).map((function(e,t){return n(i[t+1])}))}function Tx(e){var t=Fg(function(e){return Sx(e,(function(e){return e.changes})).reduce((function(e,t){var n=Fg(e,2),r=n[0],i=n[1];return e_(t)?(r.push(t),i.push(t)):$g(t)?r.push(t):i.push(t),[r,i]}),[[],[]])}(e),2),n=t[0],r=t[1],i=function(e){return e?e.content:``};return[wx(n,`old`,i).join(`
|
|
38
|
+
`),wx(r,`new`,i).join(`
|
|
39
|
+
`)]}function Ex(e){return{type:`root`,children:e}}function Dx(e,t){if(t.oldSource){var n=function(e,t){return t.reduce(Cx,e.split(`
|
|
40
|
+
`)).join(`
|
|
41
|
+
`)}(t.oldSource,e),r=t.highlight?function(e){return t.refractor.highlight(e,t.language)}:function(e){return[{type:`text`,value:e}]};return[Ex(r(t.oldSource)),Ex(r(n))]}var i=Fg(Tx(e),2),a=i[0],o=i[1],s=t.highlight?function(e){return Ex(t.refractor.highlight(e,t.language))}:function(e){return Ex([{type:`text`,value:e}])};return[s(a),s(o)]}function Ox(e){return e.map((function(e){return Mg({},e)}))}function kx(e,t){return[].concat(Lg(Ox(e.slice(0,-1))),[t])}function Ax(e){return e.type===`text`}function jx(e){var t=e[e.length-1];if(Ax(t))return t;throw Error(`Invalid token path with leaf of type ${t.type}`)}function Mx(e,t,n,r){var i=e.slice(0,-1),a=jx(e),o=[];if(n<=0||t>=a?.value.length)return[e];var s=function(e,t){var n=a.value.slice(e,t);return[].concat(Lg(i),[Mg(Mg({},a),{},{value:n})])};if(t>0){var c=s(0,t);o.push(Ox(c))}var l=s(Math.max(t,0),n);if(o.push(r?function(e,t){return[t].concat(Lg(Ox(e)))}(l,r):Ox(l)),n<a.value.length){var u=s(n);o.push(Ox(u))}return o}var Nx=[`children`];function Px(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];if(e.children){var r=e.children,i=Pg(e,Nx);n.push(i);var a,o=Ug(r);try{for(o.s();!(a=o.n()).done;)Px(a.value,t,n)}catch(e){o.e(e)}finally{o.f()}n.pop()}else t.push(Ox([].concat(Lg(n.slice(1)),[e])));return t}function Fx(e){return e.reduce((function(e,t){var n=e[e.length-1],r=Ig(function(e){var t=jx(e);return t.value.includes(`
|
|
42
|
+
`)?t.value.split(`
|
|
43
|
+
`).map((function(n){return kx(e,Mg(Mg({},t),{},{value:n}))})):[e]}(t)),i=r[0],a=r.slice(1);return[].concat(Lg(e.slice(0,-1)),[[].concat(Lg(n),[i])],Lg(a.map((function(e){return[e]}))))}),[[]])}function Ix(e){return Fx(Px(e))}var Lx=function(e,t,n){var r=(n=typeof n==`function`?n:void 0)?n(e,t):void 0;return r===void 0?Fy(e,t,void 0,n):!!r},Rx=function(e,t){return Fy(e,t)},zx=function(e){var t=e==null?0:e.length;return t?e[t-1]:void 0};function Bx(e,t){if(!e.children)throw Error(`parent node missing children property`);var n,r,i=zx(e.children);return i&&(r=t,(n=i).type===r.type&&(n.type===`text`||n.children&&r.children&&Lx(n,r,(function(e,t,n){return n===`chlidren`||Rx(e,t)}))))?e.children[e.children.length-1]=function(e,t){return`value`in e&&`value`in t?Mg(Mg({},e),{},{value:`${e.value}${t.value}`}):e}(i,t):e.children.push(t),e.children[e.children.length-1]}function Vx(e){var t,n={type:`root`,children:[]},r=Ug(e);try{var i=function(){var e=t.value;e.reduce((function(t,n,r){return Bx(t,r===e.length-1?Mg({},n):Mg(Mg({},n),{},{children:[]}))}),n)};for(r.s();!(t=r.n()).done;)i()}catch(e){r.e(e)}finally{r.f()}return n}var Hx=Object.prototype.hasOwnProperty,Ux=hx((function(e,t,n){Hx.call(e,n)?e[n].push(t):kb(e,n,[t])})),Wx=Object.prototype.hasOwnProperty,Gx=function(e){if(e==null)return!0;if(gy(e)&&(Rv(e)||typeof e==`string`||typeof e.splice==`function`||$v(e)||cy(e)||Zv(e)))return!e.length;var t=jy(e);if(t==`[object Map]`||t==`[object Set]`)return!e.size;if(fy(e))return!hy(e).length;for(var n in e)if(Wx.call(e,n))return!1;return!0},Kx=function(e,t){var n=t.start,r=n+t.length;return Fg(e.reduce((function(e,i){var a=Fg(e,2),o=a[0],s=a[1],c=s+jx(i).value.length;if(s>r||c<n)o.push(i);else{var l=Mx(i,n-s,r-s,t);o.push.apply(o,Lg(l))}return[o,c]}),[[],0]),1)[0]};function qx(e,t){var n=Ux(t,`lineNumber`);return e.map((function(e,t){return function(e,t){return Gx(t)?e:t.reduce(Kx,e)}(e,n[t+1])}))}function Jx(e,t){return function(n){var r=Fg(n,2),i=r[0],a=r[1];return[qx(i,e),qx(a,t)]}}var Yx=function(e){return e!=null&&e.length?yx(e,1):[]},Xx=Math.max,Zx=function(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:wb(n);return i<0&&(i=Xx(r+i,0)),d_(e,pb(t),i)},Qx=Gg((function(e){var t=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32};t.Diff=function(e,t){return[e,t]},t.prototype.diff_main=function(e,n,r,i){i===void 0&&(i=this.Diff_Timeout<=0?Number.MAX_VALUE:new Date().getTime()+1e3*this.Diff_Timeout);var a=i;if(e==null||n==null)throw Error(`Null input. (diff_main)`);if(e==n)return e?[new t.Diff(0,e)]:[];r===void 0&&(r=!0);var o=r,s=this.diff_commonPrefix(e,n),c=e.substring(0,s);e=e.substring(s),n=n.substring(s),s=this.diff_commonSuffix(e,n);var l=e.substring(e.length-s);e=e.substring(0,e.length-s),n=n.substring(0,n.length-s);var u=this.diff_compute_(e,n,o,a);return c&&u.unshift(new t.Diff(0,c)),l&&u.push(new t.Diff(0,l)),this.diff_cleanupMerge(u),u},t.prototype.diff_compute_=function(e,n,r,i){var a;if(!e)return[new t.Diff(1,n)];if(!n)return[new t.Diff(-1,e)];var o=e.length>n.length?e:n,s=e.length>n.length?n:e,c=o.indexOf(s);if(c!=-1)return a=[new t.Diff(1,o.substring(0,c)),new t.Diff(0,s),new t.Diff(1,o.substring(c+s.length))],e.length>n.length&&(a[0][0]=a[2][0]=-1),a;if(s.length==1)return[new t.Diff(-1,e),new t.Diff(1,n)];var l=this.diff_halfMatch_(e,n);if(l){var u=l[0],d=l[1],f=l[2],p=l[3],m=l[4],h=this.diff_main(u,f,r,i),g=this.diff_main(d,p,r,i);return h.concat([new t.Diff(0,m)],g)}return r&&e.length>100&&n.length>100?this.diff_lineMode_(e,n,i):this.diff_bisect_(e,n,i)},t.prototype.diff_lineMode_=function(e,n,r){var i=this.diff_linesToChars_(e,n);e=i.chars1,n=i.chars2;var a=i.lineArray,o=this.diff_main(e,n,!1,r);this.diff_charsToLines_(o,a),this.diff_cleanupSemantic(o),o.push(new t.Diff(0,``));for(var s=0,c=0,l=0,u=``,d=``;s<o.length;){switch(o[s][0]){case 1:l++,d+=o[s][1];break;case-1:c++,u+=o[s][1];break;case 0:if(c>=1&&l>=1){o.splice(s-c-l,c+l),s=s-c-l;for(var f=this.diff_main(u,d,!1,r),p=f.length-1;p>=0;p--)o.splice(s,0,f[p]);s+=f.length}l=0,c=0,u=``,d=``}s++}return o.pop(),o},t.prototype.diff_bisect_=function(e,n,r){for(var i=e.length,a=n.length,o=Math.ceil((i+a)/2),s=o,c=2*o,l=Array(c),u=Array(c),d=0;d<c;d++)l[d]=-1,u[d]=-1;l[s+1]=0,u[s+1]=0;for(var f=i-a,p=f%2!=0,m=0,h=0,g=0,_=0,v=0;v<o&&!(new Date().getTime()>r);v++){for(var y=-v+m;y<=v-h;y+=2){for(var b=s+y,x=(E=y==-v||y!=v&&l[b-1]<l[b+1]?l[b+1]:l[b-1]+1)-y;E<i&&x<a&&e.charAt(E)==n.charAt(x);)E++,x++;if(l[b]=E,E>i)h+=2;else if(x>a)m+=2;else if(p&&(w=s+f-y)>=0&&w<c&&u[w]!=-1&&E>=(C=i-u[w]))return this.diff_bisectSplit_(e,n,E,x,r)}for(var S=-v+g;S<=v-_;S+=2){for(var C,w=s+S,T=(C=S==-v||S!=v&&u[w-1]<u[w+1]?u[w+1]:u[w-1]+1)-S;C<i&&T<a&&e.charAt(i-C-1)==n.charAt(a-T-1);)C++,T++;if(u[w]=C,C>i)_+=2;else if(T>a)g+=2;else if(!p&&(b=s+f-S)>=0&&b<c&&l[b]!=-1){var E;if(x=s+(E=l[b])-b,E>=(C=i-C))return this.diff_bisectSplit_(e,n,E,x,r)}}}return[new t.Diff(-1,e),new t.Diff(1,n)]},t.prototype.diff_bisectSplit_=function(e,t,n,r,i){var a=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=this.diff_main(a,o,!1,i),u=this.diff_main(s,c,!1,i);return l.concat(u)},t.prototype.diff_linesToChars_=function(e,t){var n=[],r={};function i(e){for(var t=``,i=0,o=-1,s=n.length;o<e.length-1;){(o=e.indexOf(`
|
|
44
|
+
`,i))==-1&&(o=e.length-1);var c=e.substring(i,o+1);(r.hasOwnProperty?r.hasOwnProperty(c):r[c]!==void 0)?t+=String.fromCharCode(r[c]):(s==a&&(c=e.substring(i),o=e.length),t+=String.fromCharCode(s),r[c]=s,n[s++]=c),i=o+1}return t}n[0]=``;var a=4e4,o=i(e);return a=65535,{chars1:o,chars2:i(t),lineArray:n}},t.prototype.diff_charsToLines_=function(e,t){for(var n=0;n<e.length;n++){for(var r=e[n][1],i=[],a=0;a<r.length;a++)i[a]=t[r.charCodeAt(a)];e[n][1]=i.join(``)}},t.prototype.diff_commonPrefix=function(e,t){if(!e||!t||e.charAt(0)!=t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?a=n=i:r=i,i=Math.floor((r-n)/2+n);return i},t.prototype.diff_commonSuffix=function(e,t){if(!e||!t||e.charAt(e.length-1)!=t.charAt(t.length-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?a=n=i:r=i,i=Math.floor((r-n)/2+n);return i},t.prototype.diff_commonOverlap_=function(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var s=e.substring(i-o),c=t.indexOf(s);if(c==-1)return a;o+=c,c!=0&&e.substring(i-o)!=t.substring(0,o)||(a=o,o++)}},t.prototype.diff_halfMatch_=function(e,t){if(this.Diff_Timeout<=0)return null;var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||2*r.length<n.length)return null;var i=this;function a(e,t,n){for(var r,a,o,s,c=e.substring(n,n+Math.floor(e.length/4)),l=-1,u=``;(l=t.indexOf(c,l+1))!=-1;){var d=i.diff_commonPrefix(e.substring(n),t.substring(l)),f=i.diff_commonSuffix(e.substring(0,n),t.substring(0,l));u.length<f+d&&(u=t.substring(l-f,l)+t.substring(l,l+d),r=e.substring(0,n-f),a=e.substring(n+d),o=t.substring(0,l-f),s=t.substring(l+d))}return 2*u.length>=e.length?[r,a,o,s,u]:null}var o,s,c,l,u,d=a(n,r,Math.ceil(n.length/4)),f=a(n,r,Math.ceil(n.length/2));return d||f?(o=f?d&&d[4].length>f[4].length?d:f:d,e.length>t.length?(s=o[0],c=o[1],l=o[2],u=o[3]):(l=o[0],u=o[1],s=o[2],c=o[3]),[s,c,l,u,o[4]]):null},t.prototype.diff_cleanupSemantic=function(e){for(var n=!1,r=[],i=0,a=null,o=0,s=0,c=0,l=0,u=0;o<e.length;)e[o][0]==0?(r[i++]=o,s=l,c=u,l=0,u=0,a=e[o][1]):(e[o][0]==1?l+=e[o][1].length:u+=e[o][1].length,a&&a.length<=Math.max(s,c)&&a.length<=Math.max(l,u)&&(e.splice(r[i-1],0,new t.Diff(-1,a)),e[r[i-1]+1][0]=1,i--,o=--i>0?r[i-1]:-1,s=0,c=0,l=0,u=0,a=null,n=!0)),o++;for(n&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e),o=1;o<e.length;){if(e[o-1][0]==-1&&e[o][0]==1){var d=e[o-1][1],f=e[o][1],p=this.diff_commonOverlap_(d,f),m=this.diff_commonOverlap_(f,d);p>=m?(p>=d.length/2||p>=f.length/2)&&(e.splice(o,0,new t.Diff(0,f.substring(0,p))),e[o-1][1]=d.substring(0,d.length-p),e[o+1][1]=f.substring(p),o++):(m>=d.length/2||m>=f.length/2)&&(e.splice(o,0,new t.Diff(0,d.substring(0,m))),e[o-1][0]=1,e[o-1][1]=f.substring(0,f.length-m),e[o+1][0]=-1,e[o+1][1]=d.substring(m),o++),o++}o++}},t.prototype.diff_cleanupSemanticLossless=function(e){function n(e,n){if(!e||!n)return 6;var r=e.charAt(e.length-1),i=n.charAt(0),a=r.match(t.nonAlphaNumericRegex_),o=i.match(t.nonAlphaNumericRegex_),s=a&&r.match(t.whitespaceRegex_),c=o&&i.match(t.whitespaceRegex_),l=s&&r.match(t.linebreakRegex_),u=c&&i.match(t.linebreakRegex_),d=l&&e.match(t.blanklineEndRegex_),f=u&&n.match(t.blanklineStartRegex_);return d||f?5:l||u?4:a&&!s&&c?3:s||c?2:a||o?1:0}for(var r=1;r<e.length-1;){if(e[r-1][0]==0&&e[r+1][0]==0){var i=e[r-1][1],a=e[r][1],o=e[r+1][1],s=this.diff_commonSuffix(i,a);if(s){var c=a.substring(a.length-s);i=i.substring(0,i.length-s),a=c+a.substring(0,a.length-s),o=c+o}for(var l=i,u=a,d=o,f=n(i,a)+n(a,o);a.charAt(0)===o.charAt(0);){i+=a.charAt(0),a=a.substring(1)+o.charAt(0),o=o.substring(1);var p=n(i,a)+n(a,o);p>=f&&(f=p,l=i,u=a,d=o)}e[r-1][1]!=l&&(l?e[r-1][1]=l:(e.splice(r-1,1),r--),e[r][1]=u,d?e[r+1][1]=d:(e.splice(r+1,1),r--))}r++}},t.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,t.whitespaceRegex_=/\s/,t.linebreakRegex_=/[\r\n]/,t.blanklineEndRegex_=/\n\r?\n$/,t.blanklineStartRegex_=/^\r?\n\r?\n/,t.prototype.diff_cleanupEfficiency=function(e){for(var n=!1,r=[],i=0,a=null,o=0,s=!1,c=!1,l=!1,u=!1;o<e.length;)e[o][0]==0?(e[o][1].length<this.Diff_EditCost&&(l||u)?(r[i++]=o,s=l,c=u,a=e[o][1]):(i=0,a=null),l=u=!1):(e[o][0]==-1?u=!0:l=!0,a&&(s&&c&&l&&u||a.length<this.Diff_EditCost/2&&s+c+l+u==3)&&(e.splice(r[i-1],0,new t.Diff(-1,a)),e[r[i-1]+1][0]=1,i--,a=null,s&&c?(l=u=!0,i=0):(o=--i>0?r[i-1]:-1,l=u=!1),n=!0)),o++;n&&this.diff_cleanupMerge(e)},t.prototype.diff_cleanupMerge=function(e){e.push(new t.Diff(0,``));for(var n,r=0,i=0,a=0,o=``,s=``;r<e.length;)switch(e[r][0]){case 1:a++,s+=e[r][1],r++;break;case-1:i++,o+=e[r][1],r++;break;case 0:i+a>1?(i!==0&&a!==0&&((n=this.diff_commonPrefix(s,o))!==0&&(r-i-a>0&&e[r-i-a-1][0]==0?e[r-i-a-1][1]+=s.substring(0,n):(e.splice(0,0,new t.Diff(0,s.substring(0,n))),r++),s=s.substring(n),o=o.substring(n)),(n=this.diff_commonSuffix(s,o))!==0&&(e[r][1]=s.substring(s.length-n)+e[r][1],s=s.substring(0,s.length-n),o=o.substring(0,o.length-n))),r-=i+a,e.splice(r,i+a),o.length&&(e.splice(r,0,new t.Diff(-1,o)),r++),s.length&&(e.splice(r,0,new t.Diff(1,s)),r++),r++):r!==0&&e[r-1][0]==0?(e[r-1][1]+=e[r][1],e.splice(r,1)):r++,a=0,i=0,o=``,s=``}e[e.length-1][1]===``&&e.pop();var c=!1;for(r=1;r<e.length-1;)e[r-1][0]==0&&e[r+1][0]==0&&(e[r][1].substring(e[r][1].length-e[r-1][1].length)==e[r-1][1]?(e[r][1]=e[r-1][1]+e[r][1].substring(0,e[r][1].length-e[r-1][1].length),e[r+1][1]=e[r-1][1]+e[r+1][1],e.splice(r-1,1),c=!0):e[r][1].substring(0,e[r+1][1].length)==e[r+1][1]&&(e[r-1][1]+=e[r+1][1],e[r][1]=e[r][1].substring(e[r+1][1].length)+e[r+1][1],e.splice(r+1,1),c=!0)),r++;c&&this.diff_cleanupMerge(e)},t.prototype.diff_xIndex=function(e,t){var n,r=0,i=0,a=0,o=0;for(n=0;n<e.length&&(e[n][0]!==1&&(r+=e[n][1].length),e[n][0]!==-1&&(i+=e[n][1].length),!(r>t));n++)a=r,o=i;return e.length!=n&&e[n][0]===-1?o:o+(t-a)},t.prototype.diff_prettyHtml=function(e){for(var t=[],n=/&/g,r=/</g,i=/>/g,a=/\n/g,o=0;o<e.length;o++){var s=e[o][0],c=e[o][1].replace(n,`&`).replace(r,`<`).replace(i,`>`).replace(a,`¶<br>`);switch(s){case 1:t[o]=`<ins style="background:#e6ffe6;">`+c+`</ins>`;break;case-1:t[o]=`<del style="background:#ffe6e6;">`+c+`</del>`;break;case 0:t[o]=`<span>`+c+`</span>`}}return t.join(``)},t.prototype.diff_text1=function(e){for(var t=[],n=0;n<e.length;n++)e[n][0]!==1&&(t[n]=e[n][1]);return t.join(``)},t.prototype.diff_text2=function(e){for(var t=[],n=0;n<e.length;n++)e[n][0]!==-1&&(t[n]=e[n][1]);return t.join(``)},t.prototype.diff_levenshtein=function(e){for(var t=0,n=0,r=0,i=0;i<e.length;i++){var a=e[i][0],o=e[i][1];switch(a){case 1:n+=o.length;break;case-1:r+=o.length;break;case 0:t+=Math.max(n,r),n=0,r=0}}return t+=Math.max(n,r)},t.prototype.diff_toDelta=function(e){for(var t=[],n=0;n<e.length;n++)switch(e[n][0]){case 1:t[n]=`+`+encodeURI(e[n][1]);break;case-1:t[n]=`-`+e[n][1].length;break;case 0:t[n]=`=`+e[n][1].length}return t.join(` `).replace(/%20/g,` `)},t.prototype.diff_fromDelta=function(e,n){for(var r=[],i=0,a=0,o=n.split(/\t/g),s=0;s<o.length;s++){var c=o[s].substring(1);switch(o[s].charAt(0)){case`+`:try{r[i++]=new t.Diff(1,decodeURI(c))}catch{throw Error(`Illegal escape in diff_fromDelta: `+c)}break;case`-`:case`=`:var l=parseInt(c,10);if(isNaN(l)||l<0)throw Error(`Invalid number in diff_fromDelta: `+c);var u=e.substring(a,a+=l);o[s].charAt(0)==`=`?r[i++]=new t.Diff(0,u):r[i++]=new t.Diff(-1,u);break;default:if(o[s])throw Error(`Invalid diff operation in diff_fromDelta: `+o[s])}}if(a!=e.length)throw Error(`Delta length (`+a+`) does not equal source text length (`+e.length+`).`);return r},t.prototype.match_main=function(e,t,n){if(e==null||t==null||n==null)throw Error(`Null input. (match_main)`);return n=Math.max(0,Math.min(n,e.length)),e==t?0:e.length?e.substring(n,n+t.length)==t?n:this.match_bitap_(e,t,n):-1},t.prototype.match_bitap_=function(e,t,n){if(t.length>this.Match_MaxBits)throw Error(`Pattern too long for this browser.`);var r=this.match_alphabet_(t),i=this;function a(e,r){var a=e/t.length,o=Math.abs(n-r);return i.Match_Distance?a+o/i.Match_Distance:o?1:a}var o=this.Match_Threshold,s=e.indexOf(t,n);s!=-1&&(o=Math.min(a(0,s),o),(s=e.lastIndexOf(t,n+t.length))!=-1&&(o=Math.min(a(0,s),o)));var c,l,u=1<<t.length-1;s=-1;for(var d,f=t.length+e.length,p=0;p<t.length;p++){for(c=0,l=f;c<l;)a(p,n+l)<=o?c=l:f=l,l=Math.floor((f-c)/2+c);f=l;var m=Math.max(1,n-l+1),h=Math.min(n+l,e.length)+t.length,g=Array(h+2);g[h+1]=(1<<p)-1;for(var _=h;_>=m;_--){var v=r[e.charAt(_-1)];if(g[_]=p===0?(g[_+1]<<1|1)&v:(g[_+1]<<1|1)&v|(d[_+1]|d[_])<<1|1|d[_+1],g[_]&u){var y=a(p,_-1);if(y<=o){if(o=y,!((s=_-1)>n))break;m=Math.max(1,2*n-s)}}}if(a(p+1,n)>o)break;d=g}return s},t.prototype.match_alphabet_=function(e){for(var t={},n=0;n<e.length;n++)t[e.charAt(n)]=0;for(n=0;n<e.length;n++)t[e.charAt(n)]|=1<<e.length-n-1;return t},t.prototype.patch_addContext_=function(e,n){if(n.length!=0){if(e.start2===null)throw Error(`patch not initialized`);for(var r=n.substring(e.start2,e.start2+e.length1),i=0;n.indexOf(r)!=n.lastIndexOf(r)&&r.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)i+=this.Patch_Margin,r=n.substring(e.start2-i,e.start2+e.length1+i);i+=this.Patch_Margin;var a=n.substring(e.start2-i,e.start2);a&&e.diffs.unshift(new t.Diff(0,a));var o=n.substring(e.start2+e.length1,e.start2+e.length1+i);o&&e.diffs.push(new t.Diff(0,o)),e.start1-=a.length,e.start2-=a.length,e.length1+=a.length+o.length,e.length2+=a.length+o.length}},t.prototype.patch_make=function(e,n,r){var i,a;if(typeof e==`string`&&typeof n==`string`&&r===void 0)i=e,(a=this.diff_main(i,n,!0)).length>2&&(this.diff_cleanupSemantic(a),this.diff_cleanupEfficiency(a));else if(e&&typeof e==`object`&&n===void 0&&r===void 0)a=e,i=this.diff_text1(a);else if(typeof e==`string`&&n&&typeof n==`object`&&r===void 0)i=e,a=n;else{if(typeof e!=`string`||typeof n!=`string`||!r||typeof r!=`object`)throw Error(`Unknown call format to patch_make.`);i=e,a=r}if(a.length===0)return[];for(var o=[],s=new t.patch_obj,c=0,l=0,u=0,d=i,f=i,p=0;p<a.length;p++){var m=a[p][0],h=a[p][1];switch(c||m===0||(s.start1=l,s.start2=u),m){case 1:s.diffs[c++]=a[p],s.length2+=h.length,f=f.substring(0,u)+h+f.substring(u);break;case-1:s.length1+=h.length,s.diffs[c++]=a[p],f=f.substring(0,u)+f.substring(u+h.length);break;case 0:h.length<=2*this.Patch_Margin&&c&&a.length!=p+1?(s.diffs[c++]=a[p],s.length1+=h.length,s.length2+=h.length):h.length>=2*this.Patch_Margin&&c&&(this.patch_addContext_(s,d),o.push(s),s=new t.patch_obj,c=0,d=f,l=u)}m!==1&&(l+=h.length),m!==-1&&(u+=h.length)}return c&&(this.patch_addContext_(s,d),o.push(s)),o},t.prototype.patch_deepCopy=function(e){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=new t.patch_obj;a.diffs=[];for(var o=0;o<i.diffs.length;o++)a.diffs[o]=new t.Diff(i.diffs[o][0],i.diffs[o][1]);a.start1=i.start1,a.start2=i.start2,a.length1=i.length1,a.length2=i.length2,n[r]=a}return n},t.prototype.patch_apply=function(e,t){if(e.length==0)return[t,[]];e=this.patch_deepCopy(e);var n=this.patch_addPadding(e);t=n+t+n,this.patch_splitMax(e);for(var r=0,i=[],a=0;a<e.length;a++){var o,s,c=e[a].start2+r,l=this.diff_text1(e[a].diffs),u=-1;if(l.length>this.Match_MaxBits?(o=this.match_main(t,l.substring(0,this.Match_MaxBits),c))!=-1&&((u=this.match_main(t,l.substring(l.length-this.Match_MaxBits),c+l.length-this.Match_MaxBits))==-1||o>=u)&&(o=-1):o=this.match_main(t,l,c),o==-1)i[a]=!1,r-=e[a].length2-e[a].length1;else if(i[a]=!0,r=o-c,l==(s=u==-1?t.substring(o,o+l.length):t.substring(o,u+this.Match_MaxBits)))t=t.substring(0,o)+this.diff_text2(e[a].diffs)+t.substring(o+l.length);else{var d=this.diff_main(l,s,!1);if(l.length>this.Match_MaxBits&&this.diff_levenshtein(d)/l.length>this.Patch_DeleteThreshold)i[a]=!1;else{this.diff_cleanupSemanticLossless(d);for(var f,p=0,m=0;m<e[a].diffs.length;m++){var h=e[a].diffs[m];h[0]!==0&&(f=this.diff_xIndex(d,p)),h[0]===1?t=t.substring(0,o+f)+h[1]+t.substring(o+f):h[0]===-1&&(t=t.substring(0,o+f)+t.substring(o+this.diff_xIndex(d,p+h[1].length))),h[0]!==-1&&(p+=h[1].length)}}}}return[t=t.substring(n.length,t.length-n.length),i]},t.prototype.patch_addPadding=function(e){for(var n=this.Patch_Margin,r=``,i=1;i<=n;i++)r+=String.fromCharCode(i);for(i=0;i<e.length;i++)e[i].start1+=n,e[i].start2+=n;var a=e[0],o=a.diffs;if(o.length==0||o[0][0]!=0)o.unshift(new t.Diff(0,r)),a.start1-=n,a.start2-=n,a.length1+=n,a.length2+=n;else if(n>o[0][1].length){var s=n-o[0][1].length;o[0][1]=r.substring(o[0][1].length)+o[0][1],a.start1-=s,a.start2-=s,a.length1+=s,a.length2+=s}return(o=(a=e[e.length-1]).diffs).length==0||o[o.length-1][0]!=0?(o.push(new t.Diff(0,r)),a.length1+=n,a.length2+=n):n>o[o.length-1][1].length&&(s=n-o[o.length-1][1].length,o[o.length-1][1]+=r.substring(0,s),a.length1+=s,a.length2+=s),r},t.prototype.patch_splitMax=function(e){for(var n=this.Match_MaxBits,r=0;r<e.length;r++)if(!(e[r].length1<=n)){var i=e[r];e.splice(r--,1);for(var a=i.start1,o=i.start2,s=``;i.diffs.length!==0;){var c=new t.patch_obj,l=!0;for(c.start1=a-s.length,c.start2=o-s.length,s!==``&&(c.length1=c.length2=s.length,c.diffs.push(new t.Diff(0,s)));i.diffs.length!==0&&c.length1<n-this.Patch_Margin;){var u=i.diffs[0][0],d=i.diffs[0][1];u===1?(c.length2+=d.length,o+=d.length,c.diffs.push(i.diffs.shift()),l=!1):u===-1&&c.diffs.length==1&&c.diffs[0][0]==0&&d.length>2*n?(c.length1+=d.length,a+=d.length,l=!1,c.diffs.push(new t.Diff(u,d)),i.diffs.shift()):(d=d.substring(0,n-c.length1-this.Patch_Margin),c.length1+=d.length,a+=d.length,u===0?(c.length2+=d.length,o+=d.length):l=!1,c.diffs.push(new t.Diff(u,d)),d==i.diffs[0][1]?i.diffs.shift():i.diffs[0][1]=i.diffs[0][1].substring(d.length))}s=(s=this.diff_text2(c.diffs)).substring(s.length-this.Patch_Margin);var f=this.diff_text1(i.diffs).substring(0,this.Patch_Margin);f!==``&&(c.length1+=f.length,c.length2+=f.length,c.diffs.length!==0&&c.diffs[c.diffs.length-1][0]===0?c.diffs[c.diffs.length-1][1]+=f:c.diffs.push(new t.Diff(0,f))),l||e.splice(++r,0,c)}}},t.prototype.patch_toText=function(e){for(var t=[],n=0;n<e.length;n++)t[n]=e[n];return t.join(``)},t.prototype.patch_fromText=function(e){var n=[];if(!e)return n;for(var r=e.split(`
|
|
45
|
+
`),i=0,a=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;i<r.length;){var o=r[i].match(a);if(!o)throw Error(`Invalid patch string: `+r[i]);var s=new t.patch_obj;for(n.push(s),s.start1=parseInt(o[1],10),o[2]===``?(s.start1--,s.length1=1):o[2]==`0`?s.length1=0:(s.start1--,s.length1=parseInt(o[2],10)),s.start2=parseInt(o[3],10),o[4]===``?(s.start2--,s.length2=1):o[4]==`0`?s.length2=0:(s.start2--,s.length2=parseInt(o[4],10)),i++;i<r.length;){var c=r[i].charAt(0);try{var l=decodeURI(r[i].substring(1))}catch{throw Error(`Illegal escape in patch_fromText: `+l)}if(c==`-`)s.diffs.push(new t.Diff(-1,l));else if(c==`+`)s.diffs.push(new t.Diff(1,l));else if(c==` `)s.diffs.push(new t.Diff(0,l));else{if(c==`@`)break;if(c!==``)throw Error(`Invalid patch mode "`+c+`" in: `+l)}i++}}return n},(t.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0}).prototype.toString=function(){for(var e,t=[`@@ -`+(this.length1===0?this.start1+`,0`:this.length1==1?this.start1+1:this.start1+1+`,`+this.length1)+` +`+(this.length2===0?this.start2+`,0`:this.length2==1?this.start2+1:this.start2+1+`,`+this.length2)+` @@
|
|
46
|
+
`],n=0;n<this.diffs.length;n++){switch(this.diffs[n][0]){case 1:e=`+`;break;case-1:e=`-`;break;case 0:e=` `}t[n+1]=e+encodeURI(this.diffs[n][1])+`
|
|
47
|
+
`}return t.join(``).replace(/%20/g,` `)},e.exports=t,e.exports.diff_match_patch=t,e.exports.DIFF_DELETE=-1,e.exports.DIFF_INSERT=1,e.exports.DIFF_EQUAL=0})),$x=Qx.DIFF_EQUAL,eS=Qx.DIFF_DELETE,tS=Qx.DIFF_INSERT;function nS(e){var t=Zx(e,(function(e){return!e_(e)}));if(t===-1)return[];var n=Zx(e,(function(e){return!!e_(e)}),t);return n===-1?[e.slice(t)]:[e.slice(t,n)].concat(Lg(nS(e.slice(n))))}function rS(e){return e.reduce((function(e,t){var n=Fg(t,2),r=n[0],i=Ig(n[1].split(`
|
|
48
|
+
`).map((function(e){return[r,e]}))),a=i[0],o=i.slice(1);return[].concat(Lg(e.slice(0,-1)),[[].concat(Lg(e[e.length-1]),[a])],Lg(o.map((function(e){return[e]}))))}),[[]])}function iS(e,t){return e.reduce((function(e,n){var r=Fg(e,2),i=r[0],a=r[1],o=Fg(n,2),s=o[0],c=o[1];if(s!==$x){var l={type:`edit`,lineNumber:t,start:a,length:c.length};i.push(l)}return[i,a+c.length]}),[[],0])[0]}function aS(e,t){return Sx(e,(function(e,n){return iS(e,t+n)}))}function oS(e,t){var n=new Qx,r=n.diff_main(e,t);return n.diff_cleanupSemantic(r),r.length<=1?[[],[]]:function(e){return e.reduce((function(e,t){var n=Fg(e,2),r=n[0],i=n[1];switch(Fg(t,1)[0]){case tS:i.push(t);break;case eS:r.push(t);break;default:r.push(t),i.push(t)}return[r,i]}),[[],[]])}(r)}function sS(e){var t=Fg(e.reduce((function(e,t){var n=Fg(e,2),r=n[0],i=n[1];return $g(t)?[r+(r?`
|
|
49
|
+
`:``)+t.content,i]:[r,i+(i?`
|
|
50
|
+
`:``)+t.content]}),[``,``]),2),n=Fg(oS(t[0],t[1]),2),r=n[0],i=n[1];if(r.length===0&&i.length===0)return[[],[]];var a=function(e){if(e&&!e_(e))return e.lineNumber},o=a(e.find($g)),s=a(e.find(Qg));if(o===void 0||s===void 0)throw Error(`Could not find start line number for edit`);return[aS(rS(r),o),aS(rS(i),s)]}function cS(e){var t=Fg(e.reduce((function(e,t){var n=Fg(e,3),r=n[0],i=n[1],a=n[2];if(!a||!$g(a)||!Qg(t))return[r,i,t];var o=Fg(oS(a.content,t.content),2),s=o[0],c=o[1];return[r.concat(iS(s,a.lineNumber)),i.concat(iS(c,t.lineNumber)),t]}),[[],[],null]),2);return[t[0],t[1]]}function lS(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).type,n=(t===void 0?`block`:t)===`block`?sS:cS,r=Fg(Sx(e.map((function(e){return e.changes})),nS).map(n).reduce((function(e,t){var n=Fg(e,2),r=n[0],i=n[1],a=Fg(t,2),o=a[0],s=a[1];return[r.concat(o),i.concat(s)]}),[[],[]]),2),i=r[0],a=r[1];return Jx(Yx(i),Yx(a))}var uS=[`enhancers`],dS=function(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.enhancers,i=r===void 0?[]:r,a=Fg(Dx(e,Pg(n,uS)),2),o=a[0],s=a[1],c=[Ix(o),Ix(s)],l=Fg((t=[c[0],c[1]],i.reduce((function(e,t){return t(e)}),t)),2),u=l[0],d=l[1],f=[u.map(Vx),d.map(Vx)],p=f[1];return{old:f[0].map((function(e){return e.children??[]})),new:p.map((function(e){return e.children??[]}))}},fS=e=>e.type===`insert`?{oldLineNumber:null,newLineNumber:e.lineNumber}:e.type===`delete`?{oldLineNumber:e.lineNumber,newLineNumber:null}:{oldLineNumber:`oldLineNumber`in e?e.oldLineNumber:e.lineNumber,newLineNumber:`newLineNumber`in e?e.newLineNumber:e.lineNumber},pS=e=>{let{oldLineNumber:t,newLineNumber:n}=fS(e);return n===null?t===null?e.lineNumber:t:n},mS=(e,t)=>{let{oldLineNumber:n,newLineNumber:r}=fS(t);return e.new_line_number!==null&&r===e.new_line_number?!0:e.old_line_number!==null&&n===e.old_line_number},hS=(e,t)=>mS(e,t),gS=e=>e.replace(/^[ab]\//,``),_S=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?gS(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?gS(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},vS=e=>{let[t,n]=_S(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},yS=e=>e.oldLineNumber!==null&&e.newLineNumber!==null?`old ${e.oldLineNumber}, new ${e.newLineNumber}`:e.newLineNumber===null?e.oldLineNumber===null?`line unavailable`:`old ${e.oldLineNumber}`:`new ${e.newLineNumber}`,bS=e=>e===`bundle_diff`?`Branch diff`:`Uncommitted`,xS=(e,t)=>`${e}::${t}`,SS=(e,t)=>{let n=e.changes.findIndex(e=>Tb(e)===Tb(t));if(n===-1)return t.content;let r=Math.max(0,n-1),i=Math.min(e.changes.length,n+2);return e.changes.slice(r,i).map(e=>e.content).join(`
|
|
51
|
+
`)},CS=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,wS=e=>[e.hunk_header,e.line_content].filter(e=>!!e).join(`
|
|
52
|
+
`).trim(),TS=(e,t)=>{let n=t.find(t=>t.pathCandidates.includes(e.file_path??``));if(!n)return e.file_path?{filePath:e.file_path,diffSnippet:wS(e)}:null;let r=n.hunks.flatMap(e=>e.changes.map(t=>({hunk:e,change:t}))).find(({change:t})=>hS(e,t));return r?{filePath:e.file_path??vS(n),diffSnippet:SS(r.hunk,r.change)}:{filePath:e.file_path??vS(n),diffSnippet:wS(e)}},ES=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,DS=e=>e.subject_type===`file`,OS=e=>e.body.trim(),kS=(e,t)=>{if(!e.file_path)return null;let n=t.find(t=>t.pathCandidates.includes(e.file_path??``));if(!n)return{filePath:e.file_path,diffSnippet:OS(e)};let r=n.hunks.flatMap(e=>e.changes.map(t=>({hunk:e,change:t}))).find(({change:t})=>hS(e,t));return r?{filePath:e.file_path,diffSnippet:SS(r.hunk,r.change)}:{filePath:e.file_path,diffSnippet:OS(e)}},AS=e=>e.pagePath||e.pageUrl||`/`,jS=({drafts:e,findings:t,githubComments:n,previewComments:r=[],uncommittedFiles:i=[],bundleFiles:a=[]})=>{let o=[...e],s=[...t].sort((e,t)=>{let n=e.file_path??``,r=t.file_path??``;if(n!==r)return n.localeCompare(r);let i=e.new_line_number??e.old_line_number??2**53-1,a=t.new_line_number??t.old_line_number??2**53-1;return i===a?e.ordinal-t.ordinal:i-a}),c=[...n].sort((e,t)=>{let n=e.file_path??``,r=t.file_path??``;if(n!==r)return n.localeCompare(r);let i=e.new_line_number??e.old_line_number??2**53-1,a=t.new_line_number??t.old_line_number??2**53-1;return i===a?e.id.localeCompare(t.id):i-a}),l=[...r].sort((e,t)=>{let n=AS(e),r=AS(t);return n===r?e.elementLabel===t.elementLabel?e.selectorHint===t.selectorHint?e.id.localeCompare(t.id):e.selectorHint.localeCompare(t.selectorHint):e.elementLabel.localeCompare(t.elementLabel):n.localeCompare(r)}),u=o.map((e,t)=>[`${t+1}. Source: Manual comment (${bS(e.scope)})`,`File: ${e.filePath}`,`Line: ${yS(e)}`,`Hunk: ${e.hunkHeader}`,`Changed line: ${e.lineContent}`,`Comment: ${e.comment}`,`Context:`,"```diff",e.diffSnippet,"```"].join(`
|
|
53
|
+
`)),d=s.map((e,t)=>{let n=TS(e,i),r=[`${o.length+t+1}. Source: Archon review finding`,`Finding: ${e.ordinal}`];return n?.filePath&&r.push(`File: ${n.filePath}`),r.push(`Line: ${CS(e)}`),r.push(`Severity: ${e.severity}`),r.push(`Title: ${e.title}`),r.push(`What: ${e.what_text}`),e.why_text&&r.push(`Why it matters: ${e.why_text}`),e.fix_text&&r.push(`Requested fix: ${e.fix_text}`),n?.diffSnippet&&(r.push(`Context:`),r.push("```diff"),r.push(n.diffSnippet),r.push("```")),r.join(`
|
|
54
|
+
`)}),f=c.map((e,t)=>{let n=kS(e,a),r=[`${o.length+s.length+t+1}. Source: GitHub ${e.kind===`review`?`review summary`:`review comment`}`,`Author: ${e.author}`];return n?.filePath&&r.push(`File: ${n.filePath}`),e.kind===`inline`&&!DS(e)&&r.push(`Line: ${ES(e)}`),e.is_outdated&&r.push(`Status: Outdated on GitHub`),r.push(`Comment: ${e.body}`),n?.diffSnippet&&(r.push(`Context:`),r.push("```diff"),r.push(n.diffSnippet),r.push("```")),r.push(`GitHub URL: ${e.url}`),r.join(`
|
|
55
|
+
`)}),p=l.map((e,t)=>{let n=[`${o.length+s.length+c.length+t+1}. Source: Preview comment`,`Page: ${AS(e)}`,`Element: ${e.elementLabel}`,`Selector hint: ${e.selectorHint}`];return e.textSnippet&&n.push(`Text: ${e.textSnippet}`),e.href&&n.push(`Href: ${e.href}`),e.src&&n.push(`Src: ${e.src}`),n.push(`Comment: ${e.comment}`),n.join(`
|
|
56
|
+
`)}),m=[...u,...d,...f,...p],h=t.length>0||e.length>0||n.length>0;return[r.length>0?h?`Please address the following selected fixes from the current diff and preview.`:`Please address the following selected fixes from the current preview.`:h?`Please address the following selected fixes in the current diff.`:`Please address the selected fixes in the current diff.`,``,...m.flatMap(e=>[e,``]),`Apply only the selected fixes. Keep unrelated changes intact.`].join(`
|
|
57
|
+
`).trim()},MS={phone:{width:390,height:844},tablet:{width:768,height:1024},laptop:{width:1440,height:900}},NS=[.5,.75,1,1.25],PS=`archon-preview-selection`,FS=`archon-preview-selection-parent`,IS=320,LS=248,RS=12,zS=16,BS=12,VS=8,HS=8,US=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`preview-review-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,WS=({previewUrl:e,reviewCapability:t,status:n,t:r})=>t&&!t.canSelect?t.disabledReason:t?.submitPrompt?n?.state!==`ready`||!e?r(`projectPreviewPane.selection.waitForLoad`):null:r(`projectPreviewPane.selection.unavailableBuildCapable`),GS=e=>e?.target?`${e.target.kind}:${e.target.id}`:null,KS=(e,t)=>{let n=e.getBoundingClientRect(),r=t.viewport.width>0?n.width/t.viewport.width:1,i=t.viewport.height>0?n.height/t.viewport.height:1;return{left:n.left+t.bounds.left*r,top:n.top+t.bounds.top*i,width:t.bounds.width*r,height:t.bounds.height*i}},qS=(e,t)=>{let n=t.width,r=t.height,i=e.left+e.width+RS,a=i+n<=window.innerWidth-zS,o=e.left-n-RS,s=Math.max(zS,window.innerWidth-n-zS),c=a?i:o>=zS?o:Math.min(Math.max(zS,e.left),s),l=Math.max(zS,e.top),u=Math.max(zS,window.innerHeight-r-zS);return{left:c,top:l+r<=window.innerHeight-zS?l:Math.max(zS,Math.min(e.top+e.height-r,u))}},JS=e=>{if(!e)return null;let t=e.replace(/\s+/g,` `).trim();return t.length>0?t:null},YS=(e,t=96)=>{if(e.length<=t)return e;let n=e.slice(0,t+1),r=n.lastIndexOf(` `);return`${(r>Math.floor(t*.6)?n.slice(0,r):n.slice(0,t)).trimEnd()}...`},XS=({elementLabel:e,elementLabelText:t,textSnippet:n,unknownElementLabel:r})=>{let i=e.match(/^[a-z0-9-]+/i)?.[0]?.toLowerCase()??null;return i?`<${i}>`:n?t:r},ZS=(e,t)=>{let n=JS(e.textSnippet);return{kindLabel:XS({elementLabel:e.elementLabel,elementLabelText:t.element,textSnippet:n,unknownElementLabel:t.unknownElement}),detail:n?YS(n):null}},QS=({pagePath:e,selectorHint:t})=>`${e}::${t}`,$S=(e,t)=>QS(e)===QS(t),eC=(e,t)=>{let n=Array.from(e.children).filter(e=>e instanceof HTMLElement);return n.length===0?0:n.reduce((e,t)=>e+Math.round(t.getBoundingClientRect().width),0)+(n.length-1)*t},tC=({title:e,description:t,showSpinner:n=!1})=>(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,Z.jsxs)(`div`,{className:`max-w-sm rounded-2xl border border-border/70 bg-background/70 p-5 text-center shadow-lg shadow-black/20`,children:[n&&(0,Z.jsx)(ye,{className:`mx-auto mb-3 h-5 w-5 animate-spin text-muted-foreground`}),(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:t})]})}),nC=({iframeKey:e,iframeRef:t,iframeSrc:n,onLoad:r,preset:i,zoom:a})=>{let{t:o}=ht(`common`),s=i===null,c=i?{"--preview-width":`${i.width}px`,"--preview-height":`${i.height}px`,"--preview-scale":`${a}`,"--preview-scaled-width":`${Math.round(i.width*a)}px`,"--preview-scaled-height":`${Math.round(i.height*a)}px`}:void 0;return(0,Z.jsx)(`div`,{className:s?`flex h-full min-h-0 flex-col p-4`:`flex h-full min-h-0 items-start justify-center overflow-auto p-6`,children:(0,Z.jsx)(`div`,{className:s?`min-h-0 flex-1`:`w-[var(--preview-scaled-width)]`,style:c,children:(0,Z.jsx)(`div`,{className:s?`h-full min-h-0 overflow-hidden bg-white shadow-2xl shadow-black/20`:`h-[var(--preview-scaled-height)] w-[var(--preview-scaled-width)] overflow-hidden rounded-[1.5rem] border border-border/80 bg-white shadow-2xl shadow-black/30`,children:(0,Z.jsx)(`iframe`,{ref:t,src:n,sandbox:`allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts`,title:o(`projectPreviewPane.iframeTitle`),className:s?`h-full w-full border-0 bg-white`:`h-[var(--preview-height)] w-[var(--preview-width)] origin-top-left scale-[var(--preview-scale)] border-0 bg-white`,onLoad:r},e)})})})},rC=({tooltip:e,children:t,...n})=>(0,Z.jsx)(Lu,{content:e,side:`bottom`,children:(0,Z.jsx)(`span`,{className:`inline-flex`,children:(0,Z.jsx)(J,{...n,children:t})})}),iC=({comment:e,onRemoveComment:t})=>{let{t:n}=ht(`common`),r=ZS(e,{element:n(`projectPreviewPane.targetSummary.element`),unknownElement:n(`projectPreviewPane.targetSummary.unknownElement`)});return(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(vg,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:r.kindLabel}),r.detail&&(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:r.detail}),(0,Z.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-foreground`,children:e.comment})]}),(0,Z.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mt-0.5 h-7 w-7 flex-shrink-0 text-muted-foreground hover:text-foreground`,"aria-label":n(`projectPreviewPane.pendingComments.deleteAriaLabel`,{elementLabel:e.elementLabel}),onClick:()=>t(e.id),children:(0,Z.jsx)(Vf,{className:`h-4 w-4`})})]})})},aC=({isOpen:e,canSendReview:t,comments:n,triggerMode:r=`full`,disabledReason:i,isSubmittingReview:a,onOpenChange:o,onRemoveComment:s,onClearPendingFixes:c,onSubmitReview:l})=>{let{t:u}=ht(`common`),d=n.length;return(0,Z.jsxs)(hu,{open:e,onOpenChange:o,children:[(0,Z.jsx)(gu,{asChild:!0,children:(0,Z.jsxs)(J,{type:`button`,variant:`default`,size:`sm`,className:r===`compact`?`gap-1.5 px-2.5`:`gap-2`,"aria-label":u(`projectPreviewPane.pendingComments.triggerLabel`),disabled:d===0,children:[r===`compact`?(0,Z.jsx)(vg,{className:`h-4 w-4`}):(0,Z.jsx)(`span`,{children:u(`projectPreviewPane.pendingComments.triggerLabel`)}),(0,Z.jsx)(q,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:d}),(0,Z.jsx)(oe,{className:`h-4 w-4`})]})}),(0,Z.jsxs)(_u,{align:`end`,className:`z-[90] w-[30rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,Z.jsxs)(vu,{className:`flex-row items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(yu,{children:u(`projectPreviewPane.pendingComments.title`)}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`projectPreviewPane.pendingComments.description`)})]}),(0,Z.jsx)(q,{variant:`outline`,children:d})]}),d===0?(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:u(`projectPreviewPane.pendingComments.empty`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`max-h-80 space-y-2 overflow-auto pr-1`,children:n.map(e=>(0,Z.jsx)(iC,{comment:e,onRemoveComment:s},e.id))}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-end gap-2 border-t border-border/70 pt-4`,children:[(0,Z.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:c,children:u(`projectPreviewPane.pendingComments.clearAll`)}),(0,Z.jsxs)(J,{type:`button`,size:`sm`,disabled:!t,title:i??void 0,onClick:l,children:[a?(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}):null,(0,Z.jsx)(`span`,{children:a?u(`projectPreviewPane.pendingComments.sending`):u(`projectPreviewPane.pendingComments.sendFixes`,{count:d})})]})]})]})]})]})},oC=(e,t)=>e?.promptPlaceholder?e.promptPlaceholder:e?.target?.kind===`bundle`?t(`projectPreviewPane.prompt.bundlePlaceholder`):e?.target?.kind===`ticket`?t(`projectPreviewPane.prompt.ticketPlaceholder`):t(`projectPreviewPane.prompt.defaultPlaceholder`),sC=({comment:e,composerRef:t,disabled:n,mode:r,onAddComment:i,onCancel:a,onCommentChange:o,position:s,target:c})=>{let{t:l}=ht(`common`),u=(0,X.useRef)(null),d=ZS(c,{element:l(`projectPreviewPane.targetSummary.element`),unknownElement:l(`projectPreviewPane.targetSummary.unknownElement`)});return(0,X.useEffect)(()=>{u.current?.focus({preventScroll:!0})},[]),(0,Z.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[85]`,"aria-live":`polite`,children:(0,Z.jsxs)(`div`,{ref:t,className:`pointer-events-auto fixed w-80 max-h-[calc(100vh-2rem)] overflow-y-auto rounded-2xl border border-border/80 bg-background/95 p-4 shadow-2xl shadow-black/40 backdrop-blur`,style:{left:`${s.left}px`,top:`${s.top}px`},children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:l(r===`edit`?`projectPreviewPane.commentComposer.editTitle`:`projectPreviewPane.commentComposer.addTitle`)})}),(0,Z.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-foreground`,"aria-label":l(`projectPreviewPane.commentComposer.closeAriaLabel`),onClick:a,children:(0,Z.jsx)(Fe,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`mt-3 rounded-xl border border-border/70 bg-background/50 px-3 py-3 text-xs`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:d.kindLabel}),d.detail&&(0,Z.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap text-muted-foreground`,children:d.detail})]}),(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Z.jsx)(tu,{ref:u,"aria-label":l(`projectPreviewPane.commentComposer.commentAriaLabel`),className:`min-h-28 resize-none`,placeholder:l(`projectPreviewPane.commentComposer.placeholder`),value:e,onChange:e=>o(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:a,children:l(`projectPreviewPane.commentComposer.cancel`)}),(0,Z.jsx)(J,{type:`button`,size:`sm`,disabled:n,onClick:i,children:l(r===`edit`?`projectPreviewPane.commentComposer.save`:`projectPreviewPane.commentComposer.add`)})]})]})]})})},cC=({project:e,mode:t,status:n,viewportPreset:r,zoom:i,activeRun:a=null,reviewCapability:o=null,isStoppingActiveRun:s=!1,onHide:c,onStopActiveRun:l=()=>{},onToggleExpanded:u,onViewportPresetChange:d,onZoomChange:f})=>{let{t:p}=ht(`common`),m=(0,X.useRef)(null),h=(0,X.useRef)(null),g=(0,X.useRef)(null),_=(0,X.useRef)(null),v=(0,X.useRef)(null),y=(0,X.useRef)(null),b=(0,X.useRef)(null),x=(0,X.useRef)(!1),S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useRef)(null),[T,E]=(0,X.useState)(0),[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(``),[F,I]=(0,X.useState)({width:IS,height:LS}),[L,R]=(0,X.useState)([]),[z,B]=(0,X.useState)(!1),[V,ee]=(0,X.useState)(!1),[te,H]=(0,X.useState)(!1),[ne,U]=(0,X.useState)(``),[re,ie]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(!1),[se,ce]=(0,X.useState)(!1),le=(0,X.useMemo)(()=>n?.proxy_url??null,[n?.proxy_url]),ue=(0,X.useMemo)(()=>{if(!le)return`*`;try{return new URL(le).origin}catch{return`*`}},[le]),de=(0,X.useMemo)(()=>n?.detected_url??n?.proxy_url??null,[n?.detected_url,n?.proxy_url]),fe=r===`responsive`?null:MS[r],pe=(0,X.useMemo)(()=>[{value:`responsive`,label:p(`projectPreviewPane.presets.responsive`)},{value:`phone`,label:p(`projectPreviewPane.presets.phone`)},{value:`tablet`,label:p(`projectPreviewPane.presets.tablet`)},{value:`laptop`,label:p(`projectPreviewPane.presets.laptop`)}],[p]),me=pe.find(e=>e.value===r)?.label??p(`projectPreviewPane.presets.responsive`),G=NS.findIndex(e=>e===i),he=r===`responsive`,ge=!he&&G>0,_e=!he&&G>=0&&G<NS.length-1,ve=t===`expanded`,{mode:be,ref:xe}=ng({compactAt:ve?860:700,tightAt:ve?680:520}),Se=a!==null,Ce=L.length,we=(0,X.useMemo)(()=>GS(o),[o]),K=(0,X.useMemo)(()=>Sg({projectId:e.id,reviewCapabilityContextKey:we}),[e.id,we]),Te=(0,X.useMemo)(()=>k?qS(k.anchorRect,F):null,[F,k]),Ee=(0,X.useMemo)(()=>WS({previewUrl:le,reviewCapability:o,status:n,t:p}),[le,o,n,p]),De=!!o?.submitPrompt&&Ce>0&&!V&&!re,Oe=ae?`compact`:`full`,ke=j?`edit`:`add`,Ae=(0,X.useMemo)(()=>oC(o,p),[o,p]),je=!!o?.target,Me=o?.promptMode??null,Ne=!!o?.submitPrompt&&!re&&!V,Pe=(0,X.useMemo)(()=>L.map(e=>({id:e.id,pagePath:e.pagePath,selectorHint:e.selectorHint})),[L]),Ie=(0,X.useCallback)(e=>{_.current=e,xe(e)},[xe]),Le=(0,X.useCallback)(()=>{let e=m.current;if(e)try{e.src=`about:blank`}catch{}},[]),Re=(0,X.useCallback)(e=>{m.current?.contentWindow&&m.current.contentWindow.postMessage({source:FS,...e},ue)},[ue]),q=(0,X.useCallback)(()=>{Re({type:`sync-comments`,comments:Pe})},[Pe,Re]),ze=(0,X.useCallback)(e=>L.find(t=>$S(e,t))??null,[L]),Be=(0,X.useCallback)(()=>{A(null),M(null),P(``),Re({type:`clear-selection`})},[Re]),Ve=(0,X.useCallback)((e={})=>{let{resetIframe:t=!1,bumpIframeKey:n=!1}=e;O(!1),A(null),M(null),P(``),B(!1),Re({type:`clear-selection`}),Re({type:`set-enabled`,enabled:!1}),t&&(Le(),n&&E(e=>e+1))},[Le,Re]),He=(0,X.useCallback)(()=>{Ve()},[Ve]),Ue=(0,X.useCallback)(()=>{Ve(),R([])},[Ve]);(0,X.useEffect)(()=>{Ee!==null&&D&&He()},[He,Ee,D]),(0,X.useEffect)(()=>{let e=Tg(K);R(t=>wg(t,e)?t:e)},[K]),(0,X.useEffect)(()=>{Eg({contextKey:K,drafts:L})},[L,K]),(0,X.useEffect)(()=>{q()},[q]),(0,X.useEffect)(()=>{x.current=D},[D]),(0,X.useEffect)(()=>{S.current=k},[k]),(0,X.useEffect)(()=>{L.length>0||B(!1)},[L.length]),(0,X.useEffect)(()=>{ve||H(!1)},[ve]),(0,X.useEffect)(()=>{je||H(!1)},[je]),(0,X.useEffect)(()=>{U(``),ie(!1)},[we]),(0,X.useEffect)(()=>{let e=g.current;if(!e||!ve||!te)return;let t=requestAnimationFrame(()=>{e.focus(),Ag(e)});return()=>{cancelAnimationFrame(t)}},[ve,te]),(0,X.useEffect)(()=>{let e=g.current;!e||!ve||!te||Ag(e)},[ve,te,ne]);let We=(0,X.useRef)({contextKey:a?.context_key??null,previewUrl:le,state:n?.state??null});(0,X.useEffect)(()=>{let e=We.current,t={contextKey:a?.context_key??null,previewUrl:le,state:n?.state??null},r=e.contextKey!==null&&e.contextKey!==t.contextKey,i=e.previewUrl!==null&&e.previewUrl!==t.previewUrl,o=e.state===`ready`&&t.state!==`ready`;(r||i||o)&&Ve({resetIframe:!0,bumpIframeKey:r||i}),We.current=t},[a?.context_key,Ve,le,n?.state]),(0,X.useEffect)(()=>()=>{Le()},[Le]),(0,X.useLayoutEffect)(()=>{let e=_.current,t=v.current,n=y.current,r=b.current;if(!e||!t||!n||!r)return;let i=()=>{let i=Math.round(e.getBoundingClientRect().width),a=Math.round(r.getBoundingClientRect().width),o=Array.from(t.children).filter(e=>e instanceof HTMLElement),s=o.reduce((e,t)=>t===n?e:e+Math.round(t.getBoundingClientRect().width),0),c=eC(n,HS),l=s+c+Math.max(0,o.length-1)*VS;if(i<=0||a<=0||c<=0){let e=be!==`wide`,t=be===`tight`;oe(t=>t===e?t:e),ce(e=>e===t?e:t);return}ae?w.current=a:C.current=a;let u=a,d=C.current??u,f=w.current??u,p=Math.max(0,i-d-BS),m=Math.max(0,i-f-BS),h=l>p,g=h&&w.current!==null&&l>m;oe(e=>e===h?e:h),ce(e=>e===g?e:g)};if(i(),typeof ResizeObserver!=`function`)return;let a=new ResizeObserver(()=>{i()});return a.observe(e),a.observe(t),a.observe(n),a.observe(r),Array.from(t.children).forEach(e=>{e instanceof HTMLElement&&a.observe(e)}),Array.from(n.children).forEach(e=>{e instanceof HTMLElement&&a.observe(e)}),()=>{a.disconnect()}},[be,ae]),(0,X.useLayoutEffect)(()=>{if(!k||!h.current)return;let e=()=>{if(!h.current)return;let e=h.current.getBoundingClientRect(),t=Math.max(IS,Math.ceil(e.width)||IS),n=Math.max(1,window.innerHeight-zS*2),r=Math.ceil(e.height)||LS,i=Math.min(r,n);I(e=>e.width===t&&e.height===i?e:{width:t,height:i})};e();let t=typeof ResizeObserver>`u`?null:new ResizeObserver(()=>{e()});return t?.observe(h.current),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t?.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[N,k]),(0,X.useEffect)(()=>{let e=e=>{let t=e.source===m.current?.contentWindow,n=ue!==`*`&&e.origin===ue;if(!t&&!n||!e.data||typeof e.data!=`object`)return;let r=e.data;if(r.source!==PS)return;let i=r.type;if(i!==`element-selected`&&i!==`comment-marker-clicked`||i===`element-selected`&&(!x.current||!m.current)||!m.current||i===`element-selected`&&S.current)return;let a=r.payload;if(!a||typeof a!=`object`)return;let o=a,s=ze(o);A({...o,anchorRect:KS(m.current,o)}),M(s?.id??null),P(s?.comment??``)};return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e)}},[ze,ue]);let Ge=(0,X.useCallback)(()=>{A(null),M(null),P(``),Re({type:`clear-selection`}),Re({type:`sync-comments`,comments:Pe}),D&&Ee===null&&Re({type:`set-enabled`,enabled:!0})},[Pe,Re,Ee,D]),Ke=(0,X.useCallback)(()=>{if(Ee===null){if(D){He();return}O(!0),Re({type:`set-enabled`,enabled:!0})}},[He,Re,Ee,D]),qe=(0,X.useCallback)(()=>{Ve(),E(e=>e+1)},[Ve]),Je=(0,X.useCallback)(()=>{Ve({resetIframe:!0}),c()},[Ve,c]),Ye=(0,X.useCallback)(()=>{Ve({resetIframe:!0,bumpIframeKey:!0}),l()},[Ve,l]),Xe=(0,X.useCallback)(()=>{if(!k)return;let e=N.trim();e&&(R(t=>{let n=t.find(e=>e.id===j||$S(k,e)),r={id:n?.id??US(),pagePath:k.pagePath,pageUrl:k.pageUrl,elementLabel:k.elementLabel,selectorHint:k.selectorHint,textSnippet:k.textSnippet,href:k.href,src:k.src,comment:e};return n?t.map(e=>e.id===n.id?r:e):[...t,r]}),Be())},[Be,N,j,k]),Ze=(0,X.useCallback)(e=>{j===e&&Be(),R(t=>t.filter(t=>t.id!==e))},[Be,j]),Y=(0,X.useCallback)(async()=>{if(!(!o?.submitPrompt||!De)){ee(!0);try{await o.submitPrompt(jS({drafts:[],findings:[],githubComments:[],previewComments:L})),Ue(),Q.success(p(`projectPreviewPane.toasts.fixesSubmitted`),{id:`preview-review-submit-success`})}catch(e){Q.error(e instanceof Error?e.message:p(`projectPreviewPane.toasts.fixesError`),{id:`preview-review-submit-error`})}finally{ee(!1)}}},[De,L,Ue,o,p]),Qe=(0,X.useCallback)(async()=>{if(!o?.submitPrompt||!Ne)return;let e=ne.trim();if(e){ie(!0);try{await o.submitPrompt(e),U(``),Q.success(p(`projectPreviewPane.prompt.sent`),{id:`preview-prompt-submit-success`})}catch(e){Q.error(e instanceof Error?e.message:p(`projectPreviewPane.prompt.sendError`),{id:`preview-prompt-submit-error`})}finally{ie(!1)}}},[Ne,ne,o,p]),$e=(0,X.useCallback)(e=>{e.key!==`Enter`||e.shiftKey||!Ne||!ne.trim()||(e.preventDefault(),Qe())},[Ne,Qe,ne]),et=n?n.state===`ready`?le?(0,Z.jsx)(nC,{iframeKey:T,iframeRef:m,iframeSrc:le,onLoad:Ge,preset:fe,zoom:i}):(0,Z.jsx)(tC,{title:p(`projectPreviewPane.states.readyMissingUrlTitle`),description:p(`projectPreviewPane.states.readyMissingUrlDescription`)}):n.state===`detecting`?(0,Z.jsx)(tC,{title:p(`projectPreviewPane.states.detectingTitle`),description:n.message??p(`projectPreviewPane.states.detectingDescription`),showSpinner:!0}):n.state===`unsupported`?(0,Z.jsx)(tC,{title:p(`projectPreviewPane.states.unsupportedTitle`),description:n.message??p(`projectPreviewPane.states.unsupportedDescription`)}):n.state===`error`?(0,Z.jsx)(tC,{title:p(`projectPreviewPane.states.errorTitle`),description:n.message??p(`projectPreviewPane.states.errorDescription`)}):(0,Z.jsx)(tC,{title:p(`projectPreviewPane.states.idleTitle`),description:n.message??p(`projectPreviewPane.states.idleDescription`)}):(0,Z.jsx)(tC,{title:p(`projectPreviewPane.states.loadingTitle`),description:p(`projectPreviewPane.states.loadingDescription`),showSpinner:!0});return(0,Z.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col overflow-hidden bg-[#11131a] ${ve?`rounded-2xl border border-border/70 shadow-2xl shadow-black/50`:``}`,children:[(0,Z.jsxs)(`div`,{ref:Ie,"data-responsive-mode":be,"data-testid":`project-preview-header`,className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-3 gap-y-2 border-b border-border/70 px-3 py-3`,children:[(0,Z.jsxs)(`div`,{ref:v,"data-testid":`preview-header-flow`,className:W(`flex min-w-0 items-center gap-2`,se?`flex-wrap`:`flex-nowrap`),children:[(0,Z.jsx)(Ou,{label:``,triggerLabel:me,triggerAriaLabel:p(`projectPreviewPane.toolbar.viewportPresetAriaLabel`),selectId:`preview-viewport-preset`,className:`w-[10.5rem] max-w-full shrink-0`,triggerClassName:`h-8 rounded-lg border-border/70 bg-background/70 px-2.5 text-xs`,contentClassName:`min-w-[10.5rem]`,groups:[{label:``,options:pe}],isSelected:e=>r===e,onSelect:e=>{(e===`responsive`||e===`phone`||e===`tablet`||e===`laptop`)&&d(e)}}),(0,Z.jsxs)(`div`,{"data-testid":`preview-zoom-controls`,className:`flex shrink-0 items-center gap-1 rounded-lg border border-border/70 bg-background/50 p-1`,children:[(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,disabled:!ge,className:`h-6 px-2 text-xs`,onClick:()=>{G>0&&f(NS[G-1]??i)},children:`-`}),(0,Z.jsxs)(`span`,{className:`min-w-12 text-center text-xs text-muted-foreground`,children:[Math.round(i*100),`%`]}),(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,disabled:!_e,className:`h-6 px-2 text-xs`,onClick:()=>{G>=0&&G<NS.length-1&&f(NS[G+1]??i)},children:`+`})]}),(0,Z.jsxs)(`div`,{ref:y,"data-testid":`preview-action-chunk`,"data-action-chunk-wrapped":se?`true`:`false`,className:W(`flex shrink-0 items-center gap-2`,se&&`basis-full justify-start`),children:[(0,Z.jsx)(rC,{type:`button`,"aria-label":p(`projectPreviewPane.toolbar.reloadAriaLabel`),tooltip:p(`projectPreviewPane.toolbar.reloadTooltip`),size:`icon-sm`,variant:`outline`,className:`h-8 w-8`,onClick:qe,children:(0,Z.jsx)(Gm,{className:`h-4 w-4`})}),(0,Z.jsx)(rC,{type:`button`,"aria-label":p(`projectPreviewPane.toolbar.openNewTabAriaLabel`),tooltip:p(`projectPreviewPane.toolbar.openNewTabTooltip`),size:`icon-sm`,variant:`outline`,className:`h-8 w-8`,disabled:!de,onClick:()=>{de&&window.open(de,`_blank`,`noopener,noreferrer`)},children:(0,Z.jsx)(yg,{className:`h-4 w-4`})}),(0,Z.jsx)(rC,{type:`button`,"aria-label":p(`projectPreviewPane.toolbar.toggleSelectionAriaLabel`),"aria-pressed":D,"data-testid":`preview-selection-toggle`,tooltip:Ee??p(D?`projectPreviewPane.selection.disableMode`:`projectPreviewPane.selection.enableMode`),size:`icon-sm`,variant:`outline`,className:D?`h-8 w-8 border-sky-500 bg-sky-500 text-white hover:bg-sky-600 hover:text-white`:`h-8 w-8`,disabled:Ee!==null,onClick:Ke,children:(0,Z.jsx)(bg,{className:`h-4 w-4`})}),Se&&(0,Z.jsxs)(J,{type:`button`,"aria-label":p(`projectPreviewPane.toolbar.stopRunAriaLabel`),variant:`destructive`,size:`sm`,className:`h-8 gap-2 px-3`,disabled:s,onClick:Ye,children:[s?(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Zu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:p(s?`projectPreviewPane.toolbar.stopping`:`projectPreviewPane.toolbar.stop`)})]})]})]}),(0,Z.jsxs)(`div`,{ref:b,"data-testid":`preview-anchor-actions`,className:`flex shrink-0 items-center gap-2 justify-self-end`,children:[ve&&je?(0,Z.jsxs)(J,{type:`button`,size:`sm`,variant:`outline`,"aria-label":p(`projectPreviewPane.prompt.toggleAriaLabel`),"aria-pressed":te,"data-testid":`preview-prompt-toggle`,className:W(`h-8 gap-2 px-3`,te&&`border-sky-500 bg-sky-500 text-white hover:bg-sky-600 hover:text-white`),onClick:()=>{H(e=>!e)},children:[(0,Z.jsx)(vg,{className:`h-4 w-4`}),p(`projectPreviewPane.prompt.button`)]}):null,(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(aC,{isOpen:z,canSendReview:De,comments:L,triggerMode:Oe,disabledReason:o?.disabledReason,isSubmittingReview:V,onOpenChange:B,onRemoveComment:Ze,onClearPendingFixes:Ue,onSubmitReview:()=>{Y()}})}),(0,Z.jsx)(rC,{type:`button`,"aria-label":p(ve?`projectPreviewPane.toolbar.collapseAriaLabel`:`projectPreviewPane.toolbar.expandAriaLabel`),tooltip:p(ve?`projectPreviewPane.toolbar.collapseTooltip`:`projectPreviewPane.toolbar.expandTooltip`),size:`icon-sm`,variant:`outline`,className:`h-8 w-8`,onClick:u,children:ve?(0,Z.jsx)(Pm,{className:`h-4 w-4`}):(0,Z.jsx)(Fm,{className:`h-4 w-4`})}),(0,Z.jsx)(rC,{type:`button`,"aria-label":p(`projectPreviewPane.toolbar.closeAriaLabel`),tooltip:p(`projectPreviewPane.toolbar.closeTooltip`),variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-foreground`,onClick:Je,children:(0,Z.jsx)(Fe,{className:`h-4 w-4`})})]})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:et}),ve&&je&&te?(0,Z.jsx)(`div`,{"data-testid":`preview-prompt-overlay`,className:`pointer-events-none absolute inset-x-0 bottom-6 z-[80] flex justify-center px-4`,children:(0,Z.jsxs)(`div`,{className:`pointer-events-auto flex w-full max-w-[36rem] flex-col gap-3`,children:[o?.promptComposerControls?(0,Z.jsx)(`div`,{className:`flex items-center justify-start`,children:o.promptComposerControls}):null,(0,Z.jsx)(_g,{projectId:e.id,value:ne,placeholder:Ae,disabled:re,isSubmitDisabled:!Ne,isSending:re,disabledReason:o?.disabledReason??void 0,onValueChange:U,onKeyDown:$e,onSubmit:()=>{Qe()},textareaRef:g,composerInlineControls:o?.promptComposerInlineControls??null,composerTheme:Me??`default`,composerSize:`compact-on-laptop`,shellClassName:`w-full shadow-[0_22px_56px_rgba(0,0,0,0.42)] backdrop-blur supports-[backdrop-filter]:bg-card/80`})]})}):null,k&&Te&&(0,Z.jsx)(sC,{comment:N,composerRef:h,disabled:N.trim().length===0,mode:ke,onAddComment:Xe,onCancel:Be,onCommentChange:P,position:Te,target:k})]})},lC=(e,t)=>x(s(`/projects/${e}/chat-sessions`),{signal:t,fallbackErrorMessage:`Unable to load chat sessions right now.`}),uC=(e,t)=>x(s(`/projects/${e}/chat-sessions`),{method:`POST`,body:t,fallbackErrorMessage:`Unable to create a chat session right now.`}),dC=(e,t,n)=>x(s(`/projects/${e}/chat-sessions/${t}`),{signal:n,fallbackErrorMessage:`Unable to load the chat session right now.`}),fC=(e,t,n)=>x(s(`/projects/${e}/chat-sessions/${t}`),{method:`PATCH`,body:n,fallbackErrorMessage:`Unable to update the chat session right now.`}),pC=(e,t,n)=>x(s(`/projects/${e}/chat-sessions/${t}/messages`),{method:`POST`,body:n,fallbackErrorMessage:`Unable to send the chat prompt right now.`}),mC=async(e,t,n)=>{let r=new FormData;for(let e of n)r.append(`files`,e);let i=await fetch(s(`/projects/${e}/chat-sessions/${t}/attachments`),{method:`POST`,body:r});if(!i.ok)throw new we(await D(i,`Unable to upload images right now.`),i.status);return await i.json()},hC=(e,t,n)=>x(s(`/projects/${e}/chat-sessions/${t}/attachments/${n}`),{method:`DELETE`,fallbackErrorMessage:`Unable to remove the image right now.`}),gC=(e,t)=>x(s(`/projects/${e}/chat-sessions/${t}/stop`),{method:`POST`,fallbackErrorMessage:`Unable to interrupt the chat response right now.`}),_C=(e,t)=>x(s(`/projects/${e}/chat-sessions/${t}`),{method:`DELETE`,fallbackErrorMessage:`Unable to delete the chat session right now.`}),vC=(e,t)=>x(s(`/projects/${e}/chat-sessions/${t}/diff`),{fallbackErrorMessage:`Unable to load the chat diff right now.`}),yC=(e,t)=>x(s(`/projects/${e}/chat-sessions/${t}/git-status`),{fallbackErrorMessage:`Unable to load the chat git status right now.`}),bC=(e,t,n)=>x(s(`/projects/${e}/chat-sessions/${t}/messages/${n}/create-tickets`),{method:`POST`,fallbackErrorMessage:`Unable to create tickets from the chat proposal right now.`}),xC=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function SC(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function CC(e){return`nodeType`in e}function wC(e){return e?SC(e)?e:CC(e)?e.ownerDocument?.defaultView??window:window:window}function TC(e){let{Document:t}=wC(e);return e instanceof t}function EC(e){return SC(e)?!1:e instanceof wC(e).HTMLElement}function DC(e){return e instanceof wC(e).SVGElement}function OC(e){return e?SC(e)?e.document:CC(e)?TC(e)?e:EC(e)||DC(e)?e.ownerDocument:document:document:document}var kC=xC?X.useLayoutEffect:X.useEffect;function AC(e){let t=(0,X.useRef)(e);return kC(()=>{t.current=e}),(0,X.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function jC(){let e=(0,X.useRef)(null);return[(0,X.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,X.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function MC(e,t){t===void 0&&(t=[e]);let n=(0,X.useRef)(e);return kC(()=>{n.current!==e&&(n.current=e)},t),n}function NC(e,t){let n=(0,X.useRef)();return(0,X.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function PC(e){let t=AC(e),n=(0,X.useRef)(null);return[n,(0,X.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function FC(e){let t=(0,X.useRef)();return(0,X.useEffect)(()=>{t.current=e},[e]),t.current}var IC={};function LC(e,t){return(0,X.useMemo)(()=>{if(t)return t;let n=IC[e]==null?0:IC[e]+1;return IC[e]=n,e+`-`+n},[e,t])}function RC(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var zC=RC(1),BC=RC(-1);function VC(e){return`clientX`in e&&`clientY`in e}function HC(e){if(!e)return!1;let{KeyboardEvent:t}=wC(e.target);return t&&e instanceof t}function UC(e){if(!e)return!1;let{TouchEvent:t}=wC(e.target);return t&&e instanceof t}function WC(e){if(UC(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return VC(e)?{x:e.clientX,y:e.clientY}:null}var GC=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[GC.Translate.toString(e),GC.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),KC=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function qC(e){return e.matches(KC)?e:e.querySelector(KC)}var JC={display:`none`};function YC(e){let{id:t,value:n}=e;return X.createElement(`div`,{id:t,style:JC},n)}function XC(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return X.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function ZC(){let[e,t]=(0,X.useState)(``);return{announce:(0,X.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var QC=(0,X.createContext)(null);function $C(e){let t=(0,X.useContext)(QC);(0,X.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function ew(){let[e]=(0,X.useState)(()=>new Set),t=(0,X.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,X.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var tw={draggable:`
|
|
58
|
+
To pick up a draggable item, press the space bar.
|
|
59
|
+
While dragging, use the arrow keys to move the item.
|
|
60
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
61
|
+
`},nw={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function rw(e){let{announcements:t=nw,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=tw}=e,{announce:a,announcement:o}=ZC(),s=LC(`DndLiveRegion`),[c,l]=(0,X.useState)(!1);if((0,X.useEffect)(()=>{l(!0)},[]),$C((0,X.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=X.createElement(X.Fragment,null,X.createElement(YC,{id:r,value:i.draggable}),X.createElement(XC,{id:s,announcement:o}));return n?(0,$u.createPortal)(u,n):u}var iw;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(iw||={});function aw(){}function ow(e,t){return(0,X.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function sw(){var e=[...arguments];return(0,X.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var cw=Object.freeze({x:0,y:0});function lw(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function uw(e,t){let n=WC(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function dw(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function fw(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function pw(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function mw(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function hw(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var gw=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=hw(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(fw)};function _w(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var vw=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&_w(r,a)){let n=pw(a).reduce((e,t)=>e+lw(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(dw)};function yw(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function bw(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:cw}function xw(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var Sw=xw(1);function Cw(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function ww(e,t,n){let r=Cw(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var Tw={ignoreTransform:!1};function Ew(e,t){t===void 0&&(t=Tw);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=wC(e).getComputedStyle(e);t&&(n=ww(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function Dw(e){return Ew(e,{ignoreTransform:!0})}function Ow(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function kw(e,t){return t===void 0&&(t=wC(e).getComputedStyle(e)),t.position===`fixed`}function Aw(e,t){t===void 0&&(t=wC(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function jw(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(TC(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!EC(i)||DC(i)||n.includes(i))return n;let a=wC(e).getComputedStyle(i);return i!==e&&Aw(i,a)&&n.push(i),kw(i,a)?n:r(i.parentNode)}return e?r(e):n}function Mw(e){let[t]=jw(e,1);return t??null}function Nw(e){return!xC||!e?null:SC(e)?e:CC(e)?TC(e)||e===OC(e).scrollingElement?window:EC(e)?e:null:null}function Pw(e){return SC(e)?e.scrollX:e.scrollLeft}function Fw(e){return SC(e)?e.scrollY:e.scrollTop}function Iw(e){return{x:Pw(e),y:Fw(e)}}var Lw;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Lw||={});function Rw(e){return!xC||!e?!1:e===document.scrollingElement}function zw(e){let t={x:0,y:0},n=Rw(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var Bw={x:.2,y:.2};function Vw(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Bw);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=zw(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Lw.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Lw.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Lw.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Lw.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Hw(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function Uw(e){return e.reduce((e,t)=>zC(e,Iw(t)),cw)}function Ww(e){return e.reduce((e,t)=>e+Pw(t),0)}function Gw(e){return e.reduce((e,t)=>e+Fw(t),0)}function Kw(e,t){if(t===void 0&&(t=Ew),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Mw(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var qw=[[`x`,[`left`,`right`],Ww],[`y`,[`top`,`bottom`],Gw]],Jw=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=jw(t),r=Uw(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of qw)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},Yw=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function Xw(e){let{EventTarget:t}=wC(e);return e instanceof t?e:OC(e)}function Zw(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var Qw;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Qw||={});function $w(e){e.preventDefault()}function eT(e){e.stopPropagation()}var tT;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(tT||={});var nT={start:[tT.Space,tT.Enter],cancel:[tT.Esc],end:[tT.Space,tT.Enter,tT.Tab]},rT=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case tT.Right:return{...n,x:n.x+25};case tT.Left:return{...n,x:n.x-25};case tT.Down:return{...n,y:n.y+25};case tT.Up:return{...n,y:n.y-25}}},iT=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Yw(OC(t)),this.windowListeners=new Yw(wC(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Qw.Resize,this.handleCancel),this.windowListeners.add(Qw.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Qw.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Kw(n),t(cw)}handleKeyDown(e){if(HC(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=nT,coordinateGetter:a=rT,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:cw;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=BC(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=zw(n),p=Hw(n),m={x:Math.min(i===tT.Right?p.right-p.width/2:p.right,Math.max(i===tT.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===tT.Down?p.bottom-p.height/2:p.bottom,Math.max(i===tT.Down?p.top:p.top+p.height/2,u.y))},h=i===tT.Right&&!s||i===tT.Left&&!c,g=i===tT.Down&&!l||i===tT.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===tT.Right&&e<=d.x||i===tT.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===tT.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===tT.Down&&e<=d.y||i===tT.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===tT.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,zC(BC(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};iT.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=nT,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function aT(e){return!!(e&&`distance`in e)}function oT(e){return!!(e&&`delay`in e)}var sT=class{constructor(e,t,n){n===void 0&&(n=Xw(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=OC(i),this.documentListeners=new Yw(this.document),this.listeners=new Yw(n),this.windowListeners=new Yw(wC(i)),this.initialCoordinates=WC(r)??cw,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Qw.Resize,this.handleCancel),this.windowListeners.add(Qw.DragStart,$w),this.windowListeners.add(Qw.VisibilityChange,this.handleCancel),this.windowListeners.add(Qw.ContextMenu,$w),this.documentListeners.add(Qw.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(oT(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(aT(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Qw.Click,eT,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Qw.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=WC(e)??cw,s=BC(n,o);if(!t&&a){if(aT(a)){if(a.tolerance!=null&&Zw(s,a.tolerance))return this.handleCancel();if(Zw(s,a.distance))return this.handleStart()}if(oT(a)&&Zw(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===tT.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},cT={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},lT=class extends sT{constructor(e){let{event:t}=e,n=OC(t.target);super(e,cT,n)}};lT.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var uT={move:{name:`mousemove`},end:{name:`mouseup`}},dT;(function(e){e[e.RightClick=2]=`RightClick`})(dT||={});var fT=class extends sT{constructor(e){super(e,uT,OC(e.event.target))}};fT.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===dT.RightClick?!1:(r?.({event:n}),!0)}}];var pT={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},mT=class extends sT{constructor(e){super(e,pT)}static setup(){return window.addEventListener(pT.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(pT.move.name,e)};function e(){}}};mT.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var hT;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(hT||={});var gT;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(gT||={});function _T(e){let{acceleration:t,activator:n=hT.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=gT.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=yT({delta:d,disabled:!a}),[m,h]=jC(),g=(0,X.useRef)({x:0,y:0}),_=(0,X.useRef)({x:0,y:0}),v=(0,X.useMemo)(()=>{switch(n){case hT.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case hT.DraggableRect:return i}},[n,i,c]),y=(0,X.useRef)(null),b=(0,X.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,X.useMemo)(()=>s===gT.TreeOrder?[...l].reverse():l,[s,l]);(0,X.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=Vw(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var vT={x:{[Lw.Backward]:!1,[Lw.Forward]:!1},y:{[Lw.Backward]:!1,[Lw.Forward]:!1}};function yT(e){let{delta:t,disabled:n}=e,r=FC(t);return NC(e=>{if(n||!r||!e)return vT;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Lw.Backward]:e.x[Lw.Backward]||i.x===-1,[Lw.Forward]:e.x[Lw.Forward]||i.x===1},y:{[Lw.Backward]:e.y[Lw.Backward]||i.y===-1,[Lw.Forward]:e.y[Lw.Forward]||i.y===1}}},[n,t,r])}function bT(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return NC(e=>t==null?null:r??e??null,[r,t])}function xT(e,t){return(0,X.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var ST;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(ST||={});var CT;(function(e){e.Optimized=`optimized`})(CT||={});var wT=new Map;function TT(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,X.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,X.useRef)(e),d=g(),f=MC(d),p=(0,X.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,X.useRef)(null),h=NC(t=>{if(d&&!n)return wT;if(!t||t===wT||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Jw(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,X.useEffect)(()=>{u.current=e},[e]),(0,X.useEffect)(()=>{d||p()},[n,d]),(0,X.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,X.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case ST.Always:return!1;case ST.BeforeDragging:return n;default:return!n}}}function ET(e,t){return NC(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function DT(e,t){return ET(e,t)}function OT(e){let{callback:t,disabled:n}=e,r=AC(t),i=(0,X.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,X.useEffect)(()=>()=>i?.disconnect(),[i]),i}function kT(e){let{callback:t,disabled:n}=e,r=AC(t),i=(0,X.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,X.useEffect)(()=>()=>i?.disconnect(),[i]),i}function AT(e){return new Jw(Ew(e),e)}function jT(e,t,n){t===void 0&&(t=AT);let[r,i]=(0,X.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=OT({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=kT({callback:a});return kC(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function MT(e){return bw(e,ET(e))}var NT=[];function PT(e){let t=(0,X.useRef)(e),n=NC(n=>e?n&&n!==NT&&e&&t.current&&e.parentNode===t.current.parentNode?n:jw(e):NT,[e]);return(0,X.useEffect)(()=>{t.current=e},[e]),n}function FT(e){let[t,n]=(0,X.useState)(null),r=(0,X.useRef)(e),i=(0,X.useCallback)(e=>{let t=Nw(e.target);t&&n(e=>e?(e.set(t,Iw(t)),new Map(e)):null)},[]);return(0,X.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Nw(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Iw(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{Nw(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,X.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>zC(e,t),cw):Uw(e):cw,[e,t])}function IT(e,t){t===void 0&&(t=[]);let n=(0,X.useRef)(null);return(0,X.useEffect)(()=>{n.current=null},t),(0,X.useEffect)(()=>{let t=e!==cw;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?BC(e,n.current):cw}function LT(e){(0,X.useEffect)(()=>{if(!xC)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function RT(e,t){return(0,X.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function zT(e){return(0,X.useMemo)(()=>e?Ow(e):null,[e])}var BT=[];function VT(e,t){t===void 0&&(t=Ew);let[n]=e,r=zT(n?wC(n):null),[i,a]=(0,X.useState)(BT);function o(){a(()=>e.length?e.map(e=>Rw(e)?r:new Jw(t(e),e)):BT)}let s=kT({callback:o});return kC(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function HT(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return EC(t)?t:e}function UT(e){let{measure:t}=e,[n,r]=(0,X.useState)(null),i=kT({callback:(0,X.useCallback)(e=>{for(let{target:n}of e)if(EC(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=PC((0,X.useCallback)(e=>{let n=HT(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,X.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var WT=[{sensor:lT,options:{}},{sensor:iT,options:{}}],GT={current:{}},KT={draggable:{measure:Dw},droppable:{measure:Dw,strategy:ST.WhileDragging,frequency:CT.Optimized},dragOverlay:{measure:Ew}},qT=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},JT={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new qT,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:aw},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:KT,measureDroppableContainers:aw,windowRect:null,measuringScheduled:!1},YT={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:aw,draggableNodes:new Map,over:null,measureDroppableContainers:aw},XT=(0,X.createContext)(YT),ZT=(0,X.createContext)(JT);function QT(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new qT}}}function $T(e,t){switch(t.type){case iw.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case iw.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case iw.DragEnd:case iw.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case iw.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new qT(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case iw.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new qT(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case iw.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new qT(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function eE(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,X.useContext)(XT),a=FC(r),o=FC(n?.id);return(0,X.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!HC(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=qC(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function tE(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function nE(e){return(0,X.useMemo)(()=>({draggable:{...KT.draggable,...e?.draggable},droppable:{...KT.droppable,...e?.droppable},dragOverlay:{...KT.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function rE(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,X.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;kC(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=bw(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=Mw(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var iE=(0,X.createContext)({...cw,scaleX:1,scaleY:1}),aE;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(aE||={});var oE=(0,X.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=WT,collisionDetection:o=gw,measuring:s,modifiers:c,...l}=e,[u,d]=(0,X.useReducer)($T,void 0,QT),[f,p]=ew(),[m,h]=(0,X.useState)(aE.Uninitialized),g=m===aE.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,X.useRef)({initial:null,translated:null}),C=(0,X.useMemo)(()=>_==null?null:{id:_,data:x?.data??GT,rect:S},[_,x]),w=(0,X.useRef)(null),[T,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(null),k=MC(l,Object.values(l)),A=LC(`DndDescribedBy`,t),j=(0,X.useMemo)(()=>b.getEnabled(),[b]),M=nE(s),{droppableRects:N,measureDroppableContainers:P,measuringScheduled:F}=TT(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),I=bT(v,_),L=(0,X.useMemo)(()=>D?WC(D):null,[D]),R=Ce(),z=DT(I,M.draggable.measure);rE({activeNode:_==null?null:v.get(_),config:R.layoutShiftCompensation,initialRect:z,measure:M.draggable.measure});let B=jT(I,M.draggable.measure,z),V=jT(I?I.parentElement:null),ee=(0,X.useRef)({activatorEvent:null,active:null,activeNode:I,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),te=b.getNodeFor(ee.current.over?.id),H=UT({measure:M.dragOverlay.measure}),ne=H.nodeRef.current??I,U=g?H.rect??B:null,re=!!(H.nodeRef.current&&H.rect),ie=MT(re?null:B),ae=zT(ne?wC(ne):null),oe=PT(g?te??I:null),se=VT(oe),ce=tE(c,{transform:{x:y.x-ie.x,y:y.y-ie.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:B,containerNodeRect:V,draggingNodeRect:U,over:ee.current.over,overlayNodeRect:H.rect,scrollableAncestors:oe,scrollableAncestorRects:se,windowRect:ae}),le=L?zC(L,y):null,ue=FT(oe),de=IT(ue),W=IT(ue,[B]),fe=zC(ce,de),pe=U?Sw(U,ce):null,me=C&&pe?o({active:C,collisionRect:pe,droppableRects:N,droppableContainers:j,pointerCoordinates:le}):null,G=mw(me,`id`),[he,ge]=(0,X.useState)(null),_e=yw(re?ce:zC(ce,W),he?.rect??null,B),ve=(0,X.useRef)(null),ye=(0,X.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;ve.current=new n({active:w.current,activeNode:i,event:a,options:r,context:ee,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,$u.unstable_batchedUpdates)(()=>{r?.(i),h(aE.Initializing),d({type:iw.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(ve.current),O(a)})},onMove(e){d({type:iw.DragMove,coordinates:e})},onEnd:o(iw.DragEnd),onCancel:o(iw.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=ee.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===iw.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=iw.DragCancel)}w.current=null,(0,$u.unstable_batchedUpdates)(()=>{d({type:e}),h(aE.Uninitialized),ge(null),E(null),O(null),ve.current=null;let t=e===iw.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),be=xT(a,(0,X.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,ye(n,t))},[v,ye]));LT(a),kC(()=>{B&&m===aE.Initializing&&h(aE.Initialized)},[B,m]),(0,X.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=ee.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:fe.x,y:fe.y},over:i};(0,$u.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[fe.x,fe.y]),(0,X.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=ee.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(G),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,$u.unstable_batchedUpdates)(()=>{ge(s),a?.(c),f({type:`onDragOver`,event:c})})},[G]),kC(()=>{ee.current={activatorEvent:D,active:C,activeNode:I,collisionRect:pe,collisions:me,droppableRects:N,draggableNodes:v,draggingNode:ne,draggingNodeRect:U,droppableContainers:b,over:he,scrollableAncestors:oe,scrollAdjustedTranslate:fe},S.current={initial:U,translated:pe}},[C,I,me,pe,v,ne,U,N,b,he,oe,fe]),_T({...R,delta:y,draggingRect:pe,pointerCoordinates:le,scrollableAncestors:oe,scrollableAncestorRects:se});let xe=(0,X.useMemo)(()=>({active:C,activeNode:I,activeNodeRect:B,activatorEvent:D,collisions:me,containerNodeRect:V,dragOverlay:H,draggableNodes:v,droppableContainers:b,droppableRects:N,over:he,measureDroppableContainers:P,scrollableAncestors:oe,scrollableAncestorRects:se,measuringConfiguration:M,measuringScheduled:F,windowRect:ae}),[C,I,B,D,me,V,H,v,b,N,he,P,oe,se,M,F,ae]),Se=(0,X.useMemo)(()=>({activatorEvent:D,activators:be,active:C,activeNodeRect:B,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:he,measureDroppableContainers:P}),[D,be,C,B,d,A,v,he,P]);return X.createElement(QC.Provider,{value:p},X.createElement(XT.Provider,{value:Se},X.createElement(ZT.Provider,{value:xe},X.createElement(iE.Provider,{value:_e},i)),X.createElement(eE,{disabled:n?.restoreFocus===!1})),X.createElement(rw,{...n,hiddenTextDescribedById:A}));function Ce(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),sE=(0,X.createContext)(null),cE=`button`,lE=`Draggable`;function uE(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=LC(lE),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,X.useContext)(XT),{role:p=cE,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,X.useContext)(g?iE:sE),[v,y]=PC(),[b,x]=PC(),S=RT(o,t),C=MC(n);return kC(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,X.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===cE?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function dE(){return(0,X.useContext)(ZT)}var fE=`Droppable`,pE={timeout:25};function mE(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=LC(fE),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,X.useContext)(XT),u=(0,X.useRef)({disabled:n}),d=(0,X.useRef)(!1),f=(0,X.useRef)(null),p=(0,X.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...pE,...i},_=MC(h??r),v=kT({callback:(0,X.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=PC((0,X.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=MC(t);return(0,X.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,X.useEffect)(()=>(s({type:iw.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:iw.UnregisterDroppable,key:a,id:r})),[r]),(0,X.useEffect)(()=>{n!==u.current.disabled&&(s({type:iw.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function hE(e){let{animation:t,children:n}=e,[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(null),s=FC(n);return!n&&!r&&s&&i(s),kC(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),X.createElement(X.Fragment,null,n,r?(0,X.cloneElement)(r,{ref:o}):null)}var gE={x:0,y:0,scaleX:1,scaleY:1};function _E(e){let{children:t}=e;return X.createElement(XT.Provider,{value:YT},X.createElement(iE.Provider,{value:gE},t))}var vE={position:`fixed`,touchAction:`none`},yE=e=>HC(e)?`transform 250ms ease`:void 0,bE=(0,X.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=yE}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...vE,width:s.width,height:s.height,top:s.top,left:s.left,transform:GC.Transform.toString(d),transformOrigin:i&&r?uw(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return X.createElement(n,{className:o,style:f,ref:t},a)}),xE={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:GC.Transform.toString(t)},{transform:GC.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function SE(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return AC((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=HT(a);if(!c)return;let{transform:l}=wC(a).getComputedStyle(a),u=Cw(l);if(!u)return;let d=typeof t==`function`?t:CE(t);return Kw(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function CE(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...xE,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var wE=0;function TE(e){return(0,X.useMemo)(()=>{if(e!=null)return wE++,wE},[e])}var EE=X.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=dE(),S=(0,X.useContext)(iE),C=TE(d?.id),w=tE(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=ET(f),E=SE({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return X.createElement(_E,null,X.createElement(hE,{animation:E},d&&C?X.createElement(bE,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))}),DE=({className:e,...t})=>(0,Z.jsx)(`kbd`,{"data-slot":`kbd`,className:W(`inline-flex items-center justify-center rounded-md border border-border/60 bg-muted/50 px-1.5 py-0.5 text-[10px] leading-none font-medium text-muted-foreground select-none shadow-xs`,e),...t}),OE=async(e,t,n=null)=>{let r=new URLSearchParams({tool:e});n&&r.set(`project_id`,n);let i=await x(s(`/skills?${r.toString()}`),{signal:t,cache:`no-store`});return Array.isArray(i)?i.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.name==`string`&&typeof t.description==`string`}):[]},kE=e=>(0,Z.jsx)(Ga,{"data-slot":`dropdown-menu`,...e}),AE=e=>(0,Z.jsx)(Ka,{"data-slot":`dropdown-menu-trigger`,...e}),jE=({className:e,align:t=`end`,sideOffset:n=6,...r})=>(0,Z.jsx)(qa,{children:(0,Z.jsx)(Ja,{"data-slot":`dropdown-menu-content`,align:t,sideOffset:n,className:W(`z-50 min-w-44 overflow-hidden rounded-xl border border-border bg-popover p-1 text-sm text-popover-foreground shadow-2xl shadow-black/30 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r})}),ME=({className:e,inset:t=!1,...n})=>(0,Z.jsx)(Ya,{"data-slot":`dropdown-menu-item`,"data-inset":t,className:W(`relative flex cursor-default select-none items-center gap-2 rounded-lg px-2.5 py-2 text-sm outline-hidden transition-colors data-[disabled]:opacity-50 data-[disabled]:text-muted-foreground focus:bg-accent focus:text-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...n}),NE={draft:`border-sky-400/30 bg-sky-500/15 text-sky-100`,open:`border-emerald-400/30 bg-emerald-500/15 text-emerald-100`,merged:`border-violet-400/30 bg-violet-500/15 text-violet-100`,closed:`border-slate-400/30 bg-slate-500/15 text-slate-200`},PE={draft:`PR Draft`,open:`PR Open`,merged:`PR Merged`,closed:`PR Closed`},FE=({pullRequest:e,asLink:t=!1,onClick:n,onPointerDown:r,showNumber:i=!1})=>{let a=i?`PR #${e.number} ${e.state}`:PE[e.state],o=(0,Z.jsx)(q,{variant:`outline`,className:NE[e.state],children:a});return t?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex underline underline-offset-2 decoration-current hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,onClick:n,onPointerDown:r,children:o}):o},IE=({className:e})=>(0,Z.jsx)(wc,{"aria-hidden":`true`,className:e}),LE=({className:e})=>(0,Z.jsx)(_c,{"aria-hidden":`true`,className:e}),RE={plan:0,build:1,review:2},zE={plan:`build`,build:`review`},BE=e=>zE[e]??null,VE=e=>e===`plan`?`plan`:e===`build`||e===`review`||e===`done`?`build`:`default`,HE=e=>e.worktree_bundle_id??e.id,UE=e=>e.state===`build`||e.state===`review`&&e.review_follow_up_active===!0,WE=e=>e.parked_at!==null,GE=e=>WE(e)?`done`:e.state,KE=e=>e.is_stale===!0,qE=e=>e?e.files_changed===0&&e.additions===0&&e.deletions===0:!1,JE=(e,t)=>!t||e===`plan`?!1:!(e===`done`&&qE(t)),YE=e=>WE(e)||e.agent_status===`running`?!1:e.state===`build`?e.agent_status===`done`:e.state===`review`,XE=(e,t)=>WE(e)&&e.state===t,ZE=(e,t)=>e.agent_status===`running`?!1:t===`done`?YE(e):!(t!==`trash`&&RE[t]<=RE[e.state]||t===`review`&&(e.state!==`build`||e.agent_status!==`done`)),QE=e=>{let t=BE(e.state);return!t||ZE(e,t)?null:e.state===`build`?e.agent_status===`running`?`Finish the current build before moving to review.`:e.agent_status===`stopped`?`Resume and finish the build before moving to review.`:e.agent_status===`error`?`Retry and finish the build before moving to review.`:`Build must be done before moving to review.`:e.state===`plan`?`Finish planning before moving to build.`:null},$E=(e,t)=>{let n=e.created_at.localeCompare(t.created_at);if(n!==0)return n;let r=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return r===0?e.id.localeCompare(t.id):r},eD=12,tD=e=>({x:e.left+e.width/2,y:e.top+e.height/2}),nD=e=>`${e.blocker_ticket_id}:${e.dependent_ticket_id}`,rD=(e,t)=>e.filter(e=>e.blocker_ticket_id!==t&&e.dependent_ticket_id!==t),iD=(e,t)=>{let n=e.filter(e=>nD(e)!==nD(t));return n.push(t),n.sort((e,t)=>nD(e).localeCompare(nD(t))),n},aD=(e,t,n)=>e.filter(e=>!(e.blocker_ticket_id===t&&e.dependent_ticket_id===n)),oD=(e,t,n)=>{let r=[n],i=new Set;for(;r.length>0;){let n=r.shift();if(!(!n||i.has(n))){if(n===t)return!0;i.add(n);for(let t of e)t.blocker_ticket_id===n&&r.push(t.dependent_ticket_id)}}return!1},sD=(e,t,n)=>t===n?{valid:!1,reason:`self`}:e.some(e=>e.blocker_ticket_id===t&&e.dependent_ticket_id===n)?{valid:!1,reason:`duplicate`}:oD(e,t,n)?{valid:!1,reason:`cycle`}:{valid:!0},cD=e=>e===`self`?`A ticket cannot depend on itself.`:e===`duplicate`?`This dependency already exists.`:`This dependency would create a cycle.`,lD=e=>e?e.build_completed_at!==null&&e.build_completed_at!==void 0||e.state===`review`?!0:e.state===`build`&&e.agent_status===`done`:!1,uD=e=>!e||e.has_worktree===!1?!1:e.run_setup_status===`ready`?!0:lD(e),dD=e=>{if(!(!e||e.has_worktree===!1)){if(e.run_setup_status===`preparing`)return`Setting up worktree...`;if(!uD(e))return`Run unlocks after setup finishes.`}},fD=(e,t,n)=>n.filter(t=>t.dependent_ticket_id===e.id).map(e=>t.get(e.blocker_ticket_id)).filter(e=>!!e&&!lD(e)),pD=(e,t)=>{let n=[e],r=new Set,i=new Set;for(;n.length>0;){let e=n.shift();if(!(!e||r.has(e))){r.add(e);for(let r of t)r.blocker_ticket_id===e&&(i.add(r.dependent_ticket_id),n.push(r.dependent_ticket_id))}}return i},mD=(e,t,n)=>{let r=n.get(t);if(!r){e.push(t);return}let i=!1;for(let a=0;a<e.length;a+=1){let o=n.get(e[a]);if(o&&$E(r,o)<0){e.splice(a,0,t),i=!0;break}}i||e.push(t)},hD=(e,t,n)=>{if(!t.get(e))return[];let r=pD(e,n);if(r.size===0)return[];let i=[e,...r],a=new Set(i),o=new Map,s=new Map;for(let e of i)o.set(e,0),s.set(e,[]);for(let e of n)!a.has(e.blocker_ticket_id)||!a.has(e.dependent_ticket_id)||(s.get(e.blocker_ticket_id)?.push(e.dependent_ticket_id),o.set(e.dependent_ticket_id,(o.get(e.dependent_ticket_id)??0)+1));let c=[];for(let e of i)(o.get(e)??0)===0&&mD(c,e,t);let l=[];for(;c.length>0;){let e=c.shift();if(e){l.push(e);for(let n of s.get(e)??[]){let e=(o.get(n)??0)-1;o.set(n,e),e===0&&mD(c,n,t)}}}return l.map(e=>t.get(e)).filter(e=>!!e)},gD=(e,t,n)=>{let r=hD(e.id,t,n),i=r.filter(e=>!lD(e)),a=r.length>1,o=fD(e,t,n).length>0,s=e.state===`plan`&&a&&!o;return{buildChainOrder:r,pendingBuildChainOrder:i,hasDependents:a,hasOpenBlockers:o,canStartBuildChain:s,isVisibleStartPoint:e.build_chain?.is_root===!0||s,skippedBuildChainCount:r.length-i.length}},_D=(e,t)=>{let n=tD(e),r=tD(t),i=e.left+e.width,a=t.left+t.width,o=e.top+e.height,s=t.top+t.height;return e.left<a&&i>t.left?r.y>=n.y?{start:{x:n.x,y:o-eD},end:{x:r.x,y:t.top+eD}}:{start:{x:n.x,y:e.top+eD},end:{x:r.x,y:s-eD}}:r.x>=n.x?{start:{x:i-eD,y:n.y},end:{x:t.left+eD,y:r.y}}:{start:{x:e.left+eD,y:n.y},end:{x:a-eD,y:r.y}}},vD=(e,t)=>{let n=t.x-e.x,r=t.y-e.y;if(Math.abs(n)>=Math.abs(r)){let r=Math.max(64,Math.abs(n)*.6),i={x:e.x+Math.sign(n||1)*r,y:e.y},a={x:t.x-Math.sign(n||1)*r,y:t.y};return{path:`M ${e.x} ${e.y} C ${i.x} ${i.y}, ${a.x} ${a.y}, ${t.x} ${t.y}`,angle:Math.atan2(t.y-a.y,t.x-a.x)}}let i=Math.max(18,Math.round(Math.abs(r)*.4)),a=Math.max(24,Math.min(36,Math.round(Math.abs(r)*.18+Math.abs(n)*.1))),o=Math.round(a*.35),s=n>=0?1:-1,c={x:e.x+s*a,y:e.y+Math.sign(r||1)*i},l={x:t.x+s*o,y:t.y-Math.sign(r||1)*i};return{path:`M ${e.x} ${e.y} C ${c.x} ${c.y}, ${l.x} ${l.y}, ${t.x} ${t.y}`,angle:Math.atan2(t.y-l.y,t.x-l.x)}},yD=({className:e})=>(0,Z.jsx)(mc,{"aria-hidden":`true`,className:e}),bD=({className:e})=>(0,Z.jsx)(gc,{"aria-hidden":`true`,className:e}),xD=({label:e,className:t})=>(0,Z.jsxs)(q,{className:W(`inline-flex w-fit items-center gap-2 px-3 py-1 text-xs font-medium text-primary-foreground`,t),children:[(0,Z.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-violet-300`}),e]}),SD=({status:e,showBuildGlyph:t=!1})=>{let{t:n}=ht(`common`);return e===null?null:e===`queued`?(0,Z.jsx)(q,{variant:`outline`,children:n(`statusBadge.queued`)}):e===`planning`?(0,Z.jsx)(xD,{label:n(`statusBadge.planning`)}):e===`building`?(0,Z.jsx)(q,{variant:`warning`,children:n(t?`statusBadge.buildingWithGlyph`:`statusBadge.building`)}):e===`reviewing`?(0,Z.jsx)(q,{variant:`warning`,children:n(`statusBadge.reviewing`)}):e===`done`?(0,Z.jsx)(q,{variant:`success`,children:n(`statusBadge.done`)}):e===`error`?(0,Z.jsx)(q,{variant:`destructive`,children:n(`statusBadge.error`)}):(0,Z.jsx)(q,{variant:`warning`,children:n(`statusBadge.stopped`)})},CD=({title:e,stage:t,subjectLabel:n,onConfirm:r,onCancel:i})=>{let{t:a}=ht(`common`);(0,X.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let o=n||a(`cardConfirmUndoModal.defaultSubjectLabel`),s=a(t===`review`?`cardConfirmUndoModal.headingReview`:`cardConfirmUndoModal.headingBuild`),c=a(t===`review`?`cardConfirmUndoModal.descriptionReview`:`cardConfirmUndoModal.descriptionBuild`,{subjectLabel:o});return(0,Z.jsxs)(Af,{onClose:i,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:s}),(0,Z.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,Z.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:c}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(J,{type:`button`,variant:`ghost`,onClick:i,children:a(`cardConfirmUndoModal.cancel`)}),(0,Z.jsx)(J,{type:`button`,variant:`destructive`,onClick:r,children:a(`cardConfirmUndoModal.confirm`)})]})]})},wD=({isRunning:e,isRunPending:t=!1,isStopPending:n=!1,runDisabled:r=!1,runDisabledReason:i,onRun:a,onStop:o,className:s})=>{let{t:c}=ht(`common`);if(e)return o?(0,Z.jsxs)(J,{type:`button`,size:`xs`,variant:`destructive`,disabled:n,"aria-busy":n,"aria-label":c(n?`runControl.stoppingAriaLabel`:`runControl.stopAriaLabel`),title:n?c(`runControl.stoppingTitle`):void 0,className:s,onClick:e=>{e.stopPropagation(),o()},onPointerDown:e=>e.stopPropagation(),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`h-2 w-2 flex-shrink-0 rounded-full bg-emerald-400 animate-pulse`}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`flex w-3.5 justify-center`,children:n?(0,Z.jsx)(ye,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(Zu,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`min-w-[2.25rem] text-left`,children:c(`runControl.stop`)})]}):null;if(!a)return null;let l=c(t?`runControl.startingAriaLabel`:`runControl.runAriaLabel`);return(0,Z.jsxs)(J,{type:`button`,size:`xs`,variant:`secondary`,disabled:t||r,"aria-busy":t,"aria-label":l,title:r?i??c(`runControl.disabledReason`):t?c(`runControl.startingTitle`):void 0,className:W(`bg-sky-700 text-sky-50 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,s),onClick:e=>{e.stopPropagation(),!r&&a()},onPointerDown:e=>e.stopPropagation(),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`h-2 w-2 flex-shrink-0 rounded-full invisible`}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`flex w-3.5 justify-center`,children:t?(0,Z.jsx)(ye,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(Yu,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`min-w-[2.25rem] text-left`,children:c(`runControl.run`)})]})},TD=e=>e.length===0?null:e.some(e=>e.agent_status===`running`)?`reviewing`:e.some(e=>e.agent_status===`error`)?`error`:e.some(e=>e.agent_status===`stopped`)?`stopped`:e.some(e=>e.agent_status===`done`)&&e.every(e=>e.agent_status===null||e.agent_status===`done`)?`done`:e.every(e=>e.agent_status===null)?`queued`:null,ED=(e,{allTickets:t=[],preferBundleReviewStatus:n=!1}={})=>{if(e.parked_at!==null)return null;if(e.state===`plan`){if(e.agent_status===`running`)return`planning`;if(e.agent_status===null)return null;if(e.agent_status===`done`)return`done`;if(e.agent_status===`error`)return`error`;if(e.agent_status===`stopped`)return`stopped`}if(n&&e.worktree_bundle_id){let n=t.filter(t=>t.worktree_bundle_id===e.worktree_bundle_id),r=TD((n.length>0?n:[e]).filter(e=>e.state===`review`));if(r)return r}return e.agent_status===null?`queued`:e.agent_status===`running`?e.state===`review`?`reviewing`:`building`:e.agent_status===`done`?`done`:e.agent_status===`error`?`error`:e.agent_status===`stopped`?`stopped`:null},DD=(e,t)=>{if(t===`done`||e.every(e=>e.parked_at!==null))return null;let n=e.filter(e=>e.state===`review`);if(t===`review`){let e=TD(n);if(e)return e}return n.some(e=>e.agent_status===`running`)?`reviewing`:t===`plan`&&e.some(e=>e.state===`plan`&&e.agent_status===`running`)?`planning`:e.some(e=>e.agent_status===`running`)?`building`:e.some(e=>e.agent_status===`error`)?`error`:e.some(e=>e.agent_status===`stopped`)?`stopped`:e.length>0&&e.every(e=>e.agent_status===`done`)?`done`:e.some(e=>e.state===`build`)?`queued`:null},OD=({bundleName:e,ticketCount:t,onConfirm:n,onCancel:r})=>((0,X.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,Z.jsxs)(Af,{onClose:r,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Delete bundle`}),(0,Z.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,Z.jsxs)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:[`This deletes the `,t,` ticket`,t===1?``:`s`,` `,`currently inside this wrapper.`]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(J,{type:`button`,variant:`ghost`,onClick:r,children:`Cancel`}),(0,Z.jsx)(J,{type:`button`,variant:`destructive`,onClick:n,children:`Delete`})]})]})),kD=e=>e.find(e=>e.state===`review`&&e.undo?.stage===`review`&&e.undo.can_undo)??e.find(e=>e.state===`review`&&e.undo?.stage===`review`)??null,AD=(e,t)=>t?.diff_stats===void 0?e.find(e=>e.diff_stats!==void 0)?.diff_stats:t.diff_stats,jD=e=>e.length>0&&e.every(e=>KE(e)),MD=({group:e,renderTicket:t,runDisabled:n=!1,onStopBuildTicket:r,onResumeBuildTicket:i,onBuildBundle:a,onReviewBundle:o,onUndoBundleReview:s,onRunBundle:c,onStopBundle:l,onParkBundleWrapper:u,onUnparkBundleWrapper:d,bundleActionState:f,onOpenBundleDetails:p,onOpenBundleChanges:m,onOpenBundleTests:h,onOpenBundleIde:g,onRequestBundleRefresh:_,onDeleteBundleWrapper:v,onAddTicketToBundle:y,undoInProgress:b=!1,overlay:x=!1})=>{let{t:S}=ht(`common`),[C,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(!1),{attributes:D,listeners:O,setNodeRef:k,isDragging:A}=uE({id:zd(e),disabled:x||b}),j=(0,X.useMemo)(()=>DD(e.tickets,e.column),[e.column,e.tickets]),M=(0,X.useMemo)(()=>(0,Z.jsx)(SD,{status:j}),[j]),N=e.column===`plan`,P=e.column===`build`&&e.tickets.every(e=>e.agent_status===`done`),F=(0,X.useMemo)(()=>kD(e.tickets),[e.tickets]),I=e.column===`review`&&F!==null,L=F?.undo?.can_undo??!1,R=F?.undo?.reason??void 0,z=f??{build:!1,stopBuild:!1,resumeBuild:!1,review:!1,undoReview:!1,run:!1,stop:!1,followUp:!1},B=z.review||z.followUp,V=e.column===`review`&&!e.tickets.some(e=>e.agent_status===`running`)&&!B&&e.tickets.some(e=>e.can_re_review),ee=V?`Re-run review`:`Review Bundle`,te=e.tickets.find(e=>e.is_running)??e.tickets.find(e=>e.session_id)??e.tickets.find(e=>e.has_worktree)??e.tickets[0],H=(0,X.useMemo)(()=>AD(e.tickets,te),[te,e.tickets]),ne=(0,X.useMemo)(()=>jD(e.tickets),[e.tickets]),U=(0,X.useMemo)(()=>e.column!==`plan`&&H===void 0&&e.tickets.some(e=>e.diff_stats===void 0),[H,e.column,e.tickets]),re=ne||e.column===`done`,ie=e.tickets.some(e=>e.is_running),ae=e.tickets.some(e=>e.has_run_config&&uD(e)),oe=(0,X.useMemo)(()=>[...new Set(e.tickets.map(e=>e.model??``).filter(e=>e.length>0))],[e.tickets]),se=oe.length===1?oe[0]:null,ce=e.tickets.find(e=>UE(e)&&e.agent_status===`running`&&!!e.session_id)??null,le=e.tickets.find(e=>UE(e)&&e.agent_status===`stopped`&&!!e.session_id)??null,ue=ce!==null,de=!ue&&le!==null,W=e.tickets.length>0&&e.tickets.every(e=>ZE(e,`trash`)),fe=e.column!==`done`&&e.tickets.length>0&&e.tickets.every(e=>ZE(e,`done`)),pe=e.column===`done`&&e.tickets.length>0&&e.tickets.every(e=>e.state!==`plan`),me=e.tickets.length===1?`Return to ${e.tickets[0]?.state.charAt(0).toUpperCase()}${e.tickets[0]?.state.slice(1)}`:`Return to original columns`,G=x?`border-violet-400`:re?`border-border/80 hover:border-border`:`border-border hover:border-primary/40`,he=x||b?`pointer-events-none cursor-grabbing shadow-2xl`:`cursor-pointer`,ge=A?`opacity-30`:re?`opacity-90`:`opacity-100`,_e=re?`bg-card/60`:`bg-secondary/60`,ve=re?`rounded-lg border border-border/60 bg-background/25 p-2.5`:`rounded-lg border border-border/60 bg-background/35 p-2.5`,ye=re?`truncate text-sm font-medium text-foreground/70`:`truncate text-sm font-medium text-foreground`,be=re?`text-[11px] text-foreground/55`:`text-[11px] text-muted-foreground`,xe=e.column===`done`,Se=!!(h&&te?.project_id&&Id(te)),Ce=!x&&!xe&&!!y;return(0,Z.jsxs)(Nf,{ref:k,"data-testid":`bundle-card-${e.bundle.id}-${e.column}`,className:`relative shrink-0 select-none transition-colors ${G} ${he} ${ge} ${_e} gap-0 rounded-xl border shadow-none`,onClick:()=>{x||b||(_?.(e.bundle.id),p?.(e.bundle.id,e.column))},...O,...D,children:[b&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,Z.jsxs)(q,{variant:`warning`,className:`gap-1.5`,children:[(0,Z.jsx)(Gm,{className:`h-3.5 w-3.5 animate-spin`}),`Undo in progress...`]})}),(0,Z.jsxs)(Rf,{className:`p-3`,children:[(0,Z.jsxs)(`div`,{className:`group/bundle mb-3 flex items-start justify-between gap-2 border-b pb-3 border-border/70`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 text-left`,children:[(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(`div`,{className:`${ye} min-w-0`,children:Ud(e.bundle)})}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`shrink-0 ${be}`,children:[e.tickets.length,` ticket`,e.tickets.length===1?``:`s`]}),M,e.bundle.pull_request&&(0,Z.jsx)(FE,{pullRequest:e.bundle.pull_request,asLink:!0,showNumber:!0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()}),ne&&(0,Z.jsx)(q,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:`Stale`})]}),(JE(e.column,H)||U||se)&&(0,Z.jsxs)(`div`,{"data-testid":`bundle-card-metadata-${e.bundle.id}-${e.column}`,className:`mt-2 flex flex-col gap-1`,children:[(JE(e.column,H)||U)&&(0,Z.jsx)(Gu,{stats:H,isLoading:U,showFiles:!0,className:be}),se&&(0,Z.jsx)(`div`,{className:be,children:(0,Z.jsx)(`span`,{className:`truncate`,children:se})})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-shrink-0 items-start gap-1`,children:[(0,Z.jsx)(`div`,{className:`mr-1`,children:(0,Z.jsx)(wD,{isRunning:ie,isRunPending:z.run,isStopPending:z.stop,runDisabled:n,onRun:!ae||xe||!c?void 0:()=>c(e.bundle.id),onStop:l?()=>l(e.bundle.id):void 0})}),(0,Z.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:Ce?(0,Z.jsx)(Lu,{content:S(`bundleCard.addTicketTooltip`),children:(0,Z.jsx)(J,{type:`button`,"aria-label":S(`bundleCard.addTicketAriaLabel`,{bundleName:Ud(e.bundle)}),variant:`ghost`,size:`icon-xs`,className:`opacity-0 transition-all group-hover/bundle:opacity-100 group-focus-within/bundle:opacity-100`,onClick:t=>{t.stopPropagation(),y?.(e.bundle.id)},onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(tf,{className:`h-4 w-4`})})}):null}),(0,Z.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:(0,Z.jsxs)(kE,{children:[(0,Z.jsx)(AE,{asChild:!0,children:(0,Z.jsx)(J,{type:`button`,"aria-label":`Open actions menu for bundle ${Ud(e.bundle)}`,variant:`ghost`,size:`icon-xs`,className:`opacity-0 transition-all group-hover/bundle:opacity-100 data-[state=open]:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(IE,{className:`h-4 w-4`})})}),(0,Z.jsxs)(jE,{side:`right`,align:`start`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[W&&v&&(0,Z.jsxs)(ME,{className:`text-red-200 focus:bg-destructive/20 focus:text-red-100`,onSelect:()=>{w(!0)},children:[(0,Z.jsx)(Vf,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Delete bundle`})]}),pe&&d&&(0,Z.jsxs)(ME,{onSelect:()=>{d(e)},children:[(0,Z.jsx)(bD,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:me})]}),N&&a&&(0,Z.jsxs)(ME,{disabled:z.build,onSelect:()=>{a(e.bundle.id)},children:[(0,Z.jsx)(Yu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z.build?`Building Bundle...`:`Build Bundle`})]}),(P||V)&&o&&(0,Z.jsxs)(ME,{disabled:B,onSelect:()=>{o(e.bundle.id)},children:[(0,Z.jsx)(LE,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:B?`Reviewing Bundle...`:ee})]}),I&&s&&(0,Z.jsxs)(ME,{disabled:z.undoReview||!L,title:L?void 0:R,onSelect:()=>{L&&E(!0)},children:[(0,Z.jsx)(Gm,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z.undoReview?`Undoing...`:`Undo Review`})]}),!ie&&c&&(0,Z.jsxs)(ME,{disabled:z.run||n,onSelect:()=>{n||c(e.bundle.id)},children:[(0,Z.jsx)(Yu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z.run?`Starting Run...`:`Run`})]}),ie&&l&&(0,Z.jsxs)(ME,{disabled:z.stop,onSelect:()=>{l(e.bundle.id)},children:[(0,Z.jsx)(Zu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z.stop?`Stopping...`:`Stop Run`})]}),ue&&ce&&r&&(0,Z.jsxs)(ME,{className:`text-amber-200 focus:bg-amber-500/20 focus:text-amber-100`,disabled:z.stopBuild,onSelect:()=>{r(ce.id)},children:[(0,Z.jsx)(Zu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z.stopBuild?`Pausing Build...`:`Pause Build`})]}),de&&le&&i&&(0,Z.jsxs)(ME,{className:`text-amber-200 focus:bg-amber-500/20 focus:text-amber-100`,disabled:z.resumeBuild,onSelect:()=>{i(le.id)},children:[(0,Z.jsx)(Yu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z.resumeBuild?`Resuming Build...`:`Resume Build`})]}),(0,Z.jsxs)(ME,{disabled:!m,onSelect:()=>{m?.(e.bundle.id)},children:[(0,Z.jsx)(qu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Changes`})]}),Se&&(0,Z.jsxs)(ME,{onSelect:()=>{h?.(e.bundle.id)},children:[(0,Z.jsx)(Ku,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Tests`})]}),(0,Z.jsxs)(ME,{disabled:!g,onSelect:()=>{g?.(e.bundle.id)},children:[(0,Z.jsx)(Ju,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Open IDE`})]}),fe&&u&&(0,Z.jsxs)(ME,{onSelect:()=>{u(e)},children:[(0,Z.jsx)(yD,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Done`})]})]})]})})]})]}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 ${ve}`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:e.tickets.map(e=>(0,Z.jsx)(X.Fragment,{children:t(e)},e.id))}),C&&(0,Z.jsx)(OD,{bundleName:Ud(e.bundle),ticketCount:e.tickets.length,onConfirm:()=>{w(!1),v?.(e)},onCancel:()=>w(!1)}),T&&F?.undo?.stage&&(0,Z.jsx)(CD,{title:Ud(e.bundle),stage:F.undo.stage,subjectLabel:`bundle`,onConfirm:()=>{E(!1),s?.(e.bundle.id)},onCancel:()=>E(!1)})]})]})},ND=({className:e})=>(0,Z.jsx)(jc,{"aria-hidden":`true`,className:e}),PD=({title:e,canDelete:t,undo:n,undoInProgress:r,runDisabled:i,isRunPending:a,isStopPending:o,showTestsAction:s,showOpenChangesAction:c,showOpenIdeAction:l,showAddTicketToBundleAction:u,showRunAction:d,showStopRunAction:f,showAdvanceAction:p,advanceLabel:m,canAdvance:h,showParkAction:g,showReturnAction:_,returnLabel:v,showBuildChainAction:y,showPauseBuildAction:b,showResumeBuildAction:x,showStopBuildChainAction:S,onDelete:C,onConfirmDelete:w,onConfirmUndo:T,onOpenTests:E,onOpenChanges:D,onOpenIde:O,onAddTicketToBundle:k,onAdvance:A,onPark:j,onUnpark:M,onBuildChain:N,onRun:P,onStop:F,onStopBuild:I,onResumeBuild:L,onStopBuildChain:R})=>{let{t:z}=ht(`common`);return(0,Z.jsxs)(kE,{children:[(0,Z.jsx)(AE,{asChild:!0,children:(0,Z.jsx)(J,{type:`button`,"aria-label":z(`cardActionsMenu.openAriaLabel`,{title:e}),variant:`ghost`,size:`icon-xs`,className:`opacity-0 transition-all group-hover/card:opacity-100 data-[state=open]:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(IE,{className:`h-4 w-4`})})}),(0,Z.jsxs)(jE,{side:`right`,align:`start`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[C&&(0,Z.jsxs)(ME,{disabled:!t,className:`text-red-200 focus:bg-destructive/20 focus:text-red-100 data-[disabled]:text-muted-foreground`,onSelect:()=>{t&&w()},children:[(0,Z.jsx)(Vf,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z(`cardActionsMenu.delete`)})]}),n?.stage&&(0,Z.jsxs)(ME,{disabled:!n.can_undo,title:n.can_undo?void 0:n.reason??void 0,onSelect:()=>{r||!n.can_undo||T()},children:[(0,Z.jsx)(Gm,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:n.stage===`review`?z(`cardActionsMenu.undoReview`):z(`cardActionsMenu.undoBuild`)})]}),p&&m&&(0,Z.jsxs)(ME,{disabled:!h,onSelect:()=>{h&&A?.()},children:[(0,Z.jsx)(LE,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:m})]}),_&&v&&(0,Z.jsxs)(ME,{onSelect:()=>{M?.()},children:[(0,Z.jsx)(bD,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:v})]}),y&&(0,Z.jsxs)(ME,{onSelect:()=>{N?.()},children:[(0,Z.jsx)(ND,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z(`cardActionsMenu.buildChain`)})]}),u&&(0,Z.jsxs)(ME,{onSelect:()=>k?.(),children:[(0,Z.jsx)(tf,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z(`cardActionsMenu.addTicketToBundle`)})]}),d&&(0,Z.jsxs)(ME,{disabled:i||a,onSelect:()=>{i||a||P?.()},children:[(0,Z.jsx)(Yu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z(a?`cardActionsMenu.startingRun`:`cardActionsMenu.run`)})]}),f&&(0,Z.jsxs)(ME,{disabled:o,className:`text-red-200 focus:bg-destructive/20 focus:text-red-100`,onSelect:()=>{o||F?.()},children:[(0,Z.jsx)(Zu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z(o?`cardActionsMenu.stopping`:`cardActionsMenu.stopRun`)})]}),b&&(0,Z.jsxs)(ME,{className:`text-amber-200 focus:bg-amber-500/20 focus:text-amber-100`,onSelect:()=>I?.(),children:[(0,Z.jsx)(Zu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z(`cardActionsMenu.pauseBuild`)})]}),x&&(0,Z.jsxs)(ME,{className:`text-amber-200 focus:bg-amber-500/20 focus:text-amber-100`,onSelect:()=>L?.(),children:[(0,Z.jsx)(Yu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z(`cardActionsMenu.resumeBuild`)})]}),c&&(0,Z.jsxs)(ME,{onSelect:()=>D?.(),children:[(0,Z.jsx)(qu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z(`cardActionsMenu.changes`)})]}),s&&(0,Z.jsxs)(ME,{onSelect:()=>E?.(),children:[(0,Z.jsx)(Ku,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z(`cardActionsMenu.tests`)})]}),l&&(0,Z.jsxs)(ME,{onSelect:()=>O?.(),children:[(0,Z.jsx)(Ju,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z(`cardActionsMenu.openIde`)})]}),S&&(0,Z.jsxs)(ME,{className:`text-red-200 focus:bg-destructive/20 focus:text-red-100`,onSelect:()=>{R?.()},children:[(0,Z.jsx)(Zu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z(`cardActionsMenu.stopBuildChain`)})]}),g&&(0,Z.jsxs)(ME,{onSelect:()=>{j?.()},children:[(0,Z.jsx)(yD,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:z(`cardActionsMenu.done`)})]})]})]})},FD=({title:e,bundleName:t=null,onConfirm:n,onCancel:r})=>{let{t:i}=ht(`common`);return(0,X.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,Z.jsxs)(Af,{onClose:r,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:i(`cardConfirmDeleteModal.heading`)}),(0,Z.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,Z.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:t?i(`cardConfirmDeleteModal.descriptionInBundle`,{bundleName:t}):i(`cardConfirmDeleteModal.descriptionStandalone`)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(J,{type:`button`,variant:`ghost`,onClick:r,children:i(`cardConfirmDeleteModal.cancel`)}),(0,Z.jsx)(J,{type:`button`,variant:`destructive`,onClick:n,children:i(`cardConfirmDeleteModal.confirm`)})]})]})},ID=({description:e,descriptionClass:t,isExpanded:n,collapsedState:r,useStaleLikeStyling:i,onExpand:a,onCollapse:o})=>{if(!e)return null;let s=`ml-1 inline h-auto px-0 py-0 align-baseline text-xs lowercase ${i?`text-foreground/75`:`text-foreground/70`}`;return(0,Z.jsx)(`div`,{className:`mb-2 text-xs leading-relaxed ${i?`text-foreground/55`:`text-muted-foreground`}`,children:n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:t,children:e}),(0,Z.jsx)(J,{type:`button`,variant:`link`,size:`xs`,className:s,onClick:e=>{e.stopPropagation(),o()},onPointerDown:e=>e.stopPropagation(),children:`show less`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:t,children:r.text}),r.truncated&&(0,Z.jsx)(J,{type:`button`,variant:`link`,size:`xs`,className:s,onClick:e=>{e.stopPropagation(),a()},onPointerDown:e=>e.stopPropagation(),children:`show more`})]})})},LD=({ticket:e,hideStatusBadge:t,isStale:n,runControl:r,onRetry:i,undoInProgress:a,isChainStart:o})=>{let{t:s}=ht(`common`),c=(e.planning_context?.open_questions.length??0)>0,l=ED(e),u=t||e.state===`plan`&&e.agent_status===null;return(0,Z.jsxs)(Z.Fragment,{children:[n&&(0,Z.jsx)(`div`,{className:`mb-2`,children:(0,Z.jsx)(q,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:s(`cardStatusBadges.stale`)})}),!t&&l!==null&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(SD,{status:l,showBuildGlyph:!0}),l===`error`&&i&&!a&&(0,Z.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:e=>{e.stopPropagation(),i()},onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(Gm,{className:`w-3.5 h-3.5`})}),r]}),u&&r,c&&(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(q,{variant:`warning`,children:s(`cardStatusBadges.openQuestions`)})}),o&&(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsxs)(q,{variant:`secondary`,className:`gap-1.5 border-violet-500/25 bg-violet-500/12 text-violet-200`,children:[(0,Z.jsx)(ND,{className:`h-3.5 w-3.5`}),s(`cardStatusBadges.chainStart`)]})})]})},RD=(e,t)=>x(N(`/tickets/${e}/terminal`,t),{method:`POST`,fallbackErrorMessage:`Unable to open the terminal right now.`}),zD=e=>x(s(`/projects/${e}/terminal`),{method:`POST`,fallbackErrorMessage:`Unable to open the project terminal right now.`}),BD=e=>{let t=s(`/terminals/${e}/destroy`);if(typeof navigator<`u`&&typeof navigator.sendBeacon==`function`){let e=new Blob([`{}`],{type:`application/json`});if(navigator.sendBeacon(t,e))return}fetch(t,{method:`POST`,keepalive:!0,headers:{"Content-Type":`application/json`},body:`{}`}).catch(()=>{})},VD=({model:e,variant:t,skills:n})=>e||t||n.length>0?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,Z.jsx)(q,{variant:`outline`,className:`border-border/80 bg-background/70 text-[11px] text-foreground`,children:e||`Default model`}),t&&(0,Z.jsx)(q,{variant:`ghost`,className:`text-[11px] text-muted-foreground`,children:t}),n.length>0&&(0,Z.jsxs)(q,{variant:`info`,className:`text-[11px]`,children:[n.length,` skill`,n.length===1?``:`s`]})]}):(0,Z.jsx)(q,{variant:`ghost`,className:`px-0 text-[11px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Using defaults`}),HD=e=>e===`claude`?`Claude`:`OpenCode`,UD=({tool:e,className:t})=>{if(!e)return null;let n=HD(e),r=`Locked to ${n}`;return(0,Z.jsx)(Lu,{content:r,children:(0,Z.jsx)(q,{variant:`outline`,"aria-label":r,className:W(`border-violet-500/25 bg-violet-500/10 text-violet-100`,e===`claude`&&`border-orange-500/25 bg-orange-500/10 text-orange-100`,t),children:n})})},WD=({externalSource:e=null,className:t})=>{if(!e||e.provider!==`jira`)return null;let n=e.external_key;return(0,Z.jsxs)(`div`,{className:W(`inline-flex w-fit max-w-full flex-wrap items-center gap-x-1 self-start rounded-md border border-sky-500/20 bg-sky-500/10 px-2.5 py-1 text-[11px] leading-5 text-sky-100`,t),children:[(0,Z.jsx)(`span`,{children:`Imported from Jira issue`}),e.external_url?(0,Z.jsx)(`a`,{href:e.external_url,target:`_blank`,rel:`noreferrer`,className:`font-medium underline underline-offset-2 hover:text-white`,children:n}):(0,Z.jsx)(`span`,{className:`font-medium`,children:n})]})},GD=({className:e})=>(0,Z.jsx)(Sc,{"aria-hidden":`true`,className:e}),KD=({label:e,value:t,variant:n=`default`,className:r})=>{let[i,a]=(0,X.useState)(!1),o=()=>{navigator.clipboard.writeText(t),a(!0),window.setTimeout(()=>a(!1),2e3)};return n===`compact`?(0,Z.jsx)(`div`,{className:W(`min-w-0`,r),children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg border border-border/80 bg-card/70 px-2.5 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-foreground/80`,children:t}),(0,Z.jsx)(J,{type:`button`,onClick:o,variant:`ghost`,size:`icon-xs`,"aria-label":i?`${e} copied`:`Copy ${e}`,className:W(`flex-shrink-0 text-muted-foreground hover:text-foreground`,i&&`text-emerald-300`),children:(0,Z.jsx)(GD,{className:`h-3 w-3`})})]})}):(0,Z.jsxs)(`div`,{className:W(`flex flex-col gap-1.5`,r),children:[(0,Z.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-input/30 px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`flex-1 truncate font-mono text-xs text-muted-foreground`,children:t}),(0,Z.jsxs)(J,{type:`button`,onClick:o,variant:`ghost`,size:`xs`,className:`flex-shrink-0`,children:[(0,Z.jsx)(GD,{className:`h-3.5 w-3.5`}),i?`Copied`:`Copy`]})]})]})},qD=({ariaLabel:e,items:t,className:n})=>{let r=t.filter(e=>e.value.trim().length>0);return r.length===0?null:(0,Z.jsx)(`section`,{"aria-label":e,className:W(`flex flex-wrap items-center gap-2`,n),children:r.map(e=>(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 sm:flex-none sm:max-w-full`,children:(0,Z.jsx)(KD,{label:e.label,value:e.value,variant:`compact`,className:`min-w-0`})},`${e.label}:${e.value}`))})},JD=new Set([`step started`,`step finished`]),YD=e=>JD.has(e.trim().toLowerCase()),XD=e=>YD(e.content)?!1:e.kind===`description`?e.content.trim().length>0:!0,ZD=({summary:e,detail:t=null})=>{let{t:n}=ht(`common`);return(0,Z.jsxs)(`section`,{"aria-label":n(`ticketBuildChainPreview.ariaLabel`),className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:n(`ticketBuildChainPreview.title`)}),(0,Z.jsx)(`p`,{className:`text-sm text-foreground`,children:e}),t&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]})};function QD(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var $D=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tO={};function nO(e,t){return((t||tO).jsx?eO:$D).test(e)}var rO=/[ \t\n\f\r]/g;function iO(e){return typeof e==`object`?e.type===`text`?aO(e.value):!1:aO(e)}function aO(e){return e.replace(rO,``)===``}var oO=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};oO.prototype.normal={},oO.prototype.property={},oO.prototype.space=void 0;function sO(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new oO(n,r,t)}function cO(e){return e.toLowerCase()}var lO=class{constructor(e,t){this.attribute=t,this.property=e}};lO.prototype.attribute=``,lO.prototype.booleanish=!1,lO.prototype.boolean=!1,lO.prototype.commaOrSpaceSeparated=!1,lO.prototype.commaSeparated=!1,lO.prototype.defined=!1,lO.prototype.mustUseProperty=!1,lO.prototype.number=!1,lO.prototype.overloadedBoolean=!1,lO.prototype.property=``,lO.prototype.spaceSeparated=!1,lO.prototype.space=void 0;var uO=r({boolean:()=>fO,booleanish:()=>pO,commaOrSpaceSeparated:()=>vO,commaSeparated:()=>_O,number:()=>hO,overloadedBoolean:()=>mO,spaceSeparated:()=>gO}),dO=0,fO=yO(),pO=yO(),mO=yO(),hO=yO(),gO=yO(),_O=yO(),vO=yO();function yO(){return 2**++dO}var bO=Object.keys(uO),xO=class extends lO{constructor(e,t,n,r){let i=-1;if(super(e,t),SO(this,`space`,r),typeof n==`number`)for(;++i<bO.length;){let e=bO[i];SO(this,bO[i],(n&uO[e])===uO[e])}}};xO.prototype.defined=!0;function SO(e,t,n){n&&(e[t]=n)}function CO(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new xO(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[cO(r)]=r,n[cO(a.attribute)]=r}return new oO(t,n,e.space)}var wO=CO({properties:{ariaActiveDescendant:null,ariaAtomic:pO,ariaAutoComplete:null,ariaBusy:pO,ariaChecked:pO,ariaColCount:hO,ariaColIndex:hO,ariaColSpan:hO,ariaControls:gO,ariaCurrent:null,ariaDescribedBy:gO,ariaDetails:null,ariaDisabled:pO,ariaDropEffect:gO,ariaErrorMessage:null,ariaExpanded:pO,ariaFlowTo:gO,ariaGrabbed:pO,ariaHasPopup:null,ariaHidden:pO,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:gO,ariaLevel:hO,ariaLive:null,ariaModal:pO,ariaMultiLine:pO,ariaMultiSelectable:pO,ariaOrientation:null,ariaOwns:gO,ariaPlaceholder:null,ariaPosInSet:hO,ariaPressed:pO,ariaReadOnly:pO,ariaRelevant:null,ariaRequired:pO,ariaRoleDescription:gO,ariaRowCount:hO,ariaRowIndex:hO,ariaRowSpan:hO,ariaSelected:pO,ariaSetSize:hO,ariaSort:null,ariaValueMax:hO,ariaValueMin:hO,ariaValueNow:hO,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function TO(e,t){return t in e?e[t]:t}function EO(e,t){return TO(e,t.toLowerCase())}var DO=CO({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:_O,acceptCharset:gO,accessKey:gO,action:null,allow:null,allowFullScreen:fO,allowPaymentRequest:fO,allowUserMedia:fO,alt:null,as:null,async:fO,autoCapitalize:null,autoComplete:gO,autoFocus:fO,autoPlay:fO,blocking:gO,capture:null,charSet:null,checked:fO,cite:null,className:gO,cols:hO,colSpan:null,content:null,contentEditable:pO,controls:fO,controlsList:gO,coords:hO|_O,crossOrigin:null,data:null,dateTime:null,decoding:null,default:fO,defer:fO,dir:null,dirName:null,disabled:fO,download:mO,draggable:pO,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:fO,formTarget:null,headers:gO,height:hO,hidden:mO,high:hO,href:null,hrefLang:null,htmlFor:gO,httpEquiv:gO,id:null,imageSizes:null,imageSrcSet:null,inert:fO,inputMode:null,integrity:null,is:null,isMap:fO,itemId:null,itemProp:gO,itemRef:gO,itemScope:fO,itemType:gO,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:fO,low:hO,manifest:null,max:null,maxLength:hO,media:null,method:null,min:null,minLength:hO,multiple:fO,muted:fO,name:null,nonce:null,noModule:fO,noValidate:fO,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:fO,optimum:hO,pattern:null,ping:gO,placeholder:null,playsInline:fO,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:fO,referrerPolicy:null,rel:gO,required:fO,reversed:fO,rows:hO,rowSpan:hO,sandbox:gO,scope:null,scoped:fO,seamless:fO,selected:fO,shadowRootClonable:fO,shadowRootDelegatesFocus:fO,shadowRootMode:null,shape:null,size:hO,sizes:null,slot:null,span:hO,spellCheck:pO,src:null,srcDoc:null,srcLang:null,srcSet:null,start:hO,step:null,style:null,tabIndex:hO,target:null,title:null,translate:null,type:null,typeMustMatch:fO,useMap:null,value:pO,width:hO,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:gO,axis:null,background:null,bgColor:null,border:hO,borderColor:null,bottomMargin:hO,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:fO,declare:fO,event:null,face:null,frame:null,frameBorder:null,hSpace:hO,leftMargin:hO,link:null,longDesc:null,lowSrc:null,marginHeight:hO,marginWidth:hO,noResize:fO,noHref:fO,noShade:fO,noWrap:fO,object:null,profile:null,prompt:null,rev:null,rightMargin:hO,rules:null,scheme:null,scrolling:pO,standby:null,summary:null,text:null,topMargin:hO,valueType:null,version:null,vAlign:null,vLink:null,vSpace:hO,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:fO,disableRemotePlayback:fO,prefix:null,property:null,results:hO,security:null,unselectable:null},space:`html`,transform:EO}),OO=CO({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:vO,accentHeight:hO,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:hO,amplitude:hO,arabicForm:null,ascent:hO,attributeName:null,attributeType:null,azimuth:hO,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:hO,by:null,calcMode:null,capHeight:hO,className:gO,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:hO,diffuseConstant:hO,direction:null,display:null,dur:null,divisor:hO,dominantBaseline:null,download:fO,dx:null,dy:null,edgeMode:null,editable:null,elevation:hO,enableBackground:null,end:null,event:null,exponent:hO,externalResourcesRequired:null,fill:null,fillOpacity:hO,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:_O,g2:_O,glyphName:_O,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:hO,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:hO,horizOriginX:hO,horizOriginY:hO,id:null,ideographic:hO,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:hO,k:hO,k1:hO,k2:hO,k3:hO,k4:hO,kernelMatrix:vO,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:hO,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:hO,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:hO,overlineThickness:hO,paintOrder:null,panose1:null,path:null,pathLength:hO,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:gO,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:hO,pointsAtY:hO,pointsAtZ:hO,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:vO,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:vO,rev:vO,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:vO,requiredFeatures:vO,requiredFonts:vO,requiredFormats:vO,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:hO,specularExponent:hO,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:hO,strikethroughThickness:hO,string:null,stroke:null,strokeDashArray:vO,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:hO,strokeOpacity:hO,strokeWidth:null,style:null,surfaceScale:hO,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:vO,tabIndex:hO,tableValues:null,target:null,targetX:hO,targetY:hO,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:vO,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:hO,underlineThickness:hO,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:hO,values:null,vAlphabetic:hO,vMathematical:hO,vectorEffect:null,vHanging:hO,vIdeographic:hO,version:null,vertAdvY:hO,vertOriginX:hO,vertOriginY:hO,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:hO,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:TO}),kO=CO({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),AO=CO({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:EO}),jO=CO({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),MO={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},NO=/[A-Z]/g,PO=/-[a-z]/g,FO=/^data[-\w.:]+$/i;function IO(e,t){let n=cO(t),r=t,i=lO;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&FO.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(PO,RO);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!PO.test(e)){let n=e.replace(NO,LO);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=xO}return new i(r,t)}function LO(e){return`-`+e.toLowerCase()}function RO(e){return e.charAt(1).toUpperCase()}var zO=sO([wO,DO,kO,AO,jO],`html`),BO=sO([wO,OO,kO,AO,jO],`svg`);function VO(e){return e.join(` `).trim()}var HO=i(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
62
|
+
`,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),UO=i((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(HO());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),WO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),GO=i(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(UO()),r=WO();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),KO=JO(`end`),qO=JO(`start`);function JO(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function YO(e){let t=qO(e),n=KO(e);if(t&&n)return{start:t,end:n}}function XO(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?QO(e.position):`start`in e||`end`in e?QO(e):`line`in e||`column`in e?ZO(e):``}function ZO(e){return $O(e&&e.line)+`:`+$O(e&&e.column)}function QO(e){return ZO(e&&e.start)+`-`+ZO(e&&e.end)}function $O(e){return e&&typeof e==`number`?e:1}var ek=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=XO(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};ek.prototype.file=``,ek.prototype.name=``,ek.prototype.reason=``,ek.prototype.message=``,ek.prototype.stack=``,ek.prototype.column=void 0,ek.prototype.line=void 0,ek.prototype.ancestors=void 0,ek.prototype.cause=void 0,ek.prototype.fatal=void 0,ek.prototype.place=void 0,ek.prototype.ruleId=void 0,ek.prototype.source=void 0;var tk=e(GO(),1),nk={}.hasOwnProperty,rk=new Map,ik=/[A-Z]/g,ak=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),ok=new Set([`td`,`th`]),sk=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function ck(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=yk(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=vk(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?BO:zO,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=lk(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function lk(e,t,n){if(t.type===`element`)return uk(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return dk(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return pk(e,t,n);if(t.type===`mdxjsEsm`)return fk(e,t);if(t.type===`root`)return mk(e,t,n);if(t.type===`text`)return hk(e,t)}function uk(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=BO,e.schema=i),e.ancestors.push(t);let a=Tk(e,t.tagName,!1),o=bk(e,t),s=Sk(e,t);return ak.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!iO(e):!0})),gk(e,o,a,t),_k(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function dk(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Ek(e,t.position)}function fk(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ek(e,t.position)}function pk(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=BO,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Tk(e,t.name,!0),o=xk(e,t),s=Sk(e,t);return gk(e,o,a,t),_k(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function mk(e,t,n){let r={};return _k(r,Sk(e,t)),e.create(t,e.Fragment,r,n)}function hk(e,t){return t.value}function gk(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function _k(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function vk(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function yk(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=qO(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function bk(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&nk.call(t.properties,i)){let a=Ck(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&ok.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function xk(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Ek(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else Ek(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function Sk(e,t){let n=[],r=-1,i=e.passKeys?new Map:rk;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=lk(e,a,o);s!==void 0&&n.push(s)}return n}function Ck(e,t,n){let r=IO(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?QD(n):VO(n)),r.property===`style`){let t=typeof n==`object`?n:wk(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Dk(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?MO[r.property]||r.property:r.attribute,n]}}function wk(e,t){try{return(0,tk.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new ek("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=sk+`#cannot-parse-style-attribute`,r}}function Tk(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=nO(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=nO(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return nk.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ek(e)}function Ek(e,t){let n=new ek("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=sk+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function Dk(e){let t={},n;for(n in e)nk.call(e,n)&&(t[Ok(n)]=e[n]);return t}function Ok(e){let t=e.replace(ik,kk);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function kk(e){return`-`+e.toLowerCase()}var Ak={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},jk={};function Mk(e,t){let n=t||jk;return Nk(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function Nk(e,t,n){if(Fk(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return Pk(e.children,t,n)}return Array.isArray(e)?Pk(e,t,n):``}function Pk(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=Nk(e[i],t,n);return r.join(``)}function Fk(e){return!!(e&&typeof e==`object`)}var Ik=document.createElement(`i`);function Lk(e){let t=`&`+e+`;`;Ik.innerHTML=t;let n=Ik.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function Rk(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function zk(e,t){return e.length>0?(Rk(e,e.length,0,t),e):t}var Bk={}.hasOwnProperty;function Vk(e){let t={},n=-1;for(;++n<e.length;)Hk(t,e[n]);return t}function Hk(e,t){let n;for(n in t){let r=(Bk.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Bk.call(r,a)||(r[a]=[]);let e=i[a];Uk(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Uk(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Rk(e,0,0,r)}function Wk(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function Gk(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var Kk=iA(/[A-Za-z]/),qk=iA(/[\dA-Za-z]/),Jk=iA(/[#-'*+\--9=?A-Z^-~]/);function Yk(e){return e!==null&&(e<32||e===127)}var Xk=iA(/\d/),Zk=iA(/[\dA-Fa-f]/),Qk=iA(/[!-/:-@[-`{-~]/);function $k(e){return e!==null&&e<-2}function eA(e){return e!==null&&(e<0||e===32)}function tA(e){return e===-2||e===-1||e===32}var nA=iA(/\p{P}|\p{S}/u),rA=iA(/\s/);function iA(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function aA(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&qk(e.charCodeAt(n+1))&&qk(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function oA(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return tA(r)?(e.enter(n),s(r)):t(r)}function s(r){return tA(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var sA={tokenize:cA};function cA(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),oA(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return $k(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var lA={tokenize:dA},uA={tokenize:fA};function dA(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return Rk(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(uA,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(uA,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return $k(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;Rk(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function fA(e,t,n){return oA(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function pA(e){if(e===null||eA(e)||rA(e))return 1;if(nA(e))return 2}function mA(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var hA={name:`attention`,resolveAll:gA,tokenize:_A};function gA(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};vA(d,-c),vA(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=zk(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=zk(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=zk(l,mA(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=zk(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=zk(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,Rk(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function _A(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=pA(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=pA(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function vA(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var yA={name:`autolink`,tokenize:bA};function bA(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return Kk(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||qk(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||qk(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||Yk(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Jk(t)?(e.consume(t),l):n(t)}function u(e){return qk(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||qk(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var xA={partial:!0,tokenize:SA};function SA(e,t,n){return r;function r(t){return tA(t)?oA(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||$k(e)?t(e):n(e)}}var CA={continuation:{tokenize:TA},exit:EA,name:`blockQuote`,tokenize:wA};function wA(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return tA(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function TA(e,t,n){let r=this;return i;function i(t){return tA(t)?oA(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(CA,t,n)(r)}}function EA(e){e.exit(`blockQuote`)}var DA={name:`characterEscape`,tokenize:OA};function OA(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return Qk(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var kA={name:`characterReference`,tokenize:AA};function AA(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=qk,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Zk,u):(e.enter(`characterReferenceValue`),a=7,o=Xk,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===qk&&!Lk(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var jA={partial:!0,tokenize:PA},MA={concrete:!0,name:`codeFenced`,tokenize:NA};function NA(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),tA(t)?oA(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||$k(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(jA,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||$k(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):tA(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),oA(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||$k(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||$k(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&tA(t)?oA(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||$k(t)?e.check(jA,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||$k(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),tA(t)?oA(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),tA(t)?oA(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||$k(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function PA(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var FA={name:`codeIndented`,tokenize:LA},IA={partial:!0,tokenize:RA};function LA(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),oA(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):$k(t)?e.attempt(IA,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||$k(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function RA(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):$k(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):oA(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):$k(e)?i(e):n(e)}}var zA={name:`codeText`,previous:VA,resolve:BA,tokenize:HA};function BA(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function VA(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function HA(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):$k(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||$k(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var UA=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&WA(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),WA(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),WA(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);WA(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);WA(this.left,t.reverse())}}};function WA(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function GA(e){let t={},n=-1,r,i,a,o,s,c,l,u=new UA(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,KA(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return Rk(e,0,1/0,u.slice(0)),!l}function KA(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var qA={resolve:YA,tokenize:XA},JA={partial:!0,tokenize:ZA};function YA(e){return GA(e),e}function XA(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):$k(t)?e.check(JA,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function ZA(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),oA(e,a,`linePrefix`)}function a(i){if(i===null||$k(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function QA(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||Yk(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||$k(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||eA(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||Yk(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function $A(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):$k(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||$k(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!tA(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function ej(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):$k(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),oA(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||$k(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function tj(e,t){let n;return r;function r(i){return $k(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):tA(i)?oA(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var nj={name:`definition`,tokenize:ij},rj={partial:!0,tokenize:aj};function ij(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return $A.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=Gk(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return eA(t)?tj(e,l)(t):l(t)}function l(t){return QA(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(rj,d,d)(t)}function d(t){return tA(t)?oA(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||$k(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function aj(e,t,n){return r;function r(t){return eA(t)?tj(e,i)(t):n(t)}function i(t){return ej(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return tA(t)?oA(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||$k(e)?t(e):n(e)}}var oj={name:`hardBreakEscape`,tokenize:sj};function sj(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return $k(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var cj={name:`headingAtx`,resolve:lj,tokenize:uj};function lj(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},Rk(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function uj(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||eA(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||$k(n)?(e.exit(`atxHeading`),t(n)):tA(n)?oA(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||eA(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var dj=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),fj=[`pre`,`script`,`style`,`textarea`],pj={concrete:!0,name:`htmlFlow`,resolveTo:gj,tokenize:_j},mj={partial:!0,tokenize:yj},hj={partial:!0,tokenize:vj};function gj(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function _j(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):Kk(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):Kk(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return Kk(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||eA(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&fj.includes(l)?(i=1,r.interrupt?t(s):O(s)):dj.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||qk(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return tA(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||Kk(t)?(e.consume(t),b):tA(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||qk(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):tA(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):tA(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||$k(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||eA(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||tA(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||$k(t)?O(t):tA(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):$k(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(mj,R,k)(t)):t===null||$k(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(hj,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||$k(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return fj.includes(n)?(e.consume(t),L):O(t)}return Kk(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||$k(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function vj(e,t,n){let r=this;return i;function i(t){return $k(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function yj(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(xA,t,n)}}var bj={name:`htmlText`,tokenize:xj};function xj(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):Kk(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):Kk(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):$k(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):$k(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):$k(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):$k(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return Kk(t)?(e.consume(t),S):n(t)}function S(t){return t===45||qk(t)?(e.consume(t),S):C(t)}function C(t){return $k(t)?(o=C,N(t)):tA(t)?(e.consume(t),C):M(t)}function w(t){return t===45||qk(t)?(e.consume(t),w):t===47||t===62||eA(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||Kk(t)?(e.consume(t),E):$k(t)?(o=T,N(t)):tA(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||qk(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):$k(t)?(o=D,N(t)):tA(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):$k(t)?(o=O,N(t)):tA(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):$k(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||eA(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||eA(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return tA(t)?oA(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var Sj={name:`labelEnd`,resolveAll:Ej,resolveTo:Dj,tokenize:Oj},Cj={tokenize:kj},wj={tokenize:Aj},Tj={tokenize:jj};function Ej(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&Rk(e,0,e.length,n),e}function Dj(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=zk(s,e.slice(a+1,a+r+3)),s=zk(s,[[`enter`,u,t]]),s=zk(s,mA(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=zk(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=zk(s,e.slice(o+1)),s=zk(s,[[`exit`,c,t]]),Rk(e,a,e.length,s),e}function Oj(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(Gk(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Cj,u,o?u:d)(t):t===91?e.attempt(wj,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Tj,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function kj(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return eA(t)?tj(e,a)(t):a(t)}function a(t){return t===41?u(t):QA(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return eA(t)?tj(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?ej(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return eA(t)?tj(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Aj(e,t,n){let r=this;return i;function i(t){return $A.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(Gk(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function jj(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Mj={name:`labelStartImage`,resolveAll:Sj.resolveAll,tokenize:Nj};function Nj(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Pj={name:`labelStartLink`,resolveAll:Sj.resolveAll,tokenize:Fj};function Fj(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Ij={name:`lineEnding`,tokenize:Lj};function Lj(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),oA(e,t,`linePrefix`)}}var Rj={name:`thematicBreak`,tokenize:zj};function zj(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||$k(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),tA(t)?oA(e,s,`whitespace`)(t):s(t))}}var Bj={continuation:{tokenize:Wj},exit:Kj,name:`list`,tokenize:Uj},Vj={partial:!0,tokenize:qj},Hj={partial:!0,tokenize:Gj};function Uj(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:Xk(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Rj,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return Xk(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(xA,r.interrupt?n:u,e.attempt(Vj,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return tA(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function Wj(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(xA,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,oA(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!tA(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Hj,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,oA(e,e.attempt(Bj,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function Gj(e,t,n){let r=this;return oA(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function Kj(e){e.exit(this.containerState.type)}function qj(e,t,n){let r=this;return oA(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!tA(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Jj={name:`setextUnderline`,resolveTo:Yj,tokenize:Xj};function Yj(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function Xj(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),tA(t)?oA(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||$k(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var Zj={tokenize:Qj};function Qj(e){let t=this,n=e.attempt(xA,r,e.attempt(this.parser.constructs.flowInitial,i,oA(e,e.attempt(this.parser.constructs.flow,i,e.attempt(qA,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var $j={resolveAll:rM()},eM=nM(`string`),tM=nM(`text`);function nM(e){return{resolveAll:rM(e===`text`?iM:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function rM(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function iM(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var aM=r({attentionMarkers:()=>pM,contentInitial:()=>sM,disable:()=>mM,document:()=>oM,flow:()=>lM,flowInitial:()=>cM,insideSpan:()=>fM,string:()=>uM,text:()=>dM}),oM={42:Bj,43:Bj,45:Bj,48:Bj,49:Bj,50:Bj,51:Bj,52:Bj,53:Bj,54:Bj,55:Bj,56:Bj,57:Bj,62:CA},sM={91:nj},cM={[-2]:FA,[-1]:FA,32:FA},lM={35:cj,42:Rj,45:[Jj,Rj],60:pj,61:Jj,95:Rj,96:MA,126:MA},uM={38:kA,92:DA},dM={[-5]:Ij,[-4]:Ij,[-3]:Ij,33:Mj,38:kA,42:hA,60:[yA,bj],91:Pj,92:[oj,DA],93:Sj,95:hA,96:zA},fM={null:[hA,$j]},pM={null:[42,95]},mM={null:[]};function hM(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=zk(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=mA(a,l.events,l),l.events):[]}function f(e,t){return _M(p(e),t)}function p(e){return gM(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){$k(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&Rk(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function gM(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function _M(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
63
|
+
`;break;case-3:o=`\r
|
|
64
|
+
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function vM(e){let t={constructs:Vk([aM,...(e||{}).extensions||[]]),content:n(sA),defined:[],document:n(lA),flow:n(Zj),lazy:{},string:n(eM),text:n(tM)};return t;function n(e){return n;function n(n){return hM(t,e,n)}}}function yM(e){for(;!GA(e););return e}var bM=/[\0\t\n\r]/g;function xM(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(bM.lastIndex=u,c=bM.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var SM=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function CM(e){return e.replace(SM,wM)}function wM(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return Wk(n.slice(t?2:1),t?16:10)}return Lk(n)||e}var TM={}.hasOwnProperty;function EM(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),DM(n)(yM(vM(n).document().write(xM()(e,t,!0))))}function DM(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(de),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(se),blockQuote:a(U),characterEscape:T,characterReference:T,codeFenced:a(re),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(re,o),codeText:a(ie,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ae),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(oe),hardBreakEscape:a(ce),hardBreakTrailing:a(ce),htmlFlow:a(le,o),htmlFlowData:T,htmlText:a(le,o),htmlTextData:T,image:a(ue),label:o,link:a(de),listItem:a(fe),listItemValue:f,listOrdered:a(W,d),listUnordered:a(W),paragraph:a(pe),reference:z,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(se),strong:a(me),thematicBreak:a(he)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:ne,autolinkProtocol:H,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:V,characterReferenceMarkerNumeric:V,characterReferenceValue:ee,characterReference:te,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:B,resourceDestinationString:I,resourceTitleString:L,resource:R,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};kM(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];TM.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||jM).call(a,void 0,e[0])}for(r.position={start:OM(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:OM(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:OM(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||jM).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+XO({start:e.start,end:e.end})+`): it’s not open`);n.position.end=OM(e.end)}function u(){return Mk(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Gk(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=G(),n.position={start:OM(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=OM(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=OM(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=CM(t),n.identifier=Gk(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function R(){this.data.inReference=void 0}function z(){this.data.referenceType=`collapsed`}function B(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Gk(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function V(e){this.data.characterReferenceType=e.type}function ee(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=Wk(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=Lk(t);let i=this.stack[this.stack.length-1];i.value+=r}function te(e){let t=this.stack.pop();t.position.end=OM(e.end)}function H(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ne(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function U(){return{type:`blockquote`,children:[]}}function re(){return{type:`code`,lang:null,meta:null,value:``}}function ie(){return{type:`inlineCode`,value:``}}function ae(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function oe(){return{type:`emphasis`,children:[]}}function se(){return{type:`heading`,depth:0,children:[]}}function ce(){return{type:`break`}}function le(){return{type:`html`,value:``}}function ue(){return{type:`image`,title:null,url:``,alt:null}}function de(){return{type:`link`,title:null,url:``,children:[]}}function W(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function fe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function pe(){return{type:`paragraph`,children:[]}}function me(){return{type:`strong`,children:[]}}function G(){return{type:`text`,value:``}}function he(){return{type:`thematicBreak`}}}function OM(e){return{line:e.line,column:e.column,offset:e.offset}}function kM(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?kM(e,r):AM(e,r)}}function AM(e,t){let n;for(n in t)if(TM.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function jM(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+XO({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+XO({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+XO({start:t.start,end:t.end})+`) is still open`)}function MM(e){let t=this;t.parser=n;function n(n){return EM(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function NM(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function PM(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
65
|
+
`}]}function FM(e,t){let n=t.value?t.value+`
|
|
66
|
+
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function IM(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function LM(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function RM(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=aA(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function zM(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function BM(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function VM(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function HM(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return VM(e,t);let i={src:aA(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function UM(e,t){let n={src:aA(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function WM(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function GM(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return VM(e,t);let i={href:aA(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function KM(e,t){let n={href:aA(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function qM(e,t,n){let r=e.all(t),i=n?JM(n):YM(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
67
|
+
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
68
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function JM(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=YM(n[r])}return t}function YM(e){return e.spread??e.children.length>1}function XM(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function ZM(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function QM(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function $M(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function eN(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=qO(t.children[1]),o=KO(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function tN(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function nN(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var rN=9,iN=32;function aN(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(oN(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(oN(t.slice(i),i>0,!1)),a.join(``)}function oN(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===rN||t===iN;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===rN||t===iN;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function sN(e,t){let n={type:`text`,value:aN(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function cN(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var lN={blockquote:NM,break:PM,code:FM,delete:IM,emphasis:LM,footnoteReference:RM,heading:zM,html:BM,imageReference:HM,image:UM,inlineCode:WM,linkReference:GM,link:KM,listItem:qM,list:XM,paragraph:ZM,root:QM,strong:$M,table:eN,tableCell:nN,tableRow:tN,text:sN,thematicBreak:cN,toml:uN,yaml:uN,definition:uN,footnoteDefinition:uN};function uN(){}var dN=typeof self==`object`?self:globalThis,fN=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new dN[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new dN[a](o),i)};return r},pN=e=>fN(new Map,e)(0),mN=``,{toString:hN}={},{keys:gN}=Object,_N=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=hN.call(e).slice(8,-1);switch(n){case`Array`:return[1,mN];case`Object`:return[2,mN];case`Date`:return[3,mN];case`RegExp`:return[4,mN];case`Map`:return[5,mN];case`Set`:return[6,mN];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},vN=([e,t])=>e===0&&(t===`function`||t===`symbol`),yN=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=_N(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of gN(r))(e||!vN(_N(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(vN(_N(n))||vN(_N(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!vN(_N(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},bN=(e,{json:t,lossy:n}={})=>{let r=[];return yN(!(t||n),!!t,new Map,r)(e),r},xN=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?pN(bN(e,t)):structuredClone(e):(e,t)=>pN(bN(e,t));function SN(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function CN(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function wN(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||SN,r=e.options.footnoteBackLabel||CN,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=aA(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...xN(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
69
|
+
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
70
|
+
`}]}}var TN=(function(e){if(e==null)return AN;if(typeof e==`function`)return kN(e);if(typeof e==`object`)return Array.isArray(e)?EN(e):DN(e);if(typeof e==`string`)return ON(e);throw Error(`Expected function, string, or object as test`)});function EN(e){let t=[],n=-1;for(;++n<e.length;)t[n]=TN(e[n]);return kN(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function DN(e){let t=e;return kN(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function ON(e){return kN(t);function t(t){return t&&t.type===e}}function kN(e){return t;function t(t,n,r){return!!(jN(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function AN(){return!0}function jN(e){return typeof e==`object`&&!!e&&`type`in e}function MN(e){return e}var NN=[];function PN(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=TN(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,`name`,{value:`node (`+MN(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=NN,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=FN(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function FN(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?NN:[e]}function IN(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),PN(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var LN={}.hasOwnProperty,RN={};function zN(e,t){let n=t||RN,r=new Map,i=new Map,a={all:s,applyData:VN,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...lN,...n.handlers},one:o,options:n,patch:BN,wrap:UN};return IN(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(LN.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=xN(n);return r.children=a.all(e),r}return xN(e)}return(a.options.unknownHandler||HN)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=WN(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=WN(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function BN(e,t){e.position&&(t.position=YO(e))}function VN(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,xN(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function HN(e,t){let n=t.data||{},r=`value`in t&&!(LN.call(n,`hProperties`)||LN.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function UN(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
71
|
+
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
72
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
73
|
+
`}),n}function WN(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function GN(e,t){let n=zN(e,t),r=n.one(e,void 0),i=wN(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
74
|
+
`},i)),a}function KN(e,t){return e&&`run`in e?async function(n,r){let i=GN(n,{file:r,...t});await e.run(i,r)}:function(n,r){return GN(n,{file:r,...e||t})}}function qN(e){if(e)throw e}var JN=i(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function YN(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function XN(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?ZN(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function ZN(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var QN={basename:$N,dirname:eP,extname:tP,join:nP,sep:`/`};function $N(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);aP(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function eP(e){if(aP(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function tP(e){aP(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function nP(...e){let t=-1,n;for(;++t<e.length;)aP(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:rP(n)}function rP(e){aP(e);let t=e.codePointAt(0)===47,n=iP(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function iP(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function aP(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var oP={cwd:sP};function sP(){return`/`}function cP(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function lP(e){if(typeof e==`string`)e=new URL(e);else if(!cP(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return uP(e)}function uP(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var dP=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],fP=class{constructor(e){let t;t=e?cP(e)?{path:e}:typeof e==`string`||gP(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:oP.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<dP.length;){let e=dP[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)dP.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?QN.basename(this.path):void 0}set basename(e){mP(e,`basename`),pP(e,`basename`),this.path=QN.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?QN.dirname(this.path):void 0}set dirname(e){hP(this.basename,`dirname`),this.path=QN.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?QN.extname(this.path):void 0}set extname(e){if(pP(e,`extname`),hP(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=QN.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){cP(e)&&(e=lP(e)),mP(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?QN.basename(this.path,this.extname):void 0}set stem(e){mP(e,`stem`),pP(e,`stem`),this.path=QN.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new ek(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function pP(e,t){if(e&&e.includes(QN.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+QN.sep+"`")}function mP(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function hP(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function gP(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var _P=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),vP=e(JN(),1),yP={}.hasOwnProperty,bP=new class e extends _P{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=XN()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,vP.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(CP(`data`,this.frozen),this.namespace[e]=t,this):yP.call(this.namespace,e)&&this.namespace[e]||void 0:e?(CP(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=EP(e),n=this.parser||this.Parser;return xP(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),xP(`process`,this.parser||this.Parser),SP(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=EP(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);OP(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),xP(`processSync`,this.parser||this.Parser),SP(`processSync`,this.compiler||this.Compiler),this.process(e,r),TP(`processSync`,`process`,t),n;function r(e,r){t=!0,qN(e),n=r}}run(e,t,n){wP(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=EP(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),TP(`runSync`,`run`,n),r;function i(e,t){qN(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=EP(t),r=this.compiler||this.Compiler;return SP(`stringify`,r),wP(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(CP(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,vP.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];YN(o)&&YN(r)&&(r=(0,vP.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function xP(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function SP(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function CP(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function wP(e){if(!YN(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function TP(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function EP(e){return DP(e)?e:new fP(e)}function DP(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function OP(e){return typeof e==`string`||kP(e)}function kP(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var AP=[],jP={allowDangerousHtml:!0},MP=/^(https?|ircs?|mailto|xmpp)$/i,NP=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function PP(e){let t=FP(e),n=IP(e);return LP(t.runSync(t.parse(n),n),e)}function FP(e){let t=e.rehypePlugins||AP,n=e.remarkPlugins||AP,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...jP}:jP;return bP().use(MM).use(n).use(KN,r).use(t)}function IP(e){let t=e.children||``,n=new fP;return typeof t==`string`?n.value=t:``+t,n}function LP(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||RP;for(let e of NP)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return IN(e,l),ck(e,{Fragment:Z.Fragment,components:i,ignoreInvalidStyle:!0,jsx:Z.jsx,jsxs:Z.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in Ak)if(Object.hasOwn(Ak,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Ak[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function RP(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||MP.test(e.slice(0,t))?e:``}function zP(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function BP(e,t,n){let r=TN((n||{}).ignore||[]),i=VP(t),a=-1;for(;++a<i.length;)PN(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function VP(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([HP(e[0]),UP(e[1])])}return t}function HP(e){return typeof e==`string`?new RegExp(zP(e),`g`):e}function UP(e){return typeof e==`function`?e:function(){return e}}function WP(e){BP(e,[/\r?\n|\r/g,GP])}function GP(){return{type:`break`}}function KP(){return function(e){WP(e)}}var qP=/^\[(?:X|x| )\]\s+/,JP=e=>{let t=e.split(`
|
|
75
|
+
`).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0&&t.every(e=>qP.test(e))},YP=e=>JP(e)?e.split(`
|
|
76
|
+
`).map(e=>e.trim()).filter(e=>e.length>0):[],XP=RegExp(`\x1B\\[[\\d;]*m|\\[[\\d;]*m`,`g`),ZP=`apply_patch`,QP=`[[archon-apply-patch]]`,$P=`[[/archon-apply-patch]]`,eF=e=>{let t=iF(e).trim();if(!t)return null;let n=t.split(`
|
|
77
|
+
`);if(n[0]?.trim()===QP&&n[n.length-1]?.trim()===$P)return n.slice(1,-1).join(`
|
|
78
|
+
`);if(n[0]?.trim()===ZP)return n.slice(1).join(`
|
|
79
|
+
`).trim()||null;let r=n[0]?.trim()??``;return r.startsWith(`apply_patch `)&&r.includes(`*** Begin Patch`)?r:null},tF=e=>{let t=[],n=null;for(let r of e.split(`
|
|
80
|
+
`)){if(!r.startsWith(` `)&&!r.startsWith(`+`)&&!r.startsWith(`-`)){n&&t.push(n),n={filePath:r,lines:[]};continue}n||={filePath:`Patch`,lines:[]},n.lines.push(r)}return n&&t.push(n),t},nF=({content:e})=>{let t=tF(e);return t.length===0?(0,Z.jsx)(`pre`,{children:(0,Z.jsx)(`code`,{children:e})}):(0,Z.jsx)(`div`,{className:`overflow-hidden rounded-md border border-border/70 bg-background/60`,children:t.map((e,t)=>(0,Z.jsxs)(`div`,{className:W(t>0&&`border-t border-border/70`),children:[(0,Z.jsx)(`div`,{className:`border-b border-border/80 bg-zinc-900 px-3 py-2 font-mono text-[11px] font-medium text-zinc-100`,children:e.filePath}),(0,Z.jsx)(`div`,{className:`py-1`,children:e.lines.map((e,t)=>{let n=e[0]??` `,r=e.length>0?e.slice(1):``,i=n===`+`,a=n===`-`,o=i?`bg-emerald-500/12 text-emerald-100`:a?`bg-rose-500/12 text-rose-100`:`text-zinc-100`,s=i?`text-emerald-200`:a?`text-rose-200`:`text-zinc-300`;return(0,Z.jsxs)(`div`,{className:W(`flex gap-3 px-3 py-1 font-mono text-xs leading-5`,o),children:[(0,Z.jsx)(`span`,{className:W(`w-3 shrink-0 text-center`,s),children:n===` `?` `:n}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words`,children:r||`\xA0`})]},t)})})]},`${e.filePath}-${t}`))})},rF=({content:e})=>(0,Z.jsx)(`div`,{className:`not-prose flex flex-col gap-1`,"data-transcript-segment":`todo-list`,children:YP(e).map((e,t)=>(0,Z.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-6`,children:e},`${e}-${t}`))}),iF=e=>e.replace(/\r\n/g,`
|
|
81
|
+
`).replace(XP,``),aF=e=>{let t=eF(e);if(t)return[{kind:`apply_patch`,content:t}];let n=[],r=[],i=()=>{let e=r.join(`
|
|
82
|
+
`);if(!e.trim()){r.length=0;return}n.push({kind:YP(e).length>0?`todo`:`markdown`,content:e}),r.length=0};for(let t of iF(e).split(`
|
|
83
|
+
`))r.push(t);return i(),n},oF=({content:e,className:t})=>{let n=aF(e);return(0,Z.jsx)(`div`,{className:W(`prose prose-invert prose-sm max-w-none break-words text-sm text-foreground [overflow-wrap:anywhere] [&_code]:break-words [&_code]:text-violet-300 [&_h1]:mb-2 [&_h1]:mt-4 [&_h1]:text-base [&_h1]:font-semibold [&_h2]:mb-2 [&_h2]:mt-4 [&_h2]:text-base [&_h2]:font-semibold [&_h3]:mb-2 [&_h3]:mt-3 [&_h3]:font-semibold [&_li]:my-1 [&_li>p]:my-1 [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-5 [&_pre]:overflow-x-auto [&_pre]:rounded [&_pre]:bg-secondary [&_pre]:p-2 [&_pre]:whitespace-pre-wrap [&_p]:mb-3 [&_strong]:text-foreground [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5 [&_br+br]:mt-3 [&_br+br]:block`,t),children:n.map((e,t)=>e.kind===`apply_patch`?(0,Z.jsx)(nF,{content:e.content},`apply-patch-${t}`):e.kind===`code`?(0,Z.jsx)(`pre`,{children:(0,Z.jsx)(`code`,{children:e.content})},`code-${t}`):e.kind===`todo`?(0,Z.jsx)(rF,{content:e.content},`todo-${t}`):(0,Z.jsx)(PP,{remarkPlugins:[KP],children:e.content},`markdown-${t}`))})},sF=({item:e,index:t})=>{let{t:n}=ht(`common`);return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-sky-500/20 bg-background/40 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e.source===`archon_review_finding`?n(`reviewFollowUpBubble.finding`,{count:e.findingNumber??t}):e.source===`external_review_comment`?n(`reviewFollowUpBubble.externalFix`,{count:t}):e.source===`preview_comment`?n(`reviewFollowUpBubble.previewComment`,{count:t}):n(`reviewFollowUpBubble.comment`,{count:t})}),(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-xs text-foreground`,children:e.filePath??e.page??n(`reviewFollowUpBubble.unknownTarget`)})]}),e.line&&(0,Z.jsx)(`div`,{className:`rounded-full border border-border bg-background/60 px-2 py-0.5 font-mono text-[11px] text-muted-foreground`,children:e.line})]}),(e.title||e.element)&&(0,Z.jsx)(`div`,{className:`mt-3 text-sm font-medium text-foreground`,children:e.title??e.element}),e.selectorHint&&(0,Z.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.selectorHint}),(0,Z.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:e.comment}),e.text&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:n(`reviewFollowUpBubble.textLabel`)}),(0,Z.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 text-xs text-foreground`,children:e.text})]}),e.href&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:n(`reviewFollowUpBubble.hrefLabel`)}),(0,Z.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground break-all`,children:e.href})]}),e.src&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:n(`reviewFollowUpBubble.srcLabel`)}),(0,Z.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground break-all`,children:e.src})]}),e.lineContent&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:n(`reviewFollowUpBubble.changedLineLabel`)}),(0,Z.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground`,children:e.lineContent})]})]})},cF=({content:e,parsed:t})=>{let{t:n}=ht(`common`),[r,i]=(0,X.useState)(!1),a=n(`reviewFollowUpBubble.fixCount`,{count:t.items.length}),o=t.locationLabel===`file`?n(`reviewFollowUpBubble.locationFile`,{count:t.locationCount}):t.locationLabel===`page`?n(`reviewFollowUpBubble.locationPage`,{count:t.locationCount}):n(`reviewFollowUpBubble.locationTarget`,{count:t.locationCount});return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:n(`reviewFollowUpBubble.selectedFixes`)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[a,` across `,o]})]}),(0,Z.jsxs)(J,{type:`button`,size:`xs`,variant:`ghost`,className:`gap-1.5 self-start`,onClick:()=>{i(e=>!e)},children:[(0,Z.jsx)(oe,{className:`h-3.5 w-3.5 transition-transform ${r?`rotate-180`:``}`}),n(r?`reviewFollowUpBubble.hideRawPrompt`:`reviewFollowUpBubble.showRawPrompt`)]})]}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:t.items.map((e,t)=>(0,Z.jsx)(sF,{item:e,index:t+1},`${e.filePath??e.page??`target`}:${e.line??e.element??t}:${t+1}`))}),r&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/40 p-3`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-[11px] uppercase tracking-widest text-muted-foreground`,children:n(`reviewFollowUpBubble.rawPrompt`)}),(0,Z.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap text-xs leading-relaxed text-foreground`,children:e})]})]})},lF=2,uF=18,dF=288,fF=(e,t)=>{let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t).trimEnd()}...`},pF=e=>{if(typeof document>`u`)return{text:e,truncated:!1};let t=document.createElement(`span`);t.setAttribute(`aria-hidden`,`true`),t.style.position=`absolute`,t.style.visibility=`hidden`,t.style.pointerEvents=`none`,t.style.whiteSpace=`pre-wrap`,t.style.wordBreak=`break-word`,t.style.overflowWrap=`anywhere`,t.style.width=`${dF}px`,t.style.fontSize=`12px`,t.style.lineHeight=`${uF}px`,t.style.fontFamily=`inherit`,t.textContent=e,document.body.appendChild(t);let n=uF*lF;if(!(t.getBoundingClientRect().height>n+.5))return document.body.removeChild(t),{text:e,truncated:!1};let r=0,i=e.length,a=fF(e,Math.max(1,Math.floor(e.length/2)));for(;r<=i;){let o=Math.floor((r+i)/2),s=fF(e,o);t.textContent=s,t.getBoundingClientRect().height<=n+.5?(a=s,r=o+1):i=o-1}return document.body.removeChild(t),{text:a,truncated:!0}},mF=`Please address the following review comments in the current diff.`,hF=`Please address the following selected fixes in the current diff.`,gF=`Please address the following selected fixes from the current preview.`,_F=`Please address the following selected fixes from the current diff and preview.`,vF=e=>{let t=e.trimEnd(),n=t.indexOf(`
|
|
84
|
+
Context:
|
|
85
|
+
\`\`\`diff
|
|
86
|
+
`);if(n===-1)return null;let r=t.slice(0,n),i=t.slice(n+18);if(!i.endsWith("\n```"))return null;let a=r.split(`
|
|
87
|
+
`);if(a.length<5)return null;let[o,s,c,l,...u]=a;return!/^\d+\. File: /.test(o)||!s.startsWith(`Line: `)||!c.startsWith(`Hunk: `)||!l.startsWith(`Changed line: `)||u.length===0||!u[0].startsWith(`Comment: `)?null:{source:`manual_comment`,filePath:o.replace(/^\d+\. File: /,``),page:null,line:s.slice(6),element:null,selectorHint:null,text:null,href:null,src:null,hunk:c.slice(6),lineContent:l.slice(14),comment:[u[0].slice(9),...u.slice(1)].join(`
|
|
88
|
+
`),diffSnippet:i.slice(0,-4)}},yF=e=>{let t=e.trimEnd(),n=t.split(`
|
|
89
|
+
`)[0];if(!/^\d+\. Source: /.test(n))return null;let r=n.replace(/^\d+\. Source: /,``).trim().toLowerCase(),i=r===`archon review finding`?`archon_review_finding`:r===`external review comment`||r.startsWith(`github review `)?`external_review_comment`:r===`preview comment`?`preview_comment`:`manual_comment`,a=new Map,o=null,s=t.indexOf(`
|
|
90
|
+
Context:
|
|
91
|
+
\`\`\`diff
|
|
92
|
+
`),c=s===-1?t:t.slice(0,s);if(s!==-1){let e=t.slice(s+18);o=e.endsWith("\n```")?e.slice(0,-4):null}for(let e of c.split(`
|
|
93
|
+
`).slice(1)){let t=e.indexOf(`: `);t!==-1&&a.set(e.slice(0,t),e.slice(t+2))}let l=a.get(`Comment`)??a.get(`What`)??``;return l?i===`preview_comment`?{source:i,filePath:null,page:a.get(`Page`)??null,line:null,element:a.get(`Element`)??null,selectorHint:a.get(`Selector hint`)??null,text:a.get(`Text`)??null,href:a.get(`Href`)??null,src:a.get(`Src`)??null,hunk:null,lineContent:null,comment:l,diffSnippet:null,severity:null,title:null,findingNumber:null}:{source:i,filePath:a.get(`File`)??`Unknown file`,page:null,line:a.get(`Line`)??`line unavailable`,element:null,selectorHint:null,text:null,href:null,src:null,hunk:a.get(`Hunk`)??null,lineContent:a.get(`Changed line`)??null,comment:l,diffSnippet:o,severity:a.get(`Severity`)??null,title:a.get(`Title`)??null,findingNumber:a.has(`Finding`)&&Number(a.get(`Finding`))||null}:null},bF=e=>{let t=e.trim(),n=t.startsWith(mF),r=[hF,gF,_F].find(e=>t.startsWith(e));if(!n&&!r)return null;let i=n?mF:r??hF,a=t.slice(i.length).trim();if(!a)return null;let o=(n?a.split(/\n(?=\d+\. File: )/):a.replace(/\nApply only the selected fixes\. Keep unrelated changes intact\.$/,``).trim().split(/\n(?=\d+\. Source: )/)).map(n?vF:yF);if(o.some(e=>e===null))return null;let s=o.filter(e=>e!==null);return s.length===0?null:{items:s,locationCount:new Set(s.map(e=>e.filePath??e.page??`Unknown target`)).size,locationLabel:s.every(e=>e.page&&!e.filePath)?`page`:s.every(e=>e.filePath&&!e.page)?`file`:`target`}},xF=24,SF=`archon.show-thinking`,CF=new Set([`step started`,`step finished`]),wF=/^_?todo[_-]?write_?$/i,TF=`[[archon-apply-patch]]`,EF=`[[/archon-apply-patch]]`,DF=[/(^|\n)\s*<system-reminder>[\s\S]*?<\/system-reminder>\s*(?=\n|$)/g,/(^|\n)\s*<archon-[a-z0-9-]+>[\s\S]*?<\/archon-[a-z0-9-]+>\s*(?=\n|$)/g,/(^|\n)\s*<selected_skills>[\s\S]*?<\/selected_skills>\s*(?=\n|$)/g,/(^|\n)\s*<ticket>[\s\S]*?<\/ticket>\s*(?=\n|$)/g,/(^|\n)\s*<follow_up_instruction>[\s\S]*?<\/follow_up_instruction>\s*(?=\n|$)/g,/(^|\n)\s*<review_findings>[\s\S]*?<\/review_findings>\s*(?=\n|$)/g,/(^|\n)\s*<diff>[\s\S]*?<\/diff>\s*(?=\n|$)/g],OF=/^<(?<tag>archon-[a-z0-9-]+)>$/i,kF=/^<\/(?<tag>archon-[a-z0-9-]+)>$/i,AF=()=>{try{return window.localStorage.getItem(SF)===`true`}catch{return!1}},jF=e=>{if(typeof queueMicrotask==`function`){queueMicrotask(e);return}Promise.resolve().then(e)},MF=e=>{e.scrollTop=e.scrollHeight},NF=e=>e.scrollHeight-e.clientHeight-e.scrollTop<=xF,PF=e=>e.replace(/\r\n/g,`
|
|
94
|
+
`).trim(),FF=e=>DF.reduce((e,t)=>e.replace(t,`$1`),e),IF=e=>{let t=e.trim();return t?t.startsWith(`{`)||t.startsWith(`[`)||t.startsWith(`"`)||t.startsWith(`- `)||/^\d+\.\s/.test(t):!0},LF=e=>{let t=e.split(`
|
|
95
|
+
`),n=[],r=null;for(let e of t){let t=e.trim();if(r===null){let i=t.match(OF);if(i?.groups?.tag){r=i.groups.tag.toLowerCase();continue}n.push(e);continue}if(t.match(kF)?.groups?.tag?.toLowerCase()===r){r=null;continue}IF(t)||(r=null,n.push(e))}return n.join(`
|
|
96
|
+
`)},RF=e=>{let t=e.trim();if(!t.startsWith(`{`)||!t.endsWith(`}`))return!1;try{let e=JSON.parse(t);return Object.keys(e).length===1&&Array.isArray(e.open_questions)}catch{return!1}},zF=e=>{let t=PF(LF(FF(e??``)));return t?t.split(`
|
|
97
|
+
`).filter(e=>{let t=e.trim();return!CF.has(t.toLowerCase())&&!RF(t)}).join(`
|
|
98
|
+
`):``},BF=e=>{let t=PF(zF(e));if(!t)return[];let n=[],r=[],i=!1,a=()=>{let e=r.join(`
|
|
99
|
+
`).trim();if(r.length=0,e){if(wF.test(e))return;n.push(e)}};for(let e of t.split(`
|
|
100
|
+
`)){if(e===TF){a(),r.push(e),i=!0;continue}if(i){r.push(e),e===EF&&(a(),i=!1);continue}if(!e.trim()){a();continue}r.push(e)}return a(),n},VF=(e,t)=>e.length>=t.length?!1:e.every((e,n)=>e===t[n]),HF=e=>{let t=[];for(let n of e){let e=t[t.length-1];if(!e||!JP(e)||!JP(n)){t.push(n);continue}if(VF(e.split(`
|
|
101
|
+
`),n.split(`
|
|
102
|
+
`))){t[t.length-1]=n;continue}t[t.length-1]=`${e}\n${n}`}return t},UF=({visibleContent:e,internalLog:t,showThinking:n})=>{let r=HF(BF(e));if(!n||!t||t.trim().length===0)return r.map(e=>({tone:`primary`,content:e}));let i=HF(BF(t));if(i.length===0)return r.map(e=>({tone:`primary`,content:e}));let a=[],o=0;for(let e of i){let t=r[o];if(t&&PF(t)===PF(e)){a.push({tone:`primary`,content:e}),o+=1;continue}a.push({tone:`secondary`,content:e})}for(;o<r.length;)a.push({tone:`primary`,content:r[o]}),o+=1;return a},WF=(0,X.memo)(({visibleContent:e,internalLog:t,showThinking:n})=>{let r=(0,X.useMemo)(()=>UF({visibleContent:e,internalLog:t,showThinking:n}),[t,n,e]);return r.length===0?null:(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:r.map((e,t)=>(0,Z.jsx)(oF,{content:e.content,className:e.tone===`secondary`?`text-muted-foreground [&_code]:text-violet-200 [&_pre]:bg-background/70`:void 0},`${e.tone}:${t+1}`))})});WF.displayName=`AssistantMessageContent`;var GF=(0,X.memo)(({attachments:e})=>{let{t}=ht(`common`),[n,r]=(0,X.useState)(null);return e.length===0?null:(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[e.map(e=>{let n=T(e.content_url);return(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/80 bg-background/70 transition-colors hover:border-border`,children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":t(`attachmentPreviewDialog.previewImageAriaLabel`,{name:e.original_name}),className:`block w-full cursor-zoom-in overflow-hidden text-left outline-none transition-opacity hover:opacity-95 focus-visible:ring-2 focus-visible:ring-ring/50`,onClick:()=>{r(e)},children:(0,Z.jsx)(`img`,{src:n,alt:t(`conversationPane.attachmentPreviewAlt`,{name:e.original_name}),className:`h-28 w-full object-cover`,loading:`lazy`})}),(0,Z.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground`,children:e.original_name}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:rg(e.size_bytes)})]})]},e.id)}),(0,Z.jsx)(ig,{attachment:n,onClose:()=>{r(null)}})]})});GF.displayName=`MessageAttachments`;var KF=(0,X.memo)(({message:e,showThinking:t=!1,internalLog:n=null,footer:r=null})=>{let i=e.role===`user`,a=i&&e.kind===`description`,o=e.attachments??[],[s,c]=(0,X.useState)(!1),l=i?bF(e.content):null,u=(0,X.useMemo)(()=>!a||!e.content?{text:e.content,truncated:!1}:pF(e.content),[a,e.content]);return(0,Z.jsx)(`div`,{"data-message-role":e.role,className:`flex ${i?`justify-end`:`justify-start`}`,children:(0,Z.jsxs)(Nf,{className:i?`min-w-0 max-w-full w-[94%] border-sky-500/30 bg-sky-500/10 shadow-none sm:w-auto sm:max-w-[85%]`:`min-w-0 max-w-full w-[94%] border-slate-400/30 bg-slate-400/10 shadow-none sm:w-auto sm:max-w-[85%]`,size:`sm`,children:[(0,Z.jsxs)(Rf,{className:`min-w-0 flex flex-col gap-2 px-3 py-3 sm:px-4 sm:py-4 ${i?`[overflow-wrap:anywhere]`:``}`,children:[e.displayTitle&&(0,Z.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e.displayTitle}),i?l?(0,Z.jsx)(cF,{content:e.content,parsed:l}):a?(0,Z.jsx)(ID,{description:e.content,descriptionClass:`whitespace-pre-wrap text-sm leading-relaxed text-foreground`,isExpanded:s,collapsedState:u,useStaleLikeStyling:!1,onExpand:()=>c(!0),onCollapse:()=>c(!1)}):e.content?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground [overflow-wrap:anywhere]`,children:e.content}):null:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(lm,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(WF,{visibleContent:e.content,internalLog:n,showThinking:t})})]}),i&&o.length>0?(0,Z.jsx)(GF,{attachments:o}):null]}),r?(0,Z.jsx)(zf,{className:`border-t border-border/60 px-4 py-3`,children:r}):null]})})});KF.displayName=`MessageBubble`;var qF=()=>{let{t:e}=ht(`common`);return(0,Z.jsxs)(`div`,{role:`status`,"aria-label":e(`conversationPane.agentActivityAriaLabel`),"aria-live":`polite`,className:`mt-1 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,"aria-hidden":`true`,children:[(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_infinite_backwards] motion-reduce:animate-none`}),(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_0.3s_infinite_backwards] motion-reduce:animate-none`}),(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_0.6s_infinite_backwards] motion-reduce:animate-none`})]}),(0,Z.jsx)(`span`,{className:`sr-only`,children:e(`conversationPane.agentWorkingSrText`)})]})},JF=(0,X.memo)(({ticketTitle:e,streamingResponse:t,internalLog:n,showThinking:r,statusLabel:i,showActivity:a=!0})=>{let{t:o}=ht(`common`),s=i??o(`conversationPane.statusWorking`);return(0,Z.jsx)(`div`,{className:`flex justify-start`,children:(0,Z.jsx)(Nf,{className:`min-w-0 max-w-full w-[94%] border-slate-400/30 bg-slate-400/10 shadow-none sm:w-full sm:max-w-[85%]`,size:`sm`,children:(0,Z.jsxs)(Rf,{className:`flex flex-col gap-3 px-3 py-3 sm:px-4 sm:py-4`,children:[e?(0,Z.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e}):null,(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(lm,{className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(`span`,{children:s})]}),t||r&&n?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(lm,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(WF,{visibleContent:t,internalLog:n,showThinking:r})})]}):null,a?(0,Z.jsx)(qF,{}):null]})})})});JF.displayName=`PendingAgentMessage`;var YF=(0,X.memo)(({messages:e,messageThinkingLogs:t,effectiveShowThinking:n,internalLog:r,pendingAgentTitle:i,streamingResponse:a,isRunning:o,isPendingAgentVisible:s,interruptedPendingSnapshot:c,isLoading:l,emptyStateText:u,renderMessageFooter:d,hidePendingAgentTitle:f=!1})=>{let{t:p}=ht(`common`),m=c?e.findIndex(e=>e.id===c.latestMessageIdAtCapture):-1,h=m>=0?e.slice(0,m+1):e,g=m>=0?e.slice(m+1):[],_=e=>(0,Z.jsx)(KF,{message:e,footer:d?.(e)??null,showThinking:n&&t.has(e.id),internalLog:t.get(e.id)??null},`${e.ticket_id}:${e.id}`);return(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-5`,children:[e.length===0&&!o&&u&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-6 text-sm text-muted-foreground`,children:l?p(`conversationPane.loadingConversation`):u}),h.map(_),o&&s&&(0,Z.jsx)(JF,{ticketTitle:f?null:i,streamingResponse:a,internalLog:r,showThinking:n}),!o&&c?(0,Z.jsx)(JF,{ticketTitle:f?null:c.ticketTitle,streamingResponse:c.streamingResponse,internalLog:c.internalLog,showThinking:c.showThinking,statusLabel:p(`conversationPane.statusInterrupted`),showActivity:!1}):null,g.map(_)]})});YF.displayName=`ConversationTranscript`;var XF=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,currentThinkingMessageId:i=null,legacyThinkingTicketId:a=null,previousThinkingLog:o=null,previousThinkingMessageId:s=null,pendingAgentTitle:c,streamingResponse:l,isRunning:u,isLoading:d=!1,autoScrollBehavior:f=`sticky`,surfaceVariant:p=`default`,canShowComposer:m,header:h,composerControls:g,composerInlineControls:_,composerTheme:v=`default`,composerSize:y=`default`,showThinkingPlacement:b=`body`,pinComposerToBottom:x=!1,isExternallyResizing:S=!1,pendingAgentRevealKey:C=null,pendingAgentRevealDelayMs:w=0,composerFocusNonce:T=0,forceScrollToBottomKey:E,layoutKey:D,scrollLayoutKey:O,blurComposerOnSendStart:k=!1,followUpPrompt:A,draftAttachments:j=[],followUpPlaceholder:M,emptyStateText:N,autoFocusComposer:P=!1,renderMessageFooter:F,isSendingFollowUp:I,isUploadingAttachments:L=!1,canAttachImages:R=!1,followUpDisabledReason:z,hidePendingAgentTitle:B=!1,onFollowUpPromptChange:V,onFollowUpKeyDown:ee,onFollowUpPaste:te,onUploadAttachments:H,onRemoveAttachment:ne,onFollowUpSubmit:U})=>{let re=(0,X.useRef)(null),ie=(0,X.useRef)(null),ae=(0,X.useRef)(!1),oe=(0,X.useRef)(null),se=(0,X.useRef)(r),ce=(0,X.useRef)(O),le=(0,X.useRef)(!1),ue=(0,X.useRef)(A),de=(0,X.useRef)(T),fe=(0,X.useRef)(E),pe=(0,X.useRef)(S),me=(0,X.useRef)(!0),G=(0,X.useRef)(!1),he=(0,X.useRef)(!1),ge=(0,X.useRef)(I),_e=(0,X.useRef)(null),ve=(0,X.useRef)(null),[ye,be]=(0,X.useState)(AF),[xe,Se]=(0,X.useState)(null),[Ce,we]=(0,X.useState)(null),K=(0,X.useId)(),{t:Te}=ht(`common`),Ee=n.length>0?n[n.length-1].id:null,De=!u||!C||xe===C,Oe=!!(r&&r.trim().length>0||o&&o.trim().length>0),ke=ye&&Oe,Ae=!!(l||ke&&r),je=p===`chat`,Me=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(cm,{id:K,"aria-label":Te(`conversationPane.showThinkingAriaLabel`),checked:ye,onCheckedChange:be}),(0,Z.jsx)(mu,{htmlFor:K,className:`text-sm text-muted-foreground`,children:Te(`conversationPane.showThinkingLabel`)})]}),Ne=N===void 0?Te(`conversationPane.noMessagesYet`):N,Pe=typeof h==`function`?h({showThinkingControl:Me}):h,Fe=b===`header`&&!!Pe&&typeof h!=`function`,Ie=!Fe&&typeof h!=`function`,Le=(0,X.useMemo)(()=>i||u||!r?null:[...n].reverse().find(e=>e.role===`assistant`?a?e.ticket_id===a:!0:!1)?.id??null,[i,r,u,a,n]),Re=(0,X.useMemo)(()=>{let e=new Map;if(!ke)return e;s&&o&&e.set(s,o);let t=i??Le;return!u&&t&&r&&e.set(t,r),e},[i,ke,Le,r,u,o,s]),q=e=>{jF(()=>{we(e)})};return(0,X.useEffect)(()=>{q(null)},[D]),(0,X.useEffect)(()=>{u&&q(null)},[u]),(0,X.useEffect)(()=>{!u||!De||!Ae||q(e=>e&&e.latestMessageIdAtCapture===Ee&&e.internalLog===r&&e.showThinking===ke&&e.streamingResponse===l&&e.ticketTitle===c?e:{latestMessageIdAtCapture:Ee,internalLog:r,showThinking:ke,streamingResponse:l,ticketTitle:c})},[ke,Ae,r,De,u,Ee,c,l]),(0,X.useEffect)(()=>{q(e=>e&&(Ee!==e.latestMessageIdAtCapture&&n[n.length-1]?.role===`assistant`?null:e))},[Ee,n]),(0,X.useEffect)(()=>{try{if(ye){window.localStorage.setItem(SF,`true`);return}window.localStorage.removeItem(SF)}catch{}},[ye]),(0,X.useEffect)(()=>()=>{_e.current!==null&&window.clearTimeout(_e.current)},[]),(0,X.useEffect)(()=>{_e.current!==null&&(window.clearTimeout(_e.current),_e.current=null),!(!C||w<=0||xe===C)&&(_e.current=window.setTimeout(()=>{_e.current=null,Se(C)},w))},[w,C,xe]),(0,X.useEffect)(()=>{let e=re.current;if(!e)return;let t=null,n=ie.current===null,i=ie.current!==Ee,a=!ae.current&&u,o=oe.current!==l,s=se.current!==r,c=ce.current!==O,d=le.current!==ke,p=NF(e),m=f===`always`||n||me.current,h=m||p;return c&&(me.current=h),m&&(n||i||a||o||d||ke&&s)&&MF(e),c&&h&&(MF(e),t=window.requestAnimationFrame(()=>{MF(e)})),ie.current=Ee,ae.current=u,oe.current=l,se.current=r,ce.current=O,le.current=ke,()=>{t!==null&&window.cancelAnimationFrame(t)}},[ke,r,u,O,Ee,l,f]),(0,X.useEffect)(()=>{let e=re.current,t=!ge.current&&I;e&&t&&(k&&ve.current?.blur(),me.current=!0,MF(e)),ge.current=I},[k,I]),(0,X.useEffect)(()=>{let e=re.current,t=fe.current!==E;if(fe.current=E,!e||!E||!t)return;me.current=!0,MF(e);let n=requestAnimationFrame(()=>{MF(e)});return()=>{cancelAnimationFrame(n)}},[E]),(0,X.useEffect)(()=>{let e=re.current;if(!e){pe.current=S;return}let t=!pe.current&&S,n=pe.current&&!S;t&&(G.current=me.current||NF(e)),n&&(me.current=NF(e),G.current=!1),pe.current=S},[S]),(0,X.useEffect)(()=>{let e=re.current;if(!e||typeof ResizeObserver!=`function`)return;let t=new ResizeObserver(()=>{(me.current||G.current||he.current)&&MF(e)});return t.observe(e),()=>{t.disconnect()}},[]),(0,X.useEffect)(()=>{let e=re.current;!e||!De||!u||(f===`always`||me.current)&&MF(e)},[f,De,u]),(0,X.useEffect)(()=>{let e=de.current!==T;if(de.current=T,!P&&!e||!m||I)return;let t=ve.current;if(!t)return;let n=requestAnimationFrame(()=>{t.focus()});return()=>{cancelAnimationFrame(n)}},[P,m,T,I,D]),(0,X.useEffect)(()=>{let e=ve.current;if(!e||!m){ue.current=A;return}let t=re.current,n=ue.current!==A;ue.current=A;let r=!!(n&&t&&(me.current||NF(t)));if(he.current=r,Ag(e),!t||!r){he.current=!1;return}let i=requestAnimationFrame(()=>{me.current=!0,MF(t),he.current=!1});return()=>{cancelAnimationFrame(i),he.current=!1}},[m,A,D]),(0,Z.jsx)(`section`,{"aria-label":Te(`conversationPane.sectionAriaLabel`),className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Z.jsxs)(Nf,{size:`sm`,className:W(`min-h-0 flex-1 gap-0 overflow-hidden border-border/80 bg-card/70 shadow-none`,je&&`rounded-none`),children:[Pe&&(0,Z.jsxs)(`div`,{className:W(`flex items-start justify-between gap-3 border-b border-border/80 px-4`,je?`pt-3 pb-1`:`py-3`),children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:Pe}),Fe&&Me]}),Ie&&(0,Z.jsx)(`div`,{className:`flex justify-end px-4 pt-3`,children:Me}),(0,Z.jsx)(Rf,{"aria-label":Te(`conversationPane.contentAriaLabel`),ref:re,onScroll:e=>{S&&G.current||he.current||(me.current=NF(e.currentTarget))},className:W(`min-h-0 flex-1 overflow-y-auto`,je?`border-b border-border/80 px-2 pt-0 !pb-2.5 data-[size=sm]:!pb-2.5 sm:px-4`:`border-b border-border/80 px-4 py-4`),children:(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-col`,children:(0,Z.jsx)(YF,{messages:n,messageThinkingLogs:Re,effectiveShowThinking:ke,internalLog:r,pendingAgentTitle:c,streamingResponse:l,isRunning:u,isPendingAgentVisible:De,interruptedPendingSnapshot:Ce,isLoading:d,emptyStateText:Ne,renderMessageFooter:F,hidePendingAgentTitle:B})})}),m&&(0,Z.jsx)(zf,{className:W(`mt-auto`,je?`pt-1`:x&&`border-t border-border/80 bg-card/95 pt-4 backdrop-blur supports-[backdrop-filter]:bg-card/80`),children:(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-3`,children:[g?(0,Z.jsx)(`div`,{children:g}):null,(0,Z.jsx)(_g,{projectId:e,suggestionTicketId:t,value:A,attachments:j,placeholder:M,disabled:I,isSubmitDisabled:u,isSending:I,isUploadingAttachments:L,canAttachImages:R,disabledReason:z,onValueChange:V,onKeyDown:ee,onPaste:te,onUploadAttachments:H,onRemoveAttachment:ne,onSubmit:U,textareaRef:ve,composerInlineControls:_,composerTheme:v,composerSize:y})]})})]})})},ZF=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,currentThinkingMessageId:i=null,previousThinkingLog:a=null,previousThinkingMessageId:o=null,streamingResponse:s,isRunning:c,canShowComposer:l,header:u,followUpComposerControls:d,composerTheme:f=`default`,surfaceVariant:p=`default`,composerSize:m=`default`,forceScrollToBottomKey:h,layoutKey:g,scrollLayoutKey:_,followUpPlaceholder:v=`Follow up on this ticket`,emptyStateText:y,autoFocusComposer:b=!1,pendingAgentTitle:x=null,followUpPrompt:S,isSendingFollowUp:C,followUpDisabledReason:w,onFollowUpPromptChange:T,onFollowUpKeyDown:E,onFollowUpSubmit:D})=>(0,Z.jsx)(XF,{projectId:e,followUpTicketId:t,messages:n,internalLog:r,currentThinkingMessageId:i,previousThinkingLog:a,previousThinkingMessageId:o,pendingAgentTitle:x,streamingResponse:s,isRunning:c,autoScrollBehavior:`sticky`,surfaceVariant:p,canShowComposer:l,header:u,composerInlineControls:d,composerTheme:f,composerSize:m,forceScrollToBottomKey:h,layoutKey:g,scrollLayoutKey:_,followUpPrompt:S,followUpPlaceholder:v,emptyStateText:y,autoFocusComposer:b,isSendingFollowUp:C,followUpDisabledReason:w,onFollowUpPromptChange:T,onFollowUpKeyDown:E,onFollowUpSubmit:D}),QF=({title:e,items:t,resolveTicket:n,resolveOtherTicketId:r,onDeleteDependency:i})=>{let{t:a}=ht(`common`);return t.length===0?null:(0,Z.jsxs)(`section`,{"aria-label":e,className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border bg-background/40 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 truncate text-sm text-foreground`,children:n(r(e))?.title??a(`ticketDependencyDetails.unknownTicket`)}),i&&(0,Z.jsx)(J,{type:`button`,onClick:()=>{i(e)},variant:`destructive`,size:`xs`,children:a(`ticketDependencyDetails.remove`)})]},`${e.blocker_ticket_id}:${e.dependent_ticket_id}`))})]})},$F=({items:e,resolveTicket:t,onDeleteDependency:n})=>{let{t:r}=ht(`common`);if(e.length===0)return null;let i=e.map(e=>{let n=t(e.blocker_ticket_id);return{dependency:e,ready:lD(n),title:n?.title??r(`ticketDependencyDetails.unknownTicket`)}}),a=i.filter(e=>!e.ready),o=a.length===0?r(`ticketDependencyDetails.summaryReady`):r(`ticketDependencyDetails.summaryBlocked`,{count:a.length});return(0,Z.jsxs)(`section`,{"aria-label":r(`ticketDependencyDetails.buildReadinessAriaLabel`),className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:r(`ticketDependencyDetails.buildReadinessTitle`)}),(0,Z.jsx)(q,{variant:a.length===0?`success`:`warning`,children:a.length===0?r(`ticketDependencyDetails.ready`):r(`ticketDependencyDetails.blocked`)})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border bg-background/40 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e.title}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(q,{variant:e.ready?`success`:`warning`,children:e.ready?r(`ticketDependencyDetails.buildDone`):r(`ticketDependencyDetails.waitingOnBuild`)}),n&&(0,Z.jsx)(J,{type:`button`,onClick:()=>{n(e.dependency)},variant:`destructive`,size:`xs`,children:r(`ticketDependencyDetails.remove`)})]})]},`${e.dependency.blocker_ticket_id}:${e.dependency.dependent_ticket_id}`))})]})},eI=({blocks:e,blockedBy:t,resolveTicket:n,onDeleteDependency:r})=>{let{t:i}=ht(`common`),[a,o]=(0,X.useState)(!1);return e.length===0&&t.length===0?null:(0,Z.jsxs)(`section`,{className:`rounded-lg border border-border bg-card/70`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>{o(e=>!e)},className:`flex w-full cursor-pointer items-center justify-between gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/60`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:i(`ticketDependencyDetails.dependencyDetails`)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(a?`ticketDependencyDetails.hide`:`ticketDependencyDetails.show`)})]}),a&&(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 border-t border-border px-4 py-3 lg:grid-cols-2`,children:[(0,Z.jsx)(QF,{title:i(`ticketDependencyDetails.blocksTitle`),items:e,resolveTicket:n,resolveOtherTicketId:e=>e.dependent_ticket_id,onDeleteDependency:r}),(0,Z.jsx)($F,{items:t,resolveTicket:n,onDeleteDependency:r})]})]})},tI=({initialTitle:e=``,initialDescription:t=``,initialModel:n=``,initialVariant:r=``,initialSkills:i=[],initialWorktreeBundleId:a=null,validWorktreeBundleIds:o,availableModels:s=[],availableSkills:c=[],showModelSelector:l=!1,showSkillsSelector:u=!1,disableEscapeClose:d=!1,onDirtyChange:f,onAgentSettingsChange:p,onSubmit:m,onCancel:h,children:g})=>{let[_,v]=(0,X.useState)(e),[y,b]=(0,X.useState)(t),[x,S]=(0,X.useState)(n),[C,w]=(0,X.useState)(r),[T,E]=(0,X.useState)(i),[D,O]=(0,X.useState)({worktree_bundle_id:a});Of(h,{disabled:d});let k=D.worktree_bundle_id!==null&&o&&!o.includes(D.worktree_bundle_id)?null:D.worktree_bundle_id,A=_.trim()&&y.trim(),j=_!==e||y!==t||x!==n||C!==r||T.length!==i.length||T.some((e,t)=>e!==i[t])||k!==a;(0,X.useEffect)(()=>{f?.(j)},[j,f]),(0,X.useEffect)(()=>{p?.({model:x.trim()||null,variant:C.trim()||null,skills:T})},[x,p,T,C]);let M=(0,X.useCallback)(()=>{A&&m?.({title:_.trim(),description:y.trim(),model:x.trim()||null,variant:C.trim()||null,skills:T,worktree_bundle_id:k})},[y,A,x,m,k,T,_,C]),N={title:_,description:y,model:x,variant:C,skills:T,extra:{worktree_bundle_id:k},availableModels:s,availableSkills:c,showModelSelector:l,showSkillsSelector:u,setTitle:v,setDescription:b,setModel:S,setVariant:w,setSkills:E,setExtra:O,isValid:!!A,onSubmit:M,onCancel:h};return g?(0,Z.jsx)(Z.Fragment,{children:g(N)}):null},nI=2,rI=e=>e.length===0?`No skills`:e.length<=nI?e.join(`, `):`${e.slice(0,nI).join(`, `)} +${e.length-nI}`,iI=({skills:e,availableSkills:t,onSkillsChange:n,selectId:r,label:i=`Skills`,triggerAriaLabel:a,disabled:o=!1,className:s,triggerClassName:c,showSelectedBadges:l=!0})=>{let u=e.map(e=>t.find(t=>t.name===e)?.name??e).filter(Boolean),d=u.slice(0,nI),f=Math.max(0,u.length-d.length);return(0,Z.jsxs)(`div`,{className:W(`flex flex-col gap-2`,s),children:[(0,Z.jsx)(fm,{label:i,triggerLabel:rI(u),triggerAriaLabel:a??`Skills`,selectId:r,selectedValues:e,onToggle:t=>{n(e.includes(t)?e.filter(e=>e!==t):[...e,t])},disabled:o,contentClassName:`min-w-[22rem]`,triggerClassName:c,groups:[{label:``,options:t.map(e=>({value:e.name,label:e.name}))}]}),l&&u.length>0&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[d.map(e=>(0,Z.jsx)(q,{variant:`outline`,className:`border-border/80 bg-background/70 text-[11px] text-foreground`,children:e},e)),f>0&&(0,Z.jsxs)(q,{variant:`ghost`,className:`px-1.5 text-[11px] text-muted-foreground`,children:[`+`,f,` more`]})]})]})},aI=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h,layout:g=`wrap`})=>{let _=r&&s!==null&&s.variants.length>0;return!r&&!i?null:(0,Z.jsx)(`section`,{className:W(`rounded-2xl border border-border/70 bg-secondary/20 p-3`,h),"aria-label":`AI settings`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,children:`AI settings`}),(0,Z.jsx)(VD,{model:e,variant:t,skills:n})]}),(0,Z.jsxs)(`div`,{className:W(`gap-3`,g===`stacked`?`flex flex-col`:`flex flex-wrap`),children:[(0,Z.jsx)(Au,{model:e,showModelSelector:r,availableModels:a,onModelChange:c,selectId:d,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[10rem] flex-[1.35_1_10rem]`}),_&&(0,Z.jsx)(ju,{variant:t,selectedModel:s,showVariantSelector:_,onVariantChange:l,selectId:f,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[7rem] flex-[0.7_1_7rem]`}),i&&(0,Z.jsx)(iI,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[8rem] flex-[0.95_1_8rem]`,showSelectedBadges:!1})]})]})})},oI=({model:e,variant:t,skills:n,selectedModel:r})=>{let i=[];return e&&i.push(r?.label??e),t&&i.push(t),n.length>0&&i.push(`${n.length} skill${n.length===1?``:`s`}`),i.length===0?`AI defaults`:i.join(` / `)},sI=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h})=>{let g=r&&s!==null&&s.variants.length>0,_=oI({model:e,variant:t,skills:n,selectedModel:s});return!r&&!i?null:(0,Z.jsxs)(hu,{children:[(0,Z.jsx)(gu,{asChild:!0,children:(0,Z.jsxs)(J,{type:`button`,variant:`outline`,disabled:m,className:W(`max-w-full w-fit justify-start gap-2 text-left sm:max-w-80`,h),"aria-label":`AI settings`,children:[(0,Z.jsx)(lm,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`truncate`,children:_})]})}),(0,Z.jsx)(_u,{align:`start`,className:`w-80 max-w-[calc(100vw-2rem)] p-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,children:`AI settings`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(Au,{model:e,showModelSelector:r,availableModels:a,onModelChange:c,selectId:d,disabled:m}),(0,Z.jsx)(ju,{variant:t,selectedModel:s,showVariantSelector:g,onVariantChange:l,selectId:f,disabled:m}),i&&(0,Z.jsx)(iI,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,disabled:m,showSelectedBadges:!1})]})]})})]})},cI=({jiraImportState:e,onImportFromJira:t,onImported:n,inputId:r,className:i})=>{let{t:a}=ht(`common`),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(!1);if(e!==`enabled`)return null;let u=!!t,d=async()=>{if(!(!t||!o.trim())){l(!0);try{n(await t(o.trim())),s(``)}catch(e){Q.error(e instanceof Error?e.message:a(`jiraImportField.error`),{id:`jira-import-error`})}finally{l(!1)}}};return(0,Z.jsx)(Bf,{label:a(`jiraImportField.label`),htmlFor:r,className:i,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Ae,{id:r,type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key!==`Enter`||!u||(e.preventDefault(),d())},placeholder:a(`jiraImportField.placeholder`),disabled:!u||c})}),(0,Z.jsxs)(J,{type:`button`,variant:`outline`,disabled:!u||!o.trim()||c,onClick:()=>{d()},className:`sm:min-w-[7.5rem]`,children:[(0,Z.jsx)(Wm,{className:`h-4 w-4`}),a(c?`jiraImportField.importing`:`jiraImportField.import`)]})]})})},lI=({bundles:e,value:t,onChange:n,label:r,selectId:i=`bundle-selector`,emptyLabel:a,showEmptyOption:o=!0,disabled:s=!1,hideProjectRootBundles:c=!1,projectRootWarning:l=null,projectRootUnavailableReason:u=null,className:d,contentClassName:f,triggerClassName:p})=>{let{t:m}=ht(`common`),h=r??m(`bundleSelector.label`),g=a??m(`bundleSelector.emptyLabel`),_=[...c?e.filter(e=>e.kind!==`project_root`):e].sort((e,t)=>e.kind===`project_root`&&t.kind!==`project_root`?-1:+(e.kind!==`project_root`&&t.kind===`project_root`)),v=_.find(e=>e.id===t),y=v?Wd(v):g,b=v?.kind===`project_root`;return(0,Z.jsxs)(`div`,{className:W(`space-y-2`,d),children:[b&&l&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/35 bg-amber-500/10 px-3 py-2 text-xs font-medium text-amber-100`,children:l}),(0,Z.jsx)(ku,{label:h,triggerLabel:y,selectId:i,selectedValue:t,onChange:n,disabled:s,contentClassName:f,triggerClassName:p,groups:[{label:``,options:[...o?[{value:``,label:g}]:[],..._.map(e=>({value:e.id,label:Wd(e),disabled:e.kind===`project_root`&&!!u}))]}]}),u&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/35 bg-amber-500/10 px-3 py-2 text-xs text-amber-100`,children:u})]})},uI=e=>{let t=e.trim();return t?t.replace(/[^a-zA-Z0-9\s-]/g,``).trim().replace(/\s+/g,`-`).slice(0,60)||`bundle`:null},dI={subtle:`outline`,brand:`default`},fI=({heading:e,bundles:t,stackConfigurationSections:n=!1,showModelSelector:r=!1,agentSettingsPresentation:i=`panel`,preferWideBundleSelector:a=!1,availableModels:o=[],availableSkills:s=[],initialTitle:c=``,initialDescription:l=``,initialModel:u=``,initialVariant:d=``,initialSkills:f=[],initialWorktreeBundleId:p=null,projectId:m=null,jiraImportState:h=`hidden`,onImportFromJira:g,onCancel:_,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,titleInputId:x,descriptionInputId:S,bundleSelectId:C,modelSelectId:w,variantSelectId:T,skillsSelectId:E,showEmptyBundleOption:D=!0,primaryAction:O,secondaryAction:k,tertiaryAction:A,planAction:j,beforeActionsContent:M,footerLeadingContent:N,onPlanActiveChange:P,onDirtyChange:F,onAgentSettingsChange:I})=>{let{t:L}=ht(`common`),[R,z]=(0,X.useState)([]),[B,V]=(0,X.useState)([]),[ee,te]=(0,X.useState)(!1),[H,ne]=(0,X.useState)(!1),[U,re]=(0,X.useState)(null),ie=(0,X.useRef)(null),ae=L(D?`ticketEditor.automaticBundleLabel`:`bundleSelector.emptyLabel`),oe=[...R.filter(e=>!B.includes(e.id)),...t.filter(e=>!B.includes(e.id)&&!R.some(t=>t.id===e.id))],se=h!==`hidden`;return(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,Z.jsx)(tI,{initialTitle:c,initialDescription:l,initialModel:u,initialVariant:d,initialSkills:f,initialWorktreeBundleId:p,validWorktreeBundleIds:oe.map(e=>e.id),showModelSelector:r,availableModels:o,availableSkills:s,showSkillsSelector:r,onCancel:_,disableEscapeClose:ee,onDirtyChange:F,onAgentSettingsChange:I,children:({title:e,description:t,model:r,variant:o,skills:s,extra:c,availableModels:l,availableSkills:u,showModelSelector:d,showSkillsSelector:f,setTitle:p,setDescription:F,setModel:I,setVariant:R,setSkills:B,setExtra:ce,isValid:le})=>{let ue=l.find(e=>e.id===r)??null,de=c.worktree_bundle_id?null:uI(e),W={title:e.trim(),description:t.trim(),model:r.trim()||null,variant:o.trim()||null,skills:s,worktree_bundle_id:c.worktree_bundle_id,...U?{external_source:U}:{}},fe=async()=>{if(!j)return;ne(!0);let e=new AbortController;ie.current=e,P?.(!0);try{await j.onClick(W),P?.(!1)}catch(t){e.signal.aborted||(P?.(!1),Q.error(t instanceof Error?t.message:L(`ticketEditor.planningFailed`),{id:`ticket-planning-error`}))}finally{ie.current=null,ne(!1)}},pe=async e=>{if(!v)throw Error(L(`ticketEditor.bundleCreationUnavailable`));let t=await v(e);return z(e=>[t,...e.filter(e=>e.id!==t.id)]),V(e=>e.filter(e=>e!==t.id)),ce({worktree_bundle_id:t.id}),te(!1),t},me=async e=>{y&&(await y(e),V(t=>t.includes(e)?t:[...t,e]),z(t=>t.filter(t=>t.id!==e)),c.worktree_bundle_id===e&&ce({worktree_bundle_id:null}))},G=()=>{le&&(H&&ie.current?.abort(),O.onClick(W))},he=i===`popover`&&!n,ge=a&&i===`popover`,_e=n?`flex flex-col gap-3`:he?`grid grid-cols-1 gap-3 sm:grid-cols-[minmax(0,1fr)_max-content]`:`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,0.82fr)_minmax(0,1.18fr)]`,ve=n?`flex items-end gap-3`:he?`flex flex-col gap-2 sm:grid sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end sm:gap-3`:`flex flex-col gap-2 sm:flex-row sm:items-end`,ye=i===`popover`?(0,Z.jsx)(sI,{model:r,variant:o,skills:s,showModelSelector:d,showSkillsSelector:f,availableModels:l,availableSkills:u,selectedModel:ue,onModelChange:I,onVariantChange:R,onSkillsChange:B,modelSelectId:w,variantSelectId:T,skillsSelectId:E,className:`h-10 self-end`}):(0,Z.jsx)(aI,{model:r,variant:o,skills:s,showModelSelector:d,showSkillsSelector:f,availableModels:l,availableSkills:u,selectedModel:ue,onModelChange:I,onVariantChange:R,onSkillsChange:B,modelSelectId:w,variantSelectId:T,skillsSelectId:E,layout:n?`stacked`:`wrap`});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),G()},className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:se?`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,1fr)_22rem]`:`grid grid-cols-1 gap-3`,children:[(0,Z.jsx)(Bf,{label:L(`ticketEditor.titleLabel`),htmlFor:x,children:(0,Z.jsx)(Ae,{id:x,type:`text`,value:e,onChange:e=>p(e.target.value),placeholder:L(`ticketEditor.titlePlaceholder`),autoFocus:!0})}),se&&(0,Z.jsx)(cI,{jiraImportState:h,onImportFromJira:g,onImported:e=>{p(e.title),F(e.description),re(e.external_source)},inputId:`jira-import-reference`,className:`lg:min-h-[90px]`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2`,children:[(0,Z.jsx)(Bf,{label:L(`ticketEditor.descriptionLabel`),htmlFor:S,className:`gap-0`,children:(0,Z.jsx)(Z.Fragment,{})}),(0,Z.jsx)(hg,{projectId:m,suggestionAnchor:`caret`,wrapperClassName:`flex flex-1 min-h-0`,id:S,value:t,onValueChange:F,placeholder:L(`ticketEditor.descriptionPlaceholder`),disabled:H,className:H?`flex-1 min-h-0 animate-pulse`:`flex-1 min-h-0`})]}),(0,Z.jsxs)(`div`,{className:_e,children:[(0,Z.jsxs)(`div`,{className:ve,children:[(0,Z.jsxs)(`div`,{className:ge?`min-w-0 flex-1 sm:min-w-[19rem]`:`min-w-0 flex-1`,children:[(0,Z.jsx)(lI,{bundles:oe,value:c.worktree_bundle_id??``,onChange:e=>ce({worktree_bundle_id:e||null}),label:n?``:void 0,selectId:C,emptyLabel:ae,showEmptyOption:D,hideProjectRootBundles:!0,triggerClassName:ge?`sm:min-w-[19rem]`:void 0,contentClassName:ge?`w-[min(30rem,calc(100vw-2rem))] min-w-[24rem] max-w-[calc(100vw-2rem)]`:void 0}),de&&(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground absolute max-w-80`,children:[L(`ticketEditor.bundlePreview`),` `,(0,Z.jsx)(`span`,{className:`text-foreground`,children:de})]})]}),v&&y&&(0,Z.jsx)(J,{type:`button`,onClick:()=>{(async()=>{try{b&&await b()}catch{}te(!0)})()},variant:`outline`,size:n?`sm`:`default`,className:n?`shrink-0 whitespace-nowrap border-sky-500/30 bg-sky-500/10 text-sky-200 hover:border-sky-400 hover:bg-sky-500/20 hover:text-sky-100`:`h-10 whitespace-nowrap border-sky-500/35 bg-sky-500/12 px-4 text-sky-100 hover:border-sky-400 hover:bg-sky-500/20 hover:text-white`,children:L(`ticketEditor.manageBundles`)})]}),ye]})]}),M,(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex min-h-8 items-center`,children:N}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(J,{type:`button`,onClick:_,variant:`ghost`,children:L(`ticketEditor.cancel`)}),j&&(H?(0,Z.jsx)(xD,{label:L(`ticketEditor.planning`)}):(0,Z.jsxs)(J,{type:`button`,disabled:!le,variant:`outline`,onClick:()=>{le&&fe()},children:[(0,Z.jsx)(lm,{className:`h-4 w-4`}),j.label]})),(0,Z.jsxs)(J,{type:`submit`,disabled:!le||H,variant:dI[O.variant],children:[O.label,O.showAdvanceIcon&&(0,Z.jsx)(LE,{className:`h-3.5 w-3.5`})]}),k&&(0,Z.jsxs)(J,{type:`button`,disabled:!le||H,onClick:()=>{!le||H||k.onClick(W)},variant:dI[k.variant],children:[k.label,k.showAdvanceIcon&&(0,Z.jsx)(LE,{className:`h-3.5 w-3.5`})]}),A&&(0,Z.jsxs)(J,{type:`button`,disabled:!le||H,onClick:()=>{!le||H||A.onClick(W)},variant:dI[A.variant],children:[A.label,A.showAdvanceIcon&&(0,Z.jsx)(LE,{className:`h-3.5 w-3.5`})]})]})]})]}),ee&&v&&y&&(0,Z.jsx)(Uf,{bundles:oe,selectedBundleId:c.worktree_bundle_id,onSelectBundle:e=>ce({worktree_bundle_id:e}),onCreateBundle:pe,onDeleteBundle:me,onClose:()=>te(!1)})]})}})]})},pI=(e,t)=>Oe.t(`projects:memory.${e}`,t),mI=e=>pI(`stageLabels.${e}`),hI=e=>pI(`priorityLabels.${e}`),gI=e=>e.kind===`convention`?{kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implications:``,stages:e.stages.join(`
|
|
103
|
+
`),priority:e.priority}:{kind:`decision`,title:e.title,scope:e.scope??``,content:e.decision,rationale:e.rationale??``,implications:e.implications.join(`
|
|
104
|
+
`),stages:``,priority:`normal`},_I=e=>e.split(`
|
|
105
|
+
`).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),vI=e=>{let t=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`];return e.split(/\n|,/).map(e=>e.trim()).filter(e=>t.includes(e)).filter((e,t,n)=>n.indexOf(e)===t)},yI=e=>(e?.decisions.length??0)>0?`decisions`:(e?.conventions.length??0)>0?`conventions`:`generated-context`,bI=({suggestion:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let a=e.kind===`decision`?e.duplicate_match?.decision??null:null,o=pI(a?`suggested.saveAsNewDecision`:`suggested.accept`),s=e.kind===`decision`?e.decision:e.instruction;return(0,Z.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,Z.jsx)(q,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,children:pI(`suggested.badge`,{kind:e.kind})}),a&&(0,Z.jsx)(q,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`,children:pI(`suggested.duplicateBadge`)})]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:s})]})}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:pI(`suggested.review`)}),(0,Z.jsx)(J,{type:`button`,size:`sm`,disabled:t,onClick:()=>void r(e),children:o}),(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void i(e),children:pI(`suggested.dismiss`)})]})]})})},xI=({suggestion:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onStartEdit:o,onDraftChange:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{if(!e)return null;let d=e.kind===`decision`?e.duplicate_match?.decision??null:null,f=d?pI(`suggested.saveAsNewDecision`):pI(`suggested.acceptAs`,{kind:e.kind});return(0,Z.jsx)(Kl,{open:t,onOpenChange:a,children:(0,Z.jsxs)(Xl,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Z.jsxs)(Zl,{children:[(0,Z.jsx)($l,{children:e.title}),(0,Z.jsx)(eu,{children:pI(`suggested.reviewDescription`,{kind:e.kind})})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[d&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-amber-50`,children:pI(`suggested.duplicateTitle`)}),(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[d.title,`:`]}),` `,d.decision]})]}),n?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:pI(`editor.titleLabel`)}),(0,Z.jsx)(`input`,{"aria-label":pI(`editor.titleAriaLabel`),value:i.title,onChange:e=>s({...i,title:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:pI(`editor.contentLabel`)}),(0,Z.jsx)(`textarea`,{"aria-label":pI(`editor.contentAriaLabel`),value:i.content,onChange:e=>s({...i,content:e.target.value}),rows:5,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:pI(`editor.scopeLabel`)}),(0,Z.jsx)(`input`,{"aria-label":pI(`editor.scopeAriaLabel`),value:i.scope,onChange:e=>s({...i,scope:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:pI(`editor.rationaleLabel`)}),(0,Z.jsx)(`input`,{"aria-label":pI(`editor.rationaleAriaLabel`),value:i.rationale,onChange:e=>s({...i,rationale:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),i.kind===`decision`?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:pI(`editor.implicationsLabel`)}),(0,Z.jsx)(`textarea`,{"aria-label":pI(`editor.implicationsAriaLabel`),value:i.implications,onChange:e=>s({...i,implications:e.target.value}),rows:4,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:pI(`editor.stagesLabel`)}),(0,Z.jsx)(`textarea`,{"aria-label":pI(`editor.stagesLabel`),value:i.stages,onChange:e=>s({...i,stages:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:pI(`editor.priorityLabel`)}),(0,Z.jsxs)(`select`,{"aria-label":pI(`editor.priorityAriaLabel`),value:i.priority,onChange:e=>s({...i,priority:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`,children:[(0,Z.jsx)(`option`,{value:`critical`,children:pI(`priorityLabels.critical`)}),(0,Z.jsx)(`option`,{value:`normal`,children:pI(`priorityLabels.normal`)}),(0,Z.jsx)(`option`,{value:`low`,children:pI(`priorityLabels.low`)})]})]})]})]}):(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-3 text-sm text-foreground`,children:e.kind===`decision`?e.decision:e.instruction}),(0,Z.jsxs)(`div`,{className:`space-y-2 text-xs leading-5 text-muted-foreground`,children:[e.scope&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:pI(`suggested.scope`)}),` `,e.scope]}),e.rationale&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:pI(`suggested.why`)}),` `,e.rationale]}),e.kind===`decision`&&e.implications.length>0&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:pI(`suggested.implications`)}),` `,e.implications.join(`; `)]}),e.kind===`convention`&&e.stages.length>0&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:pI(`suggested.stages`)}),` `,e.stages.map(e=>mI(e)).join(`, `)]}),e.kind===`convention`&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:pI(`suggested.priority`)}),` `,hI(e.priority)]})]})]})]}),(0,Z.jsx)(Ql,{className:`border-t border-border pt-4`,children:n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(J,{type:`button`,variant:`ghost`,disabled:r,onClick:c,children:pI(`editor.cancel`)}),(0,Z.jsx)(J,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>void u(e),children:pI(`suggested.dismissKind`,{kind:e.kind})}),d&&(0,Z.jsx)(J,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:pI(`suggested.updateExistingDecision`)}),(0,Z.jsx)(J,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(J,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>a(!1),children:pI(`suggested.close`)}),(0,Z.jsx)(J,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>void u(e),children:pI(`suggested.dismissKind`,{kind:e.kind})}),(0,Z.jsx)(J,{type:`button`,variant:`outline`,disabled:r,onClick:()=>o(e),children:pI(`suggested.edit`)}),d&&(0,Z.jsx)(J,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:pI(`suggested.updateExistingDecision`)}),(0,Z.jsx)(J,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]})})]})})},SI=({activeTab:e,isLoading:t,memory:n,onActiveTabChange:r,onOpenChange:i,open:a})=>(0,Z.jsx)(Kl,{open:a,onOpenChange:i,children:(0,Z.jsxs)(Xl,{className:`max-h-[85vh] overflow-y-auto sm:max-w-4xl`,children:[(0,Z.jsxs)(Zl,{children:[(0,Z.jsx)($l,{children:pI(`ticketPanel.title`)}),(0,Z.jsx)(eu,{children:pI(`ticketPanel.dialogDescription`)})]}),(0,Z.jsxs)(Qp,{value:e,onValueChange:e=>r(e),className:`flex flex-col gap-4`,children:[(0,Z.jsxs)($p,{className:`flex h-auto w-full flex-wrap justify-start`,children:[(0,Z.jsx)(em,{value:`decisions`,children:pI(`ticketPanel.decisionsTab`)}),(0,Z.jsx)(em,{value:`conventions`,children:pI(`ticketPanel.conventionsTab`)}),(0,Z.jsx)(em,{value:`generated-context`,children:pI(`ticketPanel.generatedContextTab`)})]}),(0,Z.jsx)(tm,{value:`decisions`,className:`mt-0 outline-none`,children:t?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:pI(`ticketPanel.loading`)}):n&&n.decisions.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2 text-sm text-foreground`,children:n.decisions.map(e=>(0,Z.jsxs)(`li`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[e.title,`:`]}),` `,e.decision]},e.id))}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:pI(`ticketPanel.noAcceptedDecisions`)})}),(0,Z.jsx)(tm,{value:`conventions`,className:`mt-0 outline-none`,children:t?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:pI(`ticketPanel.loading`)}):n&&n.conventions.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2 text-sm text-foreground`,children:n.conventions.map(e=>(0,Z.jsxs)(`li`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[e.title,`:`]}),` `,e.instruction]},e.id))}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:pI(`ticketPanel.noConventions`)})}),(0,Z.jsx)(tm,{value:`generated-context`,className:`mt-0 outline-none`,children:t?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:pI(`ticketPanel.loading`)}):n?.generated_context?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[n.generated_context.is_stale&&(0,Z.jsx)(`p`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:pI(`ticketPanel.generatedContextStaleWarning`)}),n.generated_context.architecture_summary&&(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2 text-sm text-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:pI(`ticketPanel.architecture`)}),` `,n.generated_context.architecture_summary]}),n.generated_context.key_areas.length>0?(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,Z.jsx)(`h5`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:pI(`ticketPanel.relevantAreas`)}),(0,Z.jsx)(`ul`,{className:`mt-2 space-y-2 text-sm text-foreground`,children:n.generated_context.key_areas.map(e=>(0,Z.jsx)(`li`,{children:e},e))})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:pI(`ticketPanel.noRelevantAreas`)})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:pI(`ticketPanel.noGeneratedContext`)})})]}),(0,Z.jsx)(Ql,{className:`border-t border-border pt-4`,showCloseButton:!0})]})}),CI=({projectId:e,ticketId:t,memoryEnabled:n,refreshKey:r,onSuggestionsChanged:i})=>{let[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)([]),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(`decisions`),[h,g]=(0,X.useState)(null),[_,y]=(0,X.useState)(null),[b,x]=(0,X.useState)({kind:`decision`,title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`}),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(0);if((0,X.useEffect)(()=>{if(!e||!n){u(!1),o(null),c([]);return}let r=new AbortController;return u(!0),o(null),c([]),Promise.all([de(e,t,r.signal),De(e,t,r.signal)]).then(([e,t])=>{r.signal.aborted||(o(e),c(t.suggestions),y(e=>e&&!t.suggestions.some(t=>t.id===e)?null:e),g(e=>e&&!t.suggestions.some(t=>t.id===e)?null:e))}).catch(e=>{if(!r.signal.aborted){if(e instanceof we&&(e.status===404||e.status===409)){o(null),c([]);return}o(null),c([])}}).finally(()=>{r.signal.aborted||u(!1)}),()=>{r.abort()}},[n,e,r,w,t]),!n||!e)return null;let E=s.length>0,D=a?.decisions.length??0,O=a?.conventions.length??0,k=!!a?.generated_context,A=pI(l?`ticketPanel.summaryLoading`:D>0||O>0||k?`ticketPanel.summarySaved`:`ticketPanel.summaryEmpty`),j=h?s.find(e=>e.id===h)??null:null,M=e=>{e&&m(yI(a)),f(e)},N=e=>{g(e.id),y(e.id),x(gI(e))},P=()=>{y(null),x({title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`})},F=e=>{_&&_!==e.id&&P(),g(e.id)},I=e=>{e||(g(null),_&&P())},L=async(t,n)=>{if(!e)return;let r=_===t.id?b:gI(t),a=r.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:_I(r.implications)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:vI(r.stages),priority:r.priority};C(t.id);try{if(n){if(t.kind!==`decision`)throw Error(pI(`messages.onlyDecisionSuggestionsCanUpdate`));let n=t.duplicate_match?.decision;if(!n)throw Error(pI(`messages.noExistingDecision`));await v(e,t.id,n.id,a)}else await H(e,t.id,a);P(),g(null),T(e=>e+1),i?.()}catch(e){Q.error(e instanceof Error?e.message:pI(`messages.saveSuggestionError`),{id:`project-memory-suggestion-error`})}finally{C(null)}},R=async t=>{if(e){C(t.id);try{await pe(e,t.id),_===t.id&&P(),h===t.id&&g(null),T(e=>e+1),i?.()}catch(e){Q.error(e instanceof Error?e.message:pI(`messages.dismissSuggestionError`),{id:`project-memory-suggestion-error`})}finally{C(null)}}};return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(`section`,{className:`rounded-lg border border-border bg-card/70`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:pI(`ticketPanel.title`)}),l&&(0,Z.jsx)(q,{variant:`outline`,children:pI(`ticketPanel.loadingBadge`)}),!l&&a?.generated_context?.is_stale&&(0,Z.jsx)(q,{variant:`outline`,className:`border-amber-500/40 bg-amber-500/10 text-amber-100`,children:pI(`ticketPanel.scanStaleBadge`)})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:A})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:justify-end`,children:[!l&&(0,Z.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-2 whitespace-nowrap`,children:[(0,Z.jsx)(q,{variant:`outline`,children:pI(`ticketPanel.decisionCount`,{count:D})}),(0,Z.jsx)(q,{variant:`outline`,children:pI(`ticketPanel.conventionCount`,{count:O})}),(0,Z.jsx)(q,{variant:`outline`,children:pI(`ticketPanel.scanCount`,{count:+!!k})})]}),(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>M(!0),children:pI(`ticketPanel.viewDetails`)})]})]})}),E&&(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:pI(`ticketPanel.suggestionsTitle`,{count:s.length})}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:pI(`ticketPanel.suggestionsDescription`)})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:s.map(e=>(0,Z.jsx)(bI,{suggestion:e,isPending:S===e.id,onReview:F,onAccept:e=>L(e,!1),onDismiss:R},e.id))})]}),(0,Z.jsx)(SI,{open:d,onOpenChange:M,isLoading:l,memory:a,activeTab:p,onActiveTabChange:m}),(0,Z.jsx)(xI,{suggestion:j,isOpen:!!j,isEditing:_===j?.id,isPending:S===j?.id,draft:_===j?.id?b:j?gI(j):b,onOpenChange:I,onStartEdit:N,onDraftChange:x,onCancelEdit:P,onAccept:L,onDismiss:R})]})},wI=({content:e,externalSource:t=null})=>{let{t:n}=ht(`common`);return(0,Z.jsxs)(`section`,{"aria-label":n(`ticketStaticDescription.ariaLabel`),className:`min-h-0 flex-1 overflow-y-auto rounded-xl border border-border/80 bg-card/70 px-4 py-4`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-widest text-muted-foreground`,children:n(`ticketStaticDescription.title`)}),(0,Z.jsx)(WD,{externalSource:t,className:`mt-3`}),(0,Z.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:e})]})},TI=[`h-7 w-auto max-w-full rounded-md border-border/70 bg-transparent px-2.5 text-[11px] text-muted-foreground shadow-none`,`hover:border-border hover:bg-background/60 hover:text-foreground`,`focus-visible:border-ring/70 focus-visible:ring-2 focus-visible:ring-ring/20`,`disabled:border-border/40 disabled:bg-transparent disabled:text-muted-foreground/50`,`[&_svg]:ml-1 [&_svg]:h-3.5 [&_svg]:w-3.5 [&_svg]:text-muted-foreground`].join(` `),EI=[`flex h-7 shrink-0 items-center rounded-md border border-border/70 bg-transparent px-2.5`].join(` `),DI=[`h-2 rounded-full`,`h-2 rounded-full`,`h-2 rounded-full`],OI=[`w-[4.75rem]`,`w-[4.25rem]`,`w-[3.5rem]`],kI=({className:e,dataTestId:t})=>(0,Z.jsx)(`div`,{"data-testid":t,className:W(`flex min-w-0 flex-wrap items-center gap-1.5`,e),children:OI.map((e,t)=>(0,Z.jsx)(`div`,{className:EI,children:(0,Z.jsx)(Wu,{className:W(DI[t],e)})},e))}),AI=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h})=>{let g=r&&s!==null&&s.variants.length>0;return!r&&!i?null:(0,Z.jsxs)(`div`,{className:W(`flex min-w-0 flex-wrap items-center gap-1.5`,h),children:[r?(0,Z.jsx)(Au,{model:e,showModelSelector:!0,availableModels:a,onModelChange:c,selectId:d,label:``,triggerAriaLabel:`Choose model`,disabled:m,className:`min-w-0`,triggerClassName:TI}):null,g?(0,Z.jsx)(ju,{variant:t,selectedModel:s,showVariantSelector:!0,onVariantChange:l,selectId:f,label:``,triggerAriaLabel:`Choose model variant`,disabled:m,className:`min-w-0`,triggerClassName:TI}):null,i?(0,Z.jsx)(iI,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,label:``,triggerAriaLabel:`Choose skills`,disabled:m,className:`min-w-0`,triggerClassName:TI,showSelectedBadges:!1}):null]})},jI=2,MI=1,NI=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(jI,Math.floor(u/e.css.cell.width)),rows:Math.max(MI,Math.floor(l/e.css.cell.height))}}},PI=Object.defineProperty,FI=Object.getOwnPropertyDescriptor,II=(e,t)=>{for(var n in t)PI(e,n,{get:t[n],enumerable:!0})},LI=(e,t,n,r)=>{for(var i=r>1?void 0:r?FI(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&&PI(t,n,i),i},RI=(e,t)=>(n,r)=>t(n,r,e),zI=`Terminal input`,BI={get:()=>zI,set:e=>zI=e},VI=`Too much output to announce, navigate to rows manually to read`,HI={get:()=>VI,set:e=>VI=e};function UI(e){return e.replace(/\r?\n/g,`\r`)}function WI(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function GI(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function KI(e,t,n,r){e.stopPropagation(),e.clipboardData&&qI(e.clipboardData.getData(`text/plain`),t,n,r)}function qI(e,t,n,r){e=UI(e),e=WI(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function JI(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 YI(e,t,n,r,i){JI(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function XI(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ZI(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 QI=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}},$I=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}else 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}},eL=``,tL=` `,nL=class e{constructor(){this.fg=0,this.bg=0,this.extended=new rL}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)==0}isBgDefault(){return(this.bg&50331648)==0}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)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},rL=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}},iL=class e extends nL{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new rL,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?XI(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()]}},aL=`di$target`,oL=`di$dependencies`,sL=new Map;function cL(e){return e[oL]||[]}function lL(e){if(sL.has(e))return sL.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);uL(t,e,r)};return t._id=e,sL.set(e,t),t}function uL(e,t,n){t[aL]===t?t[oL].push({id:e,index:n}):(t[oL]=[{id:e,index:n}],t[aL]=t)}var dL=lL(`BufferService`),fL=lL(`CoreMouseService`),pL=lL(`CoreService`),mL=lL(`CharsetService`),hL=lL(`InstantiationService`),gL=lL(`LogService`),_L=lL(`OptionsService`),vL=lL(`OscLinkService`),yL=lL(`UnicodeService`),bL=lL(`DecorationService`),xL=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 iL,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}else 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):SL(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)}};xL=LI([RI(0,dL),RI(1,_L),RI(2,vL)],xL);function SL(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
106
|
+
|
|
107
|
+
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 CL=lL(`CharSizeService`),wL=lL(`CoreBrowserService`),TL=lL(`MouseService`),EL=lL(`RenderService`),DL=lL(`SelectionService`),OL=lL(`CharacterJoinerService`),kL=lL(`ThemeService`),AL=lL(`LinkProviderService`),jL=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?LL.isErrorNoTelemetry(e)?new LL(e.message+`
|
|
108
|
+
|
|
109
|
+
`+e.stack):Error(e.message+`
|
|
110
|
+
|
|
111
|
+
`+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 ML(e){PL(e)||jL.onUnexpectedError(e)}var NL=`Canceled`;function PL(e){return e instanceof FL?!0:e instanceof Error&&e.name===NL&&e.message===NL}var FL=class extends Error{constructor(){super(NL),this.name=this.message}};function IL(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var LL=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`}},RL=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function zL(e,t,n=0,r=e.length){let i=n,a=r;for(;i<a;){let n=Math.floor((i+a)/2);t(e[n])?i=n+1:a=n}return i-1}var BL=class e{constructor(e){this._array=e,this._findLastMonotonousLastIdx=0}findLastMonotonous(t){if(e.assertInvariants){if(this._prevFindLastPredicate){for(let e of this._array)if(this._prevFindLastPredicate(e)&&!t(e))throw Error(`MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.`)}this._prevFindLastPredicate=t}let n=zL(this._array,t,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=n+1,n===-1?void 0:this._array[n]}};BL.assertInvariants=!1;function VL(e,t=0){return e[e.length-(1+t)]}var HL;(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})(HL||={});function UL(e,t){return(n,r)=>t(e(n),e(r))}var WL=(e,t)=>e-t,GL=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):!0))}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):!0),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||HL.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};GL.empty=new GL(e=>{});function KL(e,t){let n=Object.create(null);for(let r of e){let e=t(r),i=n[e];i||=n[e]=[],i.push(r)}return n}var qL=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){return this.map.get(e)||new Set}};function JL(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 YL;(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})(YL||={});var XL=!1,ZL=null,QL=class e{constructor(){this.livingDisposables=new Map}getDisposableData(t){let n=this.livingDisposables.get(t);return n||(n={parent:null,source:null,isSingleton:!1,value:t,idx:e.idx++},this.livingDisposables.set(t,n)),n}trackDisposable(e){let t=this.getDisposableData(e);t.source||=Error().stack}setParent(e,t){let n=this.getDisposableData(e);n.parent=t}markAsDisposed(e){this.livingDisposables.delete(e)}markAsSingleton(e){this.getDisposableData(e).isSingleton=!0}getRootParent(e,t){let n=t.get(e);if(n)return n;let r=e.parent?this.getRootParent(this.getDisposableData(e.parent),t):e;return t.set(e,r),r}getTrackedDisposables(){let e=new Map;return[...this.livingDisposables.entries()].filter(([,t])=>t.source!==null&&!this.getRootParent(t,e).isSingleton).flatMap(([e])=>e)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let e=new Map,t=[...this.livingDisposables.values()].filter(t=>t.source!==null&&!this.getRootParent(t,e).isSingleton);if(t.length===0)return;let r=new Set(t.map(e=>e.value));if(n=t.filter(e=>!(e.parent&&r.has(e.parent))),n.length===0)throw Error(`There are cyclic diposable chains!`)}if(!n)return;function r(e){function t(e,t){for(;e.length>0&&t.some(t=>typeof t==`string`?t===e[0]:e[0].match(t));)e.shift()}let n=e.source.split(`
|
|
112
|
+
`).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new qL;for(let e of n){let t=r(e);for(let n=0;n<=t.length;n++)i.add(t.slice(0,n).join(`
|
|
113
|
+
`),e)}n.sort(UL(e=>e.idx,WL));let a=``,o=0;for(let t of n.slice(0,e)){o++;let e=r(t),s=[];for(let t=0;t<e.length;t++){let a=e[t];a=`(shared with ${i.get(e.slice(0,t+1).join(`
|
|
114
|
+
`)).size}/${n.length} leaks) at ${a}`;let o=KL([...i.get(e.slice(0,t).join(`
|
|
115
|
+
`))].map(e=>r(e)[t]),e=>e);delete o[e[t]];for(let[e,t]of Object.entries(o))s.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);s.unshift(a)}a+=`
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
==================== Leaking disposable ${o}/${n.length}: ${t.value.constructor.name} ====================
|
|
119
|
+
${s.join(`
|
|
120
|
+
`)}
|
|
121
|
+
============================================================
|
|
122
|
+
|
|
123
|
+
`}return n.length>e&&(a+=`
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
... and ${n.length-e} more leaking disposables
|
|
127
|
+
|
|
128
|
+
`),{leaks:n,details:a}}};QL.idx=0;function $L(e){ZL=e}if(XL){let e=`__is_disposable_tracked__`;$L(new class{trackDisposable(t){let n=Error(`Potentially leaked disposable`).stack;setTimeout(()=>{t[e]||console.log(n)},3e3)}setParent(t,n){if(t&&t!==uR.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==uR.None)try{t[e]=!0}catch{}}markAsSingleton(e){}})}function eR(e){return ZL?.trackDisposable(e),e}function tR(e){ZL?.markAsDisposed(e)}function nR(e,t){ZL?.setParent(e,t)}function rR(e,t){if(ZL)for(let n of e)ZL.setParent(n,t)}function iR(e){return ZL?.markAsSingleton(e),e}function aR(e){if(YL.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}else if(e)return e.dispose(),e}function oR(...e){let t=sR(()=>aR(e));return rR(e,t),t}function sR(e){let t=eR({dispose:JL(()=>{tR(t),e()})});return t}var cR=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,eR(this)}dispose(){this._isDisposed||(tR(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{aR(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return nR(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),nR(e,null))}};cR.DISABLE_DISPOSED_WARNING=!1;var lR=cR,uR=class{constructor(){this._store=new lR,eR(this),nR(this._store,this)}dispose(){tR(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};uR.None=Object.freeze({dispose(){}});var dR=class{constructor(){this._isDisposed=!1,eR(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&nR(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,tR(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&nR(e,null),e}},fR=typeof window==`object`?window:globalThis,pR=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};pR.Undefined=new pR(void 0);var mR=pR,hR=class{constructor(){this._first=mR.Undefined,this._last=mR.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===mR.Undefined}clear(){let e=this._first;for(;e!==mR.Undefined;){let t=e.next;e.prev=mR.Undefined,e.next=mR.Undefined,e=t}this._first=mR.Undefined,this._last=mR.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new mR(e);if(this._first===mR.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==mR.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==mR.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==mR.Undefined&&e.next!==mR.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===mR.Undefined&&e.next===mR.Undefined?(this._first=mR.Undefined,this._last=mR.Undefined):e.next===mR.Undefined?(this._last=this._last.prev,this._last.next=mR.Undefined):e.prev===mR.Undefined&&(this._first=this._first.next,this._first.prev=mR.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==mR.Undefined;)yield e.element,e=e.next}},gR=globalThis.performance&&typeof globalThis.performance.now==`function`,_R=class e{static create(t){return new e(t)}constructor(e){this._now=gR&&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}},vR=!1,yR=!1,bR=!1,xR;(e=>{e.None=()=>uR.None;function t(e){if(bR){let{onDidAddListener:t}=e,n=DR.create(),r=0;e.onDidAddListener=()=>{++r===2&&(console.warn(`snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here`),n.print()),t?.()}}}function n(e,t){return f(e,()=>{},0,void 0,!0,void 0,t)}e.defer=n;function r(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=r;function i(e,t,n){return u((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=i;function a(e,t,n){return u((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=a;function o(e,t,n){return u((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=o;function s(e){return e}e.signal=s;function c(...e){return(t,n=null,r)=>d(oR(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=c;function l(e,t,n,r){let a=n;return i(e,e=>(a=t(a,e),a),r)}e.reduce=l;function u(e,n){let r,i={onWillAddFirstListener(){r=e(a.fire,a)},onDidRemoveLastListener(){r?.dispose()}};n||t(i);let a=new FR(i);return n?.add(a),a.event}function d(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function f(e,n,r=100,i=!1,a=!1,o,s){let c,l,u,d=0,f,p={leakWarningThreshold:o,onWillAddFirstListener(){c=e(e=>{d++,l=n(l,e),i&&!u&&(m.fire(l),l=void 0),f=()=>{let e=l;l=void 0,u=void 0,(!i||d>1)&&m.fire(e),d=0},typeof r==`number`?(clearTimeout(u),u=setTimeout(f,r)):u===void 0&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){a&&d>0&&f?.()},onDidRemoveLastListener(){f=void 0,c.dispose()}};s||t(p);let m=new FR(p);return s?.add(m),m.event}e.debounce=f;function p(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=p;function m(e,t=(e,t)=>e===t,n){let r=!0,i;return o(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=m;function h(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=h;function g(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 FR({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=g;function _(e,t){return(n,r,i)=>{let a=t(new y);return e(function(e){let t=a.evaluate(e);t!==v&&n.call(r,t)},void 0,i)}}e.chain=_;let v=Symbol(`HaltChainable`);class y{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:v),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:v}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===v)break;return e}}function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new FR({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=b;function x(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new FR({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=x;function S(e){return new Promise(t=>r(e)(t))}e.toPromise=S;function C(e){let t=new FR;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=C;function w(e,t){return e(e=>t.fire(e))}e.forward=w;function T(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=T;class E{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||t(r),this.emitter=new FR(r),n&&n.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 D(e,t){return new E(e,t).emitter.event}e.fromObservable=D;function O(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 lR?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=O})(xR||={});var SR=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 _R,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}}};SR.all=new Set,SR._idPool=0;var CR=SR,wR=-1,TR=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 OR(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}};TR._idPool=1;var ER=TR,DR=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
129
|
+
`).slice(2).join(`
|
|
130
|
+
`))}},OR=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},kR=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},AR=0,jR=class{constructor(e){this.value=e,this.id=AR++}},MR=2,NR=(e,t)=>{if(e instanceof jR)t(e);else for(let n=0;n<e.length;n++){let r=e[n];r&&t(r)}},PR;if(vR){let e=[];setInterval(()=>{e.length!==0&&(console.warn(`[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:`),console.warn(e.join(`
|
|
131
|
+
`)),e.length=0)},3e3),PR=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var FR=class{constructor(e){this._size=0,this._options=e,this._leakageMon=wR>0||this._options?.leakWarningThreshold?new ER(e?.onListenerError??ML,this._options?.leakWarningThreshold??wR):void 0,this._perfMon=this._options?._profName?new CR(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(yR){let e=this._listeners;queueMicrotask(()=>{NR(e,e=>e.stack?.print())})}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 kR(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||ML)(n),uR.None}if(this._disposed)return uR.None;t&&(e=e.bind(t));let r=new jR(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=DR.create(),i=this._leakageMon.check(r.stack,this._size+1)),yR&&(r.stack=DR.create()),this._listeners?this._listeners instanceof jR?(this._deliveryQueue??=new IR,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=sR(()=>{PR?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof lR?n.add(a):Array.isArray(n)&&n.push(a),PR){let e=Error().stack.split(`
|
|
132
|
+
`).slice(2,3).join(`
|
|
133
|
+
`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);PR.register(a,t?.[2]??e,a)}return 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*MR<=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||ML;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 jR)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}},IR=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}},LR=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new FR,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new FR,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};LR.INSTANCE=new LR;var RR=LR;function zR(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}RR.INSTANCE.onDidChangeZoomLevel;function BR(e){return RR.INSTANCE.getZoomFactor(e)}RR.INSTANCE.onDidChangeFullscreen;var VR=typeof navigator==`object`?navigator.userAgent:``,HR=VR.indexOf(`Firefox`)>=0,UR=VR.indexOf(`AppleWebKit`)>=0,WR=VR.indexOf(`Chrome`)>=0,GR=!WR&&VR.indexOf(`Safari`)>=0;VR.indexOf(`Electron/`),VR.indexOf(`Android`);var KR=!1;if(typeof fR.matchMedia==`function`){let e=fR.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=fR.matchMedia(`(display-mode: fullscreen)`);KR=e.matches,zR(fR,e,({matches:e})=>{KR&&t.matches||(KR=e)})}function qR(){return KR}var JR=`en`,YR=!1,XR=!1,ZR=!1,QR=!1,$R=!1,ez=JR,tz,nz=globalThis,rz;typeof nz.vscode<`u`&&typeof nz.vscode.process<`u`?rz=nz.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(rz=process);var iz=typeof rz?.versions?.electron==`string`&&rz?.type===`renderer`;if(typeof rz==`object`){YR=rz.platform===`win32`,XR=rz.platform===`darwin`,ZR=rz.platform===`linux`,ZR&&rz.env.SNAP&&rz.env.SNAP_REVISION,rz.env.CI||rz.env.BUILD_ARTIFACTSTAGINGDIRECTORY,ez=JR;let e=rz.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,ez=t.resolvedLanguage||JR,t.languagePack?.translationsConfigFile}catch{}QR=!0}else typeof navigator==`object`&&!iz?(tz=navigator.userAgent,YR=tz.indexOf(`Windows`)>=0,XR=tz.indexOf(`Macintosh`)>=0,(tz.indexOf(`Macintosh`)>=0||tz.indexOf(`iPad`)>=0||tz.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,ZR=tz.indexOf(`Linux`)>=0,tz?.indexOf(`Mobi`),$R=!0,ez=globalThis._VSCODE_NLS_LANGUAGE||JR,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var az=YR,oz=XR,sz=ZR,cz=QR;$R&&typeof nz.importScripts==`function`&&nz.origin;var lz=tz,uz=ez,dz;(e=>{function t(){return uz}e.value=t;function n(){return uz.length===2?uz===`en`:uz.length>=3?uz[0]===`e`&&uz[1]===`n`&&uz[2]===`-`:!1}e.isDefaultVariant=n;function r(){return uz===`en`}e.isDefault=r})(dz||={});var fz=typeof nz.postMessage==`function`&&!nz.importScripts;(()=>{if(fz){let e=[];nz.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}),nz.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var pz=!!(lz&&lz.indexOf(`Chrome`)>=0);lz&&lz.indexOf(`Firefox`),!pz&&lz&&lz.indexOf(`Safari`),lz&&lz.indexOf(`Edg/`),lz&&lz.indexOf(`Android`);var mz=typeof navigator==`object`?navigator:{};cz||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||mz&&mz.clipboard&&mz.clipboard.writeText,cz||mz&&mz.clipboard&&mz.clipboard.readText,cz||qR()||mz.keyboard,`ontouchstart`in fR||mz.maxTouchPoints,fR.PointerEvent&&(`ontouchstart`in fR||navigator.maxTouchPoints);var hz=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},gz=new hz,_z=new hz,vz=new hz,yz=Array(230),bz;(e=>{function t(e){return gz.keyCodeToStr(e)}e.toString=t;function n(e){return gz.strToKeyCode(e)}e.fromString=n;function r(e){return _z.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return vz.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return _z.strToKeyCode(e)||vz.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return gz.keyCodeToStr(e)}e.toElectronAccelerator=o})(bz||={});var xz=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Sz([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Sz=class{constructor(e){if(e.length===0)throw IL(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function Cz(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return bz.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(HR)switch(t){case 59:return 85;case 60:if(sz)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(oz)return 57;break}else if(UR&&(oz&&t===93||!oz&&t===92))return 57;return yz[t]||0}var wz=oz?256:2048,Tz=512,Ez=1024,Dz=oz?2048:256,Oz=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=Cz(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=wz),this.altKey&&(t|=Tz),this.shiftKey&&(t|=Ez),this.metaKey&&(t|=Dz),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new xz(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},kz=new WeakMap;function Az(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var jz=class{static getSameOriginWindowChain(e){let t=kz.get(e);if(!t){t=[],kz.set(e,t);let n=e,r;do r=Az(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},Mz=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=jz.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Nz=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(WR){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)r?this.deltaY=t.wheelDeltaY/(120*i):this.deltaY=t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?HR&&!oz?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)GR&&az?this.deltaX=-(t.wheelDeltaX/120):r?this.deltaX=t.wheelDeltaX/(120*i):this.deltaX=t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?HR&&!oz?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*i):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Pz=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Fz;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof Iz?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:xR.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Pz})})(Fz||={});var Iz=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?Pz:(this._emitter||=new FR,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},Lz=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new RL(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new RL(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Rz=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new RL(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=sR(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var zz;(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})(zz||={});var Bz=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 FR,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 xR.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())}};Bz.EMPTY=Bz.fromArray([]);function Vz(e){return 55296<=e&&e<=56319}function Hz(e){return 56320<=e&&e<=57343}function Uz(e,t){return(e-55296<<10)+(t-56320)+65536}function Wz(e){return Gz(e,0)}function Gz(e,t){switch(typeof e){case`object`:return e===null?Kz(349,t):Array.isArray(e)?Yz(e,t):Xz(e,t);case`string`:return Jz(e,t);case`boolean`:return qz(e,t);case`number`:return Kz(e,t);case`undefined`:return Kz(937,t);default:return Kz(617,t)}}function Kz(e,t){return(t<<5)-t+e|0}function qz(e,t){return Kz(e?433:863,t)}function Jz(e,t){t=Kz(149417,t);for(let n=0,r=e.length;n<r;n++)t=Kz(e.charCodeAt(n),t);return t}function Yz(e,t){return t=Kz(104579,t),e.reduce((e,t)=>Gz(t,e),t)}function Xz(e,t){return t=Kz(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Jz(n,t),Gz(e[n],t)),t)}function Zz(e,t,n=32){let r=n-t,i=~((1<<r)-1);return(e<<t|(i&e)>>>r)>>>0}function Qz(e,t=0,n=e.byteLength,r=0){for(let i=0;i<n;i++)e[t+i]=r}function $z(e,t,n=`0`){for(;e.length<t;)e=n+e;return e}function eB(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``):$z((e>>>0).toString(16),t/4)}var tB=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(Vz(a))if(o+1<t){let t=e.charCodeAt(o+1);Hz(t)?(o++,s=Uz(a,t)):s=65533}else{i=a;break}else Hz(a)&&(s=65533);if(r=this._push(n,r,s),o++,o<t)a=e.charCodeAt(o);else break}this._buffLen=r,this._leftoverHighSurrogate=i}_push(e,t,n){return n<128?e[t++]=n:n<2048?(e[t++]=192|(n&1984)>>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),eB(this._h0)+eB(this._h1)+eB(this._h2)+eB(this._h3)+eB(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,Qz(this._buff,this._buffLen),this._buffLen>56&&(this._step(),Qz(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,Zz(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=Zz(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=Zz(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};tB._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:nB,getWindow:rB,getDocument:iB,getWindows:aB,getWindowsCount:oB,getWindowId:sB,getWindowById:cB,hasWindow:lB,onDidRegisterWindow:uB,onWillUnregisterWindow:dB,onDidUnregisterWindow:fB}=function(){let e=new Map,t={window:fR,disposables:new lR};e.set(fR.vscodeWindowId,t);let n=new FR,r=new FR,i=new FR;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return uR.None;let a=new lR,o={window:t,disposables:a.add(new lR)};return e.set(t.vscodeWindowId,o),a.add(sR(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(mB(t,CB.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:fR},getDocument(e){return rB(e).document}}}(),pB=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function mB(e,t,n,r){return new pB(e,t,n,r)}function hB(e,t){return function(n){return t(new Mz(e,n))}}function gB(e){return function(t){return e(new Oz(t))}}var _B=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=hB(rB(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=gB(n)),mB(e,t,i,r)},vB,yB=class extends Rz{constructor(e){super(),this.defaultTarget=e&&rB(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},bB=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){ML(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(bB.sort),a.shift().execute();r.set(i,!1)};vB=(t,r,a=0)=>{let o=sB(t),s=new bB(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var xB=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};xB.None=new xB(0,0);function SB(e){let t=e.getBoundingClientRect(),n=rB(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=Wz(n),a=r.get(i);if(a)a.users+=1;else{let o=new FR,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(sR(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var CB={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:UR?`webkitAnimationStart`:`animationstart`,ANIMATION_END:UR?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:UR?`webkitAnimationIteration`:`animationiteration`},wB=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function TB(e,t,n,...r){let i=wB.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function EB(e,t,...n){return TB(`http://www.w3.org/1999/xhtml`,e,t,...n)}EB.SVG=function(e,t,...n){return TB(`http://www.w3.org/2000/svg`,e,t,...n)};var DB=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=OB(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=OB(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=OB(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=OB(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=OB(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=OB(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=OB(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=OB(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=OB(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=OB(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=OB(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=OB(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=OB(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=OB(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function OB(e){return typeof e==`number`?`${e}px`:e}function kB(e){return new DB(e)}var AB=class{constructor(){this._hooks=new lR,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(sR(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=rB(e)}this._hooks.add(mB(a,CB.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(mB(a,CB.POINTER_UP,e=>this.stopMonitoring(!0)))}};function jB(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var MB;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(MB||={});var NB=class e extends uR{constructor(){super(),this.dispatched=!1,this.targets=new hR,this.ignoreTargets=new hR,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(xR.runAndSubscribe(uB,({window:e,disposables:t})=>{t.add(mB(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(mB(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(mB(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:fR,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=iR(new e),sR(e.INSTANCE.targets.push(t))):uR.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=iR(new e),sR(e.INSTANCE.ignoreTargets.push(t))):uR.None}static isTouchDevice(){return`ontouchstart`in fR||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(MB.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-VL(s.rollingPageX))<30&&Math.abs(s.initialPageY-VL(s.rollingPageY))<30){let e=this.newGestureEvent(MB.Tap,s.initialTarget);e.pageX=VL(s.rollingPageX),e.pageY=VL(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-VL(s.rollingPageX))<30&&Math.abs(s.initialPageY-VL(s.rollingPageY))<30){let e=this.newGestureEvent(MB.Contextmenu,s.initialTarget);e.pageX=VL(s.rollingPageX),e.pageY=VL(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=VL(s.rollingPageX),n=VL(s.rollingPageY),i=VL(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(MB.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===MB.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else (t.type===MB.Change||t.type===MB.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=vB(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(MB.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(MB.Change,i.initialTarget);a.translationX=r.pageX-VL(i.rollingPageX),a.translationY=r.pageY-VL(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};NB.SCROLL_FRICTION=-.005,NB.HOLD_DELAY=700,NB.CLEAR_TAP_COUNT_TIME=400,LI([jB],NB,`isTouchDevice`,1);var PB=NB,FB=class extends uR{onclick(e,t){this._register(mB(e,CB.CLICK,n=>t(new Mz(rB(e),n))))}onmousedown(e,t){this._register(mB(e,CB.MOUSE_DOWN,n=>t(new Mz(rB(e),n))))}onmouseover(e,t){this._register(mB(e,CB.MOUSE_OVER,n=>t(new Mz(rB(e),n))))}onmouseleave(e,t){this._register(mB(e,CB.MOUSE_LEAVE,n=>t(new Mz(rB(e),n))))}onkeydown(e,t){this._register(mB(e,CB.KEY_DOWN,e=>t(new Oz(e))))}onkeyup(e,t){this._register(mB(e,CB.KEY_UP,e=>t(new Oz(e))))}oninput(e,t){this._register(mB(e,CB.INPUT,t))}onblur(e,t){this._register(mB(e,CB.BLUR,t))}onfocus(e,t){this._register(mB(e,CB.FOCUS,t))}onchange(e,t){this._register(mB(e,CB.CHANGE,t))}ignoreGesture(e){return PB.ignoreTarget(e)}},IB=11,LB=class extends FB{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=IB+`px`,this.domNode.style.height=IB+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new AB),this._register(_B(this.bgDomNode,CB.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(_B(this.domNode,CB.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new yB),this._pointerdownScheduleRepeatTimer=this._register(new Lz)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,rB(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},RB=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},zB=class extends uR{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new FR),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new RB(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new UB(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=UB.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},BB=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function VB(e,t){let n=t-e;return function(t){return e+n*GB(t)}}function HB(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var UB=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),HB(VB(e,r),VB(i,t),.33)}return VB(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new BB(this.scrollLeft(t),this.scrollTop(t),!1):new BB(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){return r+=10,new e(t,n,Date.now()-10,r)}};function WB(e){return e**3}function GB(e){return 1-WB(1-e)}var KB=class extends uR{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Lz)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},qB=140,JB=class extends FB{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new KB(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new AB),this._shouldRender=!0,this.domNode=kB(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(mB(this.domNode.domNode,CB.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new LB(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=kB(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(mB(this.slider.domNode,CB.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=SB(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(az&&a>qB){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},YB=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize===t?!1:(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize===t?!1:(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition===t?!1:(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},XB=class extends JB{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new YB(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},ZB=class extends JB{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new YB(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},QB=500,$B=50,eV=!0,tV=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},nV=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(WR){let t=BR(rB(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new tV(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};nV.INSTANCE=new nV;var rV=nV,iV=class extends FB{constructor(e,t,n){super(),this._onScroll=this._register(new FR),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new FR),this.onWillScroll=this._onWillScroll.event,this._options=oV(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new ZB(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new XB(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=kB(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=kB(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=kB(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new Lz),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=aR(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,oz&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Nz(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=aR(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(mB(this._listenOnDomNode,CB.MOUSE_WHEEL,e=>{this._onMouseWheel(new Nz(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=rV.INSTANCE;eV&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!oz&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=$B*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=$B*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(eV&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),QB)}},aV=class extends iV{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function oV(e){let t={lazyRender:typeof e.lazyRender<`u`?e.lazyRender:!1,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<`u`?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`?e.horizontalHasArrows:!1,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,oz&&(t.className+=` mac`),t}var sV=class extends uR{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new FR),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new zB({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>vB(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new aV(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(xR.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(sR(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(sR(()=>this._styleElement.remove())),this._register(xR.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
|
|
134
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};sV=LI([RI(2,dL),RI(3,wL),RI(4,fL),RI(5,kL),RI(6,_L),RI(7,EL)],sV);var cV=class extends uR{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(sR(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};cV=LI([RI(1,dL),RI(2,wL),RI(3,bL),RI(4,EL)],cV);var lV=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},uV={full:0,left:0,center:0,right:0},dV={full:0,left:0,center:0,right:0},fV={full:0,left:0,center:0,right:0},pV=class extends uR{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new lV,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(sR(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);dV.full=this._canvas.width,dV.left=e,dV.center=t,dV.right=e,this._refreshDrawHeightConstants(),fV.full=1,fV.left=1,fV.center=1+dV.left,fV.right=1+dV.left+dV.center}_refreshDrawHeightConstants(){uV.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);uV.left=t,uV.center=t,uV.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*uV.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*uV.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*uV.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*uV.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(fV[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-uV[e.position||`full`]/2),dV[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+uV[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};pV=LI([RI(2,dL),RI(3,bL),RI(4,EL),RI(5,_L),RI(6,kL),RI(7,wL)],pV);var $;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
|
|
135
|
+
`,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))($||={});var mV;(e=>(e.PAD=``,e.HOP=``,e.BPH=``,e.NBH=``,e.IND=``,e.NEL=`
`,e.SSA=``,e.ESA=``,e.HTS=``,e.HTJ=``,e.VTS=``,e.PLD=``,e.PLU=``,e.RI=``,e.SS2=``,e.SS3=``,e.DCS=``,e.PU1=``,e.PU2=``,e.STS=``,e.CCH=``,e.MW=``,e.SPA=``,e.EPA=``,e.SOS=``,e.SGCI=``,e.SCI=``,e.CSI=``,e.ST=``,e.OSC=``,e.PM=``,e.APC=``))(mV||={});var hV;(e=>e.ST=`${$.ESC}\\`)(hV||={});var gV=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};gV=LI([RI(2,dL),RI(3,_L),RI(4,pL),RI(5,EL)],gV);var _V=0,vV=0,yV=0,bV=0,xV={css:`#00000000`,rgba:0},SV;(e=>{function t(e,t,n,r){return r===void 0?`#${DV(e)}${DV(t)}${DV(n)}`:`#${DV(e)}${DV(t)}${DV(n)}${DV(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(SV||={});var CV;(e=>{function t(e,t){if(bV=(t.rgba&255)/255,bV===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return _V=a+Math.round((n-a)*bV),vV=o+Math.round((r-o)*bV),yV=s+Math.round((i-s)*bV),{css:SV.toCss(_V,vV,yV),rgba:SV.toRgba(_V,vV,yV)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=EV.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return SV.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[_V,vV,yV]=EV.toChannels(t),{css:SV.toCss(_V,vV,yV),rgba:t}}e.opaque=i;function a(e,t){return bV=Math.round(t*255),[_V,vV,yV]=EV.toChannels(e.rgba),{css:SV.toCss(_V,vV,yV,bV),rgba:SV.toRgba(_V,vV,yV,bV)}}e.opacity=a;function o(e,t){return bV=e.rgba&255,a(e,bV*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(CV||={});var wV;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return _V=parseInt(e.slice(1,2).repeat(2),16),vV=parseInt(e.slice(2,3).repeat(2),16),yV=parseInt(e.slice(3,4).repeat(2),16),SV.toColor(_V,vV,yV);case 5:return _V=parseInt(e.slice(1,2).repeat(2),16),vV=parseInt(e.slice(2,3).repeat(2),16),yV=parseInt(e.slice(3,4).repeat(2),16),bV=parseInt(e.slice(4,5).repeat(2),16),SV.toColor(_V,vV,yV,bV);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return _V=parseInt(r[1]),vV=parseInt(r[2]),yV=parseInt(r[3]),bV=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),SV.toColor(_V,vV,yV,bV);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[_V,vV,yV,bV]=t.getImageData(0,0,1,1).data,bV!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:SV.toRgba(_V,vV,yV,bV),css:e}}e.toColor=r})(wV||={});var TV;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(TV||={});var EV;(e=>{function t(e,t){if(bV=(t&255)/255,bV===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return _V=a+Math.round((n-a)*bV),vV=o+Math.round((r-o)*bV),yV=s+Math.round((i-s)*bV),SV.toRgba(_V,vV,yV)}e.blend=t;function n(e,t,n){let a=TV.relativeLuminance(e>>8),o=TV.relativeLuminance(t>>8);if(OV(a,o)<n){if(o<a){let o=r(e,t,n),s=OV(a,TV.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>OV(a,TV.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=OV(a,TV.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>OV(a,TV.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=OV(TV.relativeLuminance2(o,s,c),TV.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=OV(TV.relativeLuminance2(o,s,c),TV.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=OV(TV.relativeLuminance2(o,s,c),TV.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=OV(TV.relativeLuminance2(o,s,c),TV.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(EV||={});function DV(e){let t=e.toString(16);return t.length<2?`0`+t:t}function OV(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var kV=class extends nL{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},AV=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new iL}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||tL.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)AV._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||tL.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};AV=LI([RI(0,dL)],AV);function jV(e){return 57508<=e&&e<=57558}function MV(e){return 9472<=e&&e<=9631}function NV(e){return jV(e)||MV(e)}function PV(){return{css:{canvas:FV(),cell:FV()},device:{canvas:FV(),cell:FV(),char:{width:0,height:0,left:0,top:0}}}}function FV(){return{width:0,height:0}}var IV=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new iL,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new kV(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let P=this._isCellInSelection(k,t),F=n&&k===a,I=O&&k>=l&&k<=u,L=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{L=!0});let R=N.getChars()||tL;if(R===` `&&(N.isUnderline()||N.isOverline())&&(R=`\xA0`),T=m*s-c.get(R,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(P&&w||!P&&!w&&N.bg===y)&&(P&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&I===S&&T===C&&!F&&!A&&!L&&j){N.isInvisible()?_+=tL:_+=R,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=I,C=T,w=P,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&F&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`);break;default:break}}if(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?tL:N.getChars()||tL,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault()))if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${nL.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),I&&(h.style.textDecoration=`underline`);let z=N.getFgColor(),B=N.getFgColorMode(),V=N.getBgColor(),ee=N.getBgColorMode(),te=!!N.isInverse();if(te){let e=z;z=V,V=e;let t=B;B=ee,ee=t}let H,ne,U=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&U||(e.backgroundColorRGB&&(ee=50331648,V=e.backgroundColorRGB.rgba>>8&16777215,H=e.backgroundColorRGB),e.foregroundColorRGB&&(B=50331648,z=e.foregroundColorRGB.rgba>>8&16777215,ne=e.foregroundColorRGB),U=e.options.layer===`top`)}),!U&&P&&(H=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,V=H.rgba>>8&16777215,ee=50331648,U=!0,p.selectionForeground&&(B=50331648,z=p.selectionForeground.rgba>>8&16777215,ne=p.selectionForeground)),U&&D.push(`xterm-decoration-top`);let re;switch(ee){case 16777216:case 33554432:re=p.ansi[V],D.push(`xterm-bg-${V}`);break;case 50331648:re=SV.toColor(V>>16,V>>8&255,V&255),this._addStyle(h,`background-color:#${LV((V>>>0).toString(16),`0`,6)}`);break;default:te?(re=p.foreground,D.push(`xterm-bg-257`)):re=p.background}switch(H||N.isDim()&&(H=CV.multiplyOpacity(re,.5)),B){case 16777216:case 33554432:N.isBold()&&z<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(z+=8),this._applyMinimumContrast(h,re,p.ansi[z],N,H,void 0)||D.push(`xterm-fg-${z}`);break;case 50331648:let e=SV.toColor(z>>16&255,z>>8&255,z&255);this._applyMinimumContrast(h,re,e,N,H,ne)||this._addStyle(h,`color:#${LV(z.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,re,p.foreground,N,H,ne)||te&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!F&&!A&&!L&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||NV(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=CV.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};IV=LI([RI(1,OL),RI(2,_L),RI(3,wL),RI(4,pL),RI(5,bL),RI(6,kL)],IV);function LV(e,t,n){for(;e.length<n;)e=t+e;return e}var RV=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},zV=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function BV(){return new zV}var VV=`xterm-dom-renderer-owner-`,HV=`xterm-rows`,UV=`xterm-fg-`,WV=`xterm-bg-`,GV=`xterm-focus`,KV=`xterm-selection`,qV=1,JV=class extends uR{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=qV++,this._rowElements=[],this._selectionRenderModel=BV(),this.onRequestRedraw=this._register(new FR).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(HV),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(KV),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=PV(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(IV,document),this._element.classList.add(VV+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(sR(()=>{this._element.classList.remove(VV+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new RV(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${HV} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${HV} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${HV} .xterm-dim { color: ${CV.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${HV}.${GV} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${HV}.${GV} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${HV}.${GV} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${HV} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${HV} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${HV} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${HV} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${HV} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${KV} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${KV} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${KV} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${UV}${n} { color: ${r.css}; }${this._terminalSelector} .${UV}${n}.xterm-dim { color: ${CV.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${WV}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${UV}257 { color: ${CV.opaque(e.background).css}; }${this._terminalSelector} .${UV}257.xterm-dim { color: ${CV.multiplyOpacity(CV.opaque(e.background),.5).css}; }${this._terminalSelector} .${WV}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(GV),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(GV),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${VV}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};JV=LI([RI(7,hL),RI(8,CL),RI(9,_L),RI(10,dL),RI(11,pL),RI(12,wL),RI(13,kL)],JV);var YV=class extends uR{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new FR),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new QV(this._optionsService))}catch{this._measureStrategy=this._register(new ZV(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};YV=LI([RI(2,_L)],YV);var XV=class extends uR{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},ZV=class extends XV{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},QV=class extends XV{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},$V=class extends uR{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new eH(this._window)),this._onDprChange=this._register(new FR),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new FR),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(xR.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(mB(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(mB(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},eH=class extends uR{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new dR),this._onDprChange=this._register(new FR),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(sR(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=mB(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},tH=class extends uR{constructor(){super(),this.linkProviders=[],this._register(sR(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function nH(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function rH(e,t,n,r,i,a,o,s,c){if(!a)return;let l=nH(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var iH=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return rH(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=nH(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};iH=LI([RI(0,EL),RI(1,CL)],iH);var aH=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},oH={};II(oH,{getSafariVersion:()=>pH,isChromeOS:()=>yH,isFirefox:()=>uH,isIpad:()=>hH,isIphone:()=>gH,isLegacyEdge:()=>dH,isLinux:()=>vH,isMac:()=>mH,isNode:()=>sH,isSafari:()=>fH,isWindows:()=>_H});var sH=typeof process<`u`&&`title`in process,cH=sH?`node`:navigator.userAgent,lH=sH?`node`:navigator.platform,uH=cH.includes(`Firefox`),dH=cH.includes(`Edge`),fH=/^((?!chrome|android).)*safari/i.test(cH);function pH(){if(!fH)return 0;let e=cH.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var mH=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(lH),hH=lH===`iPad`,gH=lH===`iPhone`,_H=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(lH),vH=lH.indexOf(`Linux`)>=0,yH=/\bCrOS\b/.test(cH),bH=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},xH=class extends bH{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},SH=class extends bH{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},CH=!sH&&`requestIdleCallback`in window?SH:xH,wH=class{constructor(){this._queue=new CH}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},TH=class extends uR{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new dR),this._pausedResizeTask=new wH,this._observerDisposable=this._register(new dR),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new FR),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new FR),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new FR),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new FR),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new aH((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new EH(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(sR(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=sR(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};TH=LI([RI(2,_L),RI(3,CL),RI(4,pL),RI(5,bL),RI(6,dL),RI(7,wL),RI(8,kL)],TH);var EH=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function DH(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return AH(i,a,e,t,n,r)+jH(a,t,n,r)+MH(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,zH(Math.abs(i-e),RH(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return zH(kH(a>t?e:i,n)+(s-1)*n.cols+1+OH(a>t?i:e,n),RH(o,r))}function OH(e,t){return e-1}function kH(e,t){return t.cols-e}function AH(e,t,n,r,i,a){return jH(t,r,i,a).length===0?``:zH(LH(e,t,e,t-PH(t,i),!1,i).length,RH(`D`,a))}function jH(e,t,n,r){let i=e-PH(e,n),a=t-PH(t,n);return zH(Math.abs(i-a)-NH(e,t,n),RH(IH(e,t),r))}function MH(e,t,n,r,i,a){let o;o=jH(t,r,i,a).length>0?r-PH(r,i):t;let s=r,c=FH(e,t,n,r,i,a);return zH(LH(e,o,n,s,c===`C`,i).length,RH(c,a))}function NH(e,t,n){let r=0,i=e-PH(e,n),a=t-PH(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=IH(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function PH(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function FH(e,t,n,r,i,a){let o;return o=jH(n,r,i,a).length>0?r-PH(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function IH(e,t){return e>t?`A`:`B`}function LH(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function RH(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function zH(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var BH=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function VH(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var HH=50,UH=15,WH=50,GH=500,KH=RegExp(`\xA0`,`g`),qH=class extends uR{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new iL,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new FR),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new FR),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new FR),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new FR),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new BH(this._bufferService),this._activeSelectionMode=0,this._register(sR(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(KH,` `)).join(_H?`\r
|
|
136
|
+
`:`
|
|
137
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),vH&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=VH(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=nH(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-HH),HH),t/=HH,t/Math.abs(t)+Math.round(t*(UH-1)))}shouldForceSelection(e){return mH?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),WH)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(mH&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<GH&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=DH(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=VH(n,this._bufferService.cols)}};qH=LI([RI(3,dL),RI(4,pL),RI(5,TL),RI(6,_L),RI(7,EL),RI(8,wL)],qH);var JH=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},YH=class{constructor(){this._color=new JH,this._css=new JH}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},XH=Object.freeze((()=>{let e=[wV.toColor(`#2e3436`),wV.toColor(`#cc0000`),wV.toColor(`#4e9a06`),wV.toColor(`#c4a000`),wV.toColor(`#3465a4`),wV.toColor(`#75507b`),wV.toColor(`#06989a`),wV.toColor(`#d3d7cf`),wV.toColor(`#555753`),wV.toColor(`#ef2929`),wV.toColor(`#8ae234`),wV.toColor(`#fce94f`),wV.toColor(`#729fcf`),wV.toColor(`#ad7fa8`),wV.toColor(`#34e2e2`),wV.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:SV.toCss(r,i,a),rgba:SV.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:SV.toCss(n,n,n),rgba:SV.toRgba(n,n,n)})}return e})()),ZH=wV.toColor(`#ffffff`),QH=wV.toColor(`#000000`),$H=wV.toColor(`#ffffff`),eU=QH,tU={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},nU=ZH,rU=class extends uR{constructor(e){super(),this._optionsService=e,this._contrastCache=new YH,this._halfContrastCache=new YH,this._onChangeColors=this._register(new FR),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ZH,background:QH,cursor:$H,cursorAccent:eU,selectionForeground:void 0,selectionBackgroundTransparent:tU,selectionBackgroundOpaque:CV.blend(QH,tU),selectionInactiveBackgroundTransparent:tU,selectionInactiveBackgroundOpaque:CV.blend(QH,tU),scrollbarSliderBackground:CV.opacity(ZH,.2),scrollbarSliderHoverBackground:CV.opacity(ZH,.4),scrollbarSliderActiveBackground:CV.opacity(ZH,.5),overviewRulerBorder:ZH,ansi:XH.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=iU(e.foreground,ZH),t.background=iU(e.background,QH),t.cursor=CV.blend(t.background,iU(e.cursor,$H)),t.cursorAccent=CV.blend(t.background,iU(e.cursorAccent,eU)),t.selectionBackgroundTransparent=iU(e.selectionBackground,tU),t.selectionBackgroundOpaque=CV.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=iU(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=CV.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?iU(e.selectionForeground,xV):void 0,t.selectionForeground===xV&&(t.selectionForeground=void 0),CV.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=CV.opacity(t.selectionBackgroundTransparent,.3)),CV.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=CV.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=iU(e.scrollbarSliderBackground,CV.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=iU(e.scrollbarSliderHoverBackground,CV.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=iU(e.scrollbarSliderActiveBackground,CV.opacity(t.foreground,.5)),t.overviewRulerBorder=iU(e.overviewRulerBorder,nU),t.ansi=XH.slice(),t.ansi[0]=iU(e.black,XH[0]),t.ansi[1]=iU(e.red,XH[1]),t.ansi[2]=iU(e.green,XH[2]),t.ansi[3]=iU(e.yellow,XH[3]),t.ansi[4]=iU(e.blue,XH[4]),t.ansi[5]=iU(e.magenta,XH[5]),t.ansi[6]=iU(e.cyan,XH[6]),t.ansi[7]=iU(e.white,XH[7]),t.ansi[8]=iU(e.brightBlack,XH[8]),t.ansi[9]=iU(e.brightRed,XH[9]),t.ansi[10]=iU(e.brightGreen,XH[10]),t.ansi[11]=iU(e.brightYellow,XH[11]),t.ansi[12]=iU(e.brightBlue,XH[12]),t.ansi[13]=iU(e.brightMagenta,XH[13]),t.ansi[14]=iU(e.brightCyan,XH[14]),t.ansi[15]=iU(e.brightWhite,XH[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=iU(e.extendedAnsi[r],XH[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};rU=LI([RI(0,_L)],rU);function iU(e,t){if(e!==void 0)try{return wV.toColor(e)}catch{}return t}var aU=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},oU=class{constructor(){this._services=new aU,this._services.set(hL,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=cL(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},sU={trace:0,debug:1,info:2,warn:3,error:4,off:5},cU=`xterm.js: `,lU=class extends uR{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),uU=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=sU[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:cU)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};lU=LI([RI(0,_L)],lU);var uU,dU=class extends uR{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new FR),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new FR),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new FR),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},fU=3,pU=Object.freeze(new nL),mU=0,hU=2,gU=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*fU);let r=t||iL.fromCharData([0,eL,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*fU+0],n=t&2097151;return[this._data[e*fU+1],t&2097152?this._combined[e]:n?XI(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*fU+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*fU+0]=e|2097152|t[2]<<22):this._data[e*fU+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*fU+0]>>22}hasWidth(e){return this._data[e*fU+0]&12582912}getFg(e){return this._data[e*fU+1]}getBg(e){return this._data[e*fU+2]}hasContent(e){return this._data[e*fU+0]&4194303}getCodePoint(e){let t=this._data[e*fU+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*fU+0]&2097152}getString(e){let t=this._data[e*fU+0];return t&2097152?this._combined[e]:t&2097151?XI(t&2097151):``}isProtected(e){return this._data[e*fU+2]&536870912}loadCell(e,t){return mU=e*fU,t.content=this._data[mU+0],t.fg=this._data[mU+1],t.bg=this._data[mU+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*fU+0]=t.content,this._data[e*fU+1]=t.fg,this._data[e*fU+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*fU+0]=t|n<<22,this._data[e*fU+1]=r.fg,this._data[e*fU+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*fU+0];r&2097152?this._combined[e]+=XI(t):r&2097151?(this._combined[e]=XI(r&2097151)+XI(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*fU+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new iL;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new iL;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*hU<this._data.buffer.byteLength;let n=e*fU;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*hU<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*hU<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*fU+0]&4194303)return e+(this._data[e*fU+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*fU+0]&4194303||this._data[e*fU+2]&50331648)return e+(this._data[e*fU+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<fU;e++)this._data[(n+i)*fU+e]=a[(t+i)*fU+e];a[(t+i)*fU+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<fU;e++)this._data[(n+i)*fU+e]=a[(t+i)*fU+e];a[(t+i)*fU+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*fU+0],n=e&2097151,a=e&2097152?this._combined[t]:n?XI(n):tL;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function _U(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=xU(u,d,t),p=1,m=0;for(;p<u.length;){let e=xU(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function vU(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function yU(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function bU(e,t,n){let r=[],i=e.map((n,r)=>xU(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=xU(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function xU(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var SU=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new FR),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),aR(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};SU._nextId=1;var CU=SU,wU={},TU=wU.B;wU[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:``,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},wU.A={"#":`£`},wU.B=void 0,wU[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},wU.C=wU[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},wU.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},wU.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},wU.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},wU.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},wU.E=wU[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},wU.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},wU.H=wU[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},wU[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var EU=4294967295,DU=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=pU.clone(),this.savedCharset=TU,this.markers=[],this._nullCell=iL.fromCharData([0,eL,1,0]),this._whitespaceCell=iL.fromCharData([0,tL,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new CH,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new dU(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new rL),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new rL),this._whitespaceCell}getBlankLine(e,t){return new gU(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>EU?EU:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=pU);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new dU(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(pU),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new gU(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new gU(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=_U(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(pU),n);if(r.length>0){let n=vU(this.lines,r);yU(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(pU),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new gU(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(pU),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=bU(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(pU,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=xU(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new CU(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},OU=class extends uR{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new FR),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new DU(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new DU(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},kU=2,AU=1,jU=class extends uR{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new FR),this.onResize=this._onResize.event,this._onScroll=this._register(new FR),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,kU),this.rows=Math.max(e.rawOptions.rows||0,AU),this.buffers=this._register(new OU(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};jU=LI([RI(0,_L)],jU);var MU={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:mH,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},NU=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],PU=class extends uR{constructor(e){super(),this._onOptionChange=this._register(new FR),this.onOptionChange=this._onOptionChange.event;let t={...MU};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(sR(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in MU))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in MU))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=MU[e],!FU(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=MU[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=NU.includes(t)?t:MU[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={};break}return t}};function FU(e){return e===`block`||e===`underline`||e===`bar`}function IU(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&IU(e[r],t-1);return n}var LU=Object.freeze({insertMode:!1}),RU=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),zU=class extends uR{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new FR),this.onData=this._onData.event,this._onUserInput=this._register(new FR),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new FR),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new FR),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=IU(LU),this.decPrivateModes=IU(RU)}reset(){this.modes=IU(LU),this.decPrivateModes=IU(RU)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};zU=LI([RI(0,dL),RI(1,gL),RI(2,_L)],zU);var BU={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function VU(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var HU=String.fromCharCode,UU={DEFAULT:e=>{let t=[VU(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${HU(t[0])}${HU(t[1])}${HU(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${VU(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${VU(e,!0)};${e.x};${e.y}${t}`}},WU=class extends uR{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new FR),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(BU))this.addProtocol(e,BU[e]);for(let e of Object.keys(UU))this.addEncoding(e,UU[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};WU=LI([RI(0,dL),RI(1,pL),RI(2,_L)],WU);var GU=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],KU=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],qU;function JU(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var YU=class{constructor(){if(this.version=`6`,!qU){qU=new Uint8Array(65536),qU.fill(1),qU[0]=0,qU.fill(0,1,32),qU.fill(0,127,160),qU.fill(2,4352,4448),qU[9001]=2,qU[9002]=2,qU.fill(2,11904,42192),qU[12351]=1,qU.fill(2,44032,55204),qU.fill(2,63744,64256),qU.fill(2,65040,65050),qU.fill(2,65072,65136),qU.fill(2,65280,65377),qU.fill(2,65504,65511);for(let e=0;e<GU.length;++e)qU.fill(0,GU[e][0],GU[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?qU[e]:JU(e,KU)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=XU.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return XU.createPropertyValue(0,n,r)}},XU=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new FR,this.onChange=this._onChange.event;let e=new YU;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},ZU=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function QU(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var $U=2147483647,eW=256,tW=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>eW)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>$U?$U:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>$U?$U:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,$U):e}},nW=[],rW=class{constructor(){this._state=0,this._active=nW,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=nW}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=nW,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||nW,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,ZI(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=nW,this._id=-1,this._state=0}}},iW=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=ZI(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},aW=[],oW=class{constructor(){this._handlers=Object.create(null),this._active=aW,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=aW}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=aW,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||aW,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,ZI(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=aW,this._ident=0}},sW=new tW;sW.addParam(0);var cW=class{constructor(e){this._handler=e,this._data=``,this._params=sW,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():sW,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=ZI(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=sW,this._data=``,this._hitLimit=!1,e));return this._params=sW,this._data=``,this._hitLimit=!1,t}},lW=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},uW=160,dW=function(){let e=new lW(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(uW,0,2,0),e.add(uW,8,5,8),e.add(uW,6,0,6),e.add(uW,11,0,11),e.add(uW,13,13,13),e}(),fW=class extends uR{constructor(e=dW){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new tW,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(sR(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new rW),this._dcsParser=this._register(new oW),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:uW)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<uW){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<uW){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<uW){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<uW){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<uW){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<uW){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},pW=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,mW=/^[\da-f]+$/;function hW(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=pW.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),mW.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function gW(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function _W(e,t=16){let[n,r,i]=e;return`rgb:${gW(n,t)}/${gW(r,t)}/${gW(i,t)}`}var vW={"(":0,")":1,"*":2,"+":3,"-":1,".":2},yW=131072,bW=10;function xW(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var SW=5e3,CW=0,wW=class extends uR{constructor(e,t,n,r,i,a,o,s,c=new fW){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new QI,this._utf8Decoder=new $I,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=pU.clone(),this._eraseAttrDataInternal=pU.clone(),this._onRequestBell=this._register(new FR),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new FR),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new FR),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new FR),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new FR),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new FR),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new FR),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new FR),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new FR),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new FR),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new FR),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new FR),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new FR),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new TW(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(mV.IND,()=>this.index()),this._parser.setExecuteHandler(mV.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(mV.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new iW(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new iW(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new iW(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new iW(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new iW(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new iW(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new iW(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new iW(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new iW(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new iW(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new iW(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new iW(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in wU)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new cW((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),SW))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${SW} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>yW&&(a=this._parseStack.position+yW)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<yW&&(this._parseBuffer=new Uint32Array(Math.min(e.length,yW))),o||this._dirtyRowTracker.clearRange(),e.length>yW)for(let t=a;t<e.length;t+=yW){let a=t+yW<e.length?t+yW:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=XU.extractWidth(t);let n=XU.extractShouldJoin(t),m=n?XU.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(XI(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof gU&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>xW(e.params[0],this._optionsService.rawOptions.windowOptions)?t(e):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new cW(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new iW(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(pU));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=XU.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,TU),this._charsetService.setgCharset(1,TU),this._charsetService.setgCharset(2,TU),this._charsetService.setgCharset(3,TU);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=nL.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=pU.fg,e.bg=pU.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=pU.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=pU.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=pU.fg&16777215,r.bg&=-67108864,r.bg|=pU.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=pU.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`;break}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!xW(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>bW&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>bW&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(EW(n))if(r===`?`)t.push({type:0,index:n});else{let e=hW(r);e&&t.push({type:1,index:n,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=hW(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);EW(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,TU),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(vW[e[0]],wU[e[1]]||TU),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=pU.clone(),this._eraseAttrDataInternal=pU.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new iL;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},TW=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(CW=e,e=t,t=CW),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};TW=LI([RI(0,dL)],TW);function EW(e){return 0<=e&&e<256}var DW=5e7,OW=12,kW=50,AW=class extends uR{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new FR),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>DW)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=OW?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=OW)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>kW&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},jW=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};jW=LI([RI(0,dL)],jW);var MW=!1,NW=class extends uR{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new dR),this._onBinary=this._register(new FR),this.onBinary=this._onBinary.event,this._onData=this._register(new FR),this.onData=this._onData.event,this._onLineFeed=this._register(new FR),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new FR),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new FR),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new FR),this._instantiationService=new oU,this.optionsService=this._register(new PU(e)),this._instantiationService.setService(_L,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(jU)),this._instantiationService.setService(dL,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(lU)),this._instantiationService.setService(gL,this._logService),this.coreService=this._register(this._instantiationService.createInstance(zU)),this._instantiationService.setService(pL,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(WU)),this._instantiationService.setService(fL,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(XU)),this._instantiationService.setService(yL,this.unicodeService),this._charsetService=this._instantiationService.createInstance(ZU),this._instantiationService.setService(mL,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(jW),this._instantiationService.setService(vL,this._oscLinkService),this._inputHandler=this._register(new wW(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(xR.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(xR.forward(this._bufferService.onResize,this._onResize)),this._register(xR.forward(this.coreService.onData,this._onData)),this._register(xR.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new AW((e,t)=>this._inputHandler.parse(e,t))),this._register(xR.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new FR),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!MW&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),MW=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,kU),t=Math.max(t,AU),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(QU.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(QU(this._bufferService),!1))),this._windowsWrappingHeuristics.value=sR(()=>{for(let t of e)t.dispose()})}}},PW={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function FW(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?t?i.key=$.ESC+`OA`:i.key=$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?t?i.key=$.ESC+`OD`:i.key=$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?t?i.key=$.ESC+`OC`:i.key=$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(t?i.key=$.ESC+`OB`:i.key=$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`D`:t?i.key=$.ESC+`OD`:i.key=$.ESC+`[D`;break;case 39:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`C`:t?i.key=$.ESC+`OC`:i.key=$.ESC+`[C`;break;case 38:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`A`:t?i.key=$.ESC+`OA`:i.key=$.ESC+`[A`;break;case 40:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`B`:t?i.key=$.ESC+`OB`:i.key=$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:a?i.key=$.ESC+`[3;`+(a+1)+`~`:i.key=$.ESC+`[3~`;break;case 36:a?i.key=$.ESC+`[1;`+(a+1)+`H`:t?i.key=$.ESC+`OH`:i.key=$.ESC+`[H`;break;case 35:a?i.key=$.ESC+`[1;`+(a+1)+`F`:t?i.key=$.ESC+`OF`:i.key=$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=$.ESC+`[5;`+(a+1)+`~`:i.key=$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=$.ESC+`[6;`+(a+1)+`~`:i.key=$.ESC+`[6~`;break;case 112:a?i.key=$.ESC+`[1;`+(a+1)+`P`:i.key=$.ESC+`OP`;break;case 113:a?i.key=$.ESC+`[1;`+(a+1)+`Q`:i.key=$.ESC+`OQ`;break;case 114:a?i.key=$.ESC+`[1;`+(a+1)+`R`:i.key=$.ESC+`OR`;break;case 115:a?i.key=$.ESC+`[1;`+(a+1)+`S`:i.key=$.ESC+`OS`;break;case 116:a?i.key=$.ESC+`[15;`+(a+1)+`~`:i.key=$.ESC+`[15~`;break;case 117:a?i.key=$.ESC+`[17;`+(a+1)+`~`:i.key=$.ESC+`[17~`;break;case 118:a?i.key=$.ESC+`[18;`+(a+1)+`~`:i.key=$.ESC+`[18~`;break;case 119:a?i.key=$.ESC+`[19;`+(a+1)+`~`:i.key=$.ESC+`[19~`;break;case 120:a?i.key=$.ESC+`[20;`+(a+1)+`~`:i.key=$.ESC+`[20~`;break;case 121:a?i.key=$.ESC+`[21;`+(a+1)+`~`:i.key=$.ESC+`[21~`;break;case 122:a?i.key=$.ESC+`[23;`+(a+1)+`~`:i.key=$.ESC+`[23~`;break;case 123:a?i.key=$.ESC+`[24;`+(a+1)+`~`:i.key=$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=PW[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL));break}return i}var IW=0,LW=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new CH,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new CH,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(IW=this._search(t),IW===-1)||this._getKey(this._array[IW])!==t)return!1;do if(this._array[IW]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(IW),!0;while(++IW<this._array.length&&this._getKey(this._array[IW])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(IW=this._search(e),!(IW<0||IW>=this._array.length)&&this._getKey(this._array[IW])===e))do yield this._array[IW];while(++IW<this._array.length&&this._getKey(this._array[IW])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(IW=this._search(e),!(IW<0||IW>=this._array.length)&&this._getKey(this._array[IW])===e))do t(this._array[IW]);while(++IW<this._array.length&&this._getKey(this._array[IW])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},RW=0,zW=0,BW=class extends uR{constructor(){super(),this._decorations=new LW(e=>e?.marker.line),this._onDecorationRegistered=this._register(new FR),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new FR),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(sR(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new VW(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{RW=t.options.x??0,zW=RW+(t.options.width??1),e>=RW&&e<zW&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},VW=class extends lR{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new FR),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new FR),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=wV.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=wV.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},HW=1e3,UW=class{constructor(e,t=HW){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},WW=20,GW=!1,KW=class extends uR{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new UW(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);GW?(this._accessibilityContainer.classList.add(`debug`),this._rowContainer.classList.add(`debug`),this._debugRootContainer=i.createElement(`div`),this._debugRootContainer.classList.add(`xterm`),this._debugRootContainer.appendChild(i.createTextNode(`------start a11y------`)),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(i.createTextNode(`------end a11y------`)),this._terminal.element.insertAdjacentElement(`afterend`,this._debugRootContainer)):this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
138
|
+
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(mB(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(sR(()=>{GW?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<WW+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
139
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===WW+1&&(this._liveRegion.textContent+=HI.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};KW=LI([RI(1,hL),RI(2,wL),RI(3,EL)],KW);var qW=class extends uR{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new FR),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new FR),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(sR(()=>{aR(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(mB(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(mB(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(mB(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(mB(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&JW(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,aR(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};qW=LI([RI(1,TL),RI(2,EL),RI(3,dL),RI(4,AL)],qW);function JW(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var YW=class extends NW{constructor(e={}){super(e),this._linkifier=this._register(new dR),this.browser=oH,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new dR),this._onCursorMove=this._register(new FR),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new FR),this.onKey=this._onKey.event,this._onRender=this._register(new FR),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new FR),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new FR),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new FR),this.onBell=this._onBell.event,this._onFocus=this._register(new FR),this._onBlur=this._register(new FR),this._onA11yCharEmitter=this._register(new FR),this._onA11yTabEmitter=this._register(new FR),this._onWillOpen=this._register(new FR),this._setup(),this._decorationService=this._instantiationService.createInstance(BW),this._instantiationService.setService(bL,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(tH),this._instantiationService.setService(AL,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(xL)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(xR.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(xR.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(xR.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(xR.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(sR(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=CV.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${_W(r)}${hV.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=SV.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=SV.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(KW,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(mB(this.element,`copy`,e=>{this.hasSelection()&&GI(e,this._selectionService)}));let e=e=>KI(e,this.textarea,this.coreService,this.optionsService);this._register(mB(this.textarea,`paste`,e)),this._register(mB(this.element,`paste`,e)),uH?this._register(mB(this.element,`mousedown`,e=>{e.button===2&&YI(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(mB(this.element,`contextmenu`,e=>{YI(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),vH&&this._register(mB(this.element,`auxclick`,e=>{e.button===1&&JI(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(mB(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(mB(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(mB(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(mB(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(mB(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(mB(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(mB(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(mB(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,BI.get()),yH||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance($V,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(wL,this._coreBrowserService),this._register(mB(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(mB(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(YV,this._document,this._helperContainer),this._instantiationService.setService(CL,this._charSizeService),this._themeService=this._instantiationService.createInstance(rU),this._instantiationService.setService(kL,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(AV),this._instantiationService.setService(OL,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(TH,this.rows,this.screenElement)),this._instantiationService.setService(EL,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(gV,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(iH),this._instantiationService.setService(TL,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(qW,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(sV,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(qH,this.element,this.screenElement,r)),this._instantiationService.setService(DL,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(xR.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(cV,this.screenElement)),this._register(mB(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(KW,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pV,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pV,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(JV,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(mB(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(mB(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){qI(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=FW(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(XW(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(pU));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function XW(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var ZW=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},QW=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new iL)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},$W=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new QW(t)}getNullCell(){return new iL}},eG=class extends uR{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new FR),this.onBufferChange=this._onBufferChange.event,this._normal=new $W(this._core.buffers.normal,`normal`),this._alternate=new $W(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},tG=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},nG=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},rG=[`cols`,`rows`],iG=0,aG=class extends uR{constructor(e){super(),this._core=this._register(new YW(e)),this._addonManager=this._register(new ZW),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(rG.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new tG(this._core),this._parser}get unicode(){return this._checkProposedApi(),new nG(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new eG(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`;break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
140
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return BI.get()},set promptLabel(e){BI.set(e)},get tooMuchOutput(){return HI.get()},set tooMuchOutput(e){HI.set(e)}}}_verifyIntegers(...e){for(iG of e)if(iG===1/0||isNaN(iG)||iG%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(iG of e)if(iG&&(iG===1/0||isNaN(iG)||iG%1!=0||iG<0))throw Error(`This API only accepts positive integers`)}},oG=Object.create(null);oG.open=`0`,oG.close=`1`,oG.ping=`2`,oG.pong=`3`,oG.message=`4`,oG.upgrade=`5`,oG.noop=`6`;var sG=Object.create(null);Object.keys(oG).forEach(e=>{sG[oG[e]]=e});var cG={type:`error`,data:`parser error`},lG=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,uG=typeof ArrayBuffer==`function`,dG=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,fG=({type:e,data:t},n,r)=>lG&&t instanceof Blob?n?r(t):pG(t,r):uG&&(t instanceof ArrayBuffer||dG(t))?n?r(t):pG(new Blob([t]),r):r(oG[e]+(t||``)),pG=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function mG(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var hG;function gG(e,t){if(lG&&e.data instanceof Blob)return e.data.arrayBuffer().then(mG).then(t);if(uG&&(e.data instanceof ArrayBuffer||dG(e.data)))return t(mG(e.data));fG(e,!1,e=>{hG||=new TextEncoder,t(hG.encode(e))})}var _G=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,vG=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)vG[_G.charCodeAt(e)]=e;var yG=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=vG[e.charCodeAt(r)],o=vG[e.charCodeAt(r+1)],s=vG[e.charCodeAt(r+2)],c=vG[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},bG=typeof ArrayBuffer==`function`,xG=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:CG(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:SG(e.substring(1),t)}:sG[n]?e.length>1?{type:sG[n],data:e.substring(1)}:{type:sG[n]}:cG},SG=(e,t)=>bG?CG(yG(e),t):{base64:!0,data:e},CG=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},wG=``,TG=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{fG(e,!1,e=>{r[a]=e,++i===n&&t(r.join(wG))})})},EG=(e,t)=>{let n=e.split(wG),r=[];for(let e=0;e<n.length;e++){let i=xG(n[e],t);if(r.push(i),i.type===`error`)break}return r};function DG(){return new TransformStream({transform(e,t){gG(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var OG;function kG(e){return e.reduce((e,t)=>e+t.length,0)}function AG(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function jG(e,t){OG||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(kG(n)<1)break;let e=AG(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(kG(n)<2)break;let e=AG(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(kG(n)<8)break;let e=AG(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(cG);break}i=a*2**32+t.getUint32(4),r=3}else{if(kG(n)<i)break;let e=AG(n,i);s.enqueue(xG(a?e:OG.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(cG);break}}}})}function MG(e){if(e)return NG(e)}function NG(e){for(var t in MG.prototype)e[t]=MG.prototype[t];return e}MG.prototype.on=MG.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},MG.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},MG.prototype.off=MG.prototype.removeListener=MG.prototype.removeAllListeners=MG.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},MG.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},MG.prototype.emitReserved=MG.prototype.emit,MG.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},MG.prototype.hasListeners=function(e){return!!this.listeners(e).length};var PG=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),FG=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),IG=`arraybuffer`;function LG(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var RG=FG.setTimeout,zG=FG.clearTimeout;function BG(e,t){t.useNativeTimers?(e.setTimeoutFn=RG.bind(FG),e.clearTimeoutFn=zG.bind(FG)):(e.setTimeoutFn=FG.setTimeout.bind(FG),e.clearTimeoutFn=FG.clearTimeout.bind(FG))}var VG=1.33;function HG(e){return typeof e==`string`?UG(e):Math.ceil((e.byteLength||e.size)*VG)}function UG(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function WG(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function GG(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function KG(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var qG=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},JG=class extends MG{constructor(e){super(),this.writable=!1,BG(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new qG(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=xG(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=GG(e);return t.length?`?`+t:``}},YG=class extends JG{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){EG(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,TG(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=WG()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},XG=!1;try{XG=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var ZG=XG;function QG(){}var $G=class extends YG{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},eK=class e extends MG{constructor(e,t,n){super(),this.createRequest=e,BG(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=LG(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=QG,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(eK.requestsCount=0,eK.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,tK);else if(typeof addEventListener==`function`){let e=`onpagehide`in FG?`pagehide`:`unload`;addEventListener(e,tK,!1)}}function tK(){for(let e in eK.requests)eK.requests.hasOwnProperty(e)&&eK.requests[e].abort()}var nK=(function(){let e=iK({xdomain:!1});return e&&e.responseType!==null})(),rK=class extends $G{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=nK&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new eK(iK,this.uri(),e)}};function iK(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||ZG))return new XMLHttpRequest}catch{}if(!t)try{return new FG[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var aK=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,oK=class extends JG{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=aK?{}:LG(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;fG(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&PG(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=WG()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},sK=FG.WebSocket||FG.MozWebSocket,cK={websocket:class extends oK{createSocket(e,t,n){return aK?new sK(e,t,n):t?new sK(e,t):new sK(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends JG{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=jG(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=DG();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&PG(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:rK},lK=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,uK=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function dK(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=lK.exec(e||``),a={},o=14;for(;o--;)a[uK[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=fK(a,a.path),a.queryKey=pK(a,a.query),a}function fK(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function pK(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var mK=typeof addEventListener==`function`&&typeof removeEventListener==`function`,hK=[];mK&&addEventListener(`offline`,()=>{hK.forEach(e=>e())},!1);var gK=class e extends MG{constructor(e,t){if(super(),this.binaryType=IG,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=dK(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=dK(t.host).host);BG(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=KG(this.opts.query)),mK&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},hK.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=HG(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,PG(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),mK&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=hK.indexOf(this._offlineEventListener);e!==-1&&hK.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};gK.protocol=4;var _K=class extends gK{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;gK.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;gK.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},vK=class extends _K{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>cK[e]).filter(e=>!!e)),super(e,n)}};vK.protocol;function yK(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=dK(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var bK=typeof ArrayBuffer==`function`,xK=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,SK=Object.prototype.toString,CK=typeof Blob==`function`||typeof Blob<`u`&&SK.call(Blob)===`[object BlobConstructor]`,wK=typeof File==`function`||typeof File<`u`&&SK.call(File)===`[object FileConstructor]`;function TK(e){return bK&&(e instanceof ArrayBuffer||xK(e))||CK&&e instanceof Blob||wK&&e instanceof File}function EK(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(EK(e[t]))return!0;return!1}if(TK(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return EK(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&EK(e[t]))return!0;return!1}function DK(e){let t=[],n=e.data,r=e;return r.data=OK(n,t),r.attachments=t.length,{packet:r,buffers:t}}function OK(e,t){if(!e)return e;if(TK(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=OK(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=OK(e[r],t));return n}return e}function kK(e,t){return e.data=AK(e.data,t),delete e.attachments,e}function AK(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=AK(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=AK(e[n],t));return e}var jK=r({Decoder:()=>FK,Encoder:()=>PK,PacketType:()=>NK,isPacketValid:()=>HK,protocol:()=>5}),MK=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],NK;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(NK||={});var PK=class{constructor(e){this.replacer=e}encode(e){return(e.type===NK.EVENT||e.type===NK.ACK)&&EK(e)?this.encodeAsBinary({type:e.type===NK.EVENT?NK.BINARY_EVENT:NK.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===NK.BINARY_EVENT||e.type===NK.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=DK(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},FK=class e extends MG{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===NK.BINARY_EVENT;n||t.type===NK.BINARY_ACK?(t.type=n?NK.EVENT:NK.ACK,this.reconstructor=new IK(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(TK(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(NK[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===NK.BINARY_EVENT||r.type===NK.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!RK(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case NK.CONNECT:return BK(t);case NK.DISCONNECT:return t===void 0;case NK.CONNECT_ERROR:return typeof t==`string`||BK(t);case NK.EVENT:case NK.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&MK.indexOf(t[0])===-1);case NK.ACK:case NK.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},IK=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=kK(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function LK(e){return typeof e==`string`}var RK=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function zK(e){return e===void 0||RK(e)}function BK(e){return Object.prototype.toString.call(e)===`[object Object]`}function VK(e,t){switch(e){case NK.CONNECT:return t===void 0||BK(t);case NK.DISCONNECT:return t===void 0;case NK.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&MK.indexOf(t[0])===-1);case NK.ACK:return Array.isArray(t);case NK.CONNECT_ERROR:return typeof t==`string`||BK(t);default:return!1}}function HK(e){return LK(e.nsp)&&zK(e.id)&&VK(e.type,e.data)}function UK(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var WK=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),GK=class extends MG{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[UK(e,`open`,this.onopen.bind(this)),UK(e,`packet`,this.onpacket.bind(this)),UK(e,`error`,this.onerror.bind(this)),UK(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(WK.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:NK.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:NK.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case NK.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case NK.EVENT:case NK.BINARY_EVENT:this.onevent(e);break;case NK.ACK:case NK.BINARY_ACK:this.onack(e);break;case NK.DISCONNECT:this.ondisconnect();break;case NK.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:NK.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:NK.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function KK(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}KK.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},KK.prototype.reset=function(){this.attempts=0},KK.prototype.setMin=function(e){this.ms=e},KK.prototype.setMax=function(e){this.max=e},KK.prototype.setJitter=function(e){this.jitter=e};var qK=class extends MG{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,BG(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new KK({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||jK;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new vK(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=UK(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=UK(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(UK(e,`ping`,this.onping.bind(this)),UK(e,`data`,this.ondata.bind(this)),UK(e,`error`,this.onerror.bind(this)),UK(e,`close`,this.onclose.bind(this)),UK(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){PG(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new GK(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},JK={};function YK(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=yK(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=JK[i]&&a in JK[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new qK(r,t):(JK[i]||(JK[i]=new qK(r,t)),c=JK[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(YK,{Manager:qK,Socket:GK,io:YK,connect:YK});var XK=((e=j)=>YK(e))(),ZK=({label:e,onClick:t,children:n})=>(0,Z.jsx)(J,{type:`button`,"aria-label":e,onClick:t,variant:`outline`,size:`icon-sm`,className:`bg-secondary/60`,children:n}),QK=({exitCode:e,signal:t})=>t>0?`[archon] Shell exited with signal ${t}`:`[archon] Shell exited with code ${e}`,$K=({createSession:e,isExpanded:t,isVisible:n,onClose:r,onToggleExpanded:i,className:a=``,ariaLabel:o=`Terminal`,title:s=`Terminal`,closeLabel:c=`Close terminal`,headerMeta:l})=>{let u=(0,X.useRef)(null),d=(0,X.useRef)(null),f=(0,X.useRef)(null),p=(0,X.useRef)(null),m=(0,X.useRef)(e),h=(0,X.useRef)(!1),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(!0);return(0,X.useEffect)(()=>{m.current=e},[e]),(0,X.useEffect)(()=>{if(!u.current)return;let e=new aG({cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,fontSize:13,theme:{background:`#0b0d14`,foreground:`#d8deef`,cursor:`#c4b5fd`}}),t=new NI,n=null,r=!1;e.loadAddon(t),e.open(u.current),d.current=e,f.current=t;let i=()=>{let e=p.current;!e||h.current||(h.current=!0,BD(e))};window.addEventListener(`pagehide`,i),window.addEventListener(`beforeunload`,i);let a=()=>{p.current&&XK.emit(`terminal:resize`,{sessionId:p.current,cols:e.cols,rows:e.rows})},o=()=>{!u.current||r||(t.fit(),a())},s=t=>{t.sessionId===p.current&&(y(!1),window.setTimeout(()=>{o(),e.focus()},0))},c=t=>{t.sessionId===p.current&&(y(!1),e.write(t.data))},l=t=>{t.sessionId===p.current&&(e.writeln(``),e.writeln(QK(t)))},g=t=>{t.sessionId&&t.sessionId!==p.current||(y(!1),_(t.message),e.writeln(``),e.writeln(`[archon] ${t.message}`))};XK.on(`terminal:ready`,s),XK.on(`terminal:data`,c),XK.on(`terminal:exit`,l),XK.on(`terminal:error`,g);let v=e.onData(e=>{p.current&&XK.emit(`terminal:input`,{sessionId:p.current,input:e})});return typeof ResizeObserver==`function`&&(n=new ResizeObserver(()=>{o()}),n.observe(u.current)),window.setTimeout(()=>{o()},0),m.current().then(e=>{r||(p.current=e.session_id,XK.emit(`terminal:join`,{sessionId:e.session_id}))}).catch(t=>{if(r)return;y(!1);let n=t instanceof Error?t.message:`Unable to open the terminal right now.`;_(n),e.writeln(``),e.writeln(`[archon] ${n}`)}),()=>{r=!0,window.removeEventListener(`pagehide`,i),window.removeEventListener(`beforeunload`,i),p.current&&(h.current||XK.emit(`terminal:destroy`,{sessionId:p.current})),n?.disconnect(),v.dispose(),XK.off(`terminal:ready`,s),XK.off(`terminal:data`,c),XK.off(`terminal:exit`,l),XK.off(`terminal:error`,g),e.dispose(),d.current=null,f.current=null,p.current=null}},[]),(0,X.useEffect)(()=>{if(!n)return;let e=window.setTimeout(()=>{f.current?.fit(),d.current&&p.current&&(XK.emit(`terminal:resize`,{sessionId:p.current,cols:d.current.cols,rows:d.current.rows}),d.current.focus())},0);return()=>{window.clearTimeout(e)}},[t,n]),(0,Z.jsxs)(Nf,{"aria-label":o,"data-terminal-pane":`true`,className:`flex min-h-0 flex-1 flex-col gap-0 overflow-hidden rounded-xl border-border bg-[#0c1119] ${a}`.trim(),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-border bg-card/80 px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/12 text-primary`,children:(0,Z.jsx)(Qu,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:s}),l&&(0,Z.jsx)(`div`,{className:`mt-1 min-w-0 text-xs text-muted-foreground`,children:l})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v&&!g&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Opening terminal...`}),g&&(0,Z.jsx)(`span`,{className:`max-w-56 truncate text-xs text-red-300`,children:g}),(0,Z.jsx)(ZK,{label:t?`Collapse terminal`:`Expand terminal`,onClick:i,children:t?(0,Z.jsx)(Pm,{className:`h-4 w-4`}):(0,Z.jsx)(Fm,{className:`h-4 w-4`})}),(0,Z.jsx)(ZK,{label:c,onClick:r,children:(0,Z.jsx)(Fe,{className:`h-4 w-4`})})]})]}),(0,Z.jsx)(`div`,{ref:u,"data-testid":`terminal-viewport`,onClick:()=>d.current?.focus(),className:`min-h-0 flex-1 overflow-hidden bg-[#0b0d14] pb-4`})]})},eq=({actions:e,activeAction:t=null,disableWhenActive:n=!1,className:r,heading:i,headingClassName:a,actionsClassName:o,showDisabledReason:s=!1,disabledReasonClassName:c,error:l,errorClassName:u,leadingContent:d,renderAction:f})=>{if(e.length===0&&!d)return null;let p=e.find(e=>e.disabled&&e.disabledReason)?.disabledReason??null;return(0,Z.jsxs)(`div`,{className:r,children:[i&&(0,Z.jsx)(`div`,{className:a,children:i}),(0,Z.jsxs)(`div`,{className:o,children:[d,e.map(e=>{let r=t===e.id,i=e.disabled||n&&t!==null;return f({action:e,label:r?e.pendingLabel:e.label,disabled:i,title:e.disabledReason??e.title,ariaLabel:e.ariaLabel})})]}),s&&p&&(0,Z.jsx)(`p`,{className:c,children:p}),l&&(0,Z.jsx)(`p`,{className:u,children:l})]})},tq=({id:e,label:t,pendingLabel:n,ariaLabel:r=t,title:i,disabled:a=!1,disabledReason:o=null})=>({id:e,label:t,pendingLabel:n,ariaLabel:r,title:i,disabled:a,disabledReason:o}),nq=(e,t={})=>{let{isEditing:n=!1,includePlanAdvance:r=!0,hideAdvanceWhenBlocked:i=!1,hasOpenBlockers:a=!1,canRun:o=!0,canStopRun:s=!0,canPauseBuild:c=!0,canResumeBuild:l=!0,runDisabled:u=!1,runDisabledReason:d,buildLabel:f=`Build`,reviewLabel:p=`Review`}=t,m=BE(e.state),h=m?ZE(e,m):!1,g=QE(e),_=e.bundle?.branch??e.branch,v=e.has_worktree??!!_,y=e.worktree_bundle_id!==null,b=e.state===`plan`&&e.agent_status===`running`,x=d??(e.has_run_config===!1?`No run config is available for this project.`:null),S=[];return r&&e.state===`plan`&&!e.parked_at&&S.push(tq({id:`build`,label:f,pendingLabel:`Building...`,ariaLabel:f,disabled:!h,disabledReason:g})),e.state===`build`&&!e.parked_at&&!(i&&a)&&S.push(tq({id:`review`,label:p,pendingLabel:`Starting review...`,ariaLabel:p,disabled:!h,disabledReason:g})),_&&v&&!b&&!n&&!y&&e.is_running!==!0&&o&&S.push(tq({id:`run`,label:`Run`,pendingLabel:`Starting run...`,ariaLabel:`Run`,disabled:u||!!x,disabledReason:x,title:u?x??`Stop the currently running ticket before starting another run.`:void 0})),_&&!n&&!y&&e.is_running===!0&&s&&S.push(tq({id:`stop-run`,label:`Stop Run`,pendingLabel:`Stopping run...`,ariaLabel:`Stop Run`,title:`Stop the currently running ticket.`,disabled:!1,disabledReason:null})),!n&&UE(e)&&e.agent_status===`running`&&e.session_id&&c&&S.push(tq({id:`pause-build`,label:`Pause Build`,pendingLabel:`Pausing build...`,ariaLabel:`Pause Build`,title:`Pause the build session. You can resume it later.`,disabled:!1,disabledReason:null})),!n&&UE(e)&&e.agent_status===`stopped`&&e.session_id&&l&&S.push(tq({id:`resume-build`,label:`Resume`,pendingLabel:`Resuming build...`,ariaLabel:`Resume`,disabled:!1,disabledReason:null})),S},rq=(e,t={})=>{let n=e.state===`plan`,r=e.bundle?.branch??e.branch,i=e.has_worktree??!!r;return{isPlan:n,hasWorktree:i,disabledReason:e.agent_status===`running`?n?`Wait for planning to finish before sending another message.`:`Wait for the current build to finish before sending a follow-up prompt.`:t.requireWorktree===!0&&!n&&!i?`Worktree not ready yet.`:null,heading:n?`Planning follow-up`:`Ticket follow-up`,description:n?`Ask the agent to refine this plan.`:`Send a follow-up prompt for this ticket.`,placeholder:n?`Ask the agent to refine this plan...`:`Send a follow-up for this ticket...`}},iq=(e,t,n={})=>{let r=e.tool===`opencode`||n.persistPlanSettings===!0,i=r&&t.model?t.model:null,a=r&&t.model&&t.variant?t.variant:null,o=r?t.skills:[],s=e.skills??[],c=o.length!==s.length||o.some((e,t)=>e!==s[t]);return{model:i,variant:a,skills:o,shouldPersist:r&&(i!==e.model||a!==e.variant||c)}},aq=`modulepreload`,oq=function(e){return`/`+e},sq={},cq=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=oq(t,n),t in sq)return;sq[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:aq,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},lq=(0,X.lazy)(()=>cq(()=>Promise.resolve().then(()=>yX).then(e=>({default:e.TicketChangesModal})),void 0)),uq=(0,X.lazy)(()=>cq(()=>import(`./TestsDialog-BPHhOIWL.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),dq=`(min-width: 1280px)`,fq=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:window.matchMedia(e).matches,pq=e=>{let[t,n]=(0,X.useState)(()=>fq(e));return(0,X.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>{n(t.matches)};return r(),t.addEventListener(`change`,r),()=>{t.removeEventListener(`change`,r)}},[e]),t},mq=({onClose:e})=>{let{t}=ht(`common`);return(0,Z.jsx)(Af,{onClose:e,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-full w-full max-w-none items-center justify-center rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:(0,Z.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:t(`ticketModal.loadingDiff`)})})},hq=({ariaLabel:e,title:t,closeAriaLabel:n,className:r,showTopSpacer:i=!0,description:a,onClose:o,...s})=>(0,Z.jsxs)(`aside`,{className:`min-h-0 flex flex-col gap-3 overflow-hidden${r?` ${r}`:``}`,"aria-label":e,children:[i?(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`h-9 shrink-0`}):null,(0,Z.jsx)(ZF,{...s,header:({showThinkingControl:e})=>(0,Z.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:t}),e]}),a?(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:a}):null]}),(0,Z.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":n,onClick:o,children:(0,Z.jsx)(Fe,{className:`h-4 w-4`})})]})})]}),gq=(e,t)=>e?t.find(t=>t.id===e)?.label??e:null,_q=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],projectTestCommands:i=[],showModelSelector:a=!1,availableModels:o=[],availableSkills:s=[],projectBranchState:c=null,projectMemoryEnabled:l=!1,runDisabled:u=!1,runDisabledReason:d,onClose:f,onCreateBundle:p,onDeleteBundle:m,onRefreshBundles:h,onUpdate:g,onDeleteDependency:_,onAdvance:v,onBuildChain:y,onRun:b,onOpenIde:x,onStop:S,onStopBuild:C,onStopBuildChain:w,onResumeBuild:T,onFollowUp:E,onRequestTicketRefresh:D,onProjectMemorySuggestionsChanged:O})=>{let{t:k}=ht(`common`),[A,j]=(0,X.useState)(null),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(!1),[I,L]=(0,X.useState)(!1),[R,z]=(0,X.useState)(!1),[B,V]=(0,X.useState)(!1),[ee,te]=(0,X.useState)(!1),[H,ne]=(0,X.useState)(``),[U,re]=(0,X.useState)(!1),[ie,ae]=(0,X.useState)(!1),[oe,se]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(0),[ue,de]=(0,X.useState)(!1),[W,fe]=(0,X.useState)(!1),[pe,me]=(0,X.useState)(null),G=A??e,[he,ge]=(0,X.useState)(G.model??``),[_e,ve]=(0,X.useState)(G.variant??``),[ye,be]=(0,X.useState)(G.skills??[]),[xe,Se]=(0,X.useState)(()=>gq(G.model,o)??`Agent`),Ce=(0,X.useRef)(G.id),we=(0,X.useRef)(null),K=(0,X.useRef)(null),Te=(0,X.useRef)(!1),Ee=(0,X.useRef)(G.id),De=(0,X.useRef)(G.build_completed_at),Oe=pq(dq),[ke,Ae]=(0,X.useState)(!1),[je,Me]=(0,X.useState)({model:G.model,variant:G.variant,skills:G.skills??[]}),Ne=G.state===`plan`,Pe=VE(G.state),Fe=G.worktree_bundle_id!==null,Ie=Ne&&G.agent_status===`running`,Le=Ne&&G.agent_status===`error`,Re=Ne&&!Ie||M,ze=async e=>{let t=await Kt(G.id,G.project_id,e);return j(t),g?.(t),h&&await h(),t},Be=async e=>{try{await ze(e),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},Ve=async e=>{try{if(await ze(e),!v){f();return}await v(),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},He=async()=>{!v||rt?.disabled||(await v(),f())},Ue=e=>{if(e===`review`){He();return}if(e===`run`){b?.();return}if(e===`stop-run`){S?.();return}if(e===`pause-build`){C?.();return}e===`resume-build`&&T?.()},We=async e=>{try{if(await ze(e),!y){f();return}await y(),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},Ge=Ne?G.planning_session_id:G.session_id,Ke=Ge?Ge.startsWith(`ses_`)?`opencode --session ${Ge}`:`claude --resume ${Ge}`:null,qe=G.bundle?.branch??G.branch,Je=G.has_worktree??!!qe,Ye=`Stop Build Chain`,Xe=new Map(t.map(e=>[e.id,e])),Ze=n.filter(e=>e.blocker_ticket_id===G.id),Y=n.filter(e=>e.dependent_ticket_id===G.id),Qe=gD(G,Xe,n),$e=Qe.pendingBuildChainOrder.length>0?`Will build in order: ${Qe.pendingBuildChainOrder.map(e=>e.title).join(` -> `)}`:`All tickets in this chain have already finished build.`,et=Qe.skippedBuildChainCount>0?`Skips ${Qe.skippedBuildChainCount} ticket${Qe.skippedBuildChainCount===1?``:`s`} that already finished build.`:null,tt=Qe.hasOpenBlockers,nt=nq(G,{isEditing:Re,includePlanAdvance:!1,hideAdvanceWhenBlocked:!0,hasOpenBlockers:tt,canRun:!!b,canStopRun:!!S,canPauseBuild:!!C,canResumeBuild:!!T,runDisabled:u,runDisabledReason:d,reviewLabel:`Review Bundle`}),rt=nt.find(e=>e.id===`review`)??null,it=KE(G),at=G.build_chain?.active_ticket_id?`Currently building ${Xe.get(G.build_chain.active_ticket_id)?.title??`Unknown ticket`}.`:`Build chain is active.`,ot=G.build_chain&&G.build_chain.queued_ticket_ids.length>0?`Queued next: ${G.build_chain.queued_ticket_ids.map(e=>Xe.get(e)?.title??`Unknown ticket`).join(` -> `)}`:`No additional tickets are queued after the current build.`,st=Ne&&!!v&&!Qe.hasOpenBlockers,ct=Ne&&!!y&&Qe.canStartBuildChain,lt=!!G.project_id&&!Ne&&!Fe,ut=Ne,dt=Fe&&!Ne,ft=!!G.project_id&&!!qe&&Je&&!Re&&!Ie&&!Fe,pt=!!G.project_id&&Je&&!Re&&!Ie&&!!x&&!Fe,mt=!!G.project_id&&i.length>0&&Je,gt=lt&&!R,_t=k(`workspaceControls.openTerminalAriaLabel`),vt=lt&&ee,yt=H.trim(),bt=!Re&&!Ie&&G.state!==`plan`&&Je&&!!E,xt=ut&&ie,St=dt&&oe,Ct=(G.planning_context?.open_questions.length??0)>0,wt=bt&&a&&G.tool===`opencode`,Tt=k(`ticketModal.discardUnsavedDescription`),Et=o.find(e=>e.id===he)??null,Dt=G.agent_status===`running`,Ot=ED(G,{allTickets:t,preferBundleReviewStatus:!0}),kt=G.skills??[],At=rq(G),jt=Dt?At.disabledReason??void 0:void 0,Mt=Ie?At.disabledReason??void 0:void 0,Nt=[...Ie?[]:[{label:`Worktree`,value:qe??``}],{label:`Session`,value:Ke??``},...Ie?[{label:G.bundle?.kind===`project_root`?`Project root branch`:`Bundle`,value:(G.bundle?.kind,G.bundle?Ud(G.bundle):``)}]:Ne?[{label:`Bundle`,value:G.bundle?Ud(G.bundle):``},{label:`Model`,value:G.model??``},{label:`Variant`,value:G.variant??``},{label:`Skills`,value:kt.length>0?`${kt.length} skill${kt.length===1?``:`s`}`:``},{label:`Initiative`,value:G.planning_context?.initiative_prompt??``}]:[]],Pt=Ie?{model:G.model??``,variant:G.variant??``,skills:kt}:null,Ft=ut&&ie,It=dt&&oe,Lt=(Ft||It)&&!Oe,Rt=Ft&&!Lt,zt=Rt||It&&!Lt,Bt=Ne&&(Ft||!Oe),Vt=R?`flex h-[92vh] w-[96vw] max-w-7xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:zt?`flex h-[92vh] w-[98vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:Lt?`flex h-[92vh] w-[98vw] max-w-6xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-6xl flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,Ht=R&&!B?`grid min-h-0 flex-1 grid-cols-1 gap-3 lg:grid-cols-2`:zt?`grid min-h-0 flex-1 grid-cols-1 gap-3 xl:grid-cols-[minmax(0,1fr)_minmax(30rem,1fr)]`:`flex min-h-0 flex-1 flex-col`,Ut=()=>{te(!0),z(e=>(e&&V(!1),!e))},Wt=()=>{z(!1),V(!1),te(!1),D?.(G.id)},Gt=()=>{fe(!1),me(null)},qt=()=>{fe(!1),pe===`cancel_edit`&&!Ne?N(!1):f(),me(null)},Jt=()=>{if(!Re){f();return}if(!ue){f();return}me(`close_modal`),fe(!0)},Yt=()=>{if(Ne){Jt();return}if(!ue){N(!1);return}me(`cancel_edit`),fe(!0)};(0,X.useEffect)(()=>{j(t=>!t||t.id!==e.id||e.updated_at>=t.updated_at?null:t)},[e]),(0,X.useEffect)(()=>{if(Ee.current!==G.id){Ee.current=G.id,De.current=G.build_completed_at;return}if(De.current===G.build_completed_at)return;let e=De.current;De.current=G.build_completed_at,G.build_completed_at&&G.build_completed_at!==e&&le(e=>e+1)},[G.build_completed_at,G.id]),(0,X.useEffect)(()=>{ge(G.model??``),ve(G.variant??``),be(G.skills??[])},[G.model,G.skills,G.variant]),(0,X.useEffect)(()=>{Ce.current!==G.id&&(Ce.current=G.id,Se(gq(G.model,o)??`Agent`))},[o,G.id,G.model]),(0,X.useEffect)(()=>{let e=gq(G.model,o);e&&Se(e)},[o,G.model]),(0,X.useEffect)(()=>{Me({model:G.model,variant:G.variant,skills:G.skills??[]})},[G.id,G.model,G.skills,G.variant]),(0,X.useEffect)(()=>{Re||(de(!1),fe(!1),me(null))},[Re]),(0,X.useEffect)(()=>{ue||(fe(!1),me(null))},[ue]),(0,X.useEffect)(()=>{if(!Ne){we.current=null,Te.current=!1;return}let e=we.current!==G.id,t=!Te.current&&Ct;(e&&Ct||t)&&ae(!0),we.current=G.id,Te.current=Ct},[Ct,Ne,G.id]),(0,X.useEffect)(()=>{if(!dt){K.current=null;return}K.current!==G.id&&se(!1),K.current=G.id},[dt,G.id]);let Xt=async(e,t,n)=>{Ae(!0);try{let r=await Kt(G.id,G.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});j(r),g?.(r)}catch(e){ge(G.model??``),ve(G.variant??``),be(G.skills??[]),Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{Ae(!1)}},Zt=e=>{let t=(o.find(t=>t.id===e)??null)?.variants.includes(_e)?_e:``;ge(e),ve(t),Xt(e,t,ye)},Qt=e=>{ve(e),Xt(he,e,ye)},$t=e=>{be(e),Xt(he,_e,e)},en=async()=>{if(!(!E||U||Dt||!yt)){re(!0);try{await E(yt),ne(``)}finally{re(!1)}}},tn=async()=>{if(!(U||Ie||!yt||!xt)){re(!0);try{let e=iq(G,je,{persistPlanSettings:!0});if(e.shouldPersist){let t=await Kt(G.id,G.project_id,{model:e.model,variant:e.variant,skills:e.skills});j(t),g?.(t)}let t=await _n(G.id,G.project_id,yt);j(t),g?.(t),ne(``)}finally{re(!1)}}},nn=(G.messages??[]).filter(XD).map(e=>e.role===`assistant`?{...e,displayTitle:xe}:e.kind===`follow_up`?{...e,displayTitle:k(`chatView.user.you`)}:e),rn=(G.messages??[]).filter(e=>(e.kind===`planning_follow_up`||e.kind===`planning_response`)&&XD(e)).map(e=>e.role===`assistant`?{...e,displayTitle:xe}:e.kind===`planning_follow_up`?{...e,displayTitle:k(`chatView.user.you`)}:e),an=Ft?(0,Z.jsx)(hq,{ariaLabel:k(`ticketModal.planningChatAriaLabel`),title:k(`ticketModal.planningChatTitle`),closeAriaLabel:k(`ticketModal.closePlanningChatAriaLabel`),className:Lt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Lt,description:Ct?(0,Z.jsx)(`p`,{children:k(`ticketModal.planningOpenQuestions`,{count:G.planning_context?.open_questions.length??0})}):void 0,projectId:G.project_id,followUpTicketId:null,messages:rn,internalLog:G.agent_log??null,currentThinkingMessageId:G.agent_message_id??null,previousThinkingLog:G.previous_agent_log??null,previousThinkingMessageId:G.previous_agent_message_id??null,streamingResponse:G.streaming_response??null,isRunning:G.agent_status===`running`,canShowComposer:xt,pendingAgentTitle:xe,composerTheme:Pe,followUpPlaceholder:k(`ticketModal.planningFollowUpPlaceholder`),emptyStateText:null,autoFocusComposer:ie,followUpPrompt:H,isSendingFollowUp:U,followUpDisabledReason:Mt,onFollowUpPromptChange:ne,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Ie||U||(e.preventDefault(),tn())},onFollowUpSubmit:()=>{tn()},onClose:()=>{ae(!1)}}):It?(0,Z.jsx)(hq,{ariaLabel:k(`ticketModal.ticketChatAriaLabel`),title:k(`ticketModal.ticketChatTitle`),closeAriaLabel:k(`ticketModal.closeTicketChatAriaLabel`),className:Lt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Lt,projectId:G.project_id,followUpTicketId:G.id,messages:nn,internalLog:G.agent_log??null,currentThinkingMessageId:G.agent_message_id??null,previousThinkingLog:G.previous_agent_log??null,previousThinkingMessageId:G.previous_agent_message_id??null,streamingResponse:G.streaming_response??null,isRunning:G.agent_status===`running`,canShowComposer:St,pendingAgentTitle:xe,composerTheme:Pe,autoFocusComposer:oe,followUpPrompt:H,isSendingFollowUp:U,followUpDisabledReason:jt,followUpComposerControls:wt?(0,Z.jsx)(AI,{model:he,variant:_e,skills:ye,showModelSelector:!0,showSkillsSelector:!0,availableModels:o,availableSkills:s,selectedModel:Et,onModelChange:Zt,onVariantChange:Qt,onSkillsChange:$t,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:ke}):void 0,onFollowUpPromptChange:ne,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Dt||U||(e.preventDefault(),en())},onFollowUpSubmit:()=>{en()},onClose:()=>{se(!1)}}):null;return(0,Z.jsx)(Af,{onClose:Jt,overlayClassName:`bg-black/60`,panelClassName:Vt,renderContent:({closeButton:e})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`absolute right-4 top-4 z-10 flex items-center gap-2 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:[ft&&G.diff_stats&&(0,Z.jsx)(Gu,{stats:G.diff_stats,showFiles:!0,className:`text-xs`}),ft&&(0,Z.jsxs)(J,{type:`button`,"aria-label":k(`workspaceControls.changes`),onClick:()=>{D?.(G.id),F(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(qu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.changes`)})]}),mt&&(0,Z.jsxs)(J,{type:`button`,"aria-label":k(`workspaceControls.tests`),onClick:()=>{L(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Ku,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.tests`)})]}),pt&&(0,Z.jsxs)(J,{type:`button`,"aria-label":k(`workspaceControls.openIde`),onClick:()=>{x?.()},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Ju,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.openIde`)})]}),gt&&(0,Z.jsxs)(J,{type:`button`,"aria-label":_t,"aria-pressed":R,onClick:Ut,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Qu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.terminal`)})]}),(ut||dt)&&(0,Z.jsxs)(J,{type:`button`,"aria-label":k(`workspaceControls.chat`),"aria-pressed":Ne?ie:oe,onClick:()=>{if(Ne){ae(e=>!e);return}se(e=>!e)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(vg,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.chat`)})]}),e]}),(0,Z.jsxs)(`div`,{"data-testid":`ticket-modal-layout`,"data-terminal-mode":R?B?`expanded`:`split`:`closed`,"data-side-chat-mode":zt?`inline`:Lt?`overlay`:`closed`,className:Ht,children:[(0,Z.jsxs)(`div`,{className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[Re?(0,Z.jsxs)(Z.Fragment,{children:[Le&&G.agent_log&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-red-500/40 bg-destructive/15 px-3 py-2 text-xs text-red-300`,children:[(0,Z.jsx)(`span`,{className:`font-semibold`,children:k(`ticketModal.planningFailedPrefix`)}),G.agent_log]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(UD,{tool:G.tool,className:`text-[11px]`})}),(0,Z.jsx)(WD,{externalSource:G.external_source}),(0,Z.jsx)(fI,{heading:`Edit Ticket`,bundles:r,initialTitle:G.title,initialDescription:G.description??``,initialModel:G.model??``,initialVariant:G.variant??``,initialSkills:G.skills??[],initialWorktreeBundleId:G.worktree_bundle_id,projectBranchState:c,projectId:G.project_id,stackConfigurationSections:Rt&&!Bt,preferWideBundleSelector:Rt&&Bt,agentSettingsPresentation:Bt?`popover`:`panel`,showModelSelector:a,availableModels:o,availableSkills:s,onAgentSettingsChange:Me,onCreateBundle:p,onDeleteBundle:m,onRefreshBundles:h,onCancel:Yt,onDirtyChange:de,titleInputId:`edit-title`,descriptionInputId:`edit-description`,bundleSelectId:`edit-ticket-bundle`,modelSelectId:`edit-model`,variantSelectId:`edit-variant`,skillsSelectId:`edit-skills`,showEmptyBundleOption:!1,planAction:{label:`Plan`,onClick:async({title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a})=>{let o=await Kt(G.id,G.project_id,{title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a});g?.(o),f(),await vn(G.id,G.project_id)}},primaryAction:{label:`Save`,variant:st?`subtle`:`brand`,onClick:Be},secondaryAction:st?{label:`Save & Build`,variant:`brand`,showAdvanceIcon:!0,onClick:Ve}:void 0,tertiaryAction:ct?{label:`Save & Build Chain`,variant:`brand`,showAdvanceIcon:!0,onClick:We}:void 0,beforeActionsContent:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(CI,{projectId:G.project_id,ticketId:G.id,memoryEnabled:l,refreshKey:ce,onSuggestionsChanged:O}),Qe.hasDependents&&(0,Z.jsx)(ZD,{summary:$e,detail:et}),(0,Z.jsx)(eI,{blocks:Ze,blockedBy:Y,resolveTicket:e=>Xe.get(e),onDeleteDependency:_})]}),footerLeadingContent:ue?(0,Z.jsx)(q,{variant:`outline`,className:`border-amber-500/35 bg-amber-500/10 text-amber-200`,children:`Unsaved changes`}):null},`${G.id}:${G.updated_at}:${G.title}:${G.description}`)]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`sticky top-0 -my-1 bg-card py-1 pr-12 sm:pr-24`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:G.title}),(0,Z.jsx)(UD,{tool:G.tool,className:`text-[11px]`}),(Ot===`building`||Ot===`done`)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[G.is_running&&(0,Z.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,Z.jsx)(SD,{status:Ot,showBuildGlyph:!0})]}),Ot!==null&&Ot!==`building`&&Ot!==`done`&&(0,Z.jsx)(SD,{status:Ot,showBuildGlyph:!0}),Ct&&(0,Z.jsx)(q,{variant:`warning`,children:k(`ticketModal.openQuestionsBadge`)}),it&&(0,Z.jsx)(q,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:`Stale`})]})}),Fe?(0,Z.jsx)(`div`,{className:`mt-3 min-h-0 flex flex-1 flex-col`,children:(0,Z.jsx)(wI,{content:G.description,externalSource:G.external_source})}):(0,Z.jsx)(Z.Fragment,{children:Ne?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 flex flex-col${Ie?` mt-3`:``}`,children:(0,Z.jsx)(wI,{content:G.description,externalSource:G.external_source})}):(0,Z.jsx)(ZF,{projectId:G.project_id,followUpTicketId:G.id,messages:nn,internalLog:G.agent_log??null,currentThinkingMessageId:G.agent_message_id??null,previousThinkingLog:G.previous_agent_log??null,previousThinkingMessageId:G.previous_agent_message_id??null,streamingResponse:G.streaming_response??null,isRunning:G.agent_status===`running`,canShowComposer:bt,pendingAgentTitle:xe,composerTheme:Pe,followUpComposerControls:wt?(0,Z.jsx)(AI,{model:he,variant:_e,skills:ye,showModelSelector:!0,showSkillsSelector:!0,availableModels:o,availableSkills:s,selectedModel:Et,onModelChange:Zt,onVariantChange:Qt,onSkillsChange:$t,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:ke}):void 0,followUpPrompt:H,isSendingFollowUp:U,followUpDisabledReason:jt,onFollowUpPromptChange:ne,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Dt||U||(e.preventDefault(),en())},onFollowUpSubmit:()=>{en()}})}),Ie&&(0,Z.jsxs)(`section`,{"aria-label":k(`workspaceControls.ticketMetadataAriaLabel`),className:`flex flex-wrap items-center gap-2`,children:[Nt.filter(e=>e.value.trim().length>0).map(e=>(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 sm:flex-none sm:max-w-full`,children:(0,Z.jsx)(KD,{label:e.label,value:e.value,variant:`compact`,className:`min-w-0`})},`${e.label}:${e.value}`)),(0,Z.jsx)(`div`,{className:`min-w-0 sm:flex-none`,children:(0,Z.jsx)(VD,{model:Pt.model,variant:Pt.variant,skills:Pt.skills})})]}),!Ie&&!zt&&(0,Z.jsx)(qD,{ariaLabel:k(`workspaceControls.ticketMetadataAriaLabel`),items:Nt}),(0,Z.jsx)(CI,{projectId:G.project_id,ticketId:G.id,memoryEnabled:l,refreshKey:ce,onSuggestionsChanged:O}),(0,Z.jsx)(eI,{blocks:Ze,blockedBy:Y,resolveTicket:e=>Xe.get(e),onDeleteDependency:_}),G.build_chain&&(0,Z.jsx)(ZD,{summary:at,detail:ot})]}),!Re&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-border pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(J,{type:`button`,onClick:f,variant:`ghost`,children:k(`workspaceControls.close`)}),G.build_chain&&w&&(0,Z.jsxs)(J,{type:`button`,onClick:()=>{w()},title:`Stop scheduling the remaining tickets in this build chain.`,"aria-label":Ye,variant:`destructive`,children:[(0,Z.jsx)(Zu,{className:`w-3.5 h-3.5`}),Ye]}),(0,Z.jsx)(eq,{actions:nt,actionsClassName:`contents`,renderAction:({action:e,label:t,disabled:n,title:r,ariaLabel:i})=>{let a=e.id===`review`?(0,Z.jsx)(LE,{className:`w-3.5 h-3.5`}):e.id===`run`||e.id===`resume-build`?(0,Z.jsx)(Yu,{className:`w-3.5 h-3.5`}):(0,Z.jsx)(Zu,{className:`w-3.5 h-3.5`});return(0,Z.jsxs)(J,{type:`button`,disabled:n,title:r,"aria-label":i,variant:e.id===`stop-run`?`destructive`:e.id===`pause-build`||e.id===`resume-build`?`warning`:e.id===`run`?`secondary`:`default`,className:e.id===`run`?`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`:e.id===`resume-build`?`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`:void 0,onClick:()=>Ue(e.id),children:[e.id===`review`?t:a,e.id===`review`?a:t]},e.id)}})]})]})]}),zt&&an,vt&&(0,Z.jsx)(`div`,{className:R?B?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`mt-12 min-h-0 flex flex-1 flex-col overflow-hidden`:`hidden`,children:(0,Z.jsx)($K,{createSession:()=>RD(G.id,G.project_id),isExpanded:B,isVisible:R,ariaLabel:k(`ticketModal.ticketTerminalAriaLabel`),className:B?`h-full w-full max-w-none rounded-2xl shadow-2xl`:void 0,onClose:Wt,onToggleExpanded:()=>{V(e=>!e)}})})]}),Lt&&an,P&&(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(mq,{onClose:()=>{F(!1),D?.(G.id)}}),children:(0,Z.jsx)(lq,{ticketId:G.id,projectId:G.project_id,title:G.title,onTicketUpdate:g,onRequestTicketRefresh:D,onSubmitReviewPrompt:E,canSubmitReviewPrompt:!Dt,reviewSubmitDisabledReason:jt,onClose:()=>{F(!1),D?.(G.id)}})}),I&&mt&&G.project_id&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(uq,{scope:`ticket`,ticketId:G.id,projectId:G.project_id,testCommands:i,onClose:()=>{L(!1)}})}),W&&(0,Z.jsx)(jf,{title:k(`ticketModal.discardUnsavedTitle`),description:Tt,confirmLabel:k(`ticketModal.discardUnsavedConfirm`),cancelLabel:k(`ticketModal.discardUnsavedCancel`),confirmVariant:`destructive`,onConfirm:qt,onCancel:Gt})]})})},vq=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],projectMemoryEnabled:i=!1,overlay:a=!1,showModelSelector:o,availableModels:s,runDisabled:c=!1,runDisabledReason:l,dependencyTargetState:u=`idle`,onDependencyStart:d,onDeleteDependency:f,onRegisterNode:p,onRegisterOverlayNode:m,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onDelete:y,onUndo:b,onRetry:x,onAdvance:S,onPark:C,onUnpark:w,onBuildChain:T,onRun:E,onOpenTests:D,onOpenChanges:O,onOpenIde:k,onAddTicketToBundle:A,onStop:j,onStopBuild:M,onStopBuildChain:N,onResumeBuild:P,onFollowUp:F,onOpenBundleDetails:I,onOpenTicketDetails:L,preferBundleDetailsOnClick:R=!1,hideBundleScopedControls:z=!1,hideStatusBadge:B=!1,onRequestTicketRefresh:V,undoInProgress:ee=!1})=>{let{t:te}=ht(`common`),[H,ne]=(0,X.useState)(!1),[U,re]=(0,X.useState)(!1),[ie,ae]=(0,X.useState)(!1),[oe,se]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(null),[ue,de]=(0,X.useState)(!1),[W,fe]=(0,X.useState)(!1),pe=e.agent_status===`running`||ee,me=z,G=e.bundle?.branch??e.branch,he=e.has_worktree??(e.state===`plan`?!1:!!G),ge=!z&&he,_e=gD(e,new Map(t.map(e=>[e.id,e])),n),ve=BE(e.state),ye=e.state===`review`&&e.can_re_review===!0&&e.agent_status!==`running`,be=e.worktree_bundle_id!==null,xe=WE(e),Se=GE(e),Ce=KE(e),we=!z&&Se!==`plan`&&e.diff_stats===void 0,K=(Ce||xe)&&!a,Te=ve?te(ve===`review`?`card.advance.reviewBundle`:`card.columnLabels.${ve}`):ye?te(`card.advance.rerunReview`):null,Ee=ZE(e,`trash`),De=e.undo,Oe=!!b&&De?.stage!==null,ke=ye||(ve?ZE(e,ve):!1),Ae=!xe&&!!S&&!!Te&&!_e.hasOpenBlockers,je=!!C&&YE(e),Me=xe&&typeof e.state==`string`?te(`card.returnTo`,{state:te(`card.columnLabels.${e.state}`)}):null,Ne=!!w&&Me!==null&&e.state!==`plan`,Pe=!xe&&!!T&&_e.canStartBuildChain,Fe=UE(e)&&e.agent_status===`running`&&!!e.session_id&&!!M,Ie=UE(e)&&e.agent_status===`stopped`&&!!e.session_id&&!!P,Le=ge&&!!O,Re=ge&&!!e.project_id&&!!D,ze=ge&&!!k,Be=!xe&&!z&&be&&!!A,Ve=!me&&he&&!!G&&!e.is_running&&!!E,He=!me&&he&&!!G&&!!e.is_running&&!!j,Ue=!!e.build_chain&&!!N,We=!!y||Oe||Ae||je||Ne||Pe||Fe||Ie||Be||Ve||He||Re||Le||ze||Ue,Ge=xe&&!e.is_running?`opacity-0 pointer-events-none transition-opacity group-hover/card:opacity-100 group-hover/card:pointer-events-auto group-focus-within/card:opacity-100 group-focus-within/card:pointer-events-auto`:``,Ke=async()=>{if(!(!E||c||ue)){de(!0);try{await E()}finally{de(!1)}}},qe=async()=>{if(!(!j||W)){fe(!0);try{await j()}finally{fe(!1)}}},Je=!me&&he&&G&&e.is_running&&j&&!ee?(0,Z.jsx)(wD,{isRunning:!0,isStopPending:W,onStop:qe}):!me&&he&&G&&!e.is_running&&E?(0,Z.jsx)(wD,{isRunning:!1,isRunPending:ue,runDisabled:c,runDisabledReason:l,onRun:Ke,className:Ge}):null;(0,X.useEffect)(()=>{if(!oe)return;let e=()=>{se(!1)};return window.addEventListener(`click`,e,{once:!0}),()=>{window.removeEventListener(`click`,e)}},[oe]);let Ye=()=>{if(a||oe||ee){se(!1);return}if(R&&I){I();return}if(L){L();return}V?.(e.id),ae(!0)},{attributes:Xe,listeners:Ze,setNodeRef:Y,isDragging:Qe}=uE({id:e.id,disabled:a||pe}),$e=(0,X.useRef)(Y);(0,X.useEffect)(()=>{$e.current=Y},[Y]);let et=(0,X.useCallback)(t=>{if(a){m?.(t);return}$e.current(t),p?.(e.id,t)},[p,m,a,e.id]),tt=u===`valid`?`border-emerald-400 shadow-[0_0_0_1px_rgba(52,211,153,0.35)]`:u===`invalid`?`border-red-400 shadow-[0_0_0_1px_rgba(248,113,113,0.35)]`:a?`border-violet-400`:_e.isVisibleStartPoint?`border-violet-500/35 shadow-[0_0_0_1px_rgba(168,85,247,0.18)] hover:border-violet-400/55`:`border-border hover:border-primary/40`,nt=a||ee?`pointer-events-none cursor-grabbing shadow-2xl`:`cursor-pointer`,rt=Qe?`opacity-30`:K?`opacity-90`:`opacity-100`,it=K?`bg-card/60`:`bg-secondary/30`,at=K?`p-3 text-foreground/70`:`p-3`,ot=K?`truncate text-sm font-medium text-foreground/70`:`truncate text-sm font-medium text-foreground`,st=K?`text-[11px] text-foreground/55`:`text-[11px] text-muted-foreground`,ct=K?`whitespace-pre-line text-xs leading-relaxed text-foreground/55 wrap-anywhere`:`whitespace-pre-line text-xs leading-relaxed text-muted-foreground wrap-anywhere`,lt=e.model??``,ut=!!e.bundle&&!z,dt=!!e.bundle?.pull_request&&!z,ft=ut||dt,pt=ft||lt.length>0,mt=ce===e.id,gt=(0,X.useMemo)(()=>{let t=e.description??``;return t?pF(t):{text:``,truncated:!1}},[e.description]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Nf,{"data-testid":`ticket-card-${e.id}`,className:`group/card shrink-0 select-none transition-colors ${tt} ${nt} ${rt} ${it} gap-0 rounded-xl border shadow-none`,ref:et,onClick:Ye,...Ze,...Xe,children:[ee&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,Z.jsxs)(q,{variant:`warning`,className:`gap-1.5`,children:[(0,Z.jsx)(Gm,{className:`h-3.5 w-3.5 animate-spin`}),te(`card.undoInProgress`)]})}),(0,Z.jsxs)(Rf,{className:at,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-start justify-between gap-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`div`,{className:ot,children:e.title})}),(0,Z.jsxs)(`div`,{className:`flex flex-shrink-0 items-start gap-1`,children:[(0,Z.jsx)(`div`,{className:`mr-1`,children:Je}),(0,Z.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:d&&(0,Z.jsx)(Lu,{content:te(`card.drawDependency`),children:(0,Z.jsx)(J,{type:`button`,"aria-label":te(`card.createDependencyAriaLabel`,{title:e.title}),variant:`ghost`,size:`icon-xs`,className:`cursor-crosshair opacity-0 transition-all group-hover/card:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:t=>{t.stopPropagation(),se(!0),d(e.id,t)},children:(0,Z.jsx)(dm,{className:`h-4 w-4`})})})}),(0,Z.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:We&&(0,Z.jsx)(PD,{title:e.title,canDelete:Ee,undo:De,undoInProgress:ee,runDisabled:c,isRunPending:ue,isStopPending:W,showTestsAction:Re,showOpenChangesAction:Le,showOpenIdeAction:ze,showAddTicketToBundleAction:Be,showRunAction:Ve,showStopRunAction:He,showAdvanceAction:Ae,advanceLabel:Te,canAdvance:ke,showParkAction:je,showReturnAction:Ne,returnLabel:Me,showBuildChainAction:Pe,showPauseBuildAction:Fe,showResumeBuildAction:Ie,showStopBuildChainAction:Ue,onDelete:y,onConfirmDelete:()=>ne(!0),onConfirmUndo:()=>re(!0),onOpenTests:D,onOpenChanges:O,onOpenIde:k,onAddTicketToBundle:Be?()=>A?.(e.worktree_bundle_id):void 0,onAdvance:S,onPark:C,onUnpark:w,onBuildChain:T,onRun:Ke,onStop:qe,onStopBuild:M,onResumeBuild:P,onStopBuildChain:N})})]})]}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(LD,{ticket:e,hideStatusBadge:B,hideBundleScopedControls:z,isStale:Ce,runControl:null,onRetry:x,undoInProgress:ee,isChainStart:_e.isVisibleStartPoint})}),pt&&(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,children:[ft&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${st}`,children:[ut&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:Ud(e.bundle)}),dt&&e.bundle?.pull_request&&(0,Z.jsx)(FE,{pullRequest:e.bundle.pull_request,asLink:!0,showNumber:!0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})]}),lt.length>0&&(0,Z.jsx)(`div`,{className:st,children:(0,Z.jsx)(`span`,{className:`truncate`,children:lt})})]}),e.description&&(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(ID,{description:e.description,descriptionClass:ct,isExpanded:mt,collapsedState:gt,useStaleLikeStyling:K,onExpand:()=>le(e.id),onCollapse:()=>le(null)})}),!z&&(JE(Se,e.diff_stats)||we)&&(0,Z.jsx)(Gu,{stats:e.diff_stats,isLoading:we,showFiles:!0,className:`mt-2`})]})]}),ie&&(0,Z.jsx)(_q,{ticket:e,allTickets:t,dependencies:n,bundles:r,projectMemoryEnabled:i,onClose:()=>{ae(!1),V?.(e.id)},showModelSelector:o,availableModels:s,runDisabled:c,runDisabledReason:l,onDeleteDependency:f,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onAdvance:S,onBuildChain:T,onRun:E,onOpenIde:k,onStop:j,onStopBuild:M,onStopBuildChain:N,onResumeBuild:P,onFollowUp:F}),H&&(0,Z.jsx)(FD,{title:e.title,bundleName:e.bundle?Ud(e.bundle):void 0,onConfirm:()=>{ne(!1),y?.()},onCancel:()=>ne(!1)}),U&&De?.stage&&(0,Z.jsx)(CD,{title:e.title,stage:De.stage,onConfirm:()=>{re(!1),b?.()},onCancel:()=>re(!1)})]})},yq=({index:e})=>{let{t}=ht(`common`);return(0,Z.jsx)(Nf,{"aria-hidden":`true`,"data-testid":`ticket-card-skeleton`,className:`group shrink-0 select-none gap-0 rounded-xl border border-border/70 bg-secondary/20 shadow-none`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,"aria-hidden":`true`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsx)(Wu,{className:`h-3.5 w-3/5 rounded-full`}),(0,Z.jsx)(Wu,{className:`h-5 w-11 rounded-full`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Wu,{className:`h-3 w-full rounded-full`}),(0,Z.jsx)(Wu,{className:`h-3 w-11/12 rounded-full`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Wu,{className:`h-4 w-14 rounded-full`}),(0,Z.jsx)(Wu,{className:`h-4 w-10 rounded-full`})]}),(0,Z.jsx)(`span`,{className:`sr-only`,children:t(`column.loadingCard`,{index:e+1})})]})})},bq=({id:e,title:t,items:n,ticketCount:r,pinnedContent:i=null,allTickets:a,dependencies:o,showModelSelector:s,availableModels:c,activeRunContextKey:l,isProjectRootRunActive:u=!1,isBundleRunDisabled:d,bundles:f,getDependencyTargetState:p,onDependencyStart:m,onDeleteDependency:h,onRegisterTicketNode:g,onAddTicket:_,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,onUpdateTicket:x,onDeleteTicket:S,onUndoTicket:C,undoingColumn:w=null,onRetryTicket:T,onAdvanceTicket:E,onParkTicket:D,onUnparkTicket:O,onBuildChainTicket:k,onRunTicket:A,onOpenTestsTicket:j,canOpenChangesForTicket:M,onOpenChangesTicket:N,canOpenIdeForTicket:P,onOpenIdeTicket:F,onStopTicket:I,onStopBuildTicket:L,onStopBuildChainTicket:R,onResumeBuildTicket:z,onFollowUpTicket:B,onBuildBundle:V,onReviewBundle:ee,onUndoBundleReview:te,onRunBundle:H,onStopBundle:ne,onParkBundleWrapper:U,onUnparkBundleWrapper:re,bundleActionState:ie,onOpenTicketDetails:ae,onOpenBundleDetails:oe,onOpenBundleChanges:se,onOpenBundleTests:ce,onOpenBundleIde:le,onDeleteBundleWrapper:ue,onAddTicketToBundle:de,onRequestBundleRefresh:W,onRequestTicketRefresh:fe,className:pe=``,headerAccessory:me=null,loadingSkeletonCount:G=0})=>{let{t:he}=ht(`common`),{setNodeRef:ge,isOver:_e}=mE({id:e}),ve=(0,X.useRef)(null),[ye,be]=(0,X.useState)(!1),[xe,Se]=(0,X.useState)(!1),Ce=e=>e.has_worktree??!!(e.bundle?.branch??e.branch),we=_e?`border-primary`:`border-border`,K=w===e&&(e===`build`||e===`review`),Te=(0,X.useCallback)(()=>{let e=ve.current;if(!e){be(!1),Se(!1);return}if(!(e.scrollHeight>e.clientHeight+1)){be(!1),Se(!1);return}let t=e.scrollHeight-e.clientHeight;be(e.scrollTop>1),Se(e.scrollTop<t-1)},[]);(0,X.useEffect)(()=>{let e=window.requestAnimationFrame(Te),t=ve.current;if(!t){window.cancelAnimationFrame(e);return}return t.addEventListener(`scroll`,Te),window.addEventListener(`resize`,Te),()=>{window.cancelAnimationFrame(e),t.removeEventListener(`scroll`,Te),window.removeEventListener(`resize`,Te)}},[n.length,G,Te]);let Ee=(0,X.useCallback)((t,n)=>{let r=t.worktree_bundle_id!==null,i=n?.nestedInBundle??!1,d=n?.hideStatusBadge??!1,_=r&&e!==`plan`,w=dD(t),V=u||l!==null&&l!==HE(t)?he(`column.runDisabledReason`):w;return(0,Z.jsx)(vq,{ticket:t,allTickets:a,dependencies:o,bundles:f,showModelSelector:s,availableModels:c,runDisabled:V!==void 0,runDisabledReason:V,dependencyTargetState:p?.(t.id)??`idle`,onDependencyStart:m,onDeleteDependency:h,onRegisterNode:g,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,onUpdate:x,onDelete:()=>S(t.id),onUndo:C?()=>C(t.id):void 0,undoInProgress:!1,onRetry:()=>T(t.id),onAdvance:E?()=>E(t.id):void 0,onPark:D?()=>D(t.id):void 0,onUnpark:O?()=>O(t.id):void 0,onBuildChain:k?()=>k(t.id):void 0,onRun:Ce(t)&&t.has_run_config&&A?()=>A(t.id):void 0,onOpenTests:j&&t.project_id&&Ce(t)?()=>j(t.id):void 0,onOpenChanges:M?.(t)&&N?()=>N(t.id):void 0,onOpenIde:P?.(t)&&F?()=>F(t.id):void 0,onStop:I?()=>I(t.id):void 0,onStopBuild:L?()=>L(t.id):void 0,onStopBuildChain:R?()=>R(t.id):void 0,onResumeBuild:z?()=>z(t.id):void 0,onFollowUp:B?e=>B(t.id,e):void 0,onAddTicketToBundle:de,onOpenBundleDetails:_&&oe?()=>oe(t.worktree_bundle_id,e):void 0,onOpenTicketDetails:()=>ae(t),preferBundleDetailsOnClick:_,hideBundleScopedControls:i,hideStatusBadge:d,onRequestTicketRefresh:fe})},[l,a,c,f,M,P,o,p,e,u,de,E,k,v,y,h,S,m,B,oe,N,F,j,ae,D,b,g,fe,z,T,A,R,L,I,C,O,x,s,he]);return(0,Z.jsxs)(Nf,{className:`flex min-h-0 min-w-[280px] flex-1 flex-col rounded-2xl bg-card/80 p-4 transition-colors ${pe} ${we}`,ref:ge,children:[(0,Z.jsxs)(`div`,{className:`mb-4 flex min-h-7 items-center justify-between`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:t}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[me,(0,Z.jsx)(q,{variant:`outline`,children:r}),_&&(0,Z.jsxs)(J,{type:`button`,onClick:_,size:`xs`,variant:`success`,className:`gap-2 shadow-[0_8px_20px_rgba(16,185,129,0.22)]`,children:[(0,Z.jsx)(`span`,{children:he(`column.newTicket`)}),(0,Z.jsx)(q,{"aria-hidden":`true`,variant:`hotkeyDark`,className:`rounded-md px-1.5 py-0.5 text-[10px] leading-none`,children:`N`})]})]})]}),(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,Z.jsxs)(`div`,{ref:ve,className:`flex min-h-0 h-full flex-col gap-2.5 overflow-y-auto pr-1`,children:[i,n.map(e=>{if(e.kind===`bundle`)return(0,Z.jsx)(MD,{group:e.group,renderTicket:t=>Ee(t,{nestedInBundle:!0,hideStatusBadge:e.group.column===`review`}),runDisabled:d?.(e.group.bundle.id)??!1,onBuildBundle:V,onReviewBundle:ee,onUndoBundleReview:te,onRunBundle:H,onStopBundle:ne,onParkBundleWrapper:U,onUnparkBundleWrapper:re,bundleActionState:ie,onStopBuildTicket:L,onResumeBuildTicket:z,onOpenBundleDetails:oe,onOpenBundleChanges:se,onOpenBundleTests:ce,onOpenBundleIde:le,onDeleteBundleWrapper:ue,onAddTicketToBundle:de,onRequestBundleRefresh:W},e.group.id);let t=e.ticket;return(0,Z.jsx)(X.Fragment,{children:Ee(t)},t.id)}),Array.from({length:G},(t,n)=>(0,Z.jsx)(yq,{index:n},`loading-card-${e}-${n}`))]}),K&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-undo-overlay-${e}`,className:`absolute inset-0 z-20 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,Z.jsxs)(q,{variant:`warning`,className:`gap-1.5`,children:[(0,Z.jsx)(Gm,{className:`h-3.5 w-3.5 animate-spin`}),he(`column.undoInProgress`)]})}),ye&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-top-fade`,className:`pointer-events-none absolute inset-x-0 top-0 h-6 rounded-t-xl bg-gradient-to-b from-card to-transparent`}),xe&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-bottom-fade`,className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 rounded-b-xl bg-gradient-to-t from-card to-transparent`})]})]})},xq=({ticketCount:e,isDeleting:t,onCancel:n,onConfirm:r})=>{let{t:i}=ht(`common`);return(0,Z.jsxs)(Af,{onClose:t?()=>{}:n,overlayClassName:`bg-black/60`,panelClassName:`max-w-md rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:i(`boardConfirmEmptyDoneModal.heading`)}),(0,Z.jsx)(`p`,{className:`mb-2 text-sm text-foreground`,children:i(`boardConfirmEmptyDoneModal.deletePrompt`,{count:e})}),(0,Z.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:i(`boardConfirmEmptyDoneModal.description`)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(J,{type:`button`,variant:`ghost`,disabled:t,onClick:n,children:i(`boardConfirmEmptyDoneModal.cancel`)}),(0,Z.jsx)(J,{type:`button`,variant:`destructive`,disabled:t,onClick:r,children:i(t?`boardConfirmEmptyDoneModal.deleting`:`boardConfirmEmptyDoneModal.confirm`)})]})]})},Sq=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,currentThinkingMessageId:i=null,legacyThinkingTicketId:a=null,previousThinkingLog:o=null,previousThinkingMessageId:s=null,pendingAgentTitle:c,streamingResponse:l,isRunning:u,isLoading:d=!1,canShowComposer:f,composerControls:p,composerTheme:m=`default`,layoutKey:h,scrollLayoutKey:g,followUpPrompt:_,followUpPlaceholder:v=`Follow up on this bundle`,isSendingFollowUp:y,followUpDisabledReason:b,onFollowUpPromptChange:x,onFollowUpKeyDown:S,onFollowUpSubmit:C})=>(0,Z.jsx)(XF,{projectId:e,followUpTicketId:t,messages:n,internalLog:r,currentThinkingMessageId:i,legacyThinkingTicketId:a,previousThinkingLog:o,previousThinkingMessageId:s,pendingAgentTitle:c,streamingResponse:l,isRunning:u,isLoading:d,autoScrollBehavior:`sticky`,canShowComposer:f,composerInlineControls:p,composerTheme:m,composerSize:`compact-on-laptop`,layoutKey:h,scrollLayoutKey:g,followUpPrompt:_,followUpPlaceholder:v,emptyStateText:`No bundle messages yet.`,autoFocusComposer:!0,isSendingFollowUp:y,followUpDisabledReason:b,onFollowUpPromptChange:x,onFollowUpKeyDown:S,onFollowUpSubmit:C}),Cq=({bundleId:e,actionState:t,runDisabled:n,canBuild:r,canStopBuild:i,runningBuildTicketId:a,canResumeBuild:o,resumableBuildTicketId:s,isRunning:c,canRun:l,canReview:u,reviewActionLabel:d=`Review Bundle`,onClose:f,onBuildBundle:p,onStopBuildTicket:m,onResumeBuildTicket:h,onRunBundle:g,onStopBundle:_,onReviewBundle:v})=>{let y=t.review||t.followUp;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(J,{type:`button`,onClick:f,variant:`ghost`,children:`Close`}),c?(0,Z.jsxs)(J,{type:`button`,variant:`destructive`,disabled:t.stop,onClick:()=>void _(e),children:[(0,Z.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,Z.jsx)(Zu,{className:`w-3.5 h-3.5`}),t.stop?`Stopping...`:`Stop Run`]}):l?(0,Z.jsxs)(J,{type:`button`,variant:`secondary`,disabled:t.run||n,title:n?`Stop the currently running ticket before starting another run.`:void 0,onClick:()=>{n||g(e)},className:`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,children:[(0,Z.jsx)(Yu,{className:`w-3.5 h-3.5`}),t.run?`Starting Run...`:`Run`]}):null,r&&(0,Z.jsxs)(J,{type:`button`,disabled:t.build,onClick:()=>void p(e),children:[(0,Z.jsx)(Yu,{className:`w-3.5 h-3.5`}),t.build?`Building Bundle...`:`Build Bundle`]}),i&&a&&(0,Z.jsxs)(J,{type:`button`,variant:`warning`,disabled:t.stopBuild,title:`Pause the build session. You can resume it later.`,"aria-label":`Pause Build`,onClick:()=>void m(a),children:[(0,Z.jsx)(Zu,{className:`w-3.5 h-3.5`}),t.stopBuild?`Pausing...`:`Pause Build`]}),o&&s&&(0,Z.jsxs)(J,{type:`button`,variant:`warning`,className:`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`,disabled:t.resumeBuild,onClick:()=>void h(s),children:[(0,Z.jsx)(Yu,{className:`w-3.5 h-3.5`}),t.resumeBuild?`Resuming...`:`Resume`]}),u&&(0,Z.jsxs)(J,{type:`button`,disabled:y,onClick:()=>void v(e),children:[(0,Z.jsx)(LE,{className:`w-3.5 h-3.5`}),y?`Reviewing Bundle...`:d]})]})]})},wq=e=>e.agent_status===`running`?`bg-amber-400`:e.agent_status===`error`?`bg-rose-400`:e.agent_status===`stopped`?`bg-amber-300`:e.agent_status===`done`?`bg-emerald-400`:`bg-border`,Tq=({tickets:e,onOpenTicketDetails:t,highlightedTicketId:n=null,pendingMemorySuggestionCounts:r={}})=>{let i=e.filter(e=>e.agent_status===`running`).length,a=e.filter(e=>e.agent_status===`error`).length;return(0,Z.jsxs)(`section`,{"aria-label":`Bundle tickets`,className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Tickets`}),(0,Z.jsx)(q,{variant:`outline`,children:e.length}),i>0&&(0,Z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[i,` active`]}),a>0&&(0,Z.jsxs)(`span`,{className:`text-[11px] text-rose-300`,children:[a,` error`,a===1?``:`s`]})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-col gap-1 overflow-y-auto pr-1`,children:e.map(e=>{let i=r[e.id]??0,a=e.id===n;return(0,Z.jsxs)(`button`,{type:`button`,"data-follow-up-target":a?`true`:`false`,"aria-current":a?`true`:void 0,className:W(`flex cursor-pointer items-center gap-3 rounded-lg px-2.5 py-2.5 text-left text-foreground transition-colors`,a?`border border-sky-500/35 bg-sky-500/10 shadow-[inset_0_0_0_1px_rgba(56,189,248,0.12)] hover:bg-sky-500/15`:`bg-background/20 hover:bg-accent/45`),onClick:()=>t(e),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:W(`h-2 w-2 shrink-0 rounded-full`,wq(e))}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-xs font-medium`,children:e.title}),(0,Z.jsx)(UD,{tool:e.tool,className:`shrink-0 text-[10px]`})]}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:e.state})]}),a&&(0,Z.jsx)(q,{variant:`info`,className:`shrink-0 px-1.5 text-[10px]`,"aria-label":`Follow-up target`,children:`Follow-up`}),i>0&&(0,Z.jsx)(q,{variant:`warning`,className:`h-5 min-w-5 shrink-0 justify-center rounded-full px-1.5 text-[10px]`,"aria-label":`${i} pending memory suggestion${i===1?``:`s`}`,title:`${i} pending memory suggestion${i===1?``:`s`}`,children:i})]},e.id)})})]})},Eq=e=>e.kind===`description`?e.bundle_visible_at??e.created_at:e.created_at,Dq=(e,t)=>e?t.get(e)??e:null,Oq=(e,t)=>Dq(e,t)??`Agent`,kq=e=>e.kind===`planning_follow_up`||e.kind===`planning_response`?0:e.kind===`description`?1:2,Aq=(e,t)=>{let n={};for(let r of e){let e=Dq(r.model,t);e&&(n[r.id]=e)}return n},jq=(e,t=[])=>{let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,t)=>{let r=n.get(e.id)??e.bundle_execution_position??2**53-1,i=n.get(t.id)??t.bundle_execution_position??2**53-1;if(r!==i)return r-i;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let a=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return a===0?e.id.localeCompare(t.id):a})},Mq=(e,t,n,r=[])=>{let i=jq(e,r),a=new Map(i.map((e,t)=>[e.id,t]));return i.flatMap(e=>{let r=e.messages??[],i=e.agent_status!==null||e.session_id!==null||r.some(e=>e.kind!==`description`&&XD(e)),o=r.filter(e=>XD(e)&&(i||e.kind!==`description`)),s=n[e.id]??Oq(e.model,t);return o.map(t=>t.role===`assistant`?{...t,displayTitle:s,ticketOrder:a.get(e.id)??2**53-1}:t.kind===`follow_up`?{...t,displayTitle:`You`,ticketOrder:a.get(e.id)??2**53-1}:{...t,displayTitle:e.title,ticketOrder:a.get(e.id)??2**53-1})}).sort((e,t)=>{if(e.ticket_id===t.ticket_id){let n=kq(e)-kq(t);if(n!==0)return n}let n=Eq(e),r=Eq(t);if(n!==r)return n.localeCompare(r);if(e.ticket_id!==t.ticket_id&&e.ticketOrder!==t.ticketOrder)return e.ticketOrder-t.ticketOrder;let i=kq(e)-kq(t);return i===0?e.id.localeCompare(t.id):i}).map(e=>{let{ticketOrder:t,...n}=e;return n})},Nq=e=>Ld(e.tickets,{targetTicketId:e.target_ticket_id,reviewOwnerTicketId:e.review_owner_ticket_id,latestSessionTicketId:e.latest_session_ticket_id}),Pq=(0,X.lazy)(()=>cq(()=>Promise.resolve().then(()=>yX).then(e=>({default:e.TicketChangesModal})),void 0)),Fq=e=>e.replace(/\r\n/g,`
|
|
141
|
+
`).trim(),Iq=(e,t)=>e.ticket_id===t.ticket_id&&e.role===`user`&&t.role===`user`&&e.kind===`follow_up`&&t.kind===`follow_up`&&Fq(e.content)===Fq(t.content),Lq=(e,t)=>{if(t.length===0)return e;let n=new Set,r=new Set,i=new Map,a=[];for(let a of t){let t=[...e].reverse().find(e=>!r.has(e.id)&&!n.has(a.id)&&Iq(a,e));t&&(r.add(t.id),n.add(a.id),i.set(t.id,a))}for(let t of e){let e=i.get(t.id);if(e){a.push(e);continue}a.push(t)}for(let e of t)n.has(e.id)||a.push(e);return a},Rq=e=>e?e.startsWith(`ses_`)?`opencode --session ${e}`:`claude --resume ${e}`:null,zq=(e,t)=>e.latest_session_id?Rq(e.latest_session_id):Rq(t?.session_id??null),Bq=(e,t)=>t?.diff_stats?t.diff_stats:e.find(e=>e.diff_stats)?.diff_stats??null,Vq=({details:e,activeColumn:t=null,isLoading:n=!1,actionState:r,canOpenIde:i,projectMemoryEnabled:a=!1,memorySuggestionsRefreshKey:o=0,runDisabled:s=!1,showModelSelector:c=!1,availableModels:l=[],availableSkills:u=[],onClose:d,onOpenTicketDetails:f,onOpenIde:p,onOpenTests:m,onRefresh:h,onUpdateTicket:g,onBuildBundle:_,onStopBuildTicket:v,onResumeBuildTicket:y,onReviewBundle:b,onRunBundle:x,onStopBundle:S,onFollowUpBundle:C})=>{let{t:w}=ht(`common`),[T,E]=(0,X.useState)(!1),[D,O]=(0,X.useState)(``),[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(!1),[F,I]=(0,X.useState)(``),[L,R]=(0,X.useState)(``),[z,B]=(0,X.useState)([]),[V,ee]=(0,X.useState)(null),[te,H]=(0,X.useState)(!1),[ne,U]=(0,X.useState)(!1),[re,ie]=(0,X.useState)({}),[ae,oe]=(0,X.useState)([]),se=(0,X.useMemo)(()=>Nq(e),[e]),ce=(0,X.useMemo)(()=>new Map(l.map(e=>[e.id,e.label])),[l]),[le,ue]=(0,X.useState)(()=>Aq(e.tickets,ce)),de=(0,X.useMemo)(()=>jq(e.tickets,e.execution_order_ticket_ids),[e.execution_order_ticket_ids,e.tickets]),W=t??se?.state??null,fe=W===`plan`,pe=(0,X.useMemo)(()=>Lq(Mq(e.tickets,ce,le,e.execution_order_ticket_ids),ae),[ce,e.execution_order_ticket_ids,e.tickets,ae,le]),me=(0,X.useMemo)(()=>DD(e.tickets,W),[W,e.tickets]),G=(0,X.useMemo)(()=>(0,Z.jsx)(SD,{status:me}),[me]),he=(0,X.useMemo)(()=>zq(e,se),[e,se]),ge=(0,X.useMemo)(()=>Bq(e.tickets,se),[e.tickets,se]),_e=!fe&&!!(se?.project_id&&se&&Id(se)),ve=!!(m&&se?.project_id&&se&&Id(se)),ye=!fe&&!!(se?.project_id&&se),be=ye&&!k,xe=ye&&N&&se!==null,Se=W===`plan`&&e.tickets.some(e=>e.state===`plan`),Ce=de.find(e=>UE(e)&&e.agent_status===`running`&&!!e.session_id)??null,K=de.find(e=>UE(e)&&e.agent_status===`stopped`&&!!e.session_id)??null,Te=Ce!==null,Ee=!Te&&K!==null,Oe=W===`build`&&e.tickets.some(e=>e.state===`build`)&&e.tickets.filter(e=>e.state===`build`).every(e=>e.agent_status===`done`),ke=r.review||r.followUp,Ae=W===`review`&&e.can_re_review===!0&&!e.tickets.some(e=>e.agent_status===`running`)&&!ke,je=Oe||Ae,Me=Ae?`Re-run review`:`Review Bundle`,Ne=e.tickets.some(e=>e.has_run_config&&uD(e)),Pe=e.tickets.some(e=>e.is_running),Fe=e.tickets.find(e=>e.agent_status===`running`)??se,Ie=Fe?.streaming_response??null,Le=Fe?.agent_log??null,Re=Fe?.agent_message_id??se?.agent_message_id??null,ze=Fe?.previous_agent_log??se?.previous_agent_log??null,Be=Fe?.previous_agent_message_id??se?.previous_agent_message_id??null,Ve=l.find(e=>e.id===F)??null,He=se?.project_id??e.tickets.find(e=>e.project_id)?.project_id??null,Ue=(0,X.useMemo)(()=>e.tickets.map(e=>e.id).sort().join(`|`),[e.tickets]),We=(0,X.useMemo)(()=>new Set(Ue.length>0?Ue.split(`|`):[]),[Ue]),Ge=(0,X.useMemo)(()=>e.tickets.map(e=>`${e.id}:${e.build_completed_at??``}`).sort().join(`|`),[e.tickets]),Ke=Fe??se??e.tickets[0]??null,qe=Ke??se,Je=qe?.id??null,Ye=Fe?le[Fe.id]??Fe.model??`Agent`:`Agent`,Xe=Fe?.agent_status===`running`?Ye:null,Ze=!fe&&!!(se&&Id(se)),Y=VE(t??se?.state??null),Qe=Ze&&c&&qe?.tool===`opencode`,$e=r.followUp||ne,et=e.tickets.some(e=>e.agent_status===`running`),tt=et?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,nt=Ke?`Follow up on: ${Ke.title}`:`Follow up on this bundle`,rt=[{label:e.bundle.kind===`project_root`?`Project root branch`:`Worktree`,value:e.bundle.branch},{label:`Session`,value:he??``}],it=!fe,at=k&&!j,ot=e.bundle.id,st=k?j?`expanded`:`split`:`closed`,ct=at?`flex h-[92vh] w-[98vw] max-w-[110rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,lt=at?`grid min-h-0 flex-1 grid-cols-[16rem_minmax(0,1fr)_minmax(30rem,1fr)] gap-3 2xl:grid-cols-[18rem_minmax(0,1fr)_minmax(30rem,1fr)]`:it?`grid min-h-0 flex-1 grid-cols-[16rem_minmax(0,1fr)] gap-3 2xl:grid-cols-[18rem_minmax(0,1fr)]`:`flex min-h-0 flex-1 flex-col`,ut=j?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`fixed inset-4 z-[70] flex items-stretch justify-end bg-black/30 backdrop-blur-sm 2xl:hidden sm:inset-6 lg:inset-8`;(0,X.useEffect)(()=>{if(!a||fe||!He||Ue.length===0){ie({});return}let e=new AbortController;return De(He,null,e.signal).then(t=>{e.signal.aborted||ie(t.suggestions.reduce((e,t)=>(!t.ticket_id||!We.has(t.ticket_id)||(e[t.ticket_id]=(e[t.ticket_id]??0)+1),e),{}))}).catch(t=>{if(!e.signal.aborted){if(t instanceof we&&(t.status===404||t.status===409)){ie({});return}ie({})}}),()=>{e.abort()}},[Ge,He,We,Ue,fe,o,a]),(0,X.useEffect)(()=>{ue(t=>{let n={...t},r=!1,i=new Set(e.tickets.map(e=>e.id));for(let t of e.tickets){let e=t.model?ce.get(t.model)??t.model:null;!e||n[t.id]===e||(n[t.id]=e,r=!0)}for(let e of Object.keys(n))i.has(e)||(delete n[e],r=!0);return r?n:t})},[ce,e.tickets]),(0,X.useEffect)(()=>{if(Je!==null&&V?.ticketId===Je)if((qe?.model??``)===V.model&&(qe?.variant??``)===V.variant&&(qe?.skills.length??0)===V.skills.length&&(qe?.skills??[]).every((e,t)=>e===V.skills[t]))ee(null);else return;I(qe?.model??``),R(qe?.variant??``),B(qe?.skills??[])},[qe?.model,qe?.skills,qe?.variant,Je,V]);let dt=async(e,t,n)=>{if(qe){ee({ticketId:qe.id,model:e,variant:t,skills:n}),H(!0);try{let r=await Kt(qe.id,qe.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});g?.(r)}catch(e){ee(null),I(qe.model??``),R(qe.variant??``),B(qe.skills),Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{H(!1)}}},ft=async()=>{let t=D.trim();if(!t||$e||et)return;let n=Ke?{id:`optimistic-follow-up-${Date.now()}`,ticket_id:Ke.id,role:`user`,kind:`follow_up`,content:t,created_at:new Date().toISOString(),displayTitle:`You`}:null;U(!0),O(``),n&&oe(e=>[...e,n]);try{await C(e.bundle.id,t)}catch{n&&oe(e=>e.filter(e=>e.id!==n.id)),O(t)}finally{U(!1)}},pt=Qe?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:Qe&&(0,Z.jsx)(AI,{model:F,variant:L,skills:z,showModelSelector:!0,showSkillsSelector:!0,availableModels:l,availableSkills:u,selectedModel:Ve,onModelChange:e=>{let t=(l.find(t=>t.id===e)??null)?.variants.includes(L)?L:``;I(e),R(t),dt(e,t,z)},onVariantChange:e=>{R(e),dt(F,e,z)},onSkillsChange:e=>{B(e),dt(F,L,e)},modelSelectId:`bundle-follow-up-model`,variantSelectId:`bundle-follow-up-variant`,skillsSelectId:`bundle-follow-up-skills`,disabled:te})}):void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Af,{onClose:d,overlayClassName:`bg-black/60 !z-40`,panelClassName:ct,renderContent:({closeButton:t})=>(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsxs)(`div`,{"data-testid":`bundle-modal-layout`,"data-terminal-mode":st,className:`min-h-0 flex flex-1 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:Ud(e.bundle)}),G,e.bundle.pull_request&&(0,Z.jsx)(FE,{pullRequest:e.bundle.pull_request,asLink:!0}),(0,Z.jsxs)(q,{variant:`outline`,children:[e.tickets.length,` tickets`]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[!fe&&ge&&(0,Z.jsx)(Gu,{stats:ge,showFiles:!0,className:`text-xs`}),_e&&(0,Z.jsxs)(J,{type:`button`,"aria-label":w(`workspaceControls.changes`),onClick:()=>E(!0),variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(qu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:w(`workspaceControls.changes`)})]}),ve&&(0,Z.jsxs)(J,{type:`button`,"aria-label":w(`workspaceControls.tests`),onClick:m,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Ku,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:w(`workspaceControls.tests`)})]}),!fe&&i&&(0,Z.jsxs)(J,{type:`button`,"aria-label":w(`workspaceControls.openIde`),onClick:p,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Ju,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:w(`workspaceControls.openIde`)})]}),be&&(0,Z.jsxs)(J,{type:`button`,"aria-label":w(`workspaceControls.openTerminalAriaLabel`),onClick:()=>{P(!0),A(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Qu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:w(`workspaceControls.terminal`)})]}),t]})]}),(0,Z.jsxs)(`div`,{className:lt,children:[it&&(0,Z.jsxs)(`aside`,{"data-testid":`bundle-modal-sidebar`,className:`flex min-h-0 flex-col gap-4`,children:[(0,Z.jsx)(qD,{ariaLabel:w(`workspaceControls.ticketMetadataAriaLabel`),items:rt,className:`flex-col items-stretch gap-3`}),(0,Z.jsx)(Tq,{tickets:e.tickets,onOpenTicketDetails:f,highlightedTicketId:Ke?.id??null,pendingMemorySuggestionCounts:re})]}),(0,Z.jsxs)(`div`,{"data-testid":`bundle-modal-main`,className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[!fe&&(0,Z.jsx)(Sq,{projectId:se?.project_id??null,followUpTicketId:e.target_ticket_id,messages:pe,internalLog:Le,currentThinkingMessageId:Re,legacyThinkingTicketId:Fe?.id??se?.id??null,previousThinkingLog:ze,previousThinkingMessageId:Be,pendingAgentTitle:Xe,streamingResponse:Ie,isRunning:Fe?.agent_status===`running`,isLoading:n,canShowComposer:Ze,layoutKey:ot,scrollLayoutKey:st,composerControls:pt,composerTheme:Y,followUpPrompt:D,followUpPlaceholder:nt,isSendingFollowUp:$e,followUpDisabledReason:tt,onFollowUpPromptChange:O,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||et||$e||(e.preventDefault(),ft())},onFollowUpSubmit:()=>{ft()}}),fe&&(0,Z.jsx)(Tq,{tickets:e.tickets,onOpenTicketDetails:f,pendingMemorySuggestionCounts:re}),(0,Z.jsx)(Cq,{bundleId:e.bundle.id,actionState:r,runDisabled:s,canBuild:Se,canStopBuild:Te,runningBuildTicketId:Ce?.id??null,canResumeBuild:Ee,resumableBuildTicketId:K?.id??null,isRunning:Pe,canRun:Ne,canReview:je,reviewActionLabel:Me,onClose:d,onBuildBundle:_,onStopBuildTicket:v,onResumeBuildTicket:y,onRunBundle:x,onStopBundle:S,onReviewBundle:b})]}),xe&&se&&(0,Z.jsx)(`div`,{className:k?at?`min-h-0 flex flex-col overflow-hidden`:ut:`hidden`,children:(0,Z.jsx)($K,{createSession:()=>RD(se.id,se.project_id),isExpanded:j,isVisible:k,ariaLabel:w(`bundleDetailsModal.bundleTerminalAriaLabel`),title:w(`workspaceControls.terminalTitle`),className:at||j?`h-full w-full max-w-none rounded-2xl shadow-2xl`:`h-full w-full max-w-5xl rounded-2xl shadow-2xl`,onClose:()=>{A(!1),M(!1),P(!1),h(e.bundle.id)},onToggleExpanded:()=>{M(e=>!e)}})})]})]})})}),T&&se&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Pq,{ticketId:se.id,projectId:se.project_id,reviewCommentsBundleId:e.bundle.id,title:Ud(e.bundle),onSubmitReviewPrompt:t=>C(e.bundle.id,t),canSubmitReviewPrompt:!et,reviewSubmitDisabledReason:tt,canAddReviewComments:!et,canModifyChanges:!et,changesDisabledReason:tt,onClose:()=>{E(!1),h(e.bundle.id)}})})]})},Hq=V(`group/toggle inline-flex cursor-pointer items-center justify-center gap-1 rounded-3xl text-sm font-medium whitespace-nowrap transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-9 min-w-9 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5`,sm:`h-8 min-w-8 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,lg:`h-10 min-w-10 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3`}},defaultVariants:{variant:`default`,size:`default`}}),Uq=X.createContext({size:`default`,variant:`default`,spacing:0,orientation:`horizontal`});function Wq({className:e,variant:t,size:n,spacing:r=0,orientation:i=`horizontal`,children:a,...o}){return(0,Z.jsx)(Ts,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:W(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-[spacing=0]:data-[variant=outline]:rounded-3xl data-vertical:flex-col data-vertical:items-stretch`,e),...o,children:(0,Z.jsx)(Uq.Provider,{value:{variant:t,size:n,spacing:r,orientation:i},children:a})})}function Gq({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=X.useContext(Uq);return(0,Z.jsx)(Es,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:W(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-3 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-2.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-2.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-3xl group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-3xl group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-3xl group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-3xl data-[state=on]:bg-muted group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,Hq({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}var Kq=`border-sky-400/30 bg-sky-400/10 text-sky-100`,qq=(e,t)=>Oe.t(`common:pendingFixesPopover.${e}`,t),Jq=e=>e.old_line_number!==null&&e.new_line_number!==null?qq(`lineReference.oldAndNew`,{oldLine:e.old_line_number,newLine:e.new_line_number}):e.new_line_number===null?e.old_line_number===null?qq(`lineReference.unavailable`):qq(`lineReference.oldOnly`,{oldLine:e.old_line_number}):qq(`lineReference.newOnly`,{newLine:e.new_line_number}),Yq=e=>e.old_line_number!==null&&e.new_line_number!==null?qq(`lineReference.oldAndNew`,{oldLine:e.old_line_number,newLine:e.new_line_number}):e.new_line_number===null?e.old_line_number===null?qq(`lineReference.unavailable`):qq(`lineReference.oldOnly`,{oldLine:e.old_line_number}):qq(`lineReference.newOnly`,{newLine:e.new_line_number}),Xq=e=>e.subject_type===`file`,Zq=({reviewComments:e,reviewFindings:t=[],githubComments:n=[],pendingFixCount:r,triggerMode:i=`full`,canSendReview:a,isSubmittingReview:o,reviewSubmitDisabledReason:s,onClearPendingFixes:c,onSubmitReview:l})=>(0,Z.jsxs)(hu,{children:[(0,Z.jsx)(gu,{asChild:!0,children:(0,Z.jsxs)(J,{type:`button`,variant:`default`,size:`sm`,className:i===`compact`?`gap-1.5 px-2.5`:`gap-2`,"aria-label":qq(`triggerLabel`),disabled:r===0,children:[i===`compact`?(0,Z.jsx)(vg,{className:`h-4 w-4`}):(0,Z.jsx)(`span`,{children:qq(`triggerLabel`)}),(0,Z.jsx)(q,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:r}),(0,Z.jsx)(oe,{className:`h-4 w-4`})]})}),(0,Z.jsxs)(_u,{align:`end`,className:`z-[90] w-[30rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,Z.jsxs)(vu,{className:`flex-row items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(yu,{children:qq(`title`)}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:qq(`description`)})]}),(0,Z.jsx)(q,{variant:`outline`,children:r})]}),r===0?(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:qq(`empty`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`max-h-80 space-y-2 overflow-auto pr-1`,children:[e.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/8 px-3 py-3 shadow-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(vg,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-sky-200`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:qq(`manualCommentTitle`)}),(0,Z.jsx)(q,{variant:`outline`,className:Kq,children:qq(`manualBadge`)})]}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-sky-100/70`,children:[bS(e.scope),` · `,e.filePath,` · `,yS(e)]}),(0,Z.jsx)(`div`,{className:`mt-2 rounded-lg border border-sky-500/15 bg-background/60 px-3 py-2`,children:(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-xs text-foreground`,children:e.comment})})]})]})},`${e.filePath}:${e.changeKey}`)),t.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(lm,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:qq(`findingTitle`,{ordinal:e.ordinal})}),(0,Z.jsx)(q,{variant:`outline`,className:`capitalize`,children:e.severity})]}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.file_path,Jq(e)].filter(Boolean).join(` · `)}),(0,Z.jsx)(`div`,{className:`mt-2 text-xs font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-foreground`,children:e.what_text})]})]})},e.id)),n.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Xu,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.kind===`review`?qq(`githubReviewSummary`):qq(`githubReviewComment`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.file_path,e.kind===`inline`&&!Xq(e)?Yq(e):e.author].filter(Boolean).join(` · `)}),(0,Z.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-foreground`,children:e.body})]})]})},e.id))]}),(0,Z.jsxs)(`div`,{className:`flex justify-between gap-2 pt-2`,children:[(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,disabled:r===0||o,onClick:c,children:qq(`clear`)}),(0,Z.jsxs)(J,{type:`button`,size:`sm`,variant:`default`,disabled:!a,title:s,onClick:l,className:`gap-2`,children:[(0,Z.jsx)(LE,{className:`h-4 w-4`}),o?qq(`sending`):qq(`sendFixes`,{count:r})]})]})]})]})]}),Qq=({commitMessage:e,onCommitMessageChange:t,commitMessageRef:n,selectedFileCount:r,changesDisabledReason:i,canEditCommitMessage:a=!0,canGenerateCommitMessage:o,canCommit:s,isGeneratingCommitMessage:c,isCommitting:l,onGenerateCommitMessage:u,onCommit:d})=>{let{t:f}=ht(`common`),p=e.trim()===``,m=!a||c;return(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border bg-background/40 px-4 py-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 xl:flex-row xl:items-center xl:gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 xl:w-56`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:f(`ticketChangesCommitPanel.title`)}),(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-3 text-xs text-muted-foreground`,children:(0,Z.jsx)(q,{variant:`outline`,children:f(`ticketChangesCommitPanel.selectedFiles`,{count:r})})})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(nu,{"data-disabled":!a,className:`flex-1`,children:[(0,Z.jsx)(su,{"aria-label":f(`ticketChangesCommitPanel.commitMessageAriaLabel`),id:`ticket-changes-commit-message`,ref:n,value:e,onChange:e=>{t(e.target.value)},placeholder:f(`ticketChangesCommitPanel.commitMessagePlaceholder`),disabled:m,title:i}),p&&(0,Z.jsx)(iu,{align:`inline-end`,children:(0,Z.jsx)(ou,{"aria-label":f(`ticketChangesCommitPanel.generateCommitMessageAriaLabel`),disabled:!o,onClick:u,title:i,children:f(c?`ticketChangesCommitPanel.generating`:`ticketChangesCommitPanel.generate`)})})]}),(0,Z.jsxs)(J,{type:`button`,onClick:d,disabled:!s,title:i,className:`w-full gap-2 sm:w-auto sm:min-w-32`,children:[(0,Z.jsx)(qu,{className:`h-4 w-4`}),f(l?`ticketChangesCommitPanel.committing`:`ticketChangesCommitPanel.commit`)]})]})]})})},$q=({isCommitsLoading:e,commitsError:t,unpushedCommits:n,canUndoLatestCommit:r,isUndoing:i,aheadCount:a,onUndoLatestCommit:o})=>{let{t:s}=ht(`common`);if(!e&&n.length===0&&!t)return null;let c=n.length||a;return(0,Z.jsxs)(hu,{children:[(0,Z.jsx)(gu,{asChild:!0,children:(0,Z.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:s(`ticketChangesCommitsPanel.triggerLabel`)}),(0,Z.jsx)(q,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:c}),(0,Z.jsx)(oe,{className:`h-4 w-4`})]})}),(0,Z.jsxs)(_u,{align:`end`,className:`z-[90] w-[28rem] p-4`,children:[(0,Z.jsxs)(vu,{className:`flex-row items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(yu,{children:s(`ticketChangesCommitsPanel.triggerLabel`)}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:s(`ticketChangesCommitsPanel.description`)})]}),!e&&!t&&(0,Z.jsx)(q,{variant:`outline`,children:n.length})]}),e?(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:s(`ticketChangesCommitsPanel.loading`)}):t?(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:t}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:o,disabled:!r,children:[(0,Z.jsx)(Gm,{className:`h-3.5 w-3.5`}),s(i?`ticketChangesCommitsPanel.undoing`:`ticketChangesCommitsPanel.undoLatestCommit`)]})}),(0,Z.jsx)(`div`,{className:`max-h-72 space-y-2 overflow-auto`,children:n.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.subject}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(q,{variant:`outline`,className:`font-mono`,children:e.short_hash}),(0,Z.jsx)(`span`,{children:new Date(e.committed_at).toLocaleString()})]})]},e.hash))})]})]})]})};function eJ(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
142
|
+
font-size: .6rem;
|
|
143
|
+
font-weight: bold;
|
|
144
|
+
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function tJ(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var nJ=(e,t)=>Math.abs(e-t)<1.01,rJ=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},iJ=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},aJ=e=>e,oJ=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},sJ=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(iJ(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(iJ(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},cJ={passive:!0},lJ=typeof window>`u`?!0:`onscrollend`in window,uJ=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&lJ?()=>void 0:rJ(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,cJ);let l=e.options.useScrollendEvent&&lJ;return l&&n.addEventListener(`scrollend`,c,cJ),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},dJ=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},fJ=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},pJ=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:aJ,rangeExtractor:oJ,onChange:()=>{},measureElement:dJ,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=eJ(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=eJ(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=eJ(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let l=this.measurementsCache.slice(0,c),u=Array(a).fill(void 0);for(let e=0;e<c;e++){let t=l[e];t&&(u[t.lane]=e)}for(let i=c;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),c,d,f=o===`estimate`||s.has(e);if(a!==void 0&&this.options.lanes>1){c=a;let e=u[c],r=e===void 0?void 0:l[e];d=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?l[i-1]:this.getFurthestMeasurement(l,i);d=e?e.end+this.options.gap:t+n,c=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,c)}let p=s.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=d+m;l[i]={index:i,start:d,size:m,end:h,key:e,lane:c},u[c]=i}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=eJ(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?hJ({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=eJ(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=eJ(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return tJ(t[mJ(0,t.length-1,e=>tJ(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&nJ(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},mJ=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function hJ({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=mJ(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var gJ=typeof document<`u`?X.useLayoutEffect:X.useEffect;function _J({useFlushSync:e=!0,...t}){let n=X.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,$u.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=X.useState(()=>new pJ(r));return i.setOptions(r),gJ(()=>i._didMount(),[]),gJ(()=>i._willUpdate()),i}function vJ(e){return _J({observeElementRect:sJ,observeElementOffset:uJ,scrollToFn:fJ,...e})}var yJ=8,bJ=520,xJ=2,SJ=(e,t)=>Oe.t(`common:ticketChangesDiffPanel.${e}`,t),CJ=()=>(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-resize-placeholder`,className:`space-y-4 px-3 py-3`,children:[{gutter:`w-8`,code:`w-[68%]`},{gutter:`w-10`,code:`w-[54%]`},{gutter:`w-8`,code:`w-[74%]`},{gutter:`w-6`,code:`w-[38%]`},{gutter:`w-10`,code:`w-[82%]`},{gutter:`w-7`,code:`w-[61%]`},{gutter:`w-9`,code:`w-[48%]`},{gutter:`w-8`,code:`w-[71%]`},{gutter:`w-11`,code:`w-[57%]`},{gutter:`w-7`,code:`w-[66%]`},{gutter:`w-9`,code:`w-[43%]`},{gutter:`w-8`,code:`w-[76%]`}].map((e,t)=>(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-resize-placeholder-row`,className:`flex items-center gap-4`,children:[(0,Z.jsx)(`div`,{className:W(`h-4 rounded bg-muted/80`,e.gutter)}),(0,Z.jsx)(`div`,{className:W(`h-4 rounded bg-muted/60`,e.code)})]},`${e.gutter}-${e.code}-${t}`))}),wJ=({additions:e,deletions:t,fileCount:n})=>n===null?[{key:`additions`,content:`+${e}`,className:`font-mono text-emerald-400`},{key:`deletions`,content:`-${t}`,className:`font-mono text-rose-400`}]:[{key:`files`,content:SJ(`stats.fileCount`,{count:n}),className:`text-muted-foreground`},{key:`additions`,content:`+${e}`,className:`font-mono text-emerald-400`},{key:`deletions`,content:`-${t}`,className:`font-mono text-rose-400`}],TJ=({control:e,mode:t})=>typeof e==`function`?e(t):e??null,EJ=e=>e.reduce((e,t)=>e+t.hunks.reduce((e,t)=>e+t.changes.length,0),0),DJ=e=>pS(e),OJ=(e,t)=>{let n=`oldPath`in e&&typeof e.oldPath==`string`?t(e.oldPath):``,r=`newPath`in e&&typeof e.newPath==`string`?t(e.newPath):``;return[...new Set([r,n].filter(e=>e&&e!==`/dev/null`))]},kJ=e=>e.subject_type===`file`,AJ=e=>e.subject_type===`line`,jJ=`border-sky-400/30 bg-sky-400/10 text-sky-100`,MJ=({context:e,comment:t,reviewDraftInput:n,canEdit:r,autoFocus:i,isReadOnly:a,hasSavedComment:o,onReviewDraftInputChange:s,onCancelReviewDraft:c,onEditReviewDraft:l,onRemoveReviewDraft:u,onSaveReviewDraft:d})=>{let f=(0,X.useRef)(null),[p,m]=(0,X.useState)(()=>n),h=DJ(e.change);return(0,X.useEffect)(()=>{!i||a||f.current?.focus({preventScroll:!0})},[i,a]),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/8 p-3 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(q,{variant:`outline`,className:jJ,children:SJ(`reviewComment.manualBadge`)}),(0,Z.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-sky-100/80`,children:SJ(o?`reviewComment.commentOnLine`:`reviewComment.addCommentToLine`,{lineNumber:h})})]}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[a?(0,Z.jsx)(`div`,{className:`whitespace-pre-wrap rounded-xl border border-sky-500/15 bg-background/70 px-3 py-2.5 text-xs text-foreground`,children:t}):(0,Z.jsx)(tu,{ref:f,"aria-label":SJ(`reviewComment.ariaLabel`,{filePath:e.filePath}),value:p,onChange:e=>{m(e.target.value),s(e.target.value)},disabled:!r,className:`min-h-20 text-xs`,placeholder:SJ(`reviewComment.placeholder`)}),(0,Z.jsx)(`div`,{className:`flex gap-2`,children:a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(J,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>{l(e.commentKey)},disabled:!r,children:[(0,Z.jsx)(Hm,{className:`h-3.5 w-3.5`}),SJ(`reviewComment.edit`)]}),(0,Z.jsx)(J,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{u(e.commentKey)},disabled:!r,children:SJ(`reviewComment.remove`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(J,{type:`button`,size:`xs`,onClick:()=>{d(e,p)},disabled:!r||!p.trim(),children:SJ(`reviewComment.add`)}),(0,Z.jsx)(J,{type:`button`,size:`xs`,variant:`ghost`,onClick:c,children:SJ(`reviewComment.cancel`)})]})})]})]})},NJ=e=>e===`high`?`destructive`:e===`medium`?`warning`:`outline`,PJ=e=>e.old_line_number!==null&&e.new_line_number!==null?SJ(`lineReference.oldAndNew`,{oldLine:e.old_line_number,newLine:e.new_line_number}):e.new_line_number===null?e.old_line_number===null?SJ(`lineReference.unavailable`):SJ(`lineReference.oldOnly`,{oldLine:e.old_line_number}):SJ(`lineReference.newOnly`,{newLine:e.new_line_number}),FJ=({finding:e,isSelected:t,onToggle:n})=>{let[r,i]=(0,X.useState)(!1);return(0,Z.jsxs)(`div`,{className:`rounded-xl border border-slate-400/30 bg-slate-400/10 p-3 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(lm,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,Z.jsx)(`div`,{children:SJ(`reviewFinding.title`,{ordinal:e.ordinal})}),(0,Z.jsx)(q,{variant:NJ(e.severity),className:`normal-case`,children:e.severity})]}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-foreground`,children:e.what_text})]}),(0,Z.jsxs)(J,{type:`button`,size:`xs`,variant:t?`default`:`outline`,onClick:n,className:`gap-1.5`,children:[!t&&(0,Z.jsx)(tf,{className:`h-3.5 w-3.5`}),SJ(t?`reviewFinding.selected`:`reviewFinding.fix`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:PJ(e)}),e.file_path&&(0,Z.jsx)(`span`,{children:e.file_path})]}),(e.why_text||e.fix_text)&&(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(J,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{i(e=>!e)},children:SJ(r?`reviewFinding.hideDetails`:`reviewFinding.details`)}),r&&(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-xl border border-border bg-background/60 p-3 text-xs text-foreground`,children:[e.why_text&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:SJ(`reviewFinding.whyItMatters`)}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.why_text})]}),e.fix_text&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:SJ(`reviewFinding.requestedFix`)}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.fix_text})]})]})]})]})},IJ=e=>e.old_line_number!==null&&e.new_line_number!==null?SJ(`lineReference.oldAndNew`,{oldLine:e.old_line_number,newLine:e.new_line_number}):e.new_line_number===null?e.old_line_number===null?SJ(`lineReference.unavailable`):SJ(`lineReference.oldOnly`,{oldLine:e.old_line_number}):SJ(`lineReference.newOnly`,{newLine:e.new_line_number}),LJ=e=>e.old_line_number!==null||e.new_line_number!==null,RJ=e=>e.kind===`review`?SJ(`githubComment.reviewSummary`):kJ(e)?SJ(`githubComment.fileComment`):LJ(e)||AJ(e)?SJ(`githubComment.inlineComment`):SJ(`githubComment.fileComment`),zJ=({comment:e,isSelected:t,onToggle:n})=>(0,Z.jsxs)(`div`,{className:`rounded-xl border border-violet-400/30 bg-violet-400/10 p-3 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(q,{variant:`outline`,className:`border-violet-400/40 bg-violet-400/10 text-violet-100`,children:SJ(`githubComment.badge`)}),(0,Z.jsx)(`span`,{children:RJ(e)}),e.is_outdated&&(0,Z.jsx)(q,{variant:`warning`,className:`normal-case`,children:SJ(`githubComment.outdated`)})]}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e.author}),(0,Z.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-foreground`,children:e.body})]}),(0,Z.jsxs)(J,{type:`button`,size:`xs`,variant:t?`default`:`outline`,onClick:n,className:`gap-1.5`,children:[!t&&(0,Z.jsx)(tf,{className:`h-3.5 w-3.5`}),SJ(t?`reviewFinding.selected`:`reviewFinding.fix`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[e.file_path&&(0,Z.jsx)(`span`,{children:e.file_path}),e.kind===`inline`&&!kJ(e)&&LJ(e)&&(0,Z.jsx)(`span`,{children:IJ(e)}),(0,Z.jsx)(`span`,{children:new Date(e.updated_at).toLocaleString()}),(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-violet-200 underline underline-offset-2 transition-colors hover:text-violet-100`,children:SJ(`githubComment.openOnGitHub`)})]})]}),BJ=({allDiffFiles:e,resolveFilePath:t,normalizeDiffPath:n,reviewFindings:r})=>{let i=new Map,a=new Map,o=[],s=new Map;for(let t of e)for(let e of OJ(t,n))s.has(e)||s.set(e,t);for(let e of r){let n=e.file_path,r=n?s.get(n):null;if(!r||!n){o.push(e);continue}let c=t(r),l=null;for(let t of r.hunks){for(let n of t.changes)if(hS(e,n)){l=Tb(n);break}if(l)break}if(l){let t=i.get(c)??new Map,n=t.get(l)??[];t.set(l,[...n,e]),i.set(c,t);continue}a.set(c,[...a.get(c)??[],e])}return{inlineByFilePath:i,fileLevelByFilePath:a,globalFindings:o}},VJ=({allDiffFiles:e,resolveFilePath:t,normalizeDiffPath:n,githubComments:r})=>{let i=new Map,a=new Map,o=[],s=new Map;for(let t of e)for(let e of OJ(t,n))s.has(e)||s.set(e,t);for(let e of r){if(e.kind===`review`||!e.file_path){o.push(e);continue}let n=s.get(e.file_path);if(!n){o.push(e);continue}let r=t(n);if(kJ(e)||!e.subject_type&&!LJ(e)){a.set(r,[...a.get(r)??[],e]);continue}let c=null;for(let t of n.hunks){for(let n of t.changes)if(mS(e,n)){c=Tb(n);break}if(c)break}if(!c){o.push(e);continue}let l=i.get(r)??new Map,u=l.get(c)??[];l.set(c,[...u,e]),i.set(r,l)}return{inlineByFilePath:i,fileLevelByFilePath:a,fallbackComments:o}},HJ=({filePath:e,hunks:t,activeReviewTarget:n,editingReviewCommentKey:r,reviewDraftInstanceKey:i,reviewDraftInput:a,reviewComments:o,reviewFindingsByChangeKey:s,githubCommentsByChangeKey:c,selectedReviewFindingIds:l,selectedGitHubCommentIds:u,canEditActiveReviewDraft:d,onToggleReviewFindingSelection:f,onToggleGitHubCommentSelection:p,onReviewDraftInputChange:m,onCancelReviewDraft:h,onEditReviewDraft:g,onRemoveReviewDraft:_,onSaveReviewDraft:v})=>{let y=new Map(o.map(e=>[xS(e.filePath,e.changeKey),e]));return t.reduce((t,o)=>{for(let b of o.changes){let x=Tb(b),S=xS(e,x),C=n?.commentKey===S,w=y.get(S),T=r===S,E=s.get(x)??[],D=c.get(x)??[];if(!C&&!w&&E.length===0&&D.length===0)continue;let O={filePath:e,changeKey:x,commentKey:S,hunk:o,change:b},k=!!w&&!T&&!C,A=k?w?.comment??``:a;t[x]=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[E.map(e=>(0,Z.jsx)(FJ,{finding:e,isSelected:l.includes(e.id),onToggle:()=>{f(e.id)}},e.id)),D.map(e=>(0,Z.jsx)(zJ,{comment:e,isSelected:u.includes(e.id),onToggle:()=>{p(e.id)}},e.id)),(C||w)&&(0,Z.jsx)(MJ,{context:O,comment:w?.comment??``,reviewDraftInput:A,canEdit:d,autoFocus:C||T,isReadOnly:k,hasSavedComment:!!w,onReviewDraftInputChange:m,onCancelReviewDraft:h,onEditReviewDraft:g,onRemoveReviewDraft:_,onSaveReviewDraft:v},`${i??O.commentKey}:${k?`readonly`:`editable`}`)]})}return t},{})},UJ=e=>e.reduce((e,t)=>{for(let n of t.changes)e.set(Tb(n),{hunk:t,change:n});return e},new Map),WJ=(0,X.memo)(({selectedDiffPath:e,sidebarFiles:t,diffResponse:n,isDiffLoading:r,diffError:i,allDiffFiles:a,renderedFiles:o,viewType:s,onViewTypeChange:c,onRetry:l,activeReviewTarget:u,editingReviewCommentKey:d,reviewDraftInstanceKey:f,reviewDraftInput:p,reviewComments:m,reviewFindings:h,githubComments:g,selectedReviewFindingIds:_,selectedGitHubCommentIds:v,canSelectReviewTarget:y,canEditActiveReviewDraft:b,reviewFindingsError:x,gitHubCommentsError:S,hasStaleReviewFindings:C,onSelectReviewTarget:w,onToggleReviewFindingSelection:T,onToggleGitHubCommentSelection:E,onReviewDraftInputChange:D,onCancelReviewDraft:O,onEditReviewDraft:k,onRemoveReviewDraft:A,onSaveReviewDraft:j,diffThemeClassName:M,resolveFilePath:N,normalizeDiffPath:P,emptyStateTitle:F=SJ(`states.emptyTitle`),emptyStateDescription:I=null,filePickerControl:L,reviewSummaryControl:R,extraHeaderControl:z,headerLayout:B=`stacked`,surfaceVariant:V=`default`,showViewTypeToggle:ee=!0,gutterVariant:te=`default`,isResizing:H=!1,resizePlaceholderLineThreshold:ne=1/0,onVisibleFilePathsChange:U})=>{let re=(0,X.useRef)(null),{mode:ie,ref:ae}=ng({compactAt:V===`flat`?460:620,tightAt:V===`flat`?360:500}),oe=!!n?.diff?.trim()||o.length>0||(n?.files.length??0)>0,se=(0,X.useMemo)(()=>EJ(o),[o]),ce=e===`all`&&o.length>=yJ,le=H&&se>ne,ue=(0,X.useMemo)(()=>o.map(e=>N(e)).join(`
|
|
145
|
+
`),[o,N]),de=vJ({count:ce?o.length:0,getScrollElement:()=>re.current,estimateSize:()=>bJ,overscan:xJ,getItemKey:e=>{let t=o[e];return t?`${N(t)}:${t.type??`modify`}`:e},initialRect:{width:0,height:900}}),fe=(0,X.useMemo)(()=>new Map(n?.files.map(e=>[e.path,e])??[]),[n?.files]),pe=(0,X.useMemo)(()=>BJ({allDiffFiles:a,resolveFilePath:N,normalizeDiffPath:P,reviewFindings:C?[]:h}),[a,C,P,N,h]),me=(0,X.useMemo)(()=>VJ({allDiffFiles:a,resolveFilePath:N,normalizeDiffPath:P,githubComments:g}),[a,g,P,N]);(0,X.useEffect)(()=>{let e=re.current;e&&(e.scrollTop=0)},[e]),(0,X.useEffect)(()=>{let e=re.current;return()=>{window.getSelection()?.removeAllRanges(),e&&(e.scrollTop=0)}},[ue]);let G=de.getVirtualItems(),he=(0,X.useMemo)(()=>ce?G.map(e=>N(o[e.index])):o.map(e=>N(e)),[o,N,ce,G]);(0,X.useEffect)(()=>{U?.(he)},[U,he]);let ge=ce&&G.length>0?G[0]?.start??0:0,_e=ce&&G.length>0?Math.max(0,de.getTotalSize()-(G[G.length-1]?.end??0)):0,ve=ce?G.map(e=>({file:o[e.index],virtualItem:e})):o.map(e=>({file:e,virtualItem:null})),ye=e===`all`?null:t.find(t=>t.path===e)??null,be=e===`all`?wJ({additions:n?.stats?.additions??0,deletions:n?.stats?.deletions??0,fileCount:n?.stats?.files_changed??null}):ye?wJ({additions:ye.additions,deletions:ye.deletions,fileCount:null}):[],xe=(0,X.useMemo)(()=>ee?(0,Z.jsxs)(Wq,{type:`single`,size:`sm`,variant:`outline`,value:s,onValueChange:e=>{(e===`split`||e===`unified`)&&c(e)},children:[(0,Z.jsx)(Gq,{value:`unified`,children:SJ(`viewType.unified`)}),(0,Z.jsx)(Gq,{value:`split`,children:SJ(`viewType.split`)})]}):null,[c,ee,s]),Se=(0,X.useMemo)(()=>[TJ({control:L,mode:ie}),TJ({control:R,mode:ie})].filter(Boolean),[L,ie,R]),Ce=xe||Se.length>0||z;return(0,Z.jsxs)(`section`,{className:W(`flex min-h-0 flex-1 flex-col overflow-hidden`,V===`default`?`rounded-2xl border border-border bg-background/30`:`bg-transparent`),children:[(0,Z.jsx)(`div`,{ref:ae,"data-responsive-mode":ie,"data-testid":`ticket-diff-header`,className:W(`grid min-w-0 items-start gap-x-3 gap-y-2 border-b px-4 py-3`,V===`default`?`border-border`:`border-border/70 px-3`,B===`stacked`?z?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`:Ce?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:B===`stacked`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-left`,className:`grid min-w-0 gap-2`,children:[(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-info`,className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e===`all`?SJ(`header.allChanges`):e}),be.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-3 whitespace-nowrap text-xs`,children:be.map(e=>(0,Z.jsx)(`span`,{className:e.className,children:e.content},e.key))})]}),xe||Se.length>0?(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-controls`,className:`flex min-w-0 flex-wrap items-center gap-2 justify-start`,children:[xe?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-primary-controls`,className:`shrink-0`,children:xe}):null,Se.length>0?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-secondary-controls`,className:`flex min-w-0 items-center gap-2 justify-start`,children:Se.map((e,t)=>(0,Z.jsx)(`div`,{className:`min-w-0 shrink-0`,children:e},`header-secondary-control-${t+1}`))}):null]}):null]}),z?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-close`,className:`flex shrink-0 items-start justify-end`,children:z}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-info`,className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e===`all`?SJ(`header.allChanges`):e}),be.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-3 whitespace-nowrap text-xs`,children:be.map(e=>(0,Z.jsx)(`span`,{className:e.className,children:e.content},e.key))})]}),Ce?(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-inline-controls`,className:`flex min-w-0 flex-wrap items-start justify-end gap-2`,children:[xe?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-primary-controls`,className:`shrink-0`,children:xe}):null,Se.length>0?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-secondary-controls`,className:`flex min-w-0 flex-wrap items-center justify-end gap-2`,children:Se.map((e,t)=>(0,Z.jsx)(`div`,{className:`min-w-0 shrink-0`,children:e},`header-secondary-control-${t+1}`))}):null,z?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-close`,className:`flex shrink-0 items-start justify-end`,children:z}):null]}):null]})}),(0,Z.jsx)(`div`,{ref:re,"data-testid":`ticket-diff-scroll-region`,className:`min-h-0 flex-1 overflow-auto`,children:(0,Z.jsxs)(`div`,{className:W(`min-h-full pb-4 pt-4`,V===`default`?`px-4`:`px-0`),children:[r&&(0,Z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:SJ(`states.loading`)}),!r&&i&&(0,Z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-4 text-center`,children:[(0,Z.jsx)(`p`,{className:`max-w-md text-sm text-rose-300`,children:i}),(0,Z.jsx)(J,{type:`button`,variant:`outline`,onClick:l,children:SJ(`states.retry`)})]}),!r&&!i&&n&&!oe&&(0,Z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-2 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-foreground`,children:F}),I&&(0,Z.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:I})]}),!r&&!i&&n&&oe&&e!==`all`&&o.length===0&&(0,Z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-foreground`,children:SJ(`states.noRenderableFileTitle`)}),(0,Z.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:e})]}),!r&&!i&&n&&oe&&o.length>0&&le&&(0,Z.jsx)(CJ,{}),!r&&!i&&n&&oe&&o.length>0&&!le&&(0,Z.jsxs)(`div`,{className:W(`archon-diff-viewer`,te===`compact`&&`archon-diff-viewer--compact-gutter`,e===`all`&&V===`default`&&`space-y-6`,e===`all`&&V===`flat`&&`space-y-0`,M),children:[x&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/40 px-4 py-3 text-xs text-muted-foreground`,children:x}),S&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/40 px-4 py-3 text-xs text-muted-foreground`,children:S}),pe.globalFindings.length>0&&(0,Z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card/70 p-3`,children:[(0,Z.jsx)(`div`,{className:`mb-3 text-sm font-semibold text-foreground`,children:SJ(`reviewFinding.sectionTitle`)}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:pe.globalFindings.map(e=>(0,Z.jsx)(FJ,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{T(e.id)}},e.id))})]}),e===`all`&&me.fallbackComments.length>0&&(0,Z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card/70 p-3`,children:[(0,Z.jsx)(`div`,{className:`mb-3 text-sm font-semibold text-foreground`,children:SJ(`githubComment.sectionTitle`)}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:me.fallbackComments.map(e=>(0,Z.jsx)(zJ,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{E(e.id)}},e.id))})]}),ge>0&&(0,Z.jsx)(`div`,{style:{height:ge}}),ve.map(({file:t,virtualItem:n})=>{let r=N(t),i=fe.get(r),a=UJ(t.hunks),o=pe.inlineByFilePath.get(r)??new Map,c=me.inlineByFilePath.get(r)??new Map,l=pe.fileLevelByFilePath.get(r)??[],h=me.fileLevelByFilePath.get(r)??[],g=d?m.find(e=>xS(e.filePath,e.changeKey)===d)??null:null,x=[...m.filter(e=>e.filePath===r).map(e=>e.changeKey),...u?.filePath===r?[u.changeKey]:[],...g?.filePath===r?[g.changeKey]:[]],S=HJ({filePath:r,hunks:t.hunks,activeReviewTarget:u,editingReviewCommentKey:d,reviewDraftInstanceKey:f,reviewDraftInput:p,reviewComments:m,reviewFindingsByChangeKey:o,githubCommentsByChangeKey:c,selectedReviewFindingIds:_,selectedGitHubCommentIds:v,canEditActiveReviewDraft:b,onToggleReviewFindingSelection:T,onToggleGitHubCommentSelection:E,onReviewDraftInputChange:D,onCancelReviewDraft:O,onEditReviewDraft:k,onRemoveReviewDraft:A,onSaveReviewDraft:j}),C=(0,Z.jsx)(dx,{diffType:t.type,hunks:t.hunks,tokens:t.tokens,viewType:s,selectedChanges:[...new Set(x)],widgets:S,renderGutter:({change:e,side:t,renderDefault:n,wrapInAnchor:r,inHoverState:i})=>{if(!e)return r(n());let a=Tb(e),o=t===`new`,c=y&&t===`new`,l=s===`unified`&&e.type===`normal`&&t===`new`?null:r(n());return(0,Z.jsxs)(`div`,{className:W(`flex items-center justify-end pr-1`,te===`compact`?`gap-1 pr-0.5`:`gap-2`),children:[l,o&&(0,Z.jsx)(`span`,{"data-diff-gutter-action-slot":`true`,className:[te===`compact`?`flex size-5 shrink-0 items-center justify-center rounded-md border border-emerald-300/80 bg-emerald-400 text-[#07130d] shadow-[0_8px_20px_rgba(16,185,129,0.22)] transition-all`:`flex size-6 shrink-0 items-center justify-center rounded-md border border-emerald-300/80 bg-emerald-400 text-[#07130d] shadow-[0_8px_20px_rgba(16,185,129,0.22)] transition-all`,c&&i?`border-emerald-200 bg-emerald-300 opacity-100`:`opacity-0`,!c&&`pointer-events-none`].join(` `),"aria-hidden":`true`,children:(0,Z.jsx)(tf,{className:te===`compact`?`h-3 w-3`:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`sr-only`,children:a})]})},gutterEvents:{onClick:({change:e})=>{if(!y||!e)return;let t=a.get(Tb(e));t&&w({filePath:r,changeKey:Tb(e),commentKey:xS(r,Tb(e)),hunk:t.hunk,change:t.change})}},codeEvents:{onClick:({change:e})=>{if(!y||!e)return;let t=a.get(Tb(e));t&&w({filePath:r,changeKey:Tb(e),commentKey:xS(r,Tb(e)),hunk:t.hunk,change:t.change})}},children:e=>e.map(e=>(0,Z.jsx)(ox,{hunk:e},`${r}-${e.content}`))});return e===`all`?(0,Z.jsx)(`div`,{"data-index":n?.index,ref:n?de.measureElement:void 0,children:(0,Z.jsxs)(`section`,{className:W(V===`default`?`rounded-xl border border-border bg-card/70`:`border-t border-border/70 bg-transparent first:border-t-0`),children:[(0,Z.jsxs)(`div`,{className:W(`sticky top-0 z-20 border-b text-xs font-medium text-foreground`,V===`default`?`rounded-t-xl border-border bg-card px-4 py-3`:`border-border/70 bg-background/95 px-3 py-2.5 backdrop-blur-sm`),children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[`oldPath`in t&&typeof t.oldPath==`string`&&P(t.oldPath)===`/dev/null`&&(0,Z.jsx)(q,{variant:`success`,className:`shrink-0`,children:SJ(`fileBadge.newFile`)}),(0,Z.jsx)(`span`,{children:r})]}),i&&(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-emerald-400`,children:[`+`,i.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono text-rose-400`,children:[`-`,i.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:W(`overflow-x-auto`,V===`default`?`p-3`:`px-0 py-3`),children:[l.length>0&&(0,Z.jsx)(`div`,{className:W(`mb-3 space-y-3`,V===`flat`&&`px-3`),children:l.map(e=>(0,Z.jsx)(FJ,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{T(e.id)}},e.id))}),h.length>0&&(0,Z.jsx)(`div`,{className:W(`mb-3 space-y-3`,V===`flat`&&`px-3`),children:h.map(e=>(0,Z.jsx)(zJ,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{E(e.id)}},e.id))}),C]})]})},`${r}-${t.type??`modify`}`):(0,Z.jsxs)(`div`,{"data-index":n?.index,ref:n?de.measureElement:void 0,children:[l.length>0&&(0,Z.jsx)(`div`,{className:`mb-3 space-y-3`,children:l.map(e=>(0,Z.jsx)(FJ,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{T(e.id)}},e.id))}),h.length>0&&(0,Z.jsx)(`div`,{className:`mb-3 space-y-3`,children:h.map(e=>(0,Z.jsx)(zJ,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{E(e.id)}},e.id))}),C]},`${r}-${t.type??`modify`}`)}),_e>0&&(0,Z.jsx)(`div`,{style:{height:_e}})]})]})})]})});WJ.displayName=`TicketChangesDiffPanel`;var GJ=e=>W(`group`,e?`border-sky-700 bg-card/95 shadow-sm`:`border-border/50 bg-transparent text-muted-foreground hover:border-border/80 hover:bg-accent/60 hover:text-accent-foreground hover:shadow-sm`),KJ={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},qJ={modified:`Modified`,added:`Added`,deleted:`Deleted`,renamed:`Renamed`,untracked:`Untracked`,typechanged:`Type changed`},JJ=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},YJ=({selectionWarning:e,gitError:t,sidebarFiles:n,commentCountByPath:r,commentCountTone:i,isGitStatusLoading:a,selectedPaths:o,selectedDiffPath:s,allFilesSelected:c,diffStats:l,title:u=`Changed files`,allChangesDescription:d=`Review the full workspace diff.`,enableSelection:f=!0,onToggleSelectAll:p,onSelectDiffPath:m,onTogglePath:h})=>{let g=i===`bundle_diff`?`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`;return(0,Z.jsxs)(`aside`,{className:`flex min-h-0 h-full flex-col between overflow-hidden rounded-2xl border border-border bg-background/40`,children:[(e||t)&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 border-b border-border p-4`,children:[e&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:e}),t&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:t})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border px-4 py-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:u}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n.length,` file`,n.length===1?``:`s`,` changed`]})]}),f&&(0,Z.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:p,disabled:n.length===0,children:c?`Unselect all`:`Select all`})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[a&&(0,Z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`Loading file list...`}),!a&&n.length===0&&(0,Z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`No changes to review.`}),!a&&n.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{m(`all`)},className:W(`flex w-full cursor-pointer items-start justify-between gap-3 rounded-xl border px-2.5 py-2 text-left transition-colors`,GJ(s===`all`)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`All changes`}),l&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:[l.files_changed,` file`,l.files_changed===1?``:`s`]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,l.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,l.deletions]})]})]}),(0,Z.jsx)(`div`,{className:`mt-1 flex w-full flex-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:d})]})}),n.map(e=>{let t=f&&o.has(e.path),n=s===e.path,i=r.get(e.path)??0;return(0,Z.jsxs)(`div`,{className:W(`relative flex cursor-pointer items-start gap-2.5 rounded-xl border px-2.5 py-2 transition-colors`,GJ(n)),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Open diff for ${e.path}`,onClick:()=>{m(e.path)},className:`absolute inset-0 cursor-pointer rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`}),f&&(0,Z.jsx)(`input`,{type:`checkbox`,"aria-label":e.path,checked:t,onChange:()=>{h(e.path)},className:`relative z-10 mt-0.5 h-4 w-4 rounded border-border bg-background text-primary`}),(0,Z.jsxs)(`div`,{className:`relative z-10 min-w-0 flex-1 cursor-pointer text-left pointer-events-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-1 items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:JJ(e.path)}),i>0&&(0,Z.jsx)(`span`,{"aria-label":`${i} comment${i===1?``:`s`} in ${e.path}`,className:g,children:i})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,e.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,e.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[e.status&&(0,Z.jsx)(q,{variant:`outline`,className:KJ[e.status],children:qJ[e.status]}),e.staged&&(0,Z.jsx)(q,{variant:`outline`,children:`Staged`}),e.unstaged&&(0,Z.jsx)(q,{variant:`outline`,children:`Unstaged`}),e.conflicted&&(0,Z.jsx)(q,{variant:`destructive`,children:`Conflicted`}),e.originalPath&&(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:e.status===`renamed`?`from ${e.originalPath}`:e.originalPath})]})]})]},`${e.path}:${e.originalPath??``}`)})]})]})]})},XJ=[`[--diff-background-color:transparent]`,`[--diff-text-color:rgb(226_232_240)]`,`[--diff-selection-background-color:rgba(148,163,184,0.2)]`,`[--diff-gutter-insert-background-color:rgba(34,197,94,0.16)]`,`[--diff-gutter-delete-background-color:rgba(244,63,94,0.16)]`,`[--diff-gutter-selected-background-color:rgba(148,163,184,0.12)]`,`[--diff-code-insert-background-color:rgba(34,197,94,0.08)]`,`[--diff-code-delete-background-color:rgba(244,63,94,0.08)]`,`[--diff-code-insert-edit-background-color:rgba(34,197,94,0.22)]`,`[--diff-code-delete-edit-background-color:rgba(244,63,94,0.22)]`,`[--diff-code-selected-background-color:rgba(148,163,184,0.12)]`,`[--diff-font-family:var(--font-mono)]`,`[&_.diff]:w-full`,`[&_.diff]:border-collapse`,`[&_.diff]:font-mono`,`[&_.diff-code]:whitespace-pre-wrap`,`[&_.diff-code]:break-words`,`[&_.diff-gutter]:select-none`].join(` `),ZJ=25e4,QJ=2e3,$J=new Map,eY=e=>e?e.split(`
|
|
146
|
+
`).length:0,tY=e=>{let t=e.diff??``;return t?t.length<=ZJ&&eY(t)<=QJ:!0},nY=({scope:e,projectId:t,ticketId:n})=>e===`project_root`?t?`project_root:${t}`:null:n?`ticket:${t??`none`}:${n}`:null,rY=e=>e?$J.get(e)??null:null,iY=({cacheKey:e,diffResponse:t,gitStatus:n})=>{let r=n.workspace_signature?.trim();if(!(!e||!r)){if(!tY(t)){$J.delete(e);return}$J.set(e,{diffResponse:t,gitStatus:n,workspaceSignature:r})}},aY=e=>{e&&$J.delete(e)},oY={css:`css`,html:`markup`,htm:`markup`,js:`javascript`,jsx:`jsx`,json:`json`,md:`markdown`,markdown:`markdown`,sh:`bash`,ts:`typescript`,tsx:`tsx`,yaml:`yaml`,yml:`yaml`},sY=e=>{if(!e)return null;let t=e.split(` -> `),n=t[t.length-1]??e,r=n.split(`/`),i=r[r.length-1]??n,a=``;if(i.includes(`.`)){let e=i.split(`.`);a=e[e.length-1]?.toLowerCase()??``}return oY[a]??null},cY=new Set,lY=e=>{e&&cY.forEach(t=>t(e))},uY=e=>(cY.add(e),()=>{cY.delete(e)}),dY=300,fY=(e,t={})=>{let n=t.dedupeMs??dY,r=0,i=()=>{if(document.visibilityState!==`visible`)return;let t=Date.now();t-r<n||(r=t,e())};return window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,i),()=>{window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,i)}},pY=i(((e,t)=>{t.exports=r;var n=Object.prototype.hasOwnProperty;function r(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var i in r)n.call(r,i)&&(e[i]=r[i])}return e}})),mY=i(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.normal={},n.property={};function r(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}})),hY=i(((e,t)=>{var n=pY(),r=mY();t.exports=i;function i(e){for(var t=e.length,i=[],a=[],o=-1,s,c;++o<t;)s=e[o],i.push(s.property),a.push(s.normal),c=s.space;return new r(n.apply(null,i),n.apply(null,a),c)}})),gY=i(((e,t)=>{t.exports=n;function n(e){return e.toLowerCase()}})),_Y=i(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.attribute=null,n.property=null,n.boolean=!1,n.booleanish=!1,n.overloadedBoolean=!1,n.number=!1,n.commaSeparated=!1,n.spaceSeparated=!1,n.commaOrSpaceSeparated=!1,n.mustUseProperty=!1,n.defined=!1;function r(e,t){this.property=e,this.attribute=t}})),vY=i((e=>{var t=0;e.boolean=n(),e.booleanish=n(),e.overloadedBoolean=n(),e.number=n(),e.spaceSeparated=n(),e.commaSeparated=n(),e.commaOrSpaceSeparated=n();function n(){return 2**++t}})),yY=i(((e,t)=>{var n=_Y(),r=vY();t.exports=o,o.prototype=new n,o.prototype.defined=!0;var i=[`boolean`,`booleanish`,`overloadedBoolean`,`number`,`commaSeparated`,`spaceSeparated`,`commaOrSpaceSeparated`],a=i.length;function o(e,t,o,c){var l=-1,u;for(s(this,`space`,c),n.call(this,e,t);++l<a;)u=i[l],s(this,u,(o&r[u])===r[u])}function s(e,t,n){n&&(e[t]=n)}})),bY=i(((e,t)=>{var n=gY(),r=mY(),i=yY();t.exports=a;function a(e){var t=e.space,a=e.mustUseProperty||[],o=e.attributes||{},s=e.properties,c=e.transform,l={},u={},d,f;for(d in s)f=new i(d,c(o,d),s[d],t),a.indexOf(d)!==-1&&(f.mustUseProperty=!0),l[d]=f,u[n(d)]=d,u[n(f.attribute)]=d;return new r(l,u,t)}})),xY=i(((e,t)=>{t.exports=bY()({space:`xlink`,transform:n,properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}});function n(e,t){return`xlink:`+t.slice(5).toLowerCase()}})),SY=i(((e,t)=>{t.exports=bY()({space:`xml`,transform:n,properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function n(e,t){return`xml:`+t.slice(3).toLowerCase()}})),CY=i(((e,t)=>{t.exports=n;function n(e,t){return t in e?e[t]:t}})),wY=i(((e,t)=>{var n=CY();t.exports=r;function r(e,t){return n(e,t.toLowerCase())}})),TY=i(((e,t)=>{t.exports=bY()({space:`xmlns`,attributes:{xmlnsxlink:`xmlns:xlink`},transform:wY(),properties:{xmlns:null,xmlnsXLink:null}})})),EY=i(((e,t)=>{var n=vY(),r=bY(),i=n.booleanish,a=n.number,o=n.spaceSeparated;t.exports=r({transform:s,properties:{ariaActiveDescendant:null,ariaAtomic:i,ariaAutoComplete:null,ariaBusy:i,ariaChecked:i,ariaColCount:a,ariaColIndex:a,ariaColSpan:a,ariaControls:o,ariaCurrent:null,ariaDescribedBy:o,ariaDetails:null,ariaDisabled:i,ariaDropEffect:o,ariaErrorMessage:null,ariaExpanded:i,ariaFlowTo:o,ariaGrabbed:i,ariaHasPopup:null,ariaHidden:i,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:o,ariaLevel:a,ariaLive:null,ariaModal:i,ariaMultiLine:i,ariaMultiSelectable:i,ariaOrientation:null,ariaOwns:o,ariaPlaceholder:null,ariaPosInSet:a,ariaPressed:i,ariaReadOnly:i,ariaRelevant:null,ariaRequired:i,ariaRoleDescription:o,ariaRowCount:a,ariaRowIndex:a,ariaRowSpan:a,ariaSelected:i,ariaSetSize:a,ariaSort:null,ariaValueMax:a,ariaValueMin:a,ariaValueNow:a,ariaValueText:null,role:null}});function s(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}})),DY=i(((e,t)=>{var n=vY(),r=bY(),i=wY(),a=n.boolean,o=n.overloadedBoolean,s=n.booleanish,c=n.number,l=n.spaceSeparated,u=n.commaSeparated;t.exports=r({space:`html`,attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},transform:i,mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:u,acceptCharset:l,accessKey:l,action:null,allow:null,allowFullScreen:a,allowPaymentRequest:a,allowUserMedia:a,alt:null,as:null,async:a,autoCapitalize:null,autoComplete:l,autoFocus:a,autoPlay:a,capture:a,charSet:null,checked:a,cite:null,className:l,cols:c,colSpan:null,content:null,contentEditable:s,controls:a,controlsList:l,coords:c|u,crossOrigin:null,data:null,dateTime:null,decoding:null,default:a,defer:a,dir:null,dirName:null,disabled:a,download:o,draggable:s,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:a,formTarget:null,headers:l,height:c,hidden:a,high:c,href:null,hrefLang:null,htmlFor:l,httpEquiv:l,id:null,imageSizes:null,imageSrcSet:u,inputMode:null,integrity:null,is:null,isMap:a,itemId:null,itemProp:l,itemRef:l,itemScope:a,itemType:l,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:a,low:c,manifest:null,max:null,maxLength:c,media:null,method:null,min:null,minLength:c,multiple:a,muted:a,name:null,nonce:null,noModule:a,noValidate:a,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextMenu:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:a,optimum:c,pattern:null,ping:l,placeholder:null,playsInline:a,poster:null,preload:null,readOnly:a,referrerPolicy:null,rel:l,required:a,reversed:a,rows:c,rowSpan:c,sandbox:l,scope:null,scoped:a,seamless:a,selected:a,shape:null,size:c,sizes:null,slot:null,span:c,spellCheck:s,src:null,srcDoc:null,srcLang:null,srcSet:u,start:c,step:null,style:null,tabIndex:c,target:null,title:null,translate:null,type:null,typeMustMatch:a,useMap:null,value:s,width:c,wrap:null,align:null,aLink:null,archive:l,axis:null,background:null,bgColor:null,border:c,borderColor:null,bottomMargin:c,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:a,declare:a,event:null,face:null,frame:null,frameBorder:null,hSpace:c,leftMargin:c,link:null,longDesc:null,lowSrc:null,marginHeight:c,marginWidth:c,noResize:a,noHref:a,noShade:a,noWrap:a,object:null,profile:null,prompt:null,rev:null,rightMargin:c,rules:null,scheme:null,scrolling:s,standby:null,summary:null,text:null,topMargin:c,valueType:null,version:null,vAlign:null,vLink:null,vSpace:c,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:a,disableRemotePlayback:a,prefix:null,property:null,results:c,security:null,unselectable:null}})})),OY=i(((e,t)=>{var n=hY(),r=xY();t.exports=n([SY(),r,TY(),EY(),DY()])})),kY=i(((e,t)=>{var n=gY(),r=yY(),i=_Y(),a=`data`;t.exports=l;var o=/^data[-\w.:]+$/i,s=/-[a-z]/g,c=/[A-Z]/g;function l(e,t){var s=n(t),c=t,l=i;return s in e.normal?e.property[e.normal[s]]:(s.length>4&&s.slice(0,4)===a&&o.test(t)&&(t.charAt(4)===`-`?c=u(t):t=d(t),l=r),new l(c,t))}function u(e){var t=e.slice(5).replace(s,p);return a+t.charAt(0).toUpperCase()+t.slice(1)}function d(e){var t=e.slice(4);return s.test(t)?e:(t=t.replace(c,f),t.charAt(0)!==`-`&&(t=`-`+t),a+t)}function f(e){return`-`+e.toLowerCase()}function p(e){return e.charAt(1).toUpperCase()}})),AY=i(((e,t)=>{t.exports=r;var n=/[#.]/g;function r(e,t){for(var r=e||``,i=t||`div`,a={},o=0,s,c,l;o<r.length;)n.lastIndex=o,l=n.exec(r),s=r.slice(o,l?l.index:r.length),s&&(c?c===`#`?a.id=s:a.className?a.className.push(s):a.className=[s]:i=s,o+=s.length),l&&(c=l[0],o++);return{type:`element`,tagName:i,properties:a,children:[]}}})),jY=i((e=>{e.parse=i,e.stringify=a;var t=``,n=` `,r=/[ \t\n\r\f]+/g;function i(e){var n=String(e||t).trim();return n===t?[]:n.split(r)}function a(e){return e.join(n).trim()}})),MY=i((e=>{e.parse=i,e.stringify=a;var t=`,`,n=` `,r=``;function i(e){for(var n=[],i=String(e||r),a=i.indexOf(t),o=0,s=!1,c;!s;)a===-1&&(a=i.length,s=!0),c=i.slice(o,a).trim(),(c||!s)&&n.push(c),o=a+1,a=i.indexOf(t,o);return n}function a(e,i){var a=i||{},o=a.padLeft===!1?r:n,s=a.padRight?n:r;return e[e.length-1]===r&&(e=e.concat(r)),e.join(s+t+o).trim()}})),NY=i(((e,t)=>{var n=kY(),r=gY(),i=AY(),a=jY().parse,o=MY().parse;t.exports=c;var s={}.hasOwnProperty;function c(e,t,r){var c=r?h(r):null;return u;function u(e,n){var r=i(e,t),a=Array.prototype.slice.call(arguments,2),o=r.tagName.toLowerCase(),u;if(r.tagName=c&&s.call(c,o)?c[o]:o,n&&l(n,r)&&(a.unshift(n),n=null),n)for(u in n)p(r.properties,u,n[u]);return d(r.children,a),r.tagName===`template`&&(r.content={type:`root`,children:r.children},r.children=[]),r}function p(t,r,i){var s,c,l;i==null||i!==i||(s=n(e,r),c=s.property,l=i,typeof l==`string`&&(s.spaceSeparated?l=a(l):s.commaSeparated?l=o(l):s.commaOrSpaceSeparated&&(l=a(o(l).join(` `)))),c===`style`&&typeof i!=`string`&&(l=m(l)),c===`className`&&t.className&&(l=t.className.concat(l)),t[c]=f(s,c,l))}}function l(e,t){return typeof e==`string`||`length`in e||u(t.tagName,e)}function u(e,t){var n=t.type;return e===`input`||!n||typeof n!=`string`?!1:typeof t.children==`object`&&`length`in t.children?!0:(n=n.toLowerCase(),e===`button`?n!==`menu`&&n!==`submit`&&n!==`reset`&&n!==`button`:`value`in t)}function d(e,t){var n,r;if(typeof t==`string`||typeof t==`number`){e.push({type:`text`,value:String(t)});return}if(typeof t==`object`&&`length`in t){for(n=-1,r=t.length;++n<r;)d(e,t[n]);return}if(typeof t!=`object`||!(`type`in t))throw Error("Expected node, nodes, or string, got `"+t+"`");e.push(t)}function f(e,t,n){var r,i,a;if(typeof n!=`object`||!(`length`in n))return p(e,t,n);for(i=n.length,r=-1,a=[];++r<i;)a[r]=p(e,t,n[r]);return a}function p(e,t,n){var i=n;return e.number||e.positiveNumber?!isNaN(i)&&i!==``&&(i=Number(i)):(e.boolean||e.overloadedBoolean)&&typeof i==`string`&&(i===``||r(n)===r(t))&&(i=!0),i}function m(e){var t=[],n;for(n in e)t.push([n,e[n]].join(`: `));return t.join(`; `)}function h(e){for(var t=e.length,n=-1,r={},i;++n<t;)i=e[n],r[i.toLowerCase()]=i;return r}})),PY=i(((e,t)=>{var n=OY(),r=NY()(n,`div`);r.displayName=`html`,t.exports=r})),FY=i(((e,t)=>{t.exports=PY()})),IY=r({AElig:()=>`Æ`,AMP:()=>`&`,Aacute:()=>`Á`,Acirc:()=>`Â`,Agrave:()=>`À`,Aring:()=>`Å`,Atilde:()=>`Ã`,Auml:()=>`Ä`,COPY:()=>`©`,Ccedil:()=>`Ç`,ETH:()=>`Ð`,Eacute:()=>`É`,Ecirc:()=>`Ê`,Egrave:()=>`È`,Euml:()=>`Ë`,GT:()=>`>`,Iacute:()=>`Í`,Icirc:()=>`Î`,Igrave:()=>`Ì`,Iuml:()=>`Ï`,LT:()=>`<`,Ntilde:()=>`Ñ`,Oacute:()=>`Ó`,Ocirc:()=>`Ô`,Ograve:()=>`Ò`,Oslash:()=>`Ø`,Otilde:()=>`Õ`,Ouml:()=>`Ö`,QUOT:()=>`"`,REG:()=>`®`,THORN:()=>`Þ`,Uacute:()=>`Ú`,Ucirc:()=>`Û`,Ugrave:()=>`Ù`,Uuml:()=>`Ü`,Yacute:()=>`Ý`,aacute:()=>`á`,acirc:()=>`â`,acute:()=>`´`,aelig:()=>`æ`,agrave:()=>`à`,amp:()=>`&`,aring:()=>`å`,atilde:()=>`ã`,auml:()=>`ä`,brvbar:()=>`¦`,ccedil:()=>`ç`,cedil:()=>`¸`,cent:()=>`¢`,copy:()=>`©`,curren:()=>`¤`,default:()=>LY,deg:()=>`°`,divide:()=>`÷`,eacute:()=>`é`,ecirc:()=>`ê`,egrave:()=>`è`,eth:()=>`ð`,euml:()=>`ë`,frac12:()=>`½`,frac14:()=>`¼`,frac34:()=>`¾`,gt:()=>`>`,iacute:()=>`í`,icirc:()=>`î`,iexcl:()=>`¡`,igrave:()=>`ì`,iquest:()=>`¿`,iuml:()=>`ï`,laquo:()=>`«`,lt:()=>`<`,macr:()=>`¯`,micro:()=>`µ`,middot:()=>`·`,nbsp:()=>`\xA0`,not:()=>`¬`,ntilde:()=>`ñ`,oacute:()=>`ó`,ocirc:()=>`ô`,ograve:()=>`ò`,ordf:()=>`ª`,ordm:()=>`º`,oslash:()=>`ø`,otilde:()=>`õ`,ouml:()=>`ö`,para:()=>`¶`,plusmn:()=>`±`,pound:()=>`£`,quot:()=>`"`,raquo:()=>`»`,reg:()=>`®`,sect:()=>`§`,shy:()=>``,sup1:()=>`¹`,sup2:()=>`²`,sup3:()=>`³`,szlig:()=>`ß`,thorn:()=>`þ`,times:()=>`×`,uacute:()=>`ú`,ucirc:()=>`û`,ugrave:()=>`ù`,uml:()=>`¨`,uuml:()=>`ü`,yacute:()=>`ý`,yen:()=>`¥`,yuml:()=>`ÿ`}),LY,RY=n((()=>{LY={AElig:`Æ`,AMP:`&`,Aacute:`Á`,Acirc:`Â`,Agrave:`À`,Aring:`Å`,Atilde:`Ã`,Auml:`Ä`,COPY:`©`,Ccedil:`Ç`,ETH:`Ð`,Eacute:`É`,Ecirc:`Ê`,Egrave:`È`,Euml:`Ë`,GT:`>`,Iacute:`Í`,Icirc:`Î`,Igrave:`Ì`,Iuml:`Ï`,LT:`<`,Ntilde:`Ñ`,Oacute:`Ó`,Ocirc:`Ô`,Ograve:`Ò`,Oslash:`Ø`,Otilde:`Õ`,Ouml:`Ö`,QUOT:`"`,REG:`®`,THORN:`Þ`,Uacute:`Ú`,Ucirc:`Û`,Ugrave:`Ù`,Uuml:`Ü`,Yacute:`Ý`,aacute:`á`,acirc:`â`,acute:`´`,aelig:`æ`,agrave:`à`,amp:`&`,aring:`å`,atilde:`ã`,auml:`ä`,brvbar:`¦`,ccedil:`ç`,cedil:`¸`,cent:`¢`,copy:`©`,curren:`¤`,deg:`°`,divide:`÷`,eacute:`é`,ecirc:`ê`,egrave:`è`,eth:`ð`,euml:`ë`,frac12:`½`,frac14:`¼`,frac34:`¾`,gt:`>`,iacute:`í`,icirc:`î`,iexcl:`¡`,igrave:`ì`,iquest:`¿`,iuml:`ï`,laquo:`«`,lt:`<`,macr:`¯`,micro:`µ`,middot:`·`,nbsp:`\xA0`,not:`¬`,ntilde:`ñ`,oacute:`ó`,ocirc:`ô`,ograve:`ò`,ordf:`ª`,ordm:`º`,oslash:`ø`,otilde:`õ`,ouml:`ö`,para:`¶`,plusmn:`±`,pound:`£`,quot:`"`,raquo:`»`,reg:`®`,sect:`§`,shy:``,sup1:`¹`,sup2:`²`,sup3:`³`,szlig:`ß`,thorn:`þ`,times:`×`,uacute:`ú`,ucirc:`û`,ugrave:`ù`,uml:`¨`,uuml:`ü`,yacute:`ý`,yen:`¥`,yuml:`ÿ`}})),zY=r({default:()=>BY}),BY,VY=n((()=>{BY={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`}})),HY=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}})),UY=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}})),WY=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}})),GY=i(((e,t)=>{var n=WY(),r=HY();t.exports=i;function i(e){return n(e)||r(e)}})),KY=i(((e,t)=>{var n,r=59;t.exports=i;function i(e){var t=`&`+e+`;`,i;return n||=document.createElement(`i`),n.innerHTML=t,i=n.textContent,i.charCodeAt(i.length-1)===r&&e!==`semi`||i===t?!1:i}})),qY=i(((e,n)=>{var r=(RY(),t(IY).default),i=(VY(),t(zY).default),a=HY(),o=UY(),s=GY(),c=KY();n.exports=R;var l={}.hasOwnProperty,u=String.fromCharCode,d=Function.prototype,f={warning:null,reference:null,text:null,warningContext:null,referenceContext:null,textContext:null,position:{},additional:null,attribute:!1,nonTerminated:!0},p=9,m=10,h=12,g=32,_=38,v=59,y=60,b=61,x=35,S=88,C=120,w=65533,T=`named`,E=`hexadecimal`,D=`decimal`,O={};O[E]=16,O[D]=10;var k={};k[T]=s,k[D]=a,k[E]=o;var A=1,j=2,M=3,N=4,P=5,F=6,I=7,L={};L[A]=`Named character references must be terminated by a semicolon`,L[j]=`Numeric character references must be terminated by a semicolon`,L[M]=`Named character references cannot be empty`,L[N]=`Numeric character references cannot be empty`,L[P]=`Named character references must be known`,L[F]=`Numeric character references cannot be disallowed`,L[I]=`Numeric character references cannot be outside the permissible Unicode range`;function R(e,t){var n={},r,i;for(i in t||={},f)r=t[i],n[i]=r??f[i];return(n.position.indent||n.position.start)&&(n.indent=n.position.indent||[],n.position=n.position.start),z(e,n)}function z(e,t){var n=t.additional,a=t.nonTerminated,o=t.text,f=t.reference,R=t.warning,z=t.textContext,ee=t.referenceContext,te=t.warningContext,H=t.position,ne=t.indent||[],U=e.length,re=0,ie=-1,ae=H.column||1,oe=H.line||1,se=``,ce=[],le,ue,de,W,fe,pe,me,G,he,ge,_e,ve,ye,be,xe,Se,Ce,we,K;for(typeof n==`string`&&(n=n.charCodeAt(0)),Se=Te(),G=R?Ee:d,re--,U++;++re<U;)if(fe===m&&(ae=ne[ie]||1),fe=e.charCodeAt(re),fe===_){if(me=e.charCodeAt(re+1),me===p||me===m||me===h||me===g||me===_||me===y||me!==me||n&&me===n){se+=u(fe),ae++;continue}for(ye=re+1,ve=ye,K=ye,me===x?(K=++ve,me=e.charCodeAt(K),me===S||me===C?(be=E,K=++ve):be=D):be=T,le=``,_e=``,W=``,xe=k[be],K--;++K<U&&(me=e.charCodeAt(K),xe(me));)W+=u(me),be===T&&l.call(r,W)&&(le=W,_e=r[W]);de=e.charCodeAt(K)===v,de&&(K++,ue=be===T?c(W):!1,ue&&(le=W,_e=ue)),we=1+K-ye,!de&&!a||(W?be===T?(de&&!_e?G(P,1):(le!==W&&(K=ve+le.length,we=1+K-ve,de=!1),de||(he=le?A:M,t.attribute?(me=e.charCodeAt(K),me===b?(G(he,we),_e=null):s(me)?_e=null:G(he,we)):G(he,we))),pe=_e):(de||G(j,we),pe=parseInt(W,O[be]),B(pe)?(G(I,we),pe=u(w)):pe in i?(G(F,we),pe=i[pe]):(ge=``,V(pe)&&G(F,we),pe>65535&&(pe-=65536,ge+=u(pe>>>10|55296),pe=56320|pe&1023),pe=ge+u(pe))):be!==T&&G(N,we)),pe?(De(),Se=Te(),re=K-1,ae+=K-ye+1,ce.push(pe),Ce=Te(),Ce.offset++,f&&f.call(ee,pe,{start:Se,end:Ce},e.slice(ye-1,K)),Se=Ce):(W=e.slice(ye-1,K),se+=W,ae+=W.length,re=K-1)}else fe===10&&(oe++,ie++,ae=0),fe===fe?(se+=u(fe),ae++):De();return ce.join(``);function Te(){return{line:oe,column:ae,offset:re+(H.offset||0)}}function Ee(e,t){var n=Te();n.column+=t,n.offset+=t,R.call(te,L[e],n,e)}function De(){se&&=(ce.push(se),o&&o.call(z,se,{start:Se,end:Te()}),``)}}function B(e){return e>=55296&&e<=57343||e>1114111}function V(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}})),JY=i(((e,t)=>{var n=function(e){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,r={},i={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(t){return t instanceof a?new a(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,`&`).replace(/</g,`<`).replace(/\u00a0/g,` `)},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,`__id`,{value:++n}),e.__id},clone:function e(t,n){n||={};var r,a;switch(i.util.type(t)){case`Object`:if(a=i.util.objId(t),n[a])return n[a];for(var o in r={},n[a]=r,t)t.hasOwnProperty(o)&&(r[o]=e(t[o],n));return r;case`Array`:return a=i.util.objId(t),n[a]?n[a]:(r=[],n[a]=r,t.forEach(function(t,i){r[i]=e(t,n)}),r);default:return t}},getLanguage:function(e){for(;e;){var n=t.exec(e.className);if(n)return n[1].toLowerCase();e=e.parentElement}return`none`},setLanguage:function(e,n){e.className=e.className.replace(RegExp(t,`gi`),``),e.classList.add(`language-`+n)},currentScript:function(){if(typeof document>`u`)return null;if(`currentScript`in document)return document.currentScript;try{throw Error()}catch(r){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack)||[])[1];if(e){var t=document.getElementsByTagName(`script`);for(var n in t)if(t[n].src==e)return t[n]}return null}},isActive:function(e,t,n){for(var r=`no-`+t;e;){var i=e.classList;if(i.contains(t))return!0;if(i.contains(r))return!1;e=e.parentElement}return!!n}},languages:{plain:r,plaintext:r,text:r,txt:r,extend:function(e,t){var n=i.util.clone(i.languages[e]);for(var r in t)n[r]=t[r];return n},insertBefore:function(e,t,n,r){r||=i.languages;var a=r[e],o={};for(var s in a)if(a.hasOwnProperty(s)){if(s==t)for(var c in n)n.hasOwnProperty(c)&&(o[c]=n[c]);n.hasOwnProperty(s)||(o[s]=a[s])}var l=r[e];return r[e]=o,i.languages.DFS(i.languages,function(t,n){n===l&&t!=e&&(this[t]=o)}),o},DFS:function e(t,n,r,a){a||={};var o=i.util.objId;for(var s in t)if(t.hasOwnProperty(s)){n.call(t,s,t[s],r||s);var c=t[s],l=i.util.type(c);l===`Object`&&!a[o(c)]?(a[o(c)]=!0,e(c,n,null,a)):l===`Array`&&!a[o(c)]&&(a[o(c)]=!0,e(c,n,s,a))}}},plugins:{},highlightAll:function(e,t){i.highlightAllUnder(document,e,t)},highlightAllUnder:function(e,t,n){var r={callback:n,container:e,selector:`code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code`};i.hooks.run(`before-highlightall`,r),r.elements=Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)),i.hooks.run(`before-all-elements-highlight`,r);for(var a=0,o;o=r.elements[a++];)i.highlightElement(o,t===!0,r.callback)},highlightElement:function(t,n,r){var a=i.util.getLanguage(t),o=i.languages[a];i.util.setLanguage(t,a);var s=t.parentElement;s&&s.nodeName.toLowerCase()===`pre`&&i.util.setLanguage(s,a);var c={element:t,language:a,grammar:o,code:t.textContent};function l(e){c.highlightedCode=e,i.hooks.run(`before-insert`,c),c.element.innerHTML=c.highlightedCode,i.hooks.run(`after-highlight`,c),i.hooks.run(`complete`,c),r&&r.call(c.element)}if(i.hooks.run(`before-sanity-check`,c),s=c.element.parentElement,s&&s.nodeName.toLowerCase()===`pre`&&!s.hasAttribute(`tabindex`)&&s.setAttribute(`tabindex`,`0`),!c.code){i.hooks.run(`complete`,c),r&&r.call(c.element);return}if(i.hooks.run(`before-highlight`,c),!c.grammar){l(i.util.encode(c.code));return}if(n&&e.Worker){var u=new Worker(i.filename);u.onmessage=function(e){l(e.data)},u.postMessage(JSON.stringify({language:c.language,code:c.code,immediateClose:!0}))}else l(i.highlight(c.code,c.grammar,c.language))},highlight:function(e,t,n){var r={code:e,grammar:t,language:n};if(i.hooks.run(`before-tokenize`,r),!r.grammar)throw Error(`The language "`+r.language+`" has no grammar.`);return r.tokens=i.tokenize(r.code,r.grammar),i.hooks.run(`after-tokenize`,r),a.stringify(i.util.encode(r.tokens),r.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var r in n)t[r]=n[r];delete t.rest}var i=new c;return l(i,i.head,e),s(e,i,t,i.head,0),d(i)},hooks:{all:{},add:function(e,t){var n=i.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=i.hooks.all[e];if(!(!n||!n.length))for(var r=0,a;a=n[r++];)a(t)}},Token:a};e.Prism=i;function a(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=(r||``).length|0}a.stringify=function e(t,n){if(typeof t==`string`)return t;if(Array.isArray(t)){var r=``;return t.forEach(function(t){r+=e(t,n)}),r}var a={type:t.type,content:e(t.content,n),tag:`span`,classes:[`token`,t.type],attributes:{},language:n},o=t.alias;o&&(Array.isArray(o)?Array.prototype.push.apply(a.classes,o):a.classes.push(o)),i.hooks.run(`wrap`,a);var s=``;for(var c in a.attributes)s+=` `+c+`="`+(a.attributes[c]||``).replace(/"/g,`"`)+`"`;return`<`+a.tag+` class="`+a.classes.join(` `)+`"`+s+`>`+a.content+`</`+a.tag+`>`};function o(e,t,n,r){e.lastIndex=t;var i=e.exec(n);if(i&&r&&i[1]){var a=i[1].length;i.index+=a,i[0]=i[0].slice(a)}return i}function s(e,t,n,r,c,d){for(var f in n)if(!(!n.hasOwnProperty(f)||!n[f])){var p=n[f];p=Array.isArray(p)?p:[p];for(var m=0;m<p.length;++m){if(d&&d.cause==f+`,`+m)return;var h=p[m],g=h.inside,_=!!h.lookbehind,v=!!h.greedy,y=h.alias;if(v&&!h.pattern.global){var b=h.pattern.toString().match(/[imsuy]*$/)[0];h.pattern=RegExp(h.pattern.source,b+`g`)}for(var x=h.pattern||h,S=r.next,C=c;S!==t.tail&&!(d&&C>=d.reach);C+=S.value.length,S=S.next){var w=S.value;if(t.length>e.length)return;if(!(w instanceof a)){var T=1,E;if(v){if(E=o(x,C,e,_),!E||E.index>=e.length)break;var D=E.index,O=E.index+E[0].length,k=C;for(k+=S.value.length;D>=k;)S=S.next,k+=S.value.length;if(k-=S.value.length,C=k,S.value instanceof a)continue;for(var A=S;A!==t.tail&&(k<O||typeof A.value==`string`);A=A.next)T++,k+=A.value.length;T--,w=e.slice(C,k),E.index-=C}else if(E=o(x,0,w,_),!E)continue;var D=E.index,j=E[0],M=w.slice(0,D),N=w.slice(D+j.length),P=C+w.length;d&&P>d.reach&&(d.reach=P);var F=S.prev;M&&(F=l(t,F,M),C+=M.length),u(t,F,T);var I=new a(f,g?i.tokenize(j,g):j,y,j);if(S=l(t,F,I),N&&l(t,S,N),T>1){var L={cause:f+`,`+m,reach:P};s(e,t,n,S.prev,C,L),d&&L.reach>d.reach&&(d.reach=L.reach)}}}}}}function c(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function l(e,t,n){var r=t.next,i={value:n,prev:t,next:r};return t.next=i,r.prev=i,e.length++,i}function u(e,t,n){for(var r=t.next,i=0;i<n&&r!==e.tail;i++)r=r.next;t.next=r,r.prev=t,e.length-=i}function d(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}if(!e.document)return e.addEventListener&&(i.disableWorkerMessageHandler||e.addEventListener(`message`,function(t){var n=JSON.parse(t.data),r=n.language,a=n.code,o=n.immediateClose;e.postMessage(i.highlight(a,i.languages[r],r)),o&&e.close()},!1)),i;var f=i.util.currentScript();f&&(i.filename=f.src,f.hasAttribute(`data-manual`)&&(i.manual=!0));function p(){i.manual||i.highlightAll()}if(!i.manual){var m=document.readyState;m===`loading`||m===`interactive`&&f&&f.defer?document.addEventListener(`DOMContentLoaded`,p):window.requestAnimationFrame?window.requestAnimationFrame(p):window.setTimeout(p,16)}return i}(typeof window<`u`?window:typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope?self:{});t!==void 0&&t.exports&&(t.exports=n),typeof global<`u`&&(global.Prism=n)})),YY=i(((e,t)=>{t.exports=n,n.displayName=`markup`,n.aliases=[`html`,`mathml`,`svg`,`xml`,`ssml`,`atom`,`rss`];function n(e){e.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:`named-entity`},/&#x?[\da-f]{1,8};/i]},e.languages.markup.tag.inside[`attr-value`].inside.entity=e.languages.markup.entity,e.languages.markup.doctype.inside[`internal-subset`].inside=e.languages.markup,e.hooks.add(`wrap`,function(e){e.type===`entity`&&(e.attributes.title=e.content.value.replace(/&/,`&`))}),Object.defineProperty(e.languages.markup.tag,`addInlined`,{value:function(t,n){var r={};r[`language-`+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:e.languages[n]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};i[`language-`+n]={pattern:/[\s\S]+/,inside:e.languages[n]};var a={};a[t]={pattern:RegExp(`(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)`.replace(/__/g,function(){return t}),`i`),lookbehind:!0,greedy:!0,inside:i},e.languages.insertBefore(`markup`,`cdata`,a)}}),Object.defineProperty(e.languages.markup.tag,`addAttribute`,{value:function(t,n){e.languages.markup.tag.inside[`special-attr`].push({pattern:RegExp(`(^|["'\\s])(?:`+t+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,`i`),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[n,`language-`+n],inside:e.languages[n]},punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}}}})}}),e.languages.html=e.languages.markup,e.languages.mathml=e.languages.markup,e.languages.svg=e.languages.markup,e.languages.xml=e.languages.extend(`markup`,{}),e.languages.ssml=e.languages.xml,e.languages.atom=e.languages.xml,e.languages.rss=e.languages.xml}})),XY=i(((e,t)=>{t.exports=n,n.displayName=`css`,n.aliases=[];function n(e){(function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:`selector`},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp(`\\burl\\((?:`+t.source+`|(?:[^\\\\\\r\\n()"']|\\\\[\\s\\S])*)\\)`,`i`),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp(`^`+t.source+`$`),alias:`url`}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+`)*(?=\\s*\\{)`),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined(`style`,`css`),n.tag.addAttribute(`style`,`css`))})(e)}})),ZY=i(((e,t)=>{t.exports=n,n.displayName=`clike`,n.aliases=[];function n(e){e.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}}})),QY=i(((e,t)=>{t.exports=n,n.displayName=`javascript`,n.aliases=[`js`];function n(e){e.languages.javascript=e.languages.extend(`clike`,{"class-name":[e.languages.clike[`class-name`],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(`(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])`),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),e.languages.javascript[`class-name`][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,e.languages.insertBefore(`javascript`,`keyword`,{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:`language-regex`,inside:e.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:`function`},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:e.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:e.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:e.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:e.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),e.languages.insertBefore(`javascript`,`string`,{hashbang:{pattern:/^#!.*/,greedy:!0,alias:`comment`},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:`string`},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:`punctuation`},rest:e.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:`property`}}),e.languages.insertBefore(`javascript`,`operator`,{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:`property`}}),e.languages.markup&&(e.languages.markup.tag.addInlined(`script`,`javascript`),e.languages.markup.tag.addAttribute(`on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)`,`javascript`)),e.languages.js=e.languages.javascript}})),$Y=i(((e,t)=>{var n=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{},r=C();n.Prism={manual:!0,disableWorkerMessageHandler:!0};var i=FY(),a=qY(),o=JY(),s=YY(),c=XY(),l=ZY(),u=QY();r();var d={}.hasOwnProperty;function f(){}f.prototype=o;var p=new f;t.exports=p,p.highlight=g,p.register=m,p.alias=h,p.registered=_,p.listLanguages=v,m(s),m(c),m(l),m(u),p.util.encode=x,p.Token.stringify=y;function m(e){if(typeof e!=`function`||!e.displayName)throw Error("Expected `function` for `grammar`, got `"+e+"`");p.languages[e.displayName]===void 0&&e(p)}function h(e,t){var n=p.languages,r=e,i,a,o,s;for(i in t&&(r={},r[e]=t),r)for(a=r[i],a=typeof a==`string`?[a]:a,o=a.length,s=-1;++s<o;)n[a[s]]=n[i]}function g(e,t){var n=o.highlight,r;if(typeof e!=`string`)throw Error("Expected `string` for `value`, got `"+e+"`");if(p.util.type(t)===`Object`)r=t,t=null;else{if(typeof t!=`string`)throw Error("Expected `string` for `name`, got `"+t+"`");if(d.call(p.languages,t))r=p.languages[t];else throw Error("Unknown language: `"+t+"` is not registered")}return n.call(this,e,r,t)}function _(e){if(typeof e!=`string`)throw Error("Expected `string` for `language`, got `"+e+"`");return d.call(p.languages,e)}function v(){var e=p.languages,t=[],n;for(n in e)d.call(e,n)&&typeof e[n]==`object`&&t.push(n);return t}function y(e,t,n){var r;return typeof e==`string`?{type:`text`,value:e}:p.util.type(e)===`Array`?b(e,t):(r={type:e.type,content:p.Token.stringify(e.content,t,n),tag:`span`,classes:[`token`,e.type],attributes:{},language:t,parent:n},e.alias&&(r.classes=r.classes.concat(e.alias)),p.hooks.run(`wrap`,r),i(r.tag+`.`+r.classes.join(`.`),S(r.attributes),r.content))}function b(e,t){for(var n=[],r=e.length,i=-1,a;++i<r;)a=e[i],a!==``&&a!=null&&n.push(a);for(i=-1,r=n.length;++i<r;)a=n[i],n[i]=p.Token.stringify(a,t,n);return n}function x(e){return e}function S(e){for(var t in e)e[t]=a(e[t]);return e}function C(){var e=`Prism`in n,t=e?n.Prism:void 0;return r;function r(){e?n.Prism=t:delete n.Prism,e=void 0,t=void 0}}})),eX=i(((e,t)=>{t.exports=n,n.displayName=`bash`,n.aliases=[`shell`];function n(e){(function(e){var t=`\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b`,n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:`punctuation`,inside:null},r={bash:n,environment:{pattern:RegExp(`\\$`+t),alias:`constant`},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp(`(\\{)`+t),lookbehind:!0,alias:`constant`}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:`important`},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:`function`},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:`function`}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:`variable`,lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,inside:{environment:{pattern:RegExp(`(^|[\\s;|&]|[<>]\\()`+t),lookbehind:!0,alias:`constant`}},alias:`variable`,lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp(`\\$?`+t),alias:`constant`},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:`class-name`},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:`important`},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:`important`}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var i=[`comment`,`function-name`,`for-or-select`,`assign-left`,`string`,`environment`,`function`,`keyword`,`builtin`,`boolean`,`file-descriptor`,`operator`,`punctuation`,`number`],a=r.variable[1].inside,o=0;o<i.length;o++)a[i[o]]=e.languages.bash[i[o]];e.languages.shell=e.languages.bash})(e)}})),tX=i(((e,t)=>{t.exports=n,n.displayName=`json`,n.aliases=[`webmanifest`];function n(e){e.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:`keyword`}},e.languages.webmanifest=e.languages.json}})),nX=i(((e,t)=>{t.exports=n,n.displayName=`jsx`,n.aliases=[];function n(e){(function(e){var t=e.util.clone(e.languages.javascript),n=`(?:\\s|\\/\\/.*(?!.)|\\/\\*(?:[^*]|\\*(?!\\/))\\*\\/)`,r=`(?:\\{(?:\\{(?:\\{[^{}]*\\}|[^{}])*\\}|[^{}])*\\})`,i=`(?:\\{<S>*\\.{3}(?:[^{}]|<BRACES>)*\\})`;function a(e,t){return e=e.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return i}),RegExp(e,t)}i=a(i).source,e.languages.jsx=e.languages.extend(`markup`,t),e.languages.jsx.tag.pattern=a(`<\\/?(?:[\\w.:-]+(?:<S>+(?:[\\w.:$-]+(?:=(?:"(?:\\\\[\\s\\S]|[^\\\\"])*"|'(?:\\\\[\\s\\S]|[^\\\\'])*'|[^\\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\\/?)?>`),e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,e.languages.jsx.tag.inside[`attr-value`].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,e.languages.jsx.tag.inside.tag.inside[`class-name`]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.jsx.tag.inside.comment=t.comment,e.languages.insertBefore(`inside`,`attr-name`,{spread:{pattern:a(`<SPREAD>`),inside:e.languages.jsx}},e.languages.jsx.tag),e.languages.insertBefore(`inside`,`special-attr`,{script:{pattern:a(`=<BRACES>`),alias:`language-javascript`,inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:`punctuation`},rest:e.languages.jsx}}},e.languages.jsx.tag);var o=function(e){return e?typeof e==`string`?e:typeof e.content==`string`?e.content:e.content.map(o).join(``):``},s=function(t){for(var n=[],r=0;r<t.length;r++){var i=t[r],a=!1;if(typeof i!=`string`&&(i.type===`tag`&&i.content[0]&&i.content[0].type===`tag`?i.content[0].content[0].content===`</`?n.length>0&&n[n.length-1].tagName===o(i.content[0].content[1])&&n.pop():i.content[i.content.length-1].content===`/>`||n.push({tagName:o(i.content[0].content[1]),openedBraces:0}):n.length>0&&i.type===`punctuation`&&i.content===`{`?n[n.length-1].openedBraces++:n.length>0&&n[n.length-1].openedBraces>0&&i.type===`punctuation`&&i.content===`}`?n[n.length-1].openedBraces--:a=!0),(a||typeof i==`string`)&&n.length>0&&n[n.length-1].openedBraces===0){var c=o(i);r<t.length-1&&(typeof t[r+1]==`string`||t[r+1].type===`plain-text`)&&(c+=o(t[r+1]),t.splice(r+1,1)),r>0&&(typeof t[r-1]==`string`||t[r-1].type===`plain-text`)&&(c=o(t[r-1])+c,t.splice(r-1,1),r--),t[r]=new e.Token(`plain-text`,c,null,c)}i.content&&typeof i.content!=`string`&&s(i.content)}};e.hooks.add(`after-tokenize`,function(e){e.language!==`jsx`&&e.language!==`tsx`||s(e.tokens)})})(e)}})),rX=i(((e,t)=>{t.exports=n,n.displayName=`markdown`,n.aliases=[`md`];function n(e){(function(e){var t=`(?:\\\\.|[^\\\\\\n\\r]|(?:\\n|\\r\\n?)(?![\\r\\n]))`;function n(e){return e=e.replace(/<inner>/g,function(){return t}),RegExp(`((?:^|[^\\\\])(?:\\\\{2})*)(?:`+e+`)`)}var r="(?:\\\\.|``(?:[^`\\r\\n]|`(?!`))+``|`[^`\\r\\n]+`|[^\\\\|\\r\\n`])+",i=`\\|?__(?:\\|__)+\\|?(?:(?:\\n|\\r\\n?)|(?![\\s\\S]))`.replace(/__/g,function(){return r}),a=`\\|?[ \\t]*:?-{3,}:?[ \\t]*(?:\\|[ \\t]*:?-{3,}:?[ \\t]*)+\\|?(?:\\n|\\r\\n?)`;e.languages.markdown=e.languages.extend(`markup`,{}),e.languages.insertBefore(`markdown`,`prolog`,{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:[`yaml`,`language-yaml`],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:`punctuation`},table:{pattern:RegExp(`^`+i+a+`(?:`+i+`)*`,`m`),inside:{"table-data-rows":{pattern:RegExp(`^(`+i+a+`)(?:`+i+`)*$`),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp(`^(`+i+`)`+a+`$`),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp(`^`+i+`$`),inside:{"table-header":{pattern:RegExp(r),alias:`important`,inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:`keyword`},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:`important`,inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:`important`,inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:`punctuation`},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:`punctuation`},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:`url`},bold:{pattern:n(`\\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\\b|\\*\\*(?:(?!\\*)<inner>|\\*(?:(?!\\*)<inner>)+\\*)+\\*\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(`\\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\\b|\\*(?:(?!\\*)<inner>|\\*\\*(?:(?!\\*)<inner>)+\\*\\*)+\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(`(~~?)(?:(?!~)<inner>)+\\2`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:[`code`,`keyword`]},url:{pattern:n(`!?\\[(?:(?!\\])<inner>)+\\](?:\\([^\\s)]+(?:[\\t ]+"(?:\\\\.|[^"\\\\])*")?\\)|[ \\t]?\\[(?:(?!\\])<inner>)+\\])`),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),[`url`,`bold`,`italic`,`strike`].forEach(function(t){[`url`,`bold`,`italic`,`strike`,`code-snippet`].forEach(function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])})}),e.hooks.add(`after-tokenize`,function(e){if(e.language!==`markdown`&&e.language!==`md`)return;function t(e){if(!(!e||typeof e==`string`))for(var n=0,r=e.length;n<r;n++){var i=e[n];if(i.type!==`code`){t(i.content);continue}var a=i.content[1],o=i.content[3];if(a&&o&&a.type===`code-language`&&o.type===`code-block`&&typeof a.content==`string`){var s=a.content.replace(/\b#/g,`sharp`).replace(/\b\+\+/g,`pp`);s=(/[a-z][\w-]*/i.exec(s)||[``])[0].toLowerCase();var c=`language-`+s;o.alias?typeof o.alias==`string`?o.alias=[o.alias,c]:o.alias.push(c):o.alias=[c]}}}t(e.tokens)}),e.hooks.add(`wrap`,function(t){if(t.type===`code-block`){for(var n=``,r=0,i=t.classes.length;r<i;r++){var a=t.classes[r],o=/language-(.+)/.exec(a);if(o){n=o[1];break}}var s=e.languages[n];if(s)t.content=e.highlight(l(t.content.value),s,n);else if(n&&n!==`none`&&e.plugins.autoloader){var c=`md-`+new Date().valueOf()+`-`+Math.floor(Math.random()*0x2386f26fc10000);t.attributes.id=c,e.plugins.autoloader.loadLanguages(n,function(){var t=document.getElementById(c);t&&(t.innerHTML=e.highlight(t.textContent,e.languages[n],n))})}}});var o=RegExp(e.languages.markup.tag.pattern.source,`gi`),s={amp:`&`,lt:`<`,gt:`>`,quot:`"`},c=String.fromCodePoint||String.fromCharCode;function l(e){var t=e.replace(o,``);return t=t.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(e,t){return t=t.toLowerCase(),t[0]===`#`?c(t[1]===`x`?parseInt(t.slice(2),16):Number(t.slice(1))):s[t]||e}),t}e.languages.md=e.languages.markdown})(e)}})),iX=i(((e,t)=>{t.exports=n,n.displayName=`typescript`,n.aliases=[`ts`];function n(e){(function(e){e.languages.typescript=e.languages.extend(`javascript`,{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript[`literal-property`];var t=e.languages.extend(`typescript`,{});delete t[`class-name`],e.languages.typescript[`class-name`].inside=t,e.languages.insertBefore(`typescript`,`function`,{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:`operator`},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:t}}}}),e.languages.ts=e.languages.typescript})(e)}})),aX=i(((e,t)=>{var n=nX(),r=iX();t.exports=i,i.displayName=`tsx`,i.aliases=[];function i(e){e.register(n),e.register(r),(function(e){var t=e.util.clone(e.languages.typescript);e.languages.tsx=e.languages.extend(`jsx`,t),delete e.languages.tsx.parameter,delete e.languages.tsx[`literal-property`];var n=e.languages.tsx.tag;n.pattern=RegExp(`(^|[^\\w$]|(?=<\\/))(?:`+n.pattern.source+`)`,n.pattern.flags),n.lookbehind=!0})(e)}})),oX=i(((e,t)=>{t.exports=n,n.displayName=`yaml`,n.aliases=[`yml`];function n(e){(function(e){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r=`(?:`+n.source+`(?:[ ]+`+t.source+`)?|`+t.source+`(?:[ ]+`+n.source+`)?)`,i=`(?:[^\\s\\x00-\\x08\\x0e-\\x1f!"#%&'*,\\-:>?@[\\]\`{|}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]|[?:-]<PLAIN>)(?:[ \\t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*`.replace(/<PLAIN>/g,function(){return`[^\\s\\x00-\\x08\\x0e-\\x1f,[\\]{}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]`}),a=`"(?:[^"\\\\\\r\\n]|\\\\.)*"|'(?:[^'\\\\\\r\\n]|\\\\.)*'`;function o(e,t){t=(t||``).replace(/m/g,``)+`m`;var n=`([:\\-,[{]\\s*(?:\\s<<prop>>[ \\t]+)?)(?:<<value>>)(?=[ \\t]*(?:$|,|\\]|\\}|(?:[\\r\\n]\\s*)?#))`.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return e});return RegExp(n,t)}e.languages.yaml={scalar:{pattern:RegExp(`([\\-:]\\s*(?:\\s<<prop>>[ \\t]+)?[|>])[ \\t]*(?:((?:\\r?\\n|\\r)[ \\t]+)\\S[^\\r\\n]*(?:\\2[^\\r\\n]+)*)`.replace(/<<prop>>/g,function(){return r})),lookbehind:!0,alias:`string`},comment:/#.*/,key:{pattern:RegExp(`((?:^|[:\\-,[{\\r\\n?])[ \\t]*(?:<<prop>>[ \\t]+)?)<<key>>(?=\\s*:\\s)`.replace(/<<prop>>/g,function(){return r}).replace(/<<key>>/g,function(){return`(?:`+i+`|`+a+`)`})),lookbehind:!0,greedy:!0,alias:`atrule`},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:`important`},datetime:{pattern:o(`\\d{4}-\\d\\d?-\\d\\d?(?:[tT]|[ \\t]+)\\d\\d?:\\d{2}:\\d{2}(?:\\.\\d*)?(?:[ \\t]*(?:Z|[-+]\\d\\d?(?::\\d{2})?))?|\\d{4}-\\d{2}-\\d{2}|\\d\\d?:\\d{2}(?::\\d{2}(?:\\.\\d*)?)?`),lookbehind:!0,alias:`number`},boolean:{pattern:o(`false|true`,`i`),lookbehind:!0,alias:`important`},null:{pattern:o(`null|~`,`i`),lookbehind:!0,alias:`important`},string:{pattern:o(a),lookbehind:!0,greedy:!0},number:{pattern:o(`[+-]?(?:0x[\\da-f]+|0o[0-7]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?|\\.inf|\\.nan)`,`i`),lookbehind:!0},tag:n,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},e.languages.yml=e.languages.yaml})(e)}})),sX=e($Y(),1),cX=e(eX(),1),lX=e(XY(),1),uX=e(QY(),1),dX=e(tX(),1),fX=e(nX(),1),pX=e(rX(),1),mX=e(YY(),1),hX=e(aX(),1),gX=e(iX(),1),_X=e(oX(),1),vX=e=>{let t=e.displayName;!t||sX.default.registered(t)||sX.default.register(e)};vX(mX.default),vX(lX.default),vX(uX.default),vX(gX.default),vX(hX.default),vX(dX.default),vX(fX.default),vX(pX.default),vX(_X.default),vX(cX.default);var yX=r({TicketChangesModal:()=>JX}),bX=4,xX=1500,SX=`archon.ticket-changes.review-comments`,CX=[],wX=[],TX=[],EX=e=>new Set(e.map(e=>e.path)),DX=(e,t)=>{if(!e)return null;if(e.blocked_reason)return e.blocked_reason;let n=e.files.find(e=>!t.has(e.path)&&e.staged);return n?`"${n.path}" already has staged changes. Finish that commit in the terminal first.`:null},OX=e=>e.replace(/^[ab]\//,``),kX=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?OX(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?OX(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},AX=e=>{let[t,n]=kX(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},jX=e=>{let[t,n]=kX(e);return t??n??null},MX=e=>e.hunks.reduce((e,t)=>e+t.changes.length,0),NX=e=>{if(MX(e)>xX)return null;let t=sY(jX(e));if(!t)return null;try{return dS(e.hunks,{highlight:!0,refractor:sX.default,language:t,enhancers:[lS(e.hunks)]})}catch{return null}},PX=(e,t)=>e instanceof Error?e.message:t,FX=(e,t)=>`${SX}:${e}:${t}`,IX=()=>({activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map,signature:null}),LX=()=>({uncommitted:IX(),bundle_diff:IX()}),RX=e=>({uncommitted:e(),bundle_diff:e()}),zX=()=>RX(()=>new Map),BX=e=>{let t=5381;for(let n=0;n<e.length;n+=1)t=(t<<5)+t^e.charCodeAt(n);return`${e.length}:${t>>>0}`},VX=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return(t.scope===void 0||t.scope===`uncommitted`||t.scope===`bundle_diff`)&&typeof t.filePath==`string`&&typeof t.changeKey==`string`&&typeof t.changeType==`string`&&(typeof t.oldLineNumber==`number`||t.oldLineNumber===null)&&(typeof t.newLineNumber==`number`||t.newLineNumber===null)&&typeof t.hunkHeader==`string`&&typeof t.lineContent==`string`&&typeof t.diffSnippet==`string`&&typeof t.comment==`string`},HX=e=>{try{let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let n=t;if(typeof n.diffSignature!=`string`||!Array.isArray(n.comments))return null;let r=n.comments.filter(VX).map(e=>({scope:e.scope??`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.changeType,oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber,hunkHeader:e.hunkHeader,lineContent:e.lineContent,diffSnippet:e.diffSnippet,comment:e.comment}));return r.length===n.comments.length?{diffSignature:n.diffSignature,comments:r}:null}catch{return null}},UX=e=>new Map(e.map(e=>[xS(e.filePath,e.changeKey),e])),WX=(e,t)=>{e.set(t,(e.get(t)??0)+1)},GX=e=>e.find(e=>e.trim())||``,KX=({pullRequest:e,isLoading:t,isOpen:n,canCreate:r,disabledReason:i,isCreating:a,isSyncing:o,isGeneratingDescription:s,title:c,body:l,baseBranch:u,onOpenChange:d,onTitleChange:f,onBodyChange:p,onBaseBranchChange:m,showGenerateDescription:h,onGenerateDescription:g,onCreate:_})=>t?(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`outline`,disabled:!0,className:`gap-2`,children:`Loading PR...`}):o?(0,Z.jsxs)(J,{type:`button`,size:`sm`,variant:`outline`,disabled:!0,className:`gap-2`,children:[(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}),`Checking PR...`]}):e?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-border/80 bg-background/50 px-3 py-2`,children:[(0,Z.jsx)(FE,{pullRequest:e}),(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-xs font-medium text-sky-300 underline underline-offset-2 hover:text-sky-200`,children:[`PR #`,e.number]})]}):(0,Z.jsxs)(hu,{open:n,onOpenChange:d,children:[(0,Z.jsx)(gu,{asChild:!0,children:(0,Z.jsxs)(J,{type:`button`,size:`sm`,variant:`default`,disabled:!r,title:i,className:`gap-2`,children:[a?(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Xu,{className:`h-4 w-4`}),a?`Creating PR...`:`Create PR`]})}),(0,Z.jsxs)(_u,{align:`end`,className:`z-[90] w-[36rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,Z.jsx)(vu,{children:(0,Z.jsx)(yu,{children:`Create pull request`})}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(Bf,{label:`Title`,htmlFor:`bundle-pr-title`,children:(0,Z.jsx)(Ae,{id:`bundle-pr-title`,value:c,onChange:e=>f(e.target.value),placeholder:`Bundle title`,disabled:a})}),(0,Z.jsx)(Bf,{label:`Base branch`,htmlFor:`bundle-pr-base-branch`,description:`Optional. Leave blank to use the repository default branch.`,children:(0,Z.jsx)(Ae,{id:`bundle-pr-base-branch`,value:u,onChange:e=>m(e.target.value),placeholder:`main`,disabled:a})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,htmlFor:`bundle-pr-body`,children:`Description`}),h&&(0,Z.jsxs)(J,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:a||s,onClick:g,children:[s?(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}):null,s?`Generating...`:`Generate`]})]}),(0,Z.jsx)(tu,{id:`bundle-pr-body`,value:l,onChange:e=>p(e.target.value),placeholder:`Summarize the bundle changes for reviewers.`,className:`min-h-40`,disabled:a})]}),(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(J,{type:`button`,size:`sm`,disabled:!c.trim()||a,onClick:_,children:a?`Creating...`:`Create PR`})})]})]})]}),qX=(e,t,n)=>{if(n)return EX(t);let r=new Set(t.map(e=>e.path));return new Set([...e].filter(e=>r.has(e)))},JX=e=>{let{projectId:t,reviewCommentsBundleId:n=null,title:r,onClose:i,onSubmitReviewPrompt:a,canSubmitReviewPrompt:o=!1,reviewSubmitDisabledReason:s,canAddReviewComments:c=!0,canModifyChanges:l=!0,changesDisabledReason:u}=e,d=e.scope??`ticket`,{isGitHubConnected:f}=Am(t),p=e.scope===`project_root`?null:e.ticketId,m=e.scope===`project_root`?void 0:e.onTicketUpdate,h=e.scope===`project_root`?void 0:e.onRequestTicketRefresh,[g,_]=(0,X.useState)(`uncommitted`),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)([]),[E,D]=(0,X.useState)(new Set),[O,k]=(0,X.useState)(`all`),[A,j]=(0,X.useState)(``),[M,N]=(0,X.useState)(null),[P,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(null),[z,B]=(0,X.useState)(null),[V,ee]=(0,X.useState)(!0),[te,H]=(0,X.useState)(!1),[ne,re]=(0,X.useState)(!0),[ie,ae]=(0,X.useState)(!1),[oe,ce]=(0,X.useState)(!1),[le,ue]=(0,X.useState)(!1),[de,W]=(0,X.useState)(!1),[fe,pe]=(0,X.useState)(!1),[me,G]=(0,X.useState)(`unified`),[he,ge]=(0,X.useState)(new Map),[_e,ve]=(0,X.useState)(TX),[be,xe]=(0,X.useState)(LX),[Se,Ce]=(0,X.useState)(null),[we,K]=(0,X.useState)([]),[Te,Ee]=(0,X.useState)(null),[De,Oe]=(0,X.useState)(null),[Ae,Me]=(0,X.useState)(new Set),[Ne,Pe]=(0,X.useState)(new Set),[Fe,Ie]=(0,X.useState)(!1),[Le,ze]=(0,X.useState)(null),[Be,Ve]=(0,X.useState)(!1),[Ue,We]=(0,X.useState)(!1),[Ge,Ke]=(0,X.useState)(``),[qe,Je]=(0,X.useState)(``),[Ye,Xe]=(0,X.useState)(``),[Ze,Y]=(0,X.useState)([]),[Qe,$e]=(0,X.useState)(!1),[et,tt]=(0,X.useState)(!1),[nt,rt]=(0,X.useState)(!1),it=(0,X.useRef)(null),at=(0,X.useRef)(!1),ot=(0,X.useRef)(null),st=(0,X.useRef)(null),ct=(0,X.useRef)(0),lt=(0,X.useRef)(0),ut=(0,X.useRef)(RX(()=>null)),dt=(0,X.useRef)(zX()),ft=(0,X.useMemo)(()=>nY({scope:d,projectId:t,ticketId:p}),[t,d,p]),pt=(0,X.useCallback)(()=>{if(!p)throw Error(`Ticket changes require a ticket id.`);return p},[p]),mt=(0,X.useCallback)(e=>{ot.current=e,y(e),N(null)},[]),ht=(0,X.useCallback)((e,t)=>{iY({cacheKey:ft,diffResponse:e,gitStatus:t})},[ft]),gt=(0,X.useCallback)(e=>{ot.current&&iY({cacheKey:ft,diffResponse:ot.current,gitStatus:e})},[ft]),_t=(0,X.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await se(t)}return await Jt(pt(),t)},[t,pt,d]),vt=(0,X.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Re(t)}return await Yt(pt(),t,{refreshRemote:!1})},[t,pt,d]),yt=(0,X.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await je(t)}return await $t(pt(),t)},[t,pt,d]),bt=(0,X.useCallback)(async e=>d===`project_root`||!n||!t?null:await jt(t,n,e),[t,n,d]),xt=(0,X.useCallback)(async e=>d===`project_root`||!n||!t?null:await St(t,n,e),[t,n,d]),Ct=(0,X.useCallback)(async e=>d===`project_root`||!n||!t?null:await Mt(t,n,e),[t,n,d]),Dt=(0,X.useCallback)(async e=>d===`project_root`||!n||!t?null:await Nt(t,n,e),[t,n,d]),Ot=(0,X.useCallback)((e,t)=>{xe(n=>({...n,[e]:t(n[e])}))},[]),kt=(0,X.useCallback)(async e=>{if(d===`project_root`||!n||!t)throw Error(`Pull request description generation requires a bundle context.`);return await Tt(t,n,e)},[t,n,d]),At=(0,X.useCallback)(async e=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await U(t,e)}return await Xt(pt(),t,e)},[t,pt,d]),Pt=(0,X.useCallback)(async e=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await ke(t,e)}return await Zt(pt(),t,e)},[t,pt,d]),Ft=(0,X.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await He(t)}return await Qt(pt(),t)},[t,pt,d]),It=(0,X.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await R(t)}return await en(pt(),t)},[t,pt,d]),Lt=(0,X.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=ct.current+1;ct.current=r,ae(!0),n||B(null);try{let t=await yt();if(!e()||ct.current!==r)return;T(t.commits),B(null)}catch(t){if(!e()||ct.current!==r)return;B(PX(t,`Unable to load local commits right now.`)),n||T([])}finally{e()&&ct.current===r&&ae(!1)}},[yt]),Rt=(0,X.useCallback)(()=>{ct.current+=1,T([]),B(null),ae(!1)},[]),zt=(0,X.useCallback)((e,t={})=>{let n=t.resetSelection??!1;st.current=e,C(e),L(null),D(t=>{let r=qX(t,e.files,n||!at.current);return at.current=!0,r})},[]),Bt=(0,X.useCallback)(async(e={})=>{let t=e.preserveContent??!1,n=e.gitStatusForCache??null;t||N(null),ee(!0);try{let e=await _t();mt(e),n&&ht(e,n)}catch(e){n&&aY(ft),(!t||!ot.current)&&N(PX(e,`Unable to load the diff right now.`))}finally{ee(!1)}},[mt,ft,_t,ht]),Vt=(0,X.useCallback)(async(e={})=>{let r=e.preserveContent??!1;if(d===`project_root`||!n||!t){x(null),F(null),H(!1);return}r||F(null),H(!0);try{x(await Ct()),F(null)}catch(e){(!r||!b)&&F(PX(e,`Unable to load the branch diff right now.`))}finally{H(!1)}},[b,t,Ct,n,d]),Ht=(0,X.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=t.resetSelection??!1,i=t.allowCache??!0?rY(ft):null;if(n||(N(null),L(null)),re(!0),i){mt(i.diffResponse),zt(i.gitStatus,{resetSelection:r}),ee(!1);try{let t=await vt();if(!e())return;zt(t,{resetSelection:r}),re(!1),(t.ahead??0)>0?Lt(e,{preserveContent:!0}):Rt();let n=t.workspace_signature??null;if(n&&n===i.workspaceSignature){ht(i.diffResponse,t);return}aY(ft),await Bt({preserveContent:!0,gitStatusForCache:t});return}catch(t){if(!e())return;L(PX(t,`Unable to load git status right now.`)),C(null),re(!1),Rt();return}}ee(!0),_t().then(t=>{e()&&(mt(t),st.current&&ht(t,st.current))}).catch(t=>{e()&&(!n||!ot.current)&&N(PX(t,`Unable to load the diff right now.`))}).finally(()=>{e()&&ee(!1)});try{let t=await vt();if(!e())return;zt(t,{resetSelection:r}),re(!1),ot.current&&ht(ot.current,t),(t.ahead??0)>0?Lt(e,{preserveContent:n}):Rt()}catch(t){if(!e())return;L(PX(t,`Unable to load git status right now.`)),n||C(null),re(!1),Rt()}},[mt,zt,ft,Rt,Lt,Bt,_t,vt,ht]),Ut=(0,X.useCallback)(async()=>{if(!t)return;let e=lt.current+1;lt.current=e,re(!0);try{let t=await vt();if(lt.current!==e)return;let n=st.current?.workspace_signature??null,r=t.workspace_signature??null,i=!ot.current||n!==r;if(zt(t),(t.ahead??0)>0?Lt(()=>lt.current===e,{preserveContent:!0}):Rt(),!i){gt(t);return}await Bt({preserveContent:!0,gitStatusForCache:t})}catch{return}finally{lt.current===e&&re(!1)}},[zt,Rt,Lt,Bt,t,vt,gt]);(0,X.useEffect)(()=>{ot.current=v},[v]),(0,X.useEffect)(()=>{st.current=S},[S]),(0,X.useEffect)(()=>{let e=!0;return Ht(()=>e,{resetSelection:!0}),()=>{e=!1}},[Ht]),(0,X.useEffect)(()=>{if(t)return uY(e=>{e===t&&Ut()})},[t,Ut]),(0,X.useEffect)(()=>{if(!t)return;let e=fY(()=>{document.visibilityState===`visible`&&Ut()});return()=>{e()}},[t,Ut]),(0,X.useEffect)(()=>{if(d===`project_root`){Ce(null),Ee(null),Me(new Set);return}if(!v?.diff?.trim()){Ce(null),Ee(null),Me(new Set);return}let e=new AbortController,t=!0;return Ee(null),bt(e.signal).then(e=>{t&&(Ce(e),Me(t=>{let n=new Set((e?.findings??[]).map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(n=>{!t||e.signal.aborted||(Ee(PX(n,`Unable to load review findings right now.`)),Ce(null),Me(new Set))}),()=>{t=!1,e.abort()}},[v?.diff,bt,d]),(0,X.useEffect)(()=>{_(`uncommitted`),ut.current=RX(()=>null),dt.current=zX(),xe(LX()),x(null),F(null),H(!1),K([]),Oe(null),Pe(new Set),ze(null),Ve(!1),We(!1),Ke(``),Je(``),Xe(``),Y([]),$e(!1),tt(!1),rt(!1)},[n]),(0,X.useEffect)(()=>{if(d===`project_root`||!n||!t){ze(null),Ve(!1);return}if(v===null&&!M){Ve(!1);return}let e=new AbortController,i=!0;return Ve(!0),xt(e.signal).then(e=>{i&&(ze(e),Ke(t=>t.trim()?t:e?.bundle?Ud(e.bundle):r),Je(t=>t.trim()?t:GX(e?.recent_commit_subjects??Ze)),Xe(t=>t.trim()?t:e?.bundle.pull_request?.base_branch??``))}).catch(()=>{!i||e.signal.aborted||ze(null)}).finally(()=>{i&&Ve(!1)}),()=>{i=!1,e.abort()}},[M,v,Ze,t,xt,n,d,r]),(0,X.useEffect)(()=>{if(d===`project_root`||!n||!t){x(null),F(null),H(!1);return}if(g!==`bundle_diff`){H(!1);return}let e=new AbortController,r=!0;return H(!0),F(null),Ct(e.signal).then(e=>{r&&(x(e),F(null))}).catch(t=>{!r||e.signal.aborted||(F(PX(t,`Unable to load the branch diff right now.`)),x(null))}).finally(()=>{r&&H(!1)}),()=>{r=!1,e.abort()}},[g,t,Ct,n,d]),(0,X.useEffect)(()=>{let e=Le?.bundle.pull_request??null;if(d===`project_root`||!n||!t||!e){K([]),Oe(null),Pe(new Set);return}if(!f){K([]),Oe(null),Pe(new Set);return}if(g!==`bundle_diff`)return;let r=new AbortController,i=!0;return Oe(null),Dt(r.signal).then(e=>{!i||!e||(K(e.comments),Oe(e.error),Pe(t=>{let n=new Set(e.comments.map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(e=>{!i||r.signal.aborted||(K([]),Oe(PX(e,`Unable to load GitHub review comments right now.`)),Pe(new Set))}),()=>{i=!1,r.abort()}},[g,Le?.bundle.pull_request,f,t,Dt,n,d]),(0,X.useEffect)(()=>{ne&&S===null||it.current?.focus()},[S,ne]);let Wt=(0,X.useMemo)(()=>{let e=typeof v?.diff==`string`?v.diff:``;return e.trim()?n_(e).map(e=>({...e,pathCandidates:kX(e)})):[]},[v]),Gt=(0,X.useMemo)(()=>{let e=typeof b?.diff==`string`?b.diff:``;return e.trim()?n_(e).map(e=>({...e,pathCandidates:kX(e)})):[]},[b]),Kt=(0,X.useMemo)(()=>{let e=v?.diff??``;return e?BX(e):null},[v?.diff]),qt=(0,X.useMemo)(()=>{let e=b?.diff??``;return e?BX(e):null},[b?.diff]),tn=g===`bundle_diff`?b:v,nn=g===`bundle_diff`?Gt:Wt,rn=(0,X.useMemo)(()=>n?{uncommitted:FX(n,`uncommitted`),bundle_diff:FX(n,`bundle_diff`)}:{uncommitted:null,bundle_diff:null},[n]),an=(0,X.useMemo)(()=>({uncommitted:Kt,bundle_diff:qt}),[qt,Kt]),on=(0,X.useMemo)(()=>{let e=new Map;for(let t of tn?.files??[])e.set(t.path,t);return e},[tn]),sn=(0,X.useMemo)(()=>{let e=new Map;for(let t of nn)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[nn]),cn=(0,X.useCallback)(e=>{ve(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),ln=(0,X.useMemo)(()=>g===`bundle_diff`?(b?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})):S?(S.files??[]).map(e=>{let t=on.get(e.path)??(e.original_path?on.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(v?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})),[g,b?.files,on,v?.files,S]);(0,X.useEffect)(()=>{O!==`all`&&(ln.some(e=>e.path===O)||k(`all`))},[O,ln]);let un=g===`bundle_diff`?0:E.size,dn=g===`bundle_diff`?ln.length:S?.files?.length??ln.length,fn=dn>0&&un===dn,pn=(0,X.useMemo)(()=>g===`bundle_diff`?null:DX(S,E),[g,S,E]),mn=g===`uncommitted`&&!ne&&!oe&&l&&!!S&&un>0&&A.trim().length>0&&pn===null,hn=g===`uncommitted`&&!ne&&!V&&!le&&!oe&&!de&&l&&!Fe&&!!S&&un>0,gn=!ne&&(de||!!S?.can_push&&(S?.ahead??0)>0),_n=gn&&l&&!de&&!oe,vn=l&&!ie&&!fe&&!oe&&!de&&(w?.length??0)>0,yn=(S?.ahead??0)>0?`${S?.ahead??0} to push`:`Up to date`,bn=(S?.behind??0)>0?`${S?.behind??0} behind`:`In sync`,xn=S?.branch??null,Sn=O===`all`?null:sn.get(O)??null,Cn=(0,X.useMemo)(()=>O===`all`?nn:Sn?[Sn]:[],[nn,O,Sn]);(0,X.useEffect)(()=>{ge(new Map),ve(TX)},[g,nn]),(0,X.useEffect)(()=>{let e={uncommitted:rn.uncommitted&&an.uncommitted?`${rn.uncommitted}:${an.uncommitted}`:null,bundle_diff:rn.bundle_diff&&an.bundle_diff?`${rn.bundle_diff}:${an.bundle_diff}`:null},t=ut.current;t.uncommitted===e.uncommitted&&t.bundle_diff===e.bundle_diff||(ut.current=e,xe(n=>{let r={...n};return[`uncommitted`,`bundle_diff`].forEach(i=>{if(t[i]===e[i])return;let a=an[i],o=rn[i],s=n[i];if(t[i]===null&&a&&(s.activeTarget||s.editingCommentKey||s.draftInput.trim()||s.comments.size>0)){r[i]={...s,signature:a};return}if(!a){dt.current[i]=new Map,r[i]=IX();return}let c=new Map;if(o){let e=window.localStorage.getItem(o),t=e?HX(e):null;t?.diffSignature===a?c=UX(t.comments.map(e=>({...e,scope:i}))):e!==null&&window.localStorage.removeItem(o)}dt.current[i]=new Map,r[i]={activeTarget:null,editingCommentKey:null,draftInput:``,comments:c,signature:a}}),r}))},[an,rn]),(0,X.useEffect)(()=>{[`uncommitted`,`bundle_diff`].forEach(e=>{let t=rn[e],n=an[e],r=be[e];if(!t||!n||r.signature!==n)return;if(r.comments.size===0){window.localStorage.removeItem(t);return}let i={diffSignature:n,comments:[...r.comments.values()]};window.localStorage.setItem(t,JSON.stringify(i))})},[an,rn,be]),(0,X.useEffect)(()=>{if(nn.length===0)return;let e=!1,t=null,n=(()=>{if(!Sn){let e=[],t=new Set;for(let n of _e){let r=sn.get(n);if(!r)continue;let i=AX(r);t.has(i)||(t.add(i),e.push(r))}return e.length>0?e:nn.slice(0,bX)}return[Sn]})(),r=0,i=()=>{if(e)return;let a=n.slice(r,r+bX);a.length!==0&&(ge(e=>{let t=new Map(e);for(let e of a){let n=AX(e);t.has(n)||t.set(n,NX(e))}return t}),r+=bX,r<n.length&&(t=window.setTimeout(i,0)))};return n.length<=bX?i():t=window.setTimeout(i,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[nn,sn,Sn,_e]);let wn=(0,X.useMemo)(()=>Cn.map(e=>({...e,tokens:he.get(AX(e))??null})),[he,Cn]),Tn=(0,X.useMemo)(()=>nn.map(e=>({...e,tokens:null})),[nn]),En=(0,X.useMemo)(()=>{let e=new Map;for(let t of nn){let n=AX(t);e.set(n,n);for(let r of kX(t))e.set(r,n)}return e},[nn]),Dn=(0,X.useMemo)(()=>[...be.uncommitted.comments.values()],[be.uncommitted.comments]),On=(0,X.useMemo)(()=>[...be.bundle_diff.comments.values()],[be.bundle_diff.comments]),kn=be[g],An=kn.activeTarget,jn=kn.editingCommentKey,Mn=An?.commentKey??jn,Nn=Mn?`${g}:${Mn}`:g,Pn=Mn?dt.current[g].get(Mn)??kn.draftInput:kn.draftInput,Fn=g===`bundle_diff`?On:Dn,In=(0,X.useMemo)(()=>[...Dn,...On],[On,Dn]),Ln=(0,X.useMemo)(()=>Se?.findings??[],[Se]),Rn=(0,X.useMemo)(()=>Se?.is_current_diff?Ln.filter(e=>Ae.has(e.id)):[],[Ln,Se?.is_current_diff,Ae]),zn=(0,X.useMemo)(()=>[...Ae],[Ae]),Bn=(0,X.useMemo)(()=>we.filter(e=>Ne.has(e.id)),[we,Ne]),Vn=(0,X.useMemo)(()=>[...Ne],[Ne]),Hn=In.length+Rn.length+Bn.length,Un=!!(Se?.review_run&&Ln.length>0&&!Se.is_current_diff),Wn=Le?.bundle.pull_request??null,Gn=(0,X.useMemo)(()=>Ze.length>0?Ze:Le?.recent_commit_subjects??[],[Le?.recent_commit_subjects,Ze]),Kn=Le?.has_helper_model===!0,qn=d!==`project_root`&&!!n&&!!t,Jn=g===`bundle_diff`?P:M,Yn=V&&v===null,Xn=te&&b===null,Zn=ne&&S===null,Qn=Be&&Le===null,$n=g===`bundle_diff`?Xn:Yn,er=g===`uncommitted`?Ln:CX,tr=g===`uncommitted`?zn:TX,nr=g===`bundle_diff`?we:wX,rr=g===`bundle_diff`?Vn:TX,ir=g===`bundle_diff`?`bundle_diff`:`uncommitted`,ar=(0,X.useMemo)(()=>{let e=new Map,t=e=>e?En.get(e)??e:null;for(let n of Fn){let r=t(n.filePath);r&&WX(e,r)}if(g===`uncommitted`){if(Un)return e;for(let n of Ln){let r=t(n.file_path);r&&WX(e,r)}return e}for(let n of we){let r=t(n.file_path);r&&WX(e,r)}return e},[g,En,Fn,we,Un,Ln]),or=(Un?0:Ln.length)+Dn.length,sr=we.length+On.length,cr=g===`bundle_diff`?`No branch diff to show.`:`No uncommitted changes to show.`,lr=g===`uncommitted`&&qn?`Switch to Branch diff to review the full branch diff.`:null,ur=qn&&!Qn&&!!Le&&Le?.bundle.kind!==`project_root`&&S?.has_upstream===!0&&f,dr=ur&&!Wn&&!Qe&&!et&&!nt&&!Fe&&!de&&!oe&&!fe&&(S?.ahead??0)===0&&!!S?.branch,fr=(0,X.useCallback)(e=>{if(!e){We(!1);return}if(!t||!n||!ur||Wn||et){We(e);return}tt(!0),Et(t,n).then(e=>{ze(e),Xe(t=>t.trim()?t:e.bundle.pull_request?.base_branch??``),We(!e.bundle.pull_request)}).catch(e=>{Q.error(PX(e,`Unable to check for an existing pull request right now.`),{id:`ticket-changes-sync-pr-error`}),We(!0)}).finally(()=>{tt(!1)})},[Wn,et,t,n,ur]),pr=(0,X.useMemo)(()=>{if(ur)return(S?.ahead??0)>0?`Push the branch before creating a pull request.`:S?.branch?u:`Bundle branch information is not available right now.`},[u,S?.ahead,S?.branch,ur]),mr=c&&!$n&&(g===`bundle_diff`||!Zn)&&!oe&&!de&&!fe,hr=An?mr||kn.comments.has(An.commentKey):mr,gr=!!a&&o&&Hn>0&&!Fe,_r=(0,X.useCallback)(e=>{Me(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),vr=(0,X.useCallback)(e=>{Pe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),yr=(0,X.useCallback)(()=>{dt.current=zX(),xe(e=>({uncommitted:{...e.uncommitted,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map},bundle_diff:{...e.bundle_diff,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map}}))},[]),br=(0,X.useCallback)(()=>{yr(),Me(new Set),Pe(new Set)},[yr]),xr=(0,X.useCallback)(async()=>{if(!(!t||!n||!dr)){$e(!0);try{let e=await wt(t,n,{title:Ge.trim(),body:qe.trim(),base_branch:Ye.trim()||null});ze(e),Xe(e.bundle.pull_request?.base_branch??Ye.trim()),We(!1),Q.success(`Pull request created.`,{id:`ticket-changes-create-pr-success`})}catch(e){Q.error(PX(e,`Unable to create the pull request right now.`),{id:`ticket-changes-create-pr-error`})}finally{$e(!1)}}},[dr,t,Ye,qe,Ge,n]),Sr=(0,X.useCallback)(async()=>{if(!(!t||!n||!ur||nt)){rt(!0);try{Je((await kt({title:Ge.trim(),commit_subjects:Gn})).description)}catch(e){Q.error(PX(e,`Unable to generate the pull request description right now.`),{id:`ticket-changes-generate-pr-description-error`})}finally{rt(!1)}}},[nt,t,Gn,Ge,kt,n,ur]),Cr=(0,X.useCallback)(({filePath:e,changeKey:t,commentKey:n})=>{let r=kn.comments.get(n),i=dt.current[g].get(n)??r?.comment??``;if(r){k(r.filePath),Ot(g,e=>({...e,activeTarget:null,editingCommentKey:n,draftInput:i}));return}mr&&Ot(g,r=>({...r,activeTarget:{filePath:e,changeKey:t,commentKey:n},editingCommentKey:null,draftInput:i}))},[g,kn.comments,mr,Ot]),wr=(0,X.useCallback)(()=>{Mn&&dt.current[g].delete(Mn),Ot(g,e=>({...e,activeTarget:null,editingCommentKey:null,draftInput:``}))},[g,Mn,Ot]),Tr=(0,X.useCallback)(e=>{Mn&&dt.current[g].set(Mn,e)},[g,Mn]),Er=(0,X.useCallback)((e,t)=>{let n=kn.comments.has(e.commentKey);if(!mr&&!n)return;let r=t.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;Ot(g,t=>{let n=new Map(t.comments);return n.set(e.commentKey,{scope:g,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:SS(e.hunk,e.change),comment:r}),{...t,activeTarget:null,editingCommentKey:null,draftInput:``,comments:n}}),dt.current[g].delete(e.commentKey)},[g,kn.comments,mr,Ot]),Dr=(0,X.useCallback)(e=>{let t=kn.comments.get(e);if(!t)return;k(t.filePath);let n=dt.current[g].get(e)??t.comment;Ot(g,t=>({...t,activeTarget:null,editingCommentKey:e,draftInput:n}))},[g,kn.comments,Ot]),Or=(0,X.useCallback)(e=>{dt.current[g].delete(e),Ot(g,t=>{let n=new Map(t.comments);return n.delete(e),{...t,activeTarget:t.activeTarget?.commentKey===e?null:t.activeTarget,editingCommentKey:t.editingCommentKey===e?null:t.editingCommentKey,draftInput:t.activeTarget?.commentKey===e||t.editingCommentKey===e?``:t.draftInput,comments:n}})},[g,Ot]),kr=(0,X.useCallback)(async()=>{if(!a||!gr)return;Ie(!0);let e=jS({drafts:In,findings:Rn,githubComments:Bn,uncommittedFiles:Wt,bundleFiles:Gt});try{await a(e),yr(),Me(new Set),Pe(new Set),Ce(e=>e&&{...e,findings:[],is_current_diff:!1}),Q.success(`Fixes submitted.`,{id:`ticket-diff-review-submit-success`}),i()}catch(e){Q.error(PX(e,`Unable to submit the review right now.`),{id:`ticket-diff-review-submit-error`})}finally{Ie(!1)}},[In,Gt,gr,yr,i,a,Bn,Rn,Wt]),Ar=(0,X.useCallback)(()=>{if(g===`bundle_diff`){Vt();return}Ht(()=>!0,{allowCache:!1,resetSelection:!at.current})},[g,Vt,Ht]),jr=(0,X.useMemo)(()=>a?(0,Z.jsx)(Zq,{reviewComments:In,reviewFindings:Rn,githubComments:Bn,pendingFixCount:Hn,canSendReview:gr,isSubmittingReview:Fe,reviewSubmitDisabledReason:s,onClearPendingFixes:br,onSubmitReview:()=>{kr()}}):null,[In,gr,br,kr,Fe,a,Hn,s,Bn,Rn]),Mr=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Nr=()=>{S&&D(fn?new Set:EX(S.files))},Pr=async()=>{if(mn){ce(!0);try{let e=await At({message:A.trim(),selected_paths:[...E]});e.ticket&&m?.(e.ticket),zt(e.git_status,{resetSelection:!0}),j(``),d===`project_root`&&lY(t),p&&h?.(p),await Bt({preserveContent:!0,gitStatusForCache:e.git_status}),await Vt({preserveContent:!0}),(e.git_status.ahead??0)>0?await Lt(()=>!0):Rt(),Q.success(`Commit created.`,{id:`ticket-git-commit-success`})}catch(e){Q.error(PX(e,`Unable to create the commit right now.`),{id:`ticket-git-commit-error`})}finally{ce(!1)}}},Fr=async()=>{if(hn){ue(!0);try{j((await Pt({selected_paths:[...E]})).message),it.current?.focus()}catch(e){Q.error(PX(e,`Unable to generate a commit message right now.`),{id:`ticket-git-commit-message-error`})}finally{ue(!1)}}},Ir=async()=>{if(_n){W(!0);try{let e=w.map(e=>e.subject.trim()).filter(Boolean),r=await Ft();if(r.ticket&&m?.(r.ticket),zt(r.git_status,{resetSelection:!0}),gt(r.git_status),Y(e),Rt(),d===`project_root`&&lY(t),p&&h?.(p),Q.success(r.git_status.ahead===0?`Branch pushed.`:`Push completed.`,{id:`ticket-git-push-success`}),r.git_status.ahead===0)if(d!==`project_root`&&t&&n)try{let r=await St(t,n);ze(r),Ke(e=>e.trim()?e:Ud(r.bundle)),Je(t=>t.trim()?t:GX(e)),Xe(e=>e.trim()?e:r.bundle.pull_request?.base_branch??``)}catch{}else i()}catch(e){Q.error(PX(e,`Unable to push the branch right now.`),{id:`ticket-git-push-error`})}finally{W(!1)}}},Lr=async()=>{if(vn){pe(!0);try{let e=await It();e.ticket&&m?.(e.ticket),zt(e.git_status,{resetSelection:!0}),T(e.commits),B(null),ae(!1),d===`project_root`&&lY(t),p&&h?.(p),await Bt({preserveContent:!0,gitStatusForCache:e.git_status}),await Vt({preserveContent:!0}),Q.success(`Latest local commit undone.`,{id:`ticket-git-undo-success`})}catch(e){Q.error(PX(e,`Unable to undo the latest local commit right now.`),{id:`ticket-git-undo-error`})}finally{pe(!1)}}};return(0,Z.jsx)(Af,{onClose:i,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-[92vh] w-full max-w-none flex-col overflow-hidden rounded-2xl border border-border bg-card p-6 shadow-2xl`,renderContent:({closeButton:e})=>(0,Z.jsxs)(Z.Fragment,{children:[de&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-2xl bg-black/45 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-border bg-card/95 px-4 py-3 text-sm text-foreground shadow-xl`,children:[(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}),(0,Z.jsx)(`span`,{children:`Pushing branch...`})]})}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Changes`}),xn?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`h2`,{className:`max-w-full truncate font-mono text-lg font-semibold text-foreground`,children:xn}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(q,{variant:(S?.ahead??0)>0?`info`:`outline`,children:yn}),(0,Z.jsx)(q,{variant:(S?.behind??0)>0?`warning`:`outline`,children:bn}),(0,Z.jsx)(q,{variant:S?.is_dirty?`warning`:`success`,children:S?.is_dirty?`Dirty`:`Clean`})]})]}):(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-7 w-56 animate-pulse rounded-md bg-muted/70`,"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-6 w-32 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 text-xs text-muted-foreground`,children:[(Wn||ur)&&(0,Z.jsx)(KX,{pullRequest:Wn,isLoading:Qn,isOpen:Ue,canCreate:dr,disabledReason:pr,isCreating:Qe,isSyncing:et,isGeneratingDescription:nt,title:Ge,body:qe,baseBranch:Ye,onOpenChange:fr,onTitleChange:Ke,onBodyChange:Je,onBaseBranchChange:Xe,showGenerateDescription:Kn,onGenerateDescription:()=>{Sr()},onCreate:()=>{xr()}}),(0,Z.jsx)($q,{isCommitsLoading:ie,commitsError:z,unpushedCommits:w,canUndoLatestCommit:vn,isUndoing:fe,aheadCount:S?.ahead??0,onUndoLatestCommit:()=>{Lr()}}),gn&&(0,Z.jsxs)(J,{type:`button`,size:`sm`,variant:`default`,onClick:()=>{Ir()},disabled:!_n,title:u,className:`gap-2`,children:[de?(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Xu,{className:`h-4 w-4`}),de?`Pushing...`:`Push branch`]}),e]})]}),(0,Z.jsxs)(`div`,{"data-testid":`ticket-changes-layout`,className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[18rem_minmax(0,1fr)] xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`flex min-h-0 flex-col`,children:[qn&&(0,Z.jsxs)(Wq,{type:`single`,size:`sm`,variant:`outline`,value:g,onValueChange:e=>{(e===`uncommitted`||e===`bundle_diff`)&&_(e)},className:`mb-3 self-start`,children:[(0,Z.jsxs)(Gq,{value:`uncommitted`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:`Uncommitted`}),or>0&&(0,Z.jsx)(`span`,{className:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`,children:or})]}),(0,Z.jsxs)(Gq,{value:`bundle_diff`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:`Branch diff`}),sr>0&&(0,Z.jsx)(`span`,{className:`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`,children:sr})]})]}),(0,Z.jsx)(YJ,{selectionWarning:g===`uncommitted`?pn:null,gitError:g===`uncommitted`?I:P,sidebarFiles:ln,commentCountByPath:ar,commentCountTone:ir,isGitStatusLoading:g===`bundle_diff`?Xn:Zn&&ln.length===0,selectedPaths:E,selectedDiffPath:O,allFilesSelected:fn,diffStats:tn?.stats??null,title:g===`bundle_diff`?`Branch diff files`:`Changed files`,allChangesDescription:g===`bundle_diff`?`Review the full branch diff against the review base.`:`Review the full workspace diff.`,enableSelection:g===`uncommitted`&&!Zn,onToggleSelectAll:Nr,onSelectDiffPath:k,onTogglePath:Mr})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,Z.jsx)(WJ,{selectedDiffPath:O,sidebarFiles:ln,diffResponse:tn,isDiffLoading:$n,diffError:Jn,allDiffFiles:Tn,renderedFiles:wn,viewType:me,onViewTypeChange:G,onRetry:Ar,activeReviewTarget:An,editingReviewCommentKey:jn,reviewDraftInstanceKey:Nn,reviewDraftInput:Pn,reviewComments:Fn,reviewFindings:er,githubComments:nr,selectedReviewFindingIds:tr,selectedGitHubCommentIds:rr,canSelectReviewTarget:mr,canEditActiveReviewDraft:hr,reviewFindingsError:g===`uncommitted`?Te:null,gitHubCommentsError:g===`bundle_diff`?De:null,hasStaleReviewFindings:g===`uncommitted`?Un:!1,onSelectReviewTarget:Cr,onToggleReviewFindingSelection:_r,onToggleGitHubCommentSelection:vr,onReviewDraftInputChange:Tr,onCancelReviewDraft:wr,onEditReviewDraft:Dr,onRemoveReviewDraft:Or,onSaveReviewDraft:Er,diffThemeClassName:XJ,resolveFilePath:AX,normalizeDiffPath:OX,onVisibleFilePathsChange:cn,emptyStateTitle:cr,emptyStateDescription:lr,reviewSummaryControl:jr,headerLayout:`inline-controls`}),g===`uncommitted`&&(0,Z.jsx)(`div`,{className:`mt-auto shrink-0`,children:(0,Z.jsx)(Qq,{commitMessage:A,onCommitMessageChange:j,commitMessageRef:it,selectedFileCount:un,changesDisabledReason:u,canEditCommitMessage:l&&!Fe,canGenerateCommitMessage:hn,canCommit:mn,isGeneratingCommitMessage:le,isCommitting:oe,onGenerateCommitMessage:()=>{Fr()},onCommit:()=>{Pr()}})})]})]})]})]})})},YX={blocked:{className:`stroke-red-400/80`,markerId:`dependency-arrowhead-blocked`},ready:{className:`stroke-emerald-400/80`,markerId:`dependency-arrowhead-ready`},preview:{className:`stroke-amber-300/80`,markerId:`dependency-arrowhead-preview`}},XX=e=>lD(e)?`ready`:`blocked`,ZX=180,QX=560,$X=88,eZ=12,tZ=18,nZ=(e,t,n)=>Math.min(Math.max(e,t),n),rZ=(e,t,n)=>n&&n.width>0&&n.height>0?n:Object.values(e).reduce((e,t)=>({width:Math.max(e.width,t.left+t.width),height:Math.max(e.height,t.top+t.height)}),{width:t.x,height:t.y}),iZ=(e,t)=>{let n=nZ(Math.round(e.length*7.2)+24,ZX,QX),r=Math.max(ZX,t-eZ*2);return Math.min(n,r)},aZ=(e,t,n,r,i)=>{let a=n.get(e.blockerTicketId);if(!a)return null;let o=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?r[e.hoveredTicketId]:null,s=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?n.get(e.hoveredTicketId):null,c=s?`${a.title} is blocking ${s.title}`:`${a.title} is blocking...`,{start:l,end:u}=_D(t,o??{left:e.pointer.x,top:e.pointer.y,width:0,height:0}),d=rZ(r,e.pointer,i),f=o&&s?{x:l.x+(u.x-l.x)*.6,y:l.y+(u.y-l.y)*.6-28}:{x:u.x,y:u.y-28},p=iZ(c,d.width);return{text:c,x:o&&s?nZ(f.x-p/2,eZ,Math.max(eZ,d.width-p-eZ)):(()=>{let e=f.x+tZ,t=f.x-tZ-p;return e+p<=d.width-eZ?e:t>=eZ?t:nZ(e,eZ,Math.max(eZ,d.width-p-eZ))})(),y:nZ(f.y,eZ,Math.max(eZ,d.height-$X-eZ)),width:p}},oZ=({blockerRect:e,dependentRect:t,className:n,testId:r,markerEnd:i})=>{let{start:a,end:o}=_D(e,t),{path:s}=vD(a,o);return(0,Z.jsx)(`g`,{"data-testid":r,children:(0,Z.jsx)(`path`,{d:s,className:n,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,markerEnd:i})})},sZ=({preview:e,cardRects:t,ticketsById:n,overlaySize:r})=>{if(!e)return null;let i=t[e.blockerTicketId];if(!i)return null;let a=(e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId&&t[e.hoveredTicketId]?t[e.hoveredTicketId]:null)??{left:e.pointer.x,top:e.pointer.y,width:0,height:0},o=aZ(e,i,n,t,r);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(oZ,{blockerRect:i,dependentRect:a,className:YX.preview.className,testId:`dependency-preview`,markerEnd:`url(#${YX.preview.markerId})`}),(e=>o?(0,Z.jsx)(`foreignObject`,{x:o.x,y:o.y,width:o.width,height:$X,"data-testid":`dependency-preview-label`,children:e}):null)((0,Z.jsx)(`div`,{className:`pointer-events-none flex h-full w-full items-start`,children:(0,Z.jsx)(`div`,{className:`max-w-full rounded-md border border-amber-300/60 bg-stone-950/85 px-3 py-1.5 text-xs font-medium leading-5 text-amber-100 shadow-lg shadow-stone-950/20 whitespace-normal break-words`,children:o?.text})}))]})},cZ=({dependencies:e,cardRects:t,preview:n,ticketsById:r,overlaySize:i})=>(0,Z.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 z-10 h-full w-full overflow-visible`,children:[(0,Z.jsx)(`defs`,{children:Object.values(YX).map(e=>(0,Z.jsx)(`marker`,{id:e.markerId,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`4`,orient:`auto`,markerUnits:`userSpaceOnUse`,children:(0,Z.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8`,className:e.className,fill:`none`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`})},e.markerId))}),e.map(e=>{let n=r.get(e.blocker_ticket_id),i=r.get(e.dependent_ticket_id),a=t[e.blocker_ticket_id],o=t[e.dependent_ticket_id];if(n?.parked_at||i?.parked_at)return null;let s=YX[XX(n)];return!a||!o?null:(0,Z.jsx)(oZ,{blockerRect:a,dependentRect:o,className:s.className,testId:`dependency-edge-${e.blocker_ticket_id}-${e.dependent_ticket_id}`,markerEnd:`url(#${s.markerId})`},`${e.blocker_ticket_id}:${e.dependent_ticket_id}`)}),(0,Z.jsx)(sZ,{preview:n,cardRects:t,ticketsById:r,overlaySize:i})]}),lZ=({onSubmit:e,bundles:t,projectId:n=null,projectBranchState:r=null,tool:i,showModelSelector:a=!1,availableModels:o=[],availableSkills:s=[],initialModel:c=``,initialVariant:l=``,initialSkills:u=[],initialWorktreeBundleId:d=null,onCreateBundle:f,onDeleteBundle:p,onRefreshBundles:m,onClose:h})=>{let{t:g}=ht(`common`),{jiraImportState:_,importFromJira:v}=Nm(n);return(0,Z.jsx)(Af,{onClose:h,overlayClassName:`bg-black/60`,panelClassName:`h-[92vh] w-[96vw] max-w-6xl overflow-y-auto rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,renderContent:({closeButton:y})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`absolute right-4 top-4 z-10 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:y}),(0,Z.jsx)(fI,{heading:g(`newTicketModal.heading`),bundles:t,showModelSelector:a,availableModels:o,availableSkills:s,projectId:n,initialModel:c,initialVariant:l,initialSkills:u,initialWorktreeBundleId:d,projectBranchState:r,jiraImportState:_,onImportFromJira:v,onCancel:h,onCreateBundle:f,onDeleteBundle:p,onRefreshBundles:m,titleInputId:`title`,descriptionInputId:`description`,bundleSelectId:`new-ticket-bundle`,modelSelectId:`new-model`,variantSelectId:`new-variant`,skillsSelectId:`new-skills`,showEmptyBundleOption:!0,planAction:i?{label:g(`newTicketModal.actions.plan`),onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`plan`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),h()}}:void 0,primaryAction:{label:g(`newTicketModal.actions.createTicket`),variant:`subtle`,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`create`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),h()}},secondaryAction:{label:g(`newTicketModal.actions.createAndBuild`),variant:`brand`,showAdvanceIcon:!0,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`build`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),h()}}})]})})},uZ=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},dZ=e=>e.status===`error`?`border-red-500/35 bg-red-500/10`:e.status===`done`?e.boardState===`fading`?`border-emerald-500/25 bg-emerald-500/10 opacity-0 transition-opacity duration-700`:`border-emerald-500/35 bg-emerald-500/10`:`border-violet-500/30 bg-card/60`,fZ=({run:e})=>(0,Z.jsxs)(Nf,{"data-testid":`planning-run-card-${e.id}`,className:`relative overflow-hidden rounded-xl border shadow-none ${dZ(e)}`,children:[e.status===`running`&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 top-0 h-1 animate-pulse bg-gradient-to-r from-violet-500/0 via-violet-300/80 to-violet-500/0`}),(0,Z.jsxs)(Rf,{className:`space-y-3 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[e.status===`running`?(0,Z.jsx)(xD,{label:`Planning...`}):e.status===`done`?(0,Z.jsx)(xD,{label:`Done`,className:`bg-emerald-500/85 text-emerald-50`}):(0,Z.jsx)(xD,{label:`Planning failed`,className:`bg-red-500/85 text-red-50`}),(0,Z.jsx)(`span`,{className:`text-[11px] uppercase tracking-[0.16em] text-muted-foreground`,children:uZ(e.submittedAt)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),e.status===`done`&&e.summary&&(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Created `,e.summary.ticketCount,` tickets, `,e.summary.dependencyCount,` dependencies`,e.summary.ticketsWithOpenQuestions>0?`, ${e.summary.ticketsWithOpenQuestions} open question${e.summary.ticketsWithOpenQuestions===1?``:`s`}`:``]}),e.status===`error`&&e.error&&(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-red-200`,children:e.error})]})]})]}),pZ={idle:`bg-secondary`,running:`bg-sky-400`,done:`bg-emerald-400`,error:`bg-red-400`},mZ=e=>e.some(e=>e.status===`running`)?`running`:e.some(e=>e.status===`error`)?`error`:e.some(e=>e.status===`done`)?`done`:`idle`,hZ=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},gZ=({status:e})=>{let{t}=ht(`common`);return e===`running`?(0,Z.jsx)(xD,{label:t(`planningAgentSidebar.runStatus.planning`),className:`px-2.5 py-0.5 text-[11px]`}):e===`done`?(0,Z.jsx)(q,{className:`bg-emerald-500/85 px-2.5 py-0.5 text-[11px] text-emerald-50`,children:t(`planningAgentSidebar.runStatus.done`)}):(0,Z.jsx)(q,{className:`bg-red-500/85 px-2.5 py-0.5 text-[11px] text-red-50`,children:t(`planningAgentSidebar.runStatus.failed`)})},_Z=({heading:e,runs:t})=>{let{t:n}=ht(`common`);return t.length===0?null:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,Z.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:t.map(e=>(0,Z.jsx)(Nf,{className:`rounded-2xl border-border bg-card/70 shadow-none`,children:(0,Z.jsxs)(Rf,{className:`space-y-2 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),(0,Z.jsx)(gZ,{status:e.status})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:hZ(e.submittedAt)}),e.summary&&(0,Z.jsxs)(`span`,{children:[n(`planningAgentSidebar.runSummary.tickets`,{count:e.summary.ticketCount}),`, `,n(`planningAgentSidebar.runSummary.dependencies`,{count:e.summary.dependencyCount}),e.summary.ticketsWithOpenQuestions>0?`, ${n(`planningAgentSidebar.runSummary.openQuestions`,{count:e.summary.ticketsWithOpenQuestions})}`:``]})]}),e.error&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-red-500/30 bg-destructive/15 px-3 py-2 text-xs text-red-200`,children:e.error})]})},e.id))})]})},vZ=({projectId:e=null,state:t,bundles:n,showModelSelector:r,availableModels:i,availableSkills:a,onManageBundles:o,onToggle:s,onDescriptionChange:c,onModelChange:l,onVariantChange:u,onSkillsChange:d,onBundleChange:f,onGenerate:p})=>{let{t:m}=ht(`common`),h=i.find(e=>e.id===t.composer.model)??null,{jiraImportState:g,importFromJira:_}=Nm(t.isOpen?e:null),v=(0,X.useRef)(null),y=(0,X.useRef)(t.isOpen),b=(0,X.useRef)(t.isOpen),x=mZ(t.runs),S=t.runs.filter(e=>e.status===`running`),C=t.runs.filter(e=>e.status!==`running`),w=t.composer.description.trim().length>0,T=m(`planningAgentSidebar.actions.planTickets`);(0,X.useEffect)(()=>{if(t.isOpen&&!y.current&&(b.current=!0),t.isOpen||(b.current=!1),y.current=t.isOpen,!t.isOpen||!b.current)return;let e=window.requestAnimationFrame(()=>{let e=document.activeElement,t=e instanceof HTMLElement&&e.closest(`[data-testid="planning-agent-rail"]`)!==null;if(e instanceof HTMLElement&&e!==document.body&&e!==v.current&&!t){b.current=!1;return}v.current?.focus({preventScroll:!0}),b.current=!1});return()=>{window.cancelAnimationFrame(e)}},[t.isOpen]),(0,X.useEffect)(()=>{if(!t.isOpen)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),s())};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[s,t.isOpen]);let E=(0,Z.jsxs)(J,{type:`button`,"aria-label":t.isOpen?m(`planningAgentSidebar.actions.closeAriaLabel`):m(`planningAgentSidebar.actions.openAriaLabel`),"aria-pressed":t.isOpen,onClick:s,variant:`outline`,className:`relative flex h-14 w-11 flex-col items-center justify-center gap-1 p-0`,children:[(0,Z.jsx)(lm,{className:`size-5`}),(0,Z.jsx)(DE,{"aria-hidden":`true`,children:`A`}),(0,Z.jsx)(`span`,{className:`absolute top-1 right-1 h-2.5 w-2.5 rounded-full ring-2 ring-card ${pZ[x]}`})]});return(0,Z.jsxs)(`aside`,{"aria-label":m(`planningAgentSidebar.ariaLabel`),className:`relative z-20 h-full w-16 shrink-0 overflow-visible border-r border-border bg-background`,children:[(0,Z.jsx)(`div`,{"data-testid":`planning-agent-rail`,className:`relative z-40 flex h-full w-16 shrink-0 flex-col items-center border-r border-border bg-background py-4`,children:t.isOpen?E:(0,Z.jsx)(Lu,{content:m(`planningAgentSidebar.tooltip`),children:E})}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-drawer`,"aria-hidden":!t.isOpen,inert:!t.isOpen||void 0,className:W(`absolute inset-y-0 left-16 z-30 w-[min(36rem,calc(100vw-5rem))] overflow-hidden transition-transform duration-200 ease-out motion-reduce:transition-none`,t.isOpen?`pointer-events-auto translate-x-0`:`pointer-events-none -translate-x-full`),children:(0,Z.jsxs)(`div`,{className:`flex h-full w-[min(36rem,calc(100vw-5rem))] flex-col border-r border-border bg-background`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-border px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:m(`planningAgentSidebar.title`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:m(`planningAgentSidebar.description`)})]}),(0,Z.jsx)(J,{type:`button`,"aria-label":m(`planningAgentSidebar.actions.closePanelAriaLabel`),onClick:s,variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(Fe,{className:`h-4 w-4`})})]}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-scroll-body`,className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsxs)(`div`,{className:`space-y-5 px-6 py-5`,children:[(0,Z.jsx)(cI,{jiraImportState:g,onImportFromJira:_,onImported:e=>{c(e.description)},inputId:`planning-agent-jira-import`}),(0,Z.jsx)(Bf,{label:m(`planningAgentSidebar.descriptionLabel`),htmlFor:`planning-agent-description`,className:`gap-2`,children:(0,Z.jsx)(`div`,{className:`relative`,children:(0,Z.jsx)(hg,{ref:v,projectId:e,suggestionAnchor:`caret`,id:`planning-agent-description`,"aria-label":m(`planningAgentSidebar.descriptionAriaLabel`),value:t.composer.description,onValueChange:c,rows:14,className:`min-h-[18rem] resize-y text-sm leading-6`,placeholder:m(`planningAgentSidebar.descriptionPlaceholder`)})})}),(0,Z.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(lI,{bundles:n,value:t.composer.worktreeBundleId,onChange:f,selectId:`planning-agent-bundle`,emptyLabel:m(`planningAgentSidebar.autoCreateBundle`),hideProjectRootBundles:!0,label:``})}),o&&(0,Z.jsx)(J,{type:`button`,onClick:o,variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap border-sky-500/30 bg-sky-500/10 text-sky-200 hover:border-sky-400 hover:bg-sky-500/20 hover:text-sky-100`,children:m(`planningAgentSidebar.actions.manageBundles`)})]}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:(0,Z.jsx)(aI,{model:t.composer.model,variant:t.composer.variant,skills:t.composer.skills,showModelSelector:r,showSkillsSelector:r,availableModels:i,availableSkills:a,selectedModel:h,onModelChange:l,onVariantChange:u,onSkillsChange:d,modelSelectId:`planning-agent-model`,variantSelectId:`planning-agent-variant`,skillsSelectId:`planning-agent-skills`,layout:`stacked`})}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-runs`,className:`border-t border-border/80 px-0 pt-5`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(_Z,{heading:m(`planningAgentSidebar.activeRuns`),runs:S}),(0,Z.jsx)(_Z,{heading:m(`planningAgentSidebar.recentRuns`),runs:C})]})})]})}),(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-border px-6 py-4`,children:(0,Z.jsx)(J,{type:`button`,onClick:p,disabled:!w,className:`w-full`,children:T})})]})})]})},yZ=({className:e=``})=>{let{setNodeRef:t,isOver:n}=mE({id:`trash`});return(0,Z.jsxs)(`div`,{ref:t,"data-testid":`delete-drop-zone`,className:`${e} flex min-w-[13rem] select-none items-center justify-between gap-4 rounded-2xl border px-4 py-3 backdrop-blur-sm transition-all duration-150 ${n?`scale-[1.02] border-red-400/70 bg-destructive/35 text-red-100 shadow-lg shadow-red-950/30`:`border-red-500/30 bg-background/82 text-red-200/85`}`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(q,{variant:`destructive`,className:`text-[11px] uppercase tracking-[0.28em]`,children:`Delete`}),(0,Z.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:n?`Release to delete`:`Drop here to delete`})]}),(0,Z.jsx)(`div`,{className:`rounded-xl border p-2 transition-colors ${n?`border-red-400/60 bg-red-500/20`:`border-red-500/20 bg-background/60`}`,children:(0,Z.jsx)(Vf,{className:`h-5 w-5 transition-colors ${n?`text-red-100`:`text-red-300/70`}`})})]})},bZ=(e,t)=>x(N(`/ticket-dependencies`,e),{signal:t}),xZ=(e,t)=>x(N(`/ticket-dependencies`,e),{method:`POST`,body:t,fallbackErrorMessage:`Unable to create the dependency right now.`}),SZ=(e,t,n)=>_(N(`/ticket-dependencies/${t}/${n}`,e),{method:`DELETE`,fallbackErrorMessage:`Unable to remove the dependency right now.`}),CZ=(e,t)=>{let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.left!==i.left||n.top!==i.top||n.width!==i.width||n.height!==i.height)return!1}return!0},wZ=(e,t)=>e===t?!0:!e||!t?!1:e.projectId===t.projectId&&e.blockerTicketId===t.blockerTicketId&&e.hoveredTicketId===t.hoveredTicketId&&e.pointer.x===t.pointer.x&&e.pointer.y===t.pointer.y,TZ=({activeProjectId:e,tickets:t,dependencies:n,setDependencies:r,activeTicket:i,activeOverlayNode:a,dragOffset:o})=>{let[s,c]=(0,X.useState)({}),[l,u]=(0,X.useState)({width:0,height:0}),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),h=(0,X.useRef)(null),g=(0,X.useRef)(null),_=(0,X.useRef)(null),v=(0,X.useRef)(new Map),y=(0,X.useRef)({}),b=(0,X.useRef)(null),x=(0,X.useRef)(null),S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useRef)(null),T=(0,X.useRef)(null),E=(0,X.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);(0,X.useEffect)(()=>{C.current=p},[p]),(0,X.useLayoutEffect)(()=>{if(!i||!a||!g.current)return;let e=window.requestAnimationFrame(()=>{let e=g.current?.getBoundingClientRect(),t=a.getBoundingClientRect();e&&f({ticketId:i.id,rect:{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}})});return()=>{window.cancelAnimationFrame(e)}},[a,i,o.x,o.y]);let D=(0,X.useCallback)(()=>{b.current===null&&(b.current=window.requestAnimationFrame(()=>{b.current=null;let e=g.current;if(!e){_.current=null,y.current={},c({}),u({width:0,height:0});return}let t=e.getBoundingClientRect(),n={};_.current={left:t.left,top:t.top},u(e=>e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height});for(let[e,r]of v.current){let i=r.getBoundingClientRect();n[e]={left:i.left-t.left,top:i.top-t.top,width:i.width,height:i.height}}y.current=n,c(e=>CZ(e,n)?e:n)}))},[]);(0,X.useEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{D()};return e.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[D]),(0,X.useEffect)(()=>{if(typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(()=>{D()});x.current=e;for(let t of v.current.values())e.observe(t);return()=>{e.disconnect(),x.current===e&&(x.current=null)}},[D]),(0,X.useEffect)(()=>{let e=h.current,t=g.current;if(!e&&!t)return;let n=new ResizeObserver(()=>{D()});return e&&n.observe(e),t&&t!==e&&n.observe(t),()=>{n.disconnect()}},[D]),(0,X.useEffect)(()=>(D(),()=>{b.current!==null&&(window.cancelAnimationFrame(b.current),b.current=null)}),[n,D,t]);let O=(0,X.useCallback)((e,t)=>{let n=v.current.get(e);if(t){if(n===t)return;v.current.set(e,t),x.current?.observe(t)}else{if(!n)return;v.current.delete(e),x.current?.unobserve(n)}D()},[D]),k=(0,X.useCallback)(e=>{wZ(C.current,e)||(C.current=e,m(e))},[]),A=(0,X.useCallback)(()=>{w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null),T.current=null},[]),j=(0,X.useCallback)(e=>{T.current=e,w.current===null&&(w.current=window.requestAnimationFrame(()=>{w.current=null;let e=T.current;T.current=null,k(e)}))},[k]),M=(0,X.useCallback)((e,t)=>{let n=_.current;if(!n&&g.current){let e=g.current.getBoundingClientRect();n={left:e.left,top:e.top},_.current=n}return n?{x:e-n.left,y:t-n.top}:{x:e,y:t}},[]),N=(0,X.useCallback)((e,t,n)=>{for(let[r,i]of Object.entries(y.current))if(r!==n&&e>=i.left&&e<=i.left+i.width&&t>=i.top&&t<=i.top+i.height)return r;return null},[]),P=(0,X.useCallback)(async t=>{if(e)try{await SZ(e,t.blocker_ticket_id,t.dependent_ticket_id),r(e=>aD(e,t.blocker_ticket_id,t.dependent_ticket_id))}catch(e){Q.error(e instanceof we?e.message:`Unable to remove the dependency right now.`,{id:`board-dependency-error`})}},[e,r]),F=(0,X.useCallback)((t,i)=>{if(!e)return;i.preventDefault(),S.current?.();let a=(n,r,i=!1)=>{let a=M(n,r),o={projectId:e,blockerTicketId:t,hoveredTicketId:N(a.x,a.y,t),pointer:a};if(i){A(),k(o);return}j(o)};a(i.clientX,i.clientY,!0);let o=e=>{a(e.clientX,e.clientY)},s=async i=>{let a=M(i.clientX,i.clientY),o=N(a.x,a.y,t),s=o?sD(n,t,o):null;if(S.current?.(),S.current=null,k(null),!(!o||!s)){if(!s.valid){Q.error(cD(s.reason),{id:`board-dependency-error`});return}try{let n=await xZ(e,{blocker_ticket_id:t,dependent_ticket_id:o});r(e=>iD(e,n))}catch(e){Q.error(e instanceof we?e.message:`Unable to create the dependency right now.`,{id:`board-dependency-error`})}}};S.current=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),A()},window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s,{once:!0})},[e,A,n,N,M,j,r,k]);(0,X.useEffect)(()=>{S.current?.(),S.current=null,A(),C.current=null},[e,A]),(0,X.useEffect)(()=>()=>{S.current?.(),w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null)},[]);let I=(0,X.useMemo)(()=>{let r=p?.blockerTicketId;if(!r||p.projectId!==e||!E.has(r))return null;let i=new Map;for(let e of t){if(e.id===r){i.set(e.id,`source`);continue}let t=sD(n,r,e.id);i.set(e.id,t.valid?`valid`:`idle`)}return i},[e,n,p,E,t]),L=(0,X.useCallback)(e=>{if(!I||!p)return`idle`;let t=I.get(e)??`idle`;return e===p.hoveredTicketId&&t===`idle`?`invalid`:t},[I,p]),R=(0,X.useMemo)(()=>!p||p.projectId!==e||!E.has(p.blockerTicketId)?null:{blockerTicketId:p.blockerTicketId,hoveredTicketId:p.hoveredTicketId,pointer:p.pointer},[e,p,E]);return{boardViewportRef:h,boardContentRef:g,registerTicketNode:O,measuredCardRects:(0,X.useMemo)(()=>{if(!i)return s;let e=s[i.id];return e?d?.ticketId===i.id?{...s,[i.id]:d.rect}:{...s,[i.id]:{...e,left:e.left+o.x,top:e.top+o.y}}:s},[d,i,s,o.x,o.y]),overlayPreview:R,overlaySize:l,getDependencyTargetState:L,handleDependencyStart:F,handleDeleteDependency:P}},EZ=e=>{if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.id==`string`?t.id:``,r=typeof t.name==`string`?t.name:``,i=typeof t.command==`string`?t.command:``,a=typeof t.cwd==`string`?t.cwd:``,o=t.runner===`vitest`||t.runner===`jest`||t.runner===`unknown`?t.runner:`auto`;return n.trim()===``||r.trim()===``&&i.trim()===``&&a.trim()===``?[]:[{id:n,name:r,command:i,cwd:a,runner:o}]}):[]}catch{return[]}},DZ=`[data-terminal-pane="true"]`,OZ=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||e.isContentEditable},kZ=e=>e instanceof HTMLElement?e.closest(DZ)!==null:!1,AZ=e=>OZ(e)||kZ(e),jZ=(e,t={})=>{let{isBlocked:n}=t;(0,X.useEffect)(()=>{let t=t=>{if(t.defaultPrevented||t.repeat)return;let r=e.find(e=>!e.disabled&&e.key.toLowerCase()===t.key.toLowerCase()&&(e.ctrlKey??!1)===t.ctrlKey&&(e.altKey??!1)===t.altKey&&(e.metaKey??!1)===t.metaKey&&(e.shiftKey===void 0||e.shiftKey===t.shiftKey));r&&(n?.(document.activeElement)||(t.preventDefault(),r.onKeyDown()))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,n])},MZ=e=>({...e,messages:void 0,agent_log:void 0,streaming_response:void 0}),NZ=(e,t)=>e?e.state!==t.state||e.parked_at!==t.parked_at||e.worktree_bundle_id!==t.worktree_bundle_id:!0,PZ=(e,t)=>{if(!e)return t;let n=t.worktree_bundle_id!==null&&e.worktree_bundle_id===t.worktree_bundle_id,r=t.bundle??(n&&e.bundle?.id===t.worktree_bundle_id?e.bundle:null),i=t.bundle_execution_position??(n?e.bundle_execution_position??null:null);return{...e,...t,bundle:r,bundle_execution_position:i}},FZ=(e,t)=>{let n=e=>WE(t)?WE(e):e.state===t.state&&!WE(e),r=e.findIndex(e=>n(e));if(r===-1)return[...e,t];let i=[...e];return i.splice(r,0,t),i},IZ=(e,t)=>{let n=e.find(e=>e.id===t.id);return[n&&n.pull_request!==void 0&&t.pull_request===void 0?{...n,...t,pull_request:n.pull_request}:t,...e.filter(e=>e.id!==t.id)]},LZ=(e,t)=>{let n=e.find(e=>e.id===t.id);if(!n)return[...e,t];let r=PZ(n,t);return e.map(e=>e.id===t.id?r:e)},RZ=(e,t)=>{let n=PZ(e.find(e=>e.id===t.id),t);return FZ(BZ(e,t.id),n)},zZ=(e,t)=>{if(e.length===0)return[...t];let n=[...e];for(let e of t)n=NZ(n.find(t=>t.id===e.id),e)?RZ(n,e):LZ(n,e);let r=new Set(t.map(e=>e.id));return n.filter(e=>r.has(e.id))},BZ=(e,t)=>e.filter(e=>e.id!==t),VZ=(e,t,n,r={},i={})=>{let a=e.findIndex(e=>e.id===t);if(a===-1)return e;let o={...e[a],state:n,...r},s=BZ(e,t);if(i.preferredIndex!==void 0){let e=Math.max(0,Math.min(i.preferredIndex,s.length));return s.splice(e,0,o),s}return FZ(s,o)},HZ=async(e,t)=>{`Notification`in window&&Notification.permission!==`denied`&&(Notification.permission===`default`&&await Notification.requestPermission(),Notification.permission===`granted`&&new Notification(e,{body:t}))},UZ=(0,X.createContext)(XK),WZ=()=>(0,X.useContext)(UZ),GZ=(0,X.createContext)(null),KZ=15*1e3,qZ=1e3,JZ=async e=>HZ(`Ticket done`,e),YZ=e=>MZ(e),XZ=(e,t)=>t===`running`&&e.agent_status===`done`?`Finished ${e.state} for "${e.title}"`:t===`running`&&e.agent_status===`error`?`Failed ${e.state} for "${e.title}"`:t!==`running`&&e.agent_status===`running`?`Running ${e.state} for "${e.title}"`:null,ZZ=({activeProjectId:e,refreshKey:t=0,onLoadedProjectIdChange:n,onProjectUsageChange:r,onBundlesChange:i,onBundlesLoadingChange:a,children:o})=>{let s=WZ(),[c,l]=(0,X.useState)([]),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)([]),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(null),w=(0,X.useRef)(0),T=(0,X.useRef)(0),E=(0,X.useRef)(new Map),D=(0,X.useRef)(new Map),O=(0,X.useRef)(e),A=(0,X.useRef)(new Map),j=(0,X.useRef)(new Map),M=(0,X.useRef)(new Map),N=(0,X.useCallback)((e,t)=>{let n=j.current.get(t.id);return!n||!e||t.state===n?t:e},[]),P=(0,X.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(j.current);for(let r of e)n.set(r,t);j.current=n},[]),F=(0,X.useCallback)(e=>{if(e.length===0||j.current.size===0)return;let t=new Map(j.current);for(let n of e)t.delete(n);j.current=t},[]),I=(0,X.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(M.current);for(let r of e)n.set(r,t);M.current=n},[]),L=(0,X.useCallback)(e=>{if(e.length===0||M.current.size===0)return;let t=new Map(M.current);for(let n of e)t.delete(n);M.current=t},[]),R=(0,X.useCallback)((e,t)=>{if(A.current.has(t.id))return null;let n=N(e,t);return M.current.has(t.id)?{...n,parked_at:M.current.get(t.id)??null}:n},[N]),z=(0,X.useCallback)((e,t)=>{if(A.current.size===0&&j.current.size===0&&M.current.size===0)return t;let n=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>{let t=R(n.get(e.id),e);return t?[t]:[]})},[R]),B=(0,X.useCallback)(async(e,t)=>{let n=await Vt(e,t,{detail:`board`});return Array.isArray(n)?(!t?.aborted&&O.current===e&&l(e=>zZ(e,z(e,n).map(YZ))),n):null},[z]),V=(0,X.useCallback)(async(e,t)=>{await B(e,t)},[B]),ee=(0,X.useCallback)(async(e,t)=>{let n=++T.current,r=await Ht(e,t);if(!Array.isArray(r)||t?.aborted||O.current!==e||T.current!==n)return;let i=new Map(r.map(e=>[e.id,e]));l(e=>e.map(e=>{let t=i.get(e.id);return t?{...e,diff_stats:t.diff_stats??null,is_stale:t.is_stale}:e}))},[]),te=(0,X.useCallback)(e=>e.some(e=>e.is_stale===void 0),[]),H=(0,X.useCallback)(async e=>{let t=O.current;if(!t)return null;try{let n=await Ut(e,t);if(O.current!==t)return null;let r=D.current.get(n.id),i=R(r,n);if(!i)return null;let a=YZ(i),o=NZ(r,a);return l(e=>o?RZ(e,a):LZ(e,a)),n}catch{return null}},[R]),ne=(0,X.useCallback)(async t=>{if(!e){p([]);return}p(await bt(e,t))},[e]),U=(0,X.useMemo)(()=>new Map(c.map(e=>[e.id,e])),[c]),re=(0,X.useMemo)(()=>{let e=c.filter(e=>e.agent_status===`running`),t=new Set(e.map(e=>e.worktree_bundle_id).filter(e=>typeof e==`string`&&e.trim().length>0));return{total_running:e.length,running_plan_count:e.filter(e=>e.state===`plan`).length,running_build_count:e.filter(e=>e.state===`build`).length,running_review_count:e.filter(e=>e.state===`review`).length,active_bundle_count:t.size,latest_message:S}},[S,c]);(0,X.useEffect)(()=>{D.current=U},[U]),(0,X.useEffect)(()=>{O.current=e,A.current.clear(),j.current.clear(),M.current.clear(),C(null),h(null),E.current.clear()},[e]),(0,X.useEffect)(()=>{n?.(v?null:g)},[g,v,n]),(0,X.useEffect)(()=>{if(i){if(!e){i(null,[]);return}if(g!==e){i(e,[]);return}i(e,f)}},[e,f,g,i]),(0,X.useEffect)(()=>{if(a){if(!e){a(null,!1);return}a(e,b===e)}},[e,b,a]),(0,X.useEffect)(()=>{let t=new AbortController,n=++w.current,r=null,i=async()=>{try{if(!e){l([]),d([]),p([]),_(null),y(null);return}l([]),d([]),p([]),_(null),y(e),x(e);let[n,i,a]=await Promise.allSettled([B(e,t.signal),bZ(e,t.signal),bt(e,t.signal)]);if(t.signal.aborted)return;n.status!==`fulfilled`&&!k(n.reason)&&l([]),i.status===`fulfilled`?d(i.value):k(i.reason)||d([]),a.status===`fulfilled`?p(a.value):k(a.reason)||p([]),_(n.status===`fulfilled`&&i.status===`fulfilled`&&a.status===`fulfilled`?e:null),n.status===`fulfilled`&&n.value!==null&&te(n.value)&&(r=window.setTimeout(()=>{t.signal.aborted||ee(e,t.signal)},qZ))}finally{!t.signal.aborted&&w.current===n&&(y(null),x(null))}},a=t=>{t.project_id===e&&(h(t),!A.current.has(t.id)&&(t.bundle&&p(e=>IZ(e,t.bundle)),l(e=>RZ(e,YZ(t)))))},o=t=>{if(t.project_id===e&&h(t),l(n=>{if(t.project_id!==e)return BZ(n,t.id);let r=n.find(e=>e.id===t.id),i=R(r,t);if(!i)return n;let a=YZ(i);return NZ(r,a)?RZ(n,a):LZ(n,a)}),t.project_id!==e){d(e=>rD(e,t.id));return}t.bundle&&p(e=>IZ(e,t.bundle))},c=({id:e})=>{A.current.delete(e),M.current.delete(e),j.current.delete(e),l(t=>BZ(t,e)),d(t=>rD(t,e))},u=e=>{if(!e)return;let t=D.current.get(e.blocker_ticket_id),n=D.current.get(e.dependent_ticket_id);!t||!n||t.project_id!==O.current||n.project_id!==O.current||d(t=>iD(t,e))},f=e=>{d(t=>aD(t,e.blocker_ticket_id,e.dependent_ticket_id))};return i(),s.on(`ticket:created`,a),s.on(`ticket:updated`,o),s.on(`ticket:deleted`,c),s.on(`ticket-dependency:created`,u),s.on(`ticket-dependency:deleted`,f),()=>{t.abort(),r!==null&&window.clearTimeout(r),s.off(`ticket:created`,a),s.off(`ticket:updated`,o),s.off(`ticket:deleted`,c),s.off(`ticket-dependency:created`,u),s.off(`ticket-dependency:deleted`,f)}},[e,ee,t,te,B,R,s]),(0,X.useEffect)(()=>{if(!e)return;let t=new AbortController,n=()=>{document.visibilityState===`visible`&&Promise.allSettled([B(e,t.signal),ne(t.signal)]).then(n=>{n[0]?.status===`fulfilled`&&n[0].value!==null&&te(n[0].value)&&ee(e,t.signal)}).catch(()=>{})},r=window.setInterval(n,KZ),i=fY(n);return()=>{t.abort(),window.clearInterval(r),i()}},[e,ne,ee,te,B]),(0,X.useEffect)(()=>{if(!e||!r||g!==e)return;let t=c.filter(e=>{let t=e.bundle?.branch??e.branch;return typeof t==`string`&&t.trim()!==``}).length;r({projectId:e,ticketCount:c.length,worktreeCount:t,repoPathLocked:c.length>0||t>0||f.length>0})},[e,f.length,g,r,c]),(0,X.useEffect)(()=>{for(let e of c){let t=E.current.get(e.id),n=XZ(e,t);n&&C(n),t!==void 0&&t===`running`&&e.agent_status===`done`&&(e.state===`plan`||e.state===`build`||e.state===`review`)&&JZ(e.title),E.current.set(e.id,e.agent_status)}},[c]);let ie=(0,X.useCallback)(()=>{h(null)},[]),ae=(0,X.useMemo)(()=>({tickets:c,setTickets:l,dependencies:u,setDependencies:d,bundles:f,setBundles:p,latestDetailedTicketUpdate:m,clearLatestDetailedTicketUpdate:ie,loadedProjectId:g,loadingProjectId:v,activeProjectIdRef:O,pendingDeletedTicketsRef:A,pendingOptimisticMovesRef:j,pendingParkedTicketsRef:M,refreshTickets:V,requestSingleTicketRefresh:H,refreshBundles:ne,resolvePendingTicket:R,resolvePendingTickets:z,markPendingOptimisticMoves:P,clearPendingOptimisticMoves:F,markPendingParkedTickets:I,clearPendingParkedTickets:L,liveActivity:re}),[f,ie,F,L,u,re,g,m,v,P,I,ne,V,H,R,z,c]);return(0,Z.jsx)(GZ.Provider,{value:ae,children:o})},QZ=()=>{let e=(0,X.useContext)(GZ);if(!e)throw Error(`useProjectWorkspace must be used inside ProjectWorkspaceProvider`);return e},$Z=(0,X.lazy)(()=>cq(()=>import(`./TestsDialog-BPHhOIWL.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),eQ=`archon.last-model-selection`,tQ=`archon.last-variant-selection`,nQ=`archon.last-skills-selection`,rQ=()=>{try{let e=window.localStorage.getItem(nQ),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}},iQ=e=>[e.title,e.description,e.bundle?.name??``,e.bundle?.branch??``,e.branch??``].map(e=>e.toLowerCase()),aQ=(e,t)=>{let n=e.bundle_execution_position??2**53-1,r=t.bundle_execution_position??2**53-1;if(n!==r)return n-r;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let i=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return i===0?e.id.localeCompare(t.id):i},oQ=(e,t)=>t?{...e,...t,messages:t.messages===void 0?e.messages:t.messages,agent_log:t.agent_log===void 0?e.agent_log:t.agent_log,streaming_response:t.streaming_response===void 0?e.streaming_response:t.streaming_response}:e,sQ=(e,t)=>{let n=e.toLowerCase().trim().split(/\s+/).filter(Boolean);if(n.length===0)return!0;let r=iQ(t);return n.every(e=>r.some(t=>t.includes(e)))},cQ=[`plan`,`build`,`review`],lQ=`done`,uQ=()=>({build:!1,stopBuild:!1,resumeBuild:!1,review:!1,undoReview:!1,run:!1,stop:!1,followUp:!1,bundleRefresh:!1}),dQ=({bundleId:e,activeRunContextKey:t,isProjectRootRunActive:n})=>n?!0:t!==null&&t!==e,fQ=(e,t)=>{if(!e)return null;let n=t.find(t=>t.id===e.ticket_id);return n?HE(n):e.ticket_id},pQ=()=>({description:``,model:window.localStorage.getItem(eQ)??``,variant:window.localStorage.getItem(tQ)??``,skills:rQ(),worktreeBundleId:``}),mQ=()=>({isOpen:!1,composer:pQ(),runs:[]}),hQ=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`planning-run-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,gQ=e=>({ticketCount:e.tickets.length,dependencyCount:e.dependencies.length,ticketsWithOpenQuestions:e.tickets.filter(e=>(e.planning_context?.open_questions.length??0)>0).length,ticketTitles:e.tickets.map(e=>e.title),ticketIds:e.tickets.map(e=>e.id)}),_Q=(e,t,n)=>e.map(e=>e.id===t?n(e):e),vQ=(e,t,n)=>{e?window.localStorage.setItem(eQ,e):window.localStorage.removeItem(eQ),t?window.localStorage.setItem(tQ,t):window.localStorage.removeItem(tQ),n.length>0?window.localStorage.setItem(nQ,JSON.stringify(n)):window.localStorage.removeItem(nQ)},yQ=(e,t={})=>Ld(e,t),bQ=()=>({model:window.localStorage.getItem(eQ)??``,variant:window.localStorage.getItem(tQ)??``,skills:rQ()}),xQ=(e,t)=>{let n=BZ(e,t.ticket.id),r=Math.max(0,Math.min(t.index,n.length));return n.splice(r,0,t.ticket),n},SQ=e=>e.tickets.length>0&&e.tickets.every(e=>ZE(e,`trash`)),CQ=e=>e.tickets.length>0&&e.tickets.every(e=>ZE(e,lQ)),wQ=e=>e.column===lQ&&e.tickets.length>0&&e.tickets.every(e=>e.state!==`plan`),TQ=(e,t,n,r)=>n||t!==null&&t!==HE(e)?r:dD(e),EQ=(e,t)=>t===`build`?{agent_status:null,agent_log:null,streaming_response:null,build_completed_at:null,planning_context:e.planning_context?{...e.planning_context,open_questions:[]}:null}:t===`review`?{agent_status:null,agent_log:null,streaming_response:null}:{},DQ=(e,t)=>e===`plan`&&t===`build`?`build`:e===`build`&&t===`review`?`review`:e===`review`&&t===`build`?`undoReview`:null,OQ=(e,t,n)=>t===`review`&&n===`build`?{}:EQ(e,n),kQ=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:a,onRunStopped:o,onRunStatusChange:s,refreshKey:c=0})=>{let{t:l}=ht(`common`),u=sw(ow(lT,{activationConstraint:{distance:5}})),{tickets:d,setTickets:f,dependencies:p,setDependencies:m,bundles:h,setBundles:g,latestDetailedTicketUpdate:_,clearLatestDetailedTicketUpdate:v,loadedProjectId:y,loadingProjectId:b,activeProjectIdRef:x,pendingDeletedTicketsRef:S,requestSingleTicketRefresh:C,refreshBundles:w,resolvePendingTicket:T,markPendingOptimisticMoves:E,clearPendingOptimisticMoves:D,markPendingParkedTickets:O,clearPendingParkedTickets:A}=QZ(),[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),[F,I]=(0,X.useState)(null),[L,R]=(0,X.useState)({x:0,y:0}),[z,B]=(0,X.useState)(null),[V,ee]=(0,X.useState)(!1),[te,H]=(0,X.useState)([]),[ne,U]=(0,X.useState)([]),[re,ie]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)({}),[se,ce]=(0,X.useState)(!1),[le,ue]=(0,X.useState)(!1),[de,fe]=(0,X.useState)(null),[pe,me]=(0,X.useState)(null),[G,he]=(0,X.useState)(null),[ge,_e]=(0,X.useState)(null),[ve,ye]=(0,X.useState)(null),[be,xe]=(0,X.useState)(null),[Se,Ce]=(0,X.useState)(null),[K,Te]=(0,X.useState)(null),[Ee,De]=(0,X.useState)(null),[Oe,ke]=(0,X.useState)(null),[je,Me]=(0,X.useState)(!1),[Ne,Pe]=(0,X.useState)(uQ()),[Ie,Le]=(0,X.useState)(0),[Re,q]=(0,X.useState)(``),[ze,Be]=(0,X.useState)(!1),Ve=i===`opencode`||G?.tool===`opencode`||!!be?.tickets.some(e=>e.tool===`opencode`),He=i===`opencode`&&te.length>0,Ue=G?.tool===`opencode`&&te.length>0,We=!!be?.tickets.some(e=>e.tool===`opencode`)&&te.length>0,Ge=(0,X.useRef)(e),Ke=(0,X.useRef)(null),qe=(0,X.useRef)(null),[Je,Ye]=(0,X.useState)(null),Xe=d.find(e=>e.is_running)??null,Ze=Xe?HE(Xe):null,Y=r?.context_key??null,Qe=r?.kind===`ticket`?fQ(r,d)??Ze:Ze,$e=r?.kind===`project`,et=Qe??Je,tt=(0,X.useCallback)(e=>dQ({bundleId:e,activeRunContextKey:et,isProjectRootRunActive:$e}),[et,$e]),nt=j!==null&&ZE(j,`trash`)||N!==null&&SQ(N),rt=b===e,it=(0,X.useMemo)(()=>EZ(t?.test_commands??null),[t?.test_commands]),at=(0,X.useCallback)(async e=>HZ(l(`board.notifications.planningDoneTitle`),l(`board.notifications.planningDoneBody`,{count:e})),[l]),ot=it.length>0,st=(0,X.useMemo)(()=>new Map(d.map(e=>[e.id,e])),[d]);(0,X.useEffect)(()=>{Ye(null)},[e]),(0,X.useEffect)(()=>{Je!==null&&($e||Qe!==null)&&Ye(null)},[Qe,$e,Je]),(0,X.useEffect)(()=>{if(!pe){he(null);return}let e=st.get(pe)??null;e&&he(t=>!t||t.id!==pe?e:oQ(t,e))},[pe,st]),(0,X.useEffect)(()=>{_&&(he(e=>!e||e.id!==_.id?e:oQ(e,_)),xe(e=>{if(!e)return e;let t=_.worktree_bundle_id;if(!t||e.bundle.id!==t)return e;let n=e.tickets.some(e=>e.id===_.id)?e.tickets.map(e=>e.id===_.id?oQ(e,_):e):[...e.tickets,_];return{...e,tickets:n}}))},[_]),(0,X.useEffect)(()=>{_===null||pe!==null||ge!==null||v()},[v,_,ge,pe]);let ct=(0,X.useCallback)(async e=>{let t=await C(e);if(!t)return null;let n=st.get(e),r=n?oQ(t,n):t;return he(t=>t&&t.id!==e||pe&&pe!==e?t:r),r},[C,pe,st]),lt=(0,X.useCallback)(e=>{he(e),me(e.id),ct(e.id)},[ct]),ut=(0,X.useMemo)(()=>new Map(h.map(e=>[e.id,e])),[h]),dt=(0,X.useMemo)(()=>{if(!be)return null;let e=be.bundle.id,t=_?.worktree_bundle_id===e?_:null,n=d.filter(t=>t.worktree_bundle_id===e),r=new Map(n.map(e=>[e.id,e])),i=be.tickets.filter(e=>!S.current.has(e.id)).map(e=>t&&e.id===t.id?oQ(e,t):e);t&&!i.some(e=>e.id===t.id)&&!S.current.has(t.id)&&i.push(t);let a=i.map(e=>oQ(e,r.get(e.id)));for(let e of n)a.some(t=>t.id===e.id)||a.push(e);a.sort(aQ);let o=be.execution_order_ticket_ids??[],s=a.map(e=>e.id),c=[...o,...s].filter((e,t,n)=>s.includes(e)&&n.indexOf(e)===t),l=n.some(e=>e.can_re_review!==void 0||e.has_completed_review!==void 0||e.has_follow_up_since_last_review!==void 0),u=n.some(e=>e.agent_status===`running`),f={has_completed_review:n.some(e=>e.has_completed_review===!0),has_follow_up_since_last_review:n.some(e=>e.has_follow_up_since_last_review===!0),can_re_review:!u&&n.some(e=>e.can_re_review===!0)},p=Pd(a),m=a.find(e=>e.id===be.review_owner_ticket_id&&e.state===`review`)??a.find(e=>e.state===`review`)??null,h=Ld(a,{targetTicketId:be.target_ticket_id,reviewOwnerTicketId:m?.id??be.review_owner_ticket_id,latestSessionTicketId:p?.id??be.latest_session_ticket_id});return{...be,bundle:ut.get(e)??be.bundle,tickets:a,execution_order_ticket_ids:c,latest_session_ticket_id:p?.id??null,latest_session_id:p?.session_id??null,review_owner_ticket_id:m?.id??null,target_ticket_id:h?.id??null,has_completed_review:l?f.has_completed_review:be.has_completed_review,has_follow_up_since_last_review:l?f.has_follow_up_since_last_review:be.has_follow_up_since_last_review,can_re_review:l?f.can_re_review:be.can_re_review}},[ut,_,S,be,d]),ft=(0,X.useMemo)(()=>d.filter(e=>ze&&KE(e)?!1:sQ(Re,e)),[ze,Re,d]),pt=(0,X.useMemo)(()=>ft.filter(e=>WE(e)),[ft]),mt=(0,X.useMemo)(()=>Rd(pt,h,lQ),[h,pt]),{boardViewportRef:gt,boardContentRef:_t,registerTicketNode:vt,measuredCardRects:yt,overlayPreview:bt,overlaySize:wt,getDependencyTargetState:Tt,handleDependencyStart:Et,handleDeleteDependency:jt}=TZ({activeProjectId:e,tickets:d,dependencies:p,setDependencies:m,activeTicket:j,activeOverlayNode:F,dragOffset:L}),Mt=e?ae[e]??mQ():mQ(),Nt=Mt.composer.worktreeBundleId&&h.some(e=>e.id===Mt.composer.worktreeBundleId)?Mt.composer.worktreeBundleId:``,Lt=Nt===Mt.composer.worktreeBundleId?Mt:{...Mt,composer:{...Mt.composer,worktreeBundleId:Nt}},Rt=bQ(),zt=!!t?.run_ide?.trim(),Bt=Lt.runs.filter(e=>e.boardVisible),Vt=(0,X.useCallback)((e,t,n=d)=>{let r=Rd(n,h,t).find(t=>t.kind===`bundle`&&t.group.bundle.id===e);return r?.kind===`bundle`?r.group:null},[h,d]),Ht=(0,X.useCallback)(e=>(0,Z.jsx)(vq,{ticket:e,allTickets:d,dependencies:p,bundles:h,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:e.tool===`opencode`&&te.length>0,availableModels:te,runDisabled:!0,hideBundleScopedControls:!0}),[t?.memory_enabled,te,h,p,d]),Ut=Bt.length>0?(0,Z.jsx)(`div`,{className:`mb-0.5 flex flex-col gap-2.5`,children:Bt.map(e=>(0,Z.jsx)(fZ,{run:e},e.id))}):null,Kt=(0,X.useCallback)(t=>Id(t)?t.project_id===e?zt:!!t.has_run_ide:!1,[zt,e]),Jt=(0,X.useCallback)(e=>!!e.project_id&&!!(e.bundle?.branch??e.branch)&&Id(e),[]),Yt=(0,X.useCallback)(e=>{let t=e?.tickets.find(t=>t.id===e.target_ticket_id)??e?.tickets.find(e=>e.has_worktree)??null;return t?Kt(t):!1},[Kt]),Xt=(0,X.useCallback)(e=>{let t=d.filter(t=>t.worktree_bundle_id===e).sort(aQ);return be?.bundle.id===e?yQ(be.tickets.map(e=>t.find(t=>t.id===e.id)??e).sort(aQ),{targetTicketId:be.target_ticket_id,reviewOwnerTicketId:be.review_owner_ticket_id,latestSessionTicketId:be.latest_session_ticket_id}):yQ(t)},[be,d]),Zt=(0,X.useCallback)((e,t)=>{oe(n=>({...n,[e]:t(n[e]??mQ())}))},[]);(0,X.useEffect)(()=>{ce(!1),ue(!1),Ce(null),ke(null),Ge.current!==e&&(Ke.current=e),e||(Ke.current=null,q(``)),Ge.current=e},[e,c]),(0,X.useLayoutEffect)(()=>{!e||y!==e||Ke.current===e&&(Ke.current=null,q(``))},[e,y]),(0,X.useEffect)(()=>{if(!Ve){U([]);return}let t=new AbortController;return(async()=>{try{H(await yn(`opencode`,t.signal))}catch(e){k(e)||H(e=>e)}})(),(async()=>{try{U(await OE(`opencode`,t.signal,e))}catch(e){k(e)||U([])}})(),()=>{t.abort()}},[e,Ve]);let Qt=({active:e})=>{ie(!1),I(null),R({x:0,y:0});let t=Bd(String(e.id));if(t){P(Vt(t.bundleId,t.column)),M(null);return}P(null),M(d.find(t=>t.id===e.id)??null)},$t=()=>{ie(!1),I(null),R({x:0,y:0}),M(null),P(null)},en=(0,X.useCallback)(e=>{f(t=>e.reduce((e,t)=>RZ(e,t),t))},[f]),bn=(0,X.useCallback)((e,t)=>{if(e.length===0)return;let n=e[0]?.state;n&&f(r=>e.reduce((e,r)=>VZ(e,r.id,t,OQ(r,n,t)),r))},[f]),xn=(0,X.useCallback)((e,t=d)=>!e.worktree_bundle_id||!e.project_id||e.state!==`build`?[]:t.filter(t=>t.project_id===e.project_id&&t.worktree_bundle_id===e.worktree_bundle_id&&t.state===`build`&&t.parked_at===null).sort(aQ),[d]),Sn=async({active:e,over:t})=>{let n=Bd(String(e.id)),r=d.find(t=>t.id===e.id),i=n?Vt(n.bundleId,n.column):null,a=t?.id===`trash`&&(r!==void 0&&ZE(r,`trash`)||i!==null&&SQ(i)),o=t?.id&&cQ.includes(t.id)?t.id:null;if(ie(a),I(null),R({x:0,y:0}),M(null),P(null),t){if(n){if(t.id===`trash`){if(!i||!SQ(i))return;await Pn(i);return}if(t.id===lQ){if(!i||!CQ(i))return;await jn(i);return}if(o){if(n.column===lQ){if(!i||!wQ(i))return;await Mn(i);return}await lr(n.bundleId,n.column,o)}return}if(t.id===`trash`){if(!r||!ZE(r,`trash`))return;Ln(e.id);return}if(t.id===lQ){if(!r||!ZE(r,lQ))return;await kn(e.id);return}if(o){if(r&&XE(r,o)){await An(e.id);return}if(!(!r||!ZE(r,o)))try{await Dn(r,o,{optimistic:!0})}catch(e){Q.error(e instanceof we?e.message:l(`board.errors.moveTicket`),{id:`board-move-error`})}}}},Cn=async(t,n,r,a,o,s,c)=>{let u=await Wt({title:t,description:n,tool:i,model:a,variant:o,skills:s,project_id:e,...c});if(vQ(a,o,s),f(e=>RZ(e,MZ(u))),u.bundle&&g(e=>IZ(e,u.bundle)),r===`build`)try{await Dn(u,`build`)}catch(e){Q.error(e instanceof we?e.message:l(`board.errors.moveTicket`),{id:`board-move-error`})}r===`plan`&&vn(u.id,u.project_id)},wn=async t=>{if(!e)throw Error(l(`board.errors.createBundleWithoutProject`));let n=await xt(e,{name:t,prepare:!0});return g(e=>IZ(e,n)),n},Tn=e=>{f(t=>[...e.tickets].reverse().reduce((e,t)=>RZ(e,MZ(t)),t)),m(t=>e.dependencies.reduce((e,t)=>iD(e,t),t));for(let t of e.tickets)t.bundle&&g(e=>IZ(e,t.bundle))},En=(0,X.useCallback)((e,t={})=>{let n=MZ(e);f(e=>t.reorderInState?RZ(e,n):LZ(e,n)),he(t=>!t||t.id!==e.id?t:oQ(e,n)),e.bundle&&g(t=>IZ(t,e.bundle))},[g,f]),Dn=async(e,t,n={})=>{let r=d.findIndex(t=>t.id===e.id),i=t===`review`?xn(e):[],a=t===`review`&&i.length>1,o=n.optimistic?a?i.map(e=>e.id):[e.id]:[];n.optimistic&&(E(o,t),a?bn(i,t):f(n=>VZ(n,e.id,t,EQ(e,t))));try{if(a&&e.project_id&&e.worktree_bundle_id){let t=await Ot(e.project_id,e.worktree_bundle_id);Qn(t);let n=t.tickets.find(t=>t.id===e.id);if(!n)throw Error(l(`board.errors.missingBundleReviewTicket`));return D(o),n}let n=await qt(e.id,e.project_id,t);return f(r=>{let i=r.find(t=>t.id===e.id);return i?.state===t&&n.state===t&&i.agent_status!==n.agent_status&&n.agent_status===e.agent_status?r:NZ(i,n)?RZ(r,n):LZ(r,n)}),n.bundle&&g(e=>IZ(e,n.bundle)),D(o),n}catch(t){throw n.optimistic&&(a?en(i):f(t=>VZ(t,e.id,e.state,{agent_status:e.agent_status,agent_log:e.agent_log,build_completed_at:e.build_completed_at},{preferredIndex:r})),D(o)),t}},On=(e,t)=>{f(n=>n.map(n=>n.id===e?{...n,...t}:n))},kn=async t=>{let n=d.find(e=>e.id===t);if(n)try{let r=new Date().toISOString();O([t],r),On(t,{parked_at:r}),En(await on(t,n.project_id??e),{reorderInState:!0}),A([t])}catch(e){A([t]),On(t,{parked_at:n.parked_at}),Q.error(e instanceof we?e.message:l(`board.errors.parkTicket`),{id:`board-park-error`})}},An=async t=>{let n=d.find(e=>e.id===t);if(n)try{O([t],null),On(t,{parked_at:null}),En(await sn(t,n.project_id??e),{reorderInState:!0}),A([t])}catch(e){A([t]),On(t,{parked_at:n.parked_at}),Q.error(e instanceof we?e.message:l(`board.errors.returnTicket`),{id:`board-unpark-error`})}},jn=(0,X.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at})),r=new Date().toISOString();O(e.tickets.map(e=>e.id),r),f(e=>e.map(e=>t.has(e.id)?{...e,parked_at:r}:e));let i=await Promise.allSettled(e.tickets.map(e=>on(e.id,e.project_id??x.current))),a=new Set;if(i.forEach((t,n)=>{if(t.status===`fulfilled`){A([t.value.id]),En(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&a.add(r.id)}),a.size===0)return;A([...a]),f(e=>e.map(e=>{if(!a.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let o=i.find(e=>e.status===`rejected`),s=a.size===e.tickets.length?o?.reason instanceof we?o.reason.message:l(`board.errors.moveBundleToDone`):l(`board.toasts.movedBundleToDonePartial`,{movedCount:e.tickets.length-a.size,totalCount:e.tickets.length});Q.error(s,{id:`board-bundle-park-error`})},[x,En,A,O,f,l]),Mn=(0,X.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at}));O(e.tickets.map(e=>e.id),null),f(e=>e.map(e=>t.has(e.id)?{...e,parked_at:null}:e));let r=await Promise.allSettled(e.tickets.map(e=>sn(e.id,e.project_id??x.current))),i=new Set;if(r.forEach((t,n)=>{if(t.status===`fulfilled`){A([t.value.id]),En(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&i.add(r.id)}),i.size===0)return;A([...i]),f(e=>e.map(e=>{if(!i.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let a=r.find(e=>e.status===`rejected`),o=i.size===e.tickets.length?a?.reason instanceof we?a.reason.message:l(`board.errors.restoreBundle`):l(`board.toasts.restoredBundlePartial`,{restoredCount:e.tickets.length-i.size,totalCount:e.tickets.length});Q.error(o,{id:`board-bundle-unpark-error`})},[x,En,A,O,f,l]),Nn=async t=>{e&&(await It(e,t),g(e=>e.filter(e=>e.id!==t)))},Pn=(0,X.useCallback)(async t=>{let n=t.tickets.map(e=>({ticket:e,index:d.findIndex(t=>t.id===e.id)})).filter(e=>e.index!==-1);if(n.length===0)return;for(let e of n)S.current.set(e.ticket.id,e);let r=new Set(n.map(e=>e.ticket.id));f(e=>e.filter(e=>!r.has(e.id))),m(e=>e.filter(e=>!r.has(e.blocker_ticket_id)&&!r.has(e.dependent_ticket_id)));let i=await Promise.allSettled(n.map(async t=>(await rn(t.ticket.id,t.ticket.project_id??e),S.current.delete(t.ticket.id),t.ticket.id)));t.tickets.some(e=>e.project_id===x.current)&&w().catch(()=>{});let a=n.filter((e,t)=>i[t]?.status===`rejected`);if(a.length===0)return;for(let e of a)S.current.delete(e.ticket.id);a.some(e=>e.ticket.project_id===x.current)&&f(e=>[...a].sort((e,t)=>e.index-t.index).reduce((e,t)=>xQ(e,t),e));let o=i.find(e=>e.status===`rejected`),s=a.length===n.length?o?.reason instanceof we?o.reason.message:l(`board.errors.deleteBundleTickets`):l(`board.toasts.deletedBundleTicketsPartial`,{deletedCount:n.length-a.length,totalCount:n.length});Q.error(s,{id:`board-delete-bundle-wrapper-error`})},[e,x,S,w,m,f,d,l]),Fn=e=>{let t=st.get(e.id);En(e,{reorderInState:t?t.state!==e.state||t.parked_at!==e.parked_at||t.worktree_bundle_id!==e.worktree_bundle_id:!1}),t?.worktree_bundle_id&&t.worktree_bundle_id!==e.worktree_bundle_id&&t.bundle?.ticket_count===1&&g(e=>e.filter(e=>e.id!==t.worktree_bundle_id)),(t?.worktree_bundle_id!==e.worktree_bundle_id||t?.bundle?.ticket_count!==e.bundle?.ticket_count)&&e.project_id===x.current&&w().catch(()=>{})},In=async()=>{if(!e)return;let t=e,n=Mt.composer.description.trim();if(!n)return;let r=hQ(),a=He?Mt.composer.model.trim():``,o=He&&a?Mt.composer.variant.trim():``,s=He?Mt.composer.skills:[],c=Date.now();Zt(t,e=>({...e,isOpen:!1,composer:{...e.composer,description:``,worktreeBundleId:``},runs:[{id:r,description:n,model:a,variant:o,skills:s,worktreeBundleId:Nt,status:`running`,error:null,submittedAt:c,completedAt:null,boardVisible:!0,boardState:`visible`,summary:null},...e.runs]}));try{let e=await Gt({description:n,tool:i,model:a||null,variant:a&&o||null,skills:s,project_id:t,worktree_bundle_id:Nt||null});vQ(a||null,a&&o||null,s);let c=gQ(e);Zt(t,e=>({...e,runs:_Q(e.runs,r,e=>({...e,status:`done`,error:null,completedAt:Date.now(),summary:c,boardVisible:!1}))})),Q.success(l(`board.toasts.planningAgentCardsCreated`,{count:c.ticketCount}),{id:`planning-agent-success-${r}`}),at(e.tickets.length),x.current===t&&Tn(e)}catch(e){let n=e instanceof we?e.message:l(`board.errors.generateTickets`);Zt(t,e=>({...e,runs:_Q(e.runs,r,e=>({...e,status:`error`,error:n,completedAt:Date.now()}))})),Q.error(n,{id:`planning-agent-error`})}},Ln=async t=>{let n=d.find(e=>e.id===t),r=d.findIndex(e=>e.id===t);if(!(!n||r===-1)){S.current.set(t,{ticket:n,index:r}),f(e=>BZ(e,t)),m(e=>rD(e,t));try{await rn(t,n.project_id??e),n.project_id===x.current&&w().catch(()=>{}),S.current.delete(t)}catch(e){let n=S.current.get(t);S.current.delete(t),n&&n.ticket.project_id===x.current&&(f(e=>xQ(e,n)),Q.error(e instanceof we?e.message:l(`board.errors.deleteTicket`),{id:`board-delete-error`}))}}},Rn=async t=>{let n=d.find(e=>e.id===t);if(!n)return;let r=n.state===`review`?`review`:`build`;try{if(fe(r),n.project_id&&n.worktree_bundle_id&&n.state===`review`){Qn(await kt(n.project_id,n.worktree_bundle_id));return}En(await an(t,n.project_id??e),{reorderInState:!0})}catch(e){throw Q.error(e instanceof we?e.message:l(`board.errors.undoTicket`),{id:`board-undo-error`}),e}finally{fe(e=>e===r?null:e)}},zn=t=>{ln(t,d.find(e=>e.id===t)?.project_id??e)},Bn=async t=>{let n=d.find(e=>e.id===t),r=n?HE(n):t;try{Ye(r),await un(t,n?.project_id??e),s?.()}catch(e){Ye(e=>e===r?null:e),Q.error(e instanceof we?e.message:l(`board.errors.startRun`),{id:`board-run-error`})}},Vn=(0,X.useCallback)(async t=>{let n=d.find(e=>e.id===t);try{await dn(t,n?.project_id??e)}catch(e){Q.error(e instanceof we?e.message:l(`board.errors.openIde`),{id:`board-open-ide-error`})}},[e,l,d]),Hn=async t=>{let n=d.find(e=>e.id===t),i=r?.kind===`ticket`&&n&&Qe===HE(n)?Y:null;try{await fn(t,n?.project_id??e),o?.(i),s?.()}catch{}},Un=t=>{pn(t,d.find(e=>e.id===t)?.project_id??e).then(()=>{f(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e))})},Wn=t=>{mn(t,d.find(e=>e.id===t)?.project_id??e).then(()=>{f(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e))})},Gn=(0,X.useCallback)(e=>{let t=Xt(e);!t||!Kt(t)||Vn(t.id)},[Kt,Xt,Vn]),Kn=(0,X.useCallback)(e=>{let t=Xt(e);t&&De({bundleId:e,ticketId:t.id,projectId:t.project_id,title:t.bundle?Ud(t.bundle):t.title})},[Xt]),qn=(0,X.useCallback)(e=>{if(!ot)return;let t=Xt(e);!t?.project_id||!Id(t)||ke(e)},[Xt,ot]),Jn=(0,X.useCallback)(e=>{let t=d.find(t=>t.id===e);!t||!Jt(t)||Te({ticketId:t.id,projectId:t.project_id,title:t.title})},[Jt,d]),Yn=(0,X.useCallback)(e=>{if(!ot)return;let t=d.find(t=>t.id===e);!t?.project_id||!Id(t)||Ce({ticketId:t.id,projectId:t.project_id})},[ot,d]),Xn=(0,X.useCallback)(async(t,n)=>{let r=d.find(e=>e.id===t);if(r)try{En(r.state===`plan`?await _n(t,r.project_id??e,n):await hn(t,r.project_id??e,n))}catch(e){throw Q.error(e instanceof we?e.message:l(`board.errors.sendFollowUp`),{id:`board-follow-up-error`}),e}},[e,En,l,d]),Zn=(0,X.useCallback)(e=>{f(t=>e.reduce((e,t)=>{let n=e.find(e=>e.id===t.id),r=T(n,t);if(!r)return e;let i=MZ(n&&n.state===r.state&&n.agent_status===`running`&&r.agent_status===null?{...r,agent_status:n.agent_status,session_id:n.session_id,is_running:n.is_running}:r);return NZ(n,i)?RZ(e,i):LZ(e,i)},t))},[T,f]),Qn=(0,X.useCallback)(e=>{xe(e),g(t=>IZ(t,e.bundle)),Zn(e.tickets)},[Zn,g]),$n=(0,X.useCallback)((e,t)=>{Array.isArray(t.tickets)&&xe(n=>!n||n.bundle.id!==e?n:{...n,tickets:t.tickets,execution_order_ticket_ids:t.execution_order_ticket_ids,latest_session_ticket_id:t.latest_session_ticket_id,latest_session_id:t.latest_session_id,review_owner_ticket_id:t.review_owner_ticket_id,target_ticket_id:t.target_ticket_id})},[]),er=(0,X.useCallback)(async e=>{let t=x.current;if(!t)return null;let n=await St(t,e);return x.current===t?(Qn(n),n):null},[x,Qn]),tr=(0,X.useCallback)(async e=>{let t=x.current;if(!t)return null;let n=await Ct(t,e);return x.current===t?($n(e,n),n):null},[x,$n]),nr=(0,X.useCallback)(async(e,t=null)=>{let n=x.current;if(!n)return;me(null),he(null),_e(e),ye(t),Pe(uQ());let r=ut.get(e)??null,i=d.filter(t=>t.worktree_bundle_id===e);if(r&&i.length>0){let e=Pd(i),t=Ld(i,{reviewOwnerTicketId:i.find(e=>e.state===`review`)?.id??null,latestSessionTicketId:e?.id??null});xe({bundle:r,tickets:i,latest_session_ticket_id:e?.id??null,latest_session_id:e?.session_id??null,review_owner_ticket_id:i.find(e=>e.state===`review`)?.id??null,target_ticket_id:t?.id??null})}else xe(null);Me(!0);try{await tr(e)}catch{}finally{x.current===n&&Me(!1)}},[x,ut,tr,d]),rr=(0,X.useCallback)(async(e,t)=>{Pe(t=>({...t,[e]:!0}));try{return await t()}finally{Pe(t=>({...t,[e]:!1}))}},[]),ir=(0,X.useCallback)(async t=>{await rr(`stopBuild`,async()=>{let n=d.find(e=>e.id===t);await pn(t,n?.project_id??e),f(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e)),n?.worktree_bundle_id&&await er(n.worktree_bundle_id)})},[e,er,rr,f,d]),ar=(0,X.useCallback)(async t=>{await rr(`resumeBuild`,async()=>{let n=d.find(e=>e.id===t);await mn(t,n?.project_id??e),f(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e)),n?.worktree_bundle_id&&await er(n.worktree_bundle_id)})},[e,er,rr,f,d]),or=(0,X.useCallback)(async t=>{if(e)try{Qn(await rr(`build`,()=>Dt(e,t))),ge===t&&ye(`build`),s?.()}catch(e){throw Q.error(e instanceof we?e.message:l(`board.errors.buildBundle`),{id:`board-bundle-build-error`}),e}},[e,Qn,s,rr,ge,l]),sr=(0,X.useCallback)(async t=>{if(e)try{Qn(await rr(`review`,()=>Ot(e,t))),ge===t&&ye(`review`)}catch(e){throw Q.error(e instanceof we?e.message:l(`board.errors.reviewBundle`),{id:`board-bundle-review-error`}),e}},[e,Qn,rr,ge,l]),cr=(0,X.useCallback)(async t=>{if(e)try{fe(`review`),Qn(await rr(`undoReview`,()=>kt(e,t))),ge===t&&ye(`build`)}catch(e){throw Q.error(e instanceof we?e.message:l(`board.errors.undoBundleReview`),{id:`board-bundle-undo-review-error`}),e}finally{fe(e=>e===`review`?null:e)}},[e,Qn,rr,ge,l]),lr=(0,X.useCallback)(async(e,t,n)=>{if(t===lQ||n===lQ)return;let r=DQ(t,n);if(!r)return;let i=d.filter(n=>n.worktree_bundle_id===e&&n.state===t&&n.parked_at===null);if(i.length===0)return;let a=i.map(e=>e.id);E(a,n),bn(i,n);try{if(r===`build`){await or(e),D(a);return}if(r===`review`){await sr(e),D(a);return}await cr(e),D(a)}catch(e){en(i),D(a),Q.error(e instanceof we?e.message:l(`board.errors.moveBundle`),{id:`board-bundle-move-error`})}},[D,or,sr,cr,E,bn,en,d,l]),ur=async t=>{e&&(Qn(await rr(`run`,()=>Pt(e,t))),s?.())},dr=async t=>{if(!e)return;let n=r?.kind===`ticket`&&Qe===t?Y:null,i=await rr(`stop`,()=>Ft(e,t));o?.(n),Qn(i),s?.()},fr=(0,X.useCallback)(async(t,n)=>{e&&Qn(await rr(`followUp`,()=>At(e,t,n)))},[e,Qn,rr]);(0,X.useEffect)(()=>()=>{a?.(null)},[a]),(0,X.useEffect)(()=>{if(!a)return;if(!r){a(null);return}if(r.kind===`project`){a({target:null,canSelect:!1,disabledReason:l(`board.preview.disabledProjectRoot`),submitPrompt:null});return}let e=d.find(e=>e.id===r.ticket_id);if(!e){a({target:null,canSelect:!1,disabledReason:l(`board.preview.disabledBuildCapable`),submitPrompt:null});return}if(e.state===`plan`){a({target:{kind:`ticket`,id:e.id},canSelect:!1,disabledReason:l(`board.preview.disabledPlanMode`),submitPrompt:null});return}if(e.worktree_bundle_id){a({target:{kind:`bundle`,id:e.worktree_bundle_id,ticket_id:e.id},canSelect:!0,disabledReason:null,promptPlaceholder:l(`board.preview.followUpBundlePlaceholder`),submitPrompt:t=>fr(e.worktree_bundle_id,t)});return}a({target:{kind:`ticket`,id:e.id},canSelect:!0,disabledReason:null,promptPlaceholder:l(`board.preview.followUpTicketPlaceholder`),submitPrompt:t=>Xn(e.id,t)})},[r,Xn,fr,a,l,d]);let pr=async t=>{let n=d.find(e=>e.id===t),r=n?BE(n.state):null;if(n)try{if(n.state===`review`&&n.can_re_review&&n.agent_status!==`running`){let t=await gn(n.id,n.project_id??e);En(t),t.worktree_bundle_id&&await er(t.worktree_bundle_id);return}if(!r)return;if(n.worktree_bundle_id&&r===`review`){await sr(n.worktree_bundle_id);return}await Dn(n,r)}catch(e){throw Q.error(e instanceof we?e.message:l(`board.errors.moveTicket`),{id:`board-move-error`}),e}},mr=async t=>{let n=d.find(e=>e.id===t);try{En(await tn(t,n?.project_id??e))}catch(e){throw Q.error(e instanceof we?e.message:l(`board.errors.startBuildChain`),{id:`board-build-chain-error`}),e}},hr=async t=>{let n=d.find(e=>e.id===t);try{await nn(t,n?.project_id??e)}catch(e){throw Q.error(e instanceof we?e.message:l(`board.errors.stopBuildChain`),{id:`board-stop-build-chain-error`}),e}},gr=async()=>{if(!(!e||le)){ue(!0);try{let t=await cn(e);f(e=>e.filter(e=>!t.deleted_ticket_ids.includes(e.id))),m(e=>t.deleted_ticket_ids.reduce(rD,e)),await w(),ce(!1),t.failed_count>0?Q.error(l(`board.toasts.deleteDonePartial`,{count:t.deleted_count,deletedCount:t.deleted_count,failedCount:t.failed_count}),{id:`board-delete-parked-error`}):Q.success(l(`board.toasts.deleteDoneSuccess`,{count:t.deleted_count}),{id:`board-delete-parked-success`})}catch(e){Q.error(e instanceof we?e.message:l(`board.errors.emptyDone`),{id:`board-delete-parked-error`})}finally{ue(!1)}}},_r=({delta:e})=>{R(e)},vr=(0,X.useCallback)((t=null)=>{e&&B({initialWorktreeBundleId:t})},[e]),yr=(0,X.useCallback)(()=>{e&&Zt(e,e=>e.isOpen?e:{...e,isOpen:!0})},[e,Zt]),br=(0,X.useCallback)(()=>{qe.current?.focus({preventScroll:!0})},[]);return jZ([{key:`n`,onKeyDown:vr,disabled:!e},{key:`a`,onKeyDown:yr,disabled:!e},{key:`k`,ctrlKey:!0,onKeyDown:br}],{isBlocked:AZ}),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(oE,{sensors:u,collisionDetection:vw,onDragStart:Qt,onDragMove:_r,onDragCancel:$t,onDragEnd:Sn,children:[(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(vZ,{projectId:e,state:Lt,bundles:h,projectBranchState:n,showModelSelector:He,availableModels:te,availableSkills:ne,onManageBundles:e?()=>{(async()=>{try{await w()}catch{}ee(!0)})()}:void 0,onToggle:()=>{e&&Zt(e,e=>({...e,isOpen:!e.isOpen}))},onDescriptionChange:t=>{e&&Zt(e,e=>({...e,composer:{...e.composer,description:t}}))},onModelChange:t=>{if(!e)return;let n=te.find(e=>e.id===t)??null;Zt(e,e=>({...e,composer:{...e.composer,model:t,variant:n?.variants.includes(e.composer.variant)?e.composer.variant:``}}))},onSkillsChange:t=>{e&&Zt(e,e=>({...e,composer:{...e.composer,skills:t}}))},onVariantChange:t=>{e&&Zt(e,e=>({...e,composer:{...e.composer,variant:t}}))},onBundleChange:t=>{e&&Zt(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t}}))},onGenerate:()=>{In()}}),(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:W(`absolute inset-y-0 left-16 right-0 z-10 bg-black/60 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Lt.isOpen?`opacity-100`:`pointer-events-none opacity-0`)}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4 overflow-hidden p-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(`div`,{className:`relative w-full max-w-sm`,children:[(0,Z.jsx)(Ae,{id:`board-ticket-search`,ref:qe,type:`search`,value:Re,onChange:e=>q(e.target.value),placeholder:l(`board.search.placeholder`),"aria-label":l(`board.search.ariaLabel`),className:`pr-32`}),Re.length>0?(0,Z.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":l(`board.search.clearAriaLabel`),className:`absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>{q(``),qe.current?.focus()},children:(0,Z.jsx)(Fe,{className:`size-4`})}):(0,Z.jsxs)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-0.5 text-[10px] leading-none`,children:[(0,Z.jsx)(DE,{children:`CTRL`}),(0,Z.jsx)(`span`,{children:`+`}),(0,Z.jsx)(DE,{children:`K`})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(cm,{id:`board-hide-stale-tickets`,checked:ze,onCheckedChange:Be,"aria-label":l(`board.search.hideStaleAriaLabel`)}),(0,Z.jsx)(mu,{htmlFor:`board-hide-stale-tickets`,className:`text-sm text-muted-foreground`,children:l(`board.search.hideStaleLabel`)})]})]}),(0,Z.jsx)(`div`,{ref:gt,className:`flex min-h-0 flex-1 overflow-x-auto overflow-y-hidden`,children:(0,Z.jsxs)(`div`,{ref:_t,className:`relative flex min-h-0 w-max min-w-full gap-4`,children:[(0,Z.jsx)(cZ,{dependencies:p,cardRects:yt,preview:bt,ticketsById:st,overlaySize:wt}),cQ.map(t=>{let n=d.filter(e=>e.state===t&&!WE(e)),r=ft.filter(e=>e.state===t&&!WE(e)),i=Rd(r,h,t),a=rt&&n.length===0?t===`plan`?1:t===`build`?2:0:0;return(0,Z.jsx)(bq,{id:t,title:l(`card.columnLabels.${t}`),pinnedContent:t===`plan`?Ut:null,items:i,ticketCount:r.length,allTickets:d,dependencies:p,showModelSelector:He,availableModels:te,bundles:h,activeRunContextKey:et,isProjectRootRunActive:$e,isBundleRunDisabled:tt,getDependencyTargetState:Tt,onDependencyStart:Et,onDeleteDependency:jt,onRegisterTicketNode:vt,onAddTicket:t===`plan`&&e?vr:void 0,onCreateBundle:t===`plan`&&e?wn:void 0,onDeleteBundle:t===`plan`&&e?Nn:void 0,onDeleteBundleWrapper:Pn,onRefreshBundles:t===`plan`&&e?w:void 0,onUpdateTicket:Fn,onDeleteTicket:Ln,onUndoTicket:Rn,undoingColumn:de,onRetryTicket:zn,onAdvanceTicket:pr,onParkTicket:kn,onUnparkTicket:An,onBuildChainTicket:mr,onRunTicket:Bn,onOpenTestsTicket:ot?Yn:void 0,canOpenChangesForTicket:Jt,onOpenChangesTicket:Jn,canOpenIdeForTicket:Kt,onOpenIdeTicket:Vn,onStopTicket:Hn,onStopBuildTicket:Un,onStopBuildChainTicket:hr,onResumeBuildTicket:Wn,onOpenBundleChanges:Kn,onOpenBundleTests:ot?qn:void 0,onOpenBundleIde:Gn,onAddTicketToBundle:vr,onFollowUpTicket:Xn,bundleActionState:Ne,onBuildBundle:or,onReviewBundle:sr,onUndoBundleReview:cr,onRunBundle:ur,onStopBundle:dr,onParkBundleWrapper:jn,onUnparkBundleWrapper:Mn,onOpenTicketDetails:lt,onOpenBundleDetails:(e,t)=>{nr(e,t)},onRequestBundleRefresh:e=>{rr(`bundleRefresh`,()=>er(e))},onRequestTicketRefresh:C,loadingSkeletonCount:a},t)}),(0,Z.jsx)(bq,{id:lQ,title:l(`card.columnLabels.done`),items:mt,ticketCount:pt.length,allTickets:d,dependencies:p,showModelSelector:He,availableModels:te,bundles:h,activeRunContextKey:et,isProjectRootRunActive:$e,isBundleRunDisabled:tt,getDependencyTargetState:Tt,onDependencyStart:Et,onDeleteDependency:jt,onRegisterTicketNode:vt,onUpdateTicket:Fn,onDeleteTicket:Ln,onUndoTicket:Rn,undoingColumn:de,onRetryTicket:zn,onAdvanceTicket:pr,onParkTicket:kn,onUnparkTicket:An,onBuildChainTicket:mr,onRunTicket:Bn,onOpenTestsTicket:ot?Yn:void 0,canOpenChangesForTicket:Jt,onOpenChangesTicket:Jn,canOpenIdeForTicket:Kt,onOpenIdeTicket:Vn,onStopTicket:Hn,onStopBuildTicket:Un,onStopBuildChainTicket:hr,onResumeBuildTicket:Wn,onOpenBundleChanges:Kn,onOpenBundleTests:ot?qn:void 0,onOpenBundleIde:Gn,onAddTicketToBundle:vr,onFollowUpTicket:Xn,bundleActionState:Ne,onBuildBundle:or,onReviewBundle:sr,onUndoBundleReview:cr,onRunBundle:ur,onStopBundle:dr,onParkBundleWrapper:jn,onUnparkBundleWrapper:Mn,onOpenTicketDetails:lt,onOpenBundleDetails:(e,t)=>{nr(e,t)},onRequestBundleRefresh:e=>{rr(`bundleRefresh`,()=>er(e))},onRequestTicketRefresh:C,className:`min-w-[272px] max-w-[272px] flex-[0.98] bg-card/65`,headerAccessory:(0,Z.jsxs)(J,{type:`button`,variant:`destructive`,size:`xs`,className:`gap-1.5`,disabled:pt.length===0||le,onClick:()=>ce(!0),children:[(0,Z.jsx)(Vf,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:l(`board.doneColumn.emptyAction`)})]})})]})})]})]}),(0,Z.jsxs)(EE,{zIndex:5,dropAnimation:re?null:void 0,children:[j&&(0,Z.jsx)(vq,{ticket:j,allTickets:d,dependencies:p,bundles:h,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:j.tool===`opencode`&&te.length>0,availableModels:te,runDisabled:TQ(j,et,$e,l(`board.errors.runBlockedByActive`))!==void 0,runDisabledReason:TQ(j,et,$e,l(`board.errors.runBlockedByActive`)),onDependencyStart:Et,onDeleteDependency:jt,onRegisterOverlayNode:I,onCreateBundle:wn,onDeleteBundle:Nn,onRefreshBundles:w,onUpdate:Fn,onDelete:()=>Ln(j.id),onUndo:()=>Rn(j.id),undoInProgress:de===j.state&&(j.state===`build`||j.state===`review`),onRetry:()=>zn(j.id),onAdvance:()=>pr(j.id),onPark:()=>kn(j.id),onUnpark:()=>An(j.id),onBuildChain:()=>mr(j.id),onRun:j.worktree_bundle_id===null&&Id(j)&&j.has_run_config?()=>Bn(j.id):void 0,onOpenIde:j.worktree_bundle_id===null&&Kt(j)?()=>Vn(j.id):void 0,onStop:j.worktree_bundle_id===null?()=>Hn(j.id):void 0,onStopBuild:()=>Un(j.id),onStopBuildChain:()=>hr(j.id),onResumeBuild:()=>Wn(j.id),onFollowUp:e=>Xn(j.id,e),onRequestTicketRefresh:C}),!j&&N&&(0,Z.jsx)(MD,{group:N,overlay:!0,renderTicket:Ht})]}),nt&&(0,Z.jsx)(yZ,{className:`pointer-events-auto fixed left-1/2 top-4 z-20 w-[min(14rem,calc(100vw-2rem))] -translate-x-1/2`})]}),z&&(0,Z.jsx)(lZ,{onSubmit:Cn,bundles:h,projectId:e,projectBranchState:n,tool:i,showModelSelector:He,availableModels:te,availableSkills:ne,initialModel:He?Rt.model:``,initialVariant:He&&Rt.model?Rt.variant:``,initialSkills:He?Rt.skills:[],initialWorktreeBundleId:z.initialWorktreeBundleId,onCreateBundle:wn,onDeleteBundle:Nn,onRefreshBundles:w,onClose:()=>B(null)}),V&&e&&(0,Z.jsx)(Uf,{bundles:h,selectedBundleId:Lt.composer.worktreeBundleId||null,onSelectBundle:t=>{Zt(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t??``}}))},onCreateBundle:wn,onDeleteBundle:Nn,onClose:()=>ee(!1)}),se&&(0,Z.jsx)(xq,{ticketCount:pt.length,isDeleting:le,onCancel:()=>ce(!1),onConfirm:()=>{gr()}}),G&&(0,Z.jsx)(_q,{ticket:G,allTickets:d,dependencies:p,bundles:h,projectMemoryEnabled:!!t?.memory_enabled,projectBranchState:n,onClose:()=>{let e=G.id;me(null),he(null),f(t=>t.map(t=>t.id===e?MZ(t):t))},showModelSelector:Ue,availableModels:te,availableSkills:ne,runDisabled:TQ(G,et,$e,l(`board.errors.runBlockedByActive`))!==void 0,runDisabledReason:TQ(G,et,$e,l(`board.errors.runBlockedByActive`)),onDeleteDependency:jt,onCreateBundle:wn,onDeleteBundle:Nn,onRefreshBundles:w,onUpdate:Fn,onAdvance:()=>pr(G.id),onBuildChain:()=>mr(G.id),onRun:Id(G)&&G.has_run_config?()=>Bn(G.id):void 0,onOpenIde:Kt(G)?()=>Vn(G.id):void 0,onStop:()=>Hn(G.id),onStopBuild:()=>Un(G.id),onStopBuildChain:()=>hr(G.id),onResumeBuild:()=>Wn(G.id),onFollowUp:e=>Xn(G.id,e),onProjectMemorySuggestionsChanged:()=>{Le(e=>e+1)},onRequestTicketRefresh:e=>{ct(e)}}),Se&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)($Z,{scope:`ticket`,ticketId:Se.ticketId,projectId:Se.projectId,testCommands:it,onClose:()=>Ce(null)})}),Ee&&(0,Z.jsx)(JX,{ticketId:Ee.ticketId,projectId:Ee.projectId,reviewCommentsBundleId:Ee.bundleId,title:Ee.title,onSubmitReviewPrompt:e=>fr(Ee.bundleId,e),canSubmitReviewPrompt:!d.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`),reviewSubmitDisabledReason:d.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`)?l(`board.changes.reviewPromptDisabledReason`):void 0,canAddReviewComments:!d.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`),canModifyChanges:!d.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`),changesDisabledReason:d.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`)?l(`board.changes.modifyChangesDisabledReason`):void 0,onClose:()=>{let{bundleId:e}=Ee;De(null),er(e)},onTicketUpdate:Fn,onRequestTicketRefresh:C}),K&&(0,Z.jsx)(JX,{ticketId:K.ticketId,projectId:K.projectId,title:K.title,onClose:()=>{let{ticketId:e}=K;Te(null),ct(e)},onTicketUpdate:Fn,onRequestTicketRefresh:e=>{ct(e)}}),Oe&&e&&t&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)($Z,{scope:`project`,projectId:e,targetKind:`bundle`,targetBundleId:Oe,testCommands:it,onClose:()=>ke(null)})}),ge&&dt&&(0,Z.jsx)(Vq,{details:dt,activeColumn:ve,isLoading:je||Ne.bundleRefresh,actionState:Ne,canOpenIde:Yt(dt),projectMemoryEnabled:!!t?.memory_enabled,memorySuggestionsRefreshKey:Ie,runDisabled:tt(dt.bundle.id),showModelSelector:We,availableModels:te,availableSkills:ne,onClose:()=>{let e=dt.bundle.id;_e(null),ye(null),xe(null),Me(!1),Pe(uQ()),f(t=>t.map(t=>t.worktree_bundle_id===e&&t.id!==pe?MZ(t):t))},onOpenTicketDetails:lt,onUpdateTicket:Fn,onOpenIde:()=>{let e=dt.tickets.find(e=>e.id===dt.target_ticket_id)??dt.tickets.find(e=>e.has_worktree);e&&Vn(e.id)},onOpenTests:ot?()=>{qn(dt.bundle.id)}:void 0,onRefresh:e=>{rr(`bundleRefresh`,()=>er(e))},onBuildBundle:or,onStopBuildTicket:ir,onResumeBuildTicket:ar,onReviewBundle:sr,onUndoBundleReview:cr,onRunBundle:ur,onStopBundle:dr,onFollowUpBundle:fr})]})},AQ=({className:e})=>(0,Z.jsx)(qc,{"aria-hidden":`true`,className:e}),jQ=({className:e})=>(0,Z.jsx)(Rc,{"aria-hidden":`true`,className:e}),MQ=({className:e})=>(0,Z.jsx)(zc,{"aria-hidden":`true`,className:e}),NQ=4,PQ=5e3,FQ=(e,t)=>Oe.t(`common:chatChangesPanel.${e}`,t),IQ=e=>e.replace(/^[ab]\//,``),LQ=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?IQ(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?IQ(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},RQ=e=>{let[t,n]=LQ(e);return!t&&!n?FQ(`unknownFile`):t&&n&&t!==n?`${n} -> ${t}`:t??n??FQ(`unknownFile`)},zQ=e=>{let t=sY((()=>{let[t,n]=LQ(e);return t??n??null})());if(!t)return null;try{return dS(e.hunks,{highlight:!0,refractor:sX.default,language:t,enhancers:[lS(e.hunks)]})}catch{return null}},BQ=(e,t)=>e instanceof Error?e.message:t,VQ=(e,t)=>{if(!t)return e;let n=RQ(t);return[t,...e.filter(e=>RQ(e)!==n)]},HQ=e=>[...e].sort((e,t)=>{if(e.filePath!==t.filePath)return e.filePath.localeCompare(t.filePath);let n=e.newLineNumber??e.oldLineNumber??2**53-1,r=t.newLineNumber??t.oldLineNumber??2**53-1;return n===r?e.changeKey.localeCompare(t.changeKey):n-r}),UQ=({diffResponse:e,gitStatus:t})=>{let n=new Map;for(let t of e?.files??[])n.set(t.path,t);return t?t.files.map(e=>{let t=n.get(e.path)??(e.original_path?n.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(e?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions}))},WQ=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},GQ={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},KQ=e=>FQ(`fileStatus.${e}`),qQ=({selectedDiffPath:e,sidebarFiles:t,diffStats:n,triggerMode:r=`full`,onSelectDiffPath:i})=>{let[a,o]=(0,X.useState)(!1),s=t.find(t=>t.path===e)??null,c=r===`compact`?e===`all`?FQ(`picker.diff`):s?WQ(s.path):FQ(`picker.file`):e===`all`?FQ(`picker.allChanges`):s?WQ(s.path):e;return(0,Z.jsxs)(hu,{open:a,onOpenChange:o,children:[(0,Z.jsx)(gu,{asChild:!0,children:(0,Z.jsxs)(J,{type:`button`,size:`sm`,variant:`outline`,className:W(`max-w-full gap-2`,r===`full`?`min-w-0 max-w-[18rem]`:`min-w-0 px-2.5`),"aria-label":FQ(`picker.openChangedFilesAriaLabel`),title:e===`all`?void 0:s?.path??e,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:c}),r===`full`&&(0,Z.jsx)(q,{variant:`outline`,className:`shrink-0 text-[10px] uppercase tracking-wide`,children:FQ(`picker.fileCount`,{count:t.length})}),(0,Z.jsx)(oe,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Z.jsxs)(_u,{align:`start`,className:`z-[90] w-[28rem] max-w-[calc(100vw-2rem)] p-0`,children:[(0,Z.jsx)(`div`,{className:`border-b border-border/80 px-4 py-3`,children:(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:FQ(`picker.title`)})}),(0,Z.jsx)(`div`,{className:`max-h-[min(28rem,calc(100vh-10rem))] overflow-y-auto p-3`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{i(`all`),o(!1)},className:W(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,GJ(e===`all`),`justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:FQ(`picker.allChanges`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:FQ(`picker.allChangesDescription`)})]}),n&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:FQ(`picker.fileCount`,{count:n.files_changed})}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,n.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,n.deletions]})]})]}),t.map(t=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{i(t.path),o(!1)},className:W(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,GJ(e===t.path)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:WQ(t.path)}),(0,Z.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.path})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,t.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,t.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[t.status&&(0,Z.jsx)(q,{variant:`outline`,className:GQ[t.status],children:KQ(t.status)}),t.staged&&(0,Z.jsx)(q,{variant:`outline`,children:FQ(`fileStatus.staged`)}),t.unstaged&&(0,Z.jsx)(q,{variant:`outline`,children:FQ(`fileStatus.unstaged`)}),t.conflicted&&(0,Z.jsx)(q,{variant:`destructive`,children:FQ(`fileStatus.conflicted`)}),t.originalPath&&(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.status===`renamed`?FQ(`fileStatus.renamedFrom`,{path:t.originalPath}):t.originalPath})]})]})},`${t.path}:${t.originalPath??``}`))]})})]})]})},JQ=(0,X.memo)(({projectId:e,chatSessionId:t=null,canSubmitReviewPrompt:n,reviewSubmitDisabledReason:r,onSubmitReviewPrompt:i,state:a,onStateChange:o,isResizing:s=!1,onClose:c,desktopWidth:l,panelElementRef:u})=>{let[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),[,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(new Map),[S,C]=(0,X.useState)(!1),w=(0,X.useRef)(0),T=(0,X.useRef)(0),E=(0,X.useRef)(null),D=(0,X.useRef)(null),O=a.selectedDiffPath,k=a.activeReviewTarget,A=a.editingReviewCommentKey,j=k?.commentKey??A??`chat`,M=a.reviewDraftInput,N=(0,X.useMemo)(()=>new Map(a.reviewComments.map(e=>[xS(e.filePath,e.changeKey),e])),[a.reviewComments]),P=(0,X.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await vC(e,t):await se(e)},[t,e]),F=(0,X.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await yC(e,t):await Re(e)},[t,e]);(0,X.useEffect)(()=>{E.current=d},[d]),(0,X.useEffect)(()=>{D.current=p},[p]);let I=(0,X.useCallback)(async()=>{if(!e){T.current+=1,f(null),m(null),g(null),v(!1),y(!1);return}let t=w.current+1,n=T.current+1;w.current=t,T.current=n,v(!0),y(!0);let[r,i]=await Promise.allSettled([P(),F()]);w.current===t&&(r.status===`fulfilled`?(E.current=r.value,f(r.value),g(null)):g(BQ(r.reason,FQ(`errors.loadDiff`))),i.status===`fulfilled`&&(D.current=i.value,m(i.value)),T.current===n&&v(!1),y(!1))},[P,F,e]),L=(0,X.useCallback)(async(t={})=>{if(!e)return;let{broadcastOnSignatureChange:n=!1}=t,r=w.current+1;w.current=r,y(!0);try{let t=await F();if(w.current!==r)return;let i=D.current?.workspace_signature??null,a=t.workspace_signature??null,o=!E.current||i!==a;if(D.current=t,m(t),!o){T.current+=1,v(!1);return}let s=!E.current,c=T.current+1;T.current=c,s&&v(!0);try{let t=await P();if(w.current!==r)return;E.current=t,f(t),g(null),n&&i!==a&&lY(e)}catch(e){if(w.current!==r)return;E.current||g(BQ(e,FQ(`errors.loadDiff`)))}finally{s&&T.current===c&&v(!1)}}catch{E.current||(T.current+=1,v(!1));return}finally{w.current===r&&y(!1)}},[P,F,e]);(0,X.useEffect)(()=>{I()},[I]),(0,X.useEffect)(()=>{if(e)return uY(t=>{t===e&&L()})},[e,L]),(0,X.useEffect)(()=>{if(!e)return;let t=fY(()=>{document.visibilityState===`visible`&&L({broadcastOnSignatureChange:!0})});return()=>{t()}},[e,L]),(0,X.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>{document.visibilityState===`visible`&&L({broadcastOnSignatureChange:!0})},PQ);return()=>{window.clearInterval(t)}},[e,L]);let R=(0,X.useMemo)(()=>{let e=typeof d?.diff==`string`?d.diff:``;return e.trim()?n_(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:LQ(e)})):[]},[d]),z=(0,X.useMemo)(()=>{let e=new Map;for(let t of R)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[R]),B=(0,X.useMemo)(()=>UQ({diffResponse:d,gitStatus:p}),[d,p]);(0,X.useEffect)(()=>{if(O!==`all`&&!(!d&&!p)){if(B.length===0){o(e=>({...e,selectedDiffPath:`all`}));return}B.some(e=>e.path===O)||o(e=>({...e,selectedDiffPath:`all`}))}},[d,p,o,O,B]);let V=O===`all`?null:z.get(O)??null,ee=(0,X.useMemo)(()=>VQ(R,V),[R,V]),te=(0,X.useMemo)(()=>O===`all`?R:V?[V]:[],[R,O,V]);(0,X.useEffect)(()=>{x(new Map)},[R]),(0,X.useEffect)(()=>{if(ee.length===0)return;let e=!1,t=null,n=0,r=()=>{if(e)return;let i=ee.slice(n,n+NQ);i.length!==0&&(x(e=>{let t=new Map(e);for(let e of i){let n=RQ(e);t.has(n)||t.set(n,zQ(e))}return t}),n+=NQ,n<ee.length&&(t=window.setTimeout(r,0)))};return t=window.setTimeout(r,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[ee]);let H=(0,X.useMemo)(()=>{let e=new Map;for(let t of ee.slice(0,NQ))e.set(RQ(t),zQ(t));return e},[ee]),ne=(0,X.useMemo)(()=>te.map(e=>({...e,tokens:b.get(RQ(e))??H.get(RQ(e))??null})),[H,b,te]),U=(0,X.useMemo)(()=>R.map(e=>({...e,tokens:null})),[R]),re=(0,X.useMemo)(()=>HQ(a.reviewComments),[a.reviewComments]),ie=re.length,ae=n&&!S&&ie>0,oe=(0,X.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}))},[o]),ce=(0,X.useCallback)(({filePath:e,changeKey:t,commentKey:r})=>{let i=N.get(r);if(i){o(e=>({...e,selectedDiffPath:i.filePath,activeReviewTarget:null,editingReviewCommentKey:r,reviewDraftInput:i.comment}));return}n&&o(n=>({...n,activeReviewTarget:{filePath:e,changeKey:t,commentKey:r},editingReviewCommentKey:null,reviewDraftInput:``}))},[n,o,N]),le=(0,X.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``}))},[o]),ue=(0,X.useCallback)(e=>{let t=N.has(e.commentKey);if(!n&&!t)return;let r=M.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;o(t=>{let n=new Map(t.reviewComments.map(e=>[xS(e.filePath,e.changeKey),e]));return n.set(e.commentKey,{scope:`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:SS(e.hunk,e.change),comment:r}),{...t,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[...n.values()]}})},[n,o,N,M]),de=(0,X.useCallback)(e=>{let t=N.get(e);t&&o(n=>({...n,selectedDiffPath:t.filePath,activeReviewTarget:null,editingReviewCommentKey:e,reviewDraftInput:t.comment}))},[o,N]),fe=(0,X.useCallback)(e=>{o(t=>({...t,activeReviewTarget:t.activeReviewTarget?.commentKey===e?null:t.activeReviewTarget,editingReviewCommentKey:t.editingReviewCommentKey===e?null:t.editingReviewCommentKey,reviewDraftInput:t.activeReviewTarget?.commentKey===e||t.editingReviewCommentKey===e?``:t.reviewDraftInput,reviewComments:t.reviewComments.filter(t=>xS(t.filePath,t.changeKey)!==e)}))},[o]),pe=(0,X.useCallback)(async()=>{if(!ae)return;C(!0);let e=jS({drafts:re,findings:[],githubComments:[],uncommittedFiles:R});try{await i(e),oe(),Q.success(FQ(`toasts.sendChangesSuccess`),{id:`chat-diff-review-submit-success`})}catch(e){Q.error(BQ(e,FQ(`errors.sendChanges`)),{id:`chat-diff-review-submit-error`})}finally{C(!1)}},[ae,oe,i,R,re]),me=(0,X.useCallback)(e=>(0,Z.jsx)(Zq,{reviewComments:re,pendingFixCount:ie,triggerMode:e===`wide`?`full`:`compact`,canSendReview:ae,isSubmittingReview:S,reviewSubmitDisabledReason:r??void 0,onClearPendingFixes:oe,onSubmitReview:()=>{pe()}}),[ae,oe,pe,S,ie,re,r]),G=c?(0,Z.jsx)(J,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":FQ(`closeAriaLabel`),className:`text-muted-foreground hover:text-foreground`,onClick:c,children:(0,Z.jsx)(Fe,{className:`h-4 w-4`})}):null,he=l?{"--chat-changes-panel-width":`${l}px`}:void 0;return(0,Z.jsx)(`aside`,{"data-testid":`chat-changes-panel`,"data-desktop-width":l?String(l):void 0,ref:u,style:he,className:W(`flex h-[26rem] min-h-0 w-full shrink-0 flex-col overflow-hidden border-t border-border/70 bg-background/20 xl:h-full xl:border-l xl:border-t-0`,l?`xl:w-[var(--chat-changes-panel-width)]`:`xl:w-[32rem]`),children:(0,Z.jsx)(WJ,{selectedDiffPath:O,sidebarFiles:B,diffResponse:d,isDiffLoading:_,diffError:h,allDiffFiles:U,renderedFiles:ne,viewType:`unified`,onViewTypeChange:()=>{},onRetry:()=>{I()},activeReviewTarget:k,editingReviewCommentKey:A,reviewDraftInstanceKey:j,reviewDraftInput:M,reviewComments:re,reviewFindings:[],githubComments:[],selectedReviewFindingIds:[],selectedGitHubCommentIds:[],canSelectReviewTarget:n,canEditActiveReviewDraft:n,reviewFindingsError:null,gitHubCommentsError:null,hasStaleReviewFindings:!1,onSelectReviewTarget:ce,onToggleReviewFindingSelection:()=>{},onToggleGitHubCommentSelection:()=>{},onReviewDraftInputChange:e=>{o(t=>({...t,reviewDraftInput:e}))},onCancelReviewDraft:le,onEditReviewDraft:de,onRemoveReviewDraft:fe,onSaveReviewDraft:ue,diffThemeClassName:XJ,resolveFilePath:RQ,normalizeDiffPath:IQ,emptyStateTitle:FQ(`emptyStateTitle`),emptyStateDescription:FQ(`emptyStateDescription`),filePickerControl:e=>(0,Z.jsx)(qQ,{selectedDiffPath:O,sidebarFiles:B,diffStats:d?.stats??null,triggerMode:e===`wide`?`full`:`compact`,onSelectDiffPath:e=>{o(t=>({...t,selectedDiffPath:e}))}}),reviewSummaryControl:me,extraHeaderControl:G,surfaceVariant:`flat`,showViewTypeToggle:!1,gutterVariant:`compact`,isResizing:s,resizePlaceholderLineThreshold:200})})});JQ.displayName=`ChatChangesPanel`;var YQ=({projectId:e,messages:t,internalLog:n,currentThinkingMessageId:r=null,previousThinkingLog:i=null,previousThinkingMessageId:a=null,pendingAgentTitle:o,streamingResponse:s,isRunning:c,isLoading:l=!1,canShowComposer:u,isExternallyResizing:d=!1,pendingAgentRevealKey:f=null,pendingAgentRevealDelayMs:p=0,composerFocusNonce:m=0,blurComposerOnSendStart:h=!1,hidePendingAgentTitle:g=!1,forceScrollToBottomKey:_,header:v,composerControls:y,composerInlineControls:b,composerTheme:x=`default`,layoutKey:S,scrollLayoutKey:C,followUpPrompt:w,draftAttachments:T=[],followUpPlaceholder:E,emptyStateText:D=null,renderMessageFooter:O,isSendingFollowUp:k,isUploadingAttachments:A=!1,canAttachImages:j=!1,followUpDisabledReason:M,onFollowUpPromptChange:N,onFollowUpKeyDown:P,onFollowUpPaste:F,onUploadAttachments:I,onRemoveAttachment:L,onFollowUpSubmit:R})=>(0,Z.jsx)(XF,{projectId:e,messages:t,internalLog:n,currentThinkingMessageId:r,previousThinkingLog:i,previousThinkingMessageId:a,pendingAgentTitle:o,streamingResponse:s,isRunning:c,isLoading:l,autoScrollBehavior:`sticky`,surfaceVariant:`chat`,canShowComposer:u,header:v,composerControls:y,composerInlineControls:b,composerTheme:x,composerSize:`compact-on-laptop`,showThinkingPlacement:`header`,pinComposerToBottom:!0,isExternallyResizing:d,pendingAgentRevealKey:f,pendingAgentRevealDelayMs:p,composerFocusNonce:m,blurComposerOnSendStart:h,forceScrollToBottomKey:_,layoutKey:S,scrollLayoutKey:C,followUpPrompt:w,draftAttachments:T,followUpPlaceholder:E,emptyStateText:D,autoFocusComposer:!0,renderMessageFooter:O,isSendingFollowUp:k,isUploadingAttachments:A,canAttachImages:j,followUpDisabledReason:M,hidePendingAgentTitle:g,onFollowUpPromptChange:N,onFollowUpKeyDown:P,onFollowUpPaste:F,onUploadAttachments:I,onRemoveAttachment:L,onFollowUpSubmit:R}),XQ=({value:e,disabled:t=!1,onChange:n,planInactiveTooltip:r,buildInactiveTooltip:i})=>(0,Z.jsx)(Ru,{value:e,items:[{value:`plan`,label:`Plan`,activeVariant:`ghost`,activeClassName:`border-transparent bg-sky-300 text-[#07111a] shadow-[0_10px_30px_rgba(125,211,252,0.24)] hover:bg-sky-200 hover:text-[#07111a]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:r},{value:`build`,label:`Build`,activeVariant:`ghost`,activeClassName:`border-transparent bg-emerald-400 text-[#07130d] shadow-[0_10px_30px_rgba(16,185,129,0.28)] hover:bg-emerald-300 hover:text-[#07130d]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:i}],disabled:t,onChange:n}),ZQ={default:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,muted:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`},QQ=({tone:e=`default`,className:t,children:n,...r})=>(0,Z.jsx)(q,{variant:`outline`,className:W(ZQ[e],t),...r,children:n}),$Q=(e,t)=>Oe.t(`projects:memory.${e}`,t),e$=e=>$Q(`stageLabels.${e}`),t$=e=>$Q(`priorityLabels.${e}`),n$=()=>({kind:`decision`,title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`}),r$=e=>e.kind===`convention`?{kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implications:``,stages:e.stages.join(`
|
|
147
|
+
`),priority:e.priority}:{kind:`decision`,title:e.title,scope:e.scope??``,content:e.decision,rationale:e.rationale??``,implications:e.implications.join(`
|
|
148
|
+
`),stages:``,priority:`normal`},i$=e=>e.split(`
|
|
149
|
+
`).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),a$=e=>{let t=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`];return e.split(/\n|,/).map(e=>e.trim()).filter(e=>t.includes(e)).filter((e,t,n)=>n.indexOf(e)===t)},o$=({suggestion:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let a=e.kind===`decision`?e.duplicate_match?.decision??null:null,o=$Q(a?`suggested.saveAsNewDecision`:`suggested.accept`),s=e.kind===`decision`?e.decision:e.instruction;return(0,Z.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,Z.jsx)(QQ,{children:$Q(`suggested.badge`,{kind:e.kind})}),a?(0,Z.jsx)(QQ,{tone:`muted`,children:$Q(`suggested.duplicateBadge`)}):null]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:s})]})}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:$Q(`suggested.review`)}),(0,Z.jsx)(J,{type:`button`,size:`sm`,disabled:t,onClick:()=>void r(e),children:o}),(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void i(e),children:$Q(`suggested.dismiss`)})]})]})})},s$=({suggestion:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onStartEdit:o,onDraftChange:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{if(!e)return null;let d=e.kind===`decision`?e.duplicate_match?.decision??null:null,f=d?$Q(`suggested.saveAsNewDecision`):$Q(`suggested.acceptAs`,{kind:e.kind});return(0,Z.jsx)(Kl,{open:t,onOpenChange:a,children:(0,Z.jsxs)(Xl,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Z.jsxs)(Zl,{children:[(0,Z.jsx)($l,{children:e.title}),(0,Z.jsx)(eu,{children:$Q(`suggested.reviewDescription`,{kind:e.kind})})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[d?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-amber-50`,children:$Q(`suggested.duplicateTitle`)}),(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[d.title,`:`]}),` `,d.decision]})]}):null,n?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:$Q(`editor.titleLabel`)}),(0,Z.jsx)(`input`,{"aria-label":$Q(`editor.titleAriaLabel`),value:i.title,onChange:e=>s({...i,title:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:$Q(`editor.scopeLabel`)}),(0,Z.jsx)(`input`,{"aria-label":$Q(`editor.scopeAriaLabel`),value:i.scope,onChange:e=>s({...i,scope:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:i.kind===`decision`?$Q(`suggested.decision`):$Q(`suggested.instruction`)}),(0,Z.jsx)(`textarea`,{"aria-label":i.kind===`decision`?$Q(`suggested.decision`):$Q(`suggested.instruction`),value:i.content,onChange:e=>s({...i,content:e.target.value}),rows:5,className:`min-h-32 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:$Q(`editor.rationaleLabel`)}),(0,Z.jsx)(`textarea`,{"aria-label":$Q(`editor.rationaleAriaLabel`),value:i.rationale,onChange:e=>s({...i,rationale:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),i.kind===`decision`?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:$Q(`suggested.implicationsMultiline`)}),(0,Z.jsx)(`textarea`,{"aria-label":$Q(`editor.implicationsAriaLabel`),value:i.implications,onChange:e=>s({...i,implications:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:$Q(`suggested.stagesMultiline`)}),(0,Z.jsx)(`textarea`,{"aria-label":$Q(`editor.stagesLabel`),value:i.stages,onChange:e=>s({...i,stages:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:$Q(`editor.priorityLabel`)}),(0,Z.jsxs)(`select`,{"aria-label":$Q(`editor.priorityAriaLabel`),value:i.priority,onChange:e=>s({...i,priority:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`,children:[(0,Z.jsx)(`option`,{value:`low`,children:$Q(`priorityLabels.low`)}),(0,Z.jsx)(`option`,{value:`normal`,children:$Q(`priorityLabels.normal`)}),(0,Z.jsx)(`option`,{value:`high`,children:$Q(`priorityLabels.high`)})]})]})]})]}):(0,Z.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:e.kind===`decision`?$Q(`suggested.decision`):$Q(`suggested.instruction`)}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-foreground`,children:e.kind===`decision`?e.decision:e.instruction})]}),e.rationale?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:$Q(`editor.rationaleLabel`)}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-muted-foreground`,children:e.rationale})]}):null,e.kind===`decision`&&e.implications.length>0?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:$Q(`editor.implicationsLabel`)}),(0,Z.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:e.implications.map(e=>(0,Z.jsx)(`li`,{children:e},e))})]}):null,e.kind===`convention`?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:$Q(`editor.stagesLabel`)}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:e.stages.map(e=>e$(e)).join(`, `)||$Q(`suggested.noneSpecified`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:$Q(`editor.priorityLabel`)}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:t$(e.priority)})]})]}):null]})]}),(0,Z.jsxs)(Ql,{className:`flex flex-wrap gap-2 sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n?(0,Z.jsx)(J,{type:`button`,variant:`ghost`,disabled:r,onClick:c,children:$Q(`suggested.cancelEdits`)}):(0,Z.jsx)(J,{type:`button`,variant:`outline`,disabled:r,onClick:()=>o(e),children:$Q(`suggested.edit`)}),(0,Z.jsx)(J,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>void u(e),children:$Q(`suggested.dismiss`)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[d?(0,Z.jsx)(J,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:$Q(`suggested.updateExistingDecision`)}):null,(0,Z.jsx)(J,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]})]})]})})},c$=({projectId:e,suggestions:t,title:n,description:r,emptyState:i=null,onSuggestionsChanged:a})=>{let[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(n$),[f,p]=(0,X.useState)(null);(0,X.useEffect)(()=>{l(e=>e&&!t.some(t=>t.id===e)?null:e),s(e=>e&&!t.some(t=>t.id===e)?null:e)},[t]);let m=o?t.find(e=>e.id===o)??null:null,h=()=>{l(null),d(n$())},g=e=>{s(e.id),l(e.id),d(r$(e))},_=e=>{c&&c!==e.id&&h(),s(e.id)},y=e=>{e||(s(null),c&&h())},b=async(t,n)=>{let r=c===t.id?u:r$(t),i=r.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:i$(r.implications)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:a$(r.stages),priority:r.priority};p(t.id);try{if(n){if(t.kind!==`decision`)throw Error($Q(`messages.onlyDecisionSuggestionsCanUpdate`));let n=t.duplicate_match?.decision;if(!n)throw Error($Q(`messages.noExistingDecision`));await v(e,t.id,n.id,i)}else await H(e,t.id,i);h(),s(null),a?.()}catch(e){Q.error(e instanceof Error?e.message:$Q(`messages.saveSuggestionError`),{id:`project-memory-suggestion-error`})}finally{p(null)}},x=async t=>{p(t.id);try{await pe(e,t.id),c===t.id&&h(),o===t.id&&s(null),a?.()}catch(e){Q.error(e instanceof Error?e.message:$Q(`messages.dismissSuggestionError`),{id:`project-memory-suggestion-error`})}finally{p(null)}};return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[n||r?(0,Z.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,Z.jsxs)(`div`,{children:[n?(0,Z.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:n}):null,r?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}):null]})}):null,t.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,Z.jsx)(o$,{suggestion:e,isPending:f===e.id,onReview:_,onAccept:e=>b(e,!1),onDismiss:x},e.id))}):i?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:i}):null,(0,Z.jsx)(s$,{suggestion:m,isOpen:!!m,isEditing:c===m?.id,isPending:f===m?.id,draft:c===m?.id?u:m?r$(m):u,onOpenChange:y,onStartEdit:g,onDraftChange:d,onCancelEdit:h,onAccept:b,onDismiss:x})]})},l$=()=>({selectedDiffPath:`all`,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}),u$=[{key:`today`,label:`Today`},{key:`yesterday`,label:`Yesterday`},{key:`last_7_days`,label:`Last 7 Days`},{key:`older`,label:`Older`}],d$=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t},f$=e=>e.activity_at??e.last_user_message_at??e.created_at,p$=(e,t)=>{let n=f$(e),r=f$(t);return n===r?e.created_at===t.created_at?t.id.localeCompare(e.id):t.created_at.localeCompare(e.created_at):r.localeCompare(n)},m$=e=>[...e].sort(p$),h$=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),g$=(e,t=new Date)=>{let n=d$(f$(e));if(!n)return`older`;let r=h$(t),i=new Date(r);i.setDate(i.getDate()-1);let a=new Date(r);return a.setDate(a.getDate()-6),n>=r?`today`:n>=i?`yesterday`:n>=a?`last_7_days`:`older`},_$=(e,t=new Date)=>{let n=new Map;for(let r of m$(e)){let e=g$(r,t);n.set(e,[...n.get(e)??[],r])}return u$.flatMap(e=>{let t=n.get(e.key)??[];return t.length===0?[]:[{key:e.key,label:e.label,sessions:t}]})},v$=e=>{let t={...e};return delete t.messages,t.agent_log=null,t.agent_message_id=null,t.previous_agent_log=null,t.previous_agent_message_id=null,t.streaming_response=null,t},y$=(e,t)=>Oe.t(`chatView.${e}`,t),b$=1500,x$=`archon.chat-run-config`,S$=`archon.chat-changes-panel-layout`,C$=`archon.chat-session-list-layout`,w$=`archon.chat-draft`,T$=512,E$=360,D$=.6,O$=6,k$=`.`,A$=`/`,j$=`Slash`,M$=`NumpadDivide`,N$=600,P$=4,F$=(e,t)=>{let n=Number.isFinite(e)?Math.round(e):T$;if(!Number.isFinite(t))return Math.max(E$,n);let r=Math.max(E$,Math.round(t*D$));return Math.max(E$,Math.min(r,n))},I$=e=>y$(e===`claude`?`tool.claude`:`tool.opencode`),L$=({availableModelsById:e,model:t})=>t?e.get(t)??t:null,R$=e=>y$(e===`plan`?`mode.plan`:`mode.build`),z$=e=>y$(e===`plan`?`placeholders.plan`:`placeholders.build`),B$=e=>y$(`pendingMemorySuggestions`,{count:e}),V$=e=>e===`plan`?`build`:`plan`,H$=e=>!e.defaultPrevented&&!e.altKey&&!e.shiftKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&e.key===k$,U$=e=>!e.defaultPrevented&&!e.altKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&(e.key===A$||e.code===j$||e.code===M$),W$=()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgentData?.platform??navigator.platform??navigator.userAgent;return/mac/i.test(e)},G$=()=>W$()?y$(`shortcuts.modifierMac`):y$(`shortcuts.modifierDefault`),K$=({modifierLabel:e,keys:t,ariaHidden:n=!1})=>(0,Z.jsxs)(`span`,{"aria-hidden":n,className:`flex items-center gap-0.5 text-[10px] leading-none`,children:[(0,Z.jsx)(DE,{"aria-hidden":n,children:e}),t.map(e=>(0,Z.jsxs)(`span`,{className:`contents`,children:[(0,Z.jsx)(`span`,{children:`+`}),(0,Z.jsx)(DE,{"aria-hidden":n,children:e})]},e))]}),q$=({label:e,modifierLabel:t,keys:n})=>(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(K$,{modifierLabel:t,keys:n,ariaHidden:!0})]}),J$=({modelLabel:e,tool:t})=>e??I$(t),Y$=()=>y$(`user.you`),X$=e=>{if(!Number.isFinite(e))return`0`;if(e>=1e6){let t=e/1e6,n=t<10?2:1;return`${t.toFixed(n)}M`}return e>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`},Z$=({totalTokens:e,contextWindow:t})=>!Number.isFinite(e)||!Number.isFinite(t)||t<=0?null:Math.round(e/t*100),Q$=({tool:e,model:t,availableModels:n,fallbackContextWindow:r})=>e===`opencode`?(n.find(e=>e.id===t)??null)?.context_window??r:r,$$=({projectId:e,tool:t})=>`${x$}:${e}:${t}`,e1=({projectId:e,tool:t,chatSessionId:n})=>n?`${w$}:${e}:session:${n}`:`${w$}:${e}:draft:${t}`,t1=e=>`${S$}:${e}`,n1=e=>`${C$}:${e}`,r1=e=>{if(!e)return``;try{return window.localStorage.getItem(e)??``}catch{return``}},i1=({storageKey:e,value:t})=>{if(e)try{if(t){window.localStorage.setItem(e,t);return}window.localStorage.removeItem(e)}catch{}},a1=e=>{if(!e)return{isOpen:!0,width:T$};try{let t=window.localStorage.getItem(t1(e));if(!t)return{isOpen:!0,width:T$};let n=JSON.parse(t),r=typeof n.width==`number`&&Number.isFinite(n.width)?Math.max(E$,Math.round(n.width)):T$;return{isOpen:n.isOpen!==!1,width:r}}catch{return{isOpen:!0,width:T$}}},o1=e=>{if(!e)return{isOpen:!0};try{let t=window.localStorage.getItem(n1(e));return t?{isOpen:JSON.parse(t).isOpen!==!1}:{isOpen:!0}}catch{return{isOpen:!0}}},s1=({projectId:e,isOpen:t,width:n})=>{if(e)try{window.localStorage.setItem(t1(e),JSON.stringify({isOpen:t,width:n}))}catch{}},c1=({projectId:e,isOpen:t})=>{if(e)try{window.localStorage.setItem(n1(e),JSON.stringify({isOpen:t}))}catch{}},l1=({projectId:e,tool:t})=>{if(!e||t!==`opencode`)return null;try{let n=window.localStorage.getItem($$({projectId:e,tool:t}));if(!n)return null;let r=JSON.parse(n),i=(typeof r.model==`string`?r.model.trim():``)||null,a=r.mode===`plan`||r.mode===`build`?r.mode:null;return!i&&!a?null:{model:i,variant:i&&typeof r.variant==`string`&&r.variant.trim()||null,mode:a}}catch{return null}},u1=({projectId:e,tool:t,model:n,variant:r,mode:i})=>{if(!(!e||t!==`opencode`||!n&&!i))try{window.localStorage.setItem($$({projectId:e,tool:t}),JSON.stringify({model:n,variant:n?r:null,mode:i}))}catch{}},d1=({projectId:e,tool:t})=>l1({projectId:e,tool:t})?.mode??`plan`,f1=({activeProjectId:e,helperModel:t,helperVariant:n,activeTool:r,availableModels:i})=>{let a=l1({projectId:e,tool:r}),o=new Set(i.map(e=>e.id)),s=e=>e?o.size===0?!0:o.has(e):!1,c=t??``,l=a?.model??``,u=s(l)?l:s(c)?c:``,d=u===l?a?.variant??null:u&&u===c?n??null:null,f=i.find(e=>e.id===u)??null;return{model:u,variant:f?f.variants.includes(d??``)?d??``:``:u?d??``:``,mode:a?.mode??`plan`}},p1=e=>e&&e.replace(/\s+/g,` `).trim()||null,m1=e=>{let t=p1(e.first_user_message_preview);if(t)return t;let n=e.messages?.find(e=>e.role===`user`)?.content;return p1(n)},h1=({chatSessionId:e,instruction:t,attachments:n,createdAt:r})=>({id:`optimistic:${e}:${r}`,chat_session_id:e,role:`user`,kind:`prompt`,content:t,attachments:n,created_at:r}),g1=({session:e,instruction:t,attachments:n,createdAt:r})=>({...e,messages:[...e.messages??[],h1({chatSessionId:e.id,instruction:t,attachments:n,createdAt:r})],activity_at:r,last_user_message_at:r,updated_at:r}),_1=e=>!!(e.first_user_message_preview||e.last_user_message_at||e.messages?.some(e=>e.role===`user`)),v1=({activeProject:e,activeProjectBranchState:t,session:n})=>!e||n.target_available===!1?!1:n.target_kind===`bundle`?e.active_target_kind===`bundle`&&!!n.target_bundle_id&&e.active_target_bundle_id===n.target_bundle_id:e.active_target_kind===`bundle`?!1:!t||!n.target_branch_snapshot?!0:t?.status!==`ready`||!t.branch?!1:t.branch===n.target_branch_snapshot,y1=({session:e,activeProject:t,activeProjectBranchState:n})=>e.target_kind===`bundle`?e.target_label_snapshot||y$(`targets.bundleFallback`):!t||t.active_target_kind===`bundle`||n?.status!==`ready`||!n.branch||!e.target_branch_snapshot||n.branch===e.target_branch_snapshot?null:y$(`targets.repoRootWithBranch`,{branch:e.target_branch_snapshot}),b1=e=>e.target_kind===`bundle`?e.target_label_snapshot||y$(`targets.bundleFallback`):e.target_branch_snapshot?y$(`targets.repoRootWithBranch`,{branch:e.target_branch_snapshot}):y$(`targets.repoRoot`),x1=({activeProject:e,activeProjectBranchState:t})=>e?e.active_target_kind===`bundle`?y$(`targets.selectedBundleTarget`):t?.branch?y$(`targets.repoRootWithBranch`,{branch:t.branch}):y$(`targets.repoRoot`):y$(`targets.currentTarget`),S1=e=>e.agent_status===`running`?y$(`sidebar.deleteDisabledReason`):null,C1=({count:e,title:t,isDeleting:n,onConfirm:r,onCancel:i})=>{let a=e>1;return(0,Z.jsxs)(Af,{onClose:i,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:y$(a?`deleteSessionModal.bulkTitle`:`deleteSessionModal.title`)}),t?(0,Z.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:t}):null,(0,Z.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:a?y$(`deleteSessionModal.bulkDescription`,{count:e}):y$(`deleteSessionModal.description`)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(J,{type:`button`,variant:`ghost`,onClick:i,disabled:n,children:y$(`deleteSessionModal.cancel`)}),(0,Z.jsx)(J,{type:`button`,variant:`destructive`,onClick:r,disabled:n,children:y$(n?`deleteSessionModal.deleting`:`deleteSessionModal.delete`)})]})]})},w1=({activeProject:e,activeProjectBranchState:t,activeSessionId:n,chatModeShortcutModifierLabel:r,deletingSessionIds:i,finishedBackgroundSessionIds:a,hasDeletableSessions:o,isCreatingSession:s,isSelectionMode:c,isDraftOpen:l,isLoadingSessions:u,isOpen:d,isSendingPrompt:f,selectedSessionCount:p,selectedSessionIds:m,sessionGroups:h,sessions:g,onConfirmDeleteSelectedSessions:_,onConfirmDeleteSession:v,onDraftOpen:y,onEnterSelectionMode:b,onExitSelectionMode:x,onSetSessionSelection:S,onSessionSelect:C,onToggleSessionSelection:w,onToggleOpen:T})=>{let E=(0,X.useMemo)(()=>new Set(g.filter(e=>!S1(e)&&!i.has(e.id)).map(e=>e.id)),[i,g]),D=(0,X.useRef)(null),O=(0,X.useRef)(!1),k=(0,X.useRef)(null),A=(0,X.useCallback)(()=>{k.current!==null&&(window.clearTimeout(k.current),k.current=null)},[]),j=(0,X.useCallback)(()=>{A(),k.current=window.setTimeout(()=>{O.current=!1,k.current=null},0)},[A]),M=(0,X.useCallback)(()=>{D.current&&(D.current=null,j())},[j]),N=(0,X.useCallback)(e=>{let t=D.current;!t||t.visitedSessionIds.has(e)||!E.has(e)||(t.visitedSessionIds.add(e),S(e,t.mode===`select`))},[S,E]),P=(0,X.useCallback)(e=>{let t=D.current;!t||e.pointerId!==t.pointerId||M()},[M]);return(0,X.useEffect)(()=>{if(!c){M();return}return window.addEventListener(`pointerup`,P),window.addEventListener(`pointercancel`,P),()=>{window.removeEventListener(`pointerup`,P),window.removeEventListener(`pointercancel`,P),M(),A()}},[A,P,c,M]),(0,Z.jsx)(`aside`,{"data-testid":`chat-sessions-sidebar`,"data-state":d?`expanded`:`collapsed`,"aria-label":y$(`sidebar.ariaLabel`),className:W(`relative z-20 flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background/40 transition-[width] duration-200 ease-out motion-reduce:transition-none`,d?`w-72`:`w-16`),children:d?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-start gap-2 border-b border-border/70 px-4 py-3.5`,children:[(0,Z.jsxs)(J,{type:`button`,size:`sm`,className:`gap-2`,onClick:y,disabled:s||f,children:[(0,Z.jsx)(tf,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:y$(`sidebar.newSession`)}),(0,Z.jsx)(K$,{modifierLabel:r,keys:[A$],ariaHidden:!0})]}),(0,Z.jsx)(J,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":y$(`sidebar.collapseAriaLabel`),"aria-expanded":d,className:`ml-auto`,onClick:T,children:(0,Z.jsx)(jQ,{className:`h-4 w-4`})})]}),g.length>0?(0,Z.jsx)(`div`,{className:`px-4 py-2.5`,children:c?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:x,disabled:i.size>0,children:y$(`sidebar.cancelSelection`)}),(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`destructive`,className:`h-7 px-2 text-xs`,onClick:_,disabled:p===0||i.size>0,children:y$(`sidebar.deleteSelected`)})]}),(0,Z.jsx)(`div`,{className:`flex justify-end text-xs font-medium text-muted-foreground`,children:y$(`sidebar.selectedCount`,{count:p})})]}):o?(0,Z.jsxs)(J,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 gap-1.5 px-2 text-xs`,onClick:b,children:[(0,Z.jsx)(AQ,{className:`h-3.5 w-3.5`}),y$(`sidebar.select`)]}):null}):null,(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:u&&g.length===0?(0,Z.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground`,children:y$(`sidebar.loadingSessions`)}):g.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:y$(`sidebar.noSessions`)}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:h.map(r=>(0,Z.jsxs)(`section`,{"aria-label":r.label,className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`div`,{className:`px-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/80`,children:r.label}),r.sessions.map(r=>{let o=!l&&r.id===n,s=m1(r),u=y1({session:r,activeProject:e,activeProjectBranchState:t}),d=S1(r),f=i.has(r.id),p=!!d||f,h=m.has(r.id),g=r.agent_status===`running`?`running`:r.agent_status===`stopped`?`interrupted`:!o&&a.has(r.id)?`finished`:null,_=g===`interrupted`?null:g;return(0,Z.jsxs)(`div`,{"data-chat-session-id":r.id,"data-chat-session-selectable":p?`false`:`true`,className:W(`group relative rounded-xl border transition-colors`,o?`border-sky-400/40 bg-sky-500/10 text-foreground ring-1 ring-sky-400/40`:`border-border/50 bg-card/35 text-muted-foreground hover:border-border/80 hover:bg-card/60 hover:text-foreground`),onPointerDownCapture:e=>{!c||p||e.pointerType&&e.pointerType!==`mouse`||typeof e.button==`number`&&e.button!==0||(e.preventDefault(),A(),O.current=!0,D.current={pointerId:e.pointerId,mode:h?`deselect`:`select`,visitedSessionIds:new Set},N(r.id))},onPointerMove:e=>{let t=D.current;!t||t.pointerId!==e.pointerId||N(r.id)},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":[r.title,R$(r.mode),I$(r.tool),e?.memory_enabled&&r.pending_memory_suggestion_count>0?B$(r.pending_memory_suggestion_count):null,g===`running`?y$(`sidebar.running`):g===`interrupted`?y$(`sidebar.interrupted`):g===`finished`?y$(`sidebar.finished`):null].filter(Boolean).join(` `),className:`flex w-full min-w-0 cursor-pointer items-start gap-2 rounded-xl px-3 py-2 pr-11 text-left transition-colors focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none`,onClick:()=>{if(c){if(O.current){O.current=!1;return}if(p)return;w(r.id);return}C(r)},children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[u?(0,Z.jsx)(`div`,{className:`mb-1 truncate text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75`,children:u}):null,(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-[13px] font-medium leading-5`,children:r.title}),e?.memory_enabled&&r.pending_memory_suggestion_count>0?(0,Z.jsx)(QQ,{tone:o?`default`:`muted`,className:`shrink-0`,"aria-label":B$(r.pending_memory_suggestion_count),title:B$(r.pending_memory_suggestion_count),children:r.pending_memory_suggestion_count}):null]}),s?(0,Z.jsx)(`div`,{className:W(`mt-0.5 line-clamp-1 text-xs leading-4`,o?`text-foreground/70`:`text-muted-foreground`),children:s}):null,r.target_available===!1?(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-1 text-[11px] leading-4 text-amber-200/90`,children:r.target_unavailable_reason??y$(`sidebar.targetUnavailable`)}):null]}),(0,Z.jsx)(ef,{state:_,className:`mt-1`})]})}),c?(0,Z.jsx)(`div`,{className:`absolute top-2 right-2 flex h-7 w-7 items-center justify-center`,title:d??y$(`sidebar.selectSessionTitle`,{title:r.title}),children:(0,Z.jsx)(`input`,{type:`checkbox`,"aria-label":y$(`sidebar.selectSessionAriaLabel`,{title:r.title}),checked:h,disabled:p,onClick:e=>{e.stopPropagation()},onChange:()=>{O.current||w(r.id)},className:`h-4 w-4 rounded border-border bg-background text-primary`})}):(0,Z.jsx)(J,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":y$(`sidebar.deleteSessionAriaLabel`),className:W(`absolute top-2 right-2 h-7 w-7 shrink-0 rounded-md border border-transparent text-muted-foreground transition-all duration-150 hover:border-border/70 hover:bg-card/80 hover:text-foreground focus-visible:border-border/70 focus-visible:bg-card/80 focus-visible:text-foreground`,`opacity-100 sm:opacity-0 sm:pointer-events-none sm:group-hover:pointer-events-auto sm:group-focus-within:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,p&&`sm:disabled:opacity-0 sm:group-hover:disabled:opacity-50 sm:group-focus-within:disabled:opacity-50`,(o||f)&&`sm:pointer-events-auto sm:opacity-100 sm:disabled:opacity-50`,d&&`cursor-not-allowed text-muted-foreground/50 hover:border-transparent hover:bg-transparent hover:text-muted-foreground/50 focus-visible:border-transparent focus-visible:bg-transparent focus-visible:text-muted-foreground/50`),title:d??y$(`sidebar.deleteSessionTitle`,{title:r.title}),disabled:p,onClick:e=>{e.stopPropagation(),v(r.id)},children:(0,Z.jsx)(Vf,{className:`h-4 w-4`})})]},r.id)})]},r.key))})})]}):(0,Z.jsxs)(`div`,{"data-testid":`chat-sessions-rail`,className:`flex h-full w-full flex-col items-center gap-2 bg-background/80 py-3`,children:[(0,Z.jsx)(Lu,{content:(0,Z.jsx)(q$,{label:y$(`shortcuts.startNewSession`),modifierLabel:r,keys:[A$]}),side:`right`,children:(0,Z.jsx)(J,{type:`button`,size:`icon-sm`,"aria-label":y$(`sidebar.newSession`),className:`h-9 w-9`,onClick:y,disabled:s||f,children:(0,Z.jsx)(tf,{className:`h-4 w-4`})})}),(0,Z.jsx)(J,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":y$(`sidebar.openAriaLabel`),"aria-expanded":d,className:`h-9 w-9`,onClick:T,children:(0,Z.jsx)(MQ,{className:`h-4 w-4`})})]})})},T1=({proposals:e,isApplying:t,onApply:n})=>e.status===`applied`?(0,Z.jsxs)(`div`,{className:`w-full rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-3 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:y$(`ticketProposal.createdTitle`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:y$(`ticketProposal.createdDescription`,{count:e.created_tickets.length})}),e.created_tickets.length>0?(0,Z.jsx)(`ul`,{className:`mt-3 space-y-1 text-foreground`,children:e.created_tickets.map(e=>(0,Z.jsx)(`li`,{children:e.title},e.ticket_id))}):null]}):(0,Z.jsxs)(`div`,{className:`w-full rounded-md border border-sky-500/30 bg-sky-500/10 px-3 py-3 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:y$(`ticketProposal.proposedTitle`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:y$(`ticketProposal.proposedDescription`)}),(0,Z.jsx)(`ul`,{className:`mt-3 space-y-3`,children:e.tickets.map(e=>(0,Z.jsxs)(`li`,{className:`rounded border border-border/60 bg-background/80 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap text-muted-foreground`,children:e.description})]},e.key))}),e.dependencies.length>0?(0,Z.jsx)(`div`,{className:`mt-3 text-muted-foreground`,children:y$(`ticketProposal.dependenciesLabel`,{value:e.dependencies.map(e=>`${e.blocker_key} -> ${e.dependent_key}`).join(`, `)})}):null,(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(J,{type:`button`,size:`sm`,onClick:n,disabled:t,children:y$(t?`ticketProposal.creating`:`ticketProposal.create`)})})]}),E1=({activeProjectId:e,activeProject:t,activeProjectBranchState:n=null,activeTool:r,onRestoreSessionTarget:i,onReviewCapabilityChange:a,isExternallyResizing:o=!1,showChangesPanel:s=!0})=>{let c=WZ(),[l,u]=(0,X.useState)([]),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(()=>d1({projectId:e,tool:r})),[x,S]=(0,X.useState)({}),[C,w]=(0,X.useState)({}),[T,E]=(0,X.useState)({}),[D,O]=(0,X.useState)([]),[A,j]=(0,X.useState)([]),[M,N]=(0,X.useState)(``),[P,F]=(0,X.useState)(``),[I,L]=(0,X.useState)([]),[R,z]=(0,X.useState)(!1),[B,V]=(0,X.useState)(!1),[ee,te]=(0,X.useState)(!1),[H,ne]=(0,X.useState)(!1),[U,re]=(0,X.useState)(!1),[ie,ae]=(0,X.useState)(null),[oe,se]=(0,X.useState)([]),[ce,le]=(0,X.useState)(()=>new Set),[ue,de]=(0,X.useState)(!1),[fe,pe]=(0,X.useState)(()=>new Set),[me,G]=(0,X.useState)(!1),[he,ge]=(0,X.useState)(!1),[_e,ve]=(0,X.useState)(null),[be,xe]=(0,X.useState)([]),[Se,Ce]=(0,X.useState)(!1),[we,K]=(0,X.useState)(!1),[Te,Ee]=(0,X.useState)(0),[Oe,ke]=(0,X.useState)(l$),[Ae,je]=(0,X.useState)(()=>o1(e).isOpen),[Me,Ne]=(0,X.useState)(()=>a1(e).isOpen),[Pe,Fe]=(0,X.useState)(!1),[Ie,Le]=(0,X.useState)(!1),[Re,q]=(0,X.useState)(()=>a1(e).width),[ze,Be]=(0,X.useState)(0),[Ve,He]=(0,X.useState)(null),[Ue,We]=(0,X.useState)(()=>new Set),Ge=(0,X.useRef)({model:``,variant:``,skills:[],showModelSelector:!1}),Ke=(0,X.useRef)(!1),qe=(0,X.useRef)(null),Je=(0,X.useRef)(0),Ye=(0,X.useRef)(0),Xe=(0,X.useRef)(null),Ze=(0,X.useRef)(null),Y=(0,X.useRef)(null),Qe=(0,X.useRef)(null),$e=(0,X.useRef)(null),et=(0,X.useRef)(null),tt=(0,X.useRef)(!1),nt=(0,X.useRef)(!1),rt=(0,X.useRef)(0),it=(0,X.useRef)(T$),at=(0,X.useRef)(T$),ot=(0,X.useRef)(!1),st=(0,X.useRef)(0),ct=(0,X.useRef)({id:null,status:null}),lt=(0,X.useRef)(new Map),ut=(0,X.useRef)({}),dt=(0,X.useRef)({}),ft=(0,X.useRef)(new Set),pt=(0,X.useRef)(!1),mt=e?e1({projectId:e,tool:_?r:p?.tool??r,chatSessionId:_?null:d}):null,ht=mt?x[mt]??``:``,gt=_?r:p?.tool??r,_t=p?C[p.id]??[]:[],vt=(p?T[p.id]??0:0)>0;(0,X.useEffect)(()=>{Ke.current=_},[_]),(0,X.useEffect)(()=>{ut.current=x},[x]),(0,X.useEffect)(()=>{dt.current=C},[C]),(0,X.useEffect)(()=>{if(!mt||ft.current.has(mt))return;ft.current.add(mt);let e=r1(mt);e&&S(t=>Object.prototype.hasOwnProperty.call(t,mt)?t:{...t,[mt]:e})},[mt]),(0,X.useEffect)(()=>{!mt||!Object.prototype.hasOwnProperty.call(x,mt)||i1({storageKey:mt,value:x[mt]??``})},[mt,x]),(0,X.useEffect)(()=>{qe.current=d},[d]);let yt=(0,X.useCallback)(()=>{Ye.current+=1},[]),bt=(0,X.useCallback)(e=>{yt(),m(e)},[yt]);(0,X.useEffect)(()=>{if(!pt.current){pt.current=!0;return}let t=a1(e),n=o1(e);Ke.current=!1,ot.current=!1,ft.current=new Set,f(null),bt(null),v(!1),S({}),w({}),E({}),ae(null),se([]),le(new Set),de(!1),pe(new Set),He(null),xe([]),K(!1),V(!1),ke(l$()),We(new Set),lt.current=new Map,at.current=t.width,je(n.isOpen),q(t.width),Ne(t.isOpen)},[e,bt]),(0,X.useEffect)(()=>{Pe||(at.current=Re,Y.current&&(Y.current.style.setProperty(`--chat-changes-panel-width`,`${Re}px`),Y.current.setAttribute(`data-desktop-width`,String(Re))))},[Re,Pe]),(0,X.useEffect)(()=>{if(!s||!Xe.current)return;let e=Xe.current.getBoundingClientRect().width;if(e<=0)return;let t=F$(Re,e);t!==Re&&(at.current=t,q(t))},[Re,s]),(0,X.useEffect)(()=>{c1({projectId:e,isOpen:Ae})},[e,Ae]),(0,X.useEffect)(()=>{s&&s1({projectId:e,isOpen:Me,width:Re})},[e,Re,Me,s]),(0,X.useEffect)(()=>{K(!1)},[d,_]);let xt=(0,X.useCallback)(e=>{let t=v$(e);u(e=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return m$([...e,t]);let r=[...e];return r[n]=t,m$(r)})},[]),St=(0,X.useCallback)(t=>{let n=Array.from(new Set(t));if(n.length===0)return;let i=new Set(n),a=qe.current,o=e?n.map(t=>e1({projectId:e,tool:r,chatSessionId:t})):[];S(e=>{let t=o.filter(t=>Object.prototype.hasOwnProperty.call(e,t));if(t.length===0)return e;let n={...e};for(let e of t)delete n[e];return n}),w(e=>{let t={...e},r=!1;for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(delete t[e],r=!0);return r?t:e}),E(e=>{let t={...e},r=!1;for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(delete t[e],r=!0);return r?t:e});for(let e of o)i1({storageKey:e,value:``});u(e=>{let t=e.filter(e=>!i.has(e.id));if(a&&i.has(a)){let e=t[0]??null;f(e?.id??null),bt(null),v(e===null),xe([]),Ce(!1),K(!1)}return t}),We(e=>{let t=new Set(e),r=!1;for(let e of n)t.delete(e)&&(r=!0);return r?t:e}),He(e=>e?.sessionId&&i.has(e.sessionId)?null:e),ae(e=>e&&i.has(e)?null:e),se(e=>e.filter(e=>!i.has(e))),le(e=>{let t=new Set(e),r=!1;for(let e of n)t.delete(e)&&(r=!0);return r?t:e}),pe(e=>{let t=new Set(e),r=!1;for(let e of n)t.delete(e)&&(r=!0);return r?t:e})},[e,r,bt]),Ct=(0,X.useCallback)(e=>{St([e])},[St]),wt=(0,X.useCallback)((e,t)=>{e&&S(n=>n[e]===t?n:{...n,[e]:t})},[]),Tt=(0,X.useCallback)(e=>{e&&(S(t=>t[e]===``?t:{...t,[e]:``}),i1({storageKey:e,value:``}))},[]),Et=(0,X.useCallback)((e,t)=>{w(n=>{if(t.length===0){if(!Object.prototype.hasOwnProperty.call(n,e))return n;let t={...n};return delete t[e],t}return{...n,[e]:t}})},[]),Dt=(0,X.useCallback)(e=>{w(t=>{if(!Object.prototype.hasOwnProperty.call(t,e))return t;let n={...t};return delete n[e],n}),E(t=>{if(!Object.prototype.hasOwnProperty.call(t,e))return t;let n={...t};return delete n[e],n})},[]),Ot=(0,X.useCallback)((e,t)=>{E(n=>{let r=Math.max(0,(n[e]??0)+t);if(r===0){if(!Object.prototype.hasOwnProperty.call(n,e))return n;let t={...n};return delete t[e],t}return{...n,[e]:r}})},[]),kt=(0,X.useCallback)(({fromStorageKey:e,toStorageKey:t})=>{if(!e||!t||e===t)return;let n=Object.prototype.hasOwnProperty.call(ut.current,e)?ut.current[e]??``:r1(e);S(r=>{let i={...r,[t]:n};return delete i[e],i}),i1({storageKey:t,value:n}),i1({storageKey:e,value:``})},[]),At=(0,X.useCallback)((e,t)=>{u(n=>{let r=n.findIndex(t=>t.id===e);if(r===-1)return n;let i=n[r];if(i.pending_memory_suggestion_count===t)return n;let a=[...n];return a[r]={...i,pending_memory_suggestion_count:t},a}),m(n=>!n||n.id!==e||n.pending_memory_suggestion_count===t?n:(Ye.current+=1,{...n,pending_memory_suggestion_count:t}))},[]),jt=(0,X.useCallback)(async r=>{if(!e){u([]),f(null),bt(null),v(!1),V(!1);return}z(!0);try{let i=await lC(e,r);if(r?.aborted)return;let a=m$(i.map(v$)),o=a[0]??null,s=t?.active_target_kind===`bundle`||n?.status!==`loading`;u(a),f(e=>Ke.current?null:e&&a.some(t=>t.id===e)?e:e?a[0]?.id??null:ot.current?null:o?s?(ot.current=!0,v1({activeProject:t,activeProjectBranchState:n,session:o})?o.id:null):null:(ot.current=!0,null)),a.length===0&&v(!0)}catch(e){k(e)||Q.error(e instanceof Error?e.message:y$(`errors.loadSessions`))}finally{r?.aborted||(z(!1),V(!0))}},[t,n,e,bt]),Mt=(0,X.useCallback)(async(t,n)=>{if(!e){bt(null);return}te(!0);let r=Je.current+1;Je.current=r;let i=Ye.current;try{let a=await dC(e,t,n);if(n?.aborted)return;let o=Ye.current!==i,s=Je.current===r,c=qe.current===t&&!Ke.current;if(!s||o||!c)return;bt(a),xt(a)}catch(e){k(e)||Q.error(e instanceof Error?e.message:y$(`errors.loadSession`))}finally{n?.aborted||te(!1)}},[e,bt,xt]),Nt=(0,X.useCallback)(async(n,r)=>{if(!e||!t?.memory_enabled){xe([]),Ce(!1);return}Ce(!0);try{let t=await De(e,null,r,n);if(r?.aborted)return;xe(t.suggestions),At(n,t.suggestions.length)}catch(e){k(e)||Q.error(e instanceof Error?e.message:y$(`errors.loadMemorySuggestions`))}finally{r?.aborted||Ce(!1)}},[t?.memory_enabled,e,At]),Pt=(0,X.useCallback)(()=>{xe(e=>{let t=e.length>0?e.slice(0,-1):e;return d&&At(d,t.length),t}),Ee(e=>e+1),jt(),d&&Mt(d)},[d,Mt,jt,At]);(0,X.useEffect)(()=>{let e=new AbortController;return jt(e.signal),()=>{e.abort()}},[jt]),(0,X.useEffect)(()=>{if(Ke.current||_||d||ot.current||l.length===0||t?.active_target_kind!==`bundle`&&n?.status===`loading`)return;ot.current=!0;let e=l[0]??null;e&&v1({activeProject:t,activeProjectBranchState:n,session:e})&&f(e.id)},[t,n,d,_,l]),(0,X.useEffect)(()=>{if(gt!==`opencode`){O([]),j([]),ge(!1);return}let t=new AbortController;return(async()=>{ge(!0);try{let[n,r]=await Promise.all([yn(gt,t.signal),OE(gt,t.signal,e)]);O(n),j(r)}catch(e){k(e)||(O(e=>e),j(e=>e))}finally{t.signal.aborted||ge(!1)}})(),()=>{t.abort()}},[e,gt]),(0,X.useEffect)(()=>{if(_||!d){bt(null);return}if(p?.id===d)return;bt(null);let e=new AbortController;return Mt(d,e.signal),()=>{e.abort()}},[p,d,_,Mt,bt]),(0,X.useEffect)(()=>{if(!t?.memory_enabled||_||!d){xe([]),Ce(!1);return}let e=new AbortController;return Nt(d,e.signal),()=>{e.abort()}},[t?.memory_enabled,d,_,Nt,Te]),(0,X.useEffect)(()=>{!we||Se||be.length>0||K(!1)},[Se,we,be.length]),(0,X.useEffect)(()=>{if(!d||p?.agent_status!==`running`)return;let e=new AbortController,t=window.setInterval(()=>{Promise.all([jt(e.signal),Mt(d,e.signal)])},b$);return()=>{e.abort(),window.clearInterval(t)}},[p?.agent_status,d,Mt,jt]),(0,X.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||(t.id===d&&bt(t),_1(t)&&xt(t))},n=t=>{!t||t.project_id!==e||Ct(t.id)};return c.on(`chat-session:created`,t),c.on(`chat-session:updated`,t),c.on(`chat-session:deleted`,n),()=>{c.off(`chat-session:created`,t),c.off(`chat-session:updated`,t),c.off(`chat-session:deleted`,n)}},[e,d,Ct,bt,c,xt]),(0,X.useEffect)(()=>{_&&b(d1({projectId:e,tool:r}))},[e,r,_]),(0,X.useEffect)(()=>{if(gt!==`opencode`){N(``),F(``),L([]);return}if(_){let n=f1({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:gt,availableModels:D});N(n.model),F(n.variant),L([]);return}N(p?.model??t?.helper_model??``),F(p?.variant??t?.helper_variant??``),L(p?.skills??[])},[e,t?.helper_model,t?.helper_variant,p?.id,p?.model,p?.skills,p?.variant,D,gt,_]),(0,X.useEffect)(()=>{let e=D.find(e=>e.id===M)??null;F(t=>e?e.variants.includes(t)?t:``:t)},[D,M]),(0,X.useEffect)(()=>{if(gt!==`opencode`||!_||!M||P)return;let n=f1({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:gt,availableModels:D});n.model===M&&n.variant&&F(n.variant)},[e,t?.helper_model,t?.helper_variant,gt,D,_,M,P]),(0,X.useEffect)(()=>{if(!ie)return;let e=p?.id===ie?p:l.find(e=>e.id===ie)??null;(!e||e.agent_status!==`running`)&&ae(null)},[p,ie,l]),(0,X.useEffect)(()=>{let e=ct.current,n=p?.id??null,r=p?.agent_status??null;e.id===n&&e.status===`running`&&r===`done`&&t?.memory_enabled&&n&&Ee(e=>e+1),ct.current={id:n,status:r}},[t?.memory_enabled,e,p?.agent_status,p?.id,p?.title]),(0,X.useEffect)(()=>{d&&We(e=>{if(!e.has(d))return e;let t=new Set(e);return t.delete(d),t})},[d]),(0,X.useEffect)(()=>{Ve&&Ve.sessionId!==d&&He(null)},[d,Ve]),(0,X.useEffect)(()=>{let e=lt.current,t=new Map,n=[];for(let r of l){let i=e.get(r.id)??null,a=r.agent_status??null;i===`running`&&a===`done`&&r.id!==d&&n.push(r),t.set(r.id,a)}lt.current=t,We(e=>{let t=new Set(e),r=!1,i=new Set(l.map(e=>e.id));for(let e of t)i.has(e)||(t.delete(e),r=!0);for(let e of l){let i=e.agent_status??null,a=n.some(t=>t.id===e.id);if((e.id===d||i!==`done`)&&t.delete(e.id)){r=!0;continue}a&&!t.has(e.id)&&(t.add(e.id),r=!0)}return r?t:e})},[e,d,l]);let Ft=(0,X.useMemo)(()=>new Map(D.map(e=>[e.id,e.label])),[D]),It=(0,X.useMemo)(()=>_$(l),[l]),Lt=(0,X.useMemo)(()=>oe.length===0?[]:oe.flatMap(e=>{let t=l.find(t=>t.id===e)??(p?.id===e?p:null);return t?[t]:[]}),[p,oe,l]),Rt=Lt.length===1?Lt[0]?.title??null:null;(0,X.useEffect)(()=>{oe.length>0&&Lt.length!==oe.length&&se(Lt.map(e=>e.id))},[oe,Lt]),(0,X.useEffect)(()=>{let e=new Set(l.filter(e=>!S1(e)&&!ce.has(e.id)).map(e=>e.id));pe(t=>{let n=new Set(Array.from(t).filter(t=>e.has(t)));return n.size===t.size?t:n})},[ce,l]),(0,X.useEffect)(()=>{!ue||Ae||(de(!1),pe(new Set))},[Ae,ue]);let zt=(0,X.useMemo)(()=>p?J$({modelLabel:L$({availableModelsById:Ft,model:p.model}),tool:p.tool}):null,[p,Ft]),Bt=(0,X.useMemo)(()=>p?(p.messages??[]).map(e=>({id:e.id,role:e.role,kind:e.kind,content:e.content,attachments:e.attachments??[],ticket_proposals:e.ticket_proposals??null,created_at:e.created_at,displayTitle:e.role===`assistant`?zt??I$(p.tool):Y$()})):[],[p,zt]),Vt=p?.id&&p.agent_status===`running`&&Ve?.sessionId===p.id?Ve.turnKey:null,Ht=gt===`opencode`&&D.length>0,Ut=gt===`opencode`&&!Ht&&he;(0,X.useEffect)(()=>{Ge.current={model:M,variant:P,skills:I,showModelSelector:Ht}},[M,I,P,Ht]);let Wt=(0,X.useMemo)(()=>D.find(e=>e.id===M)??null,[D,M]),Gt=_?y:p?.mode??`build`,Kt=_?y$(`composer.newChatTitle`):p?.title??y$(`composer.chatTitle`),qt=_?r:p?.tool??r,Jt=(0,X.useMemo)(()=>G$(),[]),Yt=Ht?M||null:p?.model??null,Xt=qt===`opencode`,Zt=L$({availableModelsById:Ft,model:Yt}),Qt=(0,X.useMemo)(()=>{let e=p?.usage_snapshot_total_tokens??null;if(e===null)return null;let t=Q$({tool:qt,model:Yt,availableModels:D,fallbackContextWindow:p?.usage_snapshot_context_window??null});if(t===null)return null;let n=Z$({totalTokens:e,contextWindow:t});return n===null?null:`${X$(e)} (${n}%)`},[p?.usage_snapshot_context_window,p?.usage_snapshot_total_tokens,D,Yt,qt]),$t=_?`draft:${e??`none`}:${r}`:p?.id,en=(0,X.useCallback)(()=>{Ke.current=!0,v(!0),b(d1({projectId:e,tool:r})),g(null),f(null),bt(null),ae(null),de(!1),pe(new Set),He(null)},[e,r,bt]),tn=(0,X.useCallback)((e,t=null)=>{Ke.current=!1,v(!1),g(null),f(e),bt(t)},[bt]),nn=(0,X.useCallback)(async()=>{if(!(!p||!i)){g(p.id);try{await i(p)}catch(e){Q.error(e instanceof Error?e.message:y$(`errors.restoreTarget`))}finally{g(e=>e===p.id?null:e)}}},[p,i]),rn=!!(p&&p.target_available!==!1&&!_&&!v1({activeProject:t,activeProjectBranchState:n,session:p})),an=rn&&p?y$(`review.mismatchReason`,{sessionTarget:b1(p),currentTarget:x1({activeProject:t,activeProjectBranchState:n})}):null,on=rn&&h===null,sn=(0,X.useCallback)(async r=>{g(r.id);let a=r;if(e)try{let t=await dC(e,r.id);a=t,xt(t)}catch(e){Q.error(e instanceof Error?e.message:y$(`errors.loadSession`)),g(e=>e===r.id?null:e);return}if(a.target_available===!1){tn(a.id,a);return}if(!v1({activeProject:t,activeProjectBranchState:n,session:a})&&i)try{if(!await i(a)){g(e=>e===a.id?null:e);return}}catch(e){Q.error(e instanceof Error?e.message:y$(`errors.restoreTarget`)),g(e=>e===a.id?null:e);return}tn(a.id,a)},[t,n,e,i,tn,xt]),cn=(0,X.useCallback)(()=>{Be(e=>e+1)},[]),ln=(0,X.useCallback)(async t=>{if(_){let n=Ge.current;b(t),u1({projectId:e,tool:r,model:n.showModelSelector&&n.model||null,variant:n.showModelSelector&&n.model&&n.variant||null,mode:t}),cn();return}if(!(!e||!p||p.mode===t||me)){G(!0);try{let n=await fC(e,p.id,{mode:t});u1({projectId:e,tool:n.tool,model:n.model,variant:n.variant,mode:n.mode}),bt(n),xt(n),cn()}catch(e){Q.error(e instanceof Error?e.message:y$(`errors.updateMode`))}finally{G(!1)}}},[e,p,r,cn,_,me,bt,xt]),un=(0,X.useCallback)(async({instruction:t,attachments:n,targetSession:r})=>{if(!e)return null;let i=Ge.current;st.current+=1;let a={sessionId:r.id,turnKey:`${r.id}:${st.current}`};He(a);try{let a=await pC(e,r.id,{instruction:t,...n.length>0?{attachment_ids:n.map(e=>e.id)}:{},tool:r.tool,model:i.showModelSelector&&i.model||null,variant:i.showModelSelector&&i.model&&i.variant||null,skills:i.showModelSelector?i.skills:[]});return u1({projectId:e,tool:a.tool,model:a.model,variant:a.variant,mode:a.mode}),Ke.current=!1,bt(a),f(a.id),v(!1),xt(a),a}catch(e){throw He(e=>e?.turnKey===a.turnKey?null:e),e}},[e,bt,xt]),dn=(0,X.useCallback)(async({fromStorageKey:t})=>{if(!e)return null;let n=Ge.current,i=await uC(e,{mode:Gt,tool:r,model:n.showModelSelector&&n.model||null,variant:n.showModelSelector&&n.model&&n.variant||null,skills:n.showModelSelector?n.skills:[]});Ke.current=!1,v(!1),f(i.id),bt(i);let a=e1({projectId:e,tool:i.tool,chatSessionId:i.id});return kt({fromStorageKey:t,toStorageKey:a}),{session:i,storageKey:a}},[e,r,Gt,kt,bt]),fn=(0,X.useCallback)(async t=>{if(!e||U||H||vt||p?.agent_status===`running`||p?.target_available===!1||on)return!1;let n=t.trim(),r=p?dt.current[p.id]??[]:[];if(!n&&r.length===0)return!1;re(!0);let i=null,a=p,o=e&&p?e1({projectId:e,tool:p.tool,chatSessionId:p.id}):null,s=r;try{let t=p;if(!t){ne(!0);let e=await dn({fromStorageKey:mt});i=e?.session??null,t=i,o=e?.storageKey??null,s=i?dt.current[i.id]??[]:[]}if(!t)return!1;Tt(o??mt);let r=g1({session:t,instruction:n,attachments:s,createdAt:new Date().toISOString()});bt(r),f(r.id),xt(r);let a=await un({instruction:n,attachments:s,targetSession:t});return Tt(a&&e?e1({projectId:e,tool:a.tool,chatSessionId:a.id}):o),a&&Dt(a.id),!0}catch(e){throw wt(o??mt,n),i?(bt(i),f(i.id),v(!1),xt(i)):a&&(bt(a),xt(a)),e}finally{ne(!1),re(!1)}},[e,p,Dt,Tt,dn,mt,H,U,vt,bt,un,wt,on,xt]),pn=(0,X.useCallback)(e=>{Ke.current=!0,v(!0),b(e),g(null),f(null),bt(null),ae(null),He(null)},[bt]),mn=(0,X.useCallback)(async t=>{if(!e||t.length===0||gt!==`opencode`)return;let n=t.slice(0,P$);if(n.length===0)return;let r=null,i=p;try{if(i||=(ne(!0),r=await dn({fromStorageKey:mt}),r?.session??null),!i)return;if((dt.current[i.id]??[]).length+n.length>P$){Q.error(`You can attach up to 4 images per turn.`);return}Ot(i.id,1);let t=await mC(e,i.id,n),a=dt.current[i.id]??[];Et(i.id,[...a,...t.attachments])}catch(t){if(r&&!ht.trim())try{await _C(e,r.session.id),Ct(r.session.id),pn(r.session.mode)}catch{}Q.error(t instanceof Error?t.message:y$(`errors.uploadAttachments`))}finally{i&&Ot(i.id,-1),ne(!1)}},[e,p,dn,ht,mt,Ot,pn,Ct,Et,gt]),hn=(0,X.useCallback)(async t=>{if(!e||!p)return;let n=(dt.current[p.id]??[]).filter(e=>e.id!==t);try{await hC(e,p.id,t),Et(p.id,n),n.length===0&&!ht.trim()&&(p.messages?.length??0)===0&&(await _C(e,p.id),Ct(p.id),pn(p.mode))}catch(e){Q.error(e instanceof Error?e.message:y$(`errors.removeAttachment`))}},[e,p,ht,pn,Ct,Et]),gn=(0,X.useCallback)(e=>{if(gt!==`opencode`)return;let t=Array.from(e.clipboardData.items).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(e=>e!==null);t.length!==0&&(e.preventDefault(),mn(t))},[gt,mn]),_n=(0,X.useCallback)(async e=>{await fn(e)},[fn]),vn=!!(e&&(_||p&&p.target_available!==!1&&!on)),bn=p?.agent_status===`running`,xn=p?.agent_status===`stopped`,Sn=bn&&ie===p?.id,Cn=vn&&!bn&&!U&&!H&&!vt,wn=vn?p?.target_available===!1?p.target_unavailable_reason??y$(`review.unavailableTarget`):on?an??y$(`review.restoreTargetFallback`):bn?y$(`review.waitTurn`):vt?y$(`review.waitUpload`):H||U?y$(`review.waitPrompt`):null:y$(`review.missingTarget`),Tn=(0,X.useCallback)(async()=>{if(!(!e||!p||p.agent_status!==`running`||Sn)){ae(p.id);try{await gC(e,p.id)}catch(e){ae(e=>e===p.id?null:e),Q.error(e instanceof Error?e.message:y$(`errors.interruptResponse`))}}},[e,p,Sn]),En=(0,X.useCallback)(async()=>{if(!e||oe.length===0||ce.size>0)return;let t=Array.from(new Set(oe)),n=ue||t.length>1;le(new Set(t));let r=await Promise.allSettled(t.map(async t=>(await _C(e,t),t))),i=[],a=[];for(let[e,n]of r.entries()){if(n.status===`fulfilled`){i.push(n.value);continue}a.push({sessionId:t[e]??``,message:n.reason instanceof Error?n.reason.message:null})}if(i.length>0&&St(i),le(new Set),a.length===0){se([]),n&&(de(!1),pe(new Set),Q.success(y$(`toasts.deleteSelectedSuccess`,{count:i.length})));return}let o=a.map(e=>e.sessionId);if(se(o),n&&pe(new Set(o)),i.length>0){Q.error(y$(`toasts.deleteSelectedPartial`,{count:i.length,deletedCount:i.length,failedCount:a.length}));return}Q.error(a[0]?.message??y$(`errors.deleteSession`))},[e,oe,ce,ue,St]),Dn=(0,X.useMemo)(()=>l.some(e=>!S1(e)),[l]),On=(0,X.useCallback)((e,t)=>{pe(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),kn=(0,X.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(XQ,{value:Gt,planInactiveTooltip:(0,Z.jsx)(q$,{label:y$(`shortcuts.switchToPlan`),modifierLabel:Jt,keys:[k$]}),buildInactiveTooltip:(0,Z.jsx)(q$,{label:y$(`shortcuts.switchToBuild`),modifierLabel:Jt,keys:[k$]}),disabled:me,onChange:e=>{ln(e)}}),bn?(0,Z.jsxs)(J,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:Sn,onClick:()=>{Tn()},children:[Sn?(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Zu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:y$(Sn?`review.interrupting`:`review.interrupt`)})]}):null]}),[Jt,Gt,Tn,ln,Sn,bn,me]),An=(0,X.useMemo)(()=>Ht?(0,Z.jsx)(AI,{model:M,variant:P,skills:I,showModelSelector:!0,showSkillsSelector:!0,availableModels:D,availableSkills:A,selectedModel:Wt,onModelChange:e=>{let t=D.find(t=>t.id===e)??null;N(e),F(e=>t&&t.variants.includes(e)?e:``)},onVariantChange:F,onSkillsChange:L,modelSelectId:`project-chat-model-selector`,variantSelectId:`project-chat-variant-selector`,skillsSelectId:`project-chat-skills-selector`,disabled:U||H||p?.agent_status===`running`}):Ut?(0,Z.jsx)(kI,{dataTestId:`chat-model-selector-skeleton`}):null,[p?.agent_status,D,A,H,U,Wt,M,I,P,Ht,Ut]);(0,X.useEffect)(()=>{if(a)return()=>{a(null)}},[a]),(0,X.useEffect)(()=>{if(a){if(!e||!vn){a(null);return}a({chatSessionId:p?.id??null,canSubmitReviewPrompt:Cn,reviewSubmitDisabledReason:wn,mode:Gt,onModeChange:ln,isUpdatingMode:me,promptPlaceholder:z$(Gt),promptComposerControls:kn,promptComposerInlineControls:An,submitPrompt:_n})}},[e,p,Cn,Gt,ln,_n,vn,me,a,kn,An,wn]);let jn=async()=>{if(!(!ht.trim()&&_t.length===0||vt))try{if(!await fn(ht))return}catch(e){Q.error(e instanceof Error?e.message:y$(`errors.sendPrompt`))}},Mn=e=>{e.key!==`Enter`||e.shiftKey||p?.agent_status===`running`||H||U||vt||(e.preventDefault(),jn())};(0,X.useEffect)(()=>{let t=t=>{if(U$(t)){if(!e||H||U)return;t.preventDefault(),en(),cn();return}H$(t)&&(!e||!_&&!p||(t.preventDefault(),ln(V$(Gt))))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,p,Gt,cn,en,ln,H,_,U]);let Nn=(0,X.useCallback)(async t=>{if(!(!e||!p)){ve(t);try{let n=await bC(e,p.id,t);bt(n.chatSession),xt(n.chatSession),Q.success(y$(`ticketProposal.createdFromChat`,{count:n.created_tickets.length}))}catch(e){Q.error(e instanceof Error?e.message:y$(`errors.createTickets`))}finally{ve(e=>e===t?null:e)}}},[e,p,bt,xt]),Pn=(0,X.useCallback)(e=>{if(!Xe.current)return;let t=Xe.current.getBoundingClientRect().width,n=F$(e,t);at.current=n,Y.current&&(Y.current.style.setProperty(`--chat-changes-panel-width`,`${n}px`),Y.current.setAttribute(`data-desktop-width`,String(n)))},[]),Fn=(0,X.useCallback)(()=>{et.current?.(),et.current=null},[]),In=(0,X.useCallback)(e=>{let t=Qe.current,n=$e.current,r=tt.current;if(t!==null){if(Qe.current=null,$e.current=null,tt.current=!1,Fe(!1),Le(!1),Fn(),e!==null&&typeof Ze.current?.hasPointerCapture==`function`&&Ze.current.hasPointerCapture(e)&&typeof Ze.current.releasePointerCapture==`function`&&Ze.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;q(at.current),Ne(!0);return}q(at.current)}},[Fn]),Ln=(0,X.useCallback)((e,t)=>{if(Qe.current!==e)return;let n=t-rt.current,r=it.current-n;if($e.current===`collapsed`){if(!tt.current&&r<O$)return;tt.current||(tt.current=!0,nt.current=!0,Le(!0),Fe(!0))}Pn(r)},[Pn]),Rn=(0,X.useCallback)((e,t)=>{if(Qe.current===e){if(t!==null&&($e.current===`inline`||tt.current)){let e=t-rt.current;Pn(it.current-e)}In(e)}},[In,Pn]),zn=(0,X.useCallback)(e=>{if(!s)return;e.preventDefault(),Qe.current=e.pointerId,$e.current=Me?`inline`:`collapsed`,tt.current=!1,nt.current=!1,rt.current=e.clientX,it.current=Me?at.current:0,Fe(Me),Fn(),typeof e.currentTarget.setPointerCapture==`function`&&e.currentTarget.setPointerCapture(e.pointerId);let t=e=>{Ln(e.pointerId,e.clientX)},n=e=>{Rn(e.pointerId,e.clientX)},r=e=>{Rn(e.pointerId,e.clientX)};window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,r),et.current=()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,r)}},[Rn,Ln,Me,s,Fn]),Bn=(0,X.useCallback)(e=>{Ln(e.pointerId,e.clientX)},[Ln]),Vn=(0,X.useCallback)(e=>{Rn(e.pointerId,e.clientX)},[Rn]),Hn=(0,X.useCallback)(e=>{Rn(e.pointerId,e.clientX)},[Rn]),Un=(0,X.useCallback)(e=>{Qe.current===e.pointerId&&In(e.pointerId)},[In]),Wn=(0,X.useCallback)(()=>{if(nt.current){nt.current=!1;return}Ne(!0)},[]),Gn=(0,X.useCallback)(()=>{Ne(!1)},[]),Kn=(0,X.useCallback)(e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),Wn())},[Wn]);(0,X.useEffect)(()=>{s||(Qe.current=null,$e.current=null,tt.current=!1,nt.current=!1,Fe(!1),Le(!1),Fn())},[s,Fn]),(0,X.useEffect)(()=>()=>{Fn()},[Fn]);let qn=!!d,Jn=p?.target_available===!1,Yn=Jn?p?.target_unavailable_reason??y$(`review.unavailableTarget`):null,Xn=_||!!(p&&p.target_available!==!1&&!on),Zn=!!(t?.memory_enabled&&p&&(be.length>0||Se)),Qn=s&&(_||qn)&&!Jn&&!on,$n=Qn&&!Me&&!Ie,er=Qn&&(Me||Ie),tr=`${$t??`none`}:${Qn?`changes-enabled`:`changes-disabled`}:${er?`panel-visible`:`panel-hidden`}`,nr=p||_?(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(YQ,{projectId:e,messages:p?Bt:[],internalLog:p?.agent_log??null,currentThinkingMessageId:p?.agent_message_id??null,previousThinkingLog:p?.previous_agent_log??null,previousThinkingMessageId:p?.previous_agent_message_id??null,pendingAgentTitle:zt,streamingResponse:p?.streaming_response??null,isRunning:p?.agent_status===`running`,isLoading:!_&&ee,canShowComposer:Xn,isExternallyResizing:o||Pe,pendingAgentRevealKey:Vt,pendingAgentRevealDelayMs:N$,composerFocusNonce:ze,header:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-foreground`,children:Kt}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[_?null:(0,Z.jsx)(UD,{tool:p?.tool,className:`text-[11px]`}),Zt?(0,Z.jsx)(`p`,{children:Zt}):null,xn?(0,Z.jsx)(`div`,{className:`inline-flex items-center rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-100`,children:y$(`sidebar.interrupted`)}):null,Qt?(0,Z.jsx)(`div`,{"data-testid":`chat-context-usage-badge`,className:`inline-flex items-center rounded-full border border-border/80 bg-muted/40 px-2 py-0.5 text-[11px] font-medium text-foreground`,children:Qt}):null]})]}),Zn?(0,Z.jsx)(J,{type:`button`,size:`xs`,variant:`outline`,className:`gap-2`,onClick:()=>K(!0),children:Se?y$(`composer.loadingMemory`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:y$(`composer.memorySuggestions`)}),(0,Z.jsx)(QQ,{children:be.length})]})}):null]}),on&&an?(0,Z.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{children:an}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{nn()},children:y$(`composer.switchBack`)}),(0,Z.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,onClick:en,children:y$(`composer.startNewSession`)})]})]})}):null,Jn&&Yn?(0,Z.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:Yn}):null]}),composerControls:kn,composerInlineControls:An,composerTheme:Gt,layoutKey:$t,scrollLayoutKey:tr,followUpPrompt:ht,draftAttachments:_t,followUpPlaceholder:z$(Gt),emptyStateText:null,renderMessageFooter:e=>e.ticket_proposals?(0,Z.jsx)(T1,{proposals:e.ticket_proposals,isApplying:_e===e.id,onApply:()=>{Nn(e.id)}}):null,isSendingFollowUp:U||H,isUploadingAttachments:vt,canAttachImages:Xt,followUpDisabledReason:Jn?Yn??void 0:p?.agent_status===`running`?y$(`review.waitTurnShort`):vt?y$(`review.waitUpload`):void 0,onFollowUpPromptChange:e=>{wt(mt,e)},onFollowUpKeyDown:Mn,onFollowUpPaste:gn,onUploadAttachments:e=>{mn(e)},onRemoveAttachment:e=>{hn(e)},onFollowUpSubmit:()=>{jn()}})}):qn?(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:y$(`composer.loadingSession`)}):!B||R?(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:y$(`sidebar.loadingSessions`)}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6`,children:(0,Z.jsxs)(Nf,{className:`w-full max-w-lg border-dashed border-border/70 bg-card/40`,children:[(0,Z.jsxs)(Pf,{children:[(0,Z.jsx)(Ff,{children:y$(`composer.noSessionSelectedTitle`)}),(0,Z.jsx)(If,{children:y$(`composer.noSessionSelectedDescription`)})]}),(0,Z.jsx)(Rf,{children:(0,Z.jsx)(J,{type:`button`,onClick:en,disabled:!e||H||U,children:y$(`composer.startNewSession`)})})]})}),rr=Qn?(0,Z.jsx)(`div`,{ref:Ze,"aria-label":y$($n?`composer.openDiff`:`composer.resizeDiffPanel`),"aria-orientation":$n?void 0:`vertical`,className:W($n?`group flex h-8 w-full shrink-0 touch-none select-none items-center justify-center border-t border-border/70 bg-background/90 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground xl:h-auto xl:w-7 xl:cursor-col-resize xl:border-l xl:border-t-0`:`group hidden w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 transition-colors xl:flex`,Pe&&!$n&&`bg-background`),"data-testid":$n?`collapsed-changes-rail`:void 0,onLostPointerCapture:Un,onPointerCancel:Hn,onPointerDown:zn,onPointerMove:Bn,onPointerUp:Vn,onClick:$n?Wn:void 0,onKeyDown:$n?Kn:void 0,role:$n?`button`:`separator`,tabIndex:$n?0:void 0,children:$n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`hidden h-full w-full items-center justify-center xl:flex`,children:(0,Z.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,Z.jsx)(qu,{className:`h-3 w-3 shrink-0`})}),(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]})}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-medium xl:hidden`,children:[(0,Z.jsx)(qu,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:y$(`composer.diff`)})]})]}):(0,Z.jsx)(`div`,{className:W(`h-14 w-1.5 rounded-full transition-colors`,Pe?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`)})}):null,ir=we&&e&&t?.memory_enabled?(0,Z.jsx)(Af,{onClose:()=>K(!1),overlayClassName:`bg-background/45 p-4 backdrop-blur-sm`,panelClassName:`w-full max-w-3xl`,renderContent:({closeButton:t})=>(0,Z.jsxs)(Nf,{size:`sm`,className:`max-h-[calc(100vh-2rem)] w-full gap-0 overflow-hidden border-border/80 bg-card/95 shadow-2xl`,children:[(0,Z.jsxs)(Pf,{className:`border-b border-border/80 pb-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(Ff,{children:y$(`composer.memorySuggestionsTitle`)}),(0,Z.jsx)(If,{children:y$(`composer.memorySuggestionsDescription`)})]}),(0,Z.jsx)(Lf,{children:t})]}),(0,Z.jsx)(Rf,{className:`min-h-0 flex-1 overflow-y-auto pt-4`,children:(0,Z.jsx)(c$,{projectId:e,suggestions:be,emptyState:y$(`composer.memorySuggestionsEmpty`),onSuggestionsChanged:Pt})})]}),closeButtonLabel:y$(`composer.closeMemorySuggestions`)}):null,ar=Lt.length>0?(0,Z.jsx)(C1,{count:Lt.length,title:Rt,isDeleting:ce.size>0,onConfirm:()=>{En()},onCancel:()=>{ce.size>0||se([])}}):null;return(0,Z.jsxs)(`div`,{"data-testid":`chat-view-shell`,className:`relative flex min-h-0 flex-1 overflow-hidden border-t border-border/70`,children:[(0,Z.jsx)(w1,{activeProject:t,activeProjectBranchState:n,activeSessionId:d,chatModeShortcutModifierLabel:Jt,deletingSessionIds:ce,finishedBackgroundSessionIds:Ue,hasDeletableSessions:Dn,isCreatingSession:H||!e,isSelectionMode:ue,isDraftOpen:_,isLoadingSessions:R,isOpen:Ae,isSendingPrompt:U,selectedSessionCount:fe.size,selectedSessionIds:fe,sessionGroups:It,sessions:l,onConfirmDeleteSelectedSessions:()=>{se(Array.from(fe))},onConfirmDeleteSession:e=>{se([e])},onDraftOpen:en,onEnterSelectionMode:()=>{de(!0),pe(new Set)},onExitSelectionMode:()=>{de(!1),pe(new Set)},onSetSessionSelection:On,onSessionSelect:e=>{sn(e)},onToggleSessionSelection:e=>{pe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},onToggleOpen:()=>{je(e=>!e)}}),(0,Z.jsxs)(`div`,{ref:Xe,className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden xl:flex-row`,children:[(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:nr}),Qn?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Lu,{content:y$(`composer.openDiff`),disabled:!$n,side:`left`,children:rr}),er?(0,Z.jsx)(JQ,{projectId:e,chatSessionId:_?null:d,canSubmitReviewPrompt:Cn,reviewSubmitDisabledReason:wn,onSubmitReviewPrompt:_n,state:Oe,onStateChange:ke,isResizing:Pe,onClose:Gn,desktopWidth:Re,panelElementRef:Y}):null]}):null]}),ir,ar]})},D1=({className:e})=>(0,Z.jsx)(Lc,{"aria-hidden":`true`,className:e}),O1=({activeProject:e})=>e?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-6`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,Z.jsx)(`div`,{className:`border-b border-border/60 pb-4`,children:(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground`,children:`Memory archive`}),(0,Z.jsx)(`h2`,{className:`text-xl font-semibold text-foreground`,children:e.name})]})}),(0,Z.jsx)(kh,{mode:`edit`,projectId:e.id,memoryEnabled:e.memory_enabled,persistedMemoryEnabled:e.memory_enabled,onMemoryEnabledChange:()=>{},showActivationControls:!1,archiveLayout:!0})]})}):(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Select a project to view memory.`}),k1=()=>({hasRunning:!1,hasFinishedUnseen:!1,hasErrorUnseen:!1}),A1=()=>({board:k1(),memory:k1(),chat:k1()}),j1=(e,t)=>{let n=e[t];return!n.hasFinishedUnseen&&!n.hasErrorUnseen?e:{...e,[t]:{...n,hasFinishedUnseen:!1,hasErrorUnseen:!1}}},M1=e=>({hasRunning:e.board.hasRunning||e.chat.hasRunning,hasFinishedUnseen:e.board.hasFinishedUnseen||e.chat.hasFinishedUnseen,hasErrorUnseen:e.board.hasErrorUnseen||e.chat.hasErrorUnseen}),N1=e=>e.hasErrorUnseen?`error`:e.hasRunning?`running`:e.hasFinishedUnseen?`finished`:null,P1=(e,t)=>t?null:N1(e),F1=320,I1=.7,L1=28,R1=6,z1=(e,t)=>{let n=Math.max(F1,Math.round(t*I1));return Math.max(F1,Math.min(n,Math.round(e)))},B1=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return[...e,t];let r=e.slice();return r[n]=t,r},V1=(e,t)=>{if(t.type===`reset`)return A1();if(t.type===`mark-workspace-visible`)return j1(e,t.workspace);let n=e[t.workspace],r={...n,hasRunning:t.activity.hasRunning,hasFinishedUnseen:t.visibleWorkspace===t.workspace?!1:n.hasFinishedUnseen||t.activity.didFinish,hasErrorUnseen:t.visibleWorkspace===t.workspace?!1:n.hasErrorUnseen||t.activity.didError};return n.hasRunning===r.hasRunning&&n.hasFinishedUnseen===r.hasFinishedUnseen&&n.hasErrorUnseen===r.hasErrorUnseen?e:{...e,[t.workspace]:r}},H1=({activeProjectId:e,onActivity:t})=>{let{tickets:n}=QZ(),r=(0,X.useRef)(new Map);return(0,X.useEffect)(()=>{r.current=new Map},[e]),(0,X.useEffect)(()=>{let e=r.current,i=new Map,a=!1,o=!1;for(let t of n){let n=e.get(t.id)??null,r=t.agent_status??null;n===`running`&&r===`done`&&(a=!0),n===`running`&&r===`error`&&(o=!0),i.set(t.id,r)}r.current=i,t({hasRunning:n.some(e=>e.agent_status===`running`),didFinish:a,didError:o})},[t,n]),null},U1=({activeProjectId:e,onActivity:t})=>{let n=WZ(),[r,i]=(0,X.useState)([]),a=(0,X.useRef)(new Map);return(0,X.useEffect)(()=>{if(!e)return;let t=new AbortController;return(async()=>{try{let n=await lC(e,t.signal);if(t.signal.aborted)return;i(n)}catch(e){k(e)}})(),()=>{t.abort()}},[e,n]),(0,X.useEffect)(()=>{if(!e)return;let t=new AbortController,n=fY(()=>{document.visibilityState===`visible`&&lC(e,t.signal).then(e=>{t.signal.aborted||i(e)}).catch(e=>{k(e)})});return()=>{t.abort(),n()}},[e,n]),(0,X.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||i(e=>B1(e,t))},r=t=>{!t||t.project_id!==e||i(e=>e.filter(e=>e.id!==t.id))};return n.on(`chat-session:created`,t),n.on(`chat-session:updated`,t),n.on(`chat-session:deleted`,r),()=>{n.off(`chat-session:created`,t),n.off(`chat-session:updated`,t),n.off(`chat-session:deleted`,r)}},[e,n]),(0,X.useEffect)(()=>{let n=a.current,i=new Map,o=[],s=!1;for(let e of r){let t=n.get(e.id)??null,r=e.agent_status??null;t===`running`&&r===`done`&&o.push(e),t===`running`&&r===`error`&&(s=!0),i.set(e.id,r)}a.current=i;for(let e of o)e.title&&HZ(`Chat response ready`,e.title);o.length>0&&e&&lY(e),t({hasRunning:r.some(e=>e.agent_status===`running`),didFinish:o.length>0,didError:s})},[e,t,r]),null},W1=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onRestoreChatSessionTarget:a,onChatReviewCapabilityChange:o,onPreviewReviewCapabilityChange:s,previewDisplayMode:c=`hidden`,previewPane:l=null,previewPaneWidth:u=480,isPreviewButtonDisabled:d=!1,previewButtonTitle:f,visibleWorkspace:p,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,onBoardLoadedProjectIdChange:_,onPreviewToggle:v,onPreviewPaneWidthChange:y,onRunStopped:b,onRunStatusChange:x,onWorkspaceActivityChange:S,onWorkspaceActivityEvent:C,refreshKey:w=0})=>{let T=(0,X.useRef)(null),E=(0,X.useRef)(null),D=(0,X.useRef)(null),O=(0,X.useRef)(null),k=(0,X.useRef)(!1),A=(0,X.useRef)(!1),j=(0,X.useRef)(0),M=(0,X.useRef)(u),N=(0,X.useRef)(u),P=p===`board`||p===`chat`,F=l!==null,[I,L]=(0,X.useState)(!1),[R,z]=(0,X.useState)(!1),[B,V]=(0,X.useState)(u),[ee,te]=(0,X.useReducer)(V1,void 0,A1),H=P&&F&&c===`expanded`,ne=P&&F&&c===`inline`,U=P&&F&&c===`hidden`&&!R,re=(ne||R)&&!H,ie=H||re,ae=P&&F&&!H,oe=I?B:u,se=p!==`chat`||!re,ce=e=>{let t=D.current,n=O.current,r=k.current;if(t!==null){if(D.current=null,O.current=null,k.current=!1,L(!1),z(!1),e!==null&&E.current?.hasPointerCapture(e)&&E.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;y?.(N.current),v?.();return}y?.(N.current)}},le=e=>{if(!T.current)return;let t=T.current.getBoundingClientRect().width,n=z1(e,t);N.current=n,V(n)},ue=e=>{y&&(U&&d||(e.preventDefault(),D.current=e.pointerId,O.current=U?`collapsed`:`inline`,k.current=!1,A.current=!1,j.current=e.clientX,M.current=U?0:N.current,L(!U),e.currentTarget.setPointerCapture(e.pointerId)))},de=e=>{if(D.current!==e.pointerId)return;let t=e.clientX-j.current,n=M.current-t;if(O.current===`collapsed`){if(!k.current&&n<R1)return;k.current||(k.current=!0,A.current=!0,z(!0),L(!0))}le(n)},W=e=>{if(D.current===e.pointerId){if(O.current===`inline`||k.current){let t=e.clientX-j.current;le(M.current-t)}ce(e.pointerId)}},fe=e=>{D.current===e.pointerId&&ce(e.pointerId)},pe=(0,X.useCallback)((e,t)=>{C?.(e,t),te({type:`update-workspace`,workspace:e,activity:t,visibleWorkspace:p})},[C,p]);(0,X.useEffect)(()=>{te({type:`reset`})},[e]),(0,X.useEffect)(()=>{p!==`memory`&&te({type:`mark-workspace-visible`,workspace:p})},[p]),(0,X.useEffect)(()=>{S?.(ee)},[S,ee]),(0,X.useEffect)(()=>{I||(N.current=u),!F&&(D.current=null,O.current=null,k.current=!1,A.current=!1,N.current=u)},[F,I,u]);let me=()=>{if(A.current){A.current=!1;return}d||v?.()};return(0,Z.jsx)(ZZ,{activeProjectId:e,refreshKey:w,onLoadedProjectIdChange:_,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,children:(0,Z.jsxs)(`div`,{ref:T,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsx)(H1,{activeProjectId:e,onActivity:e=>{pe(`board`,e)}}),(0,Z.jsx)(U1,{activeProjectId:e,onActivity:e=>{pe(`chat`,e)}}),p===`memory`?(0,Z.jsx)(`div`,{id:`project-workspace-panel-memory`,role:`tabpanel`,"aria-labelledby":`project-workspace-tab-memory`,className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(O1,{activeProject:t})}):(0,Z.jsxs)(`div`,{id:p===`chat`?`project-workspace-panel-chat`:`project-workspace-panel-board`,role:`tabpanel`,"aria-labelledby":p===`chat`?`project-workspace-tab-chat`:`project-workspace-tab-board`,className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:p===`chat`?(0,Z.jsx)(E1,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeTool:i,isExternallyResizing:I,onRestoreSessionTarget:a,onReviewCapabilityChange:o,showChangesPanel:se}):(0,Z.jsx)(kQ,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:s,onRunStopped:b,onRunStatusChange:x,refreshKey:w})}),[ae?(0,Z.jsx)(Lu,{content:d?f??`Preview unavailable`:`Open preview`,disabled:!U,side:`left`,children:(0,Z.jsx)(`div`,{"aria-label":U?f??`Show preview`:`Resize preview pane`,"aria-orientation":U?void 0:`vertical`,className:U?`group flex shrink-0 touch-none select-none items-center justify-center border-l border-border/70 bg-background/90 transition-colors ${d?`cursor-not-allowed text-muted-foreground/60`:`cursor-col-resize text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`:`group flex w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 ${I?`bg-background`:``}`,"data-preview-divider":`true`,"data-testid":U?`collapsed-preview-rail`:void 0,onLostPointerCapture:fe,onPointerCancel:W,onPointerDown:ue,onPointerMove:de,onPointerUp:W,onClick:U?me:void 0,onKeyDown:U?e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),me())}:void 0,ref:E,role:U?`button`:`separator`,style:U?{width:`${L1}px`}:void 0,tabIndex:U?d?-1:0:void 0,children:U?(0,Z.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,Z.jsx)(D1,{className:`h-3 w-3 shrink-0`})}),(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]}):(0,Z.jsx)(`div`,{className:`h-14 w-1.5 rounded-full transition-colors ${I?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`}`})})},`preview-divider`):null,ie?(0,Z.jsx)(`div`,{className:H?`fixed inset-0 z-50 bg-black/70 p-4 sm:p-6`:`min-h-0 shrink-0 border-l border-border/70 bg-[#11131a]`,style:H?void 0:{width:`${oe}px`},children:(0,Z.jsx)(`div`,{className:`h-full w-full`,children:l})},`preview-container`):null]]})]})})},G1=({isExpanded:e,isVisible:t,project:n,onClose:r,onToggleExpanded:i})=>(0,Z.jsx)(`div`,{className:[`fixed inset-x-4 bottom-24 z-40`,e?`top-20`:`h-[min(28rem,calc(100vh-8rem))]`,t?`block`:`hidden`].join(` `),children:(0,Z.jsx)($K,{createSession:()=>zD(n.id),isExpanded:e,isVisible:t,ariaLabel:`Project terminal for ${n.name}`,title:n.name,closeLabel:`Close terminal`,className:e?`h-full w-full rounded-2xl shadow-2xl`:`mx-auto h-full max-w-6xl shadow-2xl`,onClose:r,onToggleExpanded:i})}),K1=({activeWorkspace:e,activityByWorkspace:t,memoryEnabled:n=!1,onWorkspaceChange:r})=>(0,Z.jsx)(`div`,{role:`tablist`,"aria-label":`Project workspace`,className:`inline-flex items-end gap-1 border-b border-border/70`,children:(n?[`board`,`chat`,`memory`]:[`board`,`chat`]).map(n=>{let i=e===n,a=P1(t[n],i),o=n===`board`?`border-sky-300/70 bg-sky-500/8 text-sky-200`:n===`memory`?`border-amber-300/70 bg-amber-500/8 text-amber-200`:`border-emerald-300/70 bg-emerald-500/8 text-emerald-200`;return(0,Z.jsx)(`button`,{id:`project-workspace-tab-${n}`,type:`button`,role:`tab`,"aria-selected":i,"aria-controls":`project-workspace-panel-${n}`,tabIndex:i?0:-1,className:W(`cursor-pointer rounded-t-lg border-b-2 px-4 py-2.5 text-[15px] font-medium transition-colors duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60`,i?o:`border-transparent text-muted-foreground hover:border-border hover:bg-background/35 hover:text-foreground`),onClick:()=>r(n),children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:n===`board`?`Board`:n===`memory`?`Memory`:`Chat`}),(0,Z.jsx)(ef,{state:a,className:`mt-0`})]})},n)})}),q1=32,J1=5.5,Y1=2,X1=24,Z1=8,Q1=new Map,$1={running:{fill:`#fcd34d`,stroke:`#f59e0b`},finished:{fill:`#34d399`,stroke:`#059669`},error:{fill:`#fb7185`,stroke:`#e11d48`}},e0=e=>e.replaceAll(`&`,`&`).replaceAll(`"`,`"`).replaceAll(`<`,`<`).replaceAll(`>`,`>`),t0=e=>{if(!e)return null;let t=e.trim().match(/^([0-9]+(?:\.[0-9]+)?)/);return t?Number(t[1]):null},n0=e=>{let t=new DOMParser().parseFromString(e,`image/svg+xml`);if(t.querySelector(`parsererror`))return null;let n=t.documentElement;if(n.nodeName.toLowerCase()!==`svg`)return null;let r=n.getAttribute(`viewBox`)?.trim(),i=t0(n.getAttribute(`width`)),a=t0(n.getAttribute(`height`)),o=r??(i&&a?`0 0 ${i} ${a}`:`0 0 ${q1} ${q1}`);return`<svg ${[Array.from(n.attributes).filter(e=>![`width`,`height`,`viewBox`,`x`,`y`,`preserveAspectRatio`].includes(e.name)).map(e=>`${e.name}="${e0(e.value)}"`).join(` `),`x="0"`,`y="0"`,`width="${q1}"`,`height="${q1}"`,`viewBox="${e0(o)}"`,`preserveAspectRatio="xMidYMid meet"`].filter(e=>e.length>0).join(` `)}>${n.innerHTML}</svg>`},r0=async e=>{if(!e)return null;let t=Q1.get(e);if(t)return t;let n=(async()=>{try{if(e.startsWith(`data:image/svg+xml,`))return n0(decodeURIComponent(e.slice(19)));if(e.startsWith(`data:image/svg+xml;base64,`))return n0(atob(e.slice(26)));let t=await fetch(e);return t.ok?n0(await t.text()):null}catch{return null}})();return Q1.set(e,n),n},i0=async(e,t)=>{let{fill:n,stroke:r}=$1[e],i=await r0(t);return i?[`<svg xmlns="http://www.w3.org/2000/svg" width="${q1}" height="${q1}" viewBox="0 0 ${q1} ${q1}">`,i,`<circle cx="${X1}" cy="${Z1}" r="${J1}" fill="${n}" stroke="${r}" stroke-width="${Y1}"/>`,`</svg>`].join(``):null},a0=async(e,t)=>{if(!e)return t;let n=await i0(e,t);return n?`data:image/svg+xml,${encodeURIComponent(n)}`:t},o0=()=>{let e=document.querySelector(`link[rel="icon"]`);if(e)return e;let t=document.createElement(`link`);return t.rel=`icon`,document.head.appendChild(t),t},s0=({defaultHref:e,state:t})=>{let n=o0(),r=Number(n.dataset.browserTabActivityRequestId??`0`)+1;if(n.dataset.browserTabActivityState=t??`default`,n.dataset.browserTabActivityRequestId=String(r),!t){if(e){n.href=e;return}n.removeAttribute(`href`);return}a0(t,e).then(e=>{if(n.dataset.browserTabActivityRequestId===String(r)){if(e){n.href=e;return}n.removeAttribute(`href`)}})},c0=`archon.active-project-id`,l0=`archon.workspace-by-project`,u0=`archon.preview-mode-by-project`,d0=`archon.dismissed-preview-run-context-by-project`,f0=5e3,p0=`archon.preview-pane-width`,m0=`archon.preview-viewport-preset`,h0=`archon.preview-zoom`,g0=480,_0=`responsive`,v0=1,y0={hasMounted:!1,isOpen:!1,isExpanded:!1},b0=`hidden`,x0=(0,X.lazy)(()=>cq(()=>Promise.resolve().then(()=>yX).then(e=>({default:e.TicketChangesModal})),void 0)),S0=(0,X.lazy)(()=>cq(()=>import(`./TestsDialog-BPHhOIWL.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),C0=e=>{if(!e)return null;try{return JSON.parse(e)}catch{return null}},w0=e=>{let t=C0(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(e=>e.length>0):[]},T0=e=>{let t=C0(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.name==`string`?t.name:``,r=typeof t.cmd==`string`?t.cmd:``,i=typeof t.cwd==`string`?t.cwd:``;return n.trim()===``&&r.trim()===``&&i.trim()===``?[]:[{name:n,cmd:r,cwd:i}]}):[]},E0=e=>{let t=C0(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.source==`string`?t.source:``,r=typeof t.target==`string`?t.target:``,i=t.mode===`copy`||t.mode===`symlink`?t.mode:`copy`;return n.trim()===``&&r.trim()===``?[]:[{source:n,target:r,mode:i}]}):[]},D0=e=>({name:e.name,repoPath:e.repo_path,linkedProjectIds:e.linked_project_ids,runSetup:w0(e.run_setup),runServices:T0(e.run_services),testCommands:EZ(e.test_commands),runIde:e.run_ide??``,previewServiceName:e.preview_service_name??``,previewPath:e.preview_path??``,previewCapabilityMode:e.preview_capability_mode??`auto`,helperModel:e.helper_model??``,helperVariant:e.helper_variant??``,commitMessageRules:e.commit_message_rules??``,autoParkStaleTickets:e.auto_park_stale_tickets,memoryEnabled:e.memory_enabled,worktreeSync:E0(e.worktree_sync)}),O0=e=>{let t=e.testCommands??[],n=e.previewServiceName?.trim()||null,r=e.previewPath?.trim()||``,i=r===``||r===`/`?null:r,a=n||i||e.previewCapabilityMode===`force_web`||e.previewCapabilityMode===`force_disabled`?e.previewCapabilityMode??`auto`:null;return{name:e.name,repo_path:e.repoPath,linked_project_ids:e.linkedProjectIds,run_setup:e.runSetup.length>0?e.runSetup:null,run_services:e.runServices.length>0?e.runServices.map(e=>({...e.name?{name:e.name}:{},cmd:e.cmd,...e.cwd?{cwd:e.cwd}:{}})):null,...t.length>0?{test_commands:t.map(e=>({id:e.id,name:e.name,command:e.command,runner:e.runner,...e.cwd?{cwd:e.cwd}:{}}))}:{},run_ide:e.runIde||null,preview_service_name:n,preview_path:i,preview_capability_mode:a,helper_model:e.helperModel||null,helper_variant:e.helperModel&&e.helperVariant||null,commit_message_rules:e.commitMessageRules||null,auto_park_stale_tickets:e.autoParkStaleTickets,memory_enabled:e.memoryEnabled,worktree_sync:e.worktreeSync.length>0?e.worktreeSync.map(e=>({source:e.source,...e.target?{target:e.target}:{},mode:e.mode})):null}},k0=e=>e?w0(e.run_setup).length>0||T0(e.run_services).length>0||(e.run_ide?.trim().length??0)>0:!1,A0=(e,t,n)=>`${e} ${e===1?t:n}`,j0=e=>{if(!e.repo_path_locked)return null;let t=[];return e.ticket_count>0&&t.push(A0(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&t.push(A0(e.worktree_count,`worktree exists`,`worktrees exist`)),t.length===0?`Repository path is locked for this project.`:`Repository path is locked because ${t.join(` and `)}.`},M0=(e,t)=>{if(t.length<=1)return`Keep at least one project in Archon.`;let n=[];e.ticket_count>0&&n.push(A0(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&n.push(A0(e.worktree_count,`worktree exists`,`worktrees exist`));let r=t.filter(t=>t.linked_project_ids.includes(e.id)).length;return r>0&&n.push(A0(r,`project links to it`,`projects link to it`)),n.length===0?null:`This project can't be deleted while ${n.join(` and `)}.`},N0=(e,t)=>e.id!==t.projectId||e.ticket_count===t.ticketCount&&e.worktree_count===t.worktreeCount&&e.repo_path_locked===t.repoPathLocked?e:{...e,ticket_count:t.ticketCount,worktree_count:t.worktreeCount,repo_path_locked:t.repoPathLocked},P0=(e,t)=>({projectId:e,branch:t.branch,status:t.status,ahead:t.ahead??0,behind:t.behind??0,hasUpstream:t.has_upstream??!1,canPull:t.can_pull??!1,diffStats:t.diff_stats??null}),F0=e=>({projectId:e,branch:null,status:`loading`,ahead:0,behind:0,hasUpstream:!1,canPull:!1,diffStats:null}),I0=(e,t)=>t?e[t]??y0:y0,L0=(e,t)=>t?e[t]??b0:b0,R0=()=>{let e=window.localStorage.getItem(p0),t=Number(e);return Number.isFinite(t)&&t>=320?t:g0},z0=()=>{let e=window.localStorage.getItem(m0);return e===`phone`||e===`tablet`||e===`laptop`||e===`responsive`?e:_0},B0=()=>{let e=Number(window.localStorage.getItem(h0));return Number.isFinite(e)&&e>0?e:v0},V0=()=>{let e=C0(window.localStorage.getItem(l0));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`board`||e===`chat`||e===`memory`))},H0=()=>{let e=C0(window.localStorage.getItem(u0));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`hidden`||e===`inline`||e===`expanded`))},U0=()=>{let e=C0(window.localStorage.getItem(d0));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`||e===null))},W0=e=>!!e?.preview_service_name?.trim()&&e?.preview_capability_mode!==`force_disabled`,G0=({activeRun:e,project:t})=>{if(!e||e.kind!==`project`||!t)return!1;let n=t.active_target_kind??`repo_root`,r=t.active_target_bundle_id??null;return e.project_id===t.id&&(e.target_kind??`repo_root`)===n&&((e.target_kind??`repo_root`)!==`bundle`||e.target_bundle_id===r)},K0=({activeRun:e,project:t,projectId:n})=>!e||!n?null:e.kind===`ticket`?e.project_id===n?e:null:G0({activeRun:e,project:t})?e:null,q0=`Project root has uncommitted changes. Confirm branch switch to continue.`,J0=({activeProject:e,activeProjectBranchState:t,nextTarget:n})=>e?n.kind===`bundle`?e.active_target_kind!==`bundle`||e.active_target_bundle_id!==n.bundleId:e.active_target_kind===`bundle`?!0:n.branch?t?.branch!==n.branch:!1:!1,Y0=()=>{let[e,t]=(0,X.useState)(`opencode`),[n,r]=(0,X.useState)(!1),[i,o]=(0,X.useState)([]),[s,c]=(0,X.useState)(()=>window.localStorage.getItem(c0)),[l,u]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),[m,g]=(0,X.useState)(null),[_,v]=(0,X.useState)({}),[y,b]=(0,X.useState)({}),[x,C]=(0,X.useState)({}),[w,T]=(0,X.useState)(null),[E,D]=(0,X.useState)({}),[O,A]=(0,X.useState)(H0),[j,M]=(0,X.useState)(U0),[N,P]=(0,X.useState)(R0),[F,I]=(0,X.useState)(z0),[L,R]=(0,X.useState)(B0),[z,V]=(0,X.useState)(null),[ee,te]=(0,X.useState)([]),[H,U]=(0,X.useState)(!1),[ie,oe]=(0,X.useState)(``),[se,ce]=(0,X.useState)(``),[le,ue]=(0,X.useState)(!1),[de,W]=(0,X.useState)(null),[fe,pe]=(0,X.useState)(null),[me,G]=(0,X.useState)(null),[he,_e]=(0,X.useState)(!1),[ye,be]=(0,X.useState)({}),[xe,Se]=(0,X.useState)(V0),[Ce,K]=(0,X.useState)(()=>A1()),[Te,Ee]=(0,X.useState)(()=>k1()),[De,Oe]=(0,X.useState)(0),[ke,Ae]=(0,X.useState)(null),[je,Me]=(0,X.useState)(null),[Ne,Fe]=(0,X.useState)({}),[Le,q]=(0,X.useState)({}),[ze,J]=(0,X.useState)({}),[Ve,He]=(0,X.useState)({}),[Ue,We]=(0,X.useState)(!1),[Ge,Ke]=(0,X.useState)(!1),[qe,Je]=(0,X.useState)(null),Ye=(0,X.useRef)(null),Xe=(0,X.useRef)(null),Ze=(0,X.useRef)(null),Y=i.find(e=>e.id===s)??null,Qe=!!Y?.memory_enabled,$e=s?xe[s]??`board`:`board`,et=$e===`memory`?Qe?`memory`:`board`:$e,tt=Y!==null,nt=k0(Y),rt=!!Y?.run_ide?.trim(),it=s!==null&&f===s,at=s!==null&&(!nt||m===s),ot=s?_[s]??F0(s):null,st=s?y[s]??null:null,ct=s?!!x[s]:!1,lt=s?Ne[s]??[]:[],ut=s?!!Le[s]:!1,dt=s?ze[s]??{current_branch:null,default_branch:null,previous_branch:null}:{current_branch:null,default_branch:null,previous_branch:null},ft=s?!!Ve[s]:!1,pt=s?E[s]??null:null,mt=L0(O,s),ht=mt!==`hidden`,gt=K0({activeRun:l,project:Y,projectId:s}),_t=gt?.context_key??null,vt=s?j[s]??null:null,yt=W0(Y),bt=_t===z,St=(0,X.useMemo)(()=>M1(Ce),[Ce]),Ct=(0,X.useMemo)(()=>N1({hasRunning:St.hasRunning,hasFinishedUnseen:Te.hasFinishedUnseen,hasErrorUnseen:Te.hasErrorUnseen}),[St.hasRunning,Te.hasErrorUnseen,Te.hasFinishedUnseen]);(0,X.useEffect)(()=>{Ae(null),Me(null),Xe.current=null},[s]),(0,X.useEffect)(()=>{Me(null)},[et]),(0,X.useEffect)(()=>{ht||(Xe.current=null)},[ht]),(0,X.useEffect)(()=>{let e=ke?.target?.kind??null;if(e===`ticket`||e===`bundle`){Xe.current=ke;return}(et===`board`||!ht)&&(Xe.current=ke)},[ht,ke,et]),(0,X.useEffect)(()=>{K(A1())},[s]),(0,X.useEffect)(()=>{Ee(k1())},[s]);let wt=(0,X.useCallback)((e,t)=>{document.visibilityState!==`visible`&&(!t.didFinish&&!t.didError||Ee(e=>{let n={...e,hasFinishedUnseen:e.hasFinishedUnseen||t.didFinish,hasErrorUnseen:e.hasErrorUnseen||t.didError};return e.hasFinishedUnseen===n.hasFinishedUnseen&&e.hasErrorUnseen===n.hasErrorUnseen?e:n}))},[]);(0,X.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&Ee(e=>!e.hasFinishedUnseen&&!e.hasErrorUnseen?e:{...e,hasFinishedUnseen:!1,hasErrorUnseen:!1})};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[]),(0,X.useEffect)(()=>(Ye.current===null&&(Ye.current=document.querySelector(`link[rel="icon"]`)?.getAttribute(`href`)??`/favicon.svg`),s0({defaultHref:Ye.current,state:Ct}),()=>{s0({defaultHref:Ye.current,state:null})}),[Ct]);let Tt=(0,X.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r}=t;try{let t=await Ie(e,r,{refreshRemote:n});if(r?.aborted)return;v(n=>({...n,[e]:P0(e,t)}))}catch(t){if(k(t))return;if(t instanceof we&&t.status===404){v(t=>({...t,[e]:{...F0(e),status:`unknown`}}));return}v(t=>({...t,[e]:{projectId:e,branch:t[e]?.branch??null,status:`unknown`,ahead:t[e]?.ahead??0,behind:t[e]?.behind??0,hasUpstream:t[e]?.hasUpstream??!1,canPull:t[e]?.canPull??!1,diffStats:t[e]?.diffStats??null}}))}},[]),Et=(0,X.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r}=t;C(t=>({...t,[e]:!0}));try{let t=await Re(e,{refreshRemote:n,signal:r});if(r?.aborted)return;b(n=>({...n,[e]:t}))}catch(t){if(k(t))return;t instanceof we&&t.status===404&&b(t=>({...t,[e]:null}))}finally{r?.aborted||C(t=>({...t,[e]:!1}))}},[]);(0,X.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let{tool:n}=await bn(e.signal);t(n)}catch(e){k(e)}finally{e.signal.aborted||r(!0)}})(),()=>{e.abort()}},[]),(0,X.useEffect)(()=>{if(!le||i.length>0&&de===null||H)return;let e=new AbortController;return(async()=>{try{te(await yn(`opencode`,e.signal))}catch(e){k(e)||te(e=>e)}finally{e.signal.aborted||U(!0)}})(),()=>{e.abort()}},[H,de,i.length,le]),(0,X.useEffect)(()=>{let e=new AbortController,t=window.localStorage.getItem(c0);return(async()=>{try{let n=await ve(e.signal);if(e.signal.aborted)return;o(n);let r=n[0]?.id??null;c(n.some(e=>e.id===t)?t:r)}catch(e){k(e)||o([])}finally{e.signal.aborted||ue(!0)}})(),()=>{e.abort()}},[]),(0,X.useEffect)(()=>{if(le){if(s){window.localStorage.setItem(c0,s);return}window.localStorage.removeItem(c0)}},[s,le]),(0,X.useEffect)(()=>{window.localStorage.setItem(l0,JSON.stringify(xe))},[xe]),(0,X.useEffect)(()=>{window.localStorage.setItem(u0,JSON.stringify(O))},[O]),(0,X.useEffect)(()=>{window.localStorage.setItem(d0,JSON.stringify(j))},[j]),(0,X.useEffect)(()=>{v(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),b(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),C(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,X.useEffect)(()=>{be(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,X.useEffect)(()=>{let e=new Set(i.map(e=>e.id));Fe(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),q(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),J(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),He(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t))))},[i]),(0,X.useEffect)(()=>{le&&(D(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),A(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),M(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}))},[i,le]),(0,X.useEffect)(()=>{le&&Se(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i,le]),(0,X.useEffect)(()=>{if(!le||!s||!tt)return;let e=!1,t=null,n=null;v(e=>e[s]?e:{...e,[s]:F0(s)});let r=async(r=!1)=>{let i=r?`remote`:`local`;if(t){if(n===`remote`||n===i)return;t.abort()}let a=new AbortController;t=a,n=i;try{await Promise.all([Tt(s,{refreshRemote:r,signal:a.signal}),Et(s,{refreshRemote:r,signal:a.signal})])}catch{if(e||a.signal.aborted)return}finally{t===a&&(t=null,n=null)}};r(!1);let i=fY(()=>{document.visibilityState===`visible`&&r(!1)});return()=>{e=!0,t?.abort(),i()}},[s,tt,le,Tt,Et]),(0,X.useEffect)(()=>{if(s)return uY(e=>{e===s&&(Tt(e),Et(e))})},[s,Tt,Et]);let Dt=(0,X.useCallback)(async e=>{let t=s;if(!t){u(null),g(null);return}try{let n=await Rt(t,e);e?.aborted||(u(n.active_run),g(t))}catch(e){k(e)}},[s]),Ot=(0,X.useCallback)(async e=>{let t=s;if(t)try{let n=await Lt(t,e);e?.aborted||D(e=>({...e,[t]:n}))}catch(e){k(e)}},[s]);(0,X.useEffect)(()=>{if(!le)return;if(!nt){u(null),g(null);return}if(!it)return;let e=new AbortController;g(null),Dt(e.signal);let t=window.setInterval(()=>{Dt(e.signal)},f0),n=fY(()=>{document.visibilityState===`visible`&&Dt(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[it,nt,le,Dt]),(0,X.useEffect)(()=>{if(!le||!s||!it||!yt)return;let e=new AbortController;Ot(e.signal);let t=window.setInterval(()=>{Ot(e.signal)},f0),n=fY(()=>{document.visibilityState===`visible`&&Ot(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[s,it,yt,le,Ot]),(0,X.useEffect)(()=>{window.localStorage.setItem(p0,String(N))},[N]),(0,X.useEffect)(()=>{window.localStorage.setItem(m0,F)},[F]),(0,X.useEffect)(()=>{window.localStorage.setItem(h0,String(L))},[L]),(0,X.useEffect)(()=>{s&&_t&&M(e=>{let t=e[s]??null;return!t||t===_t?e:{...e,[s]:null}})},[s,_t]),(0,X.useEffect)(()=>{!s||!gt||!W0(Y)||vt!==gt.context_key&&A(e=>L0(e,s)===`hidden`?{...e,[s]:`inline`}:e)},[Y,s,vt,gt]);let kt=async e=>{try{t((await xn(e)).tool)}catch{}},At=(0,X.useCallback)(e=>{o(t=>t.map(t=>t.id===e.id?e:t))},[]),jt=(0,X.useCallback)((e,t)=>{Fe(n=>{let r=[t,...(n[e]??[]).filter(e=>e.id!==t.id)];return{...n,[e]:r}})},[]),Mt=(0,X.useCallback)(async e=>{He(t=>({...t,[e]:!0}));try{let t=await Be(e);J(n=>({...n,[e]:t}))}catch(e){Q.error(e instanceof we?e.message:`Unable to load the project target options right now.`,{id:`project-target-selector-load-error`})}finally{He(t=>({...t,[e]:!1}))}},[]),Nt=async e=>{try{let t=await ne(O0(e));return o(e=>[...e,t]),c(t.id),W(null),null}catch(e){return e instanceof we?e.message:`Unable to create the project right now.`}},Pt=async e=>{if(!Y)return`Select a project before editing settings.`;try{let t=await d(Y.id,O0(e));return o(e=>e.map(e=>e.id===t.id?t:e)),Oe(e=>e+1),W(null),null}catch(e){return e instanceof we?e.message:`Unable to update the project right now.`}},Ft=async()=>{if(!Y)return`Select a project before deleting it.`;try{await a(Y.id);let e=i.filter(e=>e.id!==Y.id);return o(e),c(e[0]?.id??null),W(null),null}catch(e){return e instanceof we?e.message:`Unable to delete the project right now.`}},Vt=(0,X.useCallback)(e=>{o(t=>t.map(t=>N0(t,e)))},[]),Ht=(0,X.useCallback)((e,t)=>{e&&Fe(n=>({...n,[e]:t}))},[]),Ut=(0,X.useCallback)((e,t)=>{e&&q(n=>({...n,[e]:t}))},[]),Wt=async(e,t,n)=>await Pe({repo_path:e,helper_model:t||null,helper_variant:t&&n||null}),Gt=async()=>(await S()).repo_path,Kt=(0,X.useCallback)(async e=>{let t=await h({repo_path:e});return{valid:t.valid,repoRoot:t.repo_root,error:t.error,willInitialize:t.will_initialize,hasInitialCommit:t.has_initial_commit}},[]),qt=(0,X.useCallback)(async()=>{if(!(!Y||he)){_e(!0);try{let e=await re(Y.id);o(t=>t.map(t=>t.id===e.id?e:t)),Q.success(`Initial commit created.`,{id:`project-initial-commit-success`}),Tt(e.id),Et(e.id)}catch(e){Q.error(e instanceof we?e.message:`Unable to create the initial commit right now.`,{id:`project-initial-commit-error`})}finally{_e(!1)}}},[Y,he,Tt,Et]),Jt=(0,X.useCallback)((e,t)=>{A(t=>({...t,[e]:`hidden`})),t&&M(n=>({...n,[e]:t}))},[]),Yt=(0,X.useCallback)(()=>{s&&Jt(s,_t)},[s,Jt,_t]),Xt=(0,X.useCallback)(e=>{s&&(A(e=>({...e,[s]:`hidden`})),e&&u(t=>t?.context_key===e?null:t))},[s]),Zt=(0,X.useCallback)(async()=>{if(!gt||z===gt.context_key)return;let{context_key:e}=gt;V(e);try{gt.kind===`ticket`?await fn(gt.ticket_id,gt.project_id):u((await Bt(gt.project_id)).active_run),Xt(e),await Promise.all([Dt(),Ot()])}catch(e){Q.error(e instanceof we?e.message:`Unable to stop the preview run right now.`,{id:`app-preview-run-stop-error`})}finally{V(t=>t===e?null:t)}},[Xt,gt,Ot,Dt,z]),Qt=(0,X.useCallback)(e=>{!e||!s||Mt(s)},[s,Mt]),$t=(0,X.useCallback)(e=>new Promise(t=>{Ze.current=t,Je(e)}),[]),en=(0,X.useCallback)(e=>{let t=Ze.current;Ze.current=null,Je(null),t?.(e)},[]),tn=(0,X.useCallback)(async e=>{if(!Y||!s)throw Error(`Select a project first.`);if(!J0({activeProject:Y,activeProjectBranchState:ot,nextTarget:e})||!l||l.kind!==`project`||l.project_id!==Y.id)return!0;if(!await $t({title:`Stop current run and switch target?`,description:`Switching targets will stop the current run and close its preview.`,confirmLabel:`Stop and switch`,cancelLabel:`Keep current target`,confirmVariant:`destructive`}))return!1;try{let e=l.context_key,t=await Bt(Y.id);return Xt(e),u(t.active_run),await Ot(),!0}catch(e){return Q.error(e instanceof we?e.message:`Unable to stop the project run right now.`,{id:`project-target-switch-stop-run-error`}),!1}},[Y,ot,s,l,Xt,Ot,$t]),nn=(0,X.useCallback)(async e=>{if(!s)throw Error(`Select a project first.`);return await tn({kind:`bundle`,bundleId:e})?(At(await B(s,{kind:`bundle`,bundle_id:e})),b(e=>({...e,[s]:null})),await Promise.all([Tt(s),Et(s)]),!0):!1},[s,tn,Tt,Et,At]),rn=(0,X.useCallback)(async(e,t={})=>{if(!s)throw Error(`Select a project first.`);if(!await tn({kind:`repo_root`,branch:e}))return!1;let n=n=>B(s,{kind:`repo_root`,...e?{branch:e}:{},...t.createBranch===!1?{create_branch:!1}:{},...n?{confirm_dirty_switch:!0}:{}}),r;try{r=await n(t.confirmDirtySwitch===!0)}catch(e){if(!t.confirmDirtySwitch&&e instanceof we&&e.status===409&&e.message===q0){if(!await $t({title:`Switch repo root branch?`,description:`${q0}\n\nSwitch anyway?`,confirmLabel:`Switch anyway`,cancelLabel:`Keep current branch`}))return!1;r=await n(!0)}else throw e}return At(r),b(e=>({...e,[s]:null})),await Promise.all([Tt(s),Et(s),Mt(s)]),!0},[s,tn,Mt,Tt,Et,At,$t]),an=(0,X.useCallback)(async e=>!e.target_kind||e.target_available===!1?!0:e.target_kind===`bundle`?e.target_bundle_id?await nn(e.target_bundle_id):!1:await rn(e.target_branch_snapshot??null,{createBranch:!1}),[nn,rn]),on=(0,X.useCallback)(()=>{We(!0)},[]),sn=(0,X.useCallback)(()=>{We(!1)},[]),cn=(0,X.useCallback)(e=>{if(e){nn(e);return}rn(null)},[nn,rn]),ln=(0,X.useCallback)(async e=>{if(!s)throw Error(`Select a project first.`);let t=await xt(s,{name:e,prepare:!0});return jt(s,t),Oe(e=>e+1),t},[s,jt]),un=(0,X.useCallback)(async e=>{if(!s)throw Error(`Select a project first.`);await It(s,e),Fe(t=>({...t,[s]:(t[s]??[]).filter(t=>t.id!==e)})),Oe(e=>e+1)},[s]),dn=(0,X.useCallback)(async()=>{if(!Y)return;let e=Y.active_target_kind??`repo_root`,t=Y.active_target_bundle_id??null,n=l?.kind===`project`&&l.project_id===Y.id&&(l.target_kind??`repo_root`)===e&&((l.target_kind??`repo_root`)!==`bundle`||l.target_bundle_id===t),r=n?l?.context_key??null:null,i=!n&&W0(Y)&&mt===`hidden`;i&&(A(e=>({...e,[Y.id]:`inline`})),M(e=>({...e,[Y.id]:null})));try{let e=n?await Bt(Y.id):await zt(Y.id);n&&Xt(r),u(e.active_run),Ot()}catch(e){i&&A(e=>({...e,[Y.id]:`hidden`})),Q.error(e instanceof we?e.message:`Unable to update the project run right now.`,{id:`app-project-run-error`})}},[mt,Y,l,Xt,Ot]),pn=(0,X.useCallback)(async()=>{if(!(!Y||!rt))try{await ge(Y.id)}catch(e){Q.error(e instanceof Error?e.message:`Unable to open the IDE right now.`,{id:`app-project-open-ide-error`})}},[Y,rt]),mn=(0,X.useCallback)(async()=>{if(Y){T(Y.id);try{let e=await ae(Y.id);b(t=>({...t,[Y.id]:e})),Y.active_target_kind!==`bundle`&&await Tt(Y.id),lY(Y.id),Q.success(e.behind===0?`Project branch synced.`:`Project branch updated.`,{id:`app-project-pull-success`})}catch(e){Q.error(e instanceof we?e.message:`Unable to sync the current branch right now.`,{id:`app-project-pull-error`})}finally{T(e=>e===Y.id?null:e)}}},[Y,Tt]),hn=(0,X.useCallback)(()=>{Y&&pe({projectId:Y.id,title:Y.name})},[Y]),gn=(0,X.useCallback)(()=>{if(!fe)return;let{projectId:e}=fe;pe(null),Tt(e),Et(e)},[Tt,Et,fe]),_n=(0,X.useCallback)(()=>{Y&&G({projectId:Y.id,targetKind:Y.active_target_kind??`repo_root`,targetBundleId:Y.active_target_bundle_id??null})},[Y]),vn=(0,X.useCallback)(()=>{G(null)},[]),Sn=I0(ye,s),Cn=Y?EZ(Y.test_commands).length>0:!1,wn=et===`chat`?je:null,Tn=Xe.current,En=Tn?.target?.kind??null,Dn=et===`chat`?En===`ticket`||En===`bundle`?{target:Tn?.target??null,canSelect:!1,disabledReason:`This preview belongs to a ticket run. Return to Board to send preview comments.`,promptMode:Tn?.promptMode??null,onPromptModeChange:Tn?.onPromptModeChange??null,isUpdatingPromptMode:Tn?.isUpdatingPromptMode??!1,promptPlaceholder:Tn?.promptPlaceholder??null,promptComposerControls:Tn?.promptComposerControls,promptComposerInlineControls:Tn?.promptComposerInlineControls,submitPrompt:null}:wn?{target:{kind:`chat_session`,id:wn.chatSessionId??`draft:${s}`},canSelect:wn.canSubmitReviewPrompt,disabledReason:wn.canSubmitReviewPrompt?null:wn.reviewSubmitDisabledReason??`Wait for the current chat turn to finish before sending preview comments.`,promptMode:wn.mode,onPromptModeChange:wn.onModeChange,isUpdatingPromptMode:wn.isUpdatingMode,promptPlaceholder:wn.promptPlaceholder,promptComposerControls:wn.promptComposerControls,promptComposerInlineControls:wn.promptComposerInlineControls,submitPrompt:wn.canSubmitReviewPrompt?wn.submitPrompt:null}:{target:null,canSelect:!1,disabledReason:`Select a chat session to send preview comments.`,submitPrompt:null}:ke,On=wn?.canSubmitReviewPrompt??!1,kn=et===`chat`?wn?wn.reviewSubmitDisabledReason:`Select a chat session to send review comments.`:void 0,An=(0,X.useCallback)(()=>{s&&be(e=>{let t=e[s]??y0;return{...e,[s]:{hasMounted:!0,isOpen:!t.isOpen,isExpanded:t.isExpanded}}})},[s]),jn=(0,X.useCallback)(e=>{be(t=>{let n=t[e]??y0;return!n.hasMounted||!n.isOpen?t:{...t,[e]:y0}})},[]),Mn=(0,X.useCallback)(e=>{be(t=>{let n=t[e]??y0;return{...t,[e]:{hasMounted:!0,isOpen:n.isOpen,isExpanded:!n.isExpanded}}})},[]),Nn=(0,X.useCallback)(()=>{W(`create`)},[]),Pn=(0,X.useCallback)(()=>{if(s){if(ht){Yt();return}A(e=>({...e,[s]:`inline`})),M(e=>({...e,[s]:null}))}},[s,Yt,ht]),Fn=(0,X.useCallback)(()=>{s&&A(e=>{let t=L0(e,s);return{...e,[s]:t===`expanded`?`inline`:`expanded`}})},[s]),In=Y?Y.preview_service_name?.trim()?Y.preview_capability_mode===`force_disabled`?`Preview is disabled for this project.`:pt?.state===`unsupported`?pt.message??`Preview is unavailable for this project.`:ht?`Hide preview`:`Show preview`:`Choose a named preview service in project settings first.`:`Select a project first.`,Ln=!Y||!Y.preview_service_name?.trim()||Y.preview_capability_mode===`force_disabled`||pt?.state===`unsupported`,Rn=Y&&Y.preview_service_name?.trim()?(0,Z.jsx)(cC,{project:Y,mode:mt===`expanded`?`expanded`:`inline`,status:pt,viewportPreset:F,zoom:L,activeRun:gt,reviewCapability:Dn,isStoppingActiveRun:bt,onHide:Yt,onStopActiveRun:()=>{Zt()},onToggleExpanded:Fn,onViewportPresetChange:I,onZoomChange:R}):null;return(0,Z.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden bg-[linear-gradient(180deg,_rgba(15,16,21,1),_rgba(9,10,14,1))] text-foreground`,children:[(0,Z.jsx)(Cf,{}),i.length>0&&(0,Z.jsx)(`header`,{className:`border-b border-border bg-background/95 px-6 py-3 backdrop-blur`,children:(0,Z.jsxs)(`div`,{className:`grid gap-2 lg:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] lg:items-center`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 lg:justify-self-start`,children:(0,Z.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-[20rem] sm:max-w-[30rem]`,children:(0,Z.jsx)(Hu,{activeProjectId:s,projects:i,onEditProject:()=>W(`edit`),onProjectChange:c})})}),s&&(0,Z.jsx)(`div`,{className:`flex justify-start lg:col-start-2 lg:row-start-1 lg:justify-center`,children:(0,Z.jsx)(K1,{activeWorkspace:et,activityByWorkspace:Ce,memoryEnabled:Qe,onWorkspaceChange:e=>{s&&(Se(t=>({...t,[s]:e})),K(t=>j1(t,e)))}})}),(0,Z.jsx)(`div`,{className:`w-full lg:col-start-3 lg:row-start-1 lg:w-auto lg:justify-self-end`,children:(0,Z.jsx)(Sf,{activeTool:e,onCreateProject:Nn,onMobileAccessOpen:()=>Ke(!0),onToolChange:kt})})]})}),le?i.length===0?(0,Z.jsx)(Bu,{activeTool:e,availableHelperModels:ee,helperModel:ie,helperVariant:se,isHelperModelsLoaded:H,isToolLoaded:n,onCreateProject:Nn,onHelperModelChange:e=>{oe(e),ce(``)},onHelperVariantChange:ce,onToolChange:kt}):(0,Z.jsxs)(Z.Fragment,{children:[Y?.has_initial_commit===!1&&(0,Z.jsx)(Mf,{isSubmitting:he,onCreateInitialCommit:()=>{qt()}}),(0,Z.jsx)(W1,{activeProjectId:s,activeProject:Y,activeProjectBranchState:ot,activeRun:l,activeTool:e,onRestoreChatSessionTarget:an,onChatReviewCapabilityChange:Me,isPreviewButtonDisabled:Ln,onPreviewReviewCapabilityChange:Ae,onPreviewToggle:Pn,onRunStopped:Xt,onWorkspaceActivityChange:K,onWorkspaceActivityEvent:wt,previewDisplayMode:mt,previewPane:Rn,previewPaneWidth:N,previewButtonTitle:In,visibleWorkspace:et,refreshKey:De,onBoardLoadedProjectIdChange:p,onBundlesChange:Ht,onBundlesLoadingChange:Ut,onPreviewPaneWidthChange:P,onProjectUsageChange:Vt,onRunStatusChange:()=>{Dt(),Ot()}},s??`no-project`)]}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Loading projects...`}),i.length>0&&(0,Z.jsx)($d,{activeProject:Y,activeRun:l,branchState:ot,targetGitStatus:st,isBoardLoadedForActiveProject:it,isProjectSyncing:w===s,isProjectIdeAvailable:rt,isProjectRunAvailable:nt,isRunStatusLoadedForActiveProject:at,isTerminalOpen:Sn.isOpen,targetBundles:lt,targetBranchSuggestions:dt,isTargetBundleLoading:ut,isTargetSelectorLoading:ft,isTargetGitStatusLoading:ct,hasConfiguredTests:Cn,onProjectIdeOpen:()=>{pn()},onProjectPull:()=>{mn()},onProjectRunToggle:()=>{dn()},onProjectChangesOpen:hn,onProjectTestsOpen:_n,onTerminalToggle:An,onTargetSelectorOpenChange:Qt,onSelectBundleTarget:nn,onSelectRepoRootTarget:rn,onManageBundles:on}),(0,Z.jsx)(Zp,{activeProjectId:s,open:Ge,onOpenChange:Ke}),Ue&&Y&&(0,Z.jsx)(Uf,{bundles:lt,selectedBundleId:Y.active_target_kind===`bundle`?Y.active_target_bundle_id??null:null,activeTargetBundleId:Y.active_target_kind===`bundle`?Y.active_target_bundle_id??null:null,onSelectBundle:cn,onCreateBundle:ln,onDeleteBundle:un,onClose:sn}),qe&&(0,Z.jsx)(jf,{title:qe.title,description:qe.description,confirmLabel:qe.confirmLabel,cancelLabel:qe.cancelLabel,confirmVariant:qe.confirmVariant,onConfirm:()=>en(!0),onCancel:()=>en(!1)}),i.map(e=>{let t=I0(ye,e.id);return t.hasMounted?(0,Z.jsx)(G1,{project:e,isExpanded:t.isExpanded,isVisible:e.id===s&&t.isOpen,onClose:()=>jn(e.id),onToggleExpanded:()=>Mn(e.id)},e.id):null}),de&&(0,Z.jsx)(eg,{mode:de,projectId:de===`edit`&&Y?Y.id:null,availableHelperModels:ee,isLoadingHelperModels:!H,isAutoConfigReady:n,initialValues:de===`edit`&&Y?D0(Y):i.length===0?{name:``,repoPath:``,linkedProjectIds:[],runSetup:[],runServices:[],testCommands:[],runIde:``,previewServiceName:``,previewPath:``,previewCapabilityMode:`auto`,helperModel:ie,helperVariant:se,commitMessageRules:``,autoParkStaleTickets:!1,memoryEnabled:!1,worktreeSync:[]}:void 0,linkedProjectOptions:i.filter(e=>e.id!==Y?.id).map(e=>({id:e.id,name:e.name})),repoPathLocked:de===`edit`&&Y?Y.repo_path_locked:!1,repoPathLockedMessage:de===`edit`&&Y?j0(Y):null,deleteBlockedMessage:de===`edit`&&Y?M0(Y,i):null,onDelete:de===`edit`?Ft:void 0,onAutoConfig:Wt,onBrowseRepoPath:Gt,onValidateRepoPath:Kt,onClose:()=>W(null),onSubmit:de===`edit`?Pt:Nt}),fe&&fe.projectId===s&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(x0,{scope:`project_root`,projectId:fe.projectId,title:fe.title,onSubmitReviewPrompt:wn?.submitPrompt,canSubmitReviewPrompt:On,reviewSubmitDisabledReason:kn??void 0,canAddReviewComments:On,canModifyChanges:!0,onClose:gn})}),me&&me.projectId===s&&Y&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(S0,{scope:`project`,projectId:me.projectId,targetKind:me.targetKind,targetBundleId:me.targetBundleId,testCommands:EZ(Y.test_commands),onClose:vn})})]})},X0=({className:e})=>(0,Z.jsx)(Ac,{"aria-hidden":`true`,className:e}),Z0=({className:e})=>(0,Z.jsx)(Nc,{"aria-hidden":`true`,className:e}),Q0=({className:e})=>(0,Z.jsx)(Kc,{"aria-hidden":`true`,className:e}),$0=`X-Archon-Mobile-CSRF`,e2=async(e,t={})=>{let n=await fetch(e,{credentials:`include`,...t});if(!n.ok)throw new we(await D(n,`Mobile request failed.`),n.status);return n},t2=async(e,t={})=>await(await e2(e,t)).json(),n2=e=>t2(`/mobile/projects`,{signal:e}),r2=(e,t)=>t2(`/mobile/projects/${encodeURIComponent(e)}/summary`,{signal:t}),i2=(e,t)=>t2(`/mobile/projects/${encodeURIComponent(e)}/target-options`,{signal:t}),a2=(e,t)=>t2(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions`,{signal:t}),o2=(e,t,n)=>t2(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions/${encodeURIComponent(t)}`,{signal:n}),s2=(e,t)=>t2(`/mobile/projects/${encodeURIComponent(e)}/tickets`,{signal:t}),c2=(e,t,n)=>t2(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}`,{signal:n}),l2=(e,t,n)=>t2(`/mobile/projects/${encodeURIComponent(e)}/bundles/${encodeURIComponent(t)}`,{signal:n}),u2=(e,t,n)=>t2(`/mobile/projects/${encodeURIComponent(e)}/bundles/${encodeURIComponent(t)}/build`,f2(n)),d2=(e,t,n)=>t2(`/mobile/projects/${encodeURIComponent(e)}/bundles/${encodeURIComponent(t)}/review`,f2(n)),f2=(e,t,n=`POST`)=>({method:n,headers:{"Content-Type":`application/json`,[$0]:e},body:t===void 0?void 0:JSON.stringify(t)}),p2=(e,t,n)=>t2(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions`,f2(t,n)),m2=(e,t,n,r)=>t2(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions/${encodeURIComponent(t)}/messages`,f2(n,r)),h2=(e,t,n,r)=>t2(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions/${encodeURIComponent(t)}`,f2(n,r,`PATCH`)),g2=(e,t,n)=>t2(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions/${encodeURIComponent(t)}/stop`,f2(n)),_2=(e,t,n,r)=>t2(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/state`,f2(n,{state:r},`PATCH`)),v2=(e,t,n)=>t2(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/run`,f2(n)),y2=(e,t,n)=>t2(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/stop`,f2(n)),b2=(e,t)=>t2(`/mobile/runs/${encodeURIComponent(e)}/stop`,f2(t)),x2=(e,t,n)=>t2(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/stop-build`,f2(n)),S2=(e,t,n)=>t2(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/resume-build`,f2(n)),C2=(e,t,n,r)=>t2(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}`,f2(n,r,`PATCH`)),w2=(e,t,n,r)=>t2(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/plan-follow-up`,f2(n,{instruction:r})),T2=(e,t,n,r)=>t2(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/follow-up`,f2(n,{instruction:r})),E2=(e,t,n,r)=>t2(`/mobile/projects/${encodeURIComponent(e)}/bundles/${encodeURIComponent(t)}/follow-up`,f2(n,{instruction:r})),D2=(e,t,n)=>t2(`/mobile/projects/${encodeURIComponent(e)}/target`,f2(t,n)),O2=(e,t)=>t2(`/mobile/models?tool=${encodeURIComponent(e)}`,{signal:t}),k2=(e,t,n)=>{let r=new URLSearchParams({tool:e});return t&&r.set(`project_id`,t),t2(`/mobile/skills?${r.toString()}`,{signal:n})},A2=e=>t2(`/mobile-auth/status`,{signal:e}),j2=(e,t)=>t2(`/mobile-auth/pair/preview`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t}),M2=e=>t2(`/mobile-auth/pair`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),N2=e=>t2(`/mobile-auth/logout`,{method:`POST`,headers:{[$0]:e}}),P2=()=>YK(window.location.origin,{withCredentials:!0}),F2=e=>Oe.t(`common:mobileApp.${e}`),I2={key:`overview`,label:F2(`navigation.overview`),Icon:X0},L2={key:`tickets`,label:F2(`navigation.tickets`),Icon:Q0,ctaAriaLabel:F2(`overviewActions.ticketsAriaLabel`)},R2={key:`chats`,label:F2(`navigation.chats`),Icon:vg,ctaAriaLabel:F2(`overviewActions.chatsAriaLabel`)},z2=[I2,L2,R2],B2=`Project root has uncommitted changes. Confirm branch switch to continue.`,V2=e=>e?`Repo root (${e})`:`Repo root`,H2=e=>{if(!e)return`Repo root`;if(e.length<=20)return e;let t=e.split(`/`).filter(Boolean),n=t[t.length-1]??e;return n.length<=17?`.../${n}`:`${n.slice(0,16)}...`},U2=(e,t)=>{if(!e)return`Target`;if(e.active_target_kind===`bundle`&&e.active_target_bundle_id){let n=t?.bundles.find(t=>t.id===e.active_target_bundle_id)??null;return n?Ud(n):`Selected bundle`}return H2(t?.current_branch??null)},W2=({children:e})=>(0,Z.jsx)(`main`,{className:`min-h-screen bg-background text-foreground`,children:(0,Z.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-lg items-center px-4 py-8`,children:(0,Z.jsx)(`div`,{className:`w-full`,children:e})})}),G2=({title:e,description:t,children:n})=>(0,Z.jsx)(W2,{children:(0,Z.jsxs)(Nf,{className:`w-full border-border/80 bg-card/90 shadow-2xl shadow-black/20`,children:[(0,Z.jsxs)(Pf,{children:[(0,Z.jsx)(Ff,{children:e}),(0,Z.jsx)(If,{children:t})]}),n?(0,Z.jsx)(Rf,{className:`space-y-4`,children:n}):null]})}),K2=e=>e===`connected`?{label:`Connected`,variant:`success`,indicatorState:`finished`}:e===`reconnecting`?{label:`Reconnecting`,variant:`warning`,indicatorState:`running`}:e===`unavailable`?{label:`Offline`,variant:`destructive`,indicatorState:`error`}:{label:`Connecting`,variant:`outline`,indicatorState:`running`},q2=({status:e})=>{let t=K2(e);return(0,Z.jsxs)(q,{variant:t.variant,className:`gap-1.5 px-2.5 py-1 text-[11px] uppercase tracking-[0.14em]`,children:[(0,Z.jsx)(ef,{state:t.indicatorState,className:`mt-0`}),t.label]})},J2=()=>{let[e,t]=(0,X.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(min-width: 1024px)`).matches);return(0,X.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(min-width: 1024px)`),n=n=>{t(n?.matches??e.matches)};return n(),typeof e.addEventListener==`function`?(e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)):(e.addListener(n),()=>e.removeListener(n))},[]),e},Y2=({status:e,onRetry:t})=>e===`connected`?null:e===`unavailable`?(0,Z.jsx)(Nf,{className:`border-red-500/25 bg-destructive/10 shadow-none`,children:(0,Z.jsxs)(Rf,{className:`flex flex-col gap-3 pt-5`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-red-100`,children:`Desktop Archon is currently unreachable.`}),(0,Z.jsx)(`p`,{className:`text-sm text-red-200/85`,children:`Mobile access may have been disabled, the backend may have restarted, or this phone lost network access.`})]}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(J,{variant:`warning`,onClick:t,children:`Retry connection`})})]})}):(0,Z.jsx)(Nf,{className:`border-amber-500/25 bg-amber-500/10 shadow-none`,children:(0,Z.jsx)(Rf,{className:`pt-5 text-sm text-amber-100`,children:e===`connecting`?`Connecting to live updates from desktop Archon...`:`Reconnecting to desktop Archon. Existing content stays visible while this phone reconnects.`})}),X2=({title:e,description:t,children:n})=>(0,Z.jsxs)(`div`,{className:`flex max-h-[80vh] flex-col overflow-hidden`,children:[(0,Z.jsxs)(Zl,{className:`border-b border-border/70 px-4 py-4`,children:[(0,Z.jsx)($l,{children:e}),t?(0,Z.jsx)(eu,{children:t}):null]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:n})]}),Z2=({projects:e,selectedProjectId:t,error:n,onSelectProject:r,onRetry:i})=>n?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-red-200`,children:n}),(0,Z.jsx)(J,{variant:`warning`,onClick:i,children:`Retry projects`})]}):e?e.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No projects are available on the desktop instance yet.`}):(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>{let n=e.id===t;return(0,Z.jsxs)(`button`,{type:`button`,className:W(`w-full rounded-2xl border px-4 py-3 text-left transition-colors`,n?`border-primary/50 bg-primary/10`:`border-border/80 bg-card/60 hover:border-primary/30 hover:bg-accent/60`),onClick:()=>r(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.repo_path})]}),n&&(0,Z.jsx)(q,{variant:`info`,children:`Current`})]}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.14em] text-muted-foreground`,children:(0,Z.jsxs)(`span`,{children:[e.ticket_count,` tickets`]})})]},e.id)})}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading projects...`}),Q2=({open:e,projects:t,selectedProjectId:n,error:r,onOpenChange:i,onSelectProject:a,onRetry:o})=>(0,Z.jsx)(Kl,{open:e,onOpenChange:i,children:(0,Z.jsx)(Xl,{showCloseButton:!1,"aria-describedby":void 0,className:`top-auto right-0 bottom-0 left-0 max-w-none translate-x-0 translate-y-0 overflow-hidden rounded-t-3xl rounded-b-none border-x-0 border-b-0 p-0 sm:top-1/2 sm:right-auto sm:bottom-auto sm:left-1/2 sm:max-w-md sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl sm:border sm:p-0`,children:(0,Z.jsx)(X2,{title:`Projects`,children:(0,Z.jsx)(Z2,{projects:t,selectedProjectId:n,error:r,onSelectProject:e=>{a(e),i(!1)},onRetry:o})})})}),$2=({open:e,project:t,targetOptions:n,error:r,isLoading:i,isSubmitting:a,onOpenChange:o,onRetry:s,onSelectBundle:c,onSelectRepoRoot:l})=>{let[u,d]=(0,X.useState)(``);(0,X.useEffect)(()=>{e&&d(n?.current_branch??``)},[e,n?.current_branch]);let f=t?.active_target_kind!==`bundle`,p=Nd(n?.bundles??[]),m=[{key:`default`,label:`Default branch`,branch:n?.default_branch??null},{key:`previous`,label:`Previous branch`,branch:n?.previous_branch??null}].filter(e=>e.branch&&e.branch!==n?.current_branch).filter((e,t,n)=>n.findIndex(t=>t.branch===e.branch)===t),h=t?r?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-red-200`,children:r}),(0,Z.jsx)(J,{variant:`warning`,onClick:s,children:`Retry target options`})]}):n?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:`Project target`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Choose the repo root or a prepared bundle for new chats and desktop work launched from this phone.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(mu,{className:`text-xs font-medium text-muted-foreground`,children:`Target`}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border/70 bg-background/40 p-2`,children:[(0,Z.jsx)(J,{type:`button`,variant:f?`secondary`:`ghost`,className:`w-full justify-start`,disabled:a,onClick:()=>l(null),children:V2(n.current_branch)}),(0,Z.jsxs)(`div`,{className:`relative min-h-10`,"data-testid":`mobile-target-options`,children:[i&&(0,Z.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-10 text-muted-foreground`,"data-testid":`mobile-target-options-spinner`,children:(0,Z.jsx)(ye,{className:`h-3.5 w-3.5 animate-spin`})}),(0,Z.jsx)(`div`,{className:`max-h-40 overflow-y-auto pr-7`,children:p.length===0&&!i?(0,Z.jsx)(`p`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:`No prepared bundles are available yet.`}):p.map(e=>(0,Z.jsx)(J,{type:`button`,variant:t.active_target_kind===`bundle`&&t.active_target_bundle_id===e.id?`secondary`:`ghost`,className:`w-full justify-start`,disabled:a,onClick:()=>c(e.id),children:(0,Z.jsx)(`span`,{className:`truncate`,children:Ud(e)})},e.id))})]})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(mu,{className:`text-xs font-medium text-muted-foreground`,children:`Repo root branch`}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border/70 bg-background/40 p-3`,children:[(0,Z.jsx)(`div`,{className:`space-y-2`,children:m.length>0?m.map(({key:e,label:t,branch:n})=>(0,Z.jsxs)(J,{type:`button`,variant:`outline`,className:`w-full justify-between gap-3`,disabled:!f||a||!n,onClick:()=>l(n),children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n})]},e)):(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i?`Loading branch suggestions...`:`No suggested branches available.`})}),(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsx)(mu,{htmlFor:`mobile-project-target-branch-input`,className:`text-xs text-muted-foreground`,children:`Switch or create branch`}),(0,Z.jsx)(Ae,{id:`mobile-project-target-branch-input`,value:u,disabled:!f||a,onChange:e=>d(e.target.value),placeholder:`feature/quick-fix`})]}),(0,Z.jsx)(J,{type:`button`,disabled:!f||!u.trim()||a,onClick:()=>l(u.trim()),children:`Switch`})]}),f?null:(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Switch to repo root to choose a branch.`})]})]})]}):(0,Z.jsx)(i4,{text:`Loading target options...`}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select a project before choosing a target.`});return(0,Z.jsx)(Kl,{open:e,onOpenChange:o,children:(0,Z.jsx)(Xl,{showCloseButton:!1,"aria-describedby":void 0,className:`top-auto right-0 bottom-0 left-0 max-w-none translate-x-0 translate-y-0 overflow-hidden rounded-t-3xl rounded-b-none border-x-0 border-b-0 p-0 sm:top-1/2 sm:right-auto sm:bottom-auto sm:left-1/2 sm:max-w-md sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl sm:border sm:p-0`,children:(0,Z.jsx)(X2,{title:`Target`,description:t?U2(t,n):void 0,children:h})})})},e4=({selectedProject:e,targetLabel:t,isTargetLoading:n,isTargetDisabled:r,connectionState:i,onOpenProjects:a,onOpenTargetSelector:o})=>(0,Z.jsx)(`header`,{className:`sticky top-0 z-20 border-b border-border/70 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl items-center justify-between gap-3 px-3 pb-3 pt-4 sm:px-4`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":`Choose project`,className:`min-w-0 flex-1 text-left`,onClick:a,children:[(0,Z.jsx)(`div`,{className:`truncate text-base font-medium text-foreground`,children:e?.name??`Choose a project`}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e?.repo_path??`Select a desktop project to continue`})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsx)(q2,{status:i}),(0,Z.jsxs)(J,{variant:`outline`,size:`sm`,"aria-label":`Choose target`,"data-testid":`mobile-target-trigger`,className:`h-8 max-w-32 gap-2 px-2.5 sm:max-w-40`,disabled:r,onClick:o,children:[(0,Z.jsx)(Gd,{className:`h-3.5 w-3.5 shrink-0`}),n?(0,Z.jsx)(Wu,{className:`h-3.5 w-16`}):(0,Z.jsx)(`span`,{className:`truncate text-xs sm:text-sm`,children:t})]}),(0,Z.jsx)(J,{variant:`outline`,size:`icon-sm`,"aria-label":`Choose project`,onClick:a,children:(0,Z.jsx)(wm,{className:`h-4 w-4`})})]})]})}),t4=({activeSection:e,onChange:t})=>(0,Z.jsx)(`nav`,{className:`fixed inset-x-0 bottom-0 z-20 border-t border-border/70 bg-background/95 px-3 pb-[calc(env(safe-area-inset-bottom)+0.75rem)] pt-2 backdrop-blur supports-[backdrop-filter]:bg-background/85 sm:px-4 lg:hidden`,children:(0,Z.jsx)(`div`,{className:`mx-auto flex max-w-6xl gap-2`,children:z2.map(n=>{let r=n.key===e,i=n.Icon;return(0,Z.jsxs)(J,{type:`button`,variant:r?`secondary`:`ghost`,className:`h-11 flex-1 gap-2`,"aria-current":r?`page`:void 0,onClick:()=>t(n.key),children:[(0,Z.jsx)(i,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:n.label})]},n.key)})})}),n4=({title:e,description:t,action:n})=>(0,Z.jsxs)(Nf,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsxs)(Pf,{children:[(0,Z.jsx)(Ff,{children:e}),(0,Z.jsx)(If,{children:t})]}),n?(0,Z.jsx)(Rf,{children:n}):null]}),r4=({label:e,value:t,accentClassName:n})=>(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border/70 bg-card/70 p-3`,children:[(0,Z.jsx)(`div`,{className:W(`text-xl font-semibold text-foreground`,n),children:t}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs uppercase tracking-[0.14em] text-muted-foreground`,children:e})]}),i4=({text:e})=>(0,Z.jsxs)(`div`,{"aria-live":`polite`,className:`flex items-center gap-2 px-1 py-3 text-sm text-muted-foreground`,role:`status`,children:[(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}),(0,Z.jsx)(`span`,{children:e})]}),a4=()=>(0,Z.jsxs)(`div`,{className:`space-y-3`,"data-testid":`mobile-overview-skeleton`,children:[(0,Z.jsxs)(Nf,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsx)(Pf,{className:`border-b border-border/70 pb-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(Wu,{className:`h-6 w-28`}),(0,Z.jsx)(Wu,{className:`h-6 w-28 rounded-full`})]})}),(0,Z.jsxs)(Rf,{className:`space-y-4 pt-5`,children:[(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3`,children:Array.from({length:6},(e,t)=>(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border/70 bg-card/70 p-3`,children:[(0,Z.jsx)(Wu,{className:`h-6 w-10`}),(0,Z.jsx)(Wu,{className:`mt-2 h-3 w-16`})]},t))}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,Z.jsx)(Wu,{className:`h-10 w-full rounded-xl`}),(0,Z.jsx)(Wu,{className:`h-10 w-full rounded-xl`})]})]})]}),(0,Z.jsxs)(Nf,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsx)(Pf,{children:(0,Z.jsx)(Wu,{className:`h-6 w-20`})}),(0,Z.jsx)(Rf,{children:(0,Z.jsx)(Wu,{className:`h-10 w-40 rounded-xl`})})]})]}),o4=({isLoggingOut:e,onLogout:t})=>(0,Z.jsxs)(Nf,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsx)(Pf,{children:(0,Z.jsx)(Ff,{children:`Session`})}),(0,Z.jsx)(Rf,{children:(0,Z.jsxs)(J,{variant:`destructive`,className:`gap-2`,disabled:e,onClick:t,children:[(0,Z.jsx)(Z0,{className:`h-4 w-4`}),e?`Logging out...`:`Log out this phone`]})})]}),s4=({activeRun:e,tickets:t,chatSessions:n,chatSessionDetail:r})=>{if(e)return{label:e.kind===`ticket`?`Ticket run active`:`Project run active`,variant:`success`};if(r?.agent_status===`running`||n?.some(e=>e.agent_status===`running`))return{label:`Chat active`,variant:`success`};let i=t?.filter(e=>e.agent_status===`running`&&e.parked_at===null)??[];return i.some(e=>e.state===`review`)?{label:`Reviewing`,variant:`warning`}:i.some(e=>e.state===`build`)?{label:`Building`,variant:`success`}:i.some(e=>e.state===`plan`)?{label:`Planning`,variant:`info`}:{label:`Idle`,variant:`outline`}},c4=({activeRun:e,tickets:t,chatSessions:n,chatSessionDetail:r})=>{let i=s4({activeRun:e,tickets:t,chatSessions:n,chatSessionDetail:r});return(0,Z.jsx)(q,{variant:i.variant,children:i.label})},l4=({selectedProjectId:e,summary:t,tickets:n,error:r,chatSessions:i,chatSessionDetail:a,stoppingRunContextKey:o,stopRunError:s,onRetry:c,onStopRun:l,onOpenTickets:u,onOpenChats:d})=>{let f=L2.Icon,p=R2.Icon;return r?(0,Z.jsx)(n4,{title:`Project summary unavailable`,description:r,action:(0,Z.jsx)(J,{variant:`warning`,onClick:c,children:`Retry summary`})}):e?!t||t.project.id!==e?(0,Z.jsx)(Nf,{className:`border-border/80 bg-card/70 shadow-none`,children:(0,Z.jsx)(Rf,{className:`pt-5 text-sm text-muted-foreground`,children:`Loading project summary...`})}):(0,Z.jsxs)(Nf,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsxs)(Pf,{className:`border-b border-border/70 pb-4`,children:[(0,Z.jsx)(Ff,{children:`Overview`}),(0,Z.jsx)(Lf,{children:(0,Z.jsx)(c4,{activeRun:t.active_run,tickets:n,chatSessions:i,chatSessionDetail:a})})]}),(0,Z.jsxs)(Rf,{className:`space-y-4 pt-5`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3`,children:[(0,Z.jsx)(r4,{label:`Tickets`,value:t.tickets.total}),(0,Z.jsx)(r4,{label:`Plan`,value:t.tickets.plan,accentClassName:`text-sky-200`}),(0,Z.jsx)(r4,{label:`Build`,value:t.tickets.build,accentClassName:`text-emerald-200`}),(0,Z.jsx)(r4,{label:`Review`,value:t.tickets.review,accentClassName:`text-amber-200`}),(0,Z.jsx)(r4,{label:`Done`,value:t.tickets.parked}),(0,Z.jsx)(r4,{label:`Bundles`,value:t.project.bundle_count??0})]}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,Z.jsxs)(J,{variant:`outline`,className:`gap-2`,"aria-label":L2.ctaAriaLabel,onClick:u,children:[(0,Z.jsx)(f,{className:`h-4 w-4`}),L2.label]}),(0,Z.jsxs)(J,{variant:`outline`,className:`gap-2`,"aria-label":R2.ctaAriaLabel,onClick:d,children:[(0,Z.jsx)(p,{className:`h-4 w-4`}),R2.label]})]}),t.active_run?(0,Z.jsxs)(`div`,{className:`space-y-3 rounded-2xl border border-amber-500/25 bg-amber-500/10 p-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-amber-100`,children:`Stopping this run terminates the active desktop process for this project.`}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,Z.jsx)(J,{variant:`warning`,disabled:o===t.active_run.context_key,onClick:()=>l(t.active_run?.context_key??``),children:o===t.active_run.context_key?`Stopping active run...`:`Stop active run`})}),s?(0,Z.jsx)(`p`,{className:`text-sm text-red-200`,children:s}):null]}):null]})]}):(0,Z.jsx)(n4,{title:`Choose a project`,description:`Select a desktop project before opening tickets or chats from this phone.`})},u4=e=>e.parked_at?`parked`:e.state,d4=e=>{let t=u4(e);return t===`parked`?`Done`:`${t.slice(0,1).toUpperCase()}${t.slice(1)}`},f4=e=>e===`plan`?`info`:e===`build`?`success`:e===`review`?`warning`:`outline`,p4=({ticket:e,isSelected:t,onSelectTicket:n,className:r})=>(0,Z.jsxs)(`button`,{type:`button`,className:W(`w-full rounded-2xl border px-4 py-3 text-left transition-colors`,t?`border-primary/50 bg-primary/10`:`border-border/70 bg-card/40 hover:border-primary/30 hover:bg-accent/50`,r),onClick:()=>n(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.title})}),(0,Z.jsx)(q,{variant:f4(u4(e)),children:d4(e)})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.14em] text-muted-foreground`,children:[e.agent_status?(0,Z.jsx)(`span`,{children:e.agent_status}):null,e.branch?(0,Z.jsx)(`span`,{children:e.branch}):null,e.bundle?.name?(0,Z.jsx)(`span`,{children:e.bundle.name}):null]})]}),m4=({group:e,selectedBundleId:t,selectedTicketId:n,onSelectBundle:r,onSelectTicket:i})=>{let a=e.bundle.id===t,o=e.tickets.some(e=>e.id===n),[s,c]=(0,X.useState)(o),l=Ud(e.bundle)||e.bundle.branch||e.bundle.name||`Bundle`,u=e.tickets.filter(e=>e.agent_status===`running`).length,d=a||o;return(0,X.useEffect)(()=>{o&&c(!0)},[o]),(0,Z.jsxs)(vp,{open:s,onOpenChange:c,children:[(0,Z.jsxs)(`div`,{className:W(`flex items-start gap-2 rounded-2xl border px-4 py-3 transition-colors`,d?`border-primary/50 bg-primary/10`:`border-border/70 bg-card/40 hover:border-primary/30 hover:bg-accent/50`),children:[(0,Z.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,"aria-label":`Open bundle ${l}`,onClick:()=>r(e.bundle.id),children:(0,Z.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(q,{variant:`outline`,children:`Bundle`}),(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:l})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[e.tickets.length,` ticket`,e.tickets.length===1?``:`s`]}),u>0?(0,Z.jsxs)(`span`,{children:[u,` running`]}):null,e.bundle.branch?(0,Z.jsx)(`span`,{children:e.bundle.branch}):null]})]})})}),(0,Z.jsx)(yp,{asChild:!0,children:(0,Z.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mt-0.5 shrink-0`,"aria-label":`Toggle bundle tickets for ${l}`,children:(0,Z.jsx)(oe,{className:W(`h-4 w-4 transition-transform`,s&&`rotate-180`)})})})]}),(0,Z.jsx)(bp,{className:`pt-2`,children:(0,Z.jsx)(`div`,{className:`space-y-2 pl-3`,children:e.tickets.map(t=>(0,Z.jsx)(p4,{ticket:t,isSelected:t.id===n,onSelectTicket:t=>i(t,e.bundle.id),className:`rounded-xl`},t.id))})})]})},h4=(e,t)=>Rd(e,[],t),g4=e=>[{key:`plan`,label:`Plan`,tickets:e.filter(e=>!e.parked_at&&e.state===`plan`),items:h4(e.filter(e=>!e.parked_at&&e.state===`plan`),`plan`)},{key:`build`,label:`Build`,tickets:e.filter(e=>!e.parked_at&&e.state===`build`),items:h4(e.filter(e=>!e.parked_at&&e.state===`build`),`build`)},{key:`review`,label:`Review`,tickets:e.filter(e=>!e.parked_at&&e.state===`review`),items:h4(e.filter(e=>!e.parked_at&&e.state===`review`),`review`)},{key:`parked`,label:`Done`,tickets:e.filter(e=>e.parked_at),items:h4(e.filter(e=>e.parked_at),`done`)}].filter(e=>e.tickets.length>0),_4=(e,t)=>{if(!e)return e;let n=new Map(t.tickets.map(e=>[e.id,e]));return e.map(e=>n.get(e.id)??e)},v4=({selectedProjectId:e,tickets:t,selectedBundleId:n,selectedTicketId:r,error:i,onRetry:a,onSelectBundle:o,onSelectTicket:s})=>{if(!e)return(0,Z.jsx)(n4,{title:`Choose a project`,description:`Select a project before browsing tickets from this phone.`});if(i)return(0,Z.jsx)(n4,{title:`Tickets unavailable`,description:i,action:(0,Z.jsx)(J,{variant:`warning`,onClick:a,children:`Retry tickets`})});if(!t)return(0,Z.jsx)(Nf,{className:`border-border/80 bg-card/70 shadow-none`,children:(0,Z.jsx)(Rf,{className:`pt-5 text-sm text-muted-foreground`,children:`Loading tickets...`})});if(t.length===0)return(0,Z.jsx)(n4,{title:`No tickets`,description:`This project does not have any tickets yet.`});let c=g4(t);return(0,Z.jsxs)(Nf,{className:`border-border/80 bg-card/70 shadow-none lg:flex lg:min-h-0 lg:flex-col`,children:[(0,Z.jsxs)(Pf,{className:`border-b border-border/70 pb-4`,children:[(0,Z.jsx)(Ff,{children:`Tickets`}),(0,Z.jsxs)(If,{children:[t.length,` total`]})]}),(0,Z.jsx)(Rf,{className:`space-y-4 pt-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto`,children:c.map(e=>(0,Z.jsxs)(`section`,{className:`space-y-2`,"aria-label":`${e.label} tickets`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:e.label}),(0,Z.jsx)(`span`,{children:e.tickets.length})]}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.items.map(e=>e.kind===`bundle`?(0,Z.jsx)(m4,{group:e.group,selectedBundleId:n,selectedTicketId:r,onSelectBundle:o,onSelectTicket:s},e.group.id):(0,Z.jsx)(p4,{ticket:e.ticket,isSelected:e.ticket.id===r,onSelectTicket:e=>s(e,null)},e.ticket.id))})]},e.key))})]})},y4=({selectedProjectId:e,chatSessions:t,selectedChatSessionId:n,error:r,onRetry:i,onOpenNewChat:a,onSelectChat:o})=>e?r?(0,Z.jsx)(n4,{title:`Chats unavailable`,description:r,action:(0,Z.jsx)(J,{variant:`warning`,onClick:i,children:`Retry chats`})}):(0,Z.jsxs)(Nf,{className:`border-border/80 bg-card/70 shadow-none lg:flex lg:min-h-0 lg:flex-col`,children:[(0,Z.jsxs)(Pf,{className:`border-b border-border/70 pb-4`,children:[(0,Z.jsx)(Ff,{children:`Chats`}),(0,Z.jsx)(If,{children:t?`${t.length} recent`:`Loading chats...`}),(0,Z.jsx)(Lf,{children:(0,Z.jsx)(J,{variant:`outline`,size:`sm`,onClick:a,children:`New chat`})})]}),(0,Z.jsx)(Rf,{className:`space-y-2 pt-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto`,children:t?t.length===0?(0,Z.jsx)(n4,{title:`No chats`,description:`Start a new chat to plan or build from this project.`,action:(0,Z.jsx)(J,{onClick:a,children:`Start a chat`})}):t.map(e=>(0,Z.jsx)(`button`,{type:`button`,className:W(`w-full rounded-xl border px-3 py-2.5 text-left transition-colors`,e.id===n?`border-primary/50 bg-primary/10`:`border-border/70 bg-card/40 hover:border-primary/30 hover:bg-accent/50`),onClick:()=>o(e.id),children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 pr-2 text-sm font-medium text-foreground line-clamp-2 break-words`,children:e.title}),(0,Z.jsx)(q,{variant:e.agent_status===`running`?`warning`:e.mode===`plan`?`info`:`success`,children:e.agent_status??e.mode})]})},e.id)):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading chats...`})})]}):(0,Z.jsx)(n4,{title:`Choose a project`,description:`Select a project before browsing chats from this phone.`}),b4=({label:e,disabled:t,onClick:n})=>(0,Z.jsx)(J,{type:`button`,variant:`outline`,disabled:t,onClick:n,children:e}),x4=e=>{let t=e.tickets.filter(e=>!e.parked_at),n=t.filter(e=>e.state===`plan`),r=t.filter(e=>e.state===`build`),i=t.filter(e=>e.state===`review`),a=t.some(e=>e.agent_status===`running`),o=t.find(e=>UE(e)&&e.agent_status===`running`&&!!e.session_id)??null,s=t.find(e=>UE(e)&&e.agent_status===`stopped`&&!!e.session_id)??null,c=[];n.length>0&&c.push({id:`build`,label:`Build Bundle`,pendingLabel:`Building Bundle...`,ariaLabel:`Build Bundle`,disabled:!1,disabledReason:null});let l=r.length>0&&r.every(e=>e.agent_status===`done`),u=r.length===0&&i.length>0&&e.can_re_review===!0&&!a;return(l||u)&&c.push({id:`review`,label:u?`Re-run review`:`Review Bundle`,pendingLabel:`Reviewing Bundle...`,ariaLabel:u?`Re-run review`:`Review Bundle`,disabled:!1,disabledReason:null}),o&&c.push({id:`pause-build`,label:`Pause Build`,pendingLabel:`Pausing Build...`,ariaLabel:`Pause Build`,title:`Pause the build session. You can resume it later.`,disabled:!1,disabledReason:null}),!o&&s&&c.push({id:`resume-build`,label:`Resume`,pendingLabel:`Resuming...`,ariaLabel:`Resume`,disabled:!1,disabledReason:null}),{actions:c,runningBuildTicketId:o?.id??null,resumableBuildTicketId:s?.id??null}},S4=({ticket:e,actionState:t,actionError:n,onAction:r})=>{let i=nq(e,{reviewLabel:e.worktree_bundle_id===null?`Review`:`Review Bundle`}),a=e.worktree_bundle_id===null&&e.state===`review`&&e.can_re_review===!0&&e.agent_status!==`running`&&!e.parked_at?[{id:`review`,label:`Re-run review`,pendingLabel:`Re-running review...`,ariaLabel:`Re-run review`,disabled:!1,disabledReason:null},...i]:i;return a.length===0?null:(0,Z.jsx)(eq,{actions:a,activeAction:t,disableWhenActive:!0,className:`space-y-3`,heading:`Actions`,headingClassName:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,actionsClassName:`flex flex-wrap gap-2`,showDisabledReason:!0,disabledReasonClassName:`text-sm text-amber-200`,error:n,errorClassName:`text-sm text-red-200`,renderAction:({action:e,label:t,disabled:n})=>(0,Z.jsx)(b4,{label:t,disabled:n,onClick:()=>r(e.id)},e.id)})},C4=({bundleDetail:e,actionState:t,actionError:n,onAction:r})=>{let{actions:i}=x4(e);return i.length===0?null:(0,Z.jsx)(eq,{actions:i,activeAction:t,disableWhenActive:!0,className:`space-y-3`,heading:`Actions`,headingClassName:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,actionsClassName:`flex flex-wrap gap-2`,error:n,errorClassName:`text-sm text-red-200`,renderAction:({action:e,label:t,disabled:n})=>(0,Z.jsx)(b4,{label:t,disabled:n,onClick:()=>r(e.id)},e.id)})},w4=(e,t)=>(e??[]).map(e=>({id:e.id,role:e.role,kind:e.kind,content:e.content,created_at:e.created_at,ticket_id:t??null,ticket_proposals:`ticket_proposals`in e?e.ticket_proposals??null:null})),T4=({title:e,subtitle:t,badges:n,backLabel:r,onBack:i,action:a})=>(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[i?(0,Z.jsxs)(J,{variant:`ghost`,size:`sm`,className:`h-8 px-2.5 lg:hidden`,"aria-label":r,onClick:i,children:[(0,Z.jsx)(bD,{className:`h-4 w-4`}),`Back`]}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e}),t?(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:t}):null]})]}),a?(0,Z.jsx)(`div`,{className:`shrink-0`,children:a}):null]}),n?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n}):null]}),E4=({title:e,backLabel:t,onBack:n,action:r})=>(0,Z.jsxs)(`div`,{className:`-mx-3 flex shrink-0 items-center justify-between gap-3 border-b border-border/80 bg-background/95 px-3 py-2.5 backdrop-blur supports-[backdrop-filter]:bg-background/85 sm:-mx-4 sm:px-4 lg:hidden`,children:[(0,Z.jsxs)(J,{variant:`ghost`,size:`sm`,className:`h-8 px-2.5`,"aria-label":t,onClick:n,children:[(0,Z.jsx)(bD,{className:`h-4 w-4`}),`Back`]}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`shrink-0`,children:r})]}),D4=({title:e,backLabel:t,onBack:n,action:r,subheader:i,children:a})=>(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Z.jsx)(E4,{title:e,backLabel:t,onBack:n,action:r}),i?(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-border/70 py-2 lg:hidden`,children:i}):null,(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:a})]}),O4=({value:e,onTranscript:t,onDetails:n})=>(0,Z.jsxs)(`div`,{className:`flex gap-2 px-3 sm:px-0`,children:[(0,Z.jsx)(J,{type:`button`,variant:e===`transcript`?`secondary`:`ghost`,className:`h-9 flex-1`,"aria-pressed":e===`transcript`,onClick:t,children:`Transcript`}),(0,Z.jsx)(J,{type:`button`,variant:e===`details`?`secondary`:`ghost`,className:`h-9 flex-1`,"aria-pressed":e===`details`,onClick:n,children:`Details`})]}),k4=({controls:e})=>{let[t,n]=(0,X.useState)(!1);return(0,Z.jsxs)(vp,{open:t,onOpenChange:n,children:[(0,Z.jsx)(`div`,{className:`px-1 pb-1`,children:(0,Z.jsx)(yp,{asChild:!0,children:(0,Z.jsxs)(J,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 gap-1.5 px-2 text-xs text-muted-foreground`,children:[`Options`,(0,Z.jsx)(oe,{className:W(`h-3.5 w-3.5 transition-transform`,t&&`rotate-180`)})]})})}),(0,Z.jsx)(bp,{className:`px-1 pb-1`,children:(0,Z.jsx)(`div`,{className:`rounded-lg border border-border/70 bg-background/35 p-2`,children:e})})]})},A4=({ticket:e})=>{let t=[{label:`State`,value:d4(e)},{label:`Tool`,value:e.tool},{label:`Agent`,value:e.agent_status},{label:`Branch`,value:e.branch},{label:`Bundle`,value:e.bundle?.name??null},{label:`Model`,value:e.model},{label:`Variant`,value:e.variant}].filter(e=>!!e.value);return t.length===0?null:(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2 rounded-xl border border-border/70 bg-background/40 px-3 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Details`}),(0,Z.jsx)(`dl`,{className:`grid gap-2 text-sm sm:grid-cols-2`,children:t.map(e=>(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-lg border border-border/60 bg-background/50 px-3 py-2`,children:[(0,Z.jsx)(`dt`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,Z.jsx)(`dd`,{className:`break-words text-foreground`,children:e.value})]},e.label))})]})},j4=({ticket:e,badges:t,actionState:n,actionError:r,onAction:i,className:a})=>(0,Z.jsxs)(Nf,{className:W(`flex min-h-0 min-w-0 flex-col border-border/80 bg-card/70 shadow-none`,a),children:[(0,Z.jsx)(Pf,{className:`min-w-0 pb-3`,children:(0,Z.jsx)(T4,{title:e.title,badges:t})}),(0,Z.jsxs)(Rf,{className:`min-h-0 min-w-0 flex-1 space-y-3 overflow-y-auto pt-0`,children:[(0,Z.jsx)(S4,{ticket:e,actionState:n,actionError:r,onAction:i}),e.description?(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2 rounded-xl border border-border/70 bg-background/40 px-3 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Description`}),(0,Z.jsx)(oF,{content:e.description,className:`min-w-0 text-foreground`})]}):null,(0,Z.jsx)(A4,{ticket:e})]})]}),M4=({bundleDetail:e,title:t,subtitle:n,badges:r,actionState:i,actionError:a,onAction:o,orderedTickets:s,highlightedTicketId:c,isTicketListOpen:l,onTicketListOpenChange:u,onSelectTicket:d,className:f})=>(0,Z.jsxs)(Nf,{className:W(`flex min-h-0 min-w-0 flex-col border-border/80 bg-card/70 shadow-none`,f),children:[(0,Z.jsx)(Pf,{className:`min-w-0 pb-3`,children:(0,Z.jsx)(T4,{title:t,subtitle:n,badges:r})}),(0,Z.jsxs)(Rf,{className:`min-h-0 min-w-0 flex-1 space-y-3 overflow-y-auto pt-0`,children:[(0,Z.jsx)(C4,{bundleDetail:e,actionState:i,actionError:a,onAction:o}),(0,Z.jsxs)(vp,{open:l,onOpenChange:u,children:[(0,Z.jsx)(yp,{asChild:!0,children:(0,Z.jsxs)(J,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs text-muted-foreground`,children:[`Tickets`,(0,Z.jsx)(oe,{className:W(`h-3.5 w-3.5 transition-transform`,l&&`rotate-180`)})]})}),(0,Z.jsx)(bp,{className:`pt-2`,children:(0,Z.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-background/35 p-3`,children:(0,Z.jsx)(Tq,{tickets:s,highlightedTicketId:c,onOpenTicketDetails:e=>d(e.id,e.worktree_bundle_id)})})})]})]})]}),N4=({selectedProjectId:e,bundleId:t,bundleDetail:n,openNonce:r,mobileDetailView:i,error:a,actionState:o,actionError:s,followUpPrompt:c,isSendingFollowUp:l,followUpError:u,availableModels:d,onBack:f,onRetry:p,onAction:m,onDetailViewChange:h,onSelectTicket:g,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y,isLargeScreen:b})=>{let[x,S]=(0,X.useState)(!0);if((0,X.useEffect)(()=>{S(!0)},[t,r]),!e)return(0,Z.jsx)(n4,{title:`Choose a project`,description:`Select a project before opening bundle details from this phone.`});if(!t)return(0,Z.jsx)(n4,{title:`Choose a bundle`,description:`Open a bundle to review its transcript and grouped ticket progress.`});if(a)return(0,Z.jsx)(D4,{title:`Bundle unavailable`,backLabel:`Back to tickets`,onBack:f,children:(0,Z.jsx)(n4,{title:`Bundle unavailable`,description:a,action:(0,Z.jsx)(J,{variant:`warning`,onClick:p,children:`Retry bundle`})})});if(!n||n.bundle.id!==t)return(0,Z.jsx)(D4,{title:`Loading bundle`,backLabel:`Back to tickets`,onBack:f,children:(0,Z.jsx)(i4,{text:`Loading bundle details...`})});let C=Ud(n.bundle)||n.bundle.branch||n.bundle.name||`Bundle`,w=new Map(d.map(e=>[e.id,e.label])),T=Aq(n.tickets,w),E=Nq(n),D=jq(n.tickets,n.execution_order_ticket_ids),O=Mq(n.tickets,w,T,n.execution_order_ticket_ids),k=DD(n.tickets,E?.state??null),A=n.tickets.find(e=>e.agent_status===`running`)??E,j=A??E??n.tickets[0]??null,M=A?.agent_status===`running`?T[A.id]??A.model??`Agent`:null,N=!!(E&&E.state!==`plan`&&Id(E)),P=n.tickets.some(e=>e.agent_status===`running`)?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,F=`mobile-bundle:${n.bundle.id}:${r}`,I=`${n.tickets.length} ticket${n.tickets.length===1?``:`s`}`,L=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(SD,{status:k}),(0,Z.jsx)(q,{variant:`outline`,children:I}),j?(0,Z.jsxs)(q,{variant:`outline`,children:[`Target: `,j.title]}):null]});return(0,Z.jsx)(D4,{title:C,backLabel:`Back to tickets`,onBack:f,subheader:b?void 0:(0,Z.jsx)(O4,{value:i,onTranscript:()=>h(`transcript`),onDetails:()=>h(`details`)}),children:b?(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-hidden pt-3`,children:[(0,Z.jsx)(M4,{bundleDetail:n,title:C,subtitle:n.bundle.branch,badges:L,actionState:o,actionError:s,onAction:m,orderedTickets:D,highlightedTicketId:n.target_ticket_id,isTicketListOpen:x,onTicketListOpenChange:S,onSelectTicket:g,className:`shrink-0`}),(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(Sq,{projectId:e,followUpTicketId:n.target_ticket_id,messages:O,internalLog:A?.agent_log??null,currentThinkingMessageId:A?.agent_message_id??E?.agent_message_id??null,legacyThinkingTicketId:A?.id??E?.id??null,previousThinkingLog:A?.previous_agent_log??E?.previous_agent_log??null,previousThinkingMessageId:A?.previous_agent_message_id??E?.previous_agent_message_id??null,pendingAgentTitle:M,streamingResponse:A?.streaming_response??null,isRunning:n.tickets.some(e=>e.agent_status===`running`),canShowComposer:N,composerTheme:VE(E?.state??null),layoutKey:F,scrollLayoutKey:F,followUpPrompt:c,followUpPlaceholder:j?`Follow up on: ${j.title}`:`Follow up on this bundle`,isSendingFollowUp:l,followUpDisabledReason:P,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y},F)}),u?(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-red-200`,children:u}):null]}):i===`details`?(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(M4,{bundleDetail:n,title:C,subtitle:n.bundle.branch,badges:L,actionState:o,actionError:s,onAction:m,orderedTickets:D,highlightedTicketId:n.target_ticket_id,isTicketListOpen:x,onTicketListOpenChange:S,onSelectTicket:g,className:`h-full`})}):(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Z.jsx)(Sq,{projectId:e,followUpTicketId:n.target_ticket_id,messages:O,internalLog:A?.agent_log??null,currentThinkingMessageId:A?.agent_message_id??E?.agent_message_id??null,legacyThinkingTicketId:A?.id??E?.id??null,previousThinkingLog:A?.previous_agent_log??E?.previous_agent_log??null,previousThinkingMessageId:A?.previous_agent_message_id??E?.previous_agent_message_id??null,pendingAgentTitle:M,streamingResponse:A?.streaming_response??null,isRunning:n.tickets.some(e=>e.agent_status===`running`),canShowComposer:N,composerTheme:VE(E?.state??null),layoutKey:F,scrollLayoutKey:F,followUpPrompt:c,followUpPlaceholder:j?`Follow up on: ${j.title}`:`Follow up on this bundle`,isSendingFollowUp:l,followUpDisabledReason:P,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y},F),u?(0,Z.jsx)(`p`,{className:`shrink-0 px-1 pt-2 text-sm text-red-200`,children:u}):null]})})},P4=({selectedProjectId:e,chatSession:t,chatSessionId:n,openNonce:r,error:i,isStopping:a,composerMode:o,composerTool:s,prompt:c,selectedModel:l,selectedVariant:u,selectedSkills:d,availableModels:f,availableSkills:p,isLoadingAgentSettings:m,isSending:h,isUpdatingMode:g,composerDisabledReason:_,onBack:v,onRetry:y,onStop:b,onModeChange:x,onPromptChange:S,onModelChange:C,onVariantChange:w,onSkillsChange:T,onPromptKeyDown:E,onSubmit:D,isLargeScreen:O})=>{if(!e)return(0,Z.jsx)(n4,{title:`Choose a project`,description:`Select a project before opening the chat workspace.`});if(n&&i)return(0,Z.jsx)(n4,{title:`Chat unavailable`,description:i,action:(0,Z.jsx)(J,{variant:`warning`,onClick:y,children:`Retry chat`})});if(n&&(!t||t.id!==n))return(0,Z.jsx)(D4,{title:`Loading chat`,backLabel:`Back to chats`,onBack:v,children:(0,Z.jsx)(i4,{text:`Loading chat transcript...`})});let k=t?.mode??o,A=s===`opencode`&&f.length>0,j=f.find(e=>e.id===l)??null,M=w4(t?.messages),N=t?.agent_status===`running`?(0,Z.jsxs)(J,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:a,onClick:b,children:[a?(0,Z.jsx)(ye,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Zu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:a?`Interrupting...`:`Interrupt`})]}):null,P=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{variant:k===`plan`?`info`:`success`,children:k}),(0,Z.jsx)(q,{variant:`outline`,children:t?.tool??s}),t?.agent_status?(0,Z.jsx)(q,{variant:`outline`,children:t.agent_status}):null]}),F=A?(0,Z.jsx)(AI,{model:l,variant:u,skills:d,showModelSelector:!0,showSkillsSelector:!0,availableModels:f,availableSkills:p,selectedModel:j,onModelChange:C,onVariantChange:w,onSkillsChange:T,modelSelectId:`mobile-chat-model-selector`,variantSelectId:`mobile-chat-variant-selector`,skillsSelectId:`mobile-chat-skills-selector`,disabled:!!_||h}):s===`opencode`&&m?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading model controls...`}):null,I=!O&&F?(0,Z.jsx)(k4,{controls:F}):F,L=(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,Z.jsx)(XQ,{value:k,disabled:!!_||h||g,onChange:x})}),R=O?void 0:({showThinkingControl:e})=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-1`,children:[L,(0,Z.jsx)(`div`,{className:`ml-auto`,children:e})]}),z=`mobile-chat:${n??`new`}:${r}`;return(0,Z.jsx)(D4,{title:t?.title??`New chat`,backLabel:`Back to chats`,onBack:v,action:N,children:(0,Z.jsx)(YQ,{projectId:e,messages:M,internalLog:t?.agent_log??null,currentThinkingMessageId:t?.agent_message_id??null,previousThinkingLog:t?.previous_agent_log??null,previousThinkingMessageId:t?.previous_agent_message_id??null,pendingAgentTitle:t?.title??`Archon`,streamingResponse:t?.streaming_response??null,isRunning:t?.agent_status===`running`,canShowComposer:!0,header:O?(0,Z.jsx)(T4,{title:t?.title??`New chat`,subtitle:t?.target_label_snapshot??`Project root`,badges:P}):R,composerControls:O?L:void 0,composerInlineControls:I,composerTheme:k,forceScrollToBottomKey:z,layoutKey:z,scrollLayoutKey:z,composerFocusNonce:r,blurComposerOnSendStart:!O,followUpPrompt:c,followUpPlaceholder:n?`Continue this chat`:k===`plan`?`Ask Archon to scope or reason through project work`:`Ask Archon to build or verify something in this project`,emptyStateText:n?`No messages yet.`:`Start a new project chat from this phone.`,isSendingFollowUp:h,followUpDisabledReason:_??void 0,hidePendingAgentTitle:!O,onFollowUpPromptChange:S,onFollowUpKeyDown:E,onFollowUpSubmit:D},z)})},F4=({selectedProjectId:e,ticketId:t,ticket:n,openNonce:r,error:i,actionState:a,actionError:o,followUpPrompt:s,followUpSelectedModel:c,followUpSelectedVariant:l,followUpSelectedSkills:u,availableModels:d,availableSkills:f,isLoadingAgentSettings:p,isSendingFollowUp:m,followUpError:h,onBack:g,onRetry:_,onAction:v,onFollowUpPromptChange:y,onFollowUpModelChange:b,onFollowUpVariantChange:x,onFollowUpSkillsChange:S,onFollowUpKeyDown:C,onFollowUpSubmit:w,isLargeScreen:T})=>{let[E,D]=(0,X.useState)(`transcript`);if((0,X.useEffect)(()=>{D(`transcript`)},[r,t]),!e)return(0,Z.jsx)(n4,{title:`Choose a project`,description:`Select a project before opening ticket details from this phone.`});if(!t)return(0,Z.jsx)(n4,{title:`Choose a ticket`,description:`Open a ticket to review its transcript and continue the workflow.`});if(i)return(0,Z.jsx)(n4,{title:`Ticket unavailable`,description:i,action:(0,Z.jsx)(J,{variant:`warning`,onClick:_,children:`Retry ticket`})});if(!n||n.id!==t)return(0,Z.jsx)(D4,{title:`Loading ticket`,backLabel:`Back to tickets`,onBack:g,children:(0,Z.jsx)(i4,{text:`Loading ticket details...`})});let O=rq(n,{requireWorktree:!0}),k=w4(n.messages,n.id),A=d.find(e=>e.id===c)??null,j=n.tool===`opencode`&&d.length>0?(0,Z.jsx)(AI,{model:c,variant:l,skills:u,showModelSelector:!0,showSkillsSelector:!0,availableModels:d,availableSkills:f,selectedModel:A,onModelChange:b,onVariantChange:x,onSkillsChange:S,modelSelectId:`mobile-ticket-follow-up-model-selector`,variantSelectId:`mobile-ticket-follow-up-variant-selector`,skillsSelectId:`mobile-ticket-follow-up-skills-selector`,disabled:!!O.disabledReason||m}):n.tool===`opencode`&&p?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading model controls...`}):null,M=!T&&j?(0,Z.jsx)(k4,{controls:j}):j,N=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{variant:f4(u4(n)),children:d4(n)}),n.tool?(0,Z.jsx)(q,{variant:`outline`,children:n.tool}):null,n.agent_status?(0,Z.jsx)(q,{variant:`outline`,children:n.agent_status}):null,n.branch?(0,Z.jsx)(q,{variant:`outline`,children:n.branch}):null,n.bundle?.name?(0,Z.jsx)(q,{variant:`outline`,children:n.bundle.name}):null]}),P=`mobile-ticket:${n.id}:${r}`,F=(0,Z.jsx)(O4,{value:E,onTranscript:()=>D(`transcript`),onDetails:()=>D(`details`)});return(0,Z.jsx)(D4,{title:n.title,backLabel:`Back to tickets`,onBack:g,subheader:T?void 0:F,children:T?(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-hidden pt-3`,children:[(0,Z.jsx)(j4,{ticket:n,badges:N,actionState:a,actionError:o,onAction:v,className:`shrink-0`}),(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(ZF,{projectId:e,followUpTicketId:n.id,messages:k,internalLog:n.agent_log??null,currentThinkingMessageId:n.agent_message_id??null,previousThinkingLog:n.previous_agent_log??null,previousThinkingMessageId:n.previous_agent_message_id??null,pendingAgentTitle:n.title,streamingResponse:n.streaming_response??null,isRunning:n.agent_status===`running`,canShowComposer:!0,followUpComposerControls:j,composerTheme:n.state,forceScrollToBottomKey:P,layoutKey:P,scrollLayoutKey:P,followUpPrompt:s,followUpPlaceholder:O.placeholder,emptyStateText:`No follow-up messages yet.`,isSendingFollowUp:m,followUpDisabledReason:O.disabledReason??void 0,onFollowUpPromptChange:y,onFollowUpKeyDown:C,onFollowUpSubmit:w},P)}),h?(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-red-200`,children:h}):null]}):E===`details`?(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(j4,{ticket:n,badges:N,actionState:a,actionError:o,onAction:v,className:`h-full`})}):(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Z.jsx)(ZF,{projectId:e,followUpTicketId:n.id,messages:k,internalLog:n.agent_log??null,currentThinkingMessageId:n.agent_message_id??null,previousThinkingLog:n.previous_agent_log??null,previousThinkingMessageId:n.previous_agent_message_id??null,pendingAgentTitle:n.title,streamingResponse:n.streaming_response??null,isRunning:n.agent_status===`running`,canShowComposer:!0,followUpComposerControls:M,composerTheme:n.state,surfaceVariant:`chat`,composerSize:`compact-on-laptop`,forceScrollToBottomKey:P,layoutKey:P,scrollLayoutKey:P,followUpPrompt:s,followUpPlaceholder:O.placeholder,emptyStateText:`No follow-up messages yet.`,isSendingFollowUp:m,followUpDisabledReason:O.disabledReason??void 0,onFollowUpPromptChange:y,onFollowUpKeyDown:C,onFollowUpSubmit:w},P),h?(0,Z.jsx)(`p`,{className:`shrink-0 px-1 pt-2 text-sm text-red-200`,children:h}):null]})})},I4=()=>{let e=new URLSearchParams(window.location.search),t=new URLSearchParams(window.location.hash.slice(1)),n=e.get(`mobileAccessId`)??``,r=e.get(`pairingId`)??``,i=t.get(`pairingSecret`)??``;return!n||!r||!i?null:{mobileAccessId:n,pairingId:r,pairingSecret:i}},L4=()=>{window.history.replaceState({},``,`/mobile`)},R4=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()},z4=(e,t)=>e instanceof we&&e.message?e.message:t,B4=e=>({status:`authenticated`,csrfToken:e,projects:null,selectedProjectId:null,projectError:null,projectSummary:null,projectSummaryError:null,chatSessions:null,chatSessionsError:null,selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null,tickets:null,ticketsError:null,selectedBundleId:null,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),V4=(e=`pairing_required`)=>({status:`unauthenticated`,reason:e}),H4=e=>e instanceof we&&(e.status===401||e.status===403),U4=()=>{let[e,t]=(0,X.useState)({status:`checking`}),[n,r]=(0,X.useState)(`connecting`),[i,a]=(0,X.useState)(`overview`),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(`build`),[S,C]=(0,X.useState)(``),[w,T]=(0,X.useState)(``),[E,D]=(0,X.useState)([]),[O,A]=(0,X.useState)([]),[j,M]=(0,X.useState)([]),[N,P]=(0,X.useState)(!1),[F,I]=(0,X.useState)(!1),[L,R]=(0,X.useState)(!1),[z,B]=(0,X.useState)(null),[V,ee]=(0,X.useState)(null),[te,H]=(0,X.useState)(null),[ne,U]=(0,X.useState)(null),[re,ie]=(0,X.useState)(null),[ae,oe]=(0,X.useState)(null),[se,ce]=(0,X.useState)(``),[le,ue]=(0,X.useState)(``),[de,fe]=(0,X.useState)(``),[pe,me]=(0,X.useState)([]),[G,he]=(0,X.useState)(!1),[ge,_e]=(0,X.useState)(null),[ve,ye]=(0,X.useState)(``),[be,xe]=(0,X.useState)(!1),[Se,Ce]=(0,X.useState)(null),[K,Te]=(0,X.useState)(null),[Ee,De]=(0,X.useState)(null),[Oe,ke]=(0,X.useState)(0),[Ae,je]=(0,X.useState)(0),[Me,Ne]=(0,X.useState)(0),[Pe,Fe]=(0,X.useState)(`transcript`),[Ie,Le]=(0,X.useState)(null),[Re,q]=(0,X.useState)(null),[ze,Be]=(0,X.useState)(!1),[Ve,He]=(0,X.useState)(!1),[Ue,We]=(0,X.useState)(!1),[Ge,Ke]=(0,X.useState)(null),[qe,Je]=(0,X.useState)(null),Ye=(0,X.useRef)(null),Xe=(0,X.useRef)(null),Ze=(0,X.useRef)(null),Y=(0,X.useRef)(null),Qe=(0,X.useCallback)(e=>H4(e)?(t(V4(`session_revoked`)),r(`unavailable`),s(!1),l(!1),d(!1),p(!1),!0):!1,[]),$e=(0,X.useCallback)(async(e,n,r,i)=>{try{let a=await c2(n,r,i);t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedTicketId!==r?t:{...t,ticketDetail:a,ticketDetailError:null})}catch(i){if(!k(i)){if(Qe(i))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedTicketId!==r?t:{...t,ticketDetail:null,ticketDetailError:z4(i,`Unable to load ticket details.`)})}}},[Qe]),et=(0,X.useCallback)(async(e,n,r,i)=>{try{let a=await l2(n,r,i);t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedBundleId!==r?t:{...t,bundleDetail:a,bundleDetailError:null,tickets:_4(t.tickets,a)})}catch(i){if(!k(i)){if(Qe(i))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedBundleId!==r?t:{...t,bundleDetail:null,bundleDetailError:z4(i,`Unable to load bundle details.`)})}}},[Qe]),tt=(0,X.useCallback)(async(e,n,r)=>{try{let i=await s2(n,r);t(t=>{if(t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n)return t;let r=t.selectedTicketId&&i.some(e=>e.id===t.selectedTicketId)?t.selectedTicketId:null,a=t.selectedBundleId&&i.some(e=>e.worktree_bundle_id===t.selectedBundleId)?t.selectedBundleId:null;return{...t,tickets:i,ticketsError:null,selectedBundleId:a,bundleDetail:a?t.bundleDetail:null,bundleDetailError:a?t.bundleDetailError:null,selectedTicketId:r,ticketDetail:r?t.ticketDetail:null,ticketDetailError:r?t.ticketDetailError:null}})}catch(r){if(!k(r)){if(Qe(r))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n?t:{...t,tickets:null,ticketsError:z4(r,`Unable to load project tickets.`),selectedBundleId:null,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null})}}},[Qe]),nt=(0,X.useCallback)(async(e,n,r,i)=>{try{let a=await o2(n,r,i);t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedChatSessionId!==r?t:{...t,chatSessionDetail:a,chatSessionDetailError:null})}catch(i){if(!k(i)){if(Qe(i))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedChatSessionId!==r?t:{...t,chatSessionDetail:null,chatSessionDetailError:z4(i,`Unable to load chat transcript.`)})}}},[Qe]),rt=(0,X.useCallback)(async(e,n,r)=>{try{let i=await a2(n,r);t(t=>{if(t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n)return t;let r=t.selectedChatSessionId&&i.some(e=>e.id===t.selectedChatSessionId)?t.selectedChatSessionId:null;return{...t,chatSessions:i,chatSessionsError:null,selectedChatSessionId:r,chatSessionDetail:r?t.chatSessionDetail:null,chatSessionDetailError:r?t.chatSessionDetailError:null}})}catch(r){if(!k(r)){if(Qe(r))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n?t:{...t,chatSessions:null,chatSessionsError:z4(r,`Unable to load project chats.`),selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null})}}},[Qe]),it=(0,X.useCallback)(async(e,n,r)=>{try{let i=await r2(n,r);t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n?t:{...t,projectSummary:i,projectSummaryError:null})}catch(r){if(!k(r)){if(Qe(r))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n?t:{...t,projectSummary:null,projectSummaryError:z4(r,`Unable to load the project summary.`)})}}},[Qe]),at=(0,X.useCallback)(async(e,t,n)=>{He(!0);try{let e=await i2(t,n),r=Ye.current;if(r&&r!==t)return;Le(e),q(null),Ke(null)}catch(e){if(!k(e)){if(Qe(e))return;let n=Ye.current;if(n&&n!==t)return;Le(null),q(z4(e,`Unable to load project target options.`))}}finally{n?.aborted||He(!1)}},[Qe]),ot=(0,X.useCallback)(e=>{t(t=>t.status===`authenticated`?{...t,projects:t.projects?.map(t=>t.id===e.id?e:t)??t.projects,projectSummary:t.projectSummary?.project.id===e.id?{...t.projectSummary,project:e}:t.projectSummary}:t)},[]),st=(0,X.useCallback)(async(e,n,r)=>{try{let i=await n2(n),a=r&&i.some(e=>e.id===r)?r:i[0]?.id??null;t(t=>{if(t.status!==`authenticated`||t.csrfToken!==e)return t;let n=!!(t.selectedProjectId&&a&&t.selectedProjectId===a);return{...t,projects:i,selectedProjectId:a,projectError:null,projectSummary:n?t.projectSummary:null,projectSummaryError:n?t.projectSummaryError:null,chatSessions:n?t.chatSessions:null,chatSessionsError:n?t.chatSessionsError:null,selectedChatSessionId:n?t.selectedChatSessionId:null,chatSessionDetail:n?t.chatSessionDetail:null,chatSessionDetailError:n?t.chatSessionDetailError:null,tickets:n?t.tickets:null,ticketsError:n?t.ticketsError:null,selectedBundleId:n?t.selectedBundleId:null,bundleDetail:n?t.bundleDetail:null,bundleDetailError:n?t.bundleDetailError:null,selectedTicketId:n?t.selectedTicketId:null,ticketDetail:n?t.ticketDetail:null,ticketDetailError:n?t.ticketDetailError:null}});let o=a?i.find(e=>e.id===a)??null:null;a&&(it(e,a,n),o?.active_target_kind===`bundle`&&at(e,a,n),rt(e,a,n),tt(e,a,n))}catch(n){if(!k(n)){if(Qe(n))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e?t:{...t,projects:t.projects??[],projectError:z4(n,`Unable to load projects from desktop Archon.`)})}}},[Qe,rt,it,at,tt]),ct=(0,X.useCallback)(async e=>{t({status:`checking`}),r(`connecting`);try{let n=await A2(e);if(n.authenticated&&n.csrf_token){r(`connecting`),t(B4(n.csrf_token)),st(n.csrf_token,e,n.preferred_project_id);return}t(V4())}catch(e){k(e)||t({status:`error`,message:z4(e,`Mobile access is unavailable. Make sure it is still enabled on desktop Archon.`)})}},[st]),lt=(0,X.useCallback)((e,n,i)=>{r(`connecting`),t(B4(e)),st(e,i,n)},[st]);(0,X.useEffect)(()=>{let e=new AbortController;if(window.location.pathname===`/mobile/pair`){let n=I4();return L4(),n?(t({status:`pairing`}),j2(n,e.signal).then(e=>{t({status:`pairing_confirmation`,payload:n,displayCode:e.display_code,expiresAt:e.expires_at,error:null})}).catch(e=>{t({status:`error`,message:z4(e,`Pairing failed. Regenerate the pairing link from desktop Archon and try again.`)})}),()=>e.abort()):(t({status:`error`,message:`Pairing link is missing required pairing details.`}),()=>e.abort())}return ct(e.signal),()=>e.abort()},[lt,ct]);let ut=e.status===`authenticated`?e.csrfToken:null,dt=e.status===`authenticated`?e.selectedProjectId:null,ft=e.status===`authenticated`?e.selectedChatSessionId:null,pt=e.status===`authenticated`?e.selectedBundleId:null,mt=e.status===`authenticated`?e.selectedTicketId:null,ht=e.status===`authenticated`?e.projects?.find(t=>t.id===e.selectedProjectId)??null:null,gt=e.status===`authenticated`?e.chatSessionDetail:null,_t=e.status===`authenticated`?e.bundleDetail:null,vt=e.status===`authenticated`?e.ticketDetail:null,yt=U2(ht,Ie),bt=Ve&&(!ht||ht.active_target_kind===`bundle`),xt=J2(),St=gt?.tool??`opencode`,Ct=e.status!==`authenticated`||!e.selectedProjectId?`Choose a project before sending a prompt.`:L?`Wait for the chat mode change before sending another prompt.`:gt?.agent_status===`running`?`Stop or wait for the current response before sending another prompt.`:null,wt=!xt&&(i===`tickets`&&(u&&!!mt||c&&!!pt)||i===`chats`&&f);(0,X.useEffect)(()=>{Ye.current=dt},[dt]),(0,X.useEffect)(()=>{dt||(Le(null),q(null),Ke(null),Be(!1),He(!1),We(!1))},[dt]),(0,X.useEffect)(()=>{Xe.current=ft},[ft]),(0,X.useEffect)(()=>{Ze.current=pt},[pt]),(0,X.useEffect)(()=>{Y.current=mt},[mt]),(0,X.useEffect)(()=>{if(!ut||!dt){A([]),M([]),P(!1);return}if(!(St===`opencode`||vt?.tool===`opencode`)){A([]),M([]),P(!1);return}let e=new AbortController;return P(!0),Promise.all([O2(`opencode`,e.signal),k2(`opencode`,dt,e.signal)]).then(([e,t])=>{A(e),M(t)}).catch(e=>{Qe(e)||k(e)||(A([]),M([]))}).finally(()=>{e.signal.aborted||P(!1)}),()=>e.abort()},[ut,St,Qe,dt,vt?.tool]),(0,X.useEffect)(()=>{if(St!==`opencode`){C(``),T(``),D([]);return}C(gt?.model??ht?.helper_model??``),T(gt?.variant??ht?.helper_variant??``),D(gt?.skills??[])},[St,gt?.id,gt?.model,gt?.skills,gt?.variant,ht?.helper_model,ht?.helper_variant]),(0,X.useEffect)(()=>{gt?.mode&&x(gt.mode)},[gt?.id,gt?.mode]),(0,X.useEffect)(()=>{let e=O.find(e=>e.id===S)??null;T(t=>e?e.variants.includes(t)?t:``:t)},[O,S]),(0,X.useEffect)(()=>{ce(``),_e(null),ue(vt?.model??``),fe(vt?.variant??``),me(vt?.skills??[])},[vt?.id,vt?.model,vt?.skills,vt?.variant]),(0,X.useEffect)(()=>{ye(``),Ce(null)},[_t?.bundle.id]),(0,X.useEffect)(()=>{let e=O.find(e=>e.id===le)??null;fe(t=>e?e.variants.includes(t)?t:``:t)},[O,le]),(0,X.useEffect)(()=>{if(!ut)return;let e=P2();r(`connecting`);let t=()=>{let e=Ye.current,t=Xe.current,n=Ze.current,r=Y.current;st(ut,void 0,e),e&&(it(ut,e),rt(ut,e),tt(ut,e)),e&&t&&nt(ut,e,t),e&&n&&et(ut,e,n),e&&r&&$e(ut,e,r)},n=()=>{r(`connected`),t()},i=()=>{r(`reconnecting`)},a=()=>{r(`unavailable`)},o=()=>{st(ut,void 0,Ye.current)},s=(e=null)=>{let t=Ye.current;t&&(e?.project_id&&e.project_id!==t||it(ut,t))},c=(e=null)=>{let t=Ye.current;t&&(e?.project_id&&e.project_id!==t||rt(ut,t))},l=(e=null)=>{let t=Ye.current;t&&(e?.project_id&&e.project_id!==t||tt(ut,t))},u=(e=null)=>{let t=Ye.current,n=Xe.current;!t||!n||e?.project_id&&e.project_id!==t||e?.id&&e.id!==n||nt(ut,t,n)},d=(e=null)=>{let t=Ye.current,n=Y.current;!t||!n||e?.project_id&&e.project_id!==t||e?.id&&e.id!==n||$e(ut,t,n)},f=(e=null)=>{let t=Ye.current,n=Ze.current;!t||!n||e?.project_id&&e.project_id!==t||et(ut,t,n)};return e.on(`connect`,n),e.on(`disconnect`,i),e.on(`connect_error`,a),e.on(`ticket:created`,s),e.on(`ticket:created`,l),e.on(`ticket:updated`,s),e.on(`ticket:updated`,l),e.on(`ticket:updated`,f),e.on(`ticket:updated`,d),e.on(`ticket:deleted`,o),e.on(`ticket:deleted`,l),e.on(`ticket:deleted`,f),e.on(`ticket-dependency:created`,s),e.on(`ticket-dependency:deleted`,s),e.on(`chat-session:created`,c),e.on(`chat-session:updated`,c),e.on(`chat-session:updated`,u),e.on(`chat-session:deleted`,c),()=>{e.off(`connect`,n),e.off(`disconnect`,i),e.off(`connect_error`,a),e.off(`ticket:created`,s),e.off(`ticket:created`,l),e.off(`ticket:updated`,s),e.off(`ticket:updated`,l),e.off(`ticket:updated`,f),e.off(`ticket:updated`,d),e.off(`ticket:deleted`,o),e.off(`ticket:deleted`,l),e.off(`ticket:deleted`,f),e.off(`ticket-dependency:created`,s),e.off(`ticket-dependency:deleted`,s),e.off(`chat-session:created`,c),e.off(`chat-session:updated`,c),e.off(`chat-session:updated`,u),e.off(`chat-session:deleted`,c),e.disconnect()}},[ut,et,nt,rt,it,st,$e,tt]),(0,X.useEffect)(()=>{pt||l(!1)},[pt]),(0,X.useEffect)(()=>{mt||d(!1)},[mt]);let Tt=()=>{ct()},Et=e=>{a(e),l(!1),d(!1),p(!1),Je(null)},Dt=()=>{s(!0)},Ot=()=>{e.status!==`authenticated`||!e.selectedProjectId||(Ke(null),Be(!0),!Ie&&!Ve&&at(e.csrfToken,e.selectedProjectId))},kt=()=>{e.status===`authenticated`&&(h(!0),N2(e.csrfToken).then(()=>t(V4())).catch(e=>{Qe(e)||t({status:`error`,message:z4(e,`Logout failed. Mobile access may have already been revoked from desktop Archon.`)})}).finally(()=>h(!1)))},At=()=>{if(e.status!==`pairing_confirmation`||g)return;let n=e.payload;_(!0),t({...e,error:null}),M2(n).then(e=>{if(e.authenticated&&e.csrf_token){window.history.replaceState({},``,`/mobile`),lt(e.csrf_token,e.preferred_project_id);return}t(V4())}).catch(e=>{t(t=>t.status===`pairing_confirmation`?{...t,error:z4(e,`Pairing failed. Regenerate the pairing link from desktop Archon and try again.`)}:t)}).finally(()=>_(!1))},jt=()=>{window.history.replaceState({},``,`/mobile`),t(V4())},Mt=()=>{e.status===`authenticated`&&(t({...e,projects:null,projectError:null}),st(e.csrfToken))},Nt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,projectSummary:null,projectSummaryError:null}),it(e.csrfToken,e.selectedProjectId))},Pt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(Le(null),q(null),Ke(null),at(e.csrfToken,e.selectedProjectId))},Ft=()=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,chatSessions:null,chatSessionsError:null,selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null}),rt(e.csrfToken,e.selectedProjectId))},It=()=>{e.status!==`authenticated`||!e.selectedProjectId||!e.selectedChatSessionId||(t({...e,chatSessionDetail:null,chatSessionDetailError:null}),nt(e.csrfToken,e.selectedProjectId,e.selectedChatSessionId))},Lt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,tickets:null,ticketsError:null,selectedBundleId:null,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),tt(e.csrfToken,e.selectedProjectId))},Rt=()=>{e.status!==`authenticated`||!e.selectedProjectId||!e.selectedTicketId||(t({...e,ticketDetail:null,ticketDetailError:null}),$e(e.csrfToken,e.selectedProjectId,e.selectedTicketId))},zt=()=>{e.status!==`authenticated`||!e.selectedProjectId||!e.selectedBundleId||(t({...e,bundleDetail:null,bundleDetailError:null}),et(e.csrfToken,e.selectedProjectId,e.selectedBundleId))},Bt=n=>{if(e.status!==`authenticated`)return;let r=e.projects?.find(e=>e.id===n)??null;Ye.current=n,t({...e,selectedProjectId:n,projectSummary:null,projectSummaryError:null,chatSessions:null,chatSessionsError:null,selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null,tickets:null,ticketsError:null,selectedBundleId:null,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),H(null),U(null),ie(null),oe(null),ee(null),oe(null),De(null),Ce(null),Le(null),q(null),Ke(null),s(!1),Be(!1),l(!1),d(!1),p(!1),Fe(`transcript`),Je(null),a(`overview`),it(e.csrfToken,n),r?.active_target_kind===`bundle`&&at(e.csrfToken,n),rt(e.csrfToken,n),tt(e.csrfToken,n)},Vt=async t=>{if(!(e.status!==`authenticated`||!e.selectedProjectId)){We(!0),Ke(null);try{ot(await D2(e.selectedProjectId,e.csrfToken,{kind:`bundle`,bundle_id:t})),Be(!1),it(e.csrfToken,e.selectedProjectId),at(e.csrfToken,e.selectedProjectId)}catch(e){if(Qe(e))return;Ke(z4(e,`Unable to update the project target right now.`))}finally{We(!1)}}},Ht=async(t,n={})=>{if(e.status!==`authenticated`||!e.selectedProjectId)return;We(!0),Ke(null);let r=r=>D2(e.selectedProjectId??``,e.csrfToken,{kind:`repo_root`,...t?{branch:t}:{},...n.createBranch===!1?{create_branch:!1}:{},...r?{confirm_dirty_switch:!0}:{}});try{let t;try{t=await r(n.confirmDirtySwitch===!0)}catch(e){if(!n.confirmDirtySwitch&&e instanceof we&&e.status===409&&e.message===B2){if(!window.confirm(`${B2}\n\nSwitch anyway?`))return;t=await r(!0)}else throw e}ot(t),Be(!1),it(e.csrfToken,e.selectedProjectId),at(e.csrfToken,e.selectedProjectId)}catch(e){if(Qe(e))return;Ke(z4(e,`Unable to update the project target right now.`))}finally{We(!1)}},Ut=n=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,selectedChatSessionId:n,chatSessionDetail:null,chatSessionDetailError:null}),ee(null),ke(e=>e+1),p(!0),a(`chats`),nt(e.csrfToken,e.selectedProjectId,n))},Wt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null}),ee(null),y(``),ke(e=>e+1),p(!0),a(`chats`))},Gt=n=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,selectedBundleId:n,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),H(null),U(null),oe(null),Ce(null),Je(null),Fe(`transcript`),je(e=>e+1),l(!0),d(!1),a(`tickets`),et(e.csrfToken,e.selectedProjectId,n))},Kt=(n,r)=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,selectedTicketId:n,ticketDetail:null,ticketDetailError:null}),Je(r),Ne(e=>e+1),l(r!==null),d(!0),a(`tickets`),$e(e.csrfToken,e.selectedProjectId,n))},qt=()=>{p(!1)},Jt=n=>{if(e.status!==`authenticated`||!e.selectedProjectId)return;if(!e.chatSessionDetail||!e.selectedChatSessionId){x(n);return}if(e.chatSessionDetail.mode===n||L)return;let r=e.selectedProjectId,i=e.selectedChatSessionId,a=e.csrfToken;R(!0),ee(null),h2(r,i,a,{mode:n}).then(e=>{x(e.mode),t(t=>{if(t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedChatSessionId!==i)return t;let n=t.chatSessions?.map(t=>t.id===e.id?e:t)??t.chatSessions;return{...t,chatSessions:n,chatSessionDetail:e,chatSessionDetailError:null}})}).catch(e=>{Qe(e)||ee(z4(e,`Unable to update the chat mode right now.`))}).finally(()=>R(!1))},Yt=()=>{if(e.status===`authenticated`&&qe&&e.selectedBundleId===qe){t({...e,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),d(!1),l(!0),Je(null);return}Je(null),d(!1)},Xt=()=>{l(!1)},Zt=e=>{let t=O.find(t=>t.id===e)??null;C(e),T(e=>t&&t.variants.includes(e)?e:``)},Qt=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),$t())},$t=()=>{if(e.status!==`authenticated`||!e.selectedProjectId||F||Ct)return;let n=v.trim();if(!n)return;let r=e.selectedProjectId,i=e.csrfToken,a=St===`opencode`&&S?S:null,o=St===`opencode`&&S&&w?w:null,s=St===`opencode`?E:[];ee(null),I(!0);let c=e=>m2(r,e.id,i,{instruction:n,tool:e.tool,model:a,variant:o,skills:s});(e.chatSessionDetail?c(e.chatSessionDetail):p2(r,i,{mode:b,tool:St,model:a,variant:o,skills:s}).then(c)).then(e=>{y(``),p(!0),t(t=>{if(t.status!==`authenticated`||t.selectedProjectId!==r)return t;let n=t.chatSessions??[],i=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];return{...t,chatSessions:i,selectedChatSessionId:e.id,chatSessionDetail:e,chatSessionDetailError:null}}),rt(i,r)}).catch(e=>{Qe(e)||ee(z4(e,`Unable to send the chat prompt.`))}).finally(()=>I(!1))},en=()=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedChatSessionId||z)return;let t=e.selectedProjectId,n=e.selectedChatSessionId;ee(null),B(n),g2(t,n,e.csrfToken).then(()=>nt(e.csrfToken,t,n)).catch(e=>{Qe(e)||ee(z4(e,`Unable to stop the chat response.`))}).finally(()=>B(null))},tn=n=>{if(e.status!==`authenticated`||!e.selectedProjectId||K||!n||!window.confirm(`Stop the active run on the desktop machine?`))return;let r=e.selectedProjectId,i=e.csrfToken;De(null),Te(n),b2(n,i).then(n=>{t(e=>e.status!==`authenticated`||e.selectedProjectId!==r?e:{...e,projectSummary:e.projectSummary?{...e.projectSummary,active_run:n.active_run}:e.projectSummary,projectSummaryError:null}),it(i,r),tt(i,r),e.selectedTicketId&&$e(i,r,e.selectedTicketId)}).catch(e=>{Qe(e)||De(z4(e,`Unable to stop the active run from mobile.`))}).finally(()=>Te(null))},nn=n=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedTicketId||re||(n===`stop-run`||n===`pause-build`)&&!window.confirm(`Stop this ticket action on the desktop machine?`))return;let r=e.selectedProjectId,i=e.selectedTicketId,a=e.csrfToken,o=n===`build`?_2(r,i,a,`build`):n===`review`?_2(r,i,a,`review`):n===`run`?v2(r,i,a):n===`stop-run`?y2(r,i,a):n===`pause-build`?x2(r,i,a):S2(r,i,a);ie(n),oe(null),o.then(e=>{t(t=>{if(t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedTicketId!==i)return t;let n=t.tickets?.map(t=>t.id===e.id?e:t)??t.tickets;return{...t,tickets:n,ticketDetail:e,ticketDetailError:null}}),it(a,r),tt(a,r),$e(a,r,i)}).catch(e=>{Qe(e)||oe(z4(e,`Unable to update this ticket from mobile.`))}).finally(()=>ie(null))},rn=n=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedBundleId||!e.bundleDetail||te)return;let r=e.selectedProjectId,i=e.selectedBundleId,a=e.csrfToken,o=e.bundleDetail,{runningBuildTicketId:s,resumableBuildTicketId:c}=x4(o);if(n===`pause-build`&&!window.confirm(`Pause this bundle build on the desktop machine?`))return;let l=e=>{t(t=>t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedBundleId!==i?t:{...t,tickets:_4(t.tickets,e),bundleDetail:e,bundleDetailError:null})},u=e=>{t(t=>t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedBundleId!==i?t:{...t,tickets:t.tickets?.map(t=>t.id===e.id?e:t)??t.tickets,bundleDetail:t.bundleDetail?{...t.bundleDetail,tickets:t.bundleDetail.tickets.map(t=>t.id===e.id?e:t)}:t.bundleDetail,bundleDetailError:null})},d=n===`build`?u2(r,i,a):n===`review`?d2(r,i,a):n===`pause-build`?s?x2(r,s,a):null:c?S2(r,c,a):null;d&&(H(n),U(null),d.then(e=>{`tickets`in e?l(e):u(e),it(a,r),tt(a,r),et(a,r,i)}).catch(e=>{Qe(e)||U(z4(e,`Unable to update this bundle from mobile.`))}).finally(()=>H(null)))},an=e=>{let t=O.find(t=>t.id===e)??null;ue(e),fe(e=>t&&t.variants.includes(e)?e:``)},on=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),sn())},sn=()=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedTicketId||!e.ticketDetail||G)return;let n=se.trim();if(!n)return;let r=e.selectedProjectId,i=e.ticketDetail,a=e.csrfToken,o=iq(i,{model:le||null,variant:de||null,skills:pe}),s=()=>i.state===`plan`?w2(r,i.id,a,n):T2(r,i.id,a,n),c=e=>{t(t=>{if(t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedTicketId!==i.id)return t;let n=t.tickets?.map(t=>t.id===e.id?e:t)??t.tickets;return{...t,tickets:n,ticketDetail:e,ticketDetailError:null}})};he(!0),_e(null),(async()=>{o.shouldPersist&&c(await C2(r,i.id,a,{model:o.model,variant:o.variant,skills:o.skills})),c(await s()),ce(``),tt(a,r),$e(a,r,i.id)})().catch(e=>{Qe(e)||_e(z4(e,`Unable to send the ticket follow-up.`))}).finally(()=>he(!1))},cn=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),ln())},ln=()=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedBundleId||!e.bundleDetail||be)return;let n=ve.trim();if(!n)return;let r=e.selectedProjectId,i=e.selectedBundleId,a=e.csrfToken,o=e=>{t(t=>t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedBundleId!==i?t:{...t,tickets:_4(t.tickets,e),bundleDetail:e,bundleDetailError:null})};xe(!0),Ce(null),E2(r,i,a,n).then(e=>{o(e),ye(``),tt(a,r),et(a,r,i)}).catch(e=>{Qe(e)||Ce(z4(e,`Unable to send the bundle follow-up.`))}).finally(()=>xe(!1))};return e.status===`checking`?(0,Z.jsx)(G2,{title:`Checking mobile session`,description:`Archon is validating this browser before showing project controls.`}):e.status===`pairing`?(0,Z.jsx)(G2,{title:`Checking pairing link`,description:`Keep this page open while Archon verifies the one-time pairing link.`}):e.status===`pairing_confirmation`?(0,Z.jsxs)(G2,{title:`Compare pairing code`,description:`Confirm this code matches the desktop dialog before pairing this phone.`,children:[(0,Z.jsx)(Nf,{className:`border-primary/25 bg-primary/10 shadow-none`,children:(0,Z.jsxs)(Rf,{className:`space-y-2 pt-5 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-[0.18em] text-foreground`,children:`Verification code`}),(0,Z.jsx)(`div`,{className:`font-mono text-3xl font-semibold tracking-[0.18em] text-foreground`,children:e.displayCode}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Expires at `,R4(e.expiresAt)]})]})}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`If this code does not match the desktop dialog, cancel and regenerate the pairing link from desktop Archon.`}),e.error?(0,Z.jsx)(`p`,{className:`text-sm text-red-200`,children:e.error}):null,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(J,{size:`lg`,disabled:g,onClick:At,children:g?`Pairing...`:`Pair this phone`}),(0,Z.jsx)(J,{variant:`outline`,size:`lg`,disabled:g,onClick:jt,children:`Cancel`})]})]}):e.status===`unauthenticated`?(0,Z.jsx)(G2,{title:e.reason===`session_revoked`?`Mobile session revoked`:`Pairing required`,description:e.reason===`session_revoked`?`This mobile session is no longer valid. Scan the QR code or open the pairing link from desktop Archon to continue.`:`This browser is not paired. Scan the QR code or open the pairing link from desktop Archon.`,children:(0,Z.jsx)(J,{onClick:Tt,children:`Retry`})}):e.status===`error`?(0,Z.jsx)(G2,{title:`Mobile access unavailable`,description:e.message,children:(0,Z.jsx)(J,{onClick:Tt,children:`Retry`})}):(0,Z.jsxs)(`main`,{className:W(`bg-background text-foreground`,wt?`flex h-[100dvh] flex-col overflow-hidden`:`min-h-screen`),children:[(0,Z.jsx)(Q2,{open:o,projects:e.projects,selectedProjectId:e.selectedProjectId,error:e.projectError,onOpenChange:s,onSelectProject:Bt,onRetry:Mt}),(0,Z.jsx)($2,{open:ze,project:ht,targetOptions:Ie,error:Ge??Re,isLoading:Ve,isSubmitting:Ue,onOpenChange:Be,onRetry:Pt,onSelectBundle:e=>{Vt(e)},onSelectRepoRoot:(e,t)=>{Ht(e,t)}}),(0,Z.jsx)(e4,{selectedProject:ht,targetLabel:yt,isTargetLoading:bt,isTargetDisabled:!dt,connectionState:n,onOpenProjects:Dt,onOpenTargetSelector:Ot}),wt?(0,Z.jsxs)(`div`,{className:`mx-auto flex min-h-0 w-full max-w-6xl flex-1 flex-col overflow-hidden px-3 py-3 sm:px-4`,children:[i===`tickets`?(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:u&&e.selectedTicketId?(0,Z.jsx)(F4,{selectedProjectId:e.selectedProjectId,ticketId:e.selectedTicketId,ticket:e.ticketDetail,openNonce:Me,error:e.ticketDetailError,actionState:re,actionError:ae,followUpPrompt:se,followUpSelectedModel:le,followUpSelectedVariant:de,followUpSelectedSkills:pe,availableModels:O,availableSkills:j,isLoadingAgentSettings:N,isSendingFollowUp:G,followUpError:ge,onBack:Yt,onRetry:Rt,onAction:nn,onFollowUpPromptChange:ce,onFollowUpModelChange:an,onFollowUpVariantChange:fe,onFollowUpSkillsChange:me,onFollowUpKeyDown:on,onFollowUpSubmit:sn,isLargeScreen:!1}):(0,Z.jsx)(N4,{selectedProjectId:e.selectedProjectId,bundleId:e.selectedBundleId,bundleDetail:e.bundleDetail,openNonce:Ae,mobileDetailView:Pe,error:e.bundleDetailError,actionState:te,actionError:ne,followUpPrompt:ve,isSendingFollowUp:be,followUpError:Se,availableModels:O,onBack:Xt,onRetry:zt,onAction:rn,onDetailViewChange:Fe,onSelectTicket:Kt,onFollowUpPromptChange:ye,onFollowUpKeyDown:cn,onFollowUpSubmit:ln,isLargeScreen:!1})}):null,i===`chats`?(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(P4,{selectedProjectId:e.selectedProjectId,chatSession:e.chatSessionDetail,chatSessionId:e.selectedChatSessionId,openNonce:Oe,error:e.chatSessionDetailError,isStopping:z===e.selectedChatSessionId,composerMode:e.chatSessionDetail?.mode??b,composerTool:St,prompt:v,selectedModel:S,selectedVariant:w,selectedSkills:E,availableModels:O,availableSkills:j,isLoadingAgentSettings:N,isSending:F,isUpdatingMode:L,composerDisabledReason:Ct,onBack:qt,onRetry:It,onStop:en,onModeChange:Jt,onPromptChange:y,onModelChange:Zt,onVariantChange:T,onSkillsChange:D,onPromptKeyDown:Qt,onSubmit:$t,isLargeScreen:!1}),V?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-red-200`,children:V}):null]}):null]}):(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-6xl px-3 py-3 pb-[calc(env(safe-area-inset-bottom)+5rem)] sm:px-4 lg:flex lg:min-h-[calc(100dvh-4.5rem)] lg:flex-col lg:overflow-hidden lg:pb-4`,children:(0,Z.jsxs)(`div`,{className:`space-y-3 lg:flex lg:min-h-0 lg:flex-1 lg:flex-col`,children:[(0,Z.jsx)(Y2,{status:n,onRetry:Tt}),i===`overview`?(0,Z.jsx)(`div`,{className:`space-y-3 lg:flex lg:min-h-0 lg:flex-1 lg:flex-col`,children:e.projectError?(0,Z.jsx)(n4,{title:`Projects unavailable`,description:e.projectError,action:(0,Z.jsx)(J,{variant:`warning`,onClick:Mt,children:`Retry projects`})}):e.selectedProjectId&&!e.projectSummary&&!e.projectSummaryError?(0,Z.jsx)(a4,{}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(l4,{selectedProjectId:e.selectedProjectId,summary:e.projectSummary,tickets:e.tickets,error:e.projectSummaryError,chatSessions:e.chatSessions,chatSessionDetail:e.chatSessionDetail,stoppingRunContextKey:K,stopRunError:Ee,onRetry:Nt,onStopRun:tn,onOpenTickets:()=>Et(`tickets`),onOpenChats:()=>Et(`chats`)}),(0,Z.jsx)(o4,{isLoggingOut:m,onLogout:kt})]})}):null,i===`tickets`?xt?(0,Z.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 overflow-hidden lg:grid-cols-[minmax(15rem,18rem)_minmax(0,1fr)]`,children:[(0,Z.jsx)(`div`,{className:`min-h-0`,children:(0,Z.jsx)(v4,{selectedProjectId:e.selectedProjectId,tickets:e.tickets,selectedBundleId:e.selectedBundleId,selectedTicketId:e.selectedTicketId,error:e.ticketsError,onRetry:Lt,onSelectBundle:Gt,onSelectTicket:Kt})}),(0,Z.jsx)(`div`,{className:`hidden min-h-0 lg:flex lg:flex-col lg:overflow-hidden`,children:u&&e.selectedTicketId?(0,Z.jsx)(F4,{selectedProjectId:e.selectedProjectId,ticketId:e.selectedTicketId,ticket:e.ticketDetail,openNonce:Me,error:e.ticketDetailError,actionState:re,actionError:ae,followUpPrompt:se,followUpSelectedModel:le,followUpSelectedVariant:de,followUpSelectedSkills:pe,availableModels:O,availableSkills:j,isLoadingAgentSettings:N,isSendingFollowUp:G,followUpError:ge,onBack:Yt,onRetry:Rt,onAction:nn,onFollowUpPromptChange:ce,onFollowUpModelChange:an,onFollowUpVariantChange:fe,onFollowUpSkillsChange:me,onFollowUpKeyDown:on,onFollowUpSubmit:sn,isLargeScreen:!0}):(0,Z.jsx)(N4,{selectedProjectId:e.selectedProjectId,bundleId:e.selectedBundleId,bundleDetail:e.bundleDetail,openNonce:Ae,mobileDetailView:Pe,error:e.bundleDetailError,actionState:te,actionError:ne,followUpPrompt:ve,isSendingFollowUp:be,followUpError:Se,availableModels:O,onBack:Xt,onRetry:zt,onAction:rn,onDetailViewChange:Fe,onSelectTicket:Kt,onFollowUpPromptChange:ye,onFollowUpKeyDown:cn,onFollowUpSubmit:ln,isLargeScreen:!0})})]}):(0,Z.jsx)(v4,{selectedProjectId:e.selectedProjectId,tickets:e.tickets,selectedBundleId:e.selectedBundleId,selectedTicketId:e.selectedTicketId,error:e.ticketsError,onRetry:Lt,onSelectBundle:Gt,onSelectTicket:Kt}):null,i===`chats`?xt?(0,Z.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 overflow-hidden lg:grid-cols-[minmax(15rem,18rem)_minmax(0,1fr)]`,children:[(0,Z.jsx)(`div`,{className:`min-h-0`,children:(0,Z.jsx)(y4,{selectedProjectId:e.selectedProjectId,chatSessions:e.chatSessions,selectedChatSessionId:e.selectedChatSessionId,error:e.chatSessionsError,onRetry:Ft,onOpenNewChat:Wt,onSelectChat:Ut})}),(0,Z.jsxs)(`div`,{className:`hidden min-h-0 lg:flex lg:flex-col lg:overflow-hidden`,children:[(0,Z.jsx)(P4,{selectedProjectId:e.selectedProjectId,chatSession:e.chatSessionDetail,chatSessionId:e.selectedChatSessionId,openNonce:Oe,error:e.chatSessionDetailError,isStopping:z===e.selectedChatSessionId,composerMode:e.chatSessionDetail?.mode??b,composerTool:St,prompt:v,selectedModel:S,selectedVariant:w,selectedSkills:E,availableModels:O,availableSkills:j,isLoadingAgentSettings:N,isSending:F,isUpdatingMode:L,composerDisabledReason:Ct,onBack:qt,onRetry:It,onStop:en,onModeChange:Jt,onPromptChange:y,onModelChange:Zt,onVariantChange:T,onSkillsChange:D,onPromptKeyDown:Qt,onSubmit:$t,isLargeScreen:!0}),V?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-red-200`,children:V}):null]})]}):(0,Z.jsx)(y4,{selectedProjectId:e.selectedProjectId,chatSessions:e.chatSessions,selectedChatSessionId:e.selectedChatSessionId,error:e.chatSessionsError,onRetry:Ft,onOpenNewChat:Wt,onSelectChat:Ut}):null]})}),wt?null:(0,Z.jsx)(t4,{activeSection:i,onChange:Et})]})},W4=({socket:e=XK,children:t})=>(0,Z.jsx)(UZ.Provider,{value:e,children:t}),G4=()=>typeof window<`u`&&window.location.pathname.startsWith(`/mobile`),K4=()=>{let e=G4();return vf(e?null:XK),(0,Z.jsx)(gt,{i18n:Oe,children:(0,Z.jsx)(yt,{children:(0,Z.jsxs)(W4,{children:[e&&(0,Z.jsx)(U4,{}),!e&&(0,Z.jsx)(Y0,{})]})})})};document.documentElement.classList.add(`dark`),document.documentElement.style.colorScheme=`dark`,(0,$e.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(K4,{}));export{Ql as _,AE as a,bp as c,Yu as d,Ku as f,eu as g,Xl as h,ME as i,yp as l,Jl as m,kE as n,wm as o,Kl as p,jE as r,vp as s,XK as t,Zu as u,Zl as v,$l as y};
|