nterminal 1.2.35 → 1.2.36
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/MarkdownPreview-kJS2tSfr.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-CDp3EzWK.js → TranscriptMarkdownBody-BIzF0d-f.js} +1 -1
- package/dist/client/assets/{index-BNanK2m-.js → index-BtdpJmjE.js} +1 -1
- package/dist/client/assets/{index-DEugAszO.js → index-C7Lxe2Ts.js} +3 -3
- package/dist/client/assets/{index-DaPc49Q2.css → index-Dzw0RUe4.css} +1 -1
- package/dist/client/index.html +2 -2
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview-BEfFObXf.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-kJS2tSfr.js","assets/index-BtdpJmjE.js","assets/TranscriptMarkdownBody-BIzF0d-f.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&a(d)}).observe(document,{childList:!0,subtree:!0});function n(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function a(o){if(o.ep)return;o.ep=!0;const c=n(o);fetch(o.href,c)}})();function nx(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Gd={exports:{}},Bl={};var xy;function rx(){if(xy)return Bl;xy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,o,c){var d=null;if(c!==void 0&&(d=""+c),o.key!==void 0&&(d=""+o.key),"key"in o){c={};for(var p in o)p!=="key"&&(c[p]=o[p])}else c=o;return o=c.ref,{$$typeof:e,type:a,key:d,ref:o!==void 0?o:null,props:c}}return Bl.Fragment=t,Bl.jsx=n,Bl.jsxs=n,Bl}var Ey;function ax(){return Ey||(Ey=1,Gd.exports=rx()),Gd.exports}var _=ax(),Zd={exports:{}},Ue={};var Ty;function lx(){if(Ty)return Ue;Ty=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),S=Symbol.iterator;function E(R){return R===null||typeof R!="object"?null:(R=S&&R[S]||R["@@iterator"],typeof R=="function"?R:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,B={};function M(R,Y,se){this.props=R,this.context=Y,this.refs=B,this.updater=se||x}M.prototype.isReactComponent={},M.prototype.setState=function(R,Y){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,Y,"setState")},M.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function V(){}V.prototype=M.prototype;function I(R,Y,se){this.props=R,this.context=Y,this.refs=B,this.updater=se||x}var X=I.prototype=new V;X.constructor=I,T(X,M.prototype),X.isPureReactComponent=!0;var le=Array.isArray;function ee(){}var te={H:null,A:null,T:null,S:null},ce=Object.prototype.hasOwnProperty;function pe(R,Y,se){var fe=se.ref;return{$$typeof:e,type:R,key:Y,ref:fe!==void 0?fe:null,props:se}}function A(R,Y){return pe(R.type,Y,R.props)}function P(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function K(R){var Y={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(se){return Y[se]})}var j=/\/+/g;function O(R,Y){return typeof R=="object"&&R!==null&&R.key!=null?K(""+R.key):Y.toString(36)}function Q(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(ee,ee):(R.status="pending",R.then(function(Y){R.status==="pending"&&(R.status="fulfilled",R.value=Y)},function(Y){R.status==="pending"&&(R.status="rejected",R.reason=Y)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function D(R,Y,se,fe,he){var de=typeof R;(de==="undefined"||de==="boolean")&&(R=null);var Se=!1;if(R===null)Se=!0;else switch(de){case"bigint":case"string":case"number":Se=!0;break;case"object":switch(R.$$typeof){case e:case t:Se=!0;break;case b:return Se=R._init,D(Se(R._payload),Y,se,fe,he)}}if(Se)return he=he(R),Se=fe===""?"."+O(R,0):fe,le(he)?(se="",Se!=null&&(se=Se.replace(j,"$&/")+"/"),D(he,Y,se,"",function(Re){return Re})):he!=null&&(P(he)&&(he=A(he,se+(he.key==null||R&&R.key===he.key?"":(""+he.key).replace(j,"$&/")+"/")+Se)),Y.push(he)),1;Se=0;var Be=fe===""?".":fe+":";if(le(R))for(var Ae=0;Ae<R.length;Ae++)fe=R[Ae],de=Be+O(fe,Ae),Se+=D(fe,Y,se,de,he);else if(Ae=E(R),typeof Ae=="function")for(R=Ae.call(R),Ae=0;!(fe=R.next()).done;)fe=fe.value,de=Be+O(fe,Ae++),Se+=D(fe,Y,se,de,he);else if(de==="object"){if(typeof R.then=="function")return D(Q(R),Y,se,fe,he);throw Y=String(R),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return Se}function q(R,Y,se){if(R==null)return R;var fe=[],he=0;return D(R,fe,"","",function(de){return Y.call(se,de,he++)}),fe}function Z(R){if(R._status===-1){var Y=R._result;Y=Y(),Y.then(function(se){(R._status===0||R._status===-1)&&(R._status=1,R._result=se)},function(se){(R._status===0||R._status===-1)&&(R._status=2,R._result=se)}),R._status===-1&&(R._status=0,R._result=Y)}if(R._status===1)return R._result.default;throw R._result}var ve=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},be={map:q,forEach:function(R,Y,se){q(R,function(){Y.apply(this,arguments)},se)},count:function(R){var Y=0;return q(R,function(){Y++}),Y},toArray:function(R){return q(R,function(Y){return Y})||[]},only:function(R){if(!P(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return Ue.Activity=y,Ue.Children=be,Ue.Component=M,Ue.Fragment=n,Ue.Profiler=o,Ue.PureComponent=I,Ue.StrictMode=a,Ue.Suspense=m,Ue.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=te,Ue.__COMPILER_RUNTIME={__proto__:null,c:function(R){return te.H.useMemoCache(R)}},Ue.cache=function(R){return function(){return R.apply(null,arguments)}},Ue.cacheSignal=function(){return null},Ue.cloneElement=function(R,Y,se){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var fe=T({},R.props),he=R.key;if(Y!=null)for(de in Y.key!==void 0&&(he=""+Y.key),Y)!ce.call(Y,de)||de==="key"||de==="__self"||de==="__source"||de==="ref"&&Y.ref===void 0||(fe[de]=Y[de]);var de=arguments.length-2;if(de===1)fe.children=se;else if(1<de){for(var Se=Array(de),Be=0;Be<de;Be++)Se[Be]=arguments[Be+2];fe.children=Se}return pe(R.type,he,fe)},Ue.createContext=function(R){return R={$$typeof:d,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:c,_context:R},R},Ue.createElement=function(R,Y,se){var fe,he={},de=null;if(Y!=null)for(fe in Y.key!==void 0&&(de=""+Y.key),Y)ce.call(Y,fe)&&fe!=="key"&&fe!=="__self"&&fe!=="__source"&&(he[fe]=Y[fe]);var Se=arguments.length-2;if(Se===1)he.children=se;else if(1<Se){for(var Be=Array(Se),Ae=0;Ae<Se;Ae++)Be[Ae]=arguments[Ae+2];he.children=Be}if(R&&R.defaultProps)for(fe in Se=R.defaultProps,Se)he[fe]===void 0&&(he[fe]=Se[fe]);return pe(R,de,he)},Ue.createRef=function(){return{current:null}},Ue.forwardRef=function(R){return{$$typeof:p,render:R}},Ue.isValidElement=P,Ue.lazy=function(R){return{$$typeof:b,_payload:{_status:-1,_result:R},_init:Z}},Ue.memo=function(R,Y){return{$$typeof:f,type:R,compare:Y===void 0?null:Y}},Ue.startTransition=function(R){var Y=te.T,se={};te.T=se;try{var fe=R(),he=te.S;he!==null&&he(se,fe),typeof fe=="object"&&fe!==null&&typeof fe.then=="function"&&fe.then(ee,ve)}catch(de){ve(de)}finally{Y!==null&&se.types!==null&&(Y.types=se.types),te.T=Y}},Ue.unstable_useCacheRefresh=function(){return te.H.useCacheRefresh()},Ue.use=function(R){return te.H.use(R)},Ue.useActionState=function(R,Y,se){return te.H.useActionState(R,Y,se)},Ue.useCallback=function(R,Y){return te.H.useCallback(R,Y)},Ue.useContext=function(R){return te.H.useContext(R)},Ue.useDebugValue=function(){},Ue.useDeferredValue=function(R,Y){return te.H.useDeferredValue(R,Y)},Ue.useEffect=function(R,Y){return te.H.useEffect(R,Y)},Ue.useEffectEvent=function(R){return te.H.useEffectEvent(R)},Ue.useId=function(){return te.H.useId()},Ue.useImperativeHandle=function(R,Y,se){return te.H.useImperativeHandle(R,Y,se)},Ue.useInsertionEffect=function(R,Y){return te.H.useInsertionEffect(R,Y)},Ue.useLayoutEffect=function(R,Y){return te.H.useLayoutEffect(R,Y)},Ue.useMemo=function(R,Y){return te.H.useMemo(R,Y)},Ue.useOptimistic=function(R,Y){return te.H.useOptimistic(R,Y)},Ue.useReducer=function(R,Y,se){return te.H.useReducer(R,Y,se)},Ue.useRef=function(R){return te.H.useRef(R)},Ue.useState=function(R){return te.H.useState(R)},Ue.useSyncExternalStore=function(R,Y,se){return te.H.useSyncExternalStore(R,Y,se)},Ue.useTransition=function(){return te.H.useTransition()},Ue.version="19.2.6",Ue}var ky;function tm(){return ky||(ky=1,Zd.exports=lx()),Zd.exports}var g=tm();const ii=nx(g);var Qd={exports:{}},Ol={},Jd={exports:{}},ef={};var Dy;function ox(){return Dy||(Dy=1,(function(e){function t(D,q){var Z=D.length;D.push(q);e:for(;0<Z;){var ve=Z-1>>>1,be=D[ve];if(0<o(be,q))D[ve]=q,D[Z]=be,Z=ve;else break e}}function n(D){return D.length===0?null:D[0]}function a(D){if(D.length===0)return null;var q=D[0],Z=D.pop();if(Z!==q){D[0]=Z;e:for(var ve=0,be=D.length,R=be>>>1;ve<R;){var Y=2*(ve+1)-1,se=D[Y],fe=Y+1,he=D[fe];if(0>o(se,Z))fe<be&&0>o(he,se)?(D[ve]=he,D[fe]=Z,ve=fe):(D[ve]=se,D[Y]=Z,ve=Y);else if(fe<be&&0>o(he,Z))D[ve]=he,D[fe]=Z,ve=fe;else break e}}return q}function o(D,q){var Z=D.sortIndex-q.sortIndex;return Z!==0?Z:D.id-q.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,p=d.now();e.unstable_now=function(){return d.now()-p}}var m=[],f=[],b=1,y=null,S=3,E=!1,x=!1,T=!1,B=!1,M=typeof setTimeout=="function"?setTimeout:null,V=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function X(D){for(var q=n(f);q!==null;){if(q.callback===null)a(f);else if(q.startTime<=D)a(f),q.sortIndex=q.expirationTime,t(m,q);else break;q=n(f)}}function le(D){if(T=!1,X(D),!x)if(n(m)!==null)x=!0,ee||(ee=!0,K());else{var q=n(f);q!==null&&Q(le,q.startTime-D)}}var ee=!1,te=-1,ce=5,pe=-1;function A(){return B?!0:!(e.unstable_now()-pe<ce)}function P(){if(B=!1,ee){var D=e.unstable_now();pe=D;var q=!0;try{e:{x=!1,T&&(T=!1,V(te),te=-1),E=!0;var Z=S;try{t:{for(X(D),y=n(m);y!==null&&!(y.expirationTime>D&&A());){var ve=y.callback;if(typeof ve=="function"){y.callback=null,S=y.priorityLevel;var be=ve(y.expirationTime<=D);if(D=e.unstable_now(),typeof be=="function"){y.callback=be,X(D),q=!0;break t}y===n(m)&&a(m),X(D)}else a(m);y=n(m)}if(y!==null)q=!0;else{var R=n(f);R!==null&&Q(le,R.startTime-D),q=!1}}break e}finally{y=null,S=Z,E=!1}q=void 0}}finally{q?K():ee=!1}}}var K;if(typeof I=="function")K=function(){I(P)};else if(typeof MessageChannel<"u"){var j=new MessageChannel,O=j.port2;j.port1.onmessage=P,K=function(){O.postMessage(null)}}else K=function(){M(P,0)};function Q(D,q){te=M(function(){D(e.unstable_now())},q)}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(D){D.callback=null},e.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ce=0<D?Math.floor(1e3/D):5},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_next=function(D){switch(S){case 1:case 2:case 3:var q=3;break;default:q=S}var Z=S;S=q;try{return D()}finally{S=Z}},e.unstable_requestPaint=function(){B=!0},e.unstable_runWithPriority=function(D,q){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var Z=S;S=D;try{return q()}finally{S=Z}},e.unstable_scheduleCallback=function(D,q,Z){var ve=e.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?ve+Z:ve):Z=ve,D){case 1:var be=-1;break;case 2:be=250;break;case 5:be=1073741823;break;case 4:be=1e4;break;default:be=5e3}return be=Z+be,D={id:b++,callback:q,priorityLevel:D,startTime:Z,expirationTime:be,sortIndex:-1},Z>ve?(D.sortIndex=Z,t(f,D),n(m)===null&&D===n(f)&&(T?(V(te),te=-1):T=!0,Q(le,Z-ve))):(D.sortIndex=be,t(m,D),x||E||(x=!0,ee||(ee=!0,K()))),D},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(D){var q=S;return function(){var Z=S;S=q;try{return D.apply(this,arguments)}finally{S=Z}}}})(ef)),ef}var Ry;function cx(){return Ry||(Ry=1,Jd.exports=ox()),Jd.exports}var tf={exports:{}},Mi={};var My;function ux(){if(My)return Mi;My=1;var e=tm();function t(m){var f="https://react.dev/errors/"+m;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)f+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+m+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var a={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(m,f,b){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:y==null?null:""+y,children:m,containerInfo:f,implementation:b}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(m,f){if(m==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return Mi.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,Mi.createPortal=function(m,f){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return c(m,f,null,b)},Mi.flushSync=function(m){var f=d.T,b=a.p;try{if(d.T=null,a.p=2,m)return m()}finally{d.T=f,a.p=b,a.d.f()}},Mi.preconnect=function(m,f){typeof m=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,a.d.C(m,f))},Mi.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},Mi.preinit=function(m,f){if(typeof m=="string"&&f&&typeof f.as=="string"){var b=f.as,y=p(b,f.crossOrigin),S=typeof f.integrity=="string"?f.integrity:void 0,E=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;b==="style"?a.d.S(m,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:y,integrity:S,fetchPriority:E}):b==="script"&&a.d.X(m,{crossOrigin:y,integrity:S,fetchPriority:E,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},Mi.preinitModule=function(m,f){if(typeof m=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var b=p(f.as,f.crossOrigin);a.d.M(m,{crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&a.d.M(m)},Mi.preload=function(m,f){if(typeof m=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var b=f.as,y=p(b,f.crossOrigin);a.d.L(m,b,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},Mi.preloadModule=function(m,f){if(typeof m=="string")if(f){var b=p(f.as,f.crossOrigin);a.d.m(m,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else a.d.m(m)},Mi.requestFormReset=function(m){a.d.r(m)},Mi.unstable_batchedUpdates=function(m,f){return m(f)},Mi.useFormState=function(m,f,b){return d.H.useFormState(m,f,b)},Mi.useFormStatus=function(){return d.H.useHostTransitionStatus()},Mi.version="19.2.6",Mi}var Ny;function LS(){if(Ny)return tf.exports;Ny=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),tf.exports=ux(),tf.exports}var Ay;function hx(){if(Ay)return Ol;Ay=1;var e=cx(),t=tm(),n=LS();function a(i){var s="https://react.dev/errors/"+i;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)s+="&args[]="+encodeURIComponent(arguments[r])}return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var s=i,r=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(r=s.return),i=s.return;while(i)}return s.tag===3?r:null}function d(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function p(i){if(i.tag===31){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function m(i){if(c(i)!==i)throw Error(a(188))}function f(i){var s=i.alternate;if(!s){if(s=c(i),s===null)throw Error(a(188));return s!==i?null:i}for(var r=i,l=s;;){var u=r.return;if(u===null)break;var h=u.alternate;if(h===null){if(l=u.return,l!==null){r=l;continue}break}if(u.child===h.child){for(h=u.child;h;){if(h===r)return m(u),i;if(h===l)return m(u),s;h=h.sibling}throw Error(a(188))}if(r.return!==l.return)r=u,l=h;else{for(var v=!1,w=u.child;w;){if(w===r){v=!0,r=u,l=h;break}if(w===l){v=!0,l=u,r=h;break}w=w.sibling}if(!v){for(w=h.child;w;){if(w===r){v=!0,r=h,l=u;break}if(w===l){v=!0,l=h,r=u;break}w=w.sibling}if(!v)throw Error(a(189))}}if(r.alternate!==l)throw Error(a(190))}if(r.tag!==3)throw Error(a(188));return r.stateNode.current===r?i:s}function b(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i;for(i=i.child;i!==null;){if(s=b(i),s!==null)return s;i=i.sibling}return null}var y=Object.assign,S=Symbol.for("react.element"),E=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),V=Symbol.for("react.consumer"),I=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),le=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),ce=Symbol.for("react.lazy"),pe=Symbol.for("react.activity"),A=Symbol.for("react.memo_cache_sentinel"),P=Symbol.iterator;function K(i){return i===null||typeof i!="object"?null:(i=P&&i[P]||i["@@iterator"],typeof i=="function"?i:null)}var j=Symbol.for("react.client.reference");function O(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===j?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case T:return"Fragment";case M:return"Profiler";case B:return"StrictMode";case le:return"Suspense";case ee:return"SuspenseList";case pe:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case I:return i.displayName||"Context";case V:return(i._context.displayName||"Context")+".Consumer";case X:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case te:return s=i.displayName||null,s!==null?s:O(i.type)||"Memo";case ce:s=i._payload,i=i._init;try{return O(i(s))}catch{}}return null}var Q=Array.isArray,D=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},ve=[],be=-1;function R(i){return{current:i}}function Y(i){0>be||(i.current=ve[be],ve[be]=null,be--)}function se(i,s){be++,ve[be]=i.current,i.current=s}var fe=R(null),he=R(null),de=R(null),Se=R(null);function Be(i,s){switch(se(de,s),se(he,i),se(fe,null),s.nodeType){case 9:case 11:i=(i=s.documentElement)&&(i=i.namespaceURI)?Yg(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=Yg(s),i=Vg(s,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}Y(fe),se(fe,i)}function Ae(){Y(fe),Y(he),Y(de)}function Re(i){i.memoizedState!==null&&se(Se,i);var s=fe.current,r=Vg(s,i.type);s!==r&&(se(he,i),se(fe,r))}function ze(i){he.current===i&&(Y(fe),Y(he)),Se.current===i&&(Y(Se),Ml._currentValue=Z)}var He,Te;function ne(i){if(He===void 0)try{throw Error()}catch(r){var s=r.stack.trim().match(/\n( *(at )?)/);He=s&&s[1]||"",Te=-1<r.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+He+i+Te}var De=!1;function xe(i,s){if(!i||De)return"";De=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(s){var oe=function(){throw Error()};if(Object.defineProperty(oe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(oe,[])}catch(G){var $=G}Reflect.construct(i,[],oe)}else{try{oe.call()}catch(G){$=G}i.call(oe.prototype)}}else{try{throw Error()}catch(G){$=G}(oe=i())&&typeof oe.catch=="function"&&oe.catch(function(){})}}catch(G){if(G&&$&&typeof G.stack=="string")return[G.stack,$.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var h=l.DetermineComponentFrameRoot(),v=h[0],w=h[1];if(v&&w){var N=v.split(`
|
|
@@ -12,7 +12,7 @@ Error generating stack: `+l.message+`
|
|
|
12
12
|
While dragging, use the arrow keys to move the item.
|
|
13
13
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
14
14
|
`},Tx={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 kx(e){let{announcements:t=Tx,container:n,hiddenTextDescribedById:a,screenReaderInstructions:o=Ex}=e;const{announce:c,announcement:d}=wx(),p=Lu("DndLiveRegion"),[m,f]=g.useState(!1);if(g.useEffect(()=>{f(!0)},[]),Cx(g.useMemo(()=>({onDragStart(y){let{active:S}=y;c(t.onDragStart({active:S}))},onDragMove(y){let{active:S,over:E}=y;t.onDragMove&&c(t.onDragMove({active:S,over:E}))},onDragOver(y){let{active:S,over:E}=y;c(t.onDragOver({active:S,over:E}))},onDragEnd(y){let{active:S,over:E}=y;c(t.onDragEnd({active:S,over:E}))},onDragCancel(y){let{active:S,over:E}=y;c(t.onDragCancel({active:S,over:E}))}}),[c,t])),!m)return null;const b=ii.createElement(ii.Fragment,null,ii.createElement(bx,{id:a,value:o.draggable}),ii.createElement(Sx,{id:p,announcement:d}));return n?$l.createPortal(b,n):b}var ti;(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"})(ti||(ti={}));function pu(){}function Oy(e,t){return g.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Dx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g.useMemo(()=>[...t].filter(a=>a!=null),[...t])}const Os=Object.freeze({x:0,y:0});function Rx(e,t){let{data:{value:n}}=e,{data:{value:a}}=t;return a-n}function Mx(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Nx(e,t){const n=Math.max(t.top,e.top),a=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),d=o-a,p=c-n;if(a<o&&n<c){const m=t.width*t.height,f=e.width*e.height,b=d*p,y=b/(m+f-b);return Number(y.toFixed(4))}return 0}const Ax=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:a}=e;const o=[];for(const c of a){const{id:d}=c,p=n.get(d);if(p){const m=Nx(p,t);m>0&&o.push({id:d,data:{droppableContainer:c,value:m}})}}return o.sort(Rx)};function Lx(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function KS(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Os}function Bx(e){return function(n){for(var a=arguments.length,o=new Array(a>1?a-1:0),c=1;c<a;c++)o[c-1]=arguments[c];return o.reduce((d,p)=>({...d,top:d.top+e*p.y,bottom:d.bottom+e*p.y,left:d.left+e*p.x,right:d.right+e*p.x}),{...n})}}const Ox=Bx(1);function zx(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function jx(e,t,n){const a=zx(t);if(!a)return e;const{scaleX:o,scaleY:c,x:d,y:p}=a,m=e.left-d-(1-o)*parseFloat(n),f=e.top-p-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),b=o?e.width/o:e.width,y=c?e.height/c:e.height;return{width:b,height:y,top:f,right:m+b,bottom:f+y,left:m}}const Hx={ignoreTransform:!1};function xo(e,t){t===void 0&&(t=Hx);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:b}=Zi(e).getComputedStyle(e);f&&(n=jx(n,f,b))}const{top:a,left:o,width:c,height:d,bottom:p,right:m}=n;return{top:a,left:o,width:c,height:d,bottom:p,right:m}}function zy(e){return xo(e,{ignoreTransform:!0})}function Ux(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Px(e,t){return t===void 0&&(t=Zi(e).getComputedStyle(e)),t.position==="fixed"}function Kx(e,t){t===void 0&&(t=Zi(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?n.test(c):!1})}function am(e,t){const n=[];function a(o){if(t!=null&&n.length>=t||!o)return n;if(nm(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!wo(o)||jS(o)||n.includes(o))return n;const c=Zi(e).getComputedStyle(o);return o!==e&&Kx(o,c)&&n.push(o),Px(o,c)?n:a(o.parentNode)}return e?a(e):n}function IS(e){const[t]=am(e,1);return t??null}function nf(e){return!Au||!e?null:Ua(e)?e:sm(e)?nm(e)||e===Pa(e).scrollingElement?window:wo(e)?e:null:null}function FS(e){return Ua(e)?e.scrollX:e.scrollLeft}function qS(e){return Ua(e)?e.scrollY:e.scrollTop}function Lf(e){return{x:FS(e),y:qS(e)}}var oi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(oi||(oi={}));function WS(e){return!Au||!e?!1:e===document.scrollingElement}function $S(e){const t={x:0,y:0},n=WS(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,d=e.scrollTop>=a.y,p=e.scrollLeft>=a.x;return{isTop:o,isLeft:c,isBottom:d,isRight:p,maxScroll:a,minScroll:t}}const Ix={x:.2,y:.2};function Fx(e,t,n,a,o){let{top:c,left:d,right:p,bottom:m}=n;a===void 0&&(a=10),o===void 0&&(o=Ix);const{isTop:f,isBottom:b,isLeft:y,isRight:S}=$S(e),E={x:0,y:0},x={x:0,y:0},T={height:t.height*o.y,width:t.width*o.x};return!f&&c<=t.top+T.height?(E.y=oi.Backward,x.y=a*Math.abs((t.top+T.height-c)/T.height)):!b&&m>=t.bottom-T.height&&(E.y=oi.Forward,x.y=a*Math.abs((t.bottom-T.height-m)/T.height)),!S&&p>=t.right-T.width?(E.x=oi.Forward,x.x=a*Math.abs((t.right-T.width-p)/T.width)):!y&&d<=t.left+T.width&&(E.x=oi.Backward,x.x=a*Math.abs((t.left+T.width-d)/T.width)),{direction:E,speed:x}}function qx(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:d}=window;return{top:0,left:0,right:c,bottom:d,width:c,height:d}}const{top:t,left:n,right:a,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:a,bottom:o,width:e.clientWidth,height:e.clientHeight}}function YS(e){return e.reduce((t,n)=>Ba(t,Lf(n)),Os)}function Wx(e){return e.reduce((t,n)=>t+FS(n),0)}function $x(e){return e.reduce((t,n)=>t+qS(n),0)}function Yx(e,t){if(t===void 0&&(t=xo),!e)return;const{top:n,left:a,bottom:o,right:c}=t(e);IS(e)&&(o<=0||c<=0||n>=window.innerHeight||a>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Vx=[["x",["left","right"],Wx],["y",["top","bottom"],$x]];class lm{constructor(t,n){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;const a=am(n),o=YS(a);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,d,p]of Vx)for(const m of d)Object.defineProperty(this,m,{get:()=>{const f=p(a),b=o[c]-f;return this.rect[m]+b},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class eo{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var a;return(a=this.target)==null?void 0:a.removeEventListener(...n)})},this.target=t}add(t,n,a){var o;(o=this.target)==null||o.addEventListener(t,n,a),this.listeners.push([t,n,a])}}function Xx(e){const{EventTarget:t}=Zi(e);return e instanceof t?e:Pa(e)}function rf(e,t){const n=Math.abs(e.x),a=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+a**2)>t:"x"in t&&"y"in t?n>t.x&&a>t.y:"x"in t?n>t.x:"y"in t?a>t.y:!1}var ws;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ws||(ws={}));function jy(e){e.preventDefault()}function Gx(e){e.stopPropagation()}var pt;(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"})(pt||(pt={}));const VS={start:[pt.Space,pt.Enter],cancel:[pt.Esc],end:[pt.Space,pt.Enter,pt.Tab]},Zx=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case pt.Right:return{...n,x:n.x+25};case pt.Left:return{...n,x:n.x-25};case pt.Down:return{...n,y:n.y+25};case pt.Up:return{...n,y:n.y-25}}};class XS{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new eo(Pa(n)),this.windowListeners=new eo(Zi(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ws.Resize,this.handleCancel),this.windowListeners.add(ws.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ws.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,a=t.node.current;a&&Yx(a),n(Os)}handleKeyDown(t){if(US(t)){const{active:n,context:a,options:o}=this.props,{keyboardCodes:c=VS,coordinateGetter:d=Zx,scrollBehavior:p="smooth"}=o,{code:m}=t;if(c.end.includes(m)){this.handleEnd(t);return}if(c.cancel.includes(m)){this.handleCancel(t);return}const{collisionRect:f}=a.current,b=f?{x:f.left,y:f.top}:Os;this.referenceCoordinates||(this.referenceCoordinates=b);const y=d(t,{active:n,context:a.current,currentCoordinates:b});if(y){const S=fu(y,b),E={x:0,y:0},{scrollableAncestors:x}=a.current;for(const T of x){const B=t.code,{isTop:M,isRight:V,isLeft:I,isBottom:X,maxScroll:le,minScroll:ee}=$S(T),te=qx(T),ce={x:Math.min(B===pt.Right?te.right-te.width/2:te.right,Math.max(B===pt.Right?te.left:te.left+te.width/2,y.x)),y:Math.min(B===pt.Down?te.bottom-te.height/2:te.bottom,Math.max(B===pt.Down?te.top:te.top+te.height/2,y.y))},pe=B===pt.Right&&!V||B===pt.Left&&!I,A=B===pt.Down&&!X||B===pt.Up&&!M;if(pe&&ce.x!==y.x){const P=T.scrollLeft+S.x,K=B===pt.Right&&P<=le.x||B===pt.Left&&P>=ee.x;if(K&&!S.y){T.scrollTo({left:P,behavior:p});return}K?E.x=T.scrollLeft-P:E.x=B===pt.Right?T.scrollLeft-le.x:T.scrollLeft-ee.x,E.x&&T.scrollBy({left:-E.x,behavior:p});break}else if(A&&ce.y!==y.y){const P=T.scrollTop+S.y,K=B===pt.Down&&P<=le.y||B===pt.Up&&P>=ee.y;if(K&&!S.x){T.scrollTo({top:P,behavior:p});return}K?E.y=T.scrollTop-P:E.y=B===pt.Down?T.scrollTop-le.y:T.scrollTop-ee.y,E.y&&T.scrollBy({top:-E.y,behavior:p});break}}this.handleMove(t,Ba(fu(y,this.referenceCoordinates),E))}}}handleMove(t,n){const{onMove:a}=this.props;t.preventDefault(),a(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}XS.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:a=VS,onActivation:o}=t,{active:c}=n;const{code:d}=e.nativeEvent;if(a.start.includes(d)){const p=c.activatorNode.current;return p&&e.target!==p?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Hy(e){return!!(e&&"distance"in e)}function Uy(e){return!!(e&&"delay"in e)}class om{constructor(t,n,a){var o;a===void 0&&(a=Xx(t.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=t,this.events=n;const{event:c}=t,{target:d}=c;this.props=t,this.events=n,this.document=Pa(d),this.documentListeners=new eo(this.document),this.listeners=new eo(a),this.windowListeners=new eo(Zi(d)),this.initialCoordinates=(o=Nf(c))!=null?o:Os,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(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:a}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(ws.Resize,this.handleCancel),this.windowListeners.add(ws.DragStart,jy),this.windowListeners.add(ws.VisibilityChange,this.handleCancel),this.windowListeners.add(ws.ContextMenu,jy),this.documentListeners.add(ws.Keydown,this.handleKeydown),n){if(a!=null&&a({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Uy(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Hy(n)){this.handlePending(n);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(t,n){const{active:a,onPending:o}=this.props;o(a,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(ws.Click,Gx,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ws.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:a,initialCoordinates:o,props:c}=this,{onMove:d,options:{activationConstraint:p}}=c;if(!o)return;const m=(n=Nf(t))!=null?n:Os,f=fu(o,m);if(!a&&p){if(Hy(p)){if(p.tolerance!=null&&rf(f,p.tolerance))return this.handleCancel();if(rf(f,p.distance))return this.handleStart()}if(Uy(p)&&rf(f,p.tolerance))return this.handleCancel();this.handlePending(p,f);return}t.cancelable&&t.preventDefault(),d(m)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===pt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Qx={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class GS extends om{constructor(t){const{event:n}=t,a=Pa(n.target);super(t,Qx,a)}}GS.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:a}=t;return!n.isPrimary||n.button!==0?!1:(a?.({event:n}),!0)}}];const Jx={move:{name:"mousemove"},end:{name:"mouseup"}};var Bf;(function(e){e[e.RightClick=2]="RightClick"})(Bf||(Bf={}));class ZS extends om{constructor(t){super(t,Jx,Pa(t.event.target))}}ZS.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:a}=t;return n.button===Bf.RightClick?!1:(a?.({event:n}),!0)}}];const af={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class QS extends om{constructor(t){super(t,af)}static setup(){return window.addEventListener(af.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(af.move.name,t)};function t(){}}}QS.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:a}=t;const{touches:o}=n;return o.length>1?!1:(a?.({event:n}),!0)}}];var to;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(to||(to={}));var mu;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(mu||(mu={}));function eE(e){let{acceleration:t,activator:n=to.Pointer,canScroll:a,draggingRect:o,enabled:c,interval:d=5,order:p=mu.TreeOrder,pointerCoordinates:m,scrollableAncestors:f,scrollableAncestorRects:b,delta:y,threshold:S}=e;const E=iE({delta:y,disabled:!c}),[x,T]=mx(),B=g.useRef({x:0,y:0}),M=g.useRef({x:0,y:0}),V=g.useMemo(()=>{switch(n){case to.Pointer:return m?{top:m.y,bottom:m.y,left:m.x,right:m.x}:null;case to.DraggableRect:return o}},[n,o,m]),I=g.useRef(null),X=g.useCallback(()=>{const ee=I.current;if(!ee)return;const te=B.current.x*M.current.x,ce=B.current.y*M.current.y;ee.scrollBy(te,ce)},[]),le=g.useMemo(()=>p===mu.TreeOrder?[...f].reverse():f,[p,f]);g.useEffect(()=>{if(!c||!f.length||!V){T();return}for(const ee of le){if(a?.(ee)===!1)continue;const te=f.indexOf(ee),ce=b[te];if(!ce)continue;const{direction:pe,speed:A}=Fx(ee,ce,V,t,S);for(const P of["x","y"])E[P][pe[P]]||(A[P]=0,pe[P]=0);if(A.x>0||A.y>0){T(),I.current=ee,x(X,d),B.current=A,M.current=pe;return}}B.current={x:0,y:0},M.current={x:0,y:0},T()},[t,X,a,T,c,d,JSON.stringify(V),JSON.stringify(E),x,f,le,b,JSON.stringify(S)])}const tE={x:{[oi.Backward]:!1,[oi.Forward]:!1},y:{[oi.Backward]:!1,[oi.Forward]:!1}};function iE(e){let{delta:t,disabled:n}=e;const a=Mf(t);return Co(o=>{if(n||!a||!o)return tE;const c={x:Math.sign(t.x-a.x),y:Math.sign(t.y-a.y)};return{x:{[oi.Backward]:o.x[oi.Backward]||c.x===-1,[oi.Forward]:o.x[oi.Forward]||c.x===1},y:{[oi.Backward]:o.y[oi.Backward]||c.y===-1,[oi.Forward]:o.y[oi.Forward]||c.y===1}}},[n,t,a])}function sE(e,t){const n=t!=null?e.get(t):void 0,a=n?n.node.current:null;return Co(o=>{var c;return t==null?null:(c=a??o)!=null?c:null},[a,t])}function nE(e,t){return g.useMemo(()=>e.reduce((n,a)=>{const{sensor:o}=a,c=o.activators.map(d=>({eventName:d.eventName,handler:t(d.handler,a)}));return[...n,...c]},[]),[e,t])}var oo;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(oo||(oo={}));var Of;(function(e){e.Optimized="optimized"})(Of||(Of={}));const Py=new Map;function rE(e,t){let{dragging:n,dependencies:a,config:o}=t;const[c,d]=g.useState(null),{frequency:p,measure:m,strategy:f}=o,b=g.useRef(e),y=B(),S=lo(y),E=g.useCallback(function(M){M===void 0&&(M=[]),!S.current&&d(V=>V===null?M:V.concat(M.filter(I=>!V.includes(I))))},[S]),x=g.useRef(null),T=Co(M=>{if(y&&!n)return Py;if(!M||M===Py||b.current!==e||c!=null){const V=new Map;for(let I of e){if(!I)continue;if(c&&c.length>0&&!c.includes(I.id)&&I.rect.current){V.set(I.id,I.rect.current);continue}const X=I.node.current,le=X?new lm(m(X),X):null;I.rect.current=le,le&&V.set(I.id,le)}return V}return M},[e,c,n,y,m]);return g.useEffect(()=>{b.current=e},[e]),g.useEffect(()=>{y||E()},[n,y]),g.useEffect(()=>{c&&c.length>0&&d(null)},[JSON.stringify(c)]),g.useEffect(()=>{y||typeof p!="number"||x.current!==null||(x.current=setTimeout(()=>{E(),x.current=null},p))},[p,y,E,...a]),{droppableRects:T,measureDroppableContainers:E,measuringScheduled:c!=null};function B(){switch(f){case oo.Always:return!1;case oo.BeforeDragging:return n;default:return!n}}}function JS(e,t){return Co(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function aE(e,t){return JS(e,t)}function lE(e){let{callback:t,disabled:n}=e;const a=rm(t),o=g.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(a)},[a,n]);return g.useEffect(()=>()=>o?.disconnect(),[o]),o}function Bu(e){let{callback:t,disabled:n}=e;const a=rm(t),o=g.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(a)},[n]);return g.useEffect(()=>()=>o?.disconnect(),[o]),o}function oE(e){return new lm(xo(e),e)}function Ky(e,t,n){t===void 0&&(t=oE);const[a,o]=g.useState(null);function c(){o(m=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=m??n)!=null?f:null}const b=t(e);return JSON.stringify(m)===JSON.stringify(b)?m:b})}const d=lE({callback(m){if(e)for(const f of m){const{type:b,target:y}=f;if(b==="childList"&&y instanceof HTMLElement&&y.contains(e)){c();break}}}}),p=Bu({callback:c});return ar(()=>{c(),e?(p?.observe(e),d?.observe(document.body,{childList:!0,subtree:!0})):(p?.disconnect(),d?.disconnect())},[e]),a}function cE(e){const t=JS(e);return KS(e,t)}const Iy=[];function uE(e){const t=g.useRef(e),n=Co(a=>e?a&&a!==Iy&&e&&t.current&&e.parentNode===t.current.parentNode?a:am(e):Iy,[e]);return g.useEffect(()=>{t.current=e},[e]),n}function hE(e){const[t,n]=g.useState(null),a=g.useRef(e),o=g.useCallback(c=>{const d=nf(c.target);d&&n(p=>p?(p.set(d,Lf(d)),new Map(p)):null)},[]);return g.useEffect(()=>{const c=a.current;if(e!==c){d(c);const p=e.map(m=>{const f=nf(m);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,Lf(f)]):null}).filter(m=>m!=null);n(p.length?new Map(p):null),a.current=e}return()=>{d(e),d(c)};function d(p){p.forEach(m=>{const f=nf(m);f?.removeEventListener("scroll",o)})}},[o,e]),g.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,d)=>Ba(c,d),Os):YS(e):Os,[e,t])}function Fy(e,t){t===void 0&&(t=[]);const n=g.useRef(null);return g.useEffect(()=>{n.current=null},t),g.useEffect(()=>{const a=e!==Os;a&&!n.current&&(n.current=e),!a&&n.current&&(n.current=null)},[e]),n.current?fu(e,n.current):Os}function dE(e){g.useEffect(()=>{if(!Au)return;const t=e.map(n=>{let{sensor:a}=n;return a.setup==null?void 0:a.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function fE(e,t){return g.useMemo(()=>e.reduce((n,a)=>{let{eventName:o,handler:c}=a;return n[o]=d=>{c(d,t)},n},{}),[e,t])}function e0(e){return g.useMemo(()=>e?Ux(e):null,[e])}const qy=[];function pE(e,t){t===void 0&&(t=xo);const[n]=e,a=e0(n?Zi(n):null),[o,c]=g.useState(qy);function d(){c(()=>e.length?e.map(m=>WS(m)?a:new lm(t(m),m)):qy)}const p=Bu({callback:d});return ar(()=>{p?.disconnect(),d(),e.forEach(m=>p?.observe(m))},[e]),o}function mE(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return wo(t)?t:e}function _E(e){let{measure:t}=e;const[n,a]=g.useState(null),o=g.useCallback(f=>{for(const{target:b}of f)if(wo(b)){a(y=>{const S=t(b);return y?{...y,width:S.width,height:S.height}:S});break}},[t]),c=Bu({callback:o}),d=g.useCallback(f=>{const b=mE(f);c?.disconnect(),b&&c?.observe(b),a(b?t(b):null)},[t,c]),[p,m]=du(d);return g.useMemo(()=>({nodeRef:p,rect:n,setRef:m}),[n,p,m])}const vE=[{sensor:GS,options:{}},{sensor:XS,options:{}}],gE={current:{}},eu={draggable:{measure:zy},droppable:{measure:zy,strategy:oo.WhileDragging,frequency:Of.Optimized},dragOverlay:{measure:xo}};class io extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,a;return(n=(a=this.get(t))==null?void 0:a.node.current)!=null?n:void 0}}const yE={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new io,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:pu},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:eu,measureDroppableContainers:pu,windowRect:null,measuringScheduled:!1},bE={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:pu,draggableNodes:new Map,over:null,measureDroppableContainers:pu},Ou=g.createContext(bE),SE=g.createContext(yE);function wE(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new io}}}function CE(e,t){switch(t.type){case ti.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case ti.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 ti.DragEnd:case ti.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ti.RegisterDroppable:{const{element:n}=t,{id:a}=n,o=new io(e.droppable.containers);return o.set(a,n),{...e,droppable:{...e.droppable,containers:o}}}case ti.SetDroppableDisabled:{const{id:n,key:a,disabled:o}=t,c=e.droppable.containers.get(n);if(!c||a!==c.key)return e;const d=new io(e.droppable.containers);return d.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:d}}}case ti.UnregisterDroppable:{const{id:n,key:a}=t,o=e.droppable.containers.get(n);if(!o||a!==o.key)return e;const c=new io(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function xE(e){let{disabled:t}=e;const{active:n,activatorEvent:a,draggableNodes:o}=g.useContext(Ou),c=Mf(a),d=Mf(n?.id);return g.useEffect(()=>{if(!t&&!a&&c&&d!=null){if(!US(c)||document.activeElement===c.target)return;const p=o.get(d);if(!p)return;const{activatorNode:m,node:f}=p;if(!m.current&&!f.current)return;requestAnimationFrame(()=>{for(const b of[m.current,f.current]){if(!b)continue;const y=gx(b);if(y){y.focus();break}}})}},[a,t,o,d,c]),null}function EE(e,t){let{transform:n,...a}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...a}),n):n}function TE(e){return g.useMemo(()=>({draggable:{...eu.draggable,...e?.draggable},droppable:{...eu.droppable,...e?.droppable},dragOverlay:{...eu.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function kE(e){let{activeNode:t,measure:n,initialRect:a,config:o=!0}=e;const c=g.useRef(!1),{x:d,y:p}=typeof o=="boolean"?{x:o,y:o}:o;ar(()=>{if(!d&&!p||!t){c.current=!1;return}if(c.current||!a)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const b=n(f),y=KS(b,a);if(d||(y.x=0),p||(y.y=0),c.current=!0,Math.abs(y.x)>0||Math.abs(y.y)>0){const S=IS(f);S&&S.scrollBy({top:y.y,left:y.x})}},[t,d,p,a,n])}const t0=g.createContext({...Os,scaleX:1,scaleY:1});var er;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(er||(er={}));const DE=g.memo(function(t){var n,a,o,c;let{id:d,accessibility:p,autoScroll:m=!0,children:f,sensors:b=vE,collisionDetection:y=Ax,measuring:S,modifiers:E,...x}=t;const T=g.useReducer(CE,void 0,wE),[B,M]=T,[V,I]=xx(),[X,le]=g.useState(er.Uninitialized),ee=X===er.Initialized,{draggable:{active:te,nodes:ce,translate:pe},droppable:{containers:A}}=B,P=te!=null?ce.get(te):null,K=g.useRef({initial:null,translated:null}),j=g.useMemo(()=>{var dt;return te!=null?{id:te,data:(dt=P?.data)!=null?dt:gE,rect:K}:null},[te,P]),O=g.useRef(null),[Q,D]=g.useState(null),[q,Z]=g.useState(null),ve=lo(x,Object.values(x)),be=Lu("DndDescribedBy",d),R=g.useMemo(()=>A.getEnabled(),[A]),Y=TE(S),{droppableRects:se,measureDroppableContainers:fe,measuringScheduled:he}=rE(R,{dragging:ee,dependencies:[pe.x,pe.y],config:Y.droppable}),de=sE(ce,te),Se=g.useMemo(()=>q?Nf(q):null,[q]),Be=Bi(),Ae=aE(de,Y.draggable.measure);kE({activeNode:te!=null?ce.get(te):null,config:Be.layoutShiftCompensation,initialRect:Ae,measure:Y.draggable.measure});const Re=Ky(de,Y.draggable.measure,Ae),ze=Ky(de?de.parentElement:null),He=g.useRef({activatorEvent:null,active:null,activeNode:de,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:ce,draggingNode:null,draggingNodeRect:null,droppableContainers:A,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Te=A.getNodeFor((n=He.current.over)==null?void 0:n.id),ne=_E({measure:Y.dragOverlay.measure}),De=(a=ne.nodeRef.current)!=null?a:de,xe=ee?(o=ne.rect)!=null?o:Re:null,je=!!(ne.nodeRef.current&&ne.rect),Pe=cE(je?null:Re),_t=e0(De?Zi(De):null),rt=uE(ee?Te??de:null),Ci=pE(rt),J=EE(E,{transform:{x:pe.x-Pe.x,y:pe.y-Pe.y,scaleX:1,scaleY:1},activatorEvent:q,active:j,activeNodeRect:Re,containerNodeRect:ze,draggingNodeRect:xe,over:He.current.over,overlayNodeRect:ne.rect,scrollableAncestors:rt,scrollableAncestorRects:Ci,windowRect:_t}),Ke=Se?Ba(Se,pe):null,Ne=hE(rt),bt=Fy(Ne),xi=Fy(Ne,[Re]),Ei=Ba(J,bt),ni=xe?Ox(xe,J):null,us=j&&ni?y({active:j,collisionRect:ni,droppableRects:se,droppableContainers:R,pointerCoordinates:Ke}):null,Li=Mx(us,"id"),[Pi,zs]=g.useState(null),fi=je?J:Ba(J,xi),Ct=Lx(fi,(c=Pi?.rect)!=null?c:null,Re),pi=g.useRef(null),xt=g.useCallback((dt,mt)=>{let{sensor:Et,options:jt}=mt;if(O.current==null)return;const Gt=ce.get(O.current);if(!Gt)return;const Ht=dt.nativeEvent,ri=new Et({active:O.current,activeNode:Gt,event:Ht,options:jt,context:He,onAbort(Tt){if(!ce.get(Tt))return;const{onDragAbort:Rt}=ve.current,it={id:Tt};Rt?.(it),V({type:"onDragAbort",event:it})},onPending(Tt,ki,Rt,it){if(!ce.get(Tt))return;const{onDragPending:Di}=ve.current,Ft={id:Tt,constraint:ki,initialCoordinates:Rt,offset:it};Di?.(Ft),V({type:"onDragPending",event:Ft})},onStart(Tt){const ki=O.current;if(ki==null)return;const Rt=ce.get(ki);if(!Rt)return;const{onDragStart:it}=ve.current,st={activatorEvent:Ht,active:{id:ki,data:Rt.data,rect:K}};$l.unstable_batchedUpdates(()=>{it?.(st),le(er.Initializing),M({type:ti.DragStart,initialCoordinates:Tt,active:ki}),V({type:"onDragStart",event:st}),D(pi.current),Z(Ht)})},onMove(Tt){M({type:ti.DragMove,coordinates:Tt})},onEnd:Ti(ti.DragEnd),onCancel:Ti(ti.DragCancel)});pi.current=ri;function Ti(Tt){return async function(){const{active:Rt,collisions:it,over:st,scrollAdjustedTranslate:Di}=He.current;let Ft=null;if(Rt&&Di){const{cancelDrop:Mt}=ve.current;Ft={activatorEvent:Ht,active:Rt,collisions:it,delta:Di,over:st},Tt===ti.DragEnd&&typeof Mt=="function"&&await Promise.resolve(Mt(Ft))&&(Tt=ti.DragCancel)}O.current=null,$l.unstable_batchedUpdates(()=>{M({type:Tt}),le(er.Uninitialized),zs(null),D(null),Z(null),pi.current=null;const Mt=Tt===ti.DragEnd?"onDragEnd":"onDragCancel";if(Ft){const mi=ve.current[Mt];mi?.(Ft),V({type:Mt,event:Ft})}})}}},[ce]),Xs=g.useCallback((dt,mt)=>(Et,jt)=>{const Gt=Et.nativeEvent,Ht=ce.get(jt);if(O.current!==null||!Ht||Gt.dndKit||Gt.defaultPrevented)return;const ri={active:Ht};dt(Et,mt.options,ri)===!0&&(Gt.dndKit={capturedBy:mt.sensor},O.current=jt,xt(Et,mt))},[ce,xt]),hs=nE(b,Xs);dE(b),ar(()=>{Re&&X===er.Initializing&&le(er.Initialized)},[Re,X]),g.useEffect(()=>{const{onDragMove:dt}=ve.current,{active:mt,activatorEvent:Et,collisions:jt,over:Gt}=He.current;if(!mt||!Et)return;const Ht={active:mt,activatorEvent:Et,collisions:jt,delta:{x:Ei.x,y:Ei.y},over:Gt};$l.unstable_batchedUpdates(()=>{dt?.(Ht),V({type:"onDragMove",event:Ht})})},[Ei.x,Ei.y]),g.useEffect(()=>{const{active:dt,activatorEvent:mt,collisions:Et,droppableContainers:jt,scrollAdjustedTranslate:Gt}=He.current;if(!dt||O.current==null||!mt||!Gt)return;const{onDragOver:Ht}=ve.current,ri=jt.get(Li),Ti=ri&&ri.rect.current?{id:ri.id,rect:ri.rect.current,data:ri.data,disabled:ri.disabled}:null,Tt={active:dt,activatorEvent:mt,collisions:Et,delta:{x:Gt.x,y:Gt.y},over:Ti};$l.unstable_batchedUpdates(()=>{zs(Ti),Ht?.(Tt),V({type:"onDragOver",event:Tt})})},[Li]),ar(()=>{He.current={activatorEvent:q,active:j,activeNode:de,collisionRect:ni,collisions:us,droppableRects:se,draggableNodes:ce,draggingNode:De,draggingNodeRect:xe,droppableContainers:A,over:Pi,scrollableAncestors:rt,scrollAdjustedTranslate:Ei},K.current={initial:xe,translated:ni}},[j,de,us,ni,ce,De,xe,se,A,Pi,rt,Ei]),eE({...Be,delta:pe,draggingRect:ni,pointerCoordinates:Ke,scrollableAncestors:rt,scrollableAncestorRects:Ci});const hr=g.useMemo(()=>({active:j,activeNode:de,activeNodeRect:Re,activatorEvent:q,collisions:us,containerNodeRect:ze,dragOverlay:ne,draggableNodes:ce,droppableContainers:A,droppableRects:se,over:Pi,measureDroppableContainers:fe,scrollableAncestors:rt,scrollableAncestorRects:Ci,measuringConfiguration:Y,measuringScheduled:he,windowRect:_t}),[j,de,Re,q,us,ze,ne,ce,A,se,Pi,fe,rt,Ci,Y,he,_t]),ks=g.useMemo(()=>({activatorEvent:q,activators:hs,active:j,activeNodeRect:Re,ariaDescribedById:{draggable:be},dispatch:M,draggableNodes:ce,over:Pi,measureDroppableContainers:fe}),[q,hs,j,Re,M,be,ce,Pi,fe]);return ii.createElement(PS.Provider,{value:I},ii.createElement(Ou.Provider,{value:ks},ii.createElement(SE.Provider,{value:hr},ii.createElement(t0.Provider,{value:Ct},f)),ii.createElement(xE,{disabled:p?.restoreFocus===!1})),ii.createElement(kx,{...p,hiddenTextDescribedById:be}));function Bi(){const dt=Q?.autoScrollEnabled===!1,mt=typeof m=="object"?m.enabled===!1:m===!1,Et=ee&&!dt&&!mt;return typeof m=="object"?{...m,enabled:Et}:{enabled:Et}}}),RE=g.createContext(null),Wy="button",ME="Draggable";function i0(e){let{id:t,data:n,disabled:a=!1,attributes:o}=e;const c=Lu(ME),{activators:d,activatorEvent:p,active:m,activeNodeRect:f,ariaDescribedById:b,draggableNodes:y,over:S}=g.useContext(Ou),{role:E=Wy,roleDescription:x="draggable",tabIndex:T=0}=o??{},B=m?.id===t,M=g.useContext(B?t0:RE),[V,I]=du(),[X,le]=du(),ee=fE(d,t),te=lo(n);ar(()=>(y.set(t,{id:t,key:c,node:V,activatorNode:X,data:te}),()=>{const pe=y.get(t);pe&&pe.key===c&&y.delete(t)}),[y,t]);const ce=g.useMemo(()=>({role:E,tabIndex:T,"aria-disabled":a,"aria-pressed":B&&E===Wy?!0:void 0,"aria-roledescription":x,"aria-describedby":b.draggable}),[a,E,T,B,x,b.draggable]);return{active:m,activatorEvent:p,activeNodeRect:f,attributes:ce,isDragging:B,listeners:a?void 0:ee,node:V,over:S,setNodeRef:I,setActivatorNodeRef:le,transform:M}}const NE="Droppable",AE={timeout:25};function s0(e){let{data:t,disabled:n=!1,id:a,resizeObserverConfig:o}=e;const c=Lu(NE),{active:d,dispatch:p,over:m,measureDroppableContainers:f}=g.useContext(Ou),b=g.useRef({disabled:n}),y=g.useRef(!1),S=g.useRef(null),E=g.useRef(null),{disabled:x,updateMeasurementsFor:T,timeout:B}={...AE,...o},M=lo(T??a),V=g.useCallback(()=>{if(!y.current){y.current=!0;return}E.current!=null&&clearTimeout(E.current),E.current=setTimeout(()=>{f(Array.isArray(M.current)?M.current:[M.current]),E.current=null},B)},[B]),I=Bu({callback:V,disabled:x||!d}),X=g.useCallback((ce,pe)=>{I&&(pe&&(I.unobserve(pe),y.current=!1),ce&&I.observe(ce))},[I]),[le,ee]=du(X),te=lo(t);return g.useEffect(()=>{!I||!le.current||(I.disconnect(),y.current=!1,I.observe(le.current))},[le,I]),g.useEffect(()=>(p({type:ti.RegisterDroppable,element:{id:a,key:c,disabled:n,node:le,rect:S,data:te}}),()=>p({type:ti.UnregisterDroppable,key:c,id:a})),[a]),g.useEffect(()=>{n!==b.current.disabled&&(p({type:ti.SetDroppableDisabled,id:a,key:c,disabled:n}),b.current.disabled=n)},[a,c,n,p]),{active:d,rect:S,isOver:m?.id===a,node:le,over:m,setNodeRef:ee}}const LE=128,BE=512,OE=64,zE=4096;function n0(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.activeWorkspaceId!="string"&&t.activeWorkspaceId!==null||!Array.isArray(t.workspaces)||t.workspaces.length>LE)return null;const n=t.workspaces.map(jE);return n.some(a=>a===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:n}}function jE(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTabId!="string"&&t.activeTabId!==null||!Array.isArray(t.tabs)||t.tabs.length>BE)return null;const n=t.tabs.map(HE);return n.some(a=>a===null)?null:{id:t.id,title:t.title,activeTabId:t.activeTabId,tabs:n}}function HE(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTerminalId!="string")return null;const n=UE(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function UE(e){if(!e||typeof e!="object")return null;let t=0;return zf(e,1,()=>(t+=1,t<=zE))}function zf(e,t,n){if(!e||typeof e!="object"||t>OE||!n())return null;const a=e;if(a.type==="pane")return typeof a.terminalId=="string"?{type:"pane",terminalId:a.terminalId}:null;if(a.type!=="split"||a.direction!=="horizontal"&&a.direction!=="vertical")return null;const o=zf(a.first,t+1,n),c=zf(a.second,t+1,n);return!o||!c?null:{type:"split",direction:a.direction,ratio:PE(a.ratio),first:o,second:c}}function PE(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const r0=[{id:"builtin-character-2260",filename:"character-2260.mp4",contentType:"video/mp4",size:123288,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2260.mp4"},{id:"builtin-character-2272",filename:"character-2272.mp4",contentType:"video/mp4",size:55873,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2272.mp4"},{id:"builtin-character-2258",filename:"character-2258.mp4",contentType:"video/mp4",size:112612,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2258.mp4"}];function $y(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function Yy(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Vy="Local",KE=3e4,a0="nterminal.serverList.viewMode.v1";function IE(){try{return window.localStorage.getItem(a0)==="list"?"list":"stats"}catch{return"stats"}}function FE(e){try{window.localStorage.setItem(a0,e)}catch{}}function tu(e){return e===void 0?"":e==="error"?"offline":[`CPU ${xs(e.cpuPercent)} ${cm(e)}`,`MEM ${xs(e.memoryPercent)} ${Sn(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${xs(e.diskPercent)} ${Sn(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${xs(e.swapPercent)} ${Sn(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function qE(e){if(!(e===void 0||e==="error"))return[`CPU ${xs(e.cpuPercent)} (${cm(e)})`,`RAM ${xs(e.memoryPercent)} (${Sn(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${xs(e.diskPercent)} (${Sn(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${xs(e.swapPercent)} (${Sn(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function Xy(e,t){const n=tu(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function xs(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function cm(e){const t=Number.isFinite(e.cores)&&e.cores>0?e.cores:null;return e.cpuPercent===null||e.cpuPercent===void 0||!Number.isFinite(e.cpuPercent)||t===null?`–/${t??"–"} cores`:`${jf(e.cpuPercent/100*t)}/${t} cores`}function Sn(e,t){return!Gy(e)||!Gy(t)?"–/–":WE(e,t)}function WE(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",a=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${jf(e/a)}/${jf(t/a)} ${n}`}function jf(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function Gy(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Kc(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function $E(e){return[{label:"CPU",percent:xs(e.cpuPercent),detail:cm(e),tone:Kc(e.cpuPercent)},{label:"MEM",percent:xs(e.memoryPercent),detail:Sn(e.memoryUsedBytes,e.memoryTotalBytes),tone:Kc(e.memoryPercent)},{label:"DISK",percent:xs(e.diskPercent),detail:Sn(e.diskUsedBytes,e.diskTotalBytes),tone:Kc(e.diskPercent)},{label:"SWAP",percent:xs(e.swapPercent),detail:Sn(e.swapUsedBytes,e.swapTotalBytes),tone:Kc(e.swapPercent)}]}function Zy({entry:e}){return e==="error"?_.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?_.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>_.jsxs("span",{className:"server-list-stat-cell",children:[_.jsx("span",{className:"server-list-stat-label",children:t}),_.jsx("span",{className:"server-list-stat-value",children:"–"}),_.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):_.jsx("span",{className:"server-list-stats server-list-stats-grid",title:qE(e),children:$E(e).map(t=>_.jsxs("span",{className:"server-list-stat-cell",children:[_.jsx("span",{className:"server-list-stat-label",children:t.label}),_.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent}),_.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function lf({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:a,refreshToken:o=0,compact:c=!1}){const[d,p]=g.useState([]),[m,f]=g.useState(null),[b,y]=g.useState(null),[S,E]=g.useState(""),x=g.useRef(null),[T,B]=g.useState(()=>IE()),[M,V]=g.useState({});g.useEffect(()=>{let A=!1;return e.listAgents().then(P=>{A||p(P.agents)}).catch(()=>{}),e.getMainInfo().then(P=>{A||f(P.name)}).catch(()=>{}),()=>{A=!0}},[e,o]),g.useEffect(()=>{b&&(x.current?.focus(),x.current?.select())},[b]),g.useEffect(()=>{let A=!1;function P(){const j=[{key:"__main__",load:()=>e.getMainStats()},...d.map(Q=>({key:Q.id,load:()=>e.getAgentStats(Q.id)}))],O=new Set(j.map(Q=>Q.key));V(Q=>{const D={};for(const q of O)q in Q&&(D[q]=Q[q]);return D});for(const Q of j)Q.load().then(D=>{A||V(q=>O.has(Q.key)?{...q,[Q.key]:D}:q)}).catch(D=>{if(!A){if(D instanceof bn&&D.status===401){a?.();return}V(q=>O.has(Q.key)?{...q,[Q.key]:"error"}:q)}})}P();const K=window.setInterval(P,KE);return()=>{A=!0,window.clearInterval(K)}},[e,d,a]);function I(A){A==="main"?(E(m??""),y({kind:"main"})):(E(A.name),y({kind:"agent",id:A.id}))}async function X(){if(!b)return;const A=S.trim(),P=b;if(y(null),P.kind==="main"){const K=A||"";try{const j=await e.renameMain(K);f(j.name)}catch{}}else{if(!A)return;const K=d.find(j=>j.id===P.id)?.name;p(j=>j.map(O=>O.id===P.id?{...O,name:A}:O));try{await e.renameAgent(P.id,A)}catch{K!==void 0&&p(j=>j.map(O=>O.id===P.id?{...O,name:K}:O))}}}function le(){y(null)}function ee(A){B(A),FE(A)}const te=m?.trim()||Vy,ce=b?.kind==="main",pe=T==="stats";return c?_.jsxs("div",{className:"server-list server-list--compact",children:[_.jsxs("button",{type:"button",className:`server-list-chip${t===null?" server-list-chip--active":""}`,onClick:()=>n(null),"aria-label":te,title:`${te}${tu(M.__main__)?` — ${tu(M.__main__)}`:""}`,children:[_.jsx("span",{className:"server-list-chip-initial",children:Yy(te)}),_.jsx("span",{className:"server-list-chip-pip","data-status":$y(M.__main__)})]}),d.map(A=>{const P=M[A.id],K=tu(P);return _.jsxs("button",{type:"button",className:`server-list-chip${t===A.id?" server-list-chip--active":""}`,onClick:()=>n(A.id),"aria-label":A.name,title:`${A.name}${K?` — ${K}`:""}`,children:[_.jsx("span",{className:"server-list-chip-initial",children:Yy(A.name)}),_.jsx("span",{className:"server-list-chip-pip","data-status":$y(P)})]},A.id)})]}):_.jsxs("div",{className:`server-list server-list--${T}`,children:[_.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[_.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":T==="list",onClick:()=>ee("list"),title:"Show server names only",children:"List"}),_.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":T==="stats",onClick:()=>ee("stats"),title:"Show resource usage",children:"Stats"})]}),_.jsx("div",{className:"server-list-row",children:ce?_.jsx("form",{className:"server-list-editor",onSubmit:A=>{A.preventDefault(),X()},children:_.jsx("input",{ref:x,"aria-label":"Rename main server",value:S,onChange:A=>E(A.target.value),onBlur:()=>{X()},onKeyDown:A=>{A.key==="Escape"&&(A.preventDefault(),le())},placeholder:Vy})}):_.jsxs("button",{type:"button",className:`server-list-item${t===null?" server-list-item--active":""}`,onClick:()=>n(null),onDoubleClick:A=>{A.preventDefault(),I("main")},title:Xy(te,M.__main__),children:[_.jsxs("span",{className:"server-list-item-header",children:[_.jsx("span",{className:"server-list-dot"}),_.jsx("span",{className:"server-list-name",children:te})]}),pe?_.jsx(Zy,{entry:M.__main__}):null]})}),d.map(A=>{const P=b?.kind==="agent"&&b.id===A.id;return _.jsx("div",{className:"server-list-row",children:P?_.jsx("form",{className:"server-list-editor",onSubmit:K=>{K.preventDefault(),X()},children:_.jsx("input",{ref:x,"aria-label":`Rename ${A.name}`,value:S,onChange:K=>E(K.target.value),onBlur:()=>{X()},onKeyDown:K=>{K.key==="Escape"&&(K.preventDefault(),le())}})}):_.jsxs("button",{type:"button",className:`server-list-item${t===A.id?" server-list-item--active":""}`,onClick:()=>n(A.id),onDoubleClick:K=>{K.preventDefault(),I({id:A.id,name:A.name})},title:Xy(A.name,M[A.id]),children:[_.jsxs("span",{className:"server-list-item-header",children:[_.jsx("span",{className:"server-list-dot"}),_.jsx("span",{className:"server-list-name",title:A.url,children:A.name})]}),pe?_.jsx(Zy,{entry:M[A.id]}):null]})},A.id)})]})}function YE({api:e}){const[t,n]=g.useState([]),[a,o]=g.useState([]),[c,d]=g.useState(!1),[p,m]=g.useState(null),[f,b]=g.useState(""),[y,S]=g.useState("");async function E(){try{const[M,V,I]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(M.devices),o(V.networks),d(I.totpEnabled),m(null)}catch(M){m(M instanceof Error?M.message:"Failed to load")}}g.useEffect(()=>{E()},[]);async function x(M){await e.revokeDevice(M),await E()}async function T(M){await e.removeNetwork(M),await E()}async function B(M){M.preventDefault(),m(null);try{await e.addNetwork({value:f.trim(),label:y.trim()}),b(""),S(""),await E()}catch(V){m(V instanceof Error?V.message:"Failed to add network")}}return _.jsxs(_.Fragment,{children:[p?_.jsx("p",{className:"form-error",children:p}):null,_.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Trusted devices"}),_.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?_.jsx("p",{className:"muted",children:"No trusted devices."}):_.jsx("ul",{className:"security-list",children:t.map(M=>_.jsxs("li",{children:[_.jsxs("div",{children:[_.jsxs("span",{className:"security-item-label",children:[M.label,M.current?_.jsx("span",{className:"security-badge",children:"this device"}):null]}),_.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(M.lastSeenAt).toLocaleString()]})]}),_.jsx("button",{type:"button",className:"security-remove",onClick:()=>{x(M.id)},children:"revoke"})]},M.id))})]}),_.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Trusted networks"}),_.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),a.length===0?_.jsx("p",{className:"muted",children:"No trusted networks."}):_.jsx("ul",{className:"security-list",children:a.map(M=>_.jsxs("li",{children:[_.jsxs("div",{children:[_.jsx("span",{className:"security-item-label",children:M.value}),M.label!==M.value?_.jsx("span",{className:"security-item-meta",children:M.label}):null]}),_.jsx("button",{type:"button",className:"security-remove",onClick:()=>{T(M.id)},children:"remove"})]},M.id))}),_.jsxs("form",{className:"security-add-form",onSubmit:B,children:[_.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:M=>b(M.currentTarget.value),required:!0}),_.jsx("input",{type:"text",placeholder:"Label (optional)",value:y,onChange:M=>S(M.currentTarget.value)}),_.jsx("button",{type:"submit",disabled:!f.trim(),children:"Add"})]})]}),c?_.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Two-factor authentication"}),_.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),_.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await E()},children:"Disable 2FA"})]}):null]})}const l0="nterminal.notifications.completionEnabled",um="nterminal.notifications.completionToastEnabled",hm="nterminal.notifications.completionToastDurationSeconds",dm="nterminal.notifications.completionToastPersistent",Hf="nterminal:completion-toast-display",so=6.5,Uf=2,Pf=60;function zu(){return typeof window<"u"&&"Notification"in window}function o0(){try{return window.localStorage.getItem(l0)==="true"}catch{return!1}}function Qy(e){try{window.localStorage.setItem(l0,e?"true":"false")}catch{}}function Hr(){return{enabled:ZE(),durationSeconds:GE(),persistUntilDismissed:QE()}}function VE(e){if(typeof window<"u"){try{window.localStorage.setItem(um,e?"true":"false")}catch{}pm()}return Hr()}function Jy(e){const t=u0(e);if(typeof window<"u"){try{window.localStorage.setItem(hm,String(t))}catch{}pm()}return Hr()}function XE(e){if(typeof window<"u"){try{window.localStorage.setItem(dm,e?"true":"false")}catch{}pm()}return Hr()}function c0(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===um||n.key===hm||n.key===dm)&&e()};return window.addEventListener(Hf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Hf,e),window.removeEventListener("storage",t)}}function fm(){return zu()?window.Notification.permission:"unsupported"}function GE(){if(typeof window>"u")return so;try{const e=window.localStorage.getItem(hm);return e===null?so:u0(Number(e))}catch{return so}}function ZE(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(um)!=="false"}catch{return!0}}function QE(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(dm)==="true"}catch{return!1}}function u0(e){if(!Number.isFinite(e))return so;const t=Math.round(e*2)/2;return Math.max(Uf,Math.min(Pf,t))}function pm(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Hf))}async function JE(){if(!zu())return"unsupported";try{return await window.Notification.requestPermission()}catch{return fm()}}function e2(e){if(!zu()||fm()!=="granted"||!o0()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.commandName?`${e.commandName} finished`:"Command finished";try{new Notification(`NTerminal · ${e.tabTitle}`,{body:t,tag:e.terminalId,icon:"/icons/app-icon-384.png",silent:!0})}catch{}}const t2=1500,mm="nterminal.terminal.fontSize",_m="nterminal.terminal.fontFamily",Kf="nterminal:terminal-font-size",If="nterminal:terminal-font-family",Ff=11,qf=20,zr=14,_u=[{id:"meslo",label:"MesloLGS NF",cssFamily:['"MesloLGS NF"','"MesloLGS Nerd Font Mono"','"MesloLGSNerdFontMono"','"JetBrainsMono Nerd Font"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:['"MesloLGS NF"']},{id:"jetbrains",label:"JetBrains Mono",cssFamily:['"JetBrainsMono Nerd Font"','"JetBrains Mono"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]},{id:"system",label:"System mono",cssFamily:['"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]}],Oa="meslo";Wf(Oa);async function of(e=zr,t=Oa){if(typeof document>"u"||!document.fonts)return;const n=f0(t).webFontFamilies;if(n.length===0)return;const a=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([a,new Promise(o=>{globalThis.setTimeout(o,t2)})])}function h0(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return zr;const n=Math.round(t);return Math.max(Ff,Math.min(qf,n))}function d0(e){return _u.some(t=>t.id===e)?e:Oa}function Wf(e){return f0(e).cssFamily}function f0(e){return _u.find(t=>t.id===e)??_u[0]}function $f(){if(typeof window>"u")return zr;try{const e=window.localStorage.getItem(mm);return e?h0(e):zr}catch{return zr}}function Yf(){if(typeof window>"u")return Oa;try{return d0(window.localStorage.getItem(_m))}catch{return Oa}}function Ic(e){const t=h0(e);if(typeof window>"u")return t;try{window.localStorage.setItem(mm,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Kf,{detail:t})),t}function i2(e){const t=d0(e);if(typeof window>"u")return t;try{window.localStorage.setItem(_m,t)}catch{}return window.dispatchEvent(new CustomEvent(If,{detail:t})),t}function p0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===mm&&e()};return window.addEventListener(Kf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Kf,e),window.removeEventListener("storage",t)}}function m0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===_m&&e()};return window.addEventListener(If,e),window.addEventListener("storage",t),()=>{window.removeEventListener(If,e),window.removeEventListener("storage",t)}}const vm="nterminal.terminal.showScrollProgress",Vf="nterminal:terminal-scroll-progress";function Xf(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(vm)!=="false"}catch{return!0}}function s2(e){if(typeof window<"u"){try{window.localStorage.setItem(vm,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(Vf,{detail:e}))}return e}function _0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===vm&&e()};return window.addEventListener(Vf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Vf,e),window.removeEventListener("storage",t)}}const gm="nterminal.shortcuts.workspace.v1",Gf="nterminal:workspace-shortcuts",co=[{id:"server.previous",label:"Previous server",group:"Servers"},{id:"server.next",label:"Next server",group:"Servers"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"}],ym={"server.previous":Ai("ArrowUp",{ctrlKey:!0}),"server.next":Ai("ArrowDown",{ctrlKey:!0}),"tab.previous":Ai("ArrowLeft",{ctrlKey:!0}),"tab.next":Ai("ArrowRight",{ctrlKey:!0}),"tab.index":Ai("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":Ai("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":Ai("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Ai("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0})},n2={"server.previous":Ai("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":Ai("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":Ai("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":Ai("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":Ai("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":Ai("Digit",{ctrlKey:!0,altKey:!0}),"split.right":Ai("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Ai("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0})};function Ur(){const e=b0(ym);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(gm);if(!t)return e;const n=JSON.parse(t);for(const a of co){const o=n[a.id];if(f2(o)){const c=S0(o,a);d2(c,n2[a.id])||(e[a.id]=c)}}}catch{return e}return e}function eb(){return JSON.stringify(Ur())}function r2(e,t){const n=Ur(),a=co.find(o=>o.id===e);return a&&(n[e]=S0(t,a),bm(n)),n}function a2(e){const t=Ur();return t[e]={...ym[e]},bm(t),t}function l2(){const e=b0(ym);return bm(e),e}function v0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===gm&&e()};return window.addEventListener(Gf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Gf,e),window.removeEventListener("storage",t)}}function o2(e,t){const n=C0(e);return!n||m2(n)||t.indexed&&w0(e)===null?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function c2(e){const t=Ur();for(const n of co){const a=t[n.id];if(!(!a||!p2(e,a))){if(n.indexed){if(a.code!=="Digit")continue;const o=w0(e);if(o!==null)return{id:n.id,index:o};continue}if(C0(e)===a.code)return{id:n.id,index:null}}}return null}function g0(e){return y0(Ur()[e])}function y0(e){const t=[];return e.ctrlKey&&t.push("Ctrl"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),e.metaKey&&t.push("Meta"),t.push(_2(e.code)),t.join("+")}const u2=()=>g0("split.right"),h2=()=>g0("split.down");function Ai(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function b0(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function d2(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function bm(e){if(!(typeof window>"u")){try{window.localStorage.setItem(gm,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(Gf))}}function S0(e,t){return{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function f2(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.ctrlKey=="boolean"&&typeof t.altKey=="boolean"&&typeof t.shiftKey=="boolean"&&typeof t.metaKey=="boolean"&&typeof t.code=="string"&&t.code.length>0}function p2(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function w0(e){const t=/^Digit([1-9])$/.exec(e.code);return t?.[1]?Number(t[1]):/^[1-9]$/.test(e.key)?Number(e.key):null}function C0(e){if(e.code)return e.code;if(/^[a-z]$/i.test(e.key))return`Key${e.key.toUpperCase()}`;if(/^[0-9]$/.test(e.key))return`Digit${e.key}`;switch(e.key){case"[":case"{":return"BracketLeft";case"]":case"}":return"BracketRight";case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"Tab":case"Enter":case"Escape":case"Space":return e.key==="Space"?"Space":e.key;default:return null}}function m2(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function _2(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const n=/^Key([A-Z])$/.exec(e);if(n?.[1])return n[1];switch(e){case"BracketLeft":return"[";case"BracketRight":return"]";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"Space":return"Space";default:return e.replace(/^(Numpad|Digit|Key)/,"")}}const Sm="nterminal.theme.accent",Zf="nterminal:theme-accent",uo=[{id:"aqua",label:"Aqua Teal",accent:"#5EEAD4",soft:"rgba(94, 234, 212, 0.10)",glow:"rgba(94, 234, 212, 0.55)",xtermSelection:"#1f3f45"},{id:"signal-red",label:"Signal Red",accent:"#FF2A3D",soft:"rgba(255, 42, 61, 0.12)",glow:"rgba(255, 42, 61, 0.52)",xtermSelection:"#4a1b22"}],vu="aqua";function Eo(e){return uo.some(t=>t.id===e)?e:vu}function wm(e){return uo.find(t=>t.id===e)??uo[0]}function lr(){if(typeof window>"u")return vu;try{return Eo(window.localStorage.getItem(Sm))}catch{return vu}}function v2(e){const t=Eo(e);if(typeof window<"u"){try{window.localStorage.setItem(Sm,t)}catch{}Cm(t),window.dispatchEvent(new CustomEvent(Zf,{detail:t}))}return t}function Cm(e=lr()){if(typeof document>"u")return;const t=wm(Eo(e)),n=document.documentElement;n.style.setProperty("--nt-accent",t.accent),n.style.setProperty("--nt-accent-soft",t.soft),n.style.setProperty("--nt-accent-glow",t.glow)}function g2(e=lr()){return wm(Eo(e)).accent}function y2(e=lr()){return wm(Eo(e)).xtermSelection}function x0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Sm&&(Cm(lr()),e())};return window.addEventListener(Zf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Zf,e),window.removeEventListener("storage",t)}}const b2="Automatic update needs write access to the global npm install. Run this from a normal NTerminal runtime-user shell; only the npm install step uses sudo.";function S2(e="nterminal",t=new Date){return{reason:"permission",message:b2,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function w2(e){return/\b(?:EACCES|EPERM)\b|permission denied|missing write access|access denied|operation was rejected by your operating system|operation not permitted|root-owned files/i.test(e)}const E0=3600*1e3,C2="local",Qf=new Set,nr=new Map;let or={checking:!1,hasUpdates:!1,lastCheckedAt:null},xm=null,no=null,gu=0,Jn=null;function x2(e){return Qf.add(e),()=>{Qf.delete(e)}}function tb(){return or}function E2(e){const t=M2();xm=e,Em(),Jf(e,t);const n=()=>{if(document.visibilityState!=="visible"||!cr(e,t))return;const a=or.lastCheckedAt;(a===null||Date.now()-a>=E0)&&Jf(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),cr(e,t)&&R2()}}function T2(e,t){nr.set(e,T0(t)),za({...or,hasUpdates:Tm(),lastCheckedAt:Date.now()})}function cf(e){e===void 0?nr.clear():nr.set(e,!1),za({...or,hasUpdates:Tm()})}async function Jf(e,t){if(!cr(e,t))return;if(Jn&&Jn.api===e&&Jn.runId===t)return Jn.promise;za({...or,checking:!0});const n=k2(e,t).finally(()=>{Jn?.promise===n&&(Jn=null),cr(e,t)&&(za({...or,checking:!1,lastCheckedAt:Date.now()}),D2(e,t))});return Jn={api:e,runId:t,promise:n},n}async function k2(e,t){try{const n=await e.listAgents();if(!cr(e,t))return;const a=[{key:C2,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(a.map(async c=>{try{const d=await c.check();o.set(c.key,T0(d))}catch{o.set(c.key,nr.get(c.key)??!1)}})),!cr(e,t))return;nr.clear();for(const[c,d]of o)nr.set(c,d);za({...or,hasUpdates:Tm()})}catch{}}function D2(e,t){cr(e,t)&&(Em(),no=window.setTimeout(()=>{no=null,cr(e,t)&&Jf(e,t)},E0))}function R2(){gu+=1,Em(),xm=null,Jn=null,nr.clear(),za({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function Em(){no!==null&&(window.clearTimeout(no),no=null)}function M2(){return gu+=1,gu}function cr(e,t){return xm===e&&gu===t}function T0(e){return e.updateAvailable===!0}function Tm(){return Array.from(nr.values()).some(Boolean)}function za(e){or=e;for(const t of Array.from(Qf))t()}const N2=e=>new Promise(t=>setTimeout(t,e));function A2({api:e,onAgentRemoved:t}){const[n,a]=g.useState([{key:"local",id:null,name:"Local (main)"}]),[o,c]=g.useState({}),[d,p]=g.useState(!1),[m,f]=g.useState(null),[b,y]=g.useState(!1);function S(A,P){c(K=>({...K,[A]:{...K[A],...P}}))}const E=A=>A.id===null?e.getVersion():e.getAgentVersion(A.id),x=A=>A.id===null?e.checkUpdate():e.checkAgentUpdate(A.id),T=A=>A.id===null?e.runUpdate():e.runAgentUpdate(A.id);g.useEffect(()=>{let A=!1;return e.listAgents().then(P=>{if(A)return;const K=[{key:"local",id:null,name:"Local (main)"},...P.agents.map(j=>({key:j.id,id:j.id,name:j.name}))];a(K);for(const j of K)E(j).then(O=>S(j.key,{version:O,manualUpdate:O.manualUpdate??null})).catch(O=>S(j.key,{error:O instanceof Error?O.message:"unreachable"}))}).catch(()=>{}),()=>{A=!0}},[]);async function B(A){S(A.key,{busy:!0,status:"checking…",error:void 0});try{const P=await x(A);T2(A.key,P),S(A.key,{latestVersion:P.latestVersion,updateAvailable:P.updateAvailable,status:te(P),...P.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(P){S(A.key,{busy:!1,error:P instanceof Error?P.message:"check failed"})}}async function M(){p(!0),await Promise.all(n.map(A=>B(A))),p(!1)}async function V(A,P){const K=Date.now()+18e4;for(;Date.now()<K;){await N2(3e3);try{const j=await E(A);if(P&&j.runningVersion!==P.runningVersion)return j}catch{}}return null}async function I(A){let P=o[A.key]?.version;if(!P)try{P=await E(A),S(A.key,{version:P,manualUpdate:P.manualUpdate??null})}catch(O){return S(A.key,{busy:!1,error:O instanceof Error?O.message:"version check failed"}),"failed"}S(A.key,{busy:!0,status:"updating…",error:void 0});let K;try{K=await T(A)}catch(O){return S(A.key,{busy:!1,error:O instanceof Error?O.message:"update failed"}),"failed"}if(!K.ok){const O=K.manualUpdate??(w2(K.message)?S2():null);return O?(S(A.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:O}),"manual"):(S(A.key,{busy:!1,status:void 0,error:K.message}),"failed")}if(!K.changed)return S(A.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),cf(A.key),"unchanged";S(A.key,{status:"restarting…"});const j=await V(A,P);return j?(S(A.key,{busy:!1,version:j,updateAvailable:!1,status:"updated",manualUpdate:j.manualUpdate??null}),cf(A.key),A.id===null&&(y(!0),f("Main server updated. Reload the page to use the new client.")),"updated"):(S(A.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function X(A){if(!(A.id===null||!window.confirm([`Delete secondary server "${A.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
|
|
15
|
-
`)))){S(A.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const K=await e.uninstallAgent(A.id);a(j=>j.filter(O=>O.key!==A.key)),c(j=>{const O={...j};return delete O[A.key],O}),cf(A.key),t?.(A.id),f(K.message)}catch(K){S(A.key,{busy:!1,status:void 0,error:K instanceof Error?K.message:"delete failed"})}}}async function le(){p(!0),f(null);const A=n.filter(D=>D.id!==null),P=n.find(D=>D.id===null),K=await Promise.all(A.map(D=>I(D))),j=K.filter(D=>D==="failed").length;let O=K.filter(D=>D==="manual").length,Q=null;if(P&&(Q=await I(P),Q==="manual"&&(O+=1),Q==="updated")){j>0&&f("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),p(!1);return}j>0&&O>0?f("Some servers failed and some need manual update. Check each marked row."):j>0?f("Some secondary servers failed to update. Check their rows and retry."):O>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),p(!1)}function ee(A){return A?A.error?A.error:A.status?A.status:A.manualUpdate?"manual update required":A.version?`v${A.version.version}`:"…":"…"}function te(A){return A.error?A.error:typeof A.updateAvailable=="boolean"?A.updateAvailable?`latest v${A.latestVersion??"available"}`:"up to date":"unknown"}function ce(A){const P=A?.version;return P?`npm package v${P.runningVersion}`:""}async function pe(A,P){try{await L2(P),S(A,{copiedCommand:!0}),window.setTimeout(()=>S(A,{copiedCommand:!1}),1800)}catch(K){S(A,{error:K instanceof Error?K.message:"copy failed"})}}return _.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Servers"}),_.jsxs("div",{className:"update-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{M()},disabled:d,children:"Check for updates"}),_.jsx("button",{type:"button",onClick:()=>{le()},disabled:d,children:"Update all"})]}),m?_.jsx("p",{className:"settings-status",children:m}):null,b?_.jsxs("div",{className:"server-reload-required",role:"status",children:[_.jsx("span",{children:"Main server update is ready."}),_.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,_.jsx("ul",{className:"security-list",children:n.map(A=>{const P=o[A.key],K=ce(P),j=P?.manualUpdate??null,O=P?.version!==void 0&&P?.updateAvailable!==!1&&!P?.busy&&!d,Q=A.id!==null&&!P?.busy&&!d;return _.jsxs("li",{children:[_.jsxs("div",{className:"server-row-main",children:[_.jsxs("div",{children:[_.jsx("span",{className:"security-item-label",children:A.name}),_.jsxs("span",{className:"security-item-meta",children:[K?`${K} — `:"",ee(P)]})]}),j?_.jsxs("div",{className:"server-manual-update",children:[_.jsx("span",{children:j.message}),_.jsxs("div",{className:"server-manual-command",children:[_.jsx("code",{children:j.command}),_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{pe(A.key,j.command)},children:P?.copiedCommand?"Copied":"Copy"})]})]}):null]}),_.jsxs("div",{className:"server-row-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{I(A)},disabled:!O,children:P?.busy?"…":"Update"}),A.id!==null?_.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{X(A)},disabled:!Q,children:"Delete"}):null]})]},A.key)})})]})}async function L2(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("copy failed")}finally{t.remove()}}const Fc=[{id:"terminal",label:"Terminal"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function B2({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:a,onAgentRemoved:o}){const c=g.useMemo(()=>t??Nu(),[t]),[d,p]=g.useState(()=>$f()),[m,f]=g.useState(()=>Yf()),[b,y]=g.useState(()=>Xf()),[S,E]=g.useState(()=>lr()),[x,T]=g.useState(()=>Ur()),[B,M]=g.useState(null),[V,I]=g.useState(null),[X,le]=g.useState("terminal"),[ee,te]=g.useState(()=>o0()),[ce,pe]=g.useState(()=>Hr()),[A,P]=g.useState(()=>fm()),[K,j]=g.useState([]),[O,Q]=g.useState([]),[D,q]=g.useState([]),[Z,ve]=g.useState(5*1024*1024),[be,R]=g.useState(!1),[Y,se]=g.useState(null),fe=g.useRef(null),he=g.useRef(null),de=g.useRef({terminal:null,shortcuts:null,notifications:null,security:null,servers:null}),Se=g.useMemo(()=>new Set(O),[O]),Be=!O2(O,D);g.useEffect(()=>p0(()=>p($f())),[]),g.useEffect(()=>m0(()=>f(Yf())),[]),g.useEffect(()=>_0(()=>y(Xf())),[]),g.useEffect(()=>x0(()=>E(lr())),[]),g.useEffect(()=>v0(()=>T(Ur())),[]),g.useEffect(()=>c0(()=>pe(Hr())),[]),g.useEffect(()=>{if(!B)return;const J=co.find(Ne=>Ne.id===B);if(!J)return;const Ke=Ne=>{if(Ne.preventDefault(),Ne.stopPropagation(),Ne.key==="Escape"){M(null),I(null);return}const bt=o2(Ne,J);if(!bt){I(J.indexed?"Press a shortcut ending in a number from 1 to 9.":"Press a complete shortcut.");return}T(r2(B,bt)),M(null),I(null)};return window.addEventListener("keydown",Ke,!0),()=>window.removeEventListener("keydown",Ke,!0)},[B]),g.useEffect(()=>{let J=!1;return c.listNotificationAssets().then(Ke=>{J||De(Ke)}).catch(Ke=>{J||se(qc(Ke))}),()=>{J=!0}},[c]);function Ae(J){p(Ic(Number(J)))}function Re(J){pe(Jy(Number(J)))}function ze(J){le(J);const Ke=he.current,Ne=de.current[J];if(!Ke||!Ne)return;const bt=Math.max(0,ib(Ne,Ke)-12);typeof Ke.scrollTo=="function"?Ke.scrollTo({top:bt,behavior:"smooth"}):Ke.scrollTop=bt}function He(){const J=he.current;if(!J)return;if(J.scrollTop+J.clientHeight>=J.scrollHeight-2){le(Fc[Fc.length-1].id);return}let Ke="terminal";const Ne=J.scrollTop+Math.min(180,Math.max(48,J.clientHeight*.28));for(const bt of Fc){const xi=de.current[bt.id];xi&&ib(xi,J)<=Ne&&(Ke=bt.id)}le(Ke)}function Te(J){T(a2(J)),M(null),I(null)}function ne(){T(l2()),M(null),I(null)}function De(J){const Ke=J.assets.filter(Ne=>Ne.enabled).map(Ne=>Ne.id);j(J.assets),Q(Ke),q(Ke),ve(J.maxFileBytes),se(null)}async function xe(){if(ee){Qy(!1),te(!1);return}let J=A;J==="default"&&(J=await JE(),P(J)),J==="granted"&&(Qy(!0),te(!0))}async function je(J){const Ke=J?.[0];if(Ke){if(Ke.size>Z){se(`File must be ${uf(Z)} or smaller.`),_t();return}if(Ke.type!=="video/mp4"&&Ke.type!=="video/webm"){se("Upload an MP4 or WebM video."),_t();return}R(!0),se(null);try{await c.uploadNotificationAsset(Ke),De(await c.listNotificationAssets()),a?.()}catch(Ne){se(qc(Ne))}finally{R(!1),_t()}}}async function Pe(J){R(!0),se(null);try{await c.deleteNotificationAsset(J),De(await c.listNotificationAssets()),a?.()}catch(Ke){se(qc(Ke))}finally{R(!1)}}function _t(){fe.current&&(fe.current.value="")}function rt(J,Ke){const Ne=new Set(O);if(Ke?Ne.add(J):Ne.delete(J),Ne.size===0){se("Keep at least one toast video selected.");return}se(null),Q(Array.from(Ne))}async function Ci(){if(O.length===0){se("Keep at least one toast video selected.");return}R(!0),se(null);try{const J=await c.updateNotificationAssetSelection({enabledAssetIds:O});De(J),a?.()}catch(J){se(qc(J))}finally{R(!1)}}return _.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:_.jsxs("div",{className:"security-panel settings-panel",onClick:J=>J.stopPropagation(),children:[_.jsxs("header",{className:"security-panel-header",children:[_.jsx("h2",{children:"Settings"}),_.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),_.jsxs("div",{className:"settings-layout",children:[_.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Fc.map(J=>_.jsxs("button",{type:"button","data-active":X===J.id?"true":"false","aria-current":X===J.id?"true":void 0,onClick:()=>ze(J.id),children:[J.label,J.id==="servers"&&n?_.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},J.id))}),_.jsxs("div",{ref:he,className:"settings-content",onScroll:He,children:[_.jsxs("section",{id:"settings-terminal",ref:J=>{de.current.terminal=J},className:"security-section settings-section",children:[_.jsx("h3",{children:"Terminal"}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Font size"}),_.jsxs("span",{className:"settings-control-value",children:[d,"px"]}),_.jsx("input",{type:"range",min:Ff,max:qf,step:1,value:d,"aria-label":"Terminal font size",onChange:J=>Ae(J.currentTarget.value)})]}),_.jsxs("div",{className:"settings-stepper-row",children:[_.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Ic(d-1)),children:"-"}),_.jsx("input",{type:"number",min:Ff,max:qf,step:1,value:d,"aria-label":"Terminal font size value",onChange:J=>Ae(J.currentTarget.value)}),_.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Ic(d+1)),children:"+"}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>p(Ic(zr)),children:"Reset"})]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Font family"}),_.jsx("select",{value:m,"aria-label":"Terminal font family",onChange:J=>f(i2(J.currentTarget.value)),children:_u.map(J=>_.jsx("option",{value:J.id,children:J.label},J.id))})]}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:b,onChange:J=>y(s2(J.currentTarget.checked))}),"Show scroll progress"]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Accent theme"}),_.jsx("select",{value:S,"aria-label":"Theme accent",onChange:J=>E(v2(J.currentTarget.value)),children:uo.map(J=>_.jsx("option",{value:J.id,children:J.label},J.id))})]}),_.jsx("div",{className:"settings-theme-swatches","aria-hidden":"true",children:uo.map(J=>_.jsx("span",{className:"settings-theme-swatch","data-active":S===J.id?"true":"false",style:{"--settings-theme-accent":J.accent}},J.id))})]}),_.jsxs("section",{id:"settings-shortcuts",ref:J=>{de.current.shortcuts=J},className:"security-section settings-section",children:[_.jsxs("div",{className:"settings-section-heading",children:[_.jsx("h3",{children:"Shortcuts"}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:ne,children:"Reset all"})]}),_.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),V?_.jsx("p",{className:"settings-error",children:V}):null,_.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:co.map(J=>{const Ke=B===J.id;return _.jsxs("li",{children:[_.jsxs("div",{children:[_.jsx("span",{className:"settings-shortcut-label",children:J.label}),_.jsx("span",{className:"settings-shortcut-group",children:J.group})]}),_.jsxs("div",{className:"settings-shortcut-actions",children:[_.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Ke?"true":"false",onClick:()=>{M(J.id),I(null)},children:Ke?"Press keys…":y0(x[J.id])}),_.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Te(J.id),children:"Reset"})]})]},J.id)})})]}),_.jsxs("section",{id:"settings-notifications",ref:J=>{de.current.notifications=J},className:"security-section settings-section",children:[_.jsx("h3",{children:"Notifications"}),zu()?_.jsxs(_.Fragment,{children:[_.jsxs("label",{className:"auth-checkbox",children:[_.jsx("input",{type:"checkbox",checked:ee&&A==="granted",onChange:()=>{xe()},disabled:A==="denied"}),"System notification when page is hidden"]}),A==="denied"?_.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):_.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):_.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:ce.enabled,onChange:J=>pe(VE(J.currentTarget.checked))}),"Show animated completion toast"]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Toast duration"}),_.jsx("span",{className:"settings-control-value",children:ce.persistUntilDismissed?"Until closed":`${ce.durationSeconds}s`}),_.jsx("input",{type:"range",min:Uf,max:Pf,step:.5,value:ce.durationSeconds,disabled:!ce.enabled||ce.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:J=>Re(J.currentTarget.value)})]}),_.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[_.jsx("input",{type:"number",min:Uf,max:Pf,step:.5,value:ce.durationSeconds,disabled:!ce.enabled||ce.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:J=>Re(J.currentTarget.value)}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!ce.enabled||ce.persistUntilDismissed,onClick:()=>pe(Jy(so)),children:"Reset"})]}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:ce.persistUntilDismissed,disabled:!ce.enabled,onChange:J=>pe(XE(J.currentTarget.checked))}),"Keep toast until dismissed"]}),_.jsxs("div",{className:"settings-assets-header",children:[_.jsx("span",{children:"Toast videos"}),_.jsxs("span",{children:[uf(Z)," max"]})]}),_.jsx("input",{ref:fe,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:J=>{je(J.currentTarget.files)}}),_.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:be,onClick:()=>fe.current?.click(),children:"Upload video"}),Y?_.jsx("p",{className:"settings-error",children:Y}):null,K.length>0?_.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:K.map(J=>_.jsxs("li",{"data-enabled":Se.has(J.id)?"true":"false",children:[_.jsxs("label",{className:"settings-asset-choice",children:[_.jsx("input",{type:"checkbox",checked:Se.has(J.id),disabled:be,"aria-label":`Use ${J.filename}`,onChange:Ke=>rt(J.id,Ke.currentTarget.checked)}),_.jsx("video",{src:J.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),_.jsxs("span",{className:"settings-asset-copy",children:[_.jsx("span",{children:J.filename}),_.jsx("small",{children:J.source==="built-in"?"Built-in":uf(J.size)})]})]}),J.source==="uploaded"?_.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:be,"aria-label":`Delete ${J.filename}`,onClick:()=>{Pe(J.id)},children:"x"}):null]},J.id))}):_.jsx("p",{className:"muted",children:"Built-in videos will be used."}),_.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:be||K.length===0||!Be,onClick:()=>{Ci()},children:"Save selected videos"})]}),_.jsx("div",{id:"settings-security",ref:J=>{de.current.security=J},className:"settings-section-group",children:_.jsx(YE,{api:c})}),_.jsx("div",{id:"settings-servers",ref:J=>{de.current.servers=J},className:"settings-section-group",children:_.jsx(A2,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function ib(e,t){const n=e.getBoundingClientRect(),a=t.getBoundingClientRect();return n.top-a.top+t.scrollTop}function uf(e){return e>=1024*1024?`${Math.round(e/1024/1024*10)/10} MB`:e>=1024?`${Math.round(e/1024*10)/10} KB`:`${e} B`}function qc(e){return e instanceof Error?e.message:"Request failed."}function O2(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(a=>n.has(a))}class Rr extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function z2(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,a=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:a}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let d=!1;const p=()=>{e.signal?.removeEventListener("abort",b)},m=y=>{d||(d=!0,p(),o(y))},f=y=>{d||(d=!0,p(),c(y))},b=()=>{t.abort(),f(new Rr(0,"Upload aborted."))};if(e.signal?.aborted){f(new Rr(0,"Upload aborted."));return}e.signal?.addEventListener("abort",b,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=y=>{if(e.onProgress){if(y.lengthComputable&&y.total>0){e.onProgress({loaded:y.loaded,total:y.total,percent:Math.round(y.loaded/y.total*100)});return}e.onProgress({loaded:y.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{m(JSON.parse(t.responseText))}catch{f(new Rr(t.status,"Invalid upload response."))}return}f(new Rr(t.status,j2(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new Rr(0,"Upload failed.")),t.onabort=()=>f(new Rr(0,"Upload aborted.")),t.ontimeout=()=>f(new Rr(0,"Upload timed out.")),t.send(n)})}function j2(e,t){try{const n=JSON.parse(e),a=typeof n.error=="string"?n.error:n.message;if(typeof a=="string"&&a.trim())return a}catch{}return t}const H2="modulepreload",U2=function(e){return"/"+e},sb={},km=function(t,n,a){let o=Promise.resolve();if(n&&n.length>0){let m=function(f){return Promise.all(f.map(b=>Promise.resolve(b).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=d?.nonce||d?.getAttribute("nonce");o=m(n.map(f=>{if(f=U2(f),f in sb)return;sb[f]=!0;const b=f.endsWith(".css"),y=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const S=document.createElement("link");if(S.rel=b?"stylesheet":H2,b||(S.as="script"),S.crossOrigin="",S.href=f,p&&S.setAttribute("nonce",p),document.head.appendChild(S),b)return new Promise((E,x)=>{S.addEventListener("load",E),S.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(d){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=d,window.dispatchEvent(p),!p.defaultPrevented)throw d}return o.then(d=>{for(const p of d||[])p.status==="rejected"&&c(p.reason);return t().catch(c)})},P2=g.lazy(()=>km(()=>import("./MarkdownPreview-BEfFObXf.js"),__vite__mapDeps([0,1])));function K2({api:e,activeTerminalId:t,activeTerminalCwd:n,onOpenFile:a}){const[o,c]=g.useState(null),[d,p]=g.useState(""),[m,f]=g.useState({}),[b,y]=g.useState(()=>new Set),[S,E]=g.useState(null),[x,T]=g.useState({type:"empty"}),[B,M]=g.useState("idle"),[V,I]=g.useState(null),X=g.useRef(null),le=g.useRef(null),ee=g.useRef(!1),te=g.useRef(0),ce=g.useRef(null);ce.current===null&&t&&(ce.current=t);const pe=ce.current,A=t?df(t,n):null,P=o?[o.rootPath,d].filter(Boolean).join("/"):"",K=S?.path??null;g.useEffect(()=>(ee.current=!0,()=>{ee.current=!1,te.current+=1,Be()}),[]),g.useEffect(()=>{ce.current=t,le.current=null;const ne=t?df(t,n):null;j(t,ne)},[e]),g.useEffect(()=>{if(!pe||t!==pe)return;const ne=df(pe,n);ne!==le.current&&j(pe,ne)},[pe,t,n]);async function j(ne,De=A){const xe=Ae();if(le.current=De,Be(),c(null),p(""),f({}),y(new Set),E(null),T({type:"empty"}),I(null),!ne){M("idle");return}M("loading");try{const je=await e.createFileRoot({terminalId:ne});if(!Re(xe))return;c({rootToken:je.rootToken,rootPath:je.rootPath});const Pe=await e.listFiles({rootToken:je.rootToken,path:""});if(!Re(xe))return;D(Pe),M("idle")}catch(je){if(await ze(je,xe))return;Re(xe)&&(I(Xn(je)),M("idle"))}}async function O(ne=d,De=o){if(!De)return;const xe=Ae();M("loading"),I(null);try{const je=await e.listFiles({rootToken:De.rootToken,path:ne});if(!Re(xe))return;D(je),M("idle")}catch(je){if(await ze(je,xe))return;Re(xe)&&(I(Xn(je)),M("idle"))}}async function Q(){ce.current=t,await j(t,A)}function D(ne){f(De=>({...De,[ne.path]:F2(ne.entries)}))}async function q(ne){if(!(!hf(ne)||!o)){if(E(ne),I(null),ne.kind==="directory"){p(ne.path),Se(),await ve(ne);return}if(p(Mr(ne.path)),ne.editable){await R(ne);return}ne.previewKind!=="none"&&await se(ne,ne.previewKind)}}async function Z(ne){if(!(!hf(ne)||!o)){if(E(ne),I(null),ne.kind==="directory"){p(ne.path),Se(),await ve(ne);return}if(p(Mr(ne.path)),ne.editable){await Y(ne);return}ne.previewKind!=="none"&&await se(ne,ne.previewKind)}}async function ve(ne){if(b.has(ne.path)){y(De=>{const xe=new Set(De);return xe.delete(ne.path),xe});return}y(De=>new Set(De).add(ne.path)),await O(ne.path)}function be(ne,De){ne.key==="Enter"&&(ne.preventDefault(),Z(De))}async function R(ne){if(!o)return;const De=Ae();M("loading"),Be();try{const xe=await e.readFile({rootToken:o.rootToken,path:ne.path});if(!Re(De))return;T({type:"text-preview",file:ne,read:xe}),M("idle")}catch(xe){if(await ze(xe,De))return;Re(De)&&(I(Xn(xe)),M("idle"))}}async function Y(ne){if(!o)return;const De=Ae();M("loading");try{await a({rootToken:o.rootToken,path:ne.path}),Re(De)&&M("idle")}catch(xe){if(await ze(xe,De))return;Re(De)&&(I(Xn(xe)),M("idle"))}}async function se(ne,De){if(!o)return;const xe=Ae();M("loading"),Be();try{const je=await e.previewFile({rootToken:o.rootToken,path:ne.path});if(!Re(xe))return;const Pe=URL.createObjectURL(je);if(!Re(xe)){URL.revokeObjectURL(Pe);return}X.current=Pe,T({type:"preview",file:ne,previewKind:De,url:Pe}),M("idle")}catch(je){if(await ze(je,xe))return;Re(xe)&&(I(Xn(je)),M("idle"))}}async function fe(ne){if(!o)return;const De=ne==="file"?"New file":"New folder",xe=window.prompt(De,""),je=S?S.kind==="directory"?S.path:Mr(S.path):d,Pe=nb(xe,je);if(Pe){I(null);try{const _t=await e.createFileEntry({rootToken:o.rootToken,path:Pe,kind:ne});E(_t.entry),await O(je)}catch(_t){if(await ze(_t))return;I(Xn(_t))}}}async function he(){if(!o||!S)return;const ne=window.prompt("Move selected entry",S.path),De=nb(ne,"");if(!De||De===S.path)return;const xe=Mr(S.path),je=Mr(De);I(null);try{const Pe=await e.moveFileEntry({rootToken:o.rootToken,sourcePath:S.path,destinationPath:De});E(Pe.entry),p(Pe.entry.kind==="directory"?Pe.entry.path:Mr(Pe.entry.path)),Se(),await O(xe),je!==xe&&await O(je)}catch(Pe){if(await ze(Pe))return;I(Xn(Pe))}}async function de(){if(!o||!S)return;const ne=S.path,De=Mr(ne);I(null);try{const xe=await e.previewDeleteFileEntry({rootToken:o.rootToken,path:S.path}),je=xe.descendantCount>0?` and ${xe.descendantCount} nested item${xe.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${xe.path}${je}?`))return;await e.deleteFileEntry({rootToken:o.rootToken,path:S.path,previewToken:xe.previewToken}),E(null),p(De),y(Pe=>{const _t=new Set(Pe);for(const rt of Pe)(rt===ne||rt.startsWith(`${ne}/`))&&_t.delete(rt);return _t}),Se(),await O(De)}catch(xe){if(await ze(xe))return;I(Xn(xe))}}function Se(){te.current+=1,Be(),T({type:"empty"})}function Be(){X.current&&(URL.revokeObjectURL(X.current),X.current=null)}function Ae(){return te.current+=1,te.current}function Re(ne){return ee.current&&ne===te.current}async function ze(ne,De){return q2(ne)?(De!==void 0&&!Re(De)||await j(t,A),!0):!1}function He(ne,De){const xe=hf(ne),je=ne.kind==="directory"&&b.has(ne.path),Pe=m[ne.path]??[],_t={"--file-tree-depth":De};return _.jsxs(ii.Fragment,{children:[_.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ne.kind,"data-expanded":je,"data-active":K===ne.path,disabled:!xe,style:_t,"aria-expanded":ne.kind==="directory"?je:void 0,"aria-label":`${ne.kind==="directory"?"Open folder":"Open file"} ${ne.name}`,title:ne.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{q(ne)},onDoubleClick:()=>{Z(ne)},onKeyDown:rt=>be(rt,ne),children:[_.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ne.kind==="directory"?je?"▾":"▸":""}),_.jsx("span",{className:"file-entry-name",children:ne.name}),_.jsx("small",{children:I2(ne)})]}),je?_.jsx("div",{className:"file-tree-children",role:"group",children:Pe.map(rt=>He(rt,De+1))}):null]},ne.path)}const Te=m[""]??[];return _.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":B==="loading",children:[_.jsxs("header",{className:"file-explorer-header",children:[_.jsx("div",{className:"file-explorer-path",title:P,children:P||"No active pane"}),_.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[_.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!t,onClick:()=>{Q()},children:"↻"}),_.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!o,onClick:()=>{fe("file")},children:"+"}),_.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!o,onClick:()=>{fe("directory")},children:"▣"})]})]}),V?_.jsx("div",{className:"file-explorer-alert",role:"alert",children:V}):null,_.jsxs("div",{className:"file-explorer-layout",children:[_.jsx("div",{className:"file-tree","aria-label":P?`Files in ${P}`:"Files",children:Te.map(ne=>He(ne,0))}),_.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[_.jsxs("div",{className:"file-detail-header",children:[_.jsx("strong",{children:S?.name??"detail"}),_.jsxs("div",{className:"file-detail-actions",children:[_.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!S,onClick:()=>{he()},children:"Move"}),_.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!S,onClick:()=>{de()},children:"Delete"})]})]}),B==="loading"?_.jsx("div",{className:"file-detail-empty",children:"loading"}):null,x.type==="empty"&&B!=="loading"?_.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,x.type==="preview"?_.jsxs("div",{className:"file-preview-frame",children:[x.previewKind==="image"?_.jsx("img",{src:x.url,alt:x.file.name}):null,x.previewKind==="pdf"?_.jsx("iframe",{src:x.url,title:x.file.name}):null]}):null,x.type==="text-preview"&&x.read.language==="markdown"?_.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${x.file.name}`,children:_.jsx(g.Suspense,{fallback:_.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:_.jsx(P2,{content:x.read.content})})}):null,x.type==="text-preview"&&x.read.language==="text"?_.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${x.file.name}`,children:x.read.content}):null]})]})]})}function hf(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function I2(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function df(e,t){return`${e}\0${t??""}`}function F2(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function Mr(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function nb(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function Xn(e){return e instanceof Error?e.message:"Request failed"}function q2(e){return e instanceof bn&&e.status===409&&e.message==="terminal_cwd_changed"}const W2=g.lazy(()=>km(()=>import("./MarkdownPreview-BEfFObXf.js"),__vite__mapDeps([0,1])));function rb({api:e,editor:t,canClose:n,onClose:a}){const[o,c]=g.useState(t.read),[d,p]=g.useState(t.read.content),[m,f]=g.useState("idle"),[b,y]=g.useState(null),[S,E]=g.useState(!1),[x,T]=g.useState("edit"),B=g.useRef(t),M=g.useRef(t.read),V=g.useRef(t.read.content),I=g.useRef(!1),X=g.useRef(!1),le=g.useRef(0),ee=d!==o.content&&m!=="saving"&&!S;g.useEffect(()=>(X.current=!0,()=>{X.current=!1,le.current+=1}),[]),g.useEffect(()=>{le.current+=1,I.current=!1,B.current=t,M.current=t.read,V.current=t.read.content,c(t.read),p(t.read.content),f("idle"),y(null),E(!1),T("edit")},[t.id,t.read]),g.useEffect(()=>{B.current=t},[t]),g.useEffect(()=>{M.current=o},[o]),g.useEffect(()=>{V.current=d},[d]),g.useEffect(()=>{if(d===o.content||S)return;const P=window.setInterval(()=>{!I.current&&V.current!==M.current.content&&te()},1e3);return()=>window.clearInterval(P)},[d===o.content,S,t.id]);async function te(){if(I.current)return;const P=V.current,K=M.current;if(P===K.content)return;const j=B.current,O=le.current;I.current=!0,f("saving"),y(null),E(!1);try{const Q=await e.writeFile({rootToken:j.rootToken,path:j.path,content:P,expectedVersion:K.version});if(!X.current||O!==le.current)return;const D={...K,content:P,version:Q.version};M.current=D,c(D),f(V.current===P?"saved":"idle")}catch(Q){if(!X.current||O!==le.current)return;if(Q instanceof bn&&Q.status===409){E(!0),f("idle");return}y($2(Q)),f("idle")}finally{O===le.current&&(I.current=!1)}}const ce=m==="saving"?"saving":m==="saved"?"saved":o.language,pe=o.language==="markdown",A=pe&&x==="preview";return _.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[_.jsxs("header",{className:"editor-pane-header",children:[_.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),_.jsx("strong",{children:t.title}),_.jsx("span",{className:"terminal-pane-spacer"}),_.jsx("span",{className:"terminal-pane-state",children:ce}),_.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!ee,onClick:()=>{te()},children:"Save"}),pe?_.jsx("button",{type:"button","aria-label":`${A?"Edit":"Preview"} ${t.title}`,onClick:()=>T(P=>P==="preview"?"edit":"preview"),children:A?"Edit":"Preview"}):null,n?_.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:a,children:"x"}):null]}),b?_.jsx("div",{className:"editor-pane-alert",role:"alert",children:b}):null,S?_.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,A?_.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:_.jsx(g.Suspense,{fallback:_.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:_.jsx(W2,{content:d})})}):_.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:P=>{const K=P.target.value;V.current=K,p(K),f("idle"),y(null),E(!1)}})]})}function $2(e){return e instanceof Error?e.message:"Request failed"}var Y2=2,V2=1,X2=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),a=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),d={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},p=d.top+d.bottom,m=d.right+d.left,f=a-p,b=o-m-t;return{cols:Math.max(Y2,Math.floor(b/e.css.cell.width)),rows:Math.max(V2,Math.floor(f/e.css.cell.height))}}};var k0=Object.defineProperty,G2=Object.getOwnPropertyDescriptor,Z2=(e,t)=>{for(var n in t)k0(e,n,{get:t[n],enumerable:!0})},zt=(e,t,n,a)=>{for(var o=a>1?void 0:a?G2(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=(a?d(t,n,o):d(o))||o);return a&&o&&k0(t,n,o),o},ye=(e,t)=>(n,a)=>t(n,a,e),ab="Terminal input",ep={get:()=>ab,set:e=>ab=e},lb="Too much output to announce, navigate to rows manually to read",tp={get:()=>lb,set:e=>lb=e};function Q2(e){return e.replace(/\r?\n/g,"\r")}function J2(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function eT(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function tT(e,t,n,a){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");D0(o,t,n,a)}}function D0(e,t,n,a){e=Q2(e),e=J2(e,n.decPrivateModes.bracketedPasteMode&&a.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function R0(e,t,n){let a=n.getBoundingClientRect(),o=e.clientX-a.left-10,c=e.clientY-a.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function ob(e,t,n,a,o){R0(e,t,n),o&&a.rightClickSelect(e),t.value=a.selectionText,t.select()}function tr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ju(e,t=0,n=e.length){let a="";for(let o=t;o<n;++o){let c=e[o];c>65535?(c-=65536,a+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):a+=String.fromCharCode(c)}return a}var iT=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let a=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[a++]=(this._interim-55296)*1024+c-56320+65536:(t[a++]=this._interim,t[a++]=c),this._interim=0}for(let c=o;c<n;++c){let d=e.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=n)return this._interim=d,a;let p=e.charCodeAt(c);56320<=p&&p<=57343?t[a++]=(d-55296)*1024+p-56320+65536:(t[a++]=d,t[a++]=p);continue}d!==65279&&(t[a++]=d)}return a}},sT=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let a=0,o,c,d,p,m=0,f=0;if(this.interim[0]){let S=!1,E=this.interim[0];E&=(E&224)===192?31:(E&240)===224?15:7;let x=0,T;for(;(T=this.interim[++x]&63)&&x<4;)E<<=6,E|=T;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,M=B-x;for(;f<M;){if(f>=n)return 0;if(T=e[f++],(T&192)!==128){f--,S=!0;break}else this.interim[x++]=T,E<<=6,E|=T&63}S||(B===2?E<128?f--:t[a++]=E:B===3?E<2048||E>=55296&&E<=57343||E===65279||(t[a++]=E):E<65536||E>1114111||(t[a++]=E)),this.interim.fill(0)}let b=n-4,y=f;for(;y<n;){for(;y<b&&!((o=e[y])&128)&&!((c=e[y+1])&128)&&!((d=e[y+2])&128)&&!((p=e[y+3])&128);)t[a++]=o,t[a++]=c,t[a++]=d,t[a++]=p,y+=4;if(o=e[y++],o<128)t[a++]=o;else if((o&224)===192){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(m=(o&31)<<6|c&63,m<128){y--;continue}t[a++]=m}else if((o&240)===224){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,a;if(d=e[y++],(d&192)!==128){y--;continue}if(m=(o&15)<<12|(c&63)<<6|d&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[a++]=m}else if((o&248)===240){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,a;if(d=e[y++],(d&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=d,a;if(p=e[y++],(p&192)!==128){y--;continue}if(m=(o&7)<<18|(c&63)<<12|(d&63)<<6|p&63,m<65536||m>1114111)continue;t[a++]=m}}return a}},M0="",sr=" ",To=class N0{constructor(){this.fg=0,this.bg=0,this.extended=new yu}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new N0;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}},yu=class A0{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new A0(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Es=class L0 extends To{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new yu,this.combinedData=""}static fromCharData(t){let n=new L0;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?tr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let a=t[1].charCodeAt(0);if(55296<=a&&a<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(a-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},cb="di$target",ip="di$dependencies",ff=new Map;function nT(e){return e[ip]||[]}function di(e){if(ff.has(e))return ff.get(e);let t=function(n,a,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");rT(t,n,o)};return t._id=e,ff.set(e,t),t}function rT(e,t,n){t[cb]===t?t[ip].push({id:e,index:n}):(t[ip]=[{id:e,index:n}],t[cb]=t)}var Hi=di("BufferService"),B0=di("CoreMouseService"),Ir=di("CoreService"),aT=di("CharsetService"),Dm=di("InstantiationService"),O0=di("LogService"),Ui=di("OptionsService"),z0=di("OscLinkService"),lT=di("UnicodeService"),ko=di("DecorationService"),sp=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 a=[],o=this._optionsService.rawOptions.linkHandler,c=new Es,d=n.getTrimmedLength(),p=-1,m=-1,f=!1;for(let b=0;b<d;b++)if(!(m===-1&&!n.hasContent(b))){if(n.loadCell(b,c),c.hasExtendedAttrs()&&c.extended.urlId)if(m===-1){m=b,p=c.extended.urlId;continue}else f=c.extended.urlId!==p;else m!==-1&&(f=!0);if(f||m!==-1&&b===d-1){let y=this._oscLinkService.getLinkData(p)?.uri;if(y){let S={start:{x:m+1,y:e},end:{x:b+(!f&&b===d-1?1:0),y:e}},E=!1;if(!o?.allowNonHttpProtocols)try{let x=new URL(y);["http:","https:"].includes(x.protocol)||(E=!0)}catch{E=!0}E||a.push({text:y,range:S,activate:(x,T)=>o?o.activate(x,T,S):oT(x,T),hover:(x,T)=>o?.hover?.(x,T,S),leave:(x,T)=>o?.leave?.(x,T,S)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(m=b,p=c.extended.urlId):(m=-1,p=-1)}}t(a)}};sp=zt([ye(0,Hi),ye(1,Ui),ye(2,z0)],sp);function oT(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
15
|
+
`)))){S(A.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const K=await e.uninstallAgent(A.id);a(j=>j.filter(O=>O.key!==A.key)),c(j=>{const O={...j};return delete O[A.key],O}),cf(A.key),t?.(A.id),f(K.message)}catch(K){S(A.key,{busy:!1,status:void 0,error:K instanceof Error?K.message:"delete failed"})}}}async function le(){p(!0),f(null);const A=n.filter(D=>D.id!==null),P=n.find(D=>D.id===null),K=await Promise.all(A.map(D=>I(D))),j=K.filter(D=>D==="failed").length;let O=K.filter(D=>D==="manual").length,Q=null;if(P&&(Q=await I(P),Q==="manual"&&(O+=1),Q==="updated")){j>0&&f("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),p(!1);return}j>0&&O>0?f("Some servers failed and some need manual update. Check each marked row."):j>0?f("Some secondary servers failed to update. Check their rows and retry."):O>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),p(!1)}function ee(A){return A?A.error?A.error:A.status?A.status:A.manualUpdate?"manual update required":A.version?`v${A.version.version}`:"…":"…"}function te(A){return A.error?A.error:typeof A.updateAvailable=="boolean"?A.updateAvailable?`latest v${A.latestVersion??"available"}`:"up to date":"unknown"}function ce(A){const P=A?.version;return P?`npm package v${P.runningVersion}`:""}async function pe(A,P){try{await L2(P),S(A,{copiedCommand:!0}),window.setTimeout(()=>S(A,{copiedCommand:!1}),1800)}catch(K){S(A,{error:K instanceof Error?K.message:"copy failed"})}}return _.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Servers"}),_.jsxs("div",{className:"update-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{M()},disabled:d,children:"Check for updates"}),_.jsx("button",{type:"button",onClick:()=>{le()},disabled:d,children:"Update all"})]}),m?_.jsx("p",{className:"settings-status",children:m}):null,b?_.jsxs("div",{className:"server-reload-required",role:"status",children:[_.jsx("span",{children:"Main server update is ready."}),_.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,_.jsx("ul",{className:"security-list",children:n.map(A=>{const P=o[A.key],K=ce(P),j=P?.manualUpdate??null,O=P?.version!==void 0&&P?.updateAvailable!==!1&&!P?.busy&&!d,Q=A.id!==null&&!P?.busy&&!d;return _.jsxs("li",{children:[_.jsxs("div",{className:"server-row-main",children:[_.jsxs("div",{children:[_.jsx("span",{className:"security-item-label",children:A.name}),_.jsxs("span",{className:"security-item-meta",children:[K?`${K} — `:"",ee(P)]})]}),j?_.jsxs("div",{className:"server-manual-update",children:[_.jsx("span",{children:j.message}),_.jsxs("div",{className:"server-manual-command",children:[_.jsx("code",{children:j.command}),_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{pe(A.key,j.command)},children:P?.copiedCommand?"Copied":"Copy"})]})]}):null]}),_.jsxs("div",{className:"server-row-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{I(A)},disabled:!O,children:P?.busy?"…":"Update"}),A.id!==null?_.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{X(A)},disabled:!Q,children:"Delete"}):null]})]},A.key)})})]})}async function L2(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("copy failed")}finally{t.remove()}}const Fc=[{id:"terminal",label:"Terminal"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function B2({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:a,onAgentRemoved:o}){const c=g.useMemo(()=>t??Nu(),[t]),[d,p]=g.useState(()=>$f()),[m,f]=g.useState(()=>Yf()),[b,y]=g.useState(()=>Xf()),[S,E]=g.useState(()=>lr()),[x,T]=g.useState(()=>Ur()),[B,M]=g.useState(null),[V,I]=g.useState(null),[X,le]=g.useState("terminal"),[ee,te]=g.useState(()=>o0()),[ce,pe]=g.useState(()=>Hr()),[A,P]=g.useState(()=>fm()),[K,j]=g.useState([]),[O,Q]=g.useState([]),[D,q]=g.useState([]),[Z,ve]=g.useState(5*1024*1024),[be,R]=g.useState(!1),[Y,se]=g.useState(null),fe=g.useRef(null),he=g.useRef(null),de=g.useRef({terminal:null,shortcuts:null,notifications:null,security:null,servers:null}),Se=g.useMemo(()=>new Set(O),[O]),Be=!O2(O,D);g.useEffect(()=>p0(()=>p($f())),[]),g.useEffect(()=>m0(()=>f(Yf())),[]),g.useEffect(()=>_0(()=>y(Xf())),[]),g.useEffect(()=>x0(()=>E(lr())),[]),g.useEffect(()=>v0(()=>T(Ur())),[]),g.useEffect(()=>c0(()=>pe(Hr())),[]),g.useEffect(()=>{if(!B)return;const J=co.find(Ne=>Ne.id===B);if(!J)return;const Ke=Ne=>{if(Ne.preventDefault(),Ne.stopPropagation(),Ne.key==="Escape"){M(null),I(null);return}const bt=o2(Ne,J);if(!bt){I(J.indexed?"Press a shortcut ending in a number from 1 to 9.":"Press a complete shortcut.");return}T(r2(B,bt)),M(null),I(null)};return window.addEventListener("keydown",Ke,!0),()=>window.removeEventListener("keydown",Ke,!0)},[B]),g.useEffect(()=>{let J=!1;return c.listNotificationAssets().then(Ke=>{J||De(Ke)}).catch(Ke=>{J||se(qc(Ke))}),()=>{J=!0}},[c]);function Ae(J){p(Ic(Number(J)))}function Re(J){pe(Jy(Number(J)))}function ze(J){le(J);const Ke=he.current,Ne=de.current[J];if(!Ke||!Ne)return;const bt=Math.max(0,ib(Ne,Ke)-12);typeof Ke.scrollTo=="function"?Ke.scrollTo({top:bt,behavior:"smooth"}):Ke.scrollTop=bt}function He(){const J=he.current;if(!J)return;if(J.scrollTop+J.clientHeight>=J.scrollHeight-2){le(Fc[Fc.length-1].id);return}let Ke="terminal";const Ne=J.scrollTop+Math.min(180,Math.max(48,J.clientHeight*.28));for(const bt of Fc){const xi=de.current[bt.id];xi&&ib(xi,J)<=Ne&&(Ke=bt.id)}le(Ke)}function Te(J){T(a2(J)),M(null),I(null)}function ne(){T(l2()),M(null),I(null)}function De(J){const Ke=J.assets.filter(Ne=>Ne.enabled).map(Ne=>Ne.id);j(J.assets),Q(Ke),q(Ke),ve(J.maxFileBytes),se(null)}async function xe(){if(ee){Qy(!1),te(!1);return}let J=A;J==="default"&&(J=await JE(),P(J)),J==="granted"&&(Qy(!0),te(!0))}async function je(J){const Ke=J?.[0];if(Ke){if(Ke.size>Z){se(`File must be ${uf(Z)} or smaller.`),_t();return}if(Ke.type!=="video/mp4"&&Ke.type!=="video/webm"){se("Upload an MP4 or WebM video."),_t();return}R(!0),se(null);try{await c.uploadNotificationAsset(Ke),De(await c.listNotificationAssets()),a?.()}catch(Ne){se(qc(Ne))}finally{R(!1),_t()}}}async function Pe(J){R(!0),se(null);try{await c.deleteNotificationAsset(J),De(await c.listNotificationAssets()),a?.()}catch(Ke){se(qc(Ke))}finally{R(!1)}}function _t(){fe.current&&(fe.current.value="")}function rt(J,Ke){const Ne=new Set(O);if(Ke?Ne.add(J):Ne.delete(J),Ne.size===0){se("Keep at least one toast video selected.");return}se(null),Q(Array.from(Ne))}async function Ci(){if(O.length===0){se("Keep at least one toast video selected.");return}R(!0),se(null);try{const J=await c.updateNotificationAssetSelection({enabledAssetIds:O});De(J),a?.()}catch(J){se(qc(J))}finally{R(!1)}}return _.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:_.jsxs("div",{className:"security-panel settings-panel",onClick:J=>J.stopPropagation(),children:[_.jsxs("header",{className:"security-panel-header",children:[_.jsx("h2",{children:"Settings"}),_.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),_.jsxs("div",{className:"settings-layout",children:[_.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Fc.map(J=>_.jsxs("button",{type:"button","data-active":X===J.id?"true":"false","aria-current":X===J.id?"true":void 0,onClick:()=>ze(J.id),children:[J.label,J.id==="servers"&&n?_.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},J.id))}),_.jsxs("div",{ref:he,className:"settings-content",onScroll:He,children:[_.jsxs("section",{id:"settings-terminal",ref:J=>{de.current.terminal=J},className:"security-section settings-section",children:[_.jsx("h3",{children:"Terminal"}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Font size"}),_.jsxs("span",{className:"settings-control-value",children:[d,"px"]}),_.jsx("input",{type:"range",min:Ff,max:qf,step:1,value:d,"aria-label":"Terminal font size",onChange:J=>Ae(J.currentTarget.value)})]}),_.jsxs("div",{className:"settings-stepper-row",children:[_.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Ic(d-1)),children:"-"}),_.jsx("input",{type:"number",min:Ff,max:qf,step:1,value:d,"aria-label":"Terminal font size value",onChange:J=>Ae(J.currentTarget.value)}),_.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Ic(d+1)),children:"+"}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>p(Ic(zr)),children:"Reset"})]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Font family"}),_.jsx("select",{value:m,"aria-label":"Terminal font family",onChange:J=>f(i2(J.currentTarget.value)),children:_u.map(J=>_.jsx("option",{value:J.id,children:J.label},J.id))})]}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:b,onChange:J=>y(s2(J.currentTarget.checked))}),"Show scroll progress"]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Accent theme"}),_.jsx("select",{value:S,"aria-label":"Theme accent",onChange:J=>E(v2(J.currentTarget.value)),children:uo.map(J=>_.jsx("option",{value:J.id,children:J.label},J.id))})]}),_.jsx("div",{className:"settings-theme-swatches","aria-hidden":"true",children:uo.map(J=>_.jsx("span",{className:"settings-theme-swatch","data-active":S===J.id?"true":"false",style:{"--settings-theme-accent":J.accent}},J.id))})]}),_.jsxs("section",{id:"settings-shortcuts",ref:J=>{de.current.shortcuts=J},className:"security-section settings-section",children:[_.jsxs("div",{className:"settings-section-heading",children:[_.jsx("h3",{children:"Shortcuts"}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:ne,children:"Reset all"})]}),_.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),V?_.jsx("p",{className:"settings-error",children:V}):null,_.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:co.map(J=>{const Ke=B===J.id;return _.jsxs("li",{children:[_.jsxs("div",{children:[_.jsx("span",{className:"settings-shortcut-label",children:J.label}),_.jsx("span",{className:"settings-shortcut-group",children:J.group})]}),_.jsxs("div",{className:"settings-shortcut-actions",children:[_.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Ke?"true":"false",onClick:()=>{M(J.id),I(null)},children:Ke?"Press keys…":y0(x[J.id])}),_.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Te(J.id),children:"Reset"})]})]},J.id)})})]}),_.jsxs("section",{id:"settings-notifications",ref:J=>{de.current.notifications=J},className:"security-section settings-section",children:[_.jsx("h3",{children:"Notifications"}),zu()?_.jsxs(_.Fragment,{children:[_.jsxs("label",{className:"auth-checkbox",children:[_.jsx("input",{type:"checkbox",checked:ee&&A==="granted",onChange:()=>{xe()},disabled:A==="denied"}),"System notification when page is hidden"]}),A==="denied"?_.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):_.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):_.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:ce.enabled,onChange:J=>pe(VE(J.currentTarget.checked))}),"Show animated completion toast"]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Toast duration"}),_.jsx("span",{className:"settings-control-value",children:ce.persistUntilDismissed?"Until closed":`${ce.durationSeconds}s`}),_.jsx("input",{type:"range",min:Uf,max:Pf,step:.5,value:ce.durationSeconds,disabled:!ce.enabled||ce.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:J=>Re(J.currentTarget.value)})]}),_.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[_.jsx("input",{type:"number",min:Uf,max:Pf,step:.5,value:ce.durationSeconds,disabled:!ce.enabled||ce.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:J=>Re(J.currentTarget.value)}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!ce.enabled||ce.persistUntilDismissed,onClick:()=>pe(Jy(so)),children:"Reset"})]}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:ce.persistUntilDismissed,disabled:!ce.enabled,onChange:J=>pe(XE(J.currentTarget.checked))}),"Keep toast until dismissed"]}),_.jsxs("div",{className:"settings-assets-header",children:[_.jsx("span",{children:"Toast videos"}),_.jsxs("span",{children:[uf(Z)," max"]})]}),_.jsx("input",{ref:fe,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:J=>{je(J.currentTarget.files)}}),_.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:be,onClick:()=>fe.current?.click(),children:"Upload video"}),Y?_.jsx("p",{className:"settings-error",children:Y}):null,K.length>0?_.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:K.map(J=>_.jsxs("li",{"data-enabled":Se.has(J.id)?"true":"false",children:[_.jsxs("label",{className:"settings-asset-choice",children:[_.jsx("input",{type:"checkbox",checked:Se.has(J.id),disabled:be,"aria-label":`Use ${J.filename}`,onChange:Ke=>rt(J.id,Ke.currentTarget.checked)}),_.jsx("video",{src:J.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),_.jsxs("span",{className:"settings-asset-copy",children:[_.jsx("span",{children:J.filename}),_.jsx("small",{children:J.source==="built-in"?"Built-in":uf(J.size)})]})]}),J.source==="uploaded"?_.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:be,"aria-label":`Delete ${J.filename}`,onClick:()=>{Pe(J.id)},children:"x"}):null]},J.id))}):_.jsx("p",{className:"muted",children:"Built-in videos will be used."}),_.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:be||K.length===0||!Be,onClick:()=>{Ci()},children:"Save selected videos"})]}),_.jsx("div",{id:"settings-security",ref:J=>{de.current.security=J},className:"settings-section-group",children:_.jsx(YE,{api:c})}),_.jsx("div",{id:"settings-servers",ref:J=>{de.current.servers=J},className:"settings-section-group",children:_.jsx(A2,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function ib(e,t){const n=e.getBoundingClientRect(),a=t.getBoundingClientRect();return n.top-a.top+t.scrollTop}function uf(e){return e>=1024*1024?`${Math.round(e/1024/1024*10)/10} MB`:e>=1024?`${Math.round(e/1024*10)/10} KB`:`${e} B`}function qc(e){return e instanceof Error?e.message:"Request failed."}function O2(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(a=>n.has(a))}class Rr extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function z2(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,a=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:a}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let d=!1;const p=()=>{e.signal?.removeEventListener("abort",b)},m=y=>{d||(d=!0,p(),o(y))},f=y=>{d||(d=!0,p(),c(y))},b=()=>{t.abort(),f(new Rr(0,"Upload aborted."))};if(e.signal?.aborted){f(new Rr(0,"Upload aborted."));return}e.signal?.addEventListener("abort",b,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=y=>{if(e.onProgress){if(y.lengthComputable&&y.total>0){e.onProgress({loaded:y.loaded,total:y.total,percent:Math.round(y.loaded/y.total*100)});return}e.onProgress({loaded:y.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{m(JSON.parse(t.responseText))}catch{f(new Rr(t.status,"Invalid upload response."))}return}f(new Rr(t.status,j2(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new Rr(0,"Upload failed.")),t.onabort=()=>f(new Rr(0,"Upload aborted.")),t.ontimeout=()=>f(new Rr(0,"Upload timed out.")),t.send(n)})}function j2(e,t){try{const n=JSON.parse(e),a=typeof n.error=="string"?n.error:n.message;if(typeof a=="string"&&a.trim())return a}catch{}return t}const H2="modulepreload",U2=function(e){return"/"+e},sb={},km=function(t,n,a){let o=Promise.resolve();if(n&&n.length>0){let m=function(f){return Promise.all(f.map(b=>Promise.resolve(b).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=d?.nonce||d?.getAttribute("nonce");o=m(n.map(f=>{if(f=U2(f),f in sb)return;sb[f]=!0;const b=f.endsWith(".css"),y=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const S=document.createElement("link");if(S.rel=b?"stylesheet":H2,b||(S.as="script"),S.crossOrigin="",S.href=f,p&&S.setAttribute("nonce",p),document.head.appendChild(S),b)return new Promise((E,x)=>{S.addEventListener("load",E),S.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(d){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=d,window.dispatchEvent(p),!p.defaultPrevented)throw d}return o.then(d=>{for(const p of d||[])p.status==="rejected"&&c(p.reason);return t().catch(c)})},P2=g.lazy(()=>km(()=>import("./MarkdownPreview-kJS2tSfr.js"),__vite__mapDeps([0,1])));function K2({api:e,activeTerminalId:t,activeTerminalCwd:n,onOpenFile:a}){const[o,c]=g.useState(null),[d,p]=g.useState(""),[m,f]=g.useState({}),[b,y]=g.useState(()=>new Set),[S,E]=g.useState(null),[x,T]=g.useState({type:"empty"}),[B,M]=g.useState("idle"),[V,I]=g.useState(null),X=g.useRef(null),le=g.useRef(null),ee=g.useRef(!1),te=g.useRef(0),ce=g.useRef(null);ce.current===null&&t&&(ce.current=t);const pe=ce.current,A=t?df(t,n):null,P=o?[o.rootPath,d].filter(Boolean).join("/"):"",K=S?.path??null;g.useEffect(()=>(ee.current=!0,()=>{ee.current=!1,te.current+=1,Be()}),[]),g.useEffect(()=>{ce.current=t,le.current=null;const ne=t?df(t,n):null;j(t,ne)},[e]),g.useEffect(()=>{if(!pe||t!==pe)return;const ne=df(pe,n);ne!==le.current&&j(pe,ne)},[pe,t,n]);async function j(ne,De=A){const xe=Ae();if(le.current=De,Be(),c(null),p(""),f({}),y(new Set),E(null),T({type:"empty"}),I(null),!ne){M("idle");return}M("loading");try{const je=await e.createFileRoot({terminalId:ne});if(!Re(xe))return;c({rootToken:je.rootToken,rootPath:je.rootPath});const Pe=await e.listFiles({rootToken:je.rootToken,path:""});if(!Re(xe))return;D(Pe),M("idle")}catch(je){if(await ze(je,xe))return;Re(xe)&&(I(Xn(je)),M("idle"))}}async function O(ne=d,De=o){if(!De)return;const xe=Ae();M("loading"),I(null);try{const je=await e.listFiles({rootToken:De.rootToken,path:ne});if(!Re(xe))return;D(je),M("idle")}catch(je){if(await ze(je,xe))return;Re(xe)&&(I(Xn(je)),M("idle"))}}async function Q(){ce.current=t,await j(t,A)}function D(ne){f(De=>({...De,[ne.path]:F2(ne.entries)}))}async function q(ne){if(!(!hf(ne)||!o)){if(E(ne),I(null),ne.kind==="directory"){p(ne.path),Se(),await ve(ne);return}if(p(Mr(ne.path)),ne.editable){await R(ne);return}ne.previewKind!=="none"&&await se(ne,ne.previewKind)}}async function Z(ne){if(!(!hf(ne)||!o)){if(E(ne),I(null),ne.kind==="directory"){p(ne.path),Se(),await ve(ne);return}if(p(Mr(ne.path)),ne.editable){await Y(ne);return}ne.previewKind!=="none"&&await se(ne,ne.previewKind)}}async function ve(ne){if(b.has(ne.path)){y(De=>{const xe=new Set(De);return xe.delete(ne.path),xe});return}y(De=>new Set(De).add(ne.path)),await O(ne.path)}function be(ne,De){ne.key==="Enter"&&(ne.preventDefault(),Z(De))}async function R(ne){if(!o)return;const De=Ae();M("loading"),Be();try{const xe=await e.readFile({rootToken:o.rootToken,path:ne.path});if(!Re(De))return;T({type:"text-preview",file:ne,read:xe}),M("idle")}catch(xe){if(await ze(xe,De))return;Re(De)&&(I(Xn(xe)),M("idle"))}}async function Y(ne){if(!o)return;const De=Ae();M("loading");try{await a({rootToken:o.rootToken,path:ne.path}),Re(De)&&M("idle")}catch(xe){if(await ze(xe,De))return;Re(De)&&(I(Xn(xe)),M("idle"))}}async function se(ne,De){if(!o)return;const xe=Ae();M("loading"),Be();try{const je=await e.previewFile({rootToken:o.rootToken,path:ne.path});if(!Re(xe))return;const Pe=URL.createObjectURL(je);if(!Re(xe)){URL.revokeObjectURL(Pe);return}X.current=Pe,T({type:"preview",file:ne,previewKind:De,url:Pe}),M("idle")}catch(je){if(await ze(je,xe))return;Re(xe)&&(I(Xn(je)),M("idle"))}}async function fe(ne){if(!o)return;const De=ne==="file"?"New file":"New folder",xe=window.prompt(De,""),je=S?S.kind==="directory"?S.path:Mr(S.path):d,Pe=nb(xe,je);if(Pe){I(null);try{const _t=await e.createFileEntry({rootToken:o.rootToken,path:Pe,kind:ne});E(_t.entry),await O(je)}catch(_t){if(await ze(_t))return;I(Xn(_t))}}}async function he(){if(!o||!S)return;const ne=window.prompt("Move selected entry",S.path),De=nb(ne,"");if(!De||De===S.path)return;const xe=Mr(S.path),je=Mr(De);I(null);try{const Pe=await e.moveFileEntry({rootToken:o.rootToken,sourcePath:S.path,destinationPath:De});E(Pe.entry),p(Pe.entry.kind==="directory"?Pe.entry.path:Mr(Pe.entry.path)),Se(),await O(xe),je!==xe&&await O(je)}catch(Pe){if(await ze(Pe))return;I(Xn(Pe))}}async function de(){if(!o||!S)return;const ne=S.path,De=Mr(ne);I(null);try{const xe=await e.previewDeleteFileEntry({rootToken:o.rootToken,path:S.path}),je=xe.descendantCount>0?` and ${xe.descendantCount} nested item${xe.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${xe.path}${je}?`))return;await e.deleteFileEntry({rootToken:o.rootToken,path:S.path,previewToken:xe.previewToken}),E(null),p(De),y(Pe=>{const _t=new Set(Pe);for(const rt of Pe)(rt===ne||rt.startsWith(`${ne}/`))&&_t.delete(rt);return _t}),Se(),await O(De)}catch(xe){if(await ze(xe))return;I(Xn(xe))}}function Se(){te.current+=1,Be(),T({type:"empty"})}function Be(){X.current&&(URL.revokeObjectURL(X.current),X.current=null)}function Ae(){return te.current+=1,te.current}function Re(ne){return ee.current&&ne===te.current}async function ze(ne,De){return q2(ne)?(De!==void 0&&!Re(De)||await j(t,A),!0):!1}function He(ne,De){const xe=hf(ne),je=ne.kind==="directory"&&b.has(ne.path),Pe=m[ne.path]??[],_t={"--file-tree-depth":De};return _.jsxs(ii.Fragment,{children:[_.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ne.kind,"data-expanded":je,"data-active":K===ne.path,disabled:!xe,style:_t,"aria-expanded":ne.kind==="directory"?je:void 0,"aria-label":`${ne.kind==="directory"?"Open folder":"Open file"} ${ne.name}`,title:ne.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{q(ne)},onDoubleClick:()=>{Z(ne)},onKeyDown:rt=>be(rt,ne),children:[_.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ne.kind==="directory"?je?"▾":"▸":""}),_.jsx("span",{className:"file-entry-name",children:ne.name}),_.jsx("small",{children:I2(ne)})]}),je?_.jsx("div",{className:"file-tree-children",role:"group",children:Pe.map(rt=>He(rt,De+1))}):null]},ne.path)}const Te=m[""]??[];return _.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":B==="loading",children:[_.jsxs("header",{className:"file-explorer-header",children:[_.jsx("div",{className:"file-explorer-path",title:P,children:P||"No active pane"}),_.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[_.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!t,onClick:()=>{Q()},children:"↻"}),_.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!o,onClick:()=>{fe("file")},children:"+"}),_.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!o,onClick:()=>{fe("directory")},children:"▣"})]})]}),V?_.jsx("div",{className:"file-explorer-alert",role:"alert",children:V}):null,_.jsxs("div",{className:"file-explorer-layout",children:[_.jsx("div",{className:"file-tree","aria-label":P?`Files in ${P}`:"Files",children:Te.map(ne=>He(ne,0))}),_.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[_.jsxs("div",{className:"file-detail-header",children:[_.jsx("strong",{children:S?.name??"detail"}),_.jsxs("div",{className:"file-detail-actions",children:[_.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!S,onClick:()=>{he()},children:"Move"}),_.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!S,onClick:()=>{de()},children:"Delete"})]})]}),B==="loading"?_.jsx("div",{className:"file-detail-empty",children:"loading"}):null,x.type==="empty"&&B!=="loading"?_.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,x.type==="preview"?_.jsxs("div",{className:"file-preview-frame",children:[x.previewKind==="image"?_.jsx("img",{src:x.url,alt:x.file.name}):null,x.previewKind==="pdf"?_.jsx("iframe",{src:x.url,title:x.file.name}):null]}):null,x.type==="text-preview"&&x.read.language==="markdown"?_.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${x.file.name}`,children:_.jsx(g.Suspense,{fallback:_.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:_.jsx(P2,{content:x.read.content})})}):null,x.type==="text-preview"&&x.read.language==="text"?_.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${x.file.name}`,children:x.read.content}):null]})]})]})}function hf(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function I2(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function df(e,t){return`${e}\0${t??""}`}function F2(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function Mr(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function nb(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function Xn(e){return e instanceof Error?e.message:"Request failed"}function q2(e){return e instanceof bn&&e.status===409&&e.message==="terminal_cwd_changed"}const W2=g.lazy(()=>km(()=>import("./MarkdownPreview-kJS2tSfr.js"),__vite__mapDeps([0,1])));function rb({api:e,editor:t,canClose:n,onClose:a}){const[o,c]=g.useState(t.read),[d,p]=g.useState(t.read.content),[m,f]=g.useState("idle"),[b,y]=g.useState(null),[S,E]=g.useState(!1),[x,T]=g.useState("edit"),B=g.useRef(t),M=g.useRef(t.read),V=g.useRef(t.read.content),I=g.useRef(!1),X=g.useRef(!1),le=g.useRef(0),ee=d!==o.content&&m!=="saving"&&!S;g.useEffect(()=>(X.current=!0,()=>{X.current=!1,le.current+=1}),[]),g.useEffect(()=>{le.current+=1,I.current=!1,B.current=t,M.current=t.read,V.current=t.read.content,c(t.read),p(t.read.content),f("idle"),y(null),E(!1),T("edit")},[t.id,t.read]),g.useEffect(()=>{B.current=t},[t]),g.useEffect(()=>{M.current=o},[o]),g.useEffect(()=>{V.current=d},[d]),g.useEffect(()=>{if(d===o.content||S)return;const P=window.setInterval(()=>{!I.current&&V.current!==M.current.content&&te()},1e3);return()=>window.clearInterval(P)},[d===o.content,S,t.id]);async function te(){if(I.current)return;const P=V.current,K=M.current;if(P===K.content)return;const j=B.current,O=le.current;I.current=!0,f("saving"),y(null),E(!1);try{const Q=await e.writeFile({rootToken:j.rootToken,path:j.path,content:P,expectedVersion:K.version});if(!X.current||O!==le.current)return;const D={...K,content:P,version:Q.version};M.current=D,c(D),f(V.current===P?"saved":"idle")}catch(Q){if(!X.current||O!==le.current)return;if(Q instanceof bn&&Q.status===409){E(!0),f("idle");return}y($2(Q)),f("idle")}finally{O===le.current&&(I.current=!1)}}const ce=m==="saving"?"saving":m==="saved"?"saved":o.language,pe=o.language==="markdown",A=pe&&x==="preview";return _.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[_.jsxs("header",{className:"editor-pane-header",children:[_.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),_.jsx("strong",{children:t.title}),_.jsx("span",{className:"terminal-pane-spacer"}),_.jsx("span",{className:"terminal-pane-state",children:ce}),_.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!ee,onClick:()=>{te()},children:"Save"}),pe?_.jsx("button",{type:"button","aria-label":`${A?"Edit":"Preview"} ${t.title}`,onClick:()=>T(P=>P==="preview"?"edit":"preview"),children:A?"Edit":"Preview"}):null,n?_.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:a,children:"x"}):null]}),b?_.jsx("div",{className:"editor-pane-alert",role:"alert",children:b}):null,S?_.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,A?_.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:_.jsx(g.Suspense,{fallback:_.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:_.jsx(W2,{content:d})})}):_.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:P=>{const K=P.target.value;V.current=K,p(K),f("idle"),y(null),E(!1)}})]})}function $2(e){return e instanceof Error?e.message:"Request failed"}var Y2=2,V2=1,X2=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),a=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),d={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},p=d.top+d.bottom,m=d.right+d.left,f=a-p,b=o-m-t;return{cols:Math.max(Y2,Math.floor(b/e.css.cell.width)),rows:Math.max(V2,Math.floor(f/e.css.cell.height))}}};var k0=Object.defineProperty,G2=Object.getOwnPropertyDescriptor,Z2=(e,t)=>{for(var n in t)k0(e,n,{get:t[n],enumerable:!0})},zt=(e,t,n,a)=>{for(var o=a>1?void 0:a?G2(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=(a?d(t,n,o):d(o))||o);return a&&o&&k0(t,n,o),o},ye=(e,t)=>(n,a)=>t(n,a,e),ab="Terminal input",ep={get:()=>ab,set:e=>ab=e},lb="Too much output to announce, navigate to rows manually to read",tp={get:()=>lb,set:e=>lb=e};function Q2(e){return e.replace(/\r?\n/g,"\r")}function J2(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function eT(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function tT(e,t,n,a){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");D0(o,t,n,a)}}function D0(e,t,n,a){e=Q2(e),e=J2(e,n.decPrivateModes.bracketedPasteMode&&a.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function R0(e,t,n){let a=n.getBoundingClientRect(),o=e.clientX-a.left-10,c=e.clientY-a.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function ob(e,t,n,a,o){R0(e,t,n),o&&a.rightClickSelect(e),t.value=a.selectionText,t.select()}function tr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ju(e,t=0,n=e.length){let a="";for(let o=t;o<n;++o){let c=e[o];c>65535?(c-=65536,a+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):a+=String.fromCharCode(c)}return a}var iT=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let a=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[a++]=(this._interim-55296)*1024+c-56320+65536:(t[a++]=this._interim,t[a++]=c),this._interim=0}for(let c=o;c<n;++c){let d=e.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=n)return this._interim=d,a;let p=e.charCodeAt(c);56320<=p&&p<=57343?t[a++]=(d-55296)*1024+p-56320+65536:(t[a++]=d,t[a++]=p);continue}d!==65279&&(t[a++]=d)}return a}},sT=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let a=0,o,c,d,p,m=0,f=0;if(this.interim[0]){let S=!1,E=this.interim[0];E&=(E&224)===192?31:(E&240)===224?15:7;let x=0,T;for(;(T=this.interim[++x]&63)&&x<4;)E<<=6,E|=T;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,M=B-x;for(;f<M;){if(f>=n)return 0;if(T=e[f++],(T&192)!==128){f--,S=!0;break}else this.interim[x++]=T,E<<=6,E|=T&63}S||(B===2?E<128?f--:t[a++]=E:B===3?E<2048||E>=55296&&E<=57343||E===65279||(t[a++]=E):E<65536||E>1114111||(t[a++]=E)),this.interim.fill(0)}let b=n-4,y=f;for(;y<n;){for(;y<b&&!((o=e[y])&128)&&!((c=e[y+1])&128)&&!((d=e[y+2])&128)&&!((p=e[y+3])&128);)t[a++]=o,t[a++]=c,t[a++]=d,t[a++]=p,y+=4;if(o=e[y++],o<128)t[a++]=o;else if((o&224)===192){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(m=(o&31)<<6|c&63,m<128){y--;continue}t[a++]=m}else if((o&240)===224){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,a;if(d=e[y++],(d&192)!==128){y--;continue}if(m=(o&15)<<12|(c&63)<<6|d&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[a++]=m}else if((o&248)===240){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,a;if(d=e[y++],(d&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=d,a;if(p=e[y++],(p&192)!==128){y--;continue}if(m=(o&7)<<18|(c&63)<<12|(d&63)<<6|p&63,m<65536||m>1114111)continue;t[a++]=m}}return a}},M0="",sr=" ",To=class N0{constructor(){this.fg=0,this.bg=0,this.extended=new yu}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new N0;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}},yu=class A0{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new A0(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Es=class L0 extends To{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new yu,this.combinedData=""}static fromCharData(t){let n=new L0;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?tr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let a=t[1].charCodeAt(0);if(55296<=a&&a<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(a-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},cb="di$target",ip="di$dependencies",ff=new Map;function nT(e){return e[ip]||[]}function di(e){if(ff.has(e))return ff.get(e);let t=function(n,a,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");rT(t,n,o)};return t._id=e,ff.set(e,t),t}function rT(e,t,n){t[cb]===t?t[ip].push({id:e,index:n}):(t[ip]=[{id:e,index:n}],t[cb]=t)}var Hi=di("BufferService"),B0=di("CoreMouseService"),Ir=di("CoreService"),aT=di("CharsetService"),Dm=di("InstantiationService"),O0=di("LogService"),Ui=di("OptionsService"),z0=di("OscLinkService"),lT=di("UnicodeService"),ko=di("DecorationService"),sp=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 a=[],o=this._optionsService.rawOptions.linkHandler,c=new Es,d=n.getTrimmedLength(),p=-1,m=-1,f=!1;for(let b=0;b<d;b++)if(!(m===-1&&!n.hasContent(b))){if(n.loadCell(b,c),c.hasExtendedAttrs()&&c.extended.urlId)if(m===-1){m=b,p=c.extended.urlId;continue}else f=c.extended.urlId!==p;else m!==-1&&(f=!0);if(f||m!==-1&&b===d-1){let y=this._oscLinkService.getLinkData(p)?.uri;if(y){let S={start:{x:m+1,y:e},end:{x:b+(!f&&b===d-1?1:0),y:e}},E=!1;if(!o?.allowNonHttpProtocols)try{let x=new URL(y);["http:","https:"].includes(x.protocol)||(E=!0)}catch{E=!0}E||a.push({text:y,range:S,activate:(x,T)=>o?o.activate(x,T,S):oT(x,T),hover:(x,T)=>o?.hover?.(x,T,S),leave:(x,T)=>o?.leave?.(x,T,S)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(m=b,p=c.extended.urlId):(m=-1,p=-1)}}t(a)}};sp=zt([ye(0,Hi),ye(1,Ui),ye(2,z0)],sp);function oT(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
16
16
|
|
|
17
17
|
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Hu=di("CharSizeService"),wn=di("CoreBrowserService"),Rm=di("MouseService"),Cn=di("RenderService"),cT=di("SelectionService"),j0=di("CharacterJoinerService"),Ka=di("ThemeService"),H0=di("LinkProviderService"),uT=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ub.isErrorNoTelemetry(e)?new ub(e.message+`
|
|
18
18
|
|
|
@@ -28,7 +28,7 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
|
|
|
28
28
|
`))),this._register(this._terminal.onA11yTab(c=>this._handleTab(c))),this._register(this._terminal.onKey(c=>this._handleKey(c.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Oe(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(wt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Qb+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
29
29
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qb+1&&(this._liveRegion.textContent+=tp.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\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,a=n.lines.length.toString();for(let o=e;o<=t;o++){let c=n.lines.get(n.ydisp+o),d=[],p=c?.translateToString(!0,void 0,void 0,d)||"",m=(n.ydisp+o+1).toString(),f=this._rowElements[o];f&&(p.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=p,this._rowColumns.set(f,d)),f.setAttribute("aria-posinset",m),f.setAttribute("aria-setsize",a),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,a=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===c||e.relatedTarget!==a)return;let d,p;if(t===0?(d=n,p=this._rowElements.pop(),this._rowContainer.removeChild(p)):(d=this._rowElements.shift(),p=n,this._rowContainer.removeChild(d)),d.removeEventListener("focus",this._topBoundaryFocusListener),p.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let m=this._createAccessibilityTreeNode();this._rowElements.unshift(m),this._rowContainer.insertAdjacentElement("afterbegin",m)}else{let m=this._createAccessibilityTreeNode();this._rowElements.push(m),this._rowContainer.appendChild(m)}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 a=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(a)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:a,offset:a.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let o=({node:p,offset:m})=>{let f=p instanceof Text?p.parentNode:p,b=parseInt(f?.getAttribute("aria-posinset"),10)-1;if(isNaN(b))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(f);if(!y)return console.warn("columns is null. Race condition?"),null;let S=m<y.length?y[m]:y.slice(-1)[0]+1;return S>=this._terminal.cols&&(++b,S=0),{row:b,column:S}},c=o(t),d=o(n);if(!(!c||!d)){if(c.row>d.row||c.row===d.row&&c.column>=d.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(d.row-c.row)*this._terminal.cols-c.column+d.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);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 a=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${a/t})`}};xu=zt([ye(1,Dm),ye(2,wn),ye(3,Cn)],xu);var zp=class extends We{constructor(e,t,n,a,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=a,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new _e),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new _e),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(wt(()=>{Pr(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(Oe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Oe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Oe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Oe(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 a=0;a<n.length;a++){let o=n[a];if(o.classList.contains("xterm"))break;if(o.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(a=>{a?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[a,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(a)&&(n=this._checkLinkProviderResult(a,e,n)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let d=c?.map(p=>({link:p}));this._activeProviderReplies?.set(a,d),n=this._checkLinkProviderResult(a,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let a=0;a<t.size;a++){let o=t.get(a);if(o)for(let c=0;c<o.length;c++){let d=o[c],p=d.link.range.start.y<e?0:d.link.range.start.x,m=d.link.range.end.y>e?this._bufferService.cols:d.link.range.end.x;for(let f=p;f<=m;f++){if(n.has(f)){o.splice(c--,1);break}n.add(f)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let a=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&a){let c=a.find(d=>this._linkAtPosition(d.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;c<this._activeProviderReplies.size;c++){let d=this._activeProviderReplies.get(c)?.find(p=>this._linkAtPosition(p.link,t));if(d){n=!0,this._handleNewLink(d);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&&XD(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,Pr(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:n=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:n=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let a=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(a,o),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!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,a=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-a-1,n.end.x,n.end.y-a-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_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,a=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=a}_positionFromMouseEvent(e,t,n){let a=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(a)return{x:a[0],y:a[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,a,o){return{x1:e,y1:t,x2:n,y2:a,cols:this._bufferService.cols,fg:o}}};zp=zt([ye(1,Rm),ye(2,Cn),ye(3,Hi),ye(4,H0)],zp);function XD(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 GD=class extends KD{constructor(e={}){super(e),this._linkifier=this._register(new ja),this.browser=sw,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ja),this._onCursorMove=this._register(new _e),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new _e),this.onKey=this._onKey.event,this._onRender=this._register(new _e),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new _e),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new _e),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new _e),this.onBell=this._onBell.event,this._onFocus=this._register(new _e),this._onBlur=this._register(new _e),this._onA11yCharEmitter=this._register(new _e),this._onA11yTabEmitter=this._register(new _e),this._onWillOpen=this._register(new _e),this._setup(),this._decorationService=this._instantiationService.createInstance(WD),this._instantiationService.setService(ko,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Uk),this._instantiationService.setService(H0,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(sp)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(wi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(wi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(wi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(wi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(wt(()=>{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 n,a="";switch(t.index){case 256:n="foreground",a="10";break;case 257:n="background",a="11";break;case 258:n="cursor",a="12";break;default:n="ansi",a="4;"+t.index}switch(t.type){case 0:let o=yt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${ue.ESC}]${a};${OD(o)}${tw.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=Xt.toColor(...t.color));else{let c=n;this._themeService.modifyColors(d=>d[c]=Xt.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(xu,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ue.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(ue.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),a=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),c=this._renderService.dimensions.css.cell.width*o,d=this.buffer.y*this._renderService.dimensions.css.cell.height,p=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=p+"px",this.textarea.style.top=d+"px",this.textarea.style.width=c+"px",this.textarea.style.height=a+"px",this.textarea.style.lineHeight=a+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Oe(this.element,"copy",t=>{this.hasSelection()&&eT(t,this._selectionService)}));let e=t=>tT(t,this.textarea,this.coreService,this.optionsService);this._register(Oe(this.textarea,"paste",e)),this._register(Oe(this.element,"paste",e)),nw?this._register(Oe(this.element,"mousedown",t=>{t.button===2&&ob(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Oe(this.element,"contextmenu",t=>{ob(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),jm&&this._register(Oe(this.element,"auxclick",t=>{t.button===1&&R0(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Oe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Oe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Oe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Oe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Oe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Oe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Oe(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new 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(Oe(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),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",ep.get()),lw||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(jk,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(wn,this._coreBrowserService),this._register(Oe(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Oe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(xp,this._document,this._helperContainer),this._instantiationService.setService(Hu,this._charSizeService),this._themeService=this._instantiationService.createInstance(Dp),this._instantiationService.setService(Ka,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Su),this._instantiationService.setService(j0,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Tp,this.rows,this.screenElement)),this._instantiationService.setService(Cn,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Sp,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Ep),this._instantiationService.setService(Rm,this._mouseService);let a=this._linkifier.value=this._register(this._instantiationService.createInstance(zp,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(yp,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(kp,this.element,this.screenElement,a)),this._instantiationService.setService(cT,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(wi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(bp,this.screenElement)),this._register(Oe(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),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(xu,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(bu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(bu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Cp,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(c){let d=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!d)return!1;let p,m;switch(c.overrideType||c.type){case"mousemove":m=32,c.buttons===void 0?(p=3,c.button!==void 0&&(p=c.button<3?c.button:3)):p=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":m=0,p=c.button<3?c.button:3;break;case"mousedown":m=1,p=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let f=c.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;m=f<0?0:1,p=4;break;default:return!1}return m===void 0||p===void 0||p>4?!1:e.coreMouseService.triggerMouseEvent({col:d.col,row:d.row,x:d.x,y:d.y,button:p,action:m,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let a={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:c=>(n(c),c.buttons||(this._document.removeEventListener("mouseup",a.mouseup),a.mousedrag&&this._document.removeEventListener("mousemove",a.mousedrag)),this.cancel(c)),wheel:c=>(n(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&n(c)},mousemove:c=>{c.buttons||n(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),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()),c&8?a.mousemove||(t.addEventListener("mousemove",o.mousemove),a.mousemove=o.mousemove):(t.removeEventListener("mousemove",a.mousemove),a.mousemove=null),c&16?a.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),a.wheel=o.wheel):(t.removeEventListener("wheel",a.wheel),a.wheel=null),c&2?a.mouseup||(a.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",a.mouseup),a.mouseup=null),c&4?a.mousedrag||(a.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",a.mousedrag),a.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Oe(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return n(c),a.mouseup&&this._document.addEventListener("mouseup",a.mouseup),a.mousedrag&&this._document.addEventListener("mousemove",a.mousedrag),this.cancel(c)})),this._register(Oe(t,"wheel",c=>{if(!a.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let d=ue.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(c,!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){D0(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 new 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 new 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=FD(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let a=this.rows-1;return this.scrollLines(n.type===2?-a:a),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===ue.ETX||n.key===ue.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)&&(ZD(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(Vt));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(ue.ESC+"[I"):this.coreService.triggerDataEvent(ue.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ue.ESC}[4;${n};${t}t`);break;case 1:let a=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${ue.ESC}[6;${o};${a}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function ZD(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var QD=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 new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},JD=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 Es)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Jb=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 JD(t)}getNullCell(){return new Es}},eR=class extends We{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new _e),this.onBufferChange=this._onBufferChange.event,this._normal=new Jb(this._core.buffers.normal,"normal"),this._alternate=new Jb(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 new 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)}},tR=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,a)=>t(n,a.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)}},iR=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}},sR=["cols","rows"],qs=0,nR=class extends We{constructor(e){super(),this._core=this._register(new GD(e)),this._addonManager=this._register(new QD),this._publicOptions={...this._core.options};let t=a=>this._core.options[a],n=(a,o)=>{this._checkReadonlyOptions(a),this._core.options[a]=o};for(let a in this._core.options){let o={get:t.bind(this,a),set:n.bind(this,a)};Object.defineProperty(this._publicOptions,a,o)}}_checkReadonlyOptions(e){if(sR.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new 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||(this._parser=new tR(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new iR(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._buffer=this._register(new eR(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
|
|
30
30
|
`,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 ep.get()},set promptLabel(e){ep.set(e)},get tooMuchOutput(){return tp.get()},set tooMuchOutput(e){tp.set(e)}}}_verifyIntegers(...e){for(qs of e)if(qs===1/0||isNaN(qs)||qs%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(qs of e)if(qs&&(qs===1/0||isNaN(qs)||qs%1!==0||qs<0))throw new Error("This API only accepts positive integers")}};class rR{pending=null;accept(t){let n="";for(const a of t)n+=this.acceptChar(a);return n}acceptChar(t){return t===""?this.acceptBackspace():bw.has(t)?this.acceptConsonant(t):Sw.has(t)?this.acceptVowel(t):cR(t)&&this.canReplacePendingWith(t)?(this.pending=tS(t),""):this.flushPending()+t}acceptConsonant(t){if(!this.pending)return this.pending={initial:t},"";if(!this.pending.vowel){const o=this.flushPending();return this.pending={initial:t},o}if(!this.pending.final){if(ww.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const n=oR.get(`${this.pending.final}${t}`);if(n)return this.pending.final=n,"";const a=this.flushPending();return this.pending={initial:t},a}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=lR.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const n=eS.get(this.pending.final);if(n){this.pending.final=n[0];const c=this.flushPending();return this.pending={initial:n[1],vowel:t},c}const a=this.pending.final,o=iS({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:a,vowel:t},o}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=eS.get(this.pending.final);return t?this.pending.final=t[0]:delete this.pending.final,""}return this.pending.vowel?(delete this.pending.vowel,""):(this.pending=null,"")}canReplacePendingWith(t){if(!this.pending?.initial)return!1;const n=tS(t);return n.initial===this.pending.initial&&(!this.pending.vowel||n.vowel===this.pending.vowel)&&(!this.pending.final||n.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=iS(this.pending);return this.pending=null,t}}const Eu=44032,Tu=21,Aa=28,aR=19*Tu*Aa,vw=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],gw=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],yw=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],bw=Hm(vw),Sw=Hm(gw),ww=Hm(yw),lR=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),Cw=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],oR=new Map(Cw),eS=new Map(Cw.map(([e,t])=>[t,[e[0],e[1]]]));function Hm(e){return new Map(e.map((t,n)=>[t,n]))}function cR(e){const t=e.codePointAt(0);return t!==void 0&&t>=Eu&&t<Eu+aR}function tS(e){const t=e.codePointAt(0)-Eu,n=Math.floor(t/(Tu*Aa)),a=Math.floor(t%(Tu*Aa)/Aa),o=t%Aa,c={initial:vw[n],vowel:gw[a]};return o===0?c:{...c,final:yw[o]}}function iS(e){if(!e.vowel)return e.initial;const t=bw.get(e.initial),n=Sw.get(e.vowel),a=e.final?ww.get(e.final):0;return t===void 0||n===void 0||a===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(Eu+(t*Tu+n)*Aa+a)}const uR=[{key:"escape",label:"Esc",ariaLabel:"Send Escape"},{key:"tab",label:"Tab",ariaLabel:"Send Tab"},{key:"arrowLeft",label:"←",ariaLabel:"Send Arrow Left"},{key:"arrowDown",label:"↓",ariaLabel:"Send Arrow Down"},{key:"arrowUp",label:"↑",ariaLabel:"Send Arrow Up"},{key:"arrowRight",label:"→",ariaLabel:"Send Arrow Right"}];function hR({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:a,onHide:o}){function c(d){d.stopPropagation(),a()}return _.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[_.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-ctrl","aria-label":"Arm Control modifier","aria-pressed":e,"data-active":e,onClick:t,children:"Ctrl"}),uR.map(d=>_.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":d.ariaLabel,onClick:()=>n(d.key),children:d.label},d.key)),_.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const dR={escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function fR(e){return dR[e]}function pR(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const Mo=new Map,mo=new Map,mR=Object.freeze({open:!1,text:""});function _R(e){let t=mo.get(e);return t||(t=new Set,mo.set(e,t)),t}function xw(e){const t=mo.get(e);if(t)for(const n of Array.from(t))n()}function Um(e){return Mo.get(e)??mR}function vR(e,t){const n=_R(e);return n.add(t),()=>{n.delete(t)}}function gR(e,t){const n=Um(e);n.open!==t&&(Mo.set(e,{...n,open:t}),xw(e))}function yR(e,t){const n=Um(e);n.text!==t&&(Mo.set(e,{...n,text:t}),xw(e))}function sS(e){Mo.delete(e),mo.delete(e)}function bR(){Mo.clear(),mo.clear()}const SR=20;function wR({terminalId:e,onSubmit:t,disabled:n=!1}){const a=g.useMemo(()=>S=>vR(e,S),[e]),o=g.useMemo(()=>()=>Um(e),[e]),c=g.useSyncExternalStore(a,o,o),{open:d,text:p}=c,m=g.useRef(null);g.useEffect(()=>{d&&m.current?.focus()},[d]);function f(S){gR(e,S)}function b(S){yR(e,S)}function y(){if(n||!p)return;const S=p.replace(/\r\n/g,`
|
|
31
|
-
`).replace(/\n/g,"\r");S&&t(S),window.setTimeout(()=>t("\r"),SR),b(""),m.current?.focus()}return _.jsxs("div",{className:"compose-drawer","data-open":d?"true":"false",children:[_.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":d?"true":void 0,tabIndex:d?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>f(!0),children:[_.jsx("span",{"aria-hidden":"true",children:"▴"}),_.jsx("span",{children:"compose"}),p?_.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),_.jsxs("div",{className:"compose-drawer-panel","aria-hidden":d?void 0:"true",children:[_.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:d?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:()=>f(!1),children:[_.jsx("span",{"aria-hidden":"true",children:"▾"}),_.jsx("span",{className:"compose-drawer-title",children:"compose"}),_.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),_.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),_.jsx("textarea",{ref:m,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:d?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:p,onChange:S=>b(S.target.value),onKeyDown:S=>{if(S.key==="Enter"&&(S.metaKey||S.ctrlKey)){S.preventDefault(),y();return}S.key==="Escape"&&(S.preventDefault(),f(!1))},placeholder:"Type a longer command here, then Cmd/Ctrl+Enter to send."}),_.jsxs("div",{className:"compose-drawer-actions",children:[_.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:d?0:-1,onClick:()=>{b(""),m.current?.focus()},disabled:!p,children:"Clear"}),_.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:d?0:-1,onClick:y,disabled:n||!p,children:"Send"})]})]})]})}function CR(e){e.attachCustomKeyEventHandler(o=>{if(xR(o)){const c=nS(e);return c?(o.preventDefault(),o.stopPropagation(),rS(c),!1):!0}return ER(o)?(o.preventDefault(),o.stopPropagation(),TR(e),!1):!0});const t=e.element;if(!t)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const n=o=>{const c=nS(e);if(c){if(o.clipboardData){o.clipboardData.setData("text/plain",c),o.preventDefault();return}o.preventDefault(),rS(c)}},a=o=>{const c=o.clipboardData?.getData("text/plain");if(c===void 0)return;const d=Ew(c);d!==c&&(o.preventDefault(),o.stopImmediatePropagation(),e.paste(d))};return t.addEventListener("copy",n,!0),t.addEventListener("paste",a,!0),{dispose(){t.removeEventListener("copy",n,!0),t.removeEventListener("paste",a,!0),e.attachCustomKeyEventHandler(()=>!0)}}}function xR(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function ER(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="v"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}async function TR(e){if(navigator.clipboard?.readText)try{const t=await navigator.clipboard.readText();if(!t)return;e.paste(Ew(t))}catch{}}function nS(e){return e.hasSelection()?e.getSelection():""}function Ew(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}async function rS(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}kR(e)}function kR(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.style.opacity="0",document.body.appendChild(n),n.focus({preventScroll:!0}),n.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{n.remove(),t?.focus({preventScroll:!0})}}const DR=[4,10,11,12];function RR(e,t){const n=[e.parser.registerCsiHandler({final:"c"},a=>aS(a)),e.parser.registerCsiHandler({prefix:">",final:"c"},a=>aS(a)),e.parser.registerCsiHandler({final:"n"},a=>MR(a)),e.parser.registerCsiHandler({prefix:"?",final:"n"},a=>NR(a)),e.parser.registerCsiHandler({final:"t"},a=>AR(a)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...DR.map(a=>e.parser.registerOscHandler(a,o=>LR(o)))];return{dispose(){for(const a of n)a.dispose()}}}function aS(e){return Ku(e)===0}function MR(e){const t=Ku(e);return t===5||t===6}function NR(e){return Ku(e)===6}function AR(e){const t=Ku(e);return t===14||t===16||t===18}function LR(e){return e.split(";").some(t=>t==="?")}function Ku(e){const t=e[0];return typeof t=="number"?t:0}const Ha=new Map,BR=2*1024*1024,OR=1500,zR=25e3;function jR(e,t){let n=Ha.get(e);n||(n=UR(e),Ha.set(e,n),Pm(n)),n.listeners.add(t);const a=c=>IR(n,c),o=()=>{n.listeners.delete(t)};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:a,detach:o}}function jp(e){const t=Ha.get(e);t&&(FR(t),Ha.delete(e))}function HR(e){const t=Ha.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),Iu(t);const n=t.socket;return t.socket=null,Ma(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),Pm(t),!0}function lS(){for(const e of Array.from(Ha.keys()))jp(e)}function UR(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],listeners:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,isAlive:!1,exited:!1}}function Pm(e){if(!e.reconnectEnabled)return;Ma(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,e.isAlive=!1,t.addEventListener("open",()=>{if(e.socket===t){Ma(e,"connected");for(const n of e.pendingOut)t.send(JSON.stringify(n));e.pendingOut.length=0,e.isAlive=!0,PR(e)}}),t.addEventListener("message",n=>{if(e.socket!==t)return;const a=typeof n.data=="string"?n.data:"";if(!a)return;let o=null;try{o=JSON.parse(a)}catch{return}if(!(!o||typeof o.type!="string")){if(o.type==="pong"){e.isAlive=!0;return}KR(e,o),Tw(e,{type:"message",message:o})}}),t.addEventListener("close",n=>{if(e.socket===t){if(e.socket=null,Iu(e),n.code===1008){e.reconnectEnabled=!1,Ma(e,"unauthorized");return}if(e.exited||!e.reconnectEnabled){Ma(e,"closed");return}Ma(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Pm(e)},OR)}}),t.addEventListener("error",()=>{})}function PR(e){Iu(e),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!(!t||t.readyState!==WebSocket.OPEN)){if(!e.isAlive){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:Date.now().toString(36)}))}},zR)}function Iu(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null)}function KR(e,t){if(t.type==="snapshot"){e.snapshot=t.terminal,e.output=t.output.slice(),e.history=t.history??null,e.outputBytes=e.output.reduce((n,a)=>n+a.length,0),e.exited=t.terminal.status==="exited",oS(e);return}if(t.type==="output"){e.output.push(t.data),e.outputBytes+=t.data.length,oS(e);return}if(t.type==="terminal_updated"){e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0);return}if(t.type==="exit"){e.exited=!0,e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode});return}}function oS(e){for(;e.outputBytes>BR&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function Ma(e,t){e.status!==t&&(e.status=t,Tw(e,{type:"status",status:t}))}function Tw(e,t){for(const n of Array.from(e.listeners))n(t)}function IR(e,t){const n=e.socket;return n&&n.readyState===WebSocket.OPEN?(n.send(JSON.stringify(t)),!0):(t.type==="input"&&e.pendingOut.push(t),!1)}function FR(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Iu(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const qR=[0,50,150,350],WR=[300,1200,2500],cS=1e3,$R=1e5,Hp="\x1B[?1049l\x1B[?1047l\x1B[?47l",YR=new Set(["47","1047","1049"]),kw=400,VR=6,uS=[500,1500,3e3,5e3,8e3],XR=ii.lazy(()=>km(()=>import("./TranscriptMarkdownBody-CDp3EzWK.js"),__vite__mapDeps([2,1])));function hS({terminal:e,serverApi:t,active:n,visible:a=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:d,onSelect:p,onClose:m,onExit:f,onSnapshot:b,onAuthClose:y}){const S=g.useSyncExternalStore(p0,$f,()=>zr),E=g.useSyncExternalStore(m0,Yf,()=>Oa),x=g.useSyncExternalStore(_0,Xf,()=>!0),T=g.useSyncExternalStore(x0,lr,()=>vu),B=g.useRef(null),M=g.useRef(null),V=g.useRef(null),I=g.useRef(null),X=g.useRef({onExit:f,onSnapshot:b}),le=g.useRef(t.createWebSocketUrl),ee=g.useRef(y),te=g.useRef(null),ce=g.useRef(new Map),pe=g.useRef([]),A=g.useRef([]),P=g.useRef([]),K=g.useRef(0),j=g.useRef(!1),O=g.useRef(null),Q=g.useRef(0),D=g.useRef(null),q=g.useRef(null),Z=g.useRef(!1),ve=g.useRef(!1),be=g.useRef(!1),R=g.useRef(0),Y=g.useRef(null),se=g.useRef(null),fe=g.useRef(null),he=g.useRef(null),de=g.useRef(!1),Se=g.useRef(!1),Be=g.useRef(!1),Ae=g.useRef(!1),Re=g.useRef(!1),ze=g.useRef(!1),He=g.useRef(!1),Te=g.useRef(n),ne=g.useRef(a),De=g.useRef(c),xe=g.useRef(S),je=g.useRef(E),[,Pe]=g.useState("connecting"),[_t,rt]=g.useState(!1),[Ci,J]=g.useState(null),[Ke,Ne]=g.useState(!1),[bt,xi]=g.useState(null),[Ei,ni]=g.useState(!1),[us,Li]=g.useState(!1),[Pi,zs]=g.useState(!1),[fi,Ct]=g.useState(null),[pi,xt]=g.useState(!1),[Xs,hs]=g.useState(!1);g.useLayoutEffect(()=>{Te.current=n},[n]),g.useLayoutEffect(()=>{ne.current=a},[a]),g.useLayoutEffect(()=>{De.current=c},[c]),g.useLayoutEffect(()=>{xe.current=S},[S]),g.useLayoutEffect(()=>{je.current=E},[E]),g.useEffect(()=>{a&&n&&e.status==="running"&&(it(),Oi())},[n,a,e.status]),g.useEffect(()=>{X.current={onExit:f,onSnapshot:b}},[f,b]),g.useEffect(()=>{le.current=t.createWebSocketUrl,ee.current=y},[t,y]),g.useEffect(()=>{let z=!1,C=null,k=0;const H=lM(e.currentCommand);function re(){C!==null&&(window.clearTimeout(C),C=null)}function me(){if(!H||k>=uS.length||z)return;const ge=uS[k++];C=window.setTimeout(()=>{C=null,Ee()},ge)}async function Ee(){try{const ge=await t.getTerminalTranscriptSource(e.id);if(z)return;Ct(ge.source),ge.source||me()}catch(ge){if(z)return;Ct(null),Tf(ge)&&me()}}return Ct(null),e.status!=="running"?()=>{z=!0,re()}:(Ee(),()=>{z=!0,re()})},[t,e.currentCommand,e.id,e.status]),g.useEffect(()=>{xt(!1)},[e.id,fi?.provider,fi?.sessionId]),g.useEffect(()=>{const z=M.current;z&&(z.options.disableStdin=e.status==="exited"),e.status==="exited"&&Pe("closed")},[e.status]),g.useEffect(()=>{const z=M.current;z&&(z.options.fontSize=S,of(S,je.current).then(()=>{xe.current===S&&it()}))},[S]),g.useEffect(()=>{const z=M.current;z&&(z.options.fontFamily=Wf(E),of(xe.current,E).then(()=>{je.current===E&&it()}))},[E]),g.useEffect(()=>{const z=M.current;z&&(z.options.theme=dS(T))},[T]),g.useEffect(()=>{const z=B.current;if(!z)return;let C=!1,k=null,H=null,re=null,me=null,Ee=null,ge=null,Qe=null;te.current=null,Re.current=!1,ze.current=!1,Y.current=null,se.current=null,st(),ks();const Je=xe.current,Ri=je.current,vi=new nR({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:Wf(Ri),fontSize:Je,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:$R,theme:{...dS(lr())}}),Xr=new X2;return vi.loadAddon(Xr),me=RR(vi),M.current=vi,V.current=Xr,of(Je,Ri).then(()=>{if(C)return;vi.open(z),Re.current=!0,k=CR(vi),ne.current&&Te.current&&e.status==="running"&&Oi(),it(),Ee=_M(z,vi,()=>xe.current*1.2,Ft,Ns=>{jt(Ns)},xn,Ki),ge=fM(z,vi,Ft,Ns=>{jt(Ns)},xn,Ki);const En=new rR;H=vi.onData(Ns=>{if(He.current){const Gs=pR(Ns);if(Gs){Vr(!1),Ji(Gs);return}}const $a=En.accept(Ns);$a&&Ji($a)}),re=vi.onScroll(Ns=>{if(Se.current||Ae.current||Be.current){Mt();return}Zt(),ir(vi)&&Rs({scrollToBottom:!0}),Ft(),Ns<=3&&jt()}),Qe=new ResizeObserver(()=>{ki()}),Qe.observe(z),ze.current&&(mt(),ze.current=!1,it()),Rt()}),()=>{C=!0,Re.current=!1,ze.current=!1,st(),Di(),Nt(),Be.current=!1,Ee?.(),ge?.(),Qe?.disconnect(),k?.dispose(),H?.dispose(),re?.dispose(),me?.dispose(),vi.dispose(),M.current=null,V.current=null}},[e.id]),g.useEffect(()=>{const z=le.current(e.id),C=jR(z,hr);return I.current=C.send,Pe(C.status),C.status==="connected"&&it(),C.snapshot&&(X.current.onSnapshot(C.snapshot,{notifyCompletion:!1}),M.current&&(it(),Bi(C.output,C.history),it())),()=>{C.detach(),I.current=null}},[e.id,e.status]);function hr(z){if(z.type==="status"){Pe(z.status),z.status==="unauthorized"&&ee.current?.(),z.status==="connected"&&it();return}Tt(z.message)}function ks(z=[],C=null){A.current=[],P.current=mS(z),K.current=0,j.current=!1,O.current=null,Be.current=!1,Q.current+=1,D.current=C,q.current=null,Z.current=!1,ve.current=!1,be.current=!1,ze.current=!1,fe.current=null,de.current=!1,rt(!1),J(null),Ne(!1),xi(null),ni(!1),Li(!1)}function Bi(z=[],C=null){ks(z,C),dt()}function dt(){if(!M.current||!Re.current){ze.current=!0;return}ze.current=!1,mt()}async function mt(){const z=M.current;if(!z)return;const C=Zc(z,de.current),k=C?P.current.length:K.current;await Et(z,{liveOutputLimit:k,scrollToBottom:C}),M.current===z&&Mt()}function Et(z,C={}){return new Promise(k=>{Be.current=!0,j.current=!1;const H=Q.current+1;Q.current=H;const re=Math.max(0,Math.min(C.liveOutputLimit??P.current.length,P.current.length)),me=()=>{if(M.current!==z||Q.current!==H){k();return}try{K.current=re,C.scrollToBottom&&js(z)}finally{Be.current=!1;const ge=qr();ge&&Rs(ge),k()}},Ee=()=>{if(M.current!==z||Q.current!==H){k();return}z.clear();const ge=mS([...A.current,...P.current.slice(0,re)]);if(ge.length===0){me();return}for(let Qe=0;Qe<ge.length;Qe+=1){const Je=ge[Qe];Qe===ge.length-1?z.write(Je,me):z.write(Je)}};if(z.buffer.active.type==="alternate"){z.write(Hp,Ee);return}Ee()})}async function jt(z=0){const C=M.current;if(be.current||!C)return;const k=D.current;be.current=!0,rt(!0);const H=C.buffer.active.viewportY;try{let re=!!(k&&!k.hasMore);if(!re)try{const me=await t.getTerminalHistory(e.id,{beforeLine:k?.startLine??0,limit:cS});if(D.current={startLine:me.startLine,endLine:me.endLine,hasMore:me.hasMore},me.output.length>0){await Ht(C,me.output,H,z);return}re=!me.hasMore}catch(me){re=Tf(me)}re&&await Gt(C,H,z)}catch{}finally{be.current=!1,rt(!1)}}async function Gt(z,C,k){if(!(Z.current||ve.current))try{const H=q.current,re=await t.getTerminalTranscriptHistory(e.id,{...H?{cursor:H}:{},limit:kw});Ct(re.source),q.current=re.cursor,ve.current=!re.hasMore||!re.cursor;const me=re.output.map(Rw);if(me.length===0)return;await Ht(z,me,C,k)}catch(H){Tf(H)&&(Z.current=!0)}}async function Ht(z,C,k,H){A.current=[...C,...A.current];const re=hM(C);await Et(z,{liveOutputLimit:K.current,scrollToBottom:!1}),M.current===z&&(_i(z,Math.max(0,k+re+Math.min(0,H))),de.current=!ir(z),Ft())}g.useEffect(()=>{const z=window.visualViewport;function C(){document.visibilityState==="visible"&&it()}function k(){it()}function H(){Rt()}return document.addEventListener("visibilitychange",C),window.addEventListener("pageshow",k),window.addEventListener("resize",H),z?.addEventListener("resize",H),z?.addEventListener("scroll",H),()=>{document.removeEventListener("visibilitychange",C),window.removeEventListener("pageshow",k),window.removeEventListener("resize",H),z?.removeEventListener("resize",H),z?.removeEventListener("scroll",H)}},[e.id]);function ri(){const z=le.current(e.id),C=R.current+1;R.current=C,Y.current={generation:C,snapshot:null},se.current=C,Pe("reconnecting"),HR(z),Ti(C)}async function Ti(z){try{const C=await t.getTerminalHistory(e.id,{limit:cS});if(R.current!==z)return;const k=Y.current,H=k?.generation===z?k.snapshot:null;Y.current=null,H&&(se.current=null);const re={startLine:C.startLine,endLine:C.endLine,hasMore:C.hasMore};if(C.output.length>0){Bi(C.output,re);return}H?Bi(H.output,H.history):se.current=null}catch{if(R.current!==z)return;const C=Y.current,k=C?.generation===z?C.snapshot:null;Y.current=null,se.current=null,k&&Bi(k.output,k.history)}}function Tt(z){if(z.type==="snapshot"&&z.terminal.id===e.id){if(X.current.onSnapshot(z.terminal,{notifyCompletion:!1}),!M.current)return;it();const H=Y.current;if(H){H.snapshot={output:z.output,history:z.history??null},it();return}if(se.current!==null){se.current=null,it();return}Bi(z.output,z.history??null),it();return}if(z.type==="terminal_updated"&&z.terminal.id===e.id){X.current.onSnapshot(z.terminal,{notifyCompletion:!0});return}if(z.type==="output"&&z.terminalId===e.id){const k=Aw(z.data);if(!k)return;P.current.push(k),M.current&&Re.current?Rs({scrollToBottom:!0}):ze.current=!0;return}const C=M.current;if(C){if(z.type==="exit"&&z.terminalId===e.id){X.current.onExit(z.exitCode),Pe("closed");return}z.type==="error"&&C.writeln(`\r
|
|
31
|
+
`).replace(/\n/g,"\r");S&&t(S),window.setTimeout(()=>t("\r"),SR),b(""),m.current?.focus()}return _.jsxs("div",{className:"compose-drawer","data-open":d?"true":"false",children:[_.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":d?"true":void 0,tabIndex:d?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>f(!0),children:[_.jsx("span",{"aria-hidden":"true",children:"▴"}),_.jsx("span",{children:"compose"}),p?_.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),_.jsxs("div",{className:"compose-drawer-panel","aria-hidden":d?void 0:"true",children:[_.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:d?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:()=>f(!1),children:[_.jsx("span",{"aria-hidden":"true",children:"▾"}),_.jsx("span",{className:"compose-drawer-title",children:"compose"}),_.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),_.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),_.jsx("textarea",{ref:m,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:d?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:p,onChange:S=>b(S.target.value),onKeyDown:S=>{if(S.key==="Enter"&&(S.metaKey||S.ctrlKey)){S.preventDefault(),y();return}S.key==="Escape"&&(S.preventDefault(),f(!1))},placeholder:"Type a longer command here, then Cmd/Ctrl+Enter to send."}),_.jsxs("div",{className:"compose-drawer-actions",children:[_.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:d?0:-1,onClick:()=>{b(""),m.current?.focus()},disabled:!p,children:"Clear"}),_.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:d?0:-1,onClick:y,disabled:n||!p,children:"Send"})]})]})]})}function CR(e){e.attachCustomKeyEventHandler(o=>{if(xR(o)){const c=nS(e);return c?(o.preventDefault(),o.stopPropagation(),rS(c),!1):!0}return ER(o)?(o.preventDefault(),o.stopPropagation(),TR(e),!1):!0});const t=e.element;if(!t)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const n=o=>{const c=nS(e);if(c){if(o.clipboardData){o.clipboardData.setData("text/plain",c),o.preventDefault();return}o.preventDefault(),rS(c)}},a=o=>{const c=o.clipboardData?.getData("text/plain");if(c===void 0)return;const d=Ew(c);d!==c&&(o.preventDefault(),o.stopImmediatePropagation(),e.paste(d))};return t.addEventListener("copy",n,!0),t.addEventListener("paste",a,!0),{dispose(){t.removeEventListener("copy",n,!0),t.removeEventListener("paste",a,!0),e.attachCustomKeyEventHandler(()=>!0)}}}function xR(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function ER(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="v"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}async function TR(e){if(navigator.clipboard?.readText)try{const t=await navigator.clipboard.readText();if(!t)return;e.paste(Ew(t))}catch{}}function nS(e){return e.hasSelection()?e.getSelection():""}function Ew(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}async function rS(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}kR(e)}function kR(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.style.opacity="0",document.body.appendChild(n),n.focus({preventScroll:!0}),n.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{n.remove(),t?.focus({preventScroll:!0})}}const DR=[4,10,11,12];function RR(e,t){const n=[e.parser.registerCsiHandler({final:"c"},a=>aS(a)),e.parser.registerCsiHandler({prefix:">",final:"c"},a=>aS(a)),e.parser.registerCsiHandler({final:"n"},a=>MR(a)),e.parser.registerCsiHandler({prefix:"?",final:"n"},a=>NR(a)),e.parser.registerCsiHandler({final:"t"},a=>AR(a)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...DR.map(a=>e.parser.registerOscHandler(a,o=>LR(o)))];return{dispose(){for(const a of n)a.dispose()}}}function aS(e){return Ku(e)===0}function MR(e){const t=Ku(e);return t===5||t===6}function NR(e){return Ku(e)===6}function AR(e){const t=Ku(e);return t===14||t===16||t===18}function LR(e){return e.split(";").some(t=>t==="?")}function Ku(e){const t=e[0];return typeof t=="number"?t:0}const Ha=new Map,BR=2*1024*1024,OR=1500,zR=25e3;function jR(e,t){let n=Ha.get(e);n||(n=UR(e),Ha.set(e,n),Pm(n)),n.listeners.add(t);const a=c=>IR(n,c),o=()=>{n.listeners.delete(t)};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:a,detach:o}}function jp(e){const t=Ha.get(e);t&&(FR(t),Ha.delete(e))}function HR(e){const t=Ha.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),Iu(t);const n=t.socket;return t.socket=null,Ma(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),Pm(t),!0}function lS(){for(const e of Array.from(Ha.keys()))jp(e)}function UR(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],listeners:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,isAlive:!1,exited:!1}}function Pm(e){if(!e.reconnectEnabled)return;Ma(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,e.isAlive=!1,t.addEventListener("open",()=>{if(e.socket===t){Ma(e,"connected");for(const n of e.pendingOut)t.send(JSON.stringify(n));e.pendingOut.length=0,e.isAlive=!0,PR(e)}}),t.addEventListener("message",n=>{if(e.socket!==t)return;const a=typeof n.data=="string"?n.data:"";if(!a)return;let o=null;try{o=JSON.parse(a)}catch{return}if(!(!o||typeof o.type!="string")){if(o.type==="pong"){e.isAlive=!0;return}KR(e,o),Tw(e,{type:"message",message:o})}}),t.addEventListener("close",n=>{if(e.socket===t){if(e.socket=null,Iu(e),n.code===1008){e.reconnectEnabled=!1,Ma(e,"unauthorized");return}if(e.exited||!e.reconnectEnabled){Ma(e,"closed");return}Ma(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Pm(e)},OR)}}),t.addEventListener("error",()=>{})}function PR(e){Iu(e),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!(!t||t.readyState!==WebSocket.OPEN)){if(!e.isAlive){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:Date.now().toString(36)}))}},zR)}function Iu(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null)}function KR(e,t){if(t.type==="snapshot"){e.snapshot=t.terminal,e.output=t.output.slice(),e.history=t.history??null,e.outputBytes=e.output.reduce((n,a)=>n+a.length,0),e.exited=t.terminal.status==="exited",oS(e);return}if(t.type==="output"){e.output.push(t.data),e.outputBytes+=t.data.length,oS(e);return}if(t.type==="terminal_updated"){e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0);return}if(t.type==="exit"){e.exited=!0,e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode});return}}function oS(e){for(;e.outputBytes>BR&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function Ma(e,t){e.status!==t&&(e.status=t,Tw(e,{type:"status",status:t}))}function Tw(e,t){for(const n of Array.from(e.listeners))n(t)}function IR(e,t){const n=e.socket;return n&&n.readyState===WebSocket.OPEN?(n.send(JSON.stringify(t)),!0):(t.type==="input"&&e.pendingOut.push(t),!1)}function FR(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Iu(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const qR=[0,50,150,350],WR=[300,1200,2500],cS=1e3,$R=1e5,Hp="\x1B[?1049l\x1B[?1047l\x1B[?47l",YR=new Set(["47","1047","1049"]),kw=400,VR=6,uS=[500,1500,3e3,5e3,8e3],XR=ii.lazy(()=>km(()=>import("./TranscriptMarkdownBody-BIzF0d-f.js"),__vite__mapDeps([2,1])));function hS({terminal:e,serverApi:t,active:n,visible:a=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:d,onSelect:p,onClose:m,onExit:f,onSnapshot:b,onAuthClose:y}){const S=g.useSyncExternalStore(p0,$f,()=>zr),E=g.useSyncExternalStore(m0,Yf,()=>Oa),x=g.useSyncExternalStore(_0,Xf,()=>!0),T=g.useSyncExternalStore(x0,lr,()=>vu),B=g.useRef(null),M=g.useRef(null),V=g.useRef(null),I=g.useRef(null),X=g.useRef({onExit:f,onSnapshot:b}),le=g.useRef(t.createWebSocketUrl),ee=g.useRef(y),te=g.useRef(null),ce=g.useRef(new Map),pe=g.useRef([]),A=g.useRef([]),P=g.useRef([]),K=g.useRef(0),j=g.useRef(!1),O=g.useRef(null),Q=g.useRef(0),D=g.useRef(null),q=g.useRef(null),Z=g.useRef(!1),ve=g.useRef(!1),be=g.useRef(!1),R=g.useRef(0),Y=g.useRef(null),se=g.useRef(null),fe=g.useRef(null),he=g.useRef(null),de=g.useRef(!1),Se=g.useRef(!1),Be=g.useRef(!1),Ae=g.useRef(!1),Re=g.useRef(!1),ze=g.useRef(!1),He=g.useRef(!1),Te=g.useRef(n),ne=g.useRef(a),De=g.useRef(c),xe=g.useRef(S),je=g.useRef(E),[,Pe]=g.useState("connecting"),[_t,rt]=g.useState(!1),[Ci,J]=g.useState(null),[Ke,Ne]=g.useState(!1),[bt,xi]=g.useState(null),[Ei,ni]=g.useState(!1),[us,Li]=g.useState(!1),[Pi,zs]=g.useState(!1),[fi,Ct]=g.useState(null),[pi,xt]=g.useState(!1),[Xs,hs]=g.useState(!1);g.useLayoutEffect(()=>{Te.current=n},[n]),g.useLayoutEffect(()=>{ne.current=a},[a]),g.useLayoutEffect(()=>{De.current=c},[c]),g.useLayoutEffect(()=>{xe.current=S},[S]),g.useLayoutEffect(()=>{je.current=E},[E]),g.useEffect(()=>{a&&n&&e.status==="running"&&(it(),Oi())},[n,a,e.status]),g.useEffect(()=>{X.current={onExit:f,onSnapshot:b}},[f,b]),g.useEffect(()=>{le.current=t.createWebSocketUrl,ee.current=y},[t,y]),g.useEffect(()=>{let z=!1,C=null,k=0;const H=lM(e.currentCommand);function re(){C!==null&&(window.clearTimeout(C),C=null)}function me(){if(!H||k>=uS.length||z)return;const ge=uS[k++];C=window.setTimeout(()=>{C=null,Ee()},ge)}async function Ee(){try{const ge=await t.getTerminalTranscriptSource(e.id);if(z)return;Ct(ge.source),ge.source||me()}catch(ge){if(z)return;Ct(null),Tf(ge)&&me()}}return Ct(null),e.status!=="running"?()=>{z=!0,re()}:(Ee(),()=>{z=!0,re()})},[t,e.currentCommand,e.id,e.status]),g.useEffect(()=>{xt(!1)},[e.id,fi?.provider,fi?.sessionId]),g.useEffect(()=>{const z=M.current;z&&(z.options.disableStdin=e.status==="exited"),e.status==="exited"&&Pe("closed")},[e.status]),g.useEffect(()=>{const z=M.current;z&&(z.options.fontSize=S,of(S,je.current).then(()=>{xe.current===S&&it()}))},[S]),g.useEffect(()=>{const z=M.current;z&&(z.options.fontFamily=Wf(E),of(xe.current,E).then(()=>{je.current===E&&it()}))},[E]),g.useEffect(()=>{const z=M.current;z&&(z.options.theme=dS(T))},[T]),g.useEffect(()=>{const z=B.current;if(!z)return;let C=!1,k=null,H=null,re=null,me=null,Ee=null,ge=null,Qe=null;te.current=null,Re.current=!1,ze.current=!1,Y.current=null,se.current=null,st(),ks();const Je=xe.current,Ri=je.current,vi=new nR({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:Wf(Ri),fontSize:Je,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:$R,theme:{...dS(lr())}}),Xr=new X2;return vi.loadAddon(Xr),me=RR(vi),M.current=vi,V.current=Xr,of(Je,Ri).then(()=>{if(C)return;vi.open(z),Re.current=!0,k=CR(vi),ne.current&&Te.current&&e.status==="running"&&Oi(),it(),Ee=_M(z,vi,()=>xe.current*1.2,Ft,Ns=>{jt(Ns)},xn,Ki),ge=fM(z,vi,Ft,Ns=>{jt(Ns)},xn,Ki);const En=new rR;H=vi.onData(Ns=>{if(He.current){const Gs=pR(Ns);if(Gs){Vr(!1),Ji(Gs);return}}const $a=En.accept(Ns);$a&&Ji($a)}),re=vi.onScroll(Ns=>{if(Se.current||Ae.current||Be.current){Mt();return}Zt(),ir(vi)&&Rs({scrollToBottom:!0}),Ft(),Ns<=3&&jt()}),Qe=new ResizeObserver(()=>{ki()}),Qe.observe(z),ze.current&&(mt(),ze.current=!1,it()),Rt()}),()=>{C=!0,Re.current=!1,ze.current=!1,st(),Di(),Nt(),Be.current=!1,Ee?.(),ge?.(),Qe?.disconnect(),k?.dispose(),H?.dispose(),re?.dispose(),me?.dispose(),vi.dispose(),M.current=null,V.current=null}},[e.id]),g.useEffect(()=>{const z=le.current(e.id),C=jR(z,hr);return I.current=C.send,Pe(C.status),C.status==="connected"&&it(),C.snapshot&&(X.current.onSnapshot(C.snapshot,{notifyCompletion:!1}),M.current&&(it(),Bi(C.output,C.history),it())),()=>{C.detach(),I.current=null}},[e.id,e.status]);function hr(z){if(z.type==="status"){Pe(z.status),z.status==="unauthorized"&&ee.current?.(),z.status==="connected"&&it();return}Tt(z.message)}function ks(z=[],C=null){A.current=[],P.current=mS(z),K.current=0,j.current=!1,O.current=null,Be.current=!1,Q.current+=1,D.current=C,q.current=null,Z.current=!1,ve.current=!1,be.current=!1,ze.current=!1,fe.current=null,de.current=!1,rt(!1),J(null),Ne(!1),xi(null),ni(!1),Li(!1)}function Bi(z=[],C=null){ks(z,C),dt()}function dt(){if(!M.current||!Re.current){ze.current=!0;return}ze.current=!1,mt()}async function mt(){const z=M.current;if(!z)return;const C=Zc(z,de.current),k=C?P.current.length:K.current;await Et(z,{liveOutputLimit:k,scrollToBottom:C}),M.current===z&&Mt()}function Et(z,C={}){return new Promise(k=>{Be.current=!0,j.current=!1;const H=Q.current+1;Q.current=H;const re=Math.max(0,Math.min(C.liveOutputLimit??P.current.length,P.current.length)),me=()=>{if(M.current!==z||Q.current!==H){k();return}try{K.current=re,C.scrollToBottom&&js(z)}finally{Be.current=!1;const ge=qr();ge&&Rs(ge),k()}},Ee=()=>{if(M.current!==z||Q.current!==H){k();return}z.clear();const ge=mS([...A.current,...P.current.slice(0,re)]);if(ge.length===0){me();return}for(let Qe=0;Qe<ge.length;Qe+=1){const Je=ge[Qe];Qe===ge.length-1?z.write(Je,me):z.write(Je)}};if(z.buffer.active.type==="alternate"){z.write(Hp,Ee);return}Ee()})}async function jt(z=0){const C=M.current;if(be.current||!C)return;const k=D.current;be.current=!0,rt(!0);const H=C.buffer.active.viewportY;try{let re=!!(k&&!k.hasMore);if(!re)try{const me=await t.getTerminalHistory(e.id,{beforeLine:k?.startLine??0,limit:cS});if(D.current={startLine:me.startLine,endLine:me.endLine,hasMore:me.hasMore},me.output.length>0){await Ht(C,me.output,H,z);return}re=!me.hasMore}catch(me){re=Tf(me)}re&&await Gt(C,H,z)}catch{}finally{be.current=!1,rt(!1)}}async function Gt(z,C,k){if(!(Z.current||ve.current))try{const H=q.current,re=await t.getTerminalTranscriptHistory(e.id,{...H?{cursor:H}:{},limit:kw});Ct(re.source),q.current=re.cursor,ve.current=!re.hasMore||!re.cursor;const me=re.output.map(Rw);if(me.length===0)return;await Ht(z,me,C,k)}catch(H){Tf(H)&&(Z.current=!0)}}async function Ht(z,C,k,H){A.current=[...C,...A.current];const re=hM(C);await Et(z,{liveOutputLimit:K.current,scrollToBottom:!1}),M.current===z&&(_i(z,Math.max(0,k+re+Math.min(0,H))),de.current=!ir(z),Ft())}g.useEffect(()=>{const z=window.visualViewport;function C(){document.visibilityState==="visible"&&it()}function k(){it()}function H(){Rt()}return document.addEventListener("visibilitychange",C),window.addEventListener("pageshow",k),window.addEventListener("resize",H),z?.addEventListener("resize",H),z?.addEventListener("scroll",H),()=>{document.removeEventListener("visibilitychange",C),window.removeEventListener("pageshow",k),window.removeEventListener("resize",H),z?.removeEventListener("resize",H),z?.removeEventListener("scroll",H)}},[e.id]);function ri(){const z=le.current(e.id),C=R.current+1;R.current=C,Y.current={generation:C,snapshot:null},se.current=C,Pe("reconnecting"),HR(z),Ti(C)}async function Ti(z){try{const C=await t.getTerminalHistory(e.id,{limit:cS});if(R.current!==z)return;const k=Y.current,H=k?.generation===z?k.snapshot:null;Y.current=null,H&&(se.current=null);const re={startLine:C.startLine,endLine:C.endLine,hasMore:C.hasMore};if(C.output.length>0){Bi(C.output,re);return}H?Bi(H.output,H.history):se.current=null}catch{if(R.current!==z)return;const C=Y.current,k=C?.generation===z?C.snapshot:null;Y.current=null,se.current=null,k&&Bi(k.output,k.history)}}function Tt(z){if(z.type==="snapshot"&&z.terminal.id===e.id){if(X.current.onSnapshot(z.terminal,{notifyCompletion:!1}),!M.current)return;it();const H=Y.current;if(H){H.snapshot={output:z.output,history:z.history??null},it();return}if(se.current!==null){se.current=null,it();return}Bi(z.output,z.history??null),it();return}if(z.type==="terminal_updated"&&z.terminal.id===e.id){X.current.onSnapshot(z.terminal,{notifyCompletion:!0});return}if(z.type==="output"&&z.terminalId===e.id){const k=Aw(z.data);if(!k)return;P.current.push(k),M.current&&Re.current?Rs({scrollToBottom:!0}):ze.current=!0;return}const C=M.current;if(C){if(z.type==="exit"&&z.terminalId===e.id){X.current.onExit(z.exitCode),Pe("closed");return}z.type==="error"&&C.writeln(`\r
|
|
32
32
|
[nterminal] ${z.message}`)}}function ki(z=25){if(document.visibilityState==="hidden"||!ne.current||ce.current.has(z))return;const C=window.setTimeout(()=>{ce.current.delete(z),$r()},z);ce.current.set(z,C)}function Rt(){for(const z of qR)ki(z)}function it(){te.current=null,Rt()}function st(){for(const z of ce.current.values())window.clearTimeout(z);ce.current.clear()}function Di(){for(const z of pe.current)window.clearTimeout(z);pe.current=[]}function Ft(){if(Mt(),!fe.current){Ne(!1);return}Ne(!0),Nt(),he.current=window.setTimeout(()=>{he.current=null,Ne(!1)},1200)}function Mt(){const z=M.current,C=z?dM(z):null;if(fe.current=C,J(C),Li(!!(z&&C)),ni(!!(z&&C&&!ir(z))),C||!z||!mi()){xi(null);return}xi({alternate:z.buffer.active.type==="alternate"})}function mi(){const z=D.current;return A.current.length>0||!!z?.hasMore}function Nt(){he.current!==null&&(window.clearTimeout(he.current),he.current=null)}function Zt(){const z=M.current;z&&(de.current=!ir(z),Mt())}function Ds(z){O.current=kf(O.current,z)}function dr(z){const C=O.current;return O.current=null,kf(C,z)}function qr(){const z=O.current;return O.current=null,z}function Rs(z={}){const C=M.current;if(!C||!Re.current){ze.current=!0;return}if(Be.current){Ds(z);return}if(j.current){Ds(z);return}const k=dr(z);if(!k.force&&!Zc(C,de.current)){Mt();return}j.current=!0;const H=Q.current,re=()=>{if(M.current!==C||Q.current!==H){j.current=!1;return}if(!k.force&&!Zc(C,de.current)){j.current=!1,Mt();return}const me=K.current,Ee=P.current[me];if(Ee===void 0){j.current=!1,k.scrollToBottom&&js(C),Mt();const ge=qr();ge&&Rs(kf(k,ge));return}K.current=me+1,C.write(Ee,re)};re()}function xn(){Ae.current=!0}function Ki(){Zt(),Ae.current=!1;const z=M.current;z&&ir(z)&&Rs({scrollToBottom:!0})}function js(z){Ii(()=>_S(z))&&(de.current=!1)}function _i(z,C){Ii(()=>(z.scrollToLine(C),!0))}function Ii(z){Se.current=!0;try{return z()}finally{Se.current=!1}}function Hs(){const z=M.current;if(!z)return;const C=()=>{_S(z),de.current=!1,Mt(),Rs({force:!0,scrollToBottom:!0}),Oi()};if(z.buffer.active.type==="alternate"){z.write(Hp,C);return}C()}function Ms(z){const C=M.current,k=B.current;if(!C||!k)return;const H=k.getBoundingClientRect();if(H.height<=0)return;const re=Math.max(0,Math.min(1,(z-H.top)/H.height)),me=Math.round(C.buffer.active.baseY*re);xn();try{C.scrollToLine(me)}finally{Ki()}de.current=!ir(C),Mt(),Ft(),me<=3&&jt()}function At(z){z.preventDefault(),z.stopPropagation(),z.currentTarget.setPointerCapture?.(z.pointerId),Ms(z.clientY)}function Wr(z){(z.buttons&1)!==0&&(z.preventDefault(),z.stopPropagation(),Ms(z.clientY))}function $r(){const z=M.current,C=V.current;if(!(!z||!C)&&!(document.visibilityState==="hidden"||!ne.current||B.current?.isConnected===!1))try{const k=Zc(z,de.current);C.fit(),k&&js(z),z.refresh(0,Math.max(0,z.rows-1)),Mt();const H={cols:z.cols,rows:z.rows},re=te.current;if(re&&re.cols===H.cols&&re.rows===H.rows)return;Qi({type:"resize",terminalId:e.id,cols:H.cols,rows:H.rows})&&(te.current=H)}catch{}}function Qi(z){const C=I.current;return C?C(z):!1}function Ji(z){Rs({force:!0,scrollToBottom:!0}),Qi({type:"input",terminalId:e.id,data:z})&&rM(z)&&Wa()}function Wa(){!De.current||!Te.current||(Di(),pe.current=WR.map(z=>{const C=window.setTimeout(()=>{pe.current=pe.current.filter(k=>k!==C),De.current&&Te.current&&Qi({type:"refresh_cwd",terminalId:e.id})},z);return C}))}function Oi(){M.current?.focus()}function Yr(){zs(z=>{const C=!z;return He.current=C,C}),Oi()}function Vr(z){He.current=z,zs(z)}function Fi(z){He.current&&Vr(!1),Ji(fR(z)),Oi()}return _.jsxs("section",{className:"terminal-pane","data-active":n,onMouseDown:()=>{n||p()},children:[_.jsx(GR,{terminal:e,canClose:o,tabId:d,transcriptSource:fi,onOpenTranscript:()=>xt(!0),onReload:ri,onClose:m}),_.jsx("div",{className:"xterm-container",ref:B}),_t?_.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:_.jsx("span",{"aria-hidden":"true"})}):null,x&&Ci?_.jsxs("div",{className:"terminal-scroll-progress","data-active":Ke,"aria-hidden":"true",children:[Ci.current,"/",Ci.total]}):x&&bt?_.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":bt.alternate?"alternate":"normal","aria-hidden":"true",children:[bt.alternate?"alt ":"","0/?"]}):null,Ei?_.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:z=>z.stopPropagation(),onMouseDown:z=>z.stopPropagation(),onClick:z=>{z.stopPropagation(),Hs()},children:"↓"}):null,us?_.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:At,onPointerMove:Wr,children:_.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?Xs?_.jsx(hR,{ctrlActive:Pi,onCtrl:Yr,onStandaloneKey:Fi,onPreserveFocus:Oi,onHide:()=>hs(!1)}):_.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:z=>{z.stopPropagation(),Oi()},onPointerDown:z=>{z.stopPropagation(),Oi()},onClick:()=>hs(!0),children:"⌨"}):null,_.jsx(wR,{terminalId:e.id,onSubmit:Ji,disabled:e.status!=="running"}),pi&&fi?_.jsx(ZR,{terminal:e,serverApi:t,source:fi,onClose:()=>xt(!1)}):null]})}function dS(e){return{background:"#0a0d10",foreground:"#e2e8ee",cursor:g2(e),selectionBackground:y2(e)}}function GR({terminal:e,canClose:t,tabId:n,transcriptSource:a,onOpenTranscript:o,onReload:c,onClose:d}){const p=i0({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),m={cursor:n?"grab":"default",opacity:p.isDragging?.5:void 0};return _.jsxs("header",{ref:p.setNodeRef,className:"terminal-pane-header",style:m,"data-dragging":p.isDragging,...p.attributes,...p.listeners,children:[_.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),_.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),_.jsx("span",{className:"terminal-pane-spacer"}),a?_.jsx("button",{type:"button",className:"terminal-pane-transcript","data-provider":a.provider,title:`View ${ku(a.provider)} transcript history`,"aria-label":`View ${ku(a.provider)} transcript history`,onPointerDown:f=>f.stopPropagation(),onMouseDown:f=>f.stopPropagation(),onClick:f=>{f.stopPropagation(),o()},children:"View history"}):null,_.jsx("span",{className:`terminal-pane-state terminal-pane-state-${e.status}`,children:e.status}),e.status==="running"?_.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:f=>f.stopPropagation(),onMouseDown:f=>f.stopPropagation(),onClick:f=>{f.stopPropagation(),c()},children:"↻"}):null,t?_.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:f=>f.stopPropagation(),onMouseDown:f=>f.stopPropagation(),onClick:f=>{f.stopPropagation(),d()},children:"x"}):null]})}function ZR({terminal:e,serverApi:t,source:n,onClose:a}){const o=g.useRef(null),c=g.useRef(0),d=g.useRef(!1),p=g.useRef(!1),m=g.useRef(null),f=g.useRef(""),[b,y]=g.useState([]),[S,E]=g.useState(!1),[x,T]=g.useState(""),[B,M]=g.useState(-1),[V,I]=g.useState(null),[X,le]=g.useState(!1),[ee,te]=g.useState(!0),[ce,pe]=g.useState(!1),[A,P]=g.useState(null);g.useEffect(()=>{c.current+=1;const he=c.current;return d.current=!1,p.current=!0,m.current=null,y([]),I(null),le(!1),P(null),R(null,"initial",he),()=>{c.current===he&&(c.current+=1)}},[t,S,n.provider,n.sessionId,e.id]),g.useLayoutEffect(()=>{const he=o.current;if(!he)return;if(p.current){if(ee||b.length===0)return;p.current=!1;const Se=()=>{he.scrollTop=he.scrollHeight};Se(),window.requestAnimationFrame?.(Se);return}const de=m.current;de!==null&&(m.current=null,he.scrollTop+=he.scrollHeight-de)},[b,ee,S]);const K=ku(n.provider),j=pS(b,S),O=eM(j),Q=sM(O,x),D=Q.length,q=D>0?B>=0&&B<D?B:0:-1,Z=q>=0?Q[q]?.entryIndex??null:null,ve=j?j.split(`
|
|
33
33
|
`).length-1:0,be=x.trim()?D>0?`${q+1}/${D} ${D===1?"match":"matches"} · ${ve} ${ve===1?"line":"lines"}`:`0 matches · ${ve} ${ve===1?"line":"lines"}`:ve>0?`${ve} lines`:"0 lines";g.useEffect(()=>{const he=x.trim().toLowerCase();M(de=>!he||D===0?-1:f.current!==he?0:de>=0&&de<D?de:0),f.current=he},[x,D]);async function R(he,de,Se=c.current){if(!d.current){d.current=!0,de==="initial"?te(!0):(pe(!0),m.current=o.current?.scrollHeight??null),P(null);try{await Y(he,de,Se)}catch(Be){if(c.current!==Se)return;P(Be instanceof Error?Be.message:"Failed to load transcript history.")}finally{c.current===Se&&(d.current=!1,te(!1),pe(!1))}}}async function Y(he,de,Se){let Be=he,Ae=0,Re=[];for(;c.current===Se;){const ze=await t.getTerminalTranscriptHistory(e.id,{...Be?{cursor:Be}:{},limit:kw,includeTools:S});if(c.current!==Se)return;const He=oM(ze.output,n.provider,{includeTools:S});if(I(ze.cursor),le(!!(ze.hasMore&&ze.cursor)),He&&(Re=[He,...Re],pS(Re,S))){y(Te=>de==="older"?[...Re,...Te]:Re);return}if(!ze.hasMore||!ze.cursor||Ae>=VR){Re.length>0&&y(Te=>de==="older"?[...Re,...Te]:Re);return}Be=ze.cursor,Ae+=1}}function se(){const he=o.current;!he||he.scrollTop>72||!X||!V||d.current||R(V,"older")}function fe(he){D!==0&&M(de=>{const Se=q>=0?q:he>0?-1:0;return((de>=0&&de<D?de:Se)+he+D)%D})}return _.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onClick:a,children:_.jsxs("div",{className:"security-panel transcript-dialog",onClick:he=>he.stopPropagation(),children:[_.jsxs("header",{className:"security-panel-header",children:[_.jsxs("div",{className:"transcript-dialog-title",children:[_.jsxs("h2",{id:"transcript-dialog-title",children:[K," JSONL"]}),_.jsx("span",{title:n.sessionId,children:n.sessionId})]}),_.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:a,children:"×"})]}),_.jsxs("div",{className:"transcript-dialog-controls",children:[_.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[_.jsx("input",{type:"checkbox",checked:S,onChange:he=>E(he.currentTarget.checked)}),"Show tool output"]}),_.jsxs("label",{className:"transcript-search",children:[_.jsx("span",{children:"Search"}),_.jsx("input",{type:"search",value:x,"aria-label":"Search JSONL transcript",placeholder:"Find in history",onChange:he=>T(he.currentTarget.value),onKeyDown:he=>{he.key==="Enter"&&(he.preventDefault(),fe(he.shiftKey?-1:1))}})]}),_.jsxs("div",{className:"transcript-search-actions","aria-label":"Search result navigation",children:[_.jsx("button",{type:"button",onClick:()=>fe(-1),disabled:D===0,children:"Prev"}),_.jsx("button",{type:"button",onClick:()=>fe(1),disabled:D===0,children:"Next"})]}),_.jsx("span",{className:"transcript-result-count",children:be})]}),_.jsxs("div",{ref:o,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:se,children:[ce?_.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!ee&&X?_.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,j?_.jsx(QR,{entries:O,searchQuery:x,activeEntryIndex:Z}):null,ee?_.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!ee&&!j&&!A?_.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,A?_.jsx("div",{className:"transcript-dialog-error",children:A}):null]})]})})}function QR({entries:e,searchQuery:t,activeEntryIndex:n}){const a=g.useRef(new Map);return g.useEffect(()=>{if(n===null)return;const o=a.current.get(n);!o||typeof o.scrollIntoView!="function"||o.scrollIntoView({block:"center",inline:"nearest"})},[n,t]),_.jsx("div",{className:"transcript-output transcript-formatted-output",children:e.map((o,c)=>_.jsxs("section",{ref:d=>{d?a.current.set(c,d):a.current.delete(c)},className:`transcript-entry transcript-entry-${o.kind}${n===c?" transcript-entry-search-active":""}`,children:[o.header?_.jsx("div",{className:"transcript-entry-header",children:Dw(o.header,t)}):null,o.body?_.jsx("div",{className:"transcript-entry-body",children:o.kind==="tool"?_.jsx(fS,{text:o.body,searchQuery:t}):_.jsx(ii.Suspense,{fallback:_.jsx(fS,{text:o.body,searchQuery:t}),children:_.jsx(XR,{text:o.body,searchQuery:t})})}):null]},`${o.header??"plain"}-${c}`))})}function fS({text:e,searchQuery:t}){const n=e.endsWith(`
|
|
34
34
|
`)?e.slice(0,-1).split(`
|