plotlink-ows 1.2.96 → 1.2.98

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.
@@ -0,0 +1,141 @@
1
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function i(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(a){if(a.ep)return;a.ep=!0;const o=i(a);fetch(a.href,o)}})();function Ou(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Yd={exports:{}},lo={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var tb;function hC(){if(tb)return lo;tb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function i(s,a,o){var c=null;if(o!==void 0&&(c=""+o),a.key!==void 0&&(c=""+a.key),"key"in a){o={};for(var h in a)h!=="key"&&(o[h]=a[h])}else o=a;return a=o.ref,{$$typeof:e,type:s,key:c,ref:a!==void 0?a:null,props:o}}return lo.Fragment=t,lo.jsx=i,lo.jsxs=i,lo}var ib;function dC(){return ib||(ib=1,Yd.exports=hC()),Yd.exports}var f=dC(),Kd={exports:{}},it={};/**
10
+ * @license React
11
+ * react.production.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var nb;function fC(){if(nb)return it;nb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),b=Symbol.iterator;function v(D){return D===null||typeof D!="object"?null:(D=b&&D[b]||D["@@iterator"],typeof D=="function"?D:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,M={};function E(D,V,k){this.props=D,this.context=V,this.refs=M,this.updater=k||S}E.prototype.isReactComponent={},E.prototype.setState=function(D,V){if(typeof D!="object"&&typeof D!="function"&&D!=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,D,V,"setState")},E.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function H(){}H.prototype=E.prototype;function z(D,V,k){this.props=D,this.context=V,this.refs=M,this.updater=k||S}var R=z.prototype=new H;R.constructor=z,N(R,E.prototype),R.isPureReactComponent=!0;var te=Array.isArray;function L(){}var I={H:null,A:null,T:null,S:null},re=Object.prototype.hasOwnProperty;function _e(D,V,k){var le=k.ref;return{$$typeof:e,type:D,key:V,ref:le!==void 0?le:null,props:k}}function j(D,V){return _e(D.type,V,D.props)}function J(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function F(D){var V={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(k){return V[k]})}var G=/\/+/g;function Y(D,V){return typeof D=="object"&&D!==null&&D.key!=null?F(""+D.key):V.toString(36)}function U(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(L,L):(D.status="pending",D.then(function(V){D.status==="pending"&&(D.status="fulfilled",D.value=V)},function(V){D.status==="pending"&&(D.status="rejected",D.reason=V)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function A(D,V,k,le,ne){var de=typeof D;(de==="undefined"||de==="boolean")&&(D=null);var X=!1;if(D===null)X=!0;else switch(de){case"bigint":case"string":case"number":X=!0;break;case"object":switch(D.$$typeof){case e:case t:X=!0;break;case x:return X=D._init,A(X(D._payload),V,k,le,ne)}}if(X)return ne=ne(D),X=le===""?"."+Y(D,0):le,te(ne)?(k="",X!=null&&(k=X.replace(G,"$&/")+"/"),A(ne,V,k,"",function(fe){return fe})):ne!=null&&(J(ne)&&(ne=j(ne,k+(ne.key==null||D&&D.key===ne.key?"":(""+ne.key).replace(G,"$&/")+"/")+X)),V.push(ne)),1;X=0;var ue=le===""?".":le+":";if(te(D))for(var ye=0;ye<D.length;ye++)le=D[ye],de=ue+Y(le,ye),X+=A(le,V,k,de,ne);else if(ye=v(D),typeof ye=="function")for(D=ye.call(D),ye=0;!(le=D.next()).done;)le=le.value,de=ue+Y(le,ye++),X+=A(le,V,k,de,ne);else if(de==="object"){if(typeof D.then=="function")return A(U(D),V,k,le,ne);throw V=String(D),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return X}function q(D,V,k){if(D==null)return D;var le=[],ne=0;return A(D,le,"","",function(de){return V.call(k,de,ne++)}),le}function $(D){if(D._status===-1){var V=D._result;V=V(),V.then(function(k){(D._status===0||D._status===-1)&&(D._status=1,D._result=k)},function(k){(D._status===0||D._status===-1)&&(D._status=2,D._result=k)}),D._status===-1&&(D._status=0,D._result=V)}if(D._status===1)return D._result.default;throw D._result}var be=typeof reportError=="function"?reportError:function(D){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof D=="object"&&D!==null&&typeof D.message=="string"?String(D.message):String(D),error:D});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",D);return}console.error(D)},T={map:q,forEach:function(D,V,k){q(D,function(){V.apply(this,arguments)},k)},count:function(D){var V=0;return q(D,function(){V++}),V},toArray:function(D){return q(D,function(V){return V})||[]},only:function(D){if(!J(D))throw Error("React.Children.only expected to receive a single React element child.");return D}};return it.Activity=_,it.Children=T,it.Component=E,it.Fragment=i,it.Profiler=a,it.PureComponent=z,it.StrictMode=s,it.Suspense=p,it.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,it.__COMPILER_RUNTIME={__proto__:null,c:function(D){return I.H.useMemoCache(D)}},it.cache=function(D){return function(){return D.apply(null,arguments)}},it.cacheSignal=function(){return null},it.cloneElement=function(D,V,k){if(D==null)throw Error("The argument must be a React element, but you passed "+D+".");var le=N({},D.props),ne=D.key;if(V!=null)for(de in V.key!==void 0&&(ne=""+V.key),V)!re.call(V,de)||de==="key"||de==="__self"||de==="__source"||de==="ref"&&V.ref===void 0||(le[de]=V[de]);var de=arguments.length-2;if(de===1)le.children=k;else if(1<de){for(var X=Array(de),ue=0;ue<de;ue++)X[ue]=arguments[ue+2];le.children=X}return _e(D.type,ne,le)},it.createContext=function(D){return D={$$typeof:c,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null},D.Provider=D,D.Consumer={$$typeof:o,_context:D},D},it.createElement=function(D,V,k){var le,ne={},de=null;if(V!=null)for(le in V.key!==void 0&&(de=""+V.key),V)re.call(V,le)&&le!=="key"&&le!=="__self"&&le!=="__source"&&(ne[le]=V[le]);var X=arguments.length-2;if(X===1)ne.children=k;else if(1<X){for(var ue=Array(X),ye=0;ye<X;ye++)ue[ye]=arguments[ye+2];ne.children=ue}if(D&&D.defaultProps)for(le in X=D.defaultProps,X)ne[le]===void 0&&(ne[le]=X[le]);return _e(D,de,ne)},it.createRef=function(){return{current:null}},it.forwardRef=function(D){return{$$typeof:h,render:D}},it.isValidElement=J,it.lazy=function(D){return{$$typeof:x,_payload:{_status:-1,_result:D},_init:$}},it.memo=function(D,V){return{$$typeof:d,type:D,compare:V===void 0?null:V}},it.startTransition=function(D){var V=I.T,k={};I.T=k;try{var le=D(),ne=I.S;ne!==null&&ne(k,le),typeof le=="object"&&le!==null&&typeof le.then=="function"&&le.then(L,be)}catch(de){be(de)}finally{V!==null&&k.types!==null&&(V.types=k.types),I.T=V}},it.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},it.use=function(D){return I.H.use(D)},it.useActionState=function(D,V,k){return I.H.useActionState(D,V,k)},it.useCallback=function(D,V){return I.H.useCallback(D,V)},it.useContext=function(D){return I.H.useContext(D)},it.useDebugValue=function(){},it.useDeferredValue=function(D,V){return I.H.useDeferredValue(D,V)},it.useEffect=function(D,V){return I.H.useEffect(D,V)},it.useEffectEvent=function(D){return I.H.useEffectEvent(D)},it.useId=function(){return I.H.useId()},it.useImperativeHandle=function(D,V,k){return I.H.useImperativeHandle(D,V,k)},it.useInsertionEffect=function(D,V){return I.H.useInsertionEffect(D,V)},it.useLayoutEffect=function(D,V){return I.H.useLayoutEffect(D,V)},it.useMemo=function(D,V){return I.H.useMemo(D,V)},it.useOptimistic=function(D,V){return I.H.useOptimistic(D,V)},it.useReducer=function(D,V,k){return I.H.useReducer(D,V,k)},it.useRef=function(D){return I.H.useRef(D)},it.useState=function(D){return I.H.useState(D)},it.useSyncExternalStore=function(D,V,k){return I.H.useSyncExternalStore(D,V,k)},it.useTransition=function(){return I.H.useTransition()},it.version="19.2.3",it}var rb;function Up(){return rb||(rb=1,Kd.exports=fC()),Kd.exports}var w=Up();const pC=Ou(w);var Vd={exports:{}},oo={},Xd={exports:{}},Zd={};/**
18
+ * @license React
19
+ * scheduler.production.js
20
+ *
21
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var sb;function mC(){return sb||(sb=1,(function(e){function t(A,q){var $=A.length;A.push(q);e:for(;0<$;){var be=$-1>>>1,T=A[be];if(0<a(T,q))A[be]=q,A[$]=T,$=be;else break e}}function i(A){return A.length===0?null:A[0]}function s(A){if(A.length===0)return null;var q=A[0],$=A.pop();if($!==q){A[0]=$;e:for(var be=0,T=A.length,D=T>>>1;be<D;){var V=2*(be+1)-1,k=A[V],le=V+1,ne=A[le];if(0>a(k,$))le<T&&0>a(ne,k)?(A[be]=ne,A[le]=$,be=le):(A[be]=k,A[V]=$,be=V);else if(le<T&&0>a(ne,$))A[be]=ne,A[le]=$,be=le;else break e}}return q}function a(A,q){var $=A.sortIndex-q.sortIndex;return $!==0?$:A.id-q.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,h=c.now();e.unstable_now=function(){return c.now()-h}}var p=[],d=[],x=1,_=null,b=3,v=!1,S=!1,N=!1,M=!1,E=typeof setTimeout=="function"?setTimeout:null,H=typeof clearTimeout=="function"?clearTimeout:null,z=typeof setImmediate<"u"?setImmediate:null;function R(A){for(var q=i(d);q!==null;){if(q.callback===null)s(d);else if(q.startTime<=A)s(d),q.sortIndex=q.expirationTime,t(p,q);else break;q=i(d)}}function te(A){if(N=!1,R(A),!S)if(i(p)!==null)S=!0,L||(L=!0,F());else{var q=i(d);q!==null&&U(te,q.startTime-A)}}var L=!1,I=-1,re=5,_e=-1;function j(){return M?!0:!(e.unstable_now()-_e<re)}function J(){if(M=!1,L){var A=e.unstable_now();_e=A;var q=!0;try{e:{S=!1,N&&(N=!1,H(I),I=-1),v=!0;var $=b;try{t:{for(R(A),_=i(p);_!==null&&!(_.expirationTime>A&&j());){var be=_.callback;if(typeof be=="function"){_.callback=null,b=_.priorityLevel;var T=be(_.expirationTime<=A);if(A=e.unstable_now(),typeof T=="function"){_.callback=T,R(A),q=!0;break t}_===i(p)&&s(p),R(A)}else s(p);_=i(p)}if(_!==null)q=!0;else{var D=i(d);D!==null&&U(te,D.startTime-A),q=!1}}break e}finally{_=null,b=$,v=!1}q=void 0}}finally{q?F():L=!1}}}var F;if(typeof z=="function")F=function(){z(J)};else if(typeof MessageChannel<"u"){var G=new MessageChannel,Y=G.port2;G.port1.onmessage=J,F=function(){Y.postMessage(null)}}else F=function(){E(J,0)};function U(A,q){I=E(function(){A(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(A){A.callback=null},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):re=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(A){switch(b){case 1:case 2:case 3:var q=3;break;default:q=b}var $=b;b=q;try{return A()}finally{b=$}},e.unstable_requestPaint=function(){M=!0},e.unstable_runWithPriority=function(A,q){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var $=b;b=A;try{return q()}finally{b=$}},e.unstable_scheduleCallback=function(A,q,$){var be=e.unstable_now();switch(typeof $=="object"&&$!==null?($=$.delay,$=typeof $=="number"&&0<$?be+$:be):$=be,A){case 1:var T=-1;break;case 2:T=250;break;case 5:T=1073741823;break;case 4:T=1e4;break;default:T=5e3}return T=$+T,A={id:x++,callback:q,priorityLevel:A,startTime:$,expirationTime:T,sortIndex:-1},$>be?(A.sortIndex=$,t(d,A),i(p)===null&&A===i(d)&&(N?(H(I),I=-1):N=!0,U(te,$-be))):(A.sortIndex=T,t(p,A),S||v||(S=!0,L||(L=!0,F()))),A},e.unstable_shouldYield=j,e.unstable_wrapCallback=function(A){var q=b;return function(){var $=b;b=q;try{return A.apply(this,arguments)}finally{b=$}}}})(Zd)),Zd}var ab;function gC(){return ab||(ab=1,Xd.exports=mC()),Xd.exports}var Qd={exports:{}},un={};/**
26
+ * @license React
27
+ * react-dom.production.js
28
+ *
29
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var lb;function _C(){if(lb)return un;lb=1;var e=Up();function t(p){var d="https://react.dev/errors/"+p;if(1<arguments.length){d+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)d+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+p+"; visit "+d+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var s={d:{f:i,r:function(){throw Error(t(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},a=Symbol.for("react.portal");function o(p,d,x){var _=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:_==null?null:""+_,children:p,containerInfo:d,implementation:x}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(p,d){if(p==="font")return"";if(typeof d=="string")return d==="use-credentials"?d:""}return un.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,un.createPortal=function(p,d){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11)throw Error(t(299));return o(p,d,null,x)},un.flushSync=function(p){var d=c.T,x=s.p;try{if(c.T=null,s.p=2,p)return p()}finally{c.T=d,s.p=x,s.d.f()}},un.preconnect=function(p,d){typeof p=="string"&&(d?(d=d.crossOrigin,d=typeof d=="string"?d==="use-credentials"?d:"":void 0):d=null,s.d.C(p,d))},un.prefetchDNS=function(p){typeof p=="string"&&s.d.D(p)},un.preinit=function(p,d){if(typeof p=="string"&&d&&typeof d.as=="string"){var x=d.as,_=h(x,d.crossOrigin),b=typeof d.integrity=="string"?d.integrity:void 0,v=typeof d.fetchPriority=="string"?d.fetchPriority:void 0;x==="style"?s.d.S(p,typeof d.precedence=="string"?d.precedence:void 0,{crossOrigin:_,integrity:b,fetchPriority:v}):x==="script"&&s.d.X(p,{crossOrigin:_,integrity:b,fetchPriority:v,nonce:typeof d.nonce=="string"?d.nonce:void 0})}},un.preinitModule=function(p,d){if(typeof p=="string")if(typeof d=="object"&&d!==null){if(d.as==null||d.as==="script"){var x=h(d.as,d.crossOrigin);s.d.M(p,{crossOrigin:x,integrity:typeof d.integrity=="string"?d.integrity:void 0,nonce:typeof d.nonce=="string"?d.nonce:void 0})}}else d==null&&s.d.M(p)},un.preload=function(p,d){if(typeof p=="string"&&typeof d=="object"&&d!==null&&typeof d.as=="string"){var x=d.as,_=h(x,d.crossOrigin);s.d.L(p,x,{crossOrigin:_,integrity:typeof d.integrity=="string"?d.integrity:void 0,nonce:typeof d.nonce=="string"?d.nonce:void 0,type:typeof d.type=="string"?d.type:void 0,fetchPriority:typeof d.fetchPriority=="string"?d.fetchPriority:void 0,referrerPolicy:typeof d.referrerPolicy=="string"?d.referrerPolicy:void 0,imageSrcSet:typeof d.imageSrcSet=="string"?d.imageSrcSet:void 0,imageSizes:typeof d.imageSizes=="string"?d.imageSizes:void 0,media:typeof d.media=="string"?d.media:void 0})}},un.preloadModule=function(p,d){if(typeof p=="string")if(d){var x=h(d.as,d.crossOrigin);s.d.m(p,{as:typeof d.as=="string"&&d.as!=="script"?d.as:void 0,crossOrigin:x,integrity:typeof d.integrity=="string"?d.integrity:void 0})}else s.d.m(p)},un.requestFormReset=function(p){s.d.r(p)},un.unstable_batchedUpdates=function(p,d){return p(d)},un.useFormState=function(p,d,x){return c.H.useFormState(p,d,x)},un.useFormStatus=function(){return c.H.useHostTransitionStatus()},un.version="19.2.3",un}var ob;function xC(){if(ob)return Qd.exports;ob=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(),Qd.exports=_C(),Qd.exports}/**
34
+ * @license React
35
+ * react-dom-client.production.js
36
+ *
37
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
38
+ *
39
+ * This source code is licensed under the MIT license found in the
40
+ * LICENSE file in the root directory of this source tree.
41
+ */var cb;function bC(){if(cb)return oo;cb=1;var e=gC(),t=Up(),i=xC();function s(n){var r="https://react.dev/errors/"+n;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function o(n){var r=n,l=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(l=r.return),n=r.return;while(n)}return r.tag===3?l:null}function c(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function h(n){if(n.tag===31){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function p(n){if(o(n)!==n)throw Error(s(188))}function d(n){var r=n.alternate;if(!r){if(r=o(n),r===null)throw Error(s(188));return r!==n?null:n}for(var l=n,u=r;;){var m=l.return;if(m===null)break;var g=m.alternate;if(g===null){if(u=m.return,u!==null){l=u;continue}break}if(m.child===g.child){for(g=m.child;g;){if(g===l)return p(m),n;if(g===u)return p(m),r;g=g.sibling}throw Error(s(188))}if(l.return!==u.return)l=m,u=g;else{for(var y=!1,C=m.child;C;){if(C===l){y=!0,l=m,u=g;break}if(C===u){y=!0,u=m,l=g;break}C=C.sibling}if(!y){for(C=g.child;C;){if(C===l){y=!0,l=g,u=m;break}if(C===u){y=!0,u=g,l=m;break}C=C.sibling}if(!y)throw Error(s(189))}}if(l.alternate!==u)throw Error(s(190))}if(l.tag!==3)throw Error(s(188));return l.stateNode.current===l?n:r}function x(n){var r=n.tag;if(r===5||r===26||r===27||r===6)return n;for(n=n.child;n!==null;){if(r=x(n),r!==null)return r;n=n.sibling}return null}var _=Object.assign,b=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),H=Symbol.for("react.consumer"),z=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),te=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),re=Symbol.for("react.lazy"),_e=Symbol.for("react.activity"),j=Symbol.for("react.memo_cache_sentinel"),J=Symbol.iterator;function F(n){return n===null||typeof n!="object"?null:(n=J&&n[J]||n["@@iterator"],typeof n=="function"?n:null)}var G=Symbol.for("react.client.reference");function Y(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===G?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case N:return"Fragment";case E:return"Profiler";case M:return"StrictMode";case te:return"Suspense";case L:return"SuspenseList";case _e:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case S:return"Portal";case z:return n.displayName||"Context";case H:return(n._context.displayName||"Context")+".Consumer";case R:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case I:return r=n.displayName||null,r!==null?r:Y(n.type)||"Memo";case re:r=n._payload,n=n._init;try{return Y(n(r))}catch{}}return null}var U=Array.isArray,A=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$={pending:!1,data:null,method:null,action:null},be=[],T=-1;function D(n){return{current:n}}function V(n){0>T||(n.current=be[T],be[T]=null,T--)}function k(n,r){T++,be[T]=n.current,n.current=r}var le=D(null),ne=D(null),de=D(null),X=D(null);function ue(n,r){switch(k(de,r),k(ne,n),k(le,null),r.nodeType){case 9:case 11:n=(n=r.documentElement)&&(n=n.namespaceURI)?Cx(n):0;break;default:if(n=r.tagName,r=r.namespaceURI)r=Cx(r),n=kx(r,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}V(le),k(le,n)}function ye(){V(le),V(ne),V(de)}function fe(n){n.memoizedState!==null&&k(X,n);var r=le.current,l=kx(r,n.type);r!==l&&(k(ne,n),k(le,l))}function Pe(n){ne.current===n&&(V(le),V(ne)),X.current===n&&(V(X),no._currentValue=$)}var $e,Oe;function Ke(n){if($e===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);$e=r&&r[1]||"",Oe=-1<l.stack.indexOf(`
42
+ at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
43
+ `+$e+n+Oe}var ft=!1;function tt(n,r){if(!n||ft)return"";ft=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(r){var me=function(){throw Error()};if(Object.defineProperty(me.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(me,[])}catch(ae){var ee=ae}Reflect.construct(n,[],me)}else{try{me.call()}catch(ae){ee=ae}n.call(me.prototype)}}else{try{throw Error()}catch(ae){ee=ae}(me=n())&&typeof me.catch=="function"&&me.catch(function(){})}}catch(ae){if(ae&&ee&&typeof ae.stack=="string")return[ae.stack,ee.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var m=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");m&&m.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=u.DetermineComponentFrameRoot(),y=g[0],C=g[1];if(y&&C){var B=y.split(`
44
+ `),Q=C.split(`
45
+ `);for(m=u=0;u<B.length&&!B[u].includes("DetermineComponentFrameRoot");)u++;for(;m<Q.length&&!Q[m].includes("DetermineComponentFrameRoot");)m++;if(u===B.length||m===Q.length)for(u=B.length-1,m=Q.length-1;1<=u&&0<=m&&B[u]!==Q[m];)m--;for(;1<=u&&0<=m;u--,m--)if(B[u]!==Q[m]){if(u!==1||m!==1)do if(u--,m--,0>m||B[u]!==Q[m]){var ce=`
46
+ `+B[u].replace(" at new "," at ");return n.displayName&&ce.includes("<anonymous>")&&(ce=ce.replace("<anonymous>",n.displayName)),ce}while(1<=u&&0<=m);break}}}finally{ft=!1,Error.prepareStackTrace=l}return(l=n?n.displayName||n.name:"")?Ke(l):""}function Fe(n,r){switch(n.tag){case 26:case 27:case 5:return Ke(n.type);case 16:return Ke("Lazy");case 13:return n.child!==r&&r!==null?Ke("Suspense Fallback"):Ke("Suspense");case 19:return Ke("SuspenseList");case 0:case 15:return tt(n.type,!1);case 11:return tt(n.type.render,!1);case 1:return tt(n.type,!0);case 31:return Ke("Activity");default:return""}}function ze(n){try{var r="",l=null;do r+=Fe(n,l),l=n,n=n.return;while(n);return r}catch(u){return`
47
+ Error generating stack: `+u.message+`
48
+ `+u.stack}}var qe=Object.prototype.hasOwnProperty,Gt=e.unstable_scheduleCallback,wt=e.unstable_cancelCallback,ki=e.unstable_shouldYield,Ei=e.unstable_requestPaint,yt=e.unstable_now,Li=e.unstable_getCurrentPriorityLevel,oe=e.unstable_ImmediatePriority,se=e.unstable_UserBlockingPriority,Ie=e.unstable_NormalPriority,je=e.unstable_LowPriority,De=e.unstable_IdlePriority,Ct=e.log,_t=e.unstable_setDisableYieldValue,nt=null,xt=null;function Tt(n){if(typeof Ct=="function"&&_t(n),xt&&typeof xt.setStrictMode=="function")try{xt.setStrictMode(nt,n)}catch{}}var ct=Math.clz32?Math.clz32:Kn,ui=Math.log,ei=Math.LN2;function Kn(n){return n>>>=0,n===0?32:31-(ui(n)/ei|0)|0}var mn=256,_i=262144,xi=4194304;function Ht(n){var r=n&42;if(r!==0)return r;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function ln(n,r,l){var u=n.pendingLanes;if(u===0)return 0;var m=0,g=n.suspendedLanes,y=n.pingedLanes;n=n.warmLanes;var C=u&134217727;return C!==0?(u=C&~g,u!==0?m=Ht(u):(y&=C,y!==0?m=Ht(y):l||(l=C&~n,l!==0&&(m=Ht(l))))):(C=u&~g,C!==0?m=Ht(C):y!==0?m=Ht(y):l||(l=u&~n,l!==0&&(m=Ht(l)))),m===0?0:r!==0&&r!==m&&(r&g)===0&&(g=m&-m,l=r&-r,g>=l||g===32&&(l&4194048)!==0)?r:m}function Ui(n,r){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&r)===0}function O(n,r){switch(n){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function we(){var n=xi;return xi<<=1,(xi&62914560)===0&&(xi=4194304),n}function Me(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function Te(n,r){n.pendingLanes|=r,r!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function Ze(n,r,l,u,m,g){var y=n.pendingLanes;n.pendingLanes=l,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=l,n.entangledLanes&=l,n.errorRecoveryDisabledLanes&=l,n.shellSuspendCounter=0;var C=n.entanglements,B=n.expirationTimes,Q=n.hiddenUpdates;for(l=y&~l;0<l;){var ce=31-ct(l),me=1<<ce;C[ce]=0,B[ce]=-1;var ee=Q[ce];if(ee!==null)for(Q[ce]=null,ce=0;ce<ee.length;ce++){var ae=ee[ce];ae!==null&&(ae.lane&=-536870913)}l&=~me}u!==0&&Qe(n,u,0),g!==0&&m===0&&n.tag!==0&&(n.suspendedLanes|=g&~(y&~r))}function Qe(n,r,l){n.pendingLanes|=r,n.suspendedLanes&=~r;var u=31-ct(r);n.entangledLanes|=r,n.entanglements[u]=n.entanglements[u]|1073741824|l&261930}function Nt(n,r){var l=n.entangledLanes|=r;for(n=n.entanglements;l;){var u=31-ct(l),m=1<<u;m&r|n[u]&r&&(n[u]|=r),l&=~m}}function kt(n,r){var l=r&-r;return l=(l&42)!==0?1:Rt(l),(l&(n.suspendedLanes|r))!==0?0:l}function Rt(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function Je(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function hi(){var n=q.p;return n!==0?n:(n=window.event,n===void 0?32:Kx(n.type))}function bi(n,r){var l=q.p;try{return q.p=n,r()}finally{q.p=l}}var vi=Math.random().toString(36).slice(2),Ot="__reactFiber$"+vi,si="__reactProps$"+vi,Zt="__reactContainer$"+vi,he="__reactEvents$"+vi,Ae="__reactListeners$"+vi,Ge="__reactHandles$"+vi,Dt="__reactResources$"+vi,st="__reactMarker$"+vi;function at(n){delete n[Ot],delete n[si],delete n[he],delete n[Ae],delete n[Ge]}function Bt(n){var r=n[Ot];if(r)return r;for(var l=n.parentNode;l;){if(r=l[Zt]||l[Ot]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=Dx(n);n!==null;){if(l=n[Ot])return l;n=Dx(n)}return r}n=l,l=n.parentNode}return null}function K(n){if(n=n[Ot]||n[Zt]){var r=n.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return n}return null}function xe(n){var r=n.tag;if(r===5||r===26||r===27||r===6)return n.stateNode;throw Error(s(33))}function ve(n){var r=n[Dt];return r||(r=n[Dt]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function Ce(n){n[st]=!0}var Be=new Set,He={};function dt(n,r){Lt(n,r),Lt(n+"Capture",r)}function Lt(n,r){for(He[n]=r,n=0;n<r.length;n++)Be.add(r[n])}var gn=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),on={},Vn={};function br(n){return qe.call(Vn,n)?!0:qe.call(on,n)?!1:gn.test(n)?Vn[n]=!0:(on[n]=!0,!1)}function Xn(n,r,l){if(br(r))if(l===null)n.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":n.removeAttribute(r);return;case"boolean":var u=r.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){n.removeAttribute(r);return}}n.setAttribute(r,""+l)}}function Yt(n,r,l){if(l===null)n.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(r);return}n.setAttribute(r,""+l)}}function $i(n,r,l,u){if(u===null)n.removeAttribute(l);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(l);return}n.setAttributeNS(r,l,""+u)}}function Ut(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Cn(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function vr(n,r,l){var u=Object.getOwnPropertyDescriptor(n.constructor.prototype,r);if(!n.hasOwnProperty(r)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var m=u.get,g=u.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return m.call(this)},set:function(y){l=""+y,g.call(this,y)}}),Object.defineProperty(n,r,{enumerable:u.enumerable}),{getValue:function(){return l},setValue:function(y){l=""+y},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function zt(n){if(!n._valueTracker){var r=Cn(n)?"checked":"value";n._valueTracker=vr(n,r,""+n[r])}}function ti(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var l=r.getValue(),u="";return n&&(u=Cn(n)?n.checked?"true":"false":n.value),n=u,n!==l?(r.setValue(n),!0):!1}function kn(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var cn=/[\n"\\]/g;function Qt(n){return n.replace(cn,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Ni(n,r,l,u,m,g,y,C){n.name="",y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?n.type=y:n.removeAttribute("type"),r!=null?y==="number"?(r===0&&n.value===""||n.value!=r)&&(n.value=""+Ut(r)):n.value!==""+Ut(r)&&(n.value=""+Ut(r)):y!=="submit"&&y!=="reset"||n.removeAttribute("value"),r!=null?yr(n,y,Ut(r)):l!=null?yr(n,y,Ut(l)):u!=null&&n.removeAttribute("value"),m==null&&g!=null&&(n.defaultChecked=!!g),m!=null&&(n.checked=m&&typeof m!="function"&&typeof m!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?n.name=""+Ut(C):n.removeAttribute("name")}function ls(n,r,l,u,m,g,y,C){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(n.type=g),r!=null||l!=null){if(!(g!=="submit"&&g!=="reset"||r!=null)){zt(n);return}l=l!=null?""+Ut(l):"",r=r!=null?""+Ut(r):l,C||r===n.value||(n.value=r),n.defaultValue=r}u=u??m,u=typeof u!="function"&&typeof u!="symbol"&&!!u,n.checked=C?n.checked:!!u,n.defaultChecked=!!u,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(n.name=y),zt(n)}function yr(n,r,l){r==="number"&&kn(n.ownerDocument)===n||n.defaultValue===""+l||(n.defaultValue=""+l)}function Lr(n,r,l,u){if(n=n.options,r){r={};for(var m=0;m<l.length;m++)r["$"+l[m]]=!0;for(l=0;l<n.length;l++)m=r.hasOwnProperty("$"+n[l].value),n[l].selected!==m&&(n[l].selected=m),m&&u&&(n[l].defaultSelected=!0)}else{for(l=""+Ut(l),r=null,m=0;m<n.length;m++){if(n[m].value===l){n[m].selected=!0,u&&(n[m].defaultSelected=!0);return}r!==null||n[m].disabled||(r=n[m])}r!==null&&(r.selected=!0)}}function _l(n,r,l){if(r!=null&&(r=""+Ut(r),r!==n.value&&(n.value=r),l==null)){n.defaultValue!==r&&(n.defaultValue=r);return}n.defaultValue=l!=null?""+Ut(l):""}function Sa(n,r,l,u){if(r==null){if(u!=null){if(l!=null)throw Error(s(92));if(U(u)){if(1<u.length)throw Error(s(93));u=u[0]}l=u}l==null&&(l=""),r=l}l=Ut(r),n.defaultValue=l,u=n.textContent,u===l&&u!==""&&u!==null&&(n.value=u),zt(n)}function Or(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var Us=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function wa(n,r,l){var u=r.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?u?n.setProperty(r,""):r==="float"?n.cssFloat="":n[r]="":u?n.setProperty(r,l):typeof l!="number"||l===0||Us.has(r)?r==="float"?n.cssFloat=l:n[r]=(""+l).trim():n[r]=l+"px"}function xl(n,r,l){if(r!=null&&typeof r!="object")throw Error(s(62));if(n=n.style,l!=null){for(var u in l)!l.hasOwnProperty(u)||r!=null&&r.hasOwnProperty(u)||(u.indexOf("--")===0?n.setProperty(u,""):u==="float"?n.cssFloat="":n[u]="");for(var m in r)u=r[m],r.hasOwnProperty(m)&&l[m]!==u&&wa(n,m,u)}else for(var g in r)r.hasOwnProperty(g)&&wa(n,g,r[g])}function zr(n){if(n.indexOf("-")===-1)return!1;switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Vo=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Ku=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Ca(n){return Ku.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function Zn(){}var $s=null;function bl(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var os=null,Qn=null;function Fs(n){var r=K(n);if(r&&(n=r.stateNode)){var l=n[si]||null;e:switch(n=r.stateNode,r.type){case"input":if(Ni(n,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),r=l.name,l.type==="radio"&&r!=null){for(l=n;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+Qt(""+r)+'"][type="radio"]'),r=0;r<l.length;r++){var u=l[r];if(u!==n&&u.form===n.form){var m=u[si]||null;if(!m)throw Error(s(90));Ni(u,m.value,m.defaultValue,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name)}}for(r=0;r<l.length;r++)u=l[r],u.form===n.form&&ti(u)}break e;case"textarea":_l(n,l.value,l.defaultValue);break e;case"select":r=l.value,r!=null&&Lr(n,!!l.multiple,r,!1)}}}var vl=!1;function qs(n,r,l){if(vl)return n(r,l);vl=!0;try{var u=n(r);return u}finally{if(vl=!1,(os!==null||Qn!==null)&&(Mc(),os&&(r=os,n=Qn,Qn=os=null,Fs(r),n)))for(r=0;r<n.length;r++)Fs(n[r])}}function Ws(n,r){var l=n.stateNode;if(l===null)return null;var u=l[si]||null;if(u===null)return null;l=u[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(n=n.type,u=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!u;break e;default:n=!1}if(n)return null;if(l&&typeof l!="function")throw Error(s(231,r,typeof l));return l}var ie=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ee=!1;if(ie)try{var Ne={};Object.defineProperty(Ne,"passive",{get:function(){Ee=!0}}),window.addEventListener("test",Ne,Ne),window.removeEventListener("test",Ne,Ne)}catch{Ee=!1}var Xe=null,Kt=null,yi=null;function dr(){if(yi)return yi;var n,r=Kt,l=r.length,u,m="value"in Xe?Xe.value:Xe.textContent,g=m.length;for(n=0;n<l&&r[n]===m[n];n++);var y=l-n;for(u=1;u<=y&&r[l-u]===m[g-u];u++);return yi=m.slice(n,1<u?1-u:void 0)}function fr(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function En(){return!0}function yl(){return!1}function Nn(n){function r(l,u,m,g,y){this._reactName=l,this._targetInst=m,this.type=u,this.nativeEvent=g,this.target=y,this.currentTarget=null;for(var C in n)n.hasOwnProperty(C)&&(l=n[C],this[C]=l?l(g):g[C]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?En:yl,this.isPropagationStopped=yl,this}return _(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=En)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=En)},persist:function(){},isPersistent:En}),r}var Gs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Xo=Nn(Gs),Sl=_({},Gs,{view:0,detail:0}),c1=Nn(Sl),Vu,Xu,wl,Zo=_({},Sl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Qu,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==wl&&(wl&&n.type==="mousemove"?(Vu=n.screenX-wl.screenX,Xu=n.screenY-wl.screenY):Xu=Vu=0,wl=n),Vu)},movementY:function(n){return"movementY"in n?n.movementY:Xu}}),Nm=Nn(Zo),u1=_({},Zo,{dataTransfer:0}),h1=Nn(u1),d1=_({},Sl,{relatedTarget:0}),Zu=Nn(d1),f1=_({},Gs,{animationName:0,elapsedTime:0,pseudoElement:0}),p1=Nn(f1),m1=_({},Gs,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),g1=Nn(m1),_1=_({},Gs,{data:0}),Tm=Nn(_1),x1={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},b1={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},v1={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function y1(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=v1[n])?!!r[n]:!1}function Qu(){return y1}var S1=_({},Sl,{key:function(n){if(n.key){var r=x1[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=fr(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?b1[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Qu,charCode:function(n){return n.type==="keypress"?fr(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?fr(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),w1=Nn(S1),C1=_({},Zo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),jm=Nn(C1),k1=_({},Sl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Qu}),E1=Nn(k1),N1=_({},Gs,{propertyName:0,elapsedTime:0,pseudoElement:0}),T1=Nn(N1),j1=_({},Zo,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),A1=Nn(j1),R1=_({},Gs,{newState:0,oldState:0}),D1=Nn(R1),M1=[9,13,27,32],Ju=ie&&"CompositionEvent"in window,Cl=null;ie&&"documentMode"in document&&(Cl=document.documentMode);var B1=ie&&"TextEvent"in window&&!Cl,Am=ie&&(!Ju||Cl&&8<Cl&&11>=Cl),Rm=" ",Dm=!1;function Mm(n,r){switch(n){case"keyup":return M1.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bm(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var ka=!1;function L1(n,r){switch(n){case"compositionend":return Bm(r);case"keypress":return r.which!==32?null:(Dm=!0,Rm);case"textInput":return n=r.data,n===Rm&&Dm?null:n;default:return null}}function O1(n,r){if(ka)return n==="compositionend"||!Ju&&Mm(n,r)?(n=dr(),yi=Kt=Xe=null,ka=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Am&&r.locale!=="ko"?null:r.data;default:return null}}var z1={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Lm(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!z1[n.type]:r==="textarea"}function Om(n,r,l,u){os?Qn?Qn.push(u):Qn=[u]:os=u,r=Hc(r,"onChange"),0<r.length&&(l=new Xo("onChange","change",null,l,u),n.push({event:l,listeners:r}))}var kl=null,El=null;function P1(n){xx(n,0)}function Qo(n){var r=xe(n);if(ti(r))return n}function zm(n,r){if(n==="change")return r}var Pm=!1;if(ie){var eh;if(ie){var th="oninput"in document;if(!th){var Im=document.createElement("div");Im.setAttribute("oninput","return;"),th=typeof Im.oninput=="function"}eh=th}else eh=!1;Pm=eh&&(!document.documentMode||9<document.documentMode)}function Hm(){kl&&(kl.detachEvent("onpropertychange",Um),El=kl=null)}function Um(n){if(n.propertyName==="value"&&Qo(El)){var r=[];Om(r,El,n,bl(n)),qs(P1,r)}}function I1(n,r,l){n==="focusin"?(Hm(),kl=r,El=l,kl.attachEvent("onpropertychange",Um)):n==="focusout"&&Hm()}function H1(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Qo(El)}function U1(n,r){if(n==="click")return Qo(r)}function $1(n,r){if(n==="input"||n==="change")return Qo(r)}function F1(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var zn=typeof Object.is=="function"?Object.is:F1;function Nl(n,r){if(zn(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var l=Object.keys(n),u=Object.keys(r);if(l.length!==u.length)return!1;for(u=0;u<l.length;u++){var m=l[u];if(!qe.call(r,m)||!zn(n[m],r[m]))return!1}return!0}function $m(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Fm(n,r){var l=$m(n);n=0;for(var u;l;){if(l.nodeType===3){if(u=n+l.textContent.length,n<=r&&u>=r)return{node:l,offset:r-n};n=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=$m(l)}}function qm(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?qm(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function Wm(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var r=kn(n.document);r instanceof n.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)n=r.contentWindow;else break;r=kn(n.document)}return r}function ih(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r&&(r==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||r==="textarea"||n.contentEditable==="true")}var q1=ie&&"documentMode"in document&&11>=document.documentMode,Ea=null,nh=null,Tl=null,rh=!1;function Gm(n,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;rh||Ea==null||Ea!==kn(u)||(u=Ea,"selectionStart"in u&&ih(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Tl&&Nl(Tl,u)||(Tl=u,u=Hc(nh,"onSelect"),0<u.length&&(r=new Xo("onSelect","select",null,r,l),n.push({event:r,listeners:u}),r.target=Ea)))}function Ys(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var Na={animationend:Ys("Animation","AnimationEnd"),animationiteration:Ys("Animation","AnimationIteration"),animationstart:Ys("Animation","AnimationStart"),transitionrun:Ys("Transition","TransitionRun"),transitionstart:Ys("Transition","TransitionStart"),transitioncancel:Ys("Transition","TransitionCancel"),transitionend:Ys("Transition","TransitionEnd")},sh={},Ym={};ie&&(Ym=document.createElement("div").style,"AnimationEvent"in window||(delete Na.animationend.animation,delete Na.animationiteration.animation,delete Na.animationstart.animation),"TransitionEvent"in window||delete Na.transitionend.transition);function Ks(n){if(sh[n])return sh[n];if(!Na[n])return n;var r=Na[n],l;for(l in r)if(r.hasOwnProperty(l)&&l in Ym)return sh[n]=r[l];return n}var Km=Ks("animationend"),Vm=Ks("animationiteration"),Xm=Ks("animationstart"),W1=Ks("transitionrun"),G1=Ks("transitionstart"),Y1=Ks("transitioncancel"),Zm=Ks("transitionend"),Qm=new Map,ah="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");ah.push("scrollEnd");function pr(n,r){Qm.set(n,r),dt(r,[n])}var Jo=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},Jn=[],Ta=0,lh=0;function ec(){for(var n=Ta,r=lh=Ta=0;r<n;){var l=Jn[r];Jn[r++]=null;var u=Jn[r];Jn[r++]=null;var m=Jn[r];Jn[r++]=null;var g=Jn[r];if(Jn[r++]=null,u!==null&&m!==null){var y=u.pending;y===null?m.next=m:(m.next=y.next,y.next=m),u.pending=m}g!==0&&Jm(l,m,g)}}function tc(n,r,l,u){Jn[Ta++]=n,Jn[Ta++]=r,Jn[Ta++]=l,Jn[Ta++]=u,lh|=u,n.lanes|=u,n=n.alternate,n!==null&&(n.lanes|=u)}function oh(n,r,l,u){return tc(n,r,l,u),ic(n)}function Vs(n,r){return tc(n,null,null,r),ic(n)}function Jm(n,r,l){n.lanes|=l;var u=n.alternate;u!==null&&(u.lanes|=l);for(var m=!1,g=n.return;g!==null;)g.childLanes|=l,u=g.alternate,u!==null&&(u.childLanes|=l),g.tag===22&&(n=g.stateNode,n===null||n._visibility&1||(m=!0)),n=g,g=g.return;return n.tag===3?(g=n.stateNode,m&&r!==null&&(m=31-ct(l),n=g.hiddenUpdates,u=n[m],u===null?n[m]=[r]:u.push(r),r.lane=l|536870912),g):null}function ic(n){if(50<Xl)throw Xl=0,_d=null,Error(s(185));for(var r=n.return;r!==null;)n=r,r=n.return;return n.tag===3?n.stateNode:null}var ja={};function K1(n,r,l,u){this.tag=n,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pn(n,r,l,u){return new K1(n,r,l,u)}function ch(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Pr(n,r){var l=n.alternate;return l===null?(l=Pn(n.tag,r,n.key,n.mode),l.elementType=n.elementType,l.type=n.type,l.stateNode=n.stateNode,l.alternate=n,n.alternate=l):(l.pendingProps=r,l.type=n.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=n.flags&65011712,l.childLanes=n.childLanes,l.lanes=n.lanes,l.child=n.child,l.memoizedProps=n.memoizedProps,l.memoizedState=n.memoizedState,l.updateQueue=n.updateQueue,r=n.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=n.sibling,l.index=n.index,l.ref=n.ref,l.refCleanup=n.refCleanup,l}function eg(n,r){n.flags&=65011714;var l=n.alternate;return l===null?(n.childLanes=0,n.lanes=r,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=l.childLanes,n.lanes=l.lanes,n.child=l.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=l.memoizedProps,n.memoizedState=l.memoizedState,n.updateQueue=l.updateQueue,n.type=l.type,r=l.dependencies,n.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),n}function nc(n,r,l,u,m,g){var y=0;if(u=n,typeof n=="function")ch(n)&&(y=1);else if(typeof n=="string")y=Jw(n,l,le.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case _e:return n=Pn(31,l,r,m),n.elementType=_e,n.lanes=g,n;case N:return Xs(l.children,m,g,r);case M:y=8,m|=24;break;case E:return n=Pn(12,l,r,m|2),n.elementType=E,n.lanes=g,n;case te:return n=Pn(13,l,r,m),n.elementType=te,n.lanes=g,n;case L:return n=Pn(19,l,r,m),n.elementType=L,n.lanes=g,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case z:y=10;break e;case H:y=9;break e;case R:y=11;break e;case I:y=14;break e;case re:y=16,u=null;break e}y=29,l=Error(s(130,n===null?"null":typeof n,"")),u=null}return r=Pn(y,l,r,m),r.elementType=n,r.type=u,r.lanes=g,r}function Xs(n,r,l,u){return n=Pn(7,n,u,r),n.lanes=l,n}function uh(n,r,l){return n=Pn(6,n,null,r),n.lanes=l,n}function tg(n){var r=Pn(18,null,null,0);return r.stateNode=n,r}function hh(n,r,l){return r=Pn(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}var ig=new WeakMap;function er(n,r){if(typeof n=="object"&&n!==null){var l=ig.get(n);return l!==void 0?l:(r={value:n,source:r,stack:ze(r)},ig.set(n,r),r)}return{value:n,source:r,stack:ze(r)}}var Aa=[],Ra=0,rc=null,jl=0,tr=[],ir=0,cs=null,Sr=1,wr="";function Ir(n,r){Aa[Ra++]=jl,Aa[Ra++]=rc,rc=n,jl=r}function ng(n,r,l){tr[ir++]=Sr,tr[ir++]=wr,tr[ir++]=cs,cs=n;var u=Sr;n=wr;var m=32-ct(u)-1;u&=~(1<<m),l+=1;var g=32-ct(r)+m;if(30<g){var y=m-m%5;g=(u&(1<<y)-1).toString(32),u>>=y,m-=y,Sr=1<<32-ct(r)+m|l<<m|u,wr=g+n}else Sr=1<<g|l<<m|u,wr=n}function dh(n){n.return!==null&&(Ir(n,1),ng(n,1,0))}function fh(n){for(;n===rc;)rc=Aa[--Ra],Aa[Ra]=null,jl=Aa[--Ra],Aa[Ra]=null;for(;n===cs;)cs=tr[--ir],tr[ir]=null,wr=tr[--ir],tr[ir]=null,Sr=tr[--ir],tr[ir]=null}function rg(n,r){tr[ir++]=Sr,tr[ir++]=wr,tr[ir++]=cs,Sr=r.id,wr=r.overflow,cs=n}var Ji=null,ii=null,St=!1,us=null,nr=!1,ph=Error(s(519));function hs(n){var r=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Al(er(r,n)),ph}function sg(n){var r=n.stateNode,l=n.type,u=n.memoizedProps;switch(r[Ot]=n,r[si]=u,l){case"dialog":mt("cancel",r),mt("close",r);break;case"iframe":case"object":case"embed":mt("load",r);break;case"video":case"audio":for(l=0;l<Ql.length;l++)mt(Ql[l],r);break;case"source":mt("error",r);break;case"img":case"image":case"link":mt("error",r),mt("load",r);break;case"details":mt("toggle",r);break;case"input":mt("invalid",r),ls(r,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":mt("invalid",r);break;case"textarea":mt("invalid",r),Sa(r,u.value,u.defaultValue,u.children)}l=u.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||r.textContent===""+l||u.suppressHydrationWarning===!0||Sx(r.textContent,l)?(u.popover!=null&&(mt("beforetoggle",r),mt("toggle",r)),u.onScroll!=null&&mt("scroll",r),u.onScrollEnd!=null&&mt("scrollend",r),u.onClick!=null&&(r.onclick=Zn),r=!0):r=!1,r||hs(n,!0)}function ag(n){for(Ji=n.return;Ji;)switch(Ji.tag){case 5:case 31:case 13:nr=!1;return;case 27:case 3:nr=!0;return;default:Ji=Ji.return}}function Da(n){if(n!==Ji)return!1;if(!St)return ag(n),St=!0,!1;var r=n.tag,l;if((l=r!==3&&r!==27)&&((l=r===5)&&(l=n.type,l=!(l!=="form"&&l!=="button")||Dd(n.type,n.memoizedProps)),l=!l),l&&ii&&hs(n),ag(n),r===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));ii=Rx(n)}else if(r===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));ii=Rx(n)}else r===27?(r=ii,ks(n.type)?(n=zd,zd=null,ii=n):ii=r):ii=Ji?sr(n.stateNode.nextSibling):null;return!0}function Zs(){ii=Ji=null,St=!1}function mh(){var n=us;return n!==null&&(Rn===null?Rn=n:Rn.push.apply(Rn,n),us=null),n}function Al(n){us===null?us=[n]:us.push(n)}var gh=D(null),Qs=null,Hr=null;function ds(n,r,l){k(gh,r._currentValue),r._currentValue=l}function Ur(n){n._currentValue=gh.current,V(gh)}function _h(n,r,l){for(;n!==null;){var u=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,u!==null&&(u.childLanes|=r)):u!==null&&(u.childLanes&r)!==r&&(u.childLanes|=r),n===l)break;n=n.return}}function xh(n,r,l,u){var m=n.child;for(m!==null&&(m.return=n);m!==null;){var g=m.dependencies;if(g!==null){var y=m.child;g=g.firstContext;e:for(;g!==null;){var C=g;g=m;for(var B=0;B<r.length;B++)if(C.context===r[B]){g.lanes|=l,C=g.alternate,C!==null&&(C.lanes|=l),_h(g.return,l,n),u||(y=null);break e}g=C.next}}else if(m.tag===18){if(y=m.return,y===null)throw Error(s(341));y.lanes|=l,g=y.alternate,g!==null&&(g.lanes|=l),_h(y,l,n),y=null}else y=m.child;if(y!==null)y.return=m;else for(y=m;y!==null;){if(y===n){y=null;break}if(m=y.sibling,m!==null){m.return=y.return,y=m;break}y=y.return}m=y}}function Ma(n,r,l,u){n=null;for(var m=r,g=!1;m!==null;){if(!g){if((m.flags&524288)!==0)g=!0;else if((m.flags&262144)!==0)break}if(m.tag===10){var y=m.alternate;if(y===null)throw Error(s(387));if(y=y.memoizedProps,y!==null){var C=m.type;zn(m.pendingProps.value,y.value)||(n!==null?n.push(C):n=[C])}}else if(m===X.current){if(y=m.alternate,y===null)throw Error(s(387));y.memoizedState.memoizedState!==m.memoizedState.memoizedState&&(n!==null?n.push(no):n=[no])}m=m.return}n!==null&&xh(r,n,l,u),r.flags|=262144}function sc(n){for(n=n.firstContext;n!==null;){if(!zn(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function Js(n){Qs=n,Hr=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function en(n){return lg(Qs,n)}function ac(n,r){return Qs===null&&Js(n),lg(n,r)}function lg(n,r){var l=r._currentValue;if(r={context:r,memoizedValue:l,next:null},Hr===null){if(n===null)throw Error(s(308));Hr=r,n.dependencies={lanes:0,firstContext:r},n.flags|=524288}else Hr=Hr.next=r;return l}var V1=typeof AbortController<"u"?AbortController:function(){var n=[],r=this.signal={aborted:!1,addEventListener:function(l,u){n.push(u)}};this.abort=function(){r.aborted=!0,n.forEach(function(l){return l()})}},X1=e.unstable_scheduleCallback,Z1=e.unstable_NormalPriority,Ti={$$typeof:z,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function bh(){return{controller:new V1,data:new Map,refCount:0}}function Rl(n){n.refCount--,n.refCount===0&&X1(Z1,function(){n.controller.abort()})}var Dl=null,vh=0,Ba=0,La=null;function Q1(n,r){if(Dl===null){var l=Dl=[];vh=0,Ba=wd(),La={status:"pending",value:void 0,then:function(u){l.push(u)}}}return vh++,r.then(og,og),r}function og(){if(--vh===0&&Dl!==null){La!==null&&(La.status="fulfilled");var n=Dl;Dl=null,Ba=0,La=null;for(var r=0;r<n.length;r++)(0,n[r])()}}function J1(n,r){var l=[],u={status:"pending",value:null,reason:null,then:function(m){l.push(m)}};return n.then(function(){u.status="fulfilled",u.value=r;for(var m=0;m<l.length;m++)(0,l[m])(r)},function(m){for(u.status="rejected",u.reason=m,m=0;m<l.length;m++)(0,l[m])(void 0)}),u}var cg=A.S;A.S=function(n,r){G_=yt(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&Q1(n,r),cg!==null&&cg(n,r)};var ea=D(null);function yh(){var n=ea.current;return n!==null?n:Vt.pooledCache}function lc(n,r){r===null?k(ea,ea.current):k(ea,r.pool)}function ug(){var n=yh();return n===null?null:{parent:Ti._currentValue,pool:n}}var Oa=Error(s(460)),Sh=Error(s(474)),oc=Error(s(542)),cc={then:function(){}};function hg(n){return n=n.status,n==="fulfilled"||n==="rejected"}function dg(n,r,l){switch(l=n[l],l===void 0?n.push(r):l!==r&&(r.then(Zn,Zn),r=l),r.status){case"fulfilled":return r.value;case"rejected":throw n=r.reason,pg(n),n;default:if(typeof r.status=="string")r.then(Zn,Zn);else{if(n=Vt,n!==null&&100<n.shellSuspendCounter)throw Error(s(482));n=r,n.status="pending",n.then(function(u){if(r.status==="pending"){var m=r;m.status="fulfilled",m.value=u}},function(u){if(r.status==="pending"){var m=r;m.status="rejected",m.reason=u}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw n=r.reason,pg(n),n}throw ia=r,Oa}}function ta(n){try{var r=n._init;return r(n._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(ia=l,Oa):l}}var ia=null;function fg(){if(ia===null)throw Error(s(459));var n=ia;return ia=null,n}function pg(n){if(n===Oa||n===oc)throw Error(s(483))}var za=null,Ml=0;function uc(n){var r=Ml;return Ml+=1,za===null&&(za=[]),dg(za,n,r)}function Bl(n,r){r=r.props.ref,n.ref=r!==void 0?r:null}function hc(n,r){throw r.$$typeof===b?Error(s(525)):(n=Object.prototype.toString.call(r),Error(s(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n)))}function mg(n){function r(W,P){if(n){var Z=W.deletions;Z===null?(W.deletions=[P],W.flags|=16):Z.push(P)}}function l(W,P){if(!n)return null;for(;P!==null;)r(W,P),P=P.sibling;return null}function u(W){for(var P=new Map;W!==null;)W.key!==null?P.set(W.key,W):P.set(W.index,W),W=W.sibling;return P}function m(W,P){return W=Pr(W,P),W.index=0,W.sibling=null,W}function g(W,P,Z){return W.index=Z,n?(Z=W.alternate,Z!==null?(Z=Z.index,Z<P?(W.flags|=67108866,P):Z):(W.flags|=67108866,P)):(W.flags|=1048576,P)}function y(W){return n&&W.alternate===null&&(W.flags|=67108866),W}function C(W,P,Z,pe){return P===null||P.tag!==6?(P=uh(Z,W.mode,pe),P.return=W,P):(P=m(P,Z),P.return=W,P)}function B(W,P,Z,pe){var We=Z.type;return We===N?ce(W,P,Z.props.children,pe,Z.key):P!==null&&(P.elementType===We||typeof We=="object"&&We!==null&&We.$$typeof===re&&ta(We)===P.type)?(P=m(P,Z.props),Bl(P,Z),P.return=W,P):(P=nc(Z.type,Z.key,Z.props,null,W.mode,pe),Bl(P,Z),P.return=W,P)}function Q(W,P,Z,pe){return P===null||P.tag!==4||P.stateNode.containerInfo!==Z.containerInfo||P.stateNode.implementation!==Z.implementation?(P=hh(Z,W.mode,pe),P.return=W,P):(P=m(P,Z.children||[]),P.return=W,P)}function ce(W,P,Z,pe,We){return P===null||P.tag!==7?(P=Xs(Z,W.mode,pe,We),P.return=W,P):(P=m(P,Z),P.return=W,P)}function me(W,P,Z){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=uh(""+P,W.mode,Z),P.return=W,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case v:return Z=nc(P.type,P.key,P.props,null,W.mode,Z),Bl(Z,P),Z.return=W,Z;case S:return P=hh(P,W.mode,Z),P.return=W,P;case re:return P=ta(P),me(W,P,Z)}if(U(P)||F(P))return P=Xs(P,W.mode,Z,null),P.return=W,P;if(typeof P.then=="function")return me(W,uc(P),Z);if(P.$$typeof===z)return me(W,ac(W,P),Z);hc(W,P)}return null}function ee(W,P,Z,pe){var We=P!==null?P.key:null;if(typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint")return We!==null?null:C(W,P,""+Z,pe);if(typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case v:return Z.key===We?B(W,P,Z,pe):null;case S:return Z.key===We?Q(W,P,Z,pe):null;case re:return Z=ta(Z),ee(W,P,Z,pe)}if(U(Z)||F(Z))return We!==null?null:ce(W,P,Z,pe,null);if(typeof Z.then=="function")return ee(W,P,uc(Z),pe);if(Z.$$typeof===z)return ee(W,P,ac(W,Z),pe);hc(W,Z)}return null}function ae(W,P,Z,pe,We){if(typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint")return W=W.get(Z)||null,C(P,W,""+pe,We);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case v:return W=W.get(pe.key===null?Z:pe.key)||null,B(P,W,pe,We);case S:return W=W.get(pe.key===null?Z:pe.key)||null,Q(P,W,pe,We);case re:return pe=ta(pe),ae(W,P,Z,pe,We)}if(U(pe)||F(pe))return W=W.get(Z)||null,ce(P,W,pe,We,null);if(typeof pe.then=="function")return ae(W,P,Z,uc(pe),We);if(pe.$$typeof===z)return ae(W,P,Z,ac(P,pe),We);hc(P,pe)}return null}function Le(W,P,Z,pe){for(var We=null,jt=null,Ue=P,lt=P=0,vt=null;Ue!==null&&lt<Z.length;lt++){Ue.index>lt?(vt=Ue,Ue=null):vt=Ue.sibling;var At=ee(W,Ue,Z[lt],pe);if(At===null){Ue===null&&(Ue=vt);break}n&&Ue&&At.alternate===null&&r(W,Ue),P=g(At,P,lt),jt===null?We=At:jt.sibling=At,jt=At,Ue=vt}if(lt===Z.length)return l(W,Ue),St&&Ir(W,lt),We;if(Ue===null){for(;lt<Z.length;lt++)Ue=me(W,Z[lt],pe),Ue!==null&&(P=g(Ue,P,lt),jt===null?We=Ue:jt.sibling=Ue,jt=Ue);return St&&Ir(W,lt),We}for(Ue=u(Ue);lt<Z.length;lt++)vt=ae(Ue,W,lt,Z[lt],pe),vt!==null&&(n&&vt.alternate!==null&&Ue.delete(vt.key===null?lt:vt.key),P=g(vt,P,lt),jt===null?We=vt:jt.sibling=vt,jt=vt);return n&&Ue.forEach(function(As){return r(W,As)}),St&&Ir(W,lt),We}function Ve(W,P,Z,pe){if(Z==null)throw Error(s(151));for(var We=null,jt=null,Ue=P,lt=P=0,vt=null,At=Z.next();Ue!==null&&!At.done;lt++,At=Z.next()){Ue.index>lt?(vt=Ue,Ue=null):vt=Ue.sibling;var As=ee(W,Ue,At.value,pe);if(As===null){Ue===null&&(Ue=vt);break}n&&Ue&&As.alternate===null&&r(W,Ue),P=g(As,P,lt),jt===null?We=As:jt.sibling=As,jt=As,Ue=vt}if(At.done)return l(W,Ue),St&&Ir(W,lt),We;if(Ue===null){for(;!At.done;lt++,At=Z.next())At=me(W,At.value,pe),At!==null&&(P=g(At,P,lt),jt===null?We=At:jt.sibling=At,jt=At);return St&&Ir(W,lt),We}for(Ue=u(Ue);!At.done;lt++,At=Z.next())At=ae(Ue,W,lt,At.value,pe),At!==null&&(n&&At.alternate!==null&&Ue.delete(At.key===null?lt:At.key),P=g(At,P,lt),jt===null?We=At:jt.sibling=At,jt=At);return n&&Ue.forEach(function(uC){return r(W,uC)}),St&&Ir(W,lt),We}function qt(W,P,Z,pe){if(typeof Z=="object"&&Z!==null&&Z.type===N&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case v:e:{for(var We=Z.key;P!==null;){if(P.key===We){if(We=Z.type,We===N){if(P.tag===7){l(W,P.sibling),pe=m(P,Z.props.children),pe.return=W,W=pe;break e}}else if(P.elementType===We||typeof We=="object"&&We!==null&&We.$$typeof===re&&ta(We)===P.type){l(W,P.sibling),pe=m(P,Z.props),Bl(pe,Z),pe.return=W,W=pe;break e}l(W,P);break}else r(W,P);P=P.sibling}Z.type===N?(pe=Xs(Z.props.children,W.mode,pe,Z.key),pe.return=W,W=pe):(pe=nc(Z.type,Z.key,Z.props,null,W.mode,pe),Bl(pe,Z),pe.return=W,W=pe)}return y(W);case S:e:{for(We=Z.key;P!==null;){if(P.key===We)if(P.tag===4&&P.stateNode.containerInfo===Z.containerInfo&&P.stateNode.implementation===Z.implementation){l(W,P.sibling),pe=m(P,Z.children||[]),pe.return=W,W=pe;break e}else{l(W,P);break}else r(W,P);P=P.sibling}pe=hh(Z,W.mode,pe),pe.return=W,W=pe}return y(W);case re:return Z=ta(Z),qt(W,P,Z,pe)}if(U(Z))return Le(W,P,Z,pe);if(F(Z)){if(We=F(Z),typeof We!="function")throw Error(s(150));return Z=We.call(Z),Ve(W,P,Z,pe)}if(typeof Z.then=="function")return qt(W,P,uc(Z),pe);if(Z.$$typeof===z)return qt(W,P,ac(W,Z),pe);hc(W,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,P!==null&&P.tag===6?(l(W,P.sibling),pe=m(P,Z),pe.return=W,W=pe):(l(W,P),pe=uh(Z,W.mode,pe),pe.return=W,W=pe),y(W)):l(W,P)}return function(W,P,Z,pe){try{Ml=0;var We=qt(W,P,Z,pe);return za=null,We}catch(Ue){if(Ue===Oa||Ue===oc)throw Ue;var jt=Pn(29,Ue,null,W.mode);return jt.lanes=pe,jt.return=W,jt}finally{}}}var na=mg(!0),gg=mg(!1),fs=!1;function wh(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ch(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function ps(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function ms(n,r,l){var u=n.updateQueue;if(u===null)return null;if(u=u.shared,(Mt&2)!==0){var m=u.pending;return m===null?r.next=r:(r.next=m.next,m.next=r),u.pending=r,r=ic(n),Jm(n,null,l),r}return tc(n,u,r,l),ic(n)}function Ll(n,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var u=r.lanes;u&=n.pendingLanes,l|=u,r.lanes=l,Nt(n,l)}}function kh(n,r){var l=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var m=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var y={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};g===null?m=g=y:g=g.next=y,l=l.next}while(l!==null);g===null?m=g=r:g=g.next=r}else m=g=r;l={baseState:u.baseState,firstBaseUpdate:m,lastBaseUpdate:g,shared:u.shared,callbacks:u.callbacks},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=r:n.next=r,l.lastBaseUpdate=r}var Eh=!1;function Ol(){if(Eh){var n=La;if(n!==null)throw n}}function zl(n,r,l,u){Eh=!1;var m=n.updateQueue;fs=!1;var g=m.firstBaseUpdate,y=m.lastBaseUpdate,C=m.shared.pending;if(C!==null){m.shared.pending=null;var B=C,Q=B.next;B.next=null,y===null?g=Q:y.next=Q,y=B;var ce=n.alternate;ce!==null&&(ce=ce.updateQueue,C=ce.lastBaseUpdate,C!==y&&(C===null?ce.firstBaseUpdate=Q:C.next=Q,ce.lastBaseUpdate=B))}if(g!==null){var me=m.baseState;y=0,ce=Q=B=null,C=g;do{var ee=C.lane&-536870913,ae=ee!==C.lane;if(ae?(bt&ee)===ee:(u&ee)===ee){ee!==0&&ee===Ba&&(Eh=!0),ce!==null&&(ce=ce.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var Le=n,Ve=C;ee=r;var qt=l;switch(Ve.tag){case 1:if(Le=Ve.payload,typeof Le=="function"){me=Le.call(qt,me,ee);break e}me=Le;break e;case 3:Le.flags=Le.flags&-65537|128;case 0:if(Le=Ve.payload,ee=typeof Le=="function"?Le.call(qt,me,ee):Le,ee==null)break e;me=_({},me,ee);break e;case 2:fs=!0}}ee=C.callback,ee!==null&&(n.flags|=64,ae&&(n.flags|=8192),ae=m.callbacks,ae===null?m.callbacks=[ee]:ae.push(ee))}else ae={lane:ee,tag:C.tag,payload:C.payload,callback:C.callback,next:null},ce===null?(Q=ce=ae,B=me):ce=ce.next=ae,y|=ee;if(C=C.next,C===null){if(C=m.shared.pending,C===null)break;ae=C,C=ae.next,ae.next=null,m.lastBaseUpdate=ae,m.shared.pending=null}}while(!0);ce===null&&(B=me),m.baseState=B,m.firstBaseUpdate=Q,m.lastBaseUpdate=ce,g===null&&(m.shared.lanes=0),vs|=y,n.lanes=y,n.memoizedState=me}}function _g(n,r){if(typeof n!="function")throw Error(s(191,n));n.call(r)}function xg(n,r){var l=n.callbacks;if(l!==null)for(n.callbacks=null,n=0;n<l.length;n++)_g(l[n],r)}var Pa=D(null),dc=D(0);function bg(n,r){n=Xr,k(dc,n),k(Pa,r),Xr=n|r.baseLanes}function Nh(){k(dc,Xr),k(Pa,Pa.current)}function Th(){Xr=dc.current,V(Pa),V(dc)}var In=D(null),rr=null;function gs(n){var r=n.alternate;k(Si,Si.current&1),k(In,n),rr===null&&(r===null||Pa.current!==null||r.memoizedState!==null)&&(rr=n)}function jh(n){k(Si,Si.current),k(In,n),rr===null&&(rr=n)}function vg(n){n.tag===22?(k(Si,Si.current),k(In,n),rr===null&&(rr=n)):_s()}function _s(){k(Si,Si.current),k(In,In.current)}function Hn(n){V(In),rr===n&&(rr=null),V(Si)}var Si=D(0);function fc(n){for(var r=n;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Ld(l)||Od(l)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var $r=0,rt=null,$t=null,ji=null,pc=!1,Ia=!1,ra=!1,mc=0,Pl=0,Ha=null,ew=0;function di(){throw Error(s(321))}function Ah(n,r){if(r===null)return!1;for(var l=0;l<r.length&&l<n.length;l++)if(!zn(n[l],r[l]))return!1;return!0}function Rh(n,r,l,u,m,g){return $r=g,rt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,A.H=n===null||n.memoizedState===null?n_:Gh,ra=!1,g=l(u,m),ra=!1,Ia&&(g=Sg(r,l,u,m)),yg(n),g}function yg(n){A.H=Ul;var r=$t!==null&&$t.next!==null;if($r=0,ji=$t=rt=null,pc=!1,Pl=0,Ha=null,r)throw Error(s(300));n===null||Ai||(n=n.dependencies,n!==null&&sc(n)&&(Ai=!0))}function Sg(n,r,l,u){rt=n;var m=0;do{if(Ia&&(Ha=null),Pl=0,Ia=!1,25<=m)throw Error(s(301));if(m+=1,ji=$t=null,n.updateQueue!=null){var g=n.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}A.H=r_,g=r(l,u)}while(Ia);return g}function tw(){var n=A.H,r=n.useState()[0];return r=typeof r.then=="function"?Il(r):r,n=n.useState()[0],($t!==null?$t.memoizedState:null)!==n&&(rt.flags|=1024),r}function Dh(){var n=mc!==0;return mc=0,n}function Mh(n,r,l){r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~l}function Bh(n){if(pc){for(n=n.memoizedState;n!==null;){var r=n.queue;r!==null&&(r.pending=null),n=n.next}pc=!1}$r=0,ji=$t=rt=null,Ia=!1,Pl=mc=0,Ha=null}function _n(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ji===null?rt.memoizedState=ji=n:ji=ji.next=n,ji}function wi(){if($t===null){var n=rt.alternate;n=n!==null?n.memoizedState:null}else n=$t.next;var r=ji===null?rt.memoizedState:ji.next;if(r!==null)ji=r,$t=n;else{if(n===null)throw rt.alternate===null?Error(s(467)):Error(s(310));$t=n,n={memoizedState:$t.memoizedState,baseState:$t.baseState,baseQueue:$t.baseQueue,queue:$t.queue,next:null},ji===null?rt.memoizedState=ji=n:ji=ji.next=n}return ji}function gc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Il(n){var r=Pl;return Pl+=1,Ha===null&&(Ha=[]),n=dg(Ha,n,r),r=rt,(ji===null?r.memoizedState:ji.next)===null&&(r=r.alternate,A.H=r===null||r.memoizedState===null?n_:Gh),n}function _c(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return Il(n);if(n.$$typeof===z)return en(n)}throw Error(s(438,String(n)))}function Lh(n){var r=null,l=rt.updateQueue;if(l!==null&&(r=l.memoCache),r==null){var u=rt.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(r={data:u.data.map(function(m){return m.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),l===null&&(l=gc(),rt.updateQueue=l),l.memoCache=r,l=r.data[r.index],l===void 0)for(l=r.data[r.index]=Array(n),u=0;u<n;u++)l[u]=j;return r.index++,l}function Fr(n,r){return typeof r=="function"?r(n):r}function xc(n){var r=wi();return Oh(r,$t,n)}function Oh(n,r,l){var u=n.queue;if(u===null)throw Error(s(311));u.lastRenderedReducer=l;var m=n.baseQueue,g=u.pending;if(g!==null){if(m!==null){var y=m.next;m.next=g.next,g.next=y}r.baseQueue=m=g,u.pending=null}if(g=n.baseState,m===null)n.memoizedState=g;else{r=m.next;var C=y=null,B=null,Q=r,ce=!1;do{var me=Q.lane&-536870913;if(me!==Q.lane?(bt&me)===me:($r&me)===me){var ee=Q.revertLane;if(ee===0)B!==null&&(B=B.next={lane:0,revertLane:0,gesture:null,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null}),me===Ba&&(ce=!0);else if(($r&ee)===ee){Q=Q.next,ee===Ba&&(ce=!0);continue}else me={lane:0,revertLane:Q.revertLane,gesture:null,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null},B===null?(C=B=me,y=g):B=B.next=me,rt.lanes|=ee,vs|=ee;me=Q.action,ra&&l(g,me),g=Q.hasEagerState?Q.eagerState:l(g,me)}else ee={lane:me,revertLane:Q.revertLane,gesture:Q.gesture,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null},B===null?(C=B=ee,y=g):B=B.next=ee,rt.lanes|=me,vs|=me;Q=Q.next}while(Q!==null&&Q!==r);if(B===null?y=g:B.next=C,!zn(g,n.memoizedState)&&(Ai=!0,ce&&(l=La,l!==null)))throw l;n.memoizedState=g,n.baseState=y,n.baseQueue=B,u.lastRenderedState=g}return m===null&&(u.lanes=0),[n.memoizedState,u.dispatch]}function zh(n){var r=wi(),l=r.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=n;var u=l.dispatch,m=l.pending,g=r.memoizedState;if(m!==null){l.pending=null;var y=m=m.next;do g=n(g,y.action),y=y.next;while(y!==m);zn(g,r.memoizedState)||(Ai=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,u]}function wg(n,r,l){var u=rt,m=wi(),g=St;if(g){if(l===void 0)throw Error(s(407));l=l()}else l=r();var y=!zn(($t||m).memoizedState,l);if(y&&(m.memoizedState=l,Ai=!0),m=m.queue,Hh(Eg.bind(null,u,m,n),[n]),m.getSnapshot!==r||y||ji!==null&&ji.memoizedState.tag&1){if(u.flags|=2048,Ua(9,{destroy:void 0},kg.bind(null,u,m,l,r),null),Vt===null)throw Error(s(349));g||($r&127)!==0||Cg(u,r,l)}return l}function Cg(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=rt.updateQueue,r===null?(r=gc(),rt.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function kg(n,r,l,u){r.value=l,r.getSnapshot=u,Ng(r)&&Tg(n)}function Eg(n,r,l){return l(function(){Ng(r)&&Tg(n)})}function Ng(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!zn(n,l)}catch{return!0}}function Tg(n){var r=Vs(n,2);r!==null&&Dn(r,n,2)}function Ph(n){var r=_n();if(typeof n=="function"){var l=n;if(n=l(),ra){Tt(!0);try{l()}finally{Tt(!1)}}}return r.memoizedState=r.baseState=n,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fr,lastRenderedState:n},r}function jg(n,r,l,u){return n.baseState=l,Oh(n,$t,typeof u=="function"?u:Fr)}function iw(n,r,l,u,m){if(yc(n))throw Error(s(485));if(n=r.action,n!==null){var g={payload:m,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){g.listeners.push(y)}};A.T!==null?l(!0):g.isTransition=!1,u(g),l=r.pending,l===null?(g.next=r.pending=g,Ag(r,g)):(g.next=l.next,r.pending=l.next=g)}}function Ag(n,r){var l=r.action,u=r.payload,m=n.state;if(r.isTransition){var g=A.T,y={};A.T=y;try{var C=l(m,u),B=A.S;B!==null&&B(y,C),Rg(n,r,C)}catch(Q){Ih(n,r,Q)}finally{g!==null&&y.types!==null&&(g.types=y.types),A.T=g}}else try{g=l(m,u),Rg(n,r,g)}catch(Q){Ih(n,r,Q)}}function Rg(n,r,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(u){Dg(n,r,u)},function(u){return Ih(n,r,u)}):Dg(n,r,l)}function Dg(n,r,l){r.status="fulfilled",r.value=l,Mg(r),n.state=l,r=n.pending,r!==null&&(l=r.next,l===r?n.pending=null:(l=l.next,r.next=l,Ag(n,l)))}function Ih(n,r,l){var u=n.pending;if(n.pending=null,u!==null){u=u.next;do r.status="rejected",r.reason=l,Mg(r),r=r.next;while(r!==u)}n.action=null}function Mg(n){n=n.listeners;for(var r=0;r<n.length;r++)(0,n[r])()}function Bg(n,r){return r}function Lg(n,r){if(St){var l=Vt.formState;if(l!==null){e:{var u=rt;if(St){if(ii){t:{for(var m=ii,g=nr;m.nodeType!==8;){if(!g){m=null;break t}if(m=sr(m.nextSibling),m===null){m=null;break t}}g=m.data,m=g==="F!"||g==="F"?m:null}if(m){ii=sr(m.nextSibling),u=m.data==="F!";break e}}hs(u)}u=!1}u&&(r=l[0])}}return l=_n(),l.memoizedState=l.baseState=r,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bg,lastRenderedState:r},l.queue=u,l=e_.bind(null,rt,u),u.dispatch=l,u=Ph(!1),g=Wh.bind(null,rt,!1,u.queue),u=_n(),m={state:r,dispatch:null,action:n,pending:null},u.queue=m,l=iw.bind(null,rt,m,g,l),m.dispatch=l,u.memoizedState=n,[r,l,!1]}function Og(n){var r=wi();return zg(r,$t,n)}function zg(n,r,l){if(r=Oh(n,r,Bg)[0],n=xc(Fr)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var u=Il(r)}catch(y){throw y===Oa?oc:y}else u=r;r=wi();var m=r.queue,g=m.dispatch;return l!==r.memoizedState&&(rt.flags|=2048,Ua(9,{destroy:void 0},nw.bind(null,m,l),null)),[u,g,n]}function nw(n,r){n.action=r}function Pg(n){var r=wi(),l=$t;if(l!==null)return zg(r,l,n);wi(),r=r.memoizedState,l=wi();var u=l.queue.dispatch;return l.memoizedState=n,[r,u,!1]}function Ua(n,r,l,u){return n={tag:n,create:l,deps:u,inst:r,next:null},r=rt.updateQueue,r===null&&(r=gc(),rt.updateQueue=r),l=r.lastEffect,l===null?r.lastEffect=n.next=n:(u=l.next,l.next=n,n.next=u,r.lastEffect=n),n}function Ig(){return wi().memoizedState}function bc(n,r,l,u){var m=_n();rt.flags|=n,m.memoizedState=Ua(1|r,{destroy:void 0},l,u===void 0?null:u)}function vc(n,r,l,u){var m=wi();u=u===void 0?null:u;var g=m.memoizedState.inst;$t!==null&&u!==null&&Ah(u,$t.memoizedState.deps)?m.memoizedState=Ua(r,g,l,u):(rt.flags|=n,m.memoizedState=Ua(1|r,g,l,u))}function Hg(n,r){bc(8390656,8,n,r)}function Hh(n,r){vc(2048,8,n,r)}function rw(n){rt.flags|=4;var r=rt.updateQueue;if(r===null)r=gc(),rt.updateQueue=r,r.events=[n];else{var l=r.events;l===null?r.events=[n]:l.push(n)}}function Ug(n){var r=wi().memoizedState;return rw({ref:r,nextImpl:n}),function(){if((Mt&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}function $g(n,r){return vc(4,2,n,r)}function Fg(n,r){return vc(4,4,n,r)}function qg(n,r){if(typeof r=="function"){n=n();var l=r(n);return function(){typeof l=="function"?l():r(null)}}if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function Wg(n,r,l){l=l!=null?l.concat([n]):null,vc(4,4,qg.bind(null,r,n),l)}function Uh(){}function Gg(n,r){var l=wi();r=r===void 0?null:r;var u=l.memoizedState;return r!==null&&Ah(r,u[1])?u[0]:(l.memoizedState=[n,r],n)}function Yg(n,r){var l=wi();r=r===void 0?null:r;var u=l.memoizedState;if(r!==null&&Ah(r,u[1]))return u[0];if(u=n(),ra){Tt(!0);try{n()}finally{Tt(!1)}}return l.memoizedState=[u,r],u}function $h(n,r,l){return l===void 0||($r&1073741824)!==0&&(bt&261930)===0?n.memoizedState=r:(n.memoizedState=l,n=K_(),rt.lanes|=n,vs|=n,l)}function Kg(n,r,l,u){return zn(l,r)?l:Pa.current!==null?(n=$h(n,l,u),zn(n,r)||(Ai=!0),n):($r&42)===0||($r&1073741824)!==0&&(bt&261930)===0?(Ai=!0,n.memoizedState=l):(n=K_(),rt.lanes|=n,vs|=n,r)}function Vg(n,r,l,u,m){var g=q.p;q.p=g!==0&&8>g?g:8;var y=A.T,C={};A.T=C,Wh(n,!1,r,l);try{var B=m(),Q=A.S;if(Q!==null&&Q(C,B),B!==null&&typeof B=="object"&&typeof B.then=="function"){var ce=J1(B,u);Hl(n,r,ce,Fn(n))}else Hl(n,r,u,Fn(n))}catch(me){Hl(n,r,{then:function(){},status:"rejected",reason:me},Fn())}finally{q.p=g,y!==null&&C.types!==null&&(y.types=C.types),A.T=y}}function sw(){}function Fh(n,r,l,u){if(n.tag!==5)throw Error(s(476));var m=Xg(n).queue;Vg(n,m,r,$,l===null?sw:function(){return Zg(n),l(u)})}function Xg(n){var r=n.memoizedState;if(r!==null)return r;r={memoizedState:$,baseState:$,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fr,lastRenderedState:$},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fr,lastRenderedState:l},next:null},n.memoizedState=r,n=n.alternate,n!==null&&(n.memoizedState=r),r}function Zg(n){var r=Xg(n);r.next===null&&(r=n.alternate.memoizedState),Hl(n,r.next.queue,{},Fn())}function qh(){return en(no)}function Qg(){return wi().memoizedState}function Jg(){return wi().memoizedState}function aw(n){for(var r=n.return;r!==null;){switch(r.tag){case 24:case 3:var l=Fn();n=ps(l);var u=ms(r,n,l);u!==null&&(Dn(u,r,l),Ll(u,r,l)),r={cache:bh()},n.payload=r;return}r=r.return}}function lw(n,r,l){var u=Fn();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},yc(n)?t_(r,l):(l=oh(n,r,l,u),l!==null&&(Dn(l,n,u),i_(l,r,u)))}function e_(n,r,l){var u=Fn();Hl(n,r,l,u)}function Hl(n,r,l,u){var m={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(yc(n))t_(r,m);else{var g=n.alternate;if(n.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var y=r.lastRenderedState,C=g(y,l);if(m.hasEagerState=!0,m.eagerState=C,zn(C,y))return tc(n,r,m,0),Vt===null&&ec(),!1}catch{}finally{}if(l=oh(n,r,m,u),l!==null)return Dn(l,n,u),i_(l,r,u),!0}return!1}function Wh(n,r,l,u){if(u={lane:2,revertLane:wd(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},yc(n)){if(r)throw Error(s(479))}else r=oh(n,l,u,2),r!==null&&Dn(r,n,2)}function yc(n){var r=n.alternate;return n===rt||r!==null&&r===rt}function t_(n,r){Ia=pc=!0;var l=n.pending;l===null?r.next=r:(r.next=l.next,l.next=r),n.pending=r}function i_(n,r,l){if((l&4194048)!==0){var u=r.lanes;u&=n.pendingLanes,l|=u,r.lanes=l,Nt(n,l)}}var Ul={readContext:en,use:_c,useCallback:di,useContext:di,useEffect:di,useImperativeHandle:di,useLayoutEffect:di,useInsertionEffect:di,useMemo:di,useReducer:di,useRef:di,useState:di,useDebugValue:di,useDeferredValue:di,useTransition:di,useSyncExternalStore:di,useId:di,useHostTransitionStatus:di,useFormState:di,useActionState:di,useOptimistic:di,useMemoCache:di,useCacheRefresh:di};Ul.useEffectEvent=di;var n_={readContext:en,use:_c,useCallback:function(n,r){return _n().memoizedState=[n,r===void 0?null:r],n},useContext:en,useEffect:Hg,useImperativeHandle:function(n,r,l){l=l!=null?l.concat([n]):null,bc(4194308,4,qg.bind(null,r,n),l)},useLayoutEffect:function(n,r){return bc(4194308,4,n,r)},useInsertionEffect:function(n,r){bc(4,2,n,r)},useMemo:function(n,r){var l=_n();r=r===void 0?null:r;var u=n();if(ra){Tt(!0);try{n()}finally{Tt(!1)}}return l.memoizedState=[u,r],u},useReducer:function(n,r,l){var u=_n();if(l!==void 0){var m=l(r);if(ra){Tt(!0);try{l(r)}finally{Tt(!1)}}}else m=r;return u.memoizedState=u.baseState=m,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:m},u.queue=n,n=n.dispatch=lw.bind(null,rt,n),[u.memoizedState,n]},useRef:function(n){var r=_n();return n={current:n},r.memoizedState=n},useState:function(n){n=Ph(n);var r=n.queue,l=e_.bind(null,rt,r);return r.dispatch=l,[n.memoizedState,l]},useDebugValue:Uh,useDeferredValue:function(n,r){var l=_n();return $h(l,n,r)},useTransition:function(){var n=Ph(!1);return n=Vg.bind(null,rt,n.queue,!0,!1),_n().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,r,l){var u=rt,m=_n();if(St){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),Vt===null)throw Error(s(349));(bt&127)!==0||Cg(u,r,l)}m.memoizedState=l;var g={value:l,getSnapshot:r};return m.queue=g,Hg(Eg.bind(null,u,g,n),[n]),u.flags|=2048,Ua(9,{destroy:void 0},kg.bind(null,u,g,l,r),null),l},useId:function(){var n=_n(),r=Vt.identifierPrefix;if(St){var l=wr,u=Sr;l=(u&~(1<<32-ct(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=mc++,0<l&&(r+="H"+l.toString(32)),r+="_"}else l=ew++,r="_"+r+"r_"+l.toString(32)+"_";return n.memoizedState=r},useHostTransitionStatus:qh,useFormState:Lg,useActionState:Lg,useOptimistic:function(n){var r=_n();r.memoizedState=r.baseState=n;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=l,r=Wh.bind(null,rt,!0,l),l.dispatch=r,[n,r]},useMemoCache:Lh,useCacheRefresh:function(){return _n().memoizedState=aw.bind(null,rt)},useEffectEvent:function(n){var r=_n(),l={impl:n};return r.memoizedState=l,function(){if((Mt&2)!==0)throw Error(s(440));return l.impl.apply(void 0,arguments)}}},Gh={readContext:en,use:_c,useCallback:Gg,useContext:en,useEffect:Hh,useImperativeHandle:Wg,useInsertionEffect:$g,useLayoutEffect:Fg,useMemo:Yg,useReducer:xc,useRef:Ig,useState:function(){return xc(Fr)},useDebugValue:Uh,useDeferredValue:function(n,r){var l=wi();return Kg(l,$t.memoizedState,n,r)},useTransition:function(){var n=xc(Fr)[0],r=wi().memoizedState;return[typeof n=="boolean"?n:Il(n),r]},useSyncExternalStore:wg,useId:Qg,useHostTransitionStatus:qh,useFormState:Og,useActionState:Og,useOptimistic:function(n,r){var l=wi();return jg(l,$t,n,r)},useMemoCache:Lh,useCacheRefresh:Jg};Gh.useEffectEvent=Ug;var r_={readContext:en,use:_c,useCallback:Gg,useContext:en,useEffect:Hh,useImperativeHandle:Wg,useInsertionEffect:$g,useLayoutEffect:Fg,useMemo:Yg,useReducer:zh,useRef:Ig,useState:function(){return zh(Fr)},useDebugValue:Uh,useDeferredValue:function(n,r){var l=wi();return $t===null?$h(l,n,r):Kg(l,$t.memoizedState,n,r)},useTransition:function(){var n=zh(Fr)[0],r=wi().memoizedState;return[typeof n=="boolean"?n:Il(n),r]},useSyncExternalStore:wg,useId:Qg,useHostTransitionStatus:qh,useFormState:Pg,useActionState:Pg,useOptimistic:function(n,r){var l=wi();return $t!==null?jg(l,$t,n,r):(l.baseState=n,[n,l.queue.dispatch])},useMemoCache:Lh,useCacheRefresh:Jg};r_.useEffectEvent=Ug;function Yh(n,r,l,u){r=n.memoizedState,l=l(u,r),l=l==null?r:_({},r,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var Kh={enqueueSetState:function(n,r,l){n=n._reactInternals;var u=Fn(),m=ps(u);m.payload=r,l!=null&&(m.callback=l),r=ms(n,m,u),r!==null&&(Dn(r,n,u),Ll(r,n,u))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var u=Fn(),m=ps(u);m.tag=1,m.payload=r,l!=null&&(m.callback=l),r=ms(n,m,u),r!==null&&(Dn(r,n,u),Ll(r,n,u))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=Fn(),u=ps(l);u.tag=2,r!=null&&(u.callback=r),r=ms(n,u,l),r!==null&&(Dn(r,n,l),Ll(r,n,l))}};function s_(n,r,l,u,m,g,y){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,g,y):r.prototype&&r.prototype.isPureReactComponent?!Nl(l,u)||!Nl(m,g):!0}function a_(n,r,l,u){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,u),r.state!==n&&Kh.enqueueReplaceState(r,r.state,null)}function sa(n,r){var l=r;if("ref"in r){l={};for(var u in r)u!=="ref"&&(l[u]=r[u])}if(n=n.defaultProps){l===r&&(l=_({},l));for(var m in n)l[m]===void 0&&(l[m]=n[m])}return l}function l_(n){Jo(n)}function o_(n){console.error(n)}function c_(n){Jo(n)}function Sc(n,r){try{var l=n.onUncaughtError;l(r.value,{componentStack:r.stack})}catch(u){setTimeout(function(){throw u})}}function u_(n,r,l){try{var u=n.onCaughtError;u(l.value,{componentStack:l.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(m){setTimeout(function(){throw m})}}function Vh(n,r,l){return l=ps(l),l.tag=3,l.payload={element:null},l.callback=function(){Sc(n,r)},l}function h_(n){return n=ps(n),n.tag=3,n}function d_(n,r,l,u){var m=l.type.getDerivedStateFromError;if(typeof m=="function"){var g=u.value;n.payload=function(){return m(g)},n.callback=function(){u_(r,l,u)}}var y=l.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(n.callback=function(){u_(r,l,u),typeof m!="function"&&(ys===null?ys=new Set([this]):ys.add(this));var C=u.stack;this.componentDidCatch(u.value,{componentStack:C!==null?C:""})})}function ow(n,r,l,u,m){if(l.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(r=l.alternate,r!==null&&Ma(r,l,m,!0),l=In.current,l!==null){switch(l.tag){case 31:case 13:return rr===null?Bc():l.alternate===null&&fi===0&&(fi=3),l.flags&=-257,l.flags|=65536,l.lanes=m,u===cc?l.flags|=16384:(r=l.updateQueue,r===null?l.updateQueue=new Set([u]):r.add(u),vd(n,u,m)),!1;case 22:return l.flags|=65536,u===cc?l.flags|=16384:(r=l.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([u])},l.updateQueue=r):(l=r.retryQueue,l===null?r.retryQueue=new Set([u]):l.add(u)),vd(n,u,m)),!1}throw Error(s(435,l.tag))}return vd(n,u,m),Bc(),!1}if(St)return r=In.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=m,u!==ph&&(n=Error(s(422),{cause:u}),Al(er(n,l)))):(u!==ph&&(r=Error(s(423),{cause:u}),Al(er(r,l))),n=n.current.alternate,n.flags|=65536,m&=-m,n.lanes|=m,u=er(u,l),m=Vh(n.stateNode,u,m),kh(n,m),fi!==4&&(fi=2)),!1;var g=Error(s(520),{cause:u});if(g=er(g,l),Vl===null?Vl=[g]:Vl.push(g),fi!==4&&(fi=2),r===null)return!0;u=er(u,l),l=r;do{switch(l.tag){case 3:return l.flags|=65536,n=m&-m,l.lanes|=n,n=Vh(l.stateNode,u,n),kh(l,n),!1;case 1:if(r=l.type,g=l.stateNode,(l.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(ys===null||!ys.has(g))))return l.flags|=65536,m&=-m,l.lanes|=m,m=h_(m),d_(m,n,l,u),kh(l,m),!1}l=l.return}while(l!==null);return!1}var Xh=Error(s(461)),Ai=!1;function tn(n,r,l,u){r.child=n===null?gg(r,null,l,u):na(r,n.child,l,u)}function f_(n,r,l,u,m){l=l.render;var g=r.ref;if("ref"in u){var y={};for(var C in u)C!=="ref"&&(y[C]=u[C])}else y=u;return Js(r),u=Rh(n,r,l,y,g,m),C=Dh(),n!==null&&!Ai?(Mh(n,r,m),qr(n,r,m)):(St&&C&&dh(r),r.flags|=1,tn(n,r,u,m),r.child)}function p_(n,r,l,u,m){if(n===null){var g=l.type;return typeof g=="function"&&!ch(g)&&g.defaultProps===void 0&&l.compare===null?(r.tag=15,r.type=g,m_(n,r,g,u,m)):(n=nc(l.type,null,u,r,r.mode,m),n.ref=r.ref,n.return=r,r.child=n)}if(g=n.child,!rd(n,m)){var y=g.memoizedProps;if(l=l.compare,l=l!==null?l:Nl,l(y,u)&&n.ref===r.ref)return qr(n,r,m)}return r.flags|=1,n=Pr(g,u),n.ref=r.ref,n.return=r,r.child=n}function m_(n,r,l,u,m){if(n!==null){var g=n.memoizedProps;if(Nl(g,u)&&n.ref===r.ref)if(Ai=!1,r.pendingProps=u=g,rd(n,m))(n.flags&131072)!==0&&(Ai=!0);else return r.lanes=n.lanes,qr(n,r,m)}return Zh(n,r,l,u,m)}function g_(n,r,l,u){var m=u.children,g=n!==null?n.memoizedState:null;if(n===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((r.flags&128)!==0){if(g=g!==null?g.baseLanes|l:l,n!==null){for(u=r.child=n.child,m=0;u!==null;)m=m|u.lanes|u.childLanes,u=u.sibling;u=m&~g}else u=0,r.child=null;return __(n,r,g,l,u)}if((l&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},n!==null&&lc(r,g!==null?g.cachePool:null),g!==null?bg(r,g):Nh(),vg(r);else return u=r.lanes=536870912,__(n,r,g!==null?g.baseLanes|l:l,l,u)}else g!==null?(lc(r,g.cachePool),bg(r,g),_s(),r.memoizedState=null):(n!==null&&lc(r,null),Nh(),_s());return tn(n,r,m,l),r.child}function $l(n,r){return n!==null&&n.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function __(n,r,l,u,m){var g=yh();return g=g===null?null:{parent:Ti._currentValue,pool:g},r.memoizedState={baseLanes:l,cachePool:g},n!==null&&lc(r,null),Nh(),vg(r),n!==null&&Ma(n,r,u,!0),r.childLanes=m,null}function wc(n,r){return r=kc({mode:r.mode,children:r.children},n.mode),r.ref=n.ref,n.child=r,r.return=n,r}function x_(n,r,l){return na(r,n.child,null,l),n=wc(r,r.pendingProps),n.flags|=2,Hn(r),r.memoizedState=null,n}function cw(n,r,l){var u=r.pendingProps,m=(r.flags&128)!==0;if(r.flags&=-129,n===null){if(St){if(u.mode==="hidden")return n=wc(r,u),r.lanes=536870912,$l(null,n);if(jh(r),(n=ii)?(n=Ax(n,nr),n=n!==null&&n.data==="&"?n:null,n!==null&&(r.memoizedState={dehydrated:n,treeContext:cs!==null?{id:Sr,overflow:wr}:null,retryLane:536870912,hydrationErrors:null},l=tg(n),l.return=r,r.child=l,Ji=r,ii=null)):n=null,n===null)throw hs(r);return r.lanes=536870912,null}return wc(r,u)}var g=n.memoizedState;if(g!==null){var y=g.dehydrated;if(jh(r),m)if(r.flags&256)r.flags&=-257,r=x_(n,r,l);else if(r.memoizedState!==null)r.child=n.child,r.flags|=128,r=null;else throw Error(s(558));else if(Ai||Ma(n,r,l,!1),m=(l&n.childLanes)!==0,Ai||m){if(u=Vt,u!==null&&(y=kt(u,l),y!==0&&y!==g.retryLane))throw g.retryLane=y,Vs(n,y),Dn(u,n,y),Xh;Bc(),r=x_(n,r,l)}else n=g.treeContext,ii=sr(y.nextSibling),Ji=r,St=!0,us=null,nr=!1,n!==null&&rg(r,n),r=wc(r,u),r.flags|=4096;return r}return n=Pr(n.child,{mode:u.mode,children:u.children}),n.ref=r.ref,r.child=n,n.return=r,n}function Cc(n,r){var l=r.ref;if(l===null)n!==null&&n.ref!==null&&(r.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(s(284));(n===null||n.ref!==l)&&(r.flags|=4194816)}}function Zh(n,r,l,u,m){return Js(r),l=Rh(n,r,l,u,void 0,m),u=Dh(),n!==null&&!Ai?(Mh(n,r,m),qr(n,r,m)):(St&&u&&dh(r),r.flags|=1,tn(n,r,l,m),r.child)}function b_(n,r,l,u,m,g){return Js(r),r.updateQueue=null,l=Sg(r,u,l,m),yg(n),u=Dh(),n!==null&&!Ai?(Mh(n,r,g),qr(n,r,g)):(St&&u&&dh(r),r.flags|=1,tn(n,r,l,g),r.child)}function v_(n,r,l,u,m){if(Js(r),r.stateNode===null){var g=ja,y=l.contextType;typeof y=="object"&&y!==null&&(g=en(y)),g=new l(u,g),r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Kh,r.stateNode=g,g._reactInternals=r,g=r.stateNode,g.props=u,g.state=r.memoizedState,g.refs={},wh(r),y=l.contextType,g.context=typeof y=="object"&&y!==null?en(y):ja,g.state=r.memoizedState,y=l.getDerivedStateFromProps,typeof y=="function"&&(Yh(r,l,y,u),g.state=r.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(y=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),y!==g.state&&Kh.enqueueReplaceState(g,g.state,null),zl(r,u,g,m),Ol(),g.state=r.memoizedState),typeof g.componentDidMount=="function"&&(r.flags|=4194308),u=!0}else if(n===null){g=r.stateNode;var C=r.memoizedProps,B=sa(l,C);g.props=B;var Q=g.context,ce=l.contextType;y=ja,typeof ce=="object"&&ce!==null&&(y=en(ce));var me=l.getDerivedStateFromProps;ce=typeof me=="function"||typeof g.getSnapshotBeforeUpdate=="function",C=r.pendingProps!==C,ce||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(C||Q!==y)&&a_(r,g,u,y),fs=!1;var ee=r.memoizedState;g.state=ee,zl(r,u,g,m),Ol(),Q=r.memoizedState,C||ee!==Q||fs?(typeof me=="function"&&(Yh(r,l,me,u),Q=r.memoizedState),(B=fs||s_(r,l,B,u,ee,Q,y))?(ce||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(r.flags|=4194308)):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=Q),g.props=u,g.state=Q,g.context=y,u=B):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{g=r.stateNode,Ch(n,r),y=r.memoizedProps,ce=sa(l,y),g.props=ce,me=r.pendingProps,ee=g.context,Q=l.contextType,B=ja,typeof Q=="object"&&Q!==null&&(B=en(Q)),C=l.getDerivedStateFromProps,(Q=typeof C=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(y!==me||ee!==B)&&a_(r,g,u,B),fs=!1,ee=r.memoizedState,g.state=ee,zl(r,u,g,m),Ol();var ae=r.memoizedState;y!==me||ee!==ae||fs||n!==null&&n.dependencies!==null&&sc(n.dependencies)?(typeof C=="function"&&(Yh(r,l,C,u),ae=r.memoizedState),(ce=fs||s_(r,l,ce,u,ee,ae,B)||n!==null&&n.dependencies!==null&&sc(n.dependencies))?(Q||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(u,ae,B),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(u,ae,B)),typeof g.componentDidUpdate=="function"&&(r.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof g.componentDidUpdate!="function"||y===n.memoizedProps&&ee===n.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||y===n.memoizedProps&&ee===n.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=ae),g.props=u,g.state=ae,g.context=B,u=ce):(typeof g.componentDidUpdate!="function"||y===n.memoizedProps&&ee===n.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||y===n.memoizedProps&&ee===n.memoizedState||(r.flags|=1024),u=!1)}return g=u,Cc(n,r),u=(r.flags&128)!==0,g||u?(g=r.stateNode,l=u&&typeof l.getDerivedStateFromError!="function"?null:g.render(),r.flags|=1,n!==null&&u?(r.child=na(r,n.child,null,m),r.child=na(r,null,l,m)):tn(n,r,l,m),r.memoizedState=g.state,n=r.child):n=qr(n,r,m),n}function y_(n,r,l,u){return Zs(),r.flags|=256,tn(n,r,l,u),r.child}var Qh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Jh(n){return{baseLanes:n,cachePool:ug()}}function ed(n,r,l){return n=n!==null?n.childLanes&~l:0,r&&(n|=$n),n}function S_(n,r,l){var u=r.pendingProps,m=!1,g=(r.flags&128)!==0,y;if((y=g)||(y=n!==null&&n.memoizedState===null?!1:(Si.current&2)!==0),y&&(m=!0,r.flags&=-129),y=(r.flags&32)!==0,r.flags&=-33,n===null){if(St){if(m?gs(r):_s(),(n=ii)?(n=Ax(n,nr),n=n!==null&&n.data!=="&"?n:null,n!==null&&(r.memoizedState={dehydrated:n,treeContext:cs!==null?{id:Sr,overflow:wr}:null,retryLane:536870912,hydrationErrors:null},l=tg(n),l.return=r,r.child=l,Ji=r,ii=null)):n=null,n===null)throw hs(r);return Od(n)?r.lanes=32:r.lanes=536870912,null}var C=u.children;return u=u.fallback,m?(_s(),m=r.mode,C=kc({mode:"hidden",children:C},m),u=Xs(u,m,l,null),C.return=r,u.return=r,C.sibling=u,r.child=C,u=r.child,u.memoizedState=Jh(l),u.childLanes=ed(n,y,l),r.memoizedState=Qh,$l(null,u)):(gs(r),td(r,C))}var B=n.memoizedState;if(B!==null&&(C=B.dehydrated,C!==null)){if(g)r.flags&256?(gs(r),r.flags&=-257,r=id(n,r,l)):r.memoizedState!==null?(_s(),r.child=n.child,r.flags|=128,r=null):(_s(),C=u.fallback,m=r.mode,u=kc({mode:"visible",children:u.children},m),C=Xs(C,m,l,null),C.flags|=2,u.return=r,C.return=r,u.sibling=C,r.child=u,na(r,n.child,null,l),u=r.child,u.memoizedState=Jh(l),u.childLanes=ed(n,y,l),r.memoizedState=Qh,r=$l(null,u));else if(gs(r),Od(C)){if(y=C.nextSibling&&C.nextSibling.dataset,y)var Q=y.dgst;y=Q,u=Error(s(419)),u.stack="",u.digest=y,Al({value:u,source:null,stack:null}),r=id(n,r,l)}else if(Ai||Ma(n,r,l,!1),y=(l&n.childLanes)!==0,Ai||y){if(y=Vt,y!==null&&(u=kt(y,l),u!==0&&u!==B.retryLane))throw B.retryLane=u,Vs(n,u),Dn(y,n,u),Xh;Ld(C)||Bc(),r=id(n,r,l)}else Ld(C)?(r.flags|=192,r.child=n.child,r=null):(n=B.treeContext,ii=sr(C.nextSibling),Ji=r,St=!0,us=null,nr=!1,n!==null&&rg(r,n),r=td(r,u.children),r.flags|=4096);return r}return m?(_s(),C=u.fallback,m=r.mode,B=n.child,Q=B.sibling,u=Pr(B,{mode:"hidden",children:u.children}),u.subtreeFlags=B.subtreeFlags&65011712,Q!==null?C=Pr(Q,C):(C=Xs(C,m,l,null),C.flags|=2),C.return=r,u.return=r,u.sibling=C,r.child=u,$l(null,u),u=r.child,C=n.child.memoizedState,C===null?C=Jh(l):(m=C.cachePool,m!==null?(B=Ti._currentValue,m=m.parent!==B?{parent:B,pool:B}:m):m=ug(),C={baseLanes:C.baseLanes|l,cachePool:m}),u.memoizedState=C,u.childLanes=ed(n,y,l),r.memoizedState=Qh,$l(n.child,u)):(gs(r),l=n.child,n=l.sibling,l=Pr(l,{mode:"visible",children:u.children}),l.return=r,l.sibling=null,n!==null&&(y=r.deletions,y===null?(r.deletions=[n],r.flags|=16):y.push(n)),r.child=l,r.memoizedState=null,l)}function td(n,r){return r=kc({mode:"visible",children:r},n.mode),r.return=n,n.child=r}function kc(n,r){return n=Pn(22,n,null,r),n.lanes=0,n}function id(n,r,l){return na(r,n.child,null,l),n=td(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function w_(n,r,l){n.lanes|=r;var u=n.alternate;u!==null&&(u.lanes|=r),_h(n.return,r,l)}function nd(n,r,l,u,m,g){var y=n.memoizedState;y===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:l,tailMode:m,treeForkCount:g}:(y.isBackwards=r,y.rendering=null,y.renderingStartTime=0,y.last=u,y.tail=l,y.tailMode=m,y.treeForkCount=g)}function C_(n,r,l){var u=r.pendingProps,m=u.revealOrder,g=u.tail;u=u.children;var y=Si.current,C=(y&2)!==0;if(C?(y=y&1|2,r.flags|=128):y&=1,k(Si,y),tn(n,r,u,l),u=St?jl:0,!C&&n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&w_(n,l,r);else if(n.tag===19)w_(n,l,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(m){case"forwards":for(l=r.child,m=null;l!==null;)n=l.alternate,n!==null&&fc(n)===null&&(m=l),l=l.sibling;l=m,l===null?(m=r.child,r.child=null):(m=l.sibling,l.sibling=null),nd(r,!1,m,l,g,u);break;case"backwards":case"unstable_legacy-backwards":for(l=null,m=r.child,r.child=null;m!==null;){if(n=m.alternate,n!==null&&fc(n)===null){r.child=m;break}n=m.sibling,m.sibling=l,l=m,m=n}nd(r,!0,l,null,g,u);break;case"together":nd(r,!1,null,null,void 0,u);break;default:r.memoizedState=null}return r.child}function qr(n,r,l){if(n!==null&&(r.dependencies=n.dependencies),vs|=r.lanes,(l&r.childLanes)===0)if(n!==null){if(Ma(n,r,l,!1),(l&r.childLanes)===0)return null}else return null;if(n!==null&&r.child!==n.child)throw Error(s(153));if(r.child!==null){for(n=r.child,l=Pr(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=Pr(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function rd(n,r){return(n.lanes&r)!==0?!0:(n=n.dependencies,!!(n!==null&&sc(n)))}function uw(n,r,l){switch(r.tag){case 3:ue(r,r.stateNode.containerInfo),ds(r,Ti,n.memoizedState.cache),Zs();break;case 27:case 5:fe(r);break;case 4:ue(r,r.stateNode.containerInfo);break;case 10:ds(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,jh(r),null;break;case 13:var u=r.memoizedState;if(u!==null)return u.dehydrated!==null?(gs(r),r.flags|=128,null):(l&r.child.childLanes)!==0?S_(n,r,l):(gs(r),n=qr(n,r,l),n!==null?n.sibling:null);gs(r);break;case 19:var m=(n.flags&128)!==0;if(u=(l&r.childLanes)!==0,u||(Ma(n,r,l,!1),u=(l&r.childLanes)!==0),m){if(u)return C_(n,r,l);r.flags|=128}if(m=r.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),k(Si,Si.current),u)break;return null;case 22:return r.lanes=0,g_(n,r,l,r.pendingProps);case 24:ds(r,Ti,n.memoizedState.cache)}return qr(n,r,l)}function k_(n,r,l){if(n!==null)if(n.memoizedProps!==r.pendingProps)Ai=!0;else{if(!rd(n,l)&&(r.flags&128)===0)return Ai=!1,uw(n,r,l);Ai=(n.flags&131072)!==0}else Ai=!1,St&&(r.flags&1048576)!==0&&ng(r,jl,r.index);switch(r.lanes=0,r.tag){case 16:e:{var u=r.pendingProps;if(n=ta(r.elementType),r.type=n,typeof n=="function")ch(n)?(u=sa(n,u),r.tag=1,r=v_(null,r,n,u,l)):(r.tag=0,r=Zh(null,r,n,u,l));else{if(n!=null){var m=n.$$typeof;if(m===R){r.tag=11,r=f_(null,r,n,u,l);break e}else if(m===I){r.tag=14,r=p_(null,r,n,u,l);break e}}throw r=Y(n)||n,Error(s(306,r,""))}}return r;case 0:return Zh(n,r,r.type,r.pendingProps,l);case 1:return u=r.type,m=sa(u,r.pendingProps),v_(n,r,u,m,l);case 3:e:{if(ue(r,r.stateNode.containerInfo),n===null)throw Error(s(387));u=r.pendingProps;var g=r.memoizedState;m=g.element,Ch(n,r),zl(r,u,null,l);var y=r.memoizedState;if(u=y.cache,ds(r,Ti,u),u!==g.cache&&xh(r,[Ti],l,!0),Ol(),u=y.element,g.isDehydrated)if(g={element:u,isDehydrated:!1,cache:y.cache},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){r=y_(n,r,u,l);break e}else if(u!==m){m=er(Error(s(424)),r),Al(m),r=y_(n,r,u,l);break e}else{switch(n=r.stateNode.containerInfo,n.nodeType){case 9:n=n.body;break;default:n=n.nodeName==="HTML"?n.ownerDocument.body:n}for(ii=sr(n.firstChild),Ji=r,St=!0,us=null,nr=!0,l=gg(r,null,u,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(Zs(),u===m){r=qr(n,r,l);break e}tn(n,r,u,l)}r=r.child}return r;case 26:return Cc(n,r),n===null?(l=Ox(r.type,null,r.pendingProps,null))?r.memoizedState=l:St||(l=r.type,n=r.pendingProps,u=Uc(de.current).createElement(l),u[Ot]=r,u[si]=n,nn(u,l,n),Ce(u),r.stateNode=u):r.memoizedState=Ox(r.type,n.memoizedProps,r.pendingProps,n.memoizedState),null;case 27:return fe(r),n===null&&St&&(u=r.stateNode=Mx(r.type,r.pendingProps,de.current),Ji=r,nr=!0,m=ii,ks(r.type)?(zd=m,ii=sr(u.firstChild)):ii=m),tn(n,r,r.pendingProps.children,l),Cc(n,r),n===null&&(r.flags|=4194304),r.child;case 5:return n===null&&St&&((m=u=ii)&&(u=Hw(u,r.type,r.pendingProps,nr),u!==null?(r.stateNode=u,Ji=r,ii=sr(u.firstChild),nr=!1,m=!0):m=!1),m||hs(r)),fe(r),m=r.type,g=r.pendingProps,y=n!==null?n.memoizedProps:null,u=g.children,Dd(m,g)?u=null:y!==null&&Dd(m,y)&&(r.flags|=32),r.memoizedState!==null&&(m=Rh(n,r,tw,null,null,l),no._currentValue=m),Cc(n,r),tn(n,r,u,l),r.child;case 6:return n===null&&St&&((n=l=ii)&&(l=Uw(l,r.pendingProps,nr),l!==null?(r.stateNode=l,Ji=r,ii=null,n=!0):n=!1),n||hs(r)),null;case 13:return S_(n,r,l);case 4:return ue(r,r.stateNode.containerInfo),u=r.pendingProps,n===null?r.child=na(r,null,u,l):tn(n,r,u,l),r.child;case 11:return f_(n,r,r.type,r.pendingProps,l);case 7:return tn(n,r,r.pendingProps,l),r.child;case 8:return tn(n,r,r.pendingProps.children,l),r.child;case 12:return tn(n,r,r.pendingProps.children,l),r.child;case 10:return u=r.pendingProps,ds(r,r.type,u.value),tn(n,r,u.children,l),r.child;case 9:return m=r.type._context,u=r.pendingProps.children,Js(r),m=en(m),u=u(m),r.flags|=1,tn(n,r,u,l),r.child;case 14:return p_(n,r,r.type,r.pendingProps,l);case 15:return m_(n,r,r.type,r.pendingProps,l);case 19:return C_(n,r,l);case 31:return cw(n,r,l);case 22:return g_(n,r,l,r.pendingProps);case 24:return Js(r),u=en(Ti),n===null?(m=yh(),m===null&&(m=Vt,g=bh(),m.pooledCache=g,g.refCount++,g!==null&&(m.pooledCacheLanes|=l),m=g),r.memoizedState={parent:u,cache:m},wh(r),ds(r,Ti,m)):((n.lanes&l)!==0&&(Ch(n,r),zl(r,null,null,l),Ol()),m=n.memoizedState,g=r.memoizedState,m.parent!==u?(m={parent:u,cache:u},r.memoizedState=m,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=m),ds(r,Ti,u)):(u=g.cache,ds(r,Ti,u),u!==m.cache&&xh(r,[Ti],l,!0))),tn(n,r,r.pendingProps.children,l),r.child;case 29:throw r.pendingProps}throw Error(s(156,r.tag))}function Wr(n){n.flags|=4}function sd(n,r,l,u,m){if((r=(n.mode&32)!==0)&&(r=!1),r){if(n.flags|=16777216,(m&335544128)===m)if(n.stateNode.complete)n.flags|=8192;else if(Q_())n.flags|=8192;else throw ia=cc,Sh}else n.flags&=-16777217}function E_(n,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!Ux(r))if(Q_())n.flags|=8192;else throw ia=cc,Sh}function Ec(n,r){r!==null&&(n.flags|=4),n.flags&16384&&(r=n.tag!==22?we():536870912,n.lanes|=r,Wa|=r)}function Fl(n,r){if(!St)switch(n.tailMode){case"hidden":r=n.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var u=null;l!==null;)l.alternate!==null&&(u=l),l=l.sibling;u===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function ni(n){var r=n.alternate!==null&&n.alternate.child===n.child,l=0,u=0;if(r)for(var m=n.child;m!==null;)l|=m.lanes|m.childLanes,u|=m.subtreeFlags&65011712,u|=m.flags&65011712,m.return=n,m=m.sibling;else for(m=n.child;m!==null;)l|=m.lanes|m.childLanes,u|=m.subtreeFlags,u|=m.flags,m.return=n,m=m.sibling;return n.subtreeFlags|=u,n.childLanes=l,r}function hw(n,r,l){var u=r.pendingProps;switch(fh(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ni(r),null;case 1:return ni(r),null;case 3:return l=r.stateNode,u=null,n!==null&&(u=n.memoizedState.cache),r.memoizedState.cache!==u&&(r.flags|=2048),Ur(Ti),ye(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(n===null||n.child===null)&&(Da(r)?Wr(r):n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,mh())),ni(r),null;case 26:var m=r.type,g=r.memoizedState;return n===null?(Wr(r),g!==null?(ni(r),E_(r,g)):(ni(r),sd(r,m,null,u,l))):g?g!==n.memoizedState?(Wr(r),ni(r),E_(r,g)):(ni(r),r.flags&=-16777217):(n=n.memoizedProps,n!==u&&Wr(r),ni(r),sd(r,m,n,u,l)),null;case 27:if(Pe(r),l=de.current,m=r.type,n!==null&&r.stateNode!=null)n.memoizedProps!==u&&Wr(r);else{if(!u){if(r.stateNode===null)throw Error(s(166));return ni(r),null}n=le.current,Da(r)?sg(r):(n=Mx(m,u,l),r.stateNode=n,Wr(r))}return ni(r),null;case 5:if(Pe(r),m=r.type,n!==null&&r.stateNode!=null)n.memoizedProps!==u&&Wr(r);else{if(!u){if(r.stateNode===null)throw Error(s(166));return ni(r),null}if(g=le.current,Da(r))sg(r);else{var y=Uc(de.current);switch(g){case 1:g=y.createElementNS("http://www.w3.org/2000/svg",m);break;case 2:g=y.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;default:switch(m){case"svg":g=y.createElementNS("http://www.w3.org/2000/svg",m);break;case"math":g=y.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;case"script":g=y.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof u.is=="string"?y.createElement("select",{is:u.is}):y.createElement("select"),u.multiple?g.multiple=!0:u.size&&(g.size=u.size);break;default:g=typeof u.is=="string"?y.createElement(m,{is:u.is}):y.createElement(m)}}g[Ot]=r,g[si]=u;e:for(y=r.child;y!==null;){if(y.tag===5||y.tag===6)g.appendChild(y.stateNode);else if(y.tag!==4&&y.tag!==27&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===r)break e;for(;y.sibling===null;){if(y.return===null||y.return===r)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}r.stateNode=g;e:switch(nn(g,m,u),m){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Wr(r)}}return ni(r),sd(r,r.type,n===null?null:n.memoizedProps,r.pendingProps,l),null;case 6:if(n&&r.stateNode!=null)n.memoizedProps!==u&&Wr(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(n=de.current,Da(r)){if(n=r.stateNode,l=r.memoizedProps,u=null,m=Ji,m!==null)switch(m.tag){case 27:case 5:u=m.memoizedProps}n[Ot]=r,n=!!(n.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||Sx(n.nodeValue,l)),n||hs(r,!0)}else n=Uc(n).createTextNode(u),n[Ot]=r,r.stateNode=n}return ni(r),null;case 31:if(l=r.memoizedState,n===null||n.memoizedState!==null){if(u=Da(r),l!==null){if(n===null){if(!u)throw Error(s(318));if(n=r.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(557));n[Ot]=r}else Zs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ni(r),n=!1}else l=mh(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=l),n=!0;if(!n)return r.flags&256?(Hn(r),r):(Hn(r),null);if((r.flags&128)!==0)throw Error(s(558))}return ni(r),null;case 13:if(u=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(m=Da(r),u!==null&&u.dehydrated!==null){if(n===null){if(!m)throw Error(s(318));if(m=r.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(s(317));m[Ot]=r}else Zs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ni(r),m=!1}else m=mh(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=m),m=!0;if(!m)return r.flags&256?(Hn(r),r):(Hn(r),null)}return Hn(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,n=n!==null&&n.memoizedState!==null,l&&(u=r.child,m=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(m=u.alternate.memoizedState.cachePool.pool),g=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),g!==m&&(u.flags|=2048)),l!==n&&l&&(r.child.flags|=8192),Ec(r,r.updateQueue),ni(r),null);case 4:return ye(),n===null&&Nd(r.stateNode.containerInfo),ni(r),null;case 10:return Ur(r.type),ni(r),null;case 19:if(V(Si),u=r.memoizedState,u===null)return ni(r),null;if(m=(r.flags&128)!==0,g=u.rendering,g===null)if(m)Fl(u,!1);else{if(fi!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(g=fc(n),g!==null){for(r.flags|=128,Fl(u,!1),n=g.updateQueue,r.updateQueue=n,Ec(r,n),r.subtreeFlags=0,n=l,l=r.child;l!==null;)eg(l,n),l=l.sibling;return k(Si,Si.current&1|2),St&&Ir(r,u.treeForkCount),r.child}n=n.sibling}u.tail!==null&&yt()>Rc&&(r.flags|=128,m=!0,Fl(u,!1),r.lanes=4194304)}else{if(!m)if(n=fc(g),n!==null){if(r.flags|=128,m=!0,n=n.updateQueue,r.updateQueue=n,Ec(r,n),Fl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!g.alternate&&!St)return ni(r),null}else 2*yt()-u.renderingStartTime>Rc&&l!==536870912&&(r.flags|=128,m=!0,Fl(u,!1),r.lanes=4194304);u.isBackwards?(g.sibling=r.child,r.child=g):(n=u.last,n!==null?n.sibling=g:r.child=g,u.last=g)}return u.tail!==null?(n=u.tail,u.rendering=n,u.tail=n.sibling,u.renderingStartTime=yt(),n.sibling=null,l=Si.current,k(Si,m?l&1|2:l&1),St&&Ir(r,u.treeForkCount),n):(ni(r),null);case 22:case 23:return Hn(r),Th(),u=r.memoizedState!==null,n!==null?n.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(l&536870912)!==0&&(r.flags&128)===0&&(ni(r),r.subtreeFlags&6&&(r.flags|=8192)):ni(r),l=r.updateQueue,l!==null&&Ec(r,l.retryQueue),l=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==l&&(r.flags|=2048),n!==null&&V(ea),null;case 24:return l=null,n!==null&&(l=n.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),Ur(Ti),ni(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function dw(n,r){switch(fh(r),r.tag){case 1:return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Ur(Ti),ye(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 26:case 27:case 5:return Pe(r),null;case 31:if(r.memoizedState!==null){if(Hn(r),r.alternate===null)throw Error(s(340));Zs()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 13:if(Hn(r),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Zs()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return V(Si),null;case 4:return ye(),null;case 10:return Ur(r.type),null;case 22:case 23:return Hn(r),Th(),n!==null&&V(ea),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 24:return Ur(Ti),null;case 25:return null;default:return null}}function N_(n,r){switch(fh(r),r.tag){case 3:Ur(Ti),ye();break;case 26:case 27:case 5:Pe(r);break;case 4:ye();break;case 31:r.memoizedState!==null&&Hn(r);break;case 13:Hn(r);break;case 19:V(Si);break;case 10:Ur(r.type);break;case 22:case 23:Hn(r),Th(),n!==null&&V(ea);break;case 24:Ur(Ti)}}function ql(n,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var m=u.next;l=m;do{if((l.tag&n)===n){u=void 0;var g=l.create,y=l.inst;u=g(),y.destroy=u}l=l.next}while(l!==m)}}catch(C){It(r,r.return,C)}}function xs(n,r,l){try{var u=r.updateQueue,m=u!==null?u.lastEffect:null;if(m!==null){var g=m.next;u=g;do{if((u.tag&n)===n){var y=u.inst,C=y.destroy;if(C!==void 0){y.destroy=void 0,m=r;var B=l,Q=C;try{Q()}catch(ce){It(m,B,ce)}}}u=u.next}while(u!==g)}}catch(ce){It(r,r.return,ce)}}function T_(n){var r=n.updateQueue;if(r!==null){var l=n.stateNode;try{xg(r,l)}catch(u){It(n,n.return,u)}}}function j_(n,r,l){l.props=sa(n.type,n.memoizedProps),l.state=n.memoizedState;try{l.componentWillUnmount()}catch(u){It(n,r,u)}}function Wl(n,r){try{var l=n.ref;if(l!==null){switch(n.tag){case 26:case 27:case 5:var u=n.stateNode;break;case 30:u=n.stateNode;break;default:u=n.stateNode}typeof l=="function"?n.refCleanup=l(u):l.current=u}}catch(m){It(n,r,m)}}function Cr(n,r){var l=n.ref,u=n.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(m){It(n,r,m)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(m){It(n,r,m)}else l.current=null}function A_(n){var r=n.type,l=n.memoizedProps,u=n.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&u.focus();break e;case"img":l.src?u.src=l.src:l.srcSet&&(u.srcset=l.srcSet)}}catch(m){It(n,n.return,m)}}function ad(n,r,l){try{var u=n.stateNode;Bw(u,n.type,l,r),u[si]=r}catch(m){It(n,n.return,m)}}function R_(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&ks(n.type)||n.tag===4}function ld(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||R_(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&ks(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function od(n,r,l){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(n,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(n),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=Zn));else if(u!==4&&(u===27&&ks(n.type)&&(l=n.stateNode,r=null),n=n.child,n!==null))for(od(n,r,l),n=n.sibling;n!==null;)od(n,r,l),n=n.sibling}function Nc(n,r,l){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?l.insertBefore(n,r):l.appendChild(n);else if(u!==4&&(u===27&&ks(n.type)&&(l=n.stateNode),n=n.child,n!==null))for(Nc(n,r,l),n=n.sibling;n!==null;)Nc(n,r,l),n=n.sibling}function D_(n){var r=n.stateNode,l=n.memoizedProps;try{for(var u=n.type,m=r.attributes;m.length;)r.removeAttributeNode(m[0]);nn(r,u,l),r[Ot]=n,r[si]=l}catch(g){It(n,n.return,g)}}var Gr=!1,Ri=!1,cd=!1,M_=typeof WeakSet=="function"?WeakSet:Set,Fi=null;function fw(n,r){if(n=n.containerInfo,Ad=Kc,n=Wm(n),ih(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var m=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var y=0,C=-1,B=-1,Q=0,ce=0,me=n,ee=null;t:for(;;){for(var ae;me!==l||m!==0&&me.nodeType!==3||(C=y+m),me!==g||u!==0&&me.nodeType!==3||(B=y+u),me.nodeType===3&&(y+=me.nodeValue.length),(ae=me.firstChild)!==null;)ee=me,me=ae;for(;;){if(me===n)break t;if(ee===l&&++Q===m&&(C=y),ee===g&&++ce===u&&(B=y),(ae=me.nextSibling)!==null)break;me=ee,ee=me.parentNode}me=ae}l=C===-1||B===-1?null:{start:C,end:B}}else l=null}l=l||{start:0,end:0}}else l=null;for(Rd={focusedElem:n,selectionRange:l},Kc=!1,Fi=r;Fi!==null;)if(r=Fi,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,Fi=n;else for(;Fi!==null;){switch(r=Fi,g=r.alternate,n=r.flags,r.tag){case 0:if((n&4)!==0&&(n=r.updateQueue,n=n!==null?n.events:null,n!==null))for(l=0;l<n.length;l++)m=n[l],m.ref.impl=m.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&g!==null){n=void 0,l=r,m=g.memoizedProps,g=g.memoizedState,u=l.stateNode;try{var Le=sa(l.type,m);n=u.getSnapshotBeforeUpdate(Le,g),u.__reactInternalSnapshotBeforeUpdate=n}catch(Ve){It(l,l.return,Ve)}}break;case 3:if((n&1024)!==0){if(n=r.stateNode.containerInfo,l=n.nodeType,l===9)Bd(n);else if(l===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":Bd(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((n&1024)!==0)throw Error(s(163))}if(n=r.sibling,n!==null){n.return=r.return,Fi=n;break}Fi=r.return}}function B_(n,r,l){var u=l.flags;switch(l.tag){case 0:case 11:case 15:Kr(n,l),u&4&&ql(5,l);break;case 1:if(Kr(n,l),u&4)if(n=l.stateNode,r===null)try{n.componentDidMount()}catch(y){It(l,l.return,y)}else{var m=sa(l.type,r.memoizedProps);r=r.memoizedState;try{n.componentDidUpdate(m,r,n.__reactInternalSnapshotBeforeUpdate)}catch(y){It(l,l.return,y)}}u&64&&T_(l),u&512&&Wl(l,l.return);break;case 3:if(Kr(n,l),u&64&&(n=l.updateQueue,n!==null)){if(r=null,l.child!==null)switch(l.child.tag){case 27:case 5:r=l.child.stateNode;break;case 1:r=l.child.stateNode}try{xg(n,r)}catch(y){It(l,l.return,y)}}break;case 27:r===null&&u&4&&D_(l);case 26:case 5:Kr(n,l),r===null&&u&4&&A_(l),u&512&&Wl(l,l.return);break;case 12:Kr(n,l);break;case 31:Kr(n,l),u&4&&z_(n,l);break;case 13:Kr(n,l),u&4&&P_(n,l),u&64&&(n=l.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(l=Sw.bind(null,l),$w(n,l))));break;case 22:if(u=l.memoizedState!==null||Gr,!u){r=r!==null&&r.memoizedState!==null||Ri,m=Gr;var g=Ri;Gr=u,(Ri=r)&&!g?Vr(n,l,(l.subtreeFlags&8772)!==0):Kr(n,l),Gr=m,Ri=g}break;case 30:break;default:Kr(n,l)}}function L_(n){var r=n.alternate;r!==null&&(n.alternate=null,L_(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&at(r)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var ai=null,Tn=!1;function Yr(n,r,l){for(l=l.child;l!==null;)O_(n,r,l),l=l.sibling}function O_(n,r,l){if(xt&&typeof xt.onCommitFiberUnmount=="function")try{xt.onCommitFiberUnmount(nt,l)}catch{}switch(l.tag){case 26:Ri||Cr(l,r),Yr(n,r,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:Ri||Cr(l,r);var u=ai,m=Tn;ks(l.type)&&(ai=l.stateNode,Tn=!1),Yr(n,r,l),eo(l.stateNode),ai=u,Tn=m;break;case 5:Ri||Cr(l,r);case 6:if(u=ai,m=Tn,ai=null,Yr(n,r,l),ai=u,Tn=m,ai!==null)if(Tn)try{(ai.nodeType===9?ai.body:ai.nodeName==="HTML"?ai.ownerDocument.body:ai).removeChild(l.stateNode)}catch(g){It(l,r,g)}else try{ai.removeChild(l.stateNode)}catch(g){It(l,r,g)}break;case 18:ai!==null&&(Tn?(n=ai,Tx(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,l.stateNode),Ja(n)):Tx(ai,l.stateNode));break;case 4:u=ai,m=Tn,ai=l.stateNode.containerInfo,Tn=!0,Yr(n,r,l),ai=u,Tn=m;break;case 0:case 11:case 14:case 15:xs(2,l,r),Ri||xs(4,l,r),Yr(n,r,l);break;case 1:Ri||(Cr(l,r),u=l.stateNode,typeof u.componentWillUnmount=="function"&&j_(l,r,u)),Yr(n,r,l);break;case 21:Yr(n,r,l);break;case 22:Ri=(u=Ri)||l.memoizedState!==null,Yr(n,r,l),Ri=u;break;default:Yr(n,r,l)}}function z_(n,r){if(r.memoizedState===null&&(n=r.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{Ja(n)}catch(l){It(r,r.return,l)}}}function P_(n,r){if(r.memoizedState===null&&(n=r.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{Ja(n)}catch(l){It(r,r.return,l)}}function pw(n){switch(n.tag){case 31:case 13:case 19:var r=n.stateNode;return r===null&&(r=n.stateNode=new M_),r;case 22:return n=n.stateNode,r=n._retryCache,r===null&&(r=n._retryCache=new M_),r;default:throw Error(s(435,n.tag))}}function Tc(n,r){var l=pw(n);r.forEach(function(u){if(!l.has(u)){l.add(u);var m=ww.bind(null,n,u);u.then(m,m)}})}function jn(n,r){var l=r.deletions;if(l!==null)for(var u=0;u<l.length;u++){var m=l[u],g=n,y=r,C=y;e:for(;C!==null;){switch(C.tag){case 27:if(ks(C.type)){ai=C.stateNode,Tn=!1;break e}break;case 5:ai=C.stateNode,Tn=!1;break e;case 3:case 4:ai=C.stateNode.containerInfo,Tn=!0;break e}C=C.return}if(ai===null)throw Error(s(160));O_(g,y,m),ai=null,Tn=!1,g=m.alternate,g!==null&&(g.return=null),m.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)I_(r,n),r=r.sibling}var mr=null;function I_(n,r){var l=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:jn(r,n),An(n),u&4&&(xs(3,n,n.return),ql(3,n),xs(5,n,n.return));break;case 1:jn(r,n),An(n),u&512&&(Ri||l===null||Cr(l,l.return)),u&64&&Gr&&(n=n.updateQueue,n!==null&&(u=n.callbacks,u!==null&&(l=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=l===null?u:l.concat(u))));break;case 26:var m=mr;if(jn(r,n),An(n),u&512&&(Ri||l===null||Cr(l,l.return)),u&4){var g=l!==null?l.memoizedState:null;if(u=n.memoizedState,l===null)if(u===null)if(n.stateNode===null){e:{u=n.type,l=n.memoizedProps,m=m.ownerDocument||m;t:switch(u){case"title":g=m.getElementsByTagName("title")[0],(!g||g[st]||g[Ot]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=m.createElement(u),m.head.insertBefore(g,m.querySelector("head > title"))),nn(g,u,l),g[Ot]=n,Ce(g),u=g;break e;case"link":var y=Ix("link","href",m).get(u+(l.href||""));if(y){for(var C=0;C<y.length;C++)if(g=y[C],g.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&g.getAttribute("rel")===(l.rel==null?null:l.rel)&&g.getAttribute("title")===(l.title==null?null:l.title)&&g.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){y.splice(C,1);break t}}g=m.createElement(u),nn(g,u,l),m.head.appendChild(g);break;case"meta":if(y=Ix("meta","content",m).get(u+(l.content||""))){for(C=0;C<y.length;C++)if(g=y[C],g.getAttribute("content")===(l.content==null?null:""+l.content)&&g.getAttribute("name")===(l.name==null?null:l.name)&&g.getAttribute("property")===(l.property==null?null:l.property)&&g.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&g.getAttribute("charset")===(l.charSet==null?null:l.charSet)){y.splice(C,1);break t}}g=m.createElement(u),nn(g,u,l),m.head.appendChild(g);break;default:throw Error(s(468,u))}g[Ot]=n,Ce(g),u=g}n.stateNode=u}else Hx(m,n.type,n.stateNode);else n.stateNode=Px(m,u,n.memoizedProps);else g!==u?(g===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):g.count--,u===null?Hx(m,n.type,n.stateNode):Px(m,u,n.memoizedProps)):u===null&&n.stateNode!==null&&ad(n,n.memoizedProps,l.memoizedProps)}break;case 27:jn(r,n),An(n),u&512&&(Ri||l===null||Cr(l,l.return)),l!==null&&u&4&&ad(n,n.memoizedProps,l.memoizedProps);break;case 5:if(jn(r,n),An(n),u&512&&(Ri||l===null||Cr(l,l.return)),n.flags&32){m=n.stateNode;try{Or(m,"")}catch(Le){It(n,n.return,Le)}}u&4&&n.stateNode!=null&&(m=n.memoizedProps,ad(n,m,l!==null?l.memoizedProps:m)),u&1024&&(cd=!0);break;case 6:if(jn(r,n),An(n),u&4){if(n.stateNode===null)throw Error(s(162));u=n.memoizedProps,l=n.stateNode;try{l.nodeValue=u}catch(Le){It(n,n.return,Le)}}break;case 3:if(qc=null,m=mr,mr=$c(r.containerInfo),jn(r,n),mr=m,An(n),u&4&&l!==null&&l.memoizedState.isDehydrated)try{Ja(r.containerInfo)}catch(Le){It(n,n.return,Le)}cd&&(cd=!1,H_(n));break;case 4:u=mr,mr=$c(n.stateNode.containerInfo),jn(r,n),An(n),mr=u;break;case 12:jn(r,n),An(n);break;case 31:jn(r,n),An(n),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,Tc(n,u)));break;case 13:jn(r,n),An(n),n.child.flags&8192&&n.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Ac=yt()),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,Tc(n,u)));break;case 22:m=n.memoizedState!==null;var B=l!==null&&l.memoizedState!==null,Q=Gr,ce=Ri;if(Gr=Q||m,Ri=ce||B,jn(r,n),Ri=ce,Gr=Q,An(n),u&8192)e:for(r=n.stateNode,r._visibility=m?r._visibility&-2:r._visibility|1,m&&(l===null||B||Gr||Ri||aa(n)),l=null,r=n;;){if(r.tag===5||r.tag===26){if(l===null){B=l=r;try{if(g=B.stateNode,m)y=g.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{C=B.stateNode;var me=B.memoizedProps.style,ee=me!=null&&me.hasOwnProperty("display")?me.display:null;C.style.display=ee==null||typeof ee=="boolean"?"":(""+ee).trim()}}catch(Le){It(B,B.return,Le)}}}else if(r.tag===6){if(l===null){B=r;try{B.stateNode.nodeValue=m?"":B.memoizedProps}catch(Le){It(B,B.return,Le)}}}else if(r.tag===18){if(l===null){B=r;try{var ae=B.stateNode;m?jx(ae,!0):jx(B.stateNode,!1)}catch(Le){It(B,B.return,Le)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===n)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break e;for(;r.sibling===null;){if(r.return===null||r.return===n)break e;l===r&&(l=null),r=r.return}l===r&&(l=null),r.sibling.return=r.return,r=r.sibling}u&4&&(u=n.updateQueue,u!==null&&(l=u.retryQueue,l!==null&&(u.retryQueue=null,Tc(n,l))));break;case 19:jn(r,n),An(n),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,Tc(n,u)));break;case 30:break;case 21:break;default:jn(r,n),An(n)}}function An(n){var r=n.flags;if(r&2){try{for(var l,u=n.return;u!==null;){if(R_(u)){l=u;break}u=u.return}if(l==null)throw Error(s(160));switch(l.tag){case 27:var m=l.stateNode,g=ld(n);Nc(n,g,m);break;case 5:var y=l.stateNode;l.flags&32&&(Or(y,""),l.flags&=-33);var C=ld(n);Nc(n,C,y);break;case 3:case 4:var B=l.stateNode.containerInfo,Q=ld(n);od(n,Q,B);break;default:throw Error(s(161))}}catch(ce){It(n,n.return,ce)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function H_(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var r=n;H_(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),n=n.sibling}}function Kr(n,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)B_(n,r.alternate,r),r=r.sibling}function aa(n){for(n=n.child;n!==null;){var r=n;switch(r.tag){case 0:case 11:case 14:case 15:xs(4,r,r.return),aa(r);break;case 1:Cr(r,r.return);var l=r.stateNode;typeof l.componentWillUnmount=="function"&&j_(r,r.return,l),aa(r);break;case 27:eo(r.stateNode);case 26:case 5:Cr(r,r.return),aa(r);break;case 22:r.memoizedState===null&&aa(r);break;case 30:aa(r);break;default:aa(r)}n=n.sibling}}function Vr(n,r,l){for(l=l&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var u=r.alternate,m=n,g=r,y=g.flags;switch(g.tag){case 0:case 11:case 15:Vr(m,g,l),ql(4,g);break;case 1:if(Vr(m,g,l),u=g,m=u.stateNode,typeof m.componentDidMount=="function")try{m.componentDidMount()}catch(Q){It(u,u.return,Q)}if(u=g,m=u.updateQueue,m!==null){var C=u.stateNode;try{var B=m.shared.hiddenCallbacks;if(B!==null)for(m.shared.hiddenCallbacks=null,m=0;m<B.length;m++)_g(B[m],C)}catch(Q){It(u,u.return,Q)}}l&&y&64&&T_(g),Wl(g,g.return);break;case 27:D_(g);case 26:case 5:Vr(m,g,l),l&&u===null&&y&4&&A_(g),Wl(g,g.return);break;case 12:Vr(m,g,l);break;case 31:Vr(m,g,l),l&&y&4&&z_(m,g);break;case 13:Vr(m,g,l),l&&y&4&&P_(m,g);break;case 22:g.memoizedState===null&&Vr(m,g,l),Wl(g,g.return);break;case 30:break;default:Vr(m,g,l)}r=r.sibling}}function ud(n,r){var l=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),n=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(n=r.memoizedState.cachePool.pool),n!==l&&(n!=null&&n.refCount++,l!=null&&Rl(l))}function hd(n,r){n=null,r.alternate!==null&&(n=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==n&&(r.refCount++,n!=null&&Rl(n))}function gr(n,r,l,u){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)U_(n,r,l,u),r=r.sibling}function U_(n,r,l,u){var m=r.flags;switch(r.tag){case 0:case 11:case 15:gr(n,r,l,u),m&2048&&ql(9,r);break;case 1:gr(n,r,l,u);break;case 3:gr(n,r,l,u),m&2048&&(n=null,r.alternate!==null&&(n=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==n&&(r.refCount++,n!=null&&Rl(n)));break;case 12:if(m&2048){gr(n,r,l,u),n=r.stateNode;try{var g=r.memoizedProps,y=g.id,C=g.onPostCommit;typeof C=="function"&&C(y,r.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(B){It(r,r.return,B)}}else gr(n,r,l,u);break;case 31:gr(n,r,l,u);break;case 13:gr(n,r,l,u);break;case 23:break;case 22:g=r.stateNode,y=r.alternate,r.memoizedState!==null?g._visibility&2?gr(n,r,l,u):Gl(n,r):g._visibility&2?gr(n,r,l,u):(g._visibility|=2,$a(n,r,l,u,(r.subtreeFlags&10256)!==0||!1)),m&2048&&ud(y,r);break;case 24:gr(n,r,l,u),m&2048&&hd(r.alternate,r);break;default:gr(n,r,l,u)}}function $a(n,r,l,u,m){for(m=m&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var g=n,y=r,C=l,B=u,Q=y.flags;switch(y.tag){case 0:case 11:case 15:$a(g,y,C,B,m),ql(8,y);break;case 23:break;case 22:var ce=y.stateNode;y.memoizedState!==null?ce._visibility&2?$a(g,y,C,B,m):Gl(g,y):(ce._visibility|=2,$a(g,y,C,B,m)),m&&Q&2048&&ud(y.alternate,y);break;case 24:$a(g,y,C,B,m),m&&Q&2048&&hd(y.alternate,y);break;default:$a(g,y,C,B,m)}r=r.sibling}}function Gl(n,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var l=n,u=r,m=u.flags;switch(u.tag){case 22:Gl(l,u),m&2048&&ud(u.alternate,u);break;case 24:Gl(l,u),m&2048&&hd(u.alternate,u);break;default:Gl(l,u)}r=r.sibling}}var Yl=8192;function Fa(n,r,l){if(n.subtreeFlags&Yl)for(n=n.child;n!==null;)$_(n,r,l),n=n.sibling}function $_(n,r,l){switch(n.tag){case 26:Fa(n,r,l),n.flags&Yl&&n.memoizedState!==null&&eC(l,mr,n.memoizedState,n.memoizedProps);break;case 5:Fa(n,r,l);break;case 3:case 4:var u=mr;mr=$c(n.stateNode.containerInfo),Fa(n,r,l),mr=u;break;case 22:n.memoizedState===null&&(u=n.alternate,u!==null&&u.memoizedState!==null?(u=Yl,Yl=16777216,Fa(n,r,l),Yl=u):Fa(n,r,l));break;default:Fa(n,r,l)}}function F_(n){var r=n.alternate;if(r!==null&&(n=r.child,n!==null)){r.child=null;do r=n.sibling,n.sibling=null,n=r;while(n!==null)}}function Kl(n){var r=n.deletions;if((n.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var u=r[l];Fi=u,W_(u,n)}F_(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)q_(n),n=n.sibling}function q_(n){switch(n.tag){case 0:case 11:case 15:Kl(n),n.flags&2048&&xs(9,n,n.return);break;case 3:Kl(n);break;case 12:Kl(n);break;case 22:var r=n.stateNode;n.memoizedState!==null&&r._visibility&2&&(n.return===null||n.return.tag!==13)?(r._visibility&=-3,jc(n)):Kl(n);break;default:Kl(n)}}function jc(n){var r=n.deletions;if((n.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var u=r[l];Fi=u,W_(u,n)}F_(n)}for(n=n.child;n!==null;){switch(r=n,r.tag){case 0:case 11:case 15:xs(8,r,r.return),jc(r);break;case 22:l=r.stateNode,l._visibility&2&&(l._visibility&=-3,jc(r));break;default:jc(r)}n=n.sibling}}function W_(n,r){for(;Fi!==null;){var l=Fi;switch(l.tag){case 0:case 11:case 15:xs(8,l,r);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var u=l.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:Rl(l.memoizedState.cache)}if(u=l.child,u!==null)u.return=l,Fi=u;else e:for(l=n;Fi!==null;){u=Fi;var m=u.sibling,g=u.return;if(L_(u),u===l){Fi=null;break e}if(m!==null){m.return=g,Fi=m;break e}Fi=g}}}var mw={getCacheForType:function(n){var r=en(Ti),l=r.data.get(n);return l===void 0&&(l=n(),r.data.set(n,l)),l},cacheSignal:function(){return en(Ti).controller.signal}},gw=typeof WeakMap=="function"?WeakMap:Map,Mt=0,Vt=null,pt=null,bt=0,Pt=0,Un=null,bs=!1,qa=!1,dd=!1,Xr=0,fi=0,vs=0,la=0,fd=0,$n=0,Wa=0,Vl=null,Rn=null,pd=!1,Ac=0,G_=0,Rc=1/0,Dc=null,ys=null,Oi=0,Ss=null,Ga=null,Zr=0,md=0,gd=null,Y_=null,Xl=0,_d=null;function Fn(){return(Mt&2)!==0&&bt!==0?bt&-bt:A.T!==null?wd():hi()}function K_(){if($n===0)if((bt&536870912)===0||St){var n=_i;_i<<=1,(_i&3932160)===0&&(_i=262144),$n=n}else $n=536870912;return n=In.current,n!==null&&(n.flags|=32),$n}function Dn(n,r,l){(n===Vt&&(Pt===2||Pt===9)||n.cancelPendingCommit!==null)&&(Ya(n,0),ws(n,bt,$n,!1)),Te(n,l),((Mt&2)===0||n!==Vt)&&(n===Vt&&((Mt&2)===0&&(la|=l),fi===4&&ws(n,bt,$n,!1)),kr(n))}function V_(n,r,l){if((Mt&6)!==0)throw Error(s(327));var u=!l&&(r&127)===0&&(r&n.expiredLanes)===0||Ui(n,r),m=u?bw(n,r):bd(n,r,!0),g=u;do{if(m===0){qa&&!u&&ws(n,r,0,!1);break}else{if(l=n.current.alternate,g&&!_w(l)){m=bd(n,r,!1),g=!1;continue}if(m===2){if(g=r,n.errorRecoveryDisabledLanes&g)var y=0;else y=n.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){r=y;e:{var C=n;m=Vl;var B=C.current.memoizedState.isDehydrated;if(B&&(Ya(C,y).flags|=256),y=bd(C,y,!1),y!==2){if(dd&&!B){C.errorRecoveryDisabledLanes|=g,la|=g,m=4;break e}g=Rn,Rn=m,g!==null&&(Rn===null?Rn=g:Rn.push.apply(Rn,g))}m=y}if(g=!1,m!==2)continue}}if(m===1){Ya(n,0),ws(n,r,0,!0);break}e:{switch(u=n,g=m,g){case 0:case 1:throw Error(s(345));case 4:if((r&4194048)!==r)break;case 6:ws(u,r,$n,!bs);break e;case 2:Rn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((r&62914560)===r&&(m=Ac+300-yt(),10<m)){if(ws(u,r,$n,!bs),ln(u,0,!0)!==0)break e;Zr=r,u.timeoutHandle=Ex(X_.bind(null,u,l,Rn,Dc,pd,r,$n,la,Wa,bs,g,"Throttled",-0,0),m);break e}X_(u,l,Rn,Dc,pd,r,$n,la,Wa,bs,g,null,-0,0)}}break}while(!0);kr(n)}function X_(n,r,l,u,m,g,y,C,B,Q,ce,me,ee,ae){if(n.timeoutHandle=-1,me=r.subtreeFlags,me&8192||(me&16785408)===16785408){me={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Zn},$_(r,g,me);var Le=(g&62914560)===g?Ac-yt():(g&4194048)===g?G_-yt():0;if(Le=tC(me,Le),Le!==null){Zr=g,n.cancelPendingCommit=Le(rx.bind(null,n,r,g,l,u,m,y,C,B,ce,me,null,ee,ae)),ws(n,g,y,!Q);return}}rx(n,r,g,l,u,m,y,C,B)}function _w(n){for(var r=n;;){var l=r.tag;if((l===0||l===11||l===15)&&r.flags&16384&&(l=r.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var u=0;u<l.length;u++){var m=l[u],g=m.getSnapshot;m=m.value;try{if(!zn(g(),m))return!1}catch{return!1}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function ws(n,r,l,u){r&=~fd,r&=~la,n.suspendedLanes|=r,n.pingedLanes&=~r,u&&(n.warmLanes|=r),u=n.expirationTimes;for(var m=r;0<m;){var g=31-ct(m),y=1<<g;u[g]=-1,m&=~y}l!==0&&Qe(n,l,r)}function Mc(){return(Mt&6)===0?(Zl(0),!1):!0}function xd(){if(pt!==null){if(Pt===0)var n=pt.return;else n=pt,Hr=Qs=null,Bh(n),za=null,Ml=0,n=pt;for(;n!==null;)N_(n.alternate,n),n=n.return;pt=null}}function Ya(n,r){var l=n.timeoutHandle;l!==-1&&(n.timeoutHandle=-1,zw(l)),l=n.cancelPendingCommit,l!==null&&(n.cancelPendingCommit=null,l()),Zr=0,xd(),Vt=n,pt=l=Pr(n.current,null),bt=r,Pt=0,Un=null,bs=!1,qa=Ui(n,r),dd=!1,Wa=$n=fd=la=vs=fi=0,Rn=Vl=null,pd=!1,(r&8)!==0&&(r|=r&32);var u=n.entangledLanes;if(u!==0)for(n=n.entanglements,u&=r;0<u;){var m=31-ct(u),g=1<<m;r|=n[m],u&=~g}return Xr=r,ec(),l}function Z_(n,r){rt=null,A.H=Ul,r===Oa||r===oc?(r=fg(),Pt=3):r===Sh?(r=fg(),Pt=4):Pt=r===Xh?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Un=r,pt===null&&(fi=1,Sc(n,er(r,n.current)))}function Q_(){var n=In.current;return n===null?!0:(bt&4194048)===bt?rr===null:(bt&62914560)===bt||(bt&536870912)!==0?n===rr:!1}function J_(){var n=A.H;return A.H=Ul,n===null?Ul:n}function ex(){var n=A.A;return A.A=mw,n}function Bc(){fi=4,bs||(bt&4194048)!==bt&&In.current!==null||(qa=!0),(vs&134217727)===0&&(la&134217727)===0||Vt===null||ws(Vt,bt,$n,!1)}function bd(n,r,l){var u=Mt;Mt|=2;var m=J_(),g=ex();(Vt!==n||bt!==r)&&(Dc=null,Ya(n,r)),r=!1;var y=fi;e:do try{if(Pt!==0&&pt!==null){var C=pt,B=Un;switch(Pt){case 8:xd(),y=6;break e;case 3:case 2:case 9:case 6:In.current===null&&(r=!0);var Q=Pt;if(Pt=0,Un=null,Ka(n,C,B,Q),l&&qa){y=0;break e}break;default:Q=Pt,Pt=0,Un=null,Ka(n,C,B,Q)}}xw(),y=fi;break}catch(ce){Z_(n,ce)}while(!0);return r&&n.shellSuspendCounter++,Hr=Qs=null,Mt=u,A.H=m,A.A=g,pt===null&&(Vt=null,bt=0,ec()),y}function xw(){for(;pt!==null;)tx(pt)}function bw(n,r){var l=Mt;Mt|=2;var u=J_(),m=ex();Vt!==n||bt!==r?(Dc=null,Rc=yt()+500,Ya(n,r)):qa=Ui(n,r);e:do try{if(Pt!==0&&pt!==null){r=pt;var g=Un;t:switch(Pt){case 1:Pt=0,Un=null,Ka(n,r,g,1);break;case 2:case 9:if(hg(g)){Pt=0,Un=null,ix(r);break}r=function(){Pt!==2&&Pt!==9||Vt!==n||(Pt=7),kr(n)},g.then(r,r);break e;case 3:Pt=7;break e;case 4:Pt=5;break e;case 7:hg(g)?(Pt=0,Un=null,ix(r)):(Pt=0,Un=null,Ka(n,r,g,7));break;case 5:var y=null;switch(pt.tag){case 26:y=pt.memoizedState;case 5:case 27:var C=pt;if(y?Ux(y):C.stateNode.complete){Pt=0,Un=null;var B=C.sibling;if(B!==null)pt=B;else{var Q=C.return;Q!==null?(pt=Q,Lc(Q)):pt=null}break t}}Pt=0,Un=null,Ka(n,r,g,5);break;case 6:Pt=0,Un=null,Ka(n,r,g,6);break;case 8:xd(),fi=6;break e;default:throw Error(s(462))}}vw();break}catch(ce){Z_(n,ce)}while(!0);return Hr=Qs=null,A.H=u,A.A=m,Mt=l,pt!==null?0:(Vt=null,bt=0,ec(),fi)}function vw(){for(;pt!==null&&!ki();)tx(pt)}function tx(n){var r=k_(n.alternate,n,Xr);n.memoizedProps=n.pendingProps,r===null?Lc(n):pt=r}function ix(n){var r=n,l=r.alternate;switch(r.tag){case 15:case 0:r=b_(l,r,r.pendingProps,r.type,void 0,bt);break;case 11:r=b_(l,r,r.pendingProps,r.type.render,r.ref,bt);break;case 5:Bh(r);default:N_(l,r),r=pt=eg(r,Xr),r=k_(l,r,Xr)}n.memoizedProps=n.pendingProps,r===null?Lc(n):pt=r}function Ka(n,r,l,u){Hr=Qs=null,Bh(r),za=null,Ml=0;var m=r.return;try{if(ow(n,m,r,l,bt)){fi=1,Sc(n,er(l,n.current)),pt=null;return}}catch(g){if(m!==null)throw pt=m,g;fi=1,Sc(n,er(l,n.current)),pt=null;return}r.flags&32768?(St||u===1?n=!0:qa||(bt&536870912)!==0?n=!1:(bs=n=!0,(u===2||u===9||u===3||u===6)&&(u=In.current,u!==null&&u.tag===13&&(u.flags|=16384))),nx(r,n)):Lc(r)}function Lc(n){var r=n;do{if((r.flags&32768)!==0){nx(r,bs);return}n=r.return;var l=hw(r.alternate,r,Xr);if(l!==null){pt=l;return}if(r=r.sibling,r!==null){pt=r;return}pt=r=n}while(r!==null);fi===0&&(fi=5)}function nx(n,r){do{var l=dw(n.alternate,n);if(l!==null){l.flags&=32767,pt=l;return}if(l=n.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!r&&(n=n.sibling,n!==null)){pt=n;return}pt=n=l}while(n!==null);fi=6,pt=null}function rx(n,r,l,u,m,g,y,C,B){n.cancelPendingCommit=null;do Oc();while(Oi!==0);if((Mt&6)!==0)throw Error(s(327));if(r!==null){if(r===n.current)throw Error(s(177));if(g=r.lanes|r.childLanes,g|=lh,Ze(n,l,g,y,C,B),n===Vt&&(pt=Vt=null,bt=0),Ga=r,Ss=n,Zr=l,md=g,gd=m,Y_=u,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,Cw(Ie,function(){return cx(),null})):(n.callbackNode=null,n.callbackPriority=0),u=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||u){u=A.T,A.T=null,m=q.p,q.p=2,y=Mt,Mt|=4;try{fw(n,r,l)}finally{Mt=y,q.p=m,A.T=u}}Oi=1,sx(),ax(),lx()}}function sx(){if(Oi===1){Oi=0;var n=Ss,r=Ga,l=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||l){l=A.T,A.T=null;var u=q.p;q.p=2;var m=Mt;Mt|=4;try{I_(r,n);var g=Rd,y=Wm(n.containerInfo),C=g.focusedElem,B=g.selectionRange;if(y!==C&&C&&C.ownerDocument&&qm(C.ownerDocument.documentElement,C)){if(B!==null&&ih(C)){var Q=B.start,ce=B.end;if(ce===void 0&&(ce=Q),"selectionStart"in C)C.selectionStart=Q,C.selectionEnd=Math.min(ce,C.value.length);else{var me=C.ownerDocument||document,ee=me&&me.defaultView||window;if(ee.getSelection){var ae=ee.getSelection(),Le=C.textContent.length,Ve=Math.min(B.start,Le),qt=B.end===void 0?Ve:Math.min(B.end,Le);!ae.extend&&Ve>qt&&(y=qt,qt=Ve,Ve=y);var W=Fm(C,Ve),P=Fm(C,qt);if(W&&P&&(ae.rangeCount!==1||ae.anchorNode!==W.node||ae.anchorOffset!==W.offset||ae.focusNode!==P.node||ae.focusOffset!==P.offset)){var Z=me.createRange();Z.setStart(W.node,W.offset),ae.removeAllRanges(),Ve>qt?(ae.addRange(Z),ae.extend(P.node,P.offset)):(Z.setEnd(P.node,P.offset),ae.addRange(Z))}}}}for(me=[],ae=C;ae=ae.parentNode;)ae.nodeType===1&&me.push({element:ae,left:ae.scrollLeft,top:ae.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<me.length;C++){var pe=me[C];pe.element.scrollLeft=pe.left,pe.element.scrollTop=pe.top}}Kc=!!Ad,Rd=Ad=null}finally{Mt=m,q.p=u,A.T=l}}n.current=r,Oi=2}}function ax(){if(Oi===2){Oi=0;var n=Ss,r=Ga,l=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||l){l=A.T,A.T=null;var u=q.p;q.p=2;var m=Mt;Mt|=4;try{B_(n,r.alternate,r)}finally{Mt=m,q.p=u,A.T=l}}Oi=3}}function lx(){if(Oi===4||Oi===3){Oi=0,Ei();var n=Ss,r=Ga,l=Zr,u=Y_;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Oi=5:(Oi=0,Ga=Ss=null,ox(n,n.pendingLanes));var m=n.pendingLanes;if(m===0&&(ys=null),Je(l),r=r.stateNode,xt&&typeof xt.onCommitFiberRoot=="function")try{xt.onCommitFiberRoot(nt,r,void 0,(r.current.flags&128)===128)}catch{}if(u!==null){r=A.T,m=q.p,q.p=2,A.T=null;try{for(var g=n.onRecoverableError,y=0;y<u.length;y++){var C=u[y];g(C.value,{componentStack:C.stack})}}finally{A.T=r,q.p=m}}(Zr&3)!==0&&Oc(),kr(n),m=n.pendingLanes,(l&261930)!==0&&(m&42)!==0?n===_d?Xl++:(Xl=0,_d=n):Xl=0,Zl(0)}}function ox(n,r){(n.pooledCacheLanes&=r)===0&&(r=n.pooledCache,r!=null&&(n.pooledCache=null,Rl(r)))}function Oc(){return sx(),ax(),lx(),cx()}function cx(){if(Oi!==5)return!1;var n=Ss,r=md;md=0;var l=Je(Zr),u=A.T,m=q.p;try{q.p=32>l?32:l,A.T=null,l=gd,gd=null;var g=Ss,y=Zr;if(Oi=0,Ga=Ss=null,Zr=0,(Mt&6)!==0)throw Error(s(331));var C=Mt;if(Mt|=4,q_(g.current),U_(g,g.current,y,l),Mt=C,Zl(0,!1),xt&&typeof xt.onPostCommitFiberRoot=="function")try{xt.onPostCommitFiberRoot(nt,g)}catch{}return!0}finally{q.p=m,A.T=u,ox(n,r)}}function ux(n,r,l){r=er(l,r),r=Vh(n.stateNode,r,2),n=ms(n,r,2),n!==null&&(Te(n,2),kr(n))}function It(n,r,l){if(n.tag===3)ux(n,n,l);else for(;r!==null;){if(r.tag===3){ux(r,n,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(ys===null||!ys.has(u))){n=er(l,n),l=h_(2),u=ms(r,l,2),u!==null&&(d_(l,u,r,n),Te(u,2),kr(u));break}}r=r.return}}function vd(n,r,l){var u=n.pingCache;if(u===null){u=n.pingCache=new gw;var m=new Set;u.set(r,m)}else m=u.get(r),m===void 0&&(m=new Set,u.set(r,m));m.has(l)||(dd=!0,m.add(l),n=yw.bind(null,n,r,l),r.then(n,n))}function yw(n,r,l){var u=n.pingCache;u!==null&&u.delete(r),n.pingedLanes|=n.suspendedLanes&l,n.warmLanes&=~l,Vt===n&&(bt&l)===l&&(fi===4||fi===3&&(bt&62914560)===bt&&300>yt()-Ac?(Mt&2)===0&&Ya(n,0):fd|=l,Wa===bt&&(Wa=0)),kr(n)}function hx(n,r){r===0&&(r=we()),n=Vs(n,r),n!==null&&(Te(n,r),kr(n))}function Sw(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),hx(n,l)}function ww(n,r){var l=0;switch(n.tag){case 31:case 13:var u=n.stateNode,m=n.memoizedState;m!==null&&(l=m.retryLane);break;case 19:u=n.stateNode;break;case 22:u=n.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(r),hx(n,l)}function Cw(n,r){return Gt(n,r)}var zc=null,Va=null,yd=!1,Pc=!1,Sd=!1,Cs=0;function kr(n){n!==Va&&n.next===null&&(Va===null?zc=Va=n:Va=Va.next=n),Pc=!0,yd||(yd=!0,Ew())}function Zl(n,r){if(!Sd&&Pc){Sd=!0;do for(var l=!1,u=zc;u!==null;){if(n!==0){var m=u.pendingLanes;if(m===0)var g=0;else{var y=u.suspendedLanes,C=u.pingedLanes;g=(1<<31-ct(42|n)+1)-1,g&=m&~(y&~C),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(l=!0,mx(u,g))}else g=bt,g=ln(u,u===Vt?g:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(g&3)===0||Ui(u,g)||(l=!0,mx(u,g));u=u.next}while(l);Sd=!1}}function kw(){dx()}function dx(){Pc=yd=!1;var n=0;Cs!==0&&Ow()&&(n=Cs);for(var r=yt(),l=null,u=zc;u!==null;){var m=u.next,g=fx(u,r);g===0?(u.next=null,l===null?zc=m:l.next=m,m===null&&(Va=l)):(l=u,(n!==0||(g&3)!==0)&&(Pc=!0)),u=m}Oi!==0&&Oi!==5||Zl(n),Cs!==0&&(Cs=0)}function fx(n,r){for(var l=n.suspendedLanes,u=n.pingedLanes,m=n.expirationTimes,g=n.pendingLanes&-62914561;0<g;){var y=31-ct(g),C=1<<y,B=m[y];B===-1?((C&l)===0||(C&u)!==0)&&(m[y]=O(C,r)):B<=r&&(n.expiredLanes|=C),g&=~C}if(r=Vt,l=bt,l=ln(n,n===r?l:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),u=n.callbackNode,l===0||n===r&&(Pt===2||Pt===9)||n.cancelPendingCommit!==null)return u!==null&&u!==null&&wt(u),n.callbackNode=null,n.callbackPriority=0;if((l&3)===0||Ui(n,l)){if(r=l&-l,r===n.callbackPriority)return r;switch(u!==null&&wt(u),Je(l)){case 2:case 8:l=se;break;case 32:l=Ie;break;case 268435456:l=De;break;default:l=Ie}return u=px.bind(null,n),l=Gt(l,u),n.callbackPriority=r,n.callbackNode=l,r}return u!==null&&u!==null&&wt(u),n.callbackPriority=2,n.callbackNode=null,2}function px(n,r){if(Oi!==0&&Oi!==5)return n.callbackNode=null,n.callbackPriority=0,null;var l=n.callbackNode;if(Oc()&&n.callbackNode!==l)return null;var u=bt;return u=ln(n,n===Vt?u:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),u===0?null:(V_(n,u,r),fx(n,yt()),n.callbackNode!=null&&n.callbackNode===l?px.bind(null,n):null)}function mx(n,r){if(Oc())return null;V_(n,r,!0)}function Ew(){Pw(function(){(Mt&6)!==0?Gt(oe,kw):dx()})}function wd(){if(Cs===0){var n=Ba;n===0&&(n=mn,mn<<=1,(mn&261888)===0&&(mn=256)),Cs=n}return Cs}function gx(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:Ca(""+n)}function _x(n,r){var l=r.ownerDocument.createElement("input");return l.name=r.name,l.value=r.value,n.id&&l.setAttribute("form",n.id),r.parentNode.insertBefore(l,r),n=new FormData(n),l.parentNode.removeChild(l),n}function Nw(n,r,l,u,m){if(r==="submit"&&l&&l.stateNode===m){var g=gx((m[si]||null).action),y=u.submitter;y&&(r=(r=y[si]||null)?gx(r.formAction):y.getAttribute("formAction"),r!==null&&(g=r,y=null));var C=new Xo("action","action",null,u,m);n.push({event:C,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(Cs!==0){var B=y?_x(m,y):new FormData(m);Fh(l,{pending:!0,data:B,method:m.method,action:g},null,B)}}else typeof g=="function"&&(C.preventDefault(),B=y?_x(m,y):new FormData(m),Fh(l,{pending:!0,data:B,method:m.method,action:g},g,B))},currentTarget:m}]})}}for(var Cd=0;Cd<ah.length;Cd++){var kd=ah[Cd],Tw=kd.toLowerCase(),jw=kd[0].toUpperCase()+kd.slice(1);pr(Tw,"on"+jw)}pr(Km,"onAnimationEnd"),pr(Vm,"onAnimationIteration"),pr(Xm,"onAnimationStart"),pr("dblclick","onDoubleClick"),pr("focusin","onFocus"),pr("focusout","onBlur"),pr(W1,"onTransitionRun"),pr(G1,"onTransitionStart"),pr(Y1,"onTransitionCancel"),pr(Zm,"onTransitionEnd"),Lt("onMouseEnter",["mouseout","mouseover"]),Lt("onMouseLeave",["mouseout","mouseover"]),Lt("onPointerEnter",["pointerout","pointerover"]),Lt("onPointerLeave",["pointerout","pointerover"]),dt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),dt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),dt("onBeforeInput",["compositionend","keypress","textInput","paste"]),dt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),dt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),dt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ql="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Aw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ql));function xx(n,r){r=(r&4)!==0;for(var l=0;l<n.length;l++){var u=n[l],m=u.event;u=u.listeners;e:{var g=void 0;if(r)for(var y=u.length-1;0<=y;y--){var C=u[y],B=C.instance,Q=C.currentTarget;if(C=C.listener,B!==g&&m.isPropagationStopped())break e;g=C,m.currentTarget=Q;try{g(m)}catch(ce){Jo(ce)}m.currentTarget=null,g=B}else for(y=0;y<u.length;y++){if(C=u[y],B=C.instance,Q=C.currentTarget,C=C.listener,B!==g&&m.isPropagationStopped())break e;g=C,m.currentTarget=Q;try{g(m)}catch(ce){Jo(ce)}m.currentTarget=null,g=B}}}}function mt(n,r){var l=r[he];l===void 0&&(l=r[he]=new Set);var u=n+"__bubble";l.has(u)||(bx(r,n,2,!1),l.add(u))}function Ed(n,r,l){var u=0;r&&(u|=4),bx(l,n,u,r)}var Ic="_reactListening"+Math.random().toString(36).slice(2);function Nd(n){if(!n[Ic]){n[Ic]=!0,Be.forEach(function(l){l!=="selectionchange"&&(Aw.has(l)||Ed(l,!1,n),Ed(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Ic]||(r[Ic]=!0,Ed("selectionchange",!1,r))}}function bx(n,r,l,u){switch(Kx(r)){case 2:var m=rC;break;case 8:m=sC;break;default:m=$d}l=m.bind(null,r,l,n),m=void 0,!Ee||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(m=!0),u?m!==void 0?n.addEventListener(r,l,{capture:!0,passive:m}):n.addEventListener(r,l,!0):m!==void 0?n.addEventListener(r,l,{passive:m}):n.addEventListener(r,l,!1)}function Td(n,r,l,u,m){var g=u;if((r&1)===0&&(r&2)===0&&u!==null)e:for(;;){if(u===null)return;var y=u.tag;if(y===3||y===4){var C=u.stateNode.containerInfo;if(C===m)break;if(y===4)for(y=u.return;y!==null;){var B=y.tag;if((B===3||B===4)&&y.stateNode.containerInfo===m)return;y=y.return}for(;C!==null;){if(y=Bt(C),y===null)return;if(B=y.tag,B===5||B===6||B===26||B===27){u=g=y;continue e}C=C.parentNode}}u=u.return}qs(function(){var Q=g,ce=bl(l),me=[];e:{var ee=Qm.get(n);if(ee!==void 0){var ae=Xo,Le=n;switch(n){case"keypress":if(fr(l)===0)break e;case"keydown":case"keyup":ae=w1;break;case"focusin":Le="focus",ae=Zu;break;case"focusout":Le="blur",ae=Zu;break;case"beforeblur":case"afterblur":ae=Zu;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ae=Nm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ae=h1;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ae=E1;break;case Km:case Vm:case Xm:ae=p1;break;case Zm:ae=T1;break;case"scroll":case"scrollend":ae=c1;break;case"wheel":ae=A1;break;case"copy":case"cut":case"paste":ae=g1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ae=jm;break;case"toggle":case"beforetoggle":ae=D1}var Ve=(r&4)!==0,qt=!Ve&&(n==="scroll"||n==="scrollend"),W=Ve?ee!==null?ee+"Capture":null:ee;Ve=[];for(var P=Q,Z;P!==null;){var pe=P;if(Z=pe.stateNode,pe=pe.tag,pe!==5&&pe!==26&&pe!==27||Z===null||W===null||(pe=Ws(P,W),pe!=null&&Ve.push(Jl(P,pe,Z))),qt)break;P=P.return}0<Ve.length&&(ee=new ae(ee,Le,null,l,ce),me.push({event:ee,listeners:Ve}))}}if((r&7)===0){e:{if(ee=n==="mouseover"||n==="pointerover",ae=n==="mouseout"||n==="pointerout",ee&&l!==$s&&(Le=l.relatedTarget||l.fromElement)&&(Bt(Le)||Le[Zt]))break e;if((ae||ee)&&(ee=ce.window===ce?ce:(ee=ce.ownerDocument)?ee.defaultView||ee.parentWindow:window,ae?(Le=l.relatedTarget||l.toElement,ae=Q,Le=Le?Bt(Le):null,Le!==null&&(qt=o(Le),Ve=Le.tag,Le!==qt||Ve!==5&&Ve!==27&&Ve!==6)&&(Le=null)):(ae=null,Le=Q),ae!==Le)){if(Ve=Nm,pe="onMouseLeave",W="onMouseEnter",P="mouse",(n==="pointerout"||n==="pointerover")&&(Ve=jm,pe="onPointerLeave",W="onPointerEnter",P="pointer"),qt=ae==null?ee:xe(ae),Z=Le==null?ee:xe(Le),ee=new Ve(pe,P+"leave",ae,l,ce),ee.target=qt,ee.relatedTarget=Z,pe=null,Bt(ce)===Q&&(Ve=new Ve(W,P+"enter",Le,l,ce),Ve.target=Z,Ve.relatedTarget=qt,pe=Ve),qt=pe,ae&&Le)t:{for(Ve=Rw,W=ae,P=Le,Z=0,pe=W;pe;pe=Ve(pe))Z++;pe=0;for(var We=P;We;We=Ve(We))pe++;for(;0<Z-pe;)W=Ve(W),Z--;for(;0<pe-Z;)P=Ve(P),pe--;for(;Z--;){if(W===P||P!==null&&W===P.alternate){Ve=W;break t}W=Ve(W),P=Ve(P)}Ve=null}else Ve=null;ae!==null&&vx(me,ee,ae,Ve,!1),Le!==null&&qt!==null&&vx(me,qt,Le,Ve,!0)}}e:{if(ee=Q?xe(Q):window,ae=ee.nodeName&&ee.nodeName.toLowerCase(),ae==="select"||ae==="input"&&ee.type==="file")var jt=zm;else if(Lm(ee))if(Pm)jt=$1;else{jt=H1;var Ue=I1}else ae=ee.nodeName,!ae||ae.toLowerCase()!=="input"||ee.type!=="checkbox"&&ee.type!=="radio"?Q&&zr(Q.elementType)&&(jt=zm):jt=U1;if(jt&&(jt=jt(n,Q))){Om(me,jt,l,ce);break e}Ue&&Ue(n,ee,Q),n==="focusout"&&Q&&ee.type==="number"&&Q.memoizedProps.value!=null&&yr(ee,"number",ee.value)}switch(Ue=Q?xe(Q):window,n){case"focusin":(Lm(Ue)||Ue.contentEditable==="true")&&(Ea=Ue,nh=Q,Tl=null);break;case"focusout":Tl=nh=Ea=null;break;case"mousedown":rh=!0;break;case"contextmenu":case"mouseup":case"dragend":rh=!1,Gm(me,l,ce);break;case"selectionchange":if(q1)break;case"keydown":case"keyup":Gm(me,l,ce)}var lt;if(Ju)e:{switch(n){case"compositionstart":var vt="onCompositionStart";break e;case"compositionend":vt="onCompositionEnd";break e;case"compositionupdate":vt="onCompositionUpdate";break e}vt=void 0}else ka?Mm(n,l)&&(vt="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(vt="onCompositionStart");vt&&(Am&&l.locale!=="ko"&&(ka||vt!=="onCompositionStart"?vt==="onCompositionEnd"&&ka&&(lt=dr()):(Xe=ce,Kt="value"in Xe?Xe.value:Xe.textContent,ka=!0)),Ue=Hc(Q,vt),0<Ue.length&&(vt=new Tm(vt,n,null,l,ce),me.push({event:vt,listeners:Ue}),lt?vt.data=lt:(lt=Bm(l),lt!==null&&(vt.data=lt)))),(lt=B1?L1(n,l):O1(n,l))&&(vt=Hc(Q,"onBeforeInput"),0<vt.length&&(Ue=new Tm("onBeforeInput","beforeinput",null,l,ce),me.push({event:Ue,listeners:vt}),Ue.data=lt)),Nw(me,n,Q,l,ce)}xx(me,r)})}function Jl(n,r,l){return{instance:n,listener:r,currentTarget:l}}function Hc(n,r){for(var l=r+"Capture",u=[];n!==null;){var m=n,g=m.stateNode;if(m=m.tag,m!==5&&m!==26&&m!==27||g===null||(m=Ws(n,l),m!=null&&u.unshift(Jl(n,m,g)),m=Ws(n,r),m!=null&&u.push(Jl(n,m,g))),n.tag===3)return u;n=n.return}return[]}function Rw(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function vx(n,r,l,u,m){for(var g=r._reactName,y=[];l!==null&&l!==u;){var C=l,B=C.alternate,Q=C.stateNode;if(C=C.tag,B!==null&&B===u)break;C!==5&&C!==26&&C!==27||Q===null||(B=Q,m?(Q=Ws(l,g),Q!=null&&y.unshift(Jl(l,Q,B))):m||(Q=Ws(l,g),Q!=null&&y.push(Jl(l,Q,B)))),l=l.return}y.length!==0&&n.push({event:r,listeners:y})}var Dw=/\r\n?/g,Mw=/\u0000|\uFFFD/g;function yx(n){return(typeof n=="string"?n:""+n).replace(Dw,`
49
+ `).replace(Mw,"")}function Sx(n,r){return r=yx(r),yx(n)===r}function Ft(n,r,l,u,m,g){switch(l){case"children":typeof u=="string"?r==="body"||r==="textarea"&&u===""||Or(n,u):(typeof u=="number"||typeof u=="bigint")&&r!=="body"&&Or(n,""+u);break;case"className":Yt(n,"class",u);break;case"tabIndex":Yt(n,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":Yt(n,l,u);break;case"style":xl(n,u,g);break;case"data":if(r!=="object"){Yt(n,"data",u);break}case"src":case"href":if(u===""&&(r!=="a"||l!=="href")){n.removeAttribute(l);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){n.removeAttribute(l);break}u=Ca(""+u),n.setAttribute(l,u);break;case"action":case"formAction":if(typeof u=="function"){n.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof g=="function"&&(l==="formAction"?(r!=="input"&&Ft(n,r,"name",m.name,m,null),Ft(n,r,"formEncType",m.formEncType,m,null),Ft(n,r,"formMethod",m.formMethod,m,null),Ft(n,r,"formTarget",m.formTarget,m,null)):(Ft(n,r,"encType",m.encType,m,null),Ft(n,r,"method",m.method,m,null),Ft(n,r,"target",m.target,m,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){n.removeAttribute(l);break}u=Ca(""+u),n.setAttribute(l,u);break;case"onClick":u!=null&&(n.onclick=Zn);break;case"onScroll":u!=null&&mt("scroll",n);break;case"onScrollEnd":u!=null&&mt("scrollend",n);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(l=u.__html,l!=null){if(m.children!=null)throw Error(s(60));n.innerHTML=l}}break;case"multiple":n.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":n.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){n.removeAttribute("xlink:href");break}l=Ca(""+u),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":u!=null&&typeof u!="function"&&typeof u!="symbol"?n.setAttribute(l,""+u):n.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":u&&typeof u!="function"&&typeof u!="symbol"?n.setAttribute(l,""):n.removeAttribute(l);break;case"capture":case"download":u===!0?n.setAttribute(l,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?n.setAttribute(l,u):n.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?n.setAttribute(l,u):n.removeAttribute(l);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?n.removeAttribute(l):n.setAttribute(l,u);break;case"popover":mt("beforetoggle",n),mt("toggle",n),Xn(n,"popover",u);break;case"xlinkActuate":$i(n,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":$i(n,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":$i(n,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":$i(n,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":$i(n,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":$i(n,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":$i(n,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":$i(n,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":$i(n,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":Xn(n,"is",u);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=Vo.get(l)||l,Xn(n,l,u))}}function jd(n,r,l,u,m,g){switch(l){case"style":xl(n,u,g);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(l=u.__html,l!=null){if(m.children!=null)throw Error(s(60));n.innerHTML=l}}break;case"children":typeof u=="string"?Or(n,u):(typeof u=="number"||typeof u=="bigint")&&Or(n,""+u);break;case"onScroll":u!=null&&mt("scroll",n);break;case"onScrollEnd":u!=null&&mt("scrollend",n);break;case"onClick":u!=null&&(n.onclick=Zn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!He.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(m=l.endsWith("Capture"),r=l.slice(2,m?l.length-7:void 0),g=n[si]||null,g=g!=null?g[l]:null,typeof g=="function"&&n.removeEventListener(r,g,m),typeof u=="function")){typeof g!="function"&&g!==null&&(l in n?n[l]=null:n.hasAttribute(l)&&n.removeAttribute(l)),n.addEventListener(r,u,m);break e}l in n?n[l]=u:u===!0?n.setAttribute(l,""):Xn(n,l,u)}}}function nn(n,r,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":mt("error",n),mt("load",n);var u=!1,m=!1,g;for(g in l)if(l.hasOwnProperty(g)){var y=l[g];if(y!=null)switch(g){case"src":u=!0;break;case"srcSet":m=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:Ft(n,r,g,y,l,null)}}m&&Ft(n,r,"srcSet",l.srcSet,l,null),u&&Ft(n,r,"src",l.src,l,null);return;case"input":mt("invalid",n);var C=g=y=m=null,B=null,Q=null;for(u in l)if(l.hasOwnProperty(u)){var ce=l[u];if(ce!=null)switch(u){case"name":m=ce;break;case"type":y=ce;break;case"checked":B=ce;break;case"defaultChecked":Q=ce;break;case"value":g=ce;break;case"defaultValue":C=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(s(137,r));break;default:Ft(n,r,u,ce,l,null)}}ls(n,g,C,B,Q,y,m,!1);return;case"select":mt("invalid",n),u=y=g=null;for(m in l)if(l.hasOwnProperty(m)&&(C=l[m],C!=null))switch(m){case"value":g=C;break;case"defaultValue":y=C;break;case"multiple":u=C;default:Ft(n,r,m,C,l,null)}r=g,l=y,n.multiple=!!u,r!=null?Lr(n,!!u,r,!1):l!=null&&Lr(n,!!u,l,!0);return;case"textarea":mt("invalid",n),g=m=u=null;for(y in l)if(l.hasOwnProperty(y)&&(C=l[y],C!=null))switch(y){case"value":u=C;break;case"defaultValue":m=C;break;case"children":g=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(s(91));break;default:Ft(n,r,y,C,l,null)}Sa(n,u,m,g);return;case"option":for(B in l)if(l.hasOwnProperty(B)&&(u=l[B],u!=null))switch(B){case"selected":n.selected=u&&typeof u!="function"&&typeof u!="symbol";break;default:Ft(n,r,B,u,l,null)}return;case"dialog":mt("beforetoggle",n),mt("toggle",n),mt("cancel",n),mt("close",n);break;case"iframe":case"object":mt("load",n);break;case"video":case"audio":for(u=0;u<Ql.length;u++)mt(Ql[u],n);break;case"image":mt("error",n),mt("load",n);break;case"details":mt("toggle",n);break;case"embed":case"source":case"link":mt("error",n),mt("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Q in l)if(l.hasOwnProperty(Q)&&(u=l[Q],u!=null))switch(Q){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:Ft(n,r,Q,u,l,null)}return;default:if(zr(r)){for(ce in l)l.hasOwnProperty(ce)&&(u=l[ce],u!==void 0&&jd(n,r,ce,u,l,void 0));return}}for(C in l)l.hasOwnProperty(C)&&(u=l[C],u!=null&&Ft(n,r,C,u,l,null))}function Bw(n,r,l,u){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var m=null,g=null,y=null,C=null,B=null,Q=null,ce=null;for(ae in l){var me=l[ae];if(l.hasOwnProperty(ae)&&me!=null)switch(ae){case"checked":break;case"value":break;case"defaultValue":B=me;default:u.hasOwnProperty(ae)||Ft(n,r,ae,null,u,me)}}for(var ee in u){var ae=u[ee];if(me=l[ee],u.hasOwnProperty(ee)&&(ae!=null||me!=null))switch(ee){case"type":g=ae;break;case"name":m=ae;break;case"checked":Q=ae;break;case"defaultChecked":ce=ae;break;case"value":y=ae;break;case"defaultValue":C=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(s(137,r));break;default:ae!==me&&Ft(n,r,ee,ae,u,me)}}Ni(n,y,C,B,Q,ce,g,m);return;case"select":ae=y=C=ee=null;for(g in l)if(B=l[g],l.hasOwnProperty(g)&&B!=null)switch(g){case"value":break;case"multiple":ae=B;default:u.hasOwnProperty(g)||Ft(n,r,g,null,u,B)}for(m in u)if(g=u[m],B=l[m],u.hasOwnProperty(m)&&(g!=null||B!=null))switch(m){case"value":ee=g;break;case"defaultValue":C=g;break;case"multiple":y=g;default:g!==B&&Ft(n,r,m,g,u,B)}r=C,l=y,u=ae,ee!=null?Lr(n,!!l,ee,!1):!!u!=!!l&&(r!=null?Lr(n,!!l,r,!0):Lr(n,!!l,l?[]:"",!1));return;case"textarea":ae=ee=null;for(C in l)if(m=l[C],l.hasOwnProperty(C)&&m!=null&&!u.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:Ft(n,r,C,null,u,m)}for(y in u)if(m=u[y],g=l[y],u.hasOwnProperty(y)&&(m!=null||g!=null))switch(y){case"value":ee=m;break;case"defaultValue":ae=m;break;case"children":break;case"dangerouslySetInnerHTML":if(m!=null)throw Error(s(91));break;default:m!==g&&Ft(n,r,y,m,u,g)}_l(n,ee,ae);return;case"option":for(var Le in l)if(ee=l[Le],l.hasOwnProperty(Le)&&ee!=null&&!u.hasOwnProperty(Le))switch(Le){case"selected":n.selected=!1;break;default:Ft(n,r,Le,null,u,ee)}for(B in u)if(ee=u[B],ae=l[B],u.hasOwnProperty(B)&&ee!==ae&&(ee!=null||ae!=null))switch(B){case"selected":n.selected=ee&&typeof ee!="function"&&typeof ee!="symbol";break;default:Ft(n,r,B,ee,u,ae)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ve in l)ee=l[Ve],l.hasOwnProperty(Ve)&&ee!=null&&!u.hasOwnProperty(Ve)&&Ft(n,r,Ve,null,u,ee);for(Q in u)if(ee=u[Q],ae=l[Q],u.hasOwnProperty(Q)&&ee!==ae&&(ee!=null||ae!=null))switch(Q){case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(s(137,r));break;default:Ft(n,r,Q,ee,u,ae)}return;default:if(zr(r)){for(var qt in l)ee=l[qt],l.hasOwnProperty(qt)&&ee!==void 0&&!u.hasOwnProperty(qt)&&jd(n,r,qt,void 0,u,ee);for(ce in u)ee=u[ce],ae=l[ce],!u.hasOwnProperty(ce)||ee===ae||ee===void 0&&ae===void 0||jd(n,r,ce,ee,u,ae);return}}for(var W in l)ee=l[W],l.hasOwnProperty(W)&&ee!=null&&!u.hasOwnProperty(W)&&Ft(n,r,W,null,u,ee);for(me in u)ee=u[me],ae=l[me],!u.hasOwnProperty(me)||ee===ae||ee==null&&ae==null||Ft(n,r,me,ee,u,ae)}function wx(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Lw(){if(typeof performance.getEntriesByType=="function"){for(var n=0,r=0,l=performance.getEntriesByType("resource"),u=0;u<l.length;u++){var m=l[u],g=m.transferSize,y=m.initiatorType,C=m.duration;if(g&&C&&wx(y)){for(y=0,C=m.responseEnd,u+=1;u<l.length;u++){var B=l[u],Q=B.startTime;if(Q>C)break;var ce=B.transferSize,me=B.initiatorType;ce&&wx(me)&&(B=B.responseEnd,y+=ce*(B<C?1:(C-Q)/(B-Q)))}if(--u,r+=8*(g+y)/(m.duration/1e3),n++,10<n)break}}if(0<n)return r/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var Ad=null,Rd=null;function Uc(n){return n.nodeType===9?n:n.ownerDocument}function Cx(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function kx(n,r){if(n===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&r==="foreignObject"?0:n}function Dd(n,r){return n==="textarea"||n==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Md=null;function Ow(){var n=window.event;return n&&n.type==="popstate"?n===Md?!1:(Md=n,!0):(Md=null,!1)}var Ex=typeof setTimeout=="function"?setTimeout:void 0,zw=typeof clearTimeout=="function"?clearTimeout:void 0,Nx=typeof Promise=="function"?Promise:void 0,Pw=typeof queueMicrotask=="function"?queueMicrotask:typeof Nx<"u"?function(n){return Nx.resolve(null).then(n).catch(Iw)}:Ex;function Iw(n){setTimeout(function(){throw n})}function ks(n){return n==="head"}function Tx(n,r){var l=r,u=0;do{var m=l.nextSibling;if(n.removeChild(l),m&&m.nodeType===8)if(l=m.data,l==="/$"||l==="/&"){if(u===0){n.removeChild(m),Ja(r);return}u--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")u++;else if(l==="html")eo(n.ownerDocument.documentElement);else if(l==="head"){l=n.ownerDocument.head,eo(l);for(var g=l.firstChild;g;){var y=g.nextSibling,C=g.nodeName;g[st]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&g.rel.toLowerCase()==="stylesheet"||l.removeChild(g),g=y}}else l==="body"&&eo(n.ownerDocument.body);l=m}while(l);Ja(r)}function jx(n,r){var l=n;n=0;do{var u=l.nextSibling;if(l.nodeType===1?r?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(r?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),u&&u.nodeType===8)if(l=u.data,l==="/$"){if(n===0)break;n--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||n++;l=u}while(l)}function Bd(n){var r=n.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var l=r;switch(r=r.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Bd(l),at(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}n.removeChild(l)}}function Hw(n,r,l,u){for(;n.nodeType===1;){var m=l;if(n.nodeName.toLowerCase()!==r.toLowerCase()){if(!u&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(u){if(!n[st])switch(r){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(g=n.getAttribute("rel"),g==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(g!==m.rel||n.getAttribute("href")!==(m.href==null||m.href===""?null:m.href)||n.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin)||n.getAttribute("title")!==(m.title==null?null:m.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(g=n.getAttribute("src"),(g!==(m.src==null?null:m.src)||n.getAttribute("type")!==(m.type==null?null:m.type)||n.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin))&&g&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(r==="input"&&n.type==="hidden"){var g=m.name==null?null:""+m.name;if(m.type==="hidden"&&n.getAttribute("name")===g)return n}else return n;if(n=sr(n.nextSibling),n===null)break}return null}function Uw(n,r,l){if(r==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!l||(n=sr(n.nextSibling),n===null))return null;return n}function Ax(n,r){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!r||(n=sr(n.nextSibling),n===null))return null;return n}function Ld(n){return n.data==="$?"||n.data==="$~"}function Od(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function $w(n,r){var l=n.ownerDocument;if(n.data==="$~")n._reactRetry=r;else if(n.data!=="$?"||l.readyState!=="loading")r();else{var u=function(){r(),l.removeEventListener("DOMContentLoaded",u)};l.addEventListener("DOMContentLoaded",u),n._reactRetry=u}}function sr(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return n}var zd=null;function Rx(n){n=n.nextSibling;for(var r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"||l==="/&"){if(r===0)return sr(n.nextSibling);r--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||r++}n=n.nextSibling}return null}function Dx(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(r===0)return n;r--}else l!=="/$"&&l!=="/&"||r++}n=n.previousSibling}return null}function Mx(n,r,l){switch(r=Uc(l),n){case"html":if(n=r.documentElement,!n)throw Error(s(452));return n;case"head":if(n=r.head,!n)throw Error(s(453));return n;case"body":if(n=r.body,!n)throw Error(s(454));return n;default:throw Error(s(451))}}function eo(n){for(var r=n.attributes;r.length;)n.removeAttributeNode(r[0]);at(n)}var ar=new Map,Bx=new Set;function $c(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var Qr=q.d;q.d={f:Fw,r:qw,D:Ww,C:Gw,L:Yw,m:Kw,X:Xw,S:Vw,M:Zw};function Fw(){var n=Qr.f(),r=Mc();return n||r}function qw(n){var r=K(n);r!==null&&r.tag===5&&r.type==="form"?Zg(r):Qr.r(n)}var Xa=typeof document>"u"?null:document;function Lx(n,r,l){var u=Xa;if(u&&typeof r=="string"&&r){var m=Qt(r);m='link[rel="'+n+'"][href="'+m+'"]',typeof l=="string"&&(m+='[crossorigin="'+l+'"]'),Bx.has(m)||(Bx.add(m),n={rel:n,crossOrigin:l,href:r},u.querySelector(m)===null&&(r=u.createElement("link"),nn(r,"link",n),Ce(r),u.head.appendChild(r)))}}function Ww(n){Qr.D(n),Lx("dns-prefetch",n,null)}function Gw(n,r){Qr.C(n,r),Lx("preconnect",n,r)}function Yw(n,r,l){Qr.L(n,r,l);var u=Xa;if(u&&n&&r){var m='link[rel="preload"][as="'+Qt(r)+'"]';r==="image"&&l&&l.imageSrcSet?(m+='[imagesrcset="'+Qt(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(m+='[imagesizes="'+Qt(l.imageSizes)+'"]')):m+='[href="'+Qt(n)+'"]';var g=m;switch(r){case"style":g=Za(n);break;case"script":g=Qa(n)}ar.has(g)||(n=_({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:n,as:r},l),ar.set(g,n),u.querySelector(m)!==null||r==="style"&&u.querySelector(to(g))||r==="script"&&u.querySelector(io(g))||(r=u.createElement("link"),nn(r,"link",n),Ce(r),u.head.appendChild(r)))}}function Kw(n,r){Qr.m(n,r);var l=Xa;if(l&&n){var u=r&&typeof r.as=="string"?r.as:"script",m='link[rel="modulepreload"][as="'+Qt(u)+'"][href="'+Qt(n)+'"]',g=m;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Qa(n)}if(!ar.has(g)&&(n=_({rel:"modulepreload",href:n},r),ar.set(g,n),l.querySelector(m)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(io(g)))return}u=l.createElement("link"),nn(u,"link",n),Ce(u),l.head.appendChild(u)}}}function Vw(n,r,l){Qr.S(n,r,l);var u=Xa;if(u&&n){var m=ve(u).hoistableStyles,g=Za(n);r=r||"default";var y=m.get(g);if(!y){var C={loading:0,preload:null};if(y=u.querySelector(to(g)))C.loading=5;else{n=_({rel:"stylesheet",href:n,"data-precedence":r},l),(l=ar.get(g))&&Pd(n,l);var B=y=u.createElement("link");Ce(B),nn(B,"link",n),B._p=new Promise(function(Q,ce){B.onload=Q,B.onerror=ce}),B.addEventListener("load",function(){C.loading|=1}),B.addEventListener("error",function(){C.loading|=2}),C.loading|=4,Fc(y,r,u)}y={type:"stylesheet",instance:y,count:1,state:C},m.set(g,y)}}}function Xw(n,r){Qr.X(n,r);var l=Xa;if(l&&n){var u=ve(l).hoistableScripts,m=Qa(n),g=u.get(m);g||(g=l.querySelector(io(m)),g||(n=_({src:n,async:!0},r),(r=ar.get(m))&&Id(n,r),g=l.createElement("script"),Ce(g),nn(g,"link",n),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(m,g))}}function Zw(n,r){Qr.M(n,r);var l=Xa;if(l&&n){var u=ve(l).hoistableScripts,m=Qa(n),g=u.get(m);g||(g=l.querySelector(io(m)),g||(n=_({src:n,async:!0,type:"module"},r),(r=ar.get(m))&&Id(n,r),g=l.createElement("script"),Ce(g),nn(g,"link",n),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(m,g))}}function Ox(n,r,l,u){var m=(m=de.current)?$c(m):null;if(!m)throw Error(s(446));switch(n){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=Za(l.href),l=ve(m).hoistableStyles,u=l.get(r),u||(u={type:"style",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){n=Za(l.href);var g=ve(m).hoistableStyles,y=g.get(n);if(y||(m=m.ownerDocument||m,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(n,y),(g=m.querySelector(to(n)))&&!g._p&&(y.instance=g,y.state.loading=5),ar.has(n)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},ar.set(n,l),g||Qw(m,n,l,y.state))),r&&u===null)throw Error(s(528,""));return y}if(r&&u!==null)throw Error(s(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Qa(l),l=ve(m).hoistableScripts,u=l.get(r),u||(u={type:"script",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,n))}}function Za(n){return'href="'+Qt(n)+'"'}function to(n){return'link[rel="stylesheet"]['+n+"]"}function zx(n){return _({},n,{"data-precedence":n.precedence,precedence:null})}function Qw(n,r,l,u){n.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=n.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),nn(r,"link",l),Ce(r),n.head.appendChild(r))}function Qa(n){return'[src="'+Qt(n)+'"]'}function io(n){return"script[async]"+n}function Px(n,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=n.querySelector('style[data-href~="'+Qt(l.href)+'"]');if(u)return r.instance=u,Ce(u),u;var m=_({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(n.ownerDocument||n).createElement("style"),Ce(u),nn(u,"style",m),Fc(u,l.precedence,n),r.instance=u;case"stylesheet":m=Za(l.href);var g=n.querySelector(to(m));if(g)return r.state.loading|=4,r.instance=g,Ce(g),g;u=zx(l),(m=ar.get(m))&&Pd(u,m),g=(n.ownerDocument||n).createElement("link"),Ce(g);var y=g;return y._p=new Promise(function(C,B){y.onload=C,y.onerror=B}),nn(g,"link",u),r.state.loading|=4,Fc(g,l.precedence,n),r.instance=g;case"script":return g=Qa(l.src),(m=n.querySelector(io(g)))?(r.instance=m,Ce(m),m):(u=l,(m=ar.get(g))&&(u=_({},l),Id(u,m)),n=n.ownerDocument||n,m=n.createElement("script"),Ce(m),nn(m,"link",u),n.head.appendChild(m),r.instance=m);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,Fc(u,l.precedence,n));return r.instance}function Fc(n,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=u.length?u[u.length-1]:null,g=m,y=0;y<u.length;y++){var C=u[y];if(C.dataset.precedence===r)g=C;else if(g!==m)break}g?g.parentNode.insertBefore(n,g.nextSibling):(r=l.nodeType===9?l.head:l,r.insertBefore(n,r.firstChild))}function Pd(n,r){n.crossOrigin==null&&(n.crossOrigin=r.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=r.referrerPolicy),n.title==null&&(n.title=r.title)}function Id(n,r){n.crossOrigin==null&&(n.crossOrigin=r.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=r.referrerPolicy),n.integrity==null&&(n.integrity=r.integrity)}var qc=null;function Ix(n,r,l){if(qc===null){var u=new Map,m=qc=new Map;m.set(l,u)}else m=qc,u=m.get(l),u||(u=new Map,m.set(l,u));if(u.has(n))return u;for(u.set(n,null),l=l.getElementsByTagName(n),m=0;m<l.length;m++){var g=l[m];if(!(g[st]||g[Ot]||n==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var y=g.getAttribute(r)||"";y=n+y;var C=u.get(y);C?C.push(g):u.set(y,[g])}}return u}function Hx(n,r,l){n=n.ownerDocument||n,n.head.insertBefore(l,r==="title"?n.querySelector("head > title"):null)}function Jw(n,r,l){if(l===1||r.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return n=r.disabled,typeof r.precedence=="string"&&n==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function Ux(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function eC(n,r,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var m=Za(u.href),g=r.querySelector(to(m));if(g){r=g._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(n.count++,n=Wc.bind(n),r.then(n,n)),l.state.loading|=4,l.instance=g,Ce(g);return}g=r.ownerDocument||r,u=zx(u),(m=ar.get(m))&&Pd(u,m),g=g.createElement("link"),Ce(g);var y=g;y._p=new Promise(function(C,B){y.onload=C,y.onerror=B}),nn(g,"link",u),l.instance=g}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(n.count++,l=Wc.bind(n),r.addEventListener("load",l),r.addEventListener("error",l))}}var Hd=0;function tC(n,r){return n.stylesheets&&n.count===0&&Yc(n,n.stylesheets),0<n.count||0<n.imgCount?function(l){var u=setTimeout(function(){if(n.stylesheets&&Yc(n,n.stylesheets),n.unsuspend){var g=n.unsuspend;n.unsuspend=null,g()}},6e4+r);0<n.imgBytes&&Hd===0&&(Hd=62500*Lw());var m=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&Yc(n,n.stylesheets),n.unsuspend)){var g=n.unsuspend;n.unsuspend=null,g()}},(n.imgBytes>Hd?50:800)+r);return n.unsuspend=l,function(){n.unsuspend=null,clearTimeout(u),clearTimeout(m)}}:null}function Wc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Yc(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var Gc=null;function Yc(n,r){n.stylesheets=null,n.unsuspend!==null&&(n.count++,Gc=new Map,r.forEach(iC,n),Gc=null,Wc.call(n))}function iC(n,r){if(!(r.state.loading&4)){var l=Gc.get(n);if(l)var u=l.get(null);else{l=new Map,Gc.set(n,l);for(var m=n.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<m.length;g++){var y=m[g];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(l.set(y.dataset.precedence,y),u=y)}u&&l.set(null,u)}m=r.instance,y=m.getAttribute("data-precedence"),g=l.get(y)||u,g===u&&l.set(null,m),l.set(y,m),this.count++,u=Wc.bind(this),m.addEventListener("load",u),m.addEventListener("error",u),g?g.parentNode.insertBefore(m,g.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(m,n.firstChild)),r.state.loading|=4}}var no={$$typeof:z,Provider:null,Consumer:null,_currentValue:$,_currentValue2:$,_threadCount:0};function nC(n,r,l,u,m,g,y,C,B){this.tag=1,this.containerInfo=n,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Me(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Me(0),this.hiddenUpdates=Me(null),this.identifierPrefix=u,this.onUncaughtError=m,this.onCaughtError=g,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=B,this.incompleteTransitions=new Map}function $x(n,r,l,u,m,g,y,C,B,Q,ce,me){return n=new nC(n,r,l,y,B,Q,ce,me,C),r=1,g===!0&&(r|=24),g=Pn(3,null,null,r),n.current=g,g.stateNode=n,r=bh(),r.refCount++,n.pooledCache=r,r.refCount++,g.memoizedState={element:u,isDehydrated:l,cache:r},wh(g),n}function Fx(n){return n?(n=ja,n):ja}function qx(n,r,l,u,m,g){m=Fx(m),u.context===null?u.context=m:u.pendingContext=m,u=ps(r),u.payload={element:l},g=g===void 0?null:g,g!==null&&(u.callback=g),l=ms(n,u,r),l!==null&&(Dn(l,n,r),Ll(l,n,r))}function Wx(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function Ud(n,r){Wx(n,r),(n=n.alternate)&&Wx(n,r)}function Gx(n){if(n.tag===13||n.tag===31){var r=Vs(n,67108864);r!==null&&Dn(r,n,67108864),Ud(n,67108864)}}function Yx(n){if(n.tag===13||n.tag===31){var r=Fn();r=Rt(r);var l=Vs(n,r);l!==null&&Dn(l,n,r),Ud(n,r)}}var Kc=!0;function rC(n,r,l,u){var m=A.T;A.T=null;var g=q.p;try{q.p=2,$d(n,r,l,u)}finally{q.p=g,A.T=m}}function sC(n,r,l,u){var m=A.T;A.T=null;var g=q.p;try{q.p=8,$d(n,r,l,u)}finally{q.p=g,A.T=m}}function $d(n,r,l,u){if(Kc){var m=Fd(u);if(m===null)Td(n,r,u,Vc,l),Vx(n,u);else if(lC(m,n,r,l,u))u.stopPropagation();else if(Vx(n,u),r&4&&-1<aC.indexOf(n)){for(;m!==null;){var g=K(m);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var y=Ht(g.pendingLanes);if(y!==0){var C=g;for(C.pendingLanes|=2,C.entangledLanes|=2;y;){var B=1<<31-ct(y);C.entanglements[1]|=B,y&=~B}kr(g),(Mt&6)===0&&(Rc=yt()+500,Zl(0))}}break;case 31:case 13:C=Vs(g,2),C!==null&&Dn(C,g,2),Mc(),Ud(g,2)}if(g=Fd(u),g===null&&Td(n,r,u,Vc,l),g===m)break;m=g}m!==null&&u.stopPropagation()}else Td(n,r,u,null,l)}}function Fd(n){return n=bl(n),qd(n)}var Vc=null;function qd(n){if(Vc=null,n=Bt(n),n!==null){var r=o(n);if(r===null)n=null;else{var l=r.tag;if(l===13){if(n=c(r),n!==null)return n;n=null}else if(l===31){if(n=h(r),n!==null)return n;n=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null)}}return Vc=n,null}function Kx(n){switch(n){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Li()){case oe:return 2;case se:return 8;case Ie:case je:return 32;case De:return 268435456;default:return 32}default:return 32}}var Wd=!1,Es=null,Ns=null,Ts=null,ro=new Map,so=new Map,js=[],aC="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Vx(n,r){switch(n){case"focusin":case"focusout":Es=null;break;case"dragenter":case"dragleave":Ns=null;break;case"mouseover":case"mouseout":Ts=null;break;case"pointerover":case"pointerout":ro.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":so.delete(r.pointerId)}}function ao(n,r,l,u,m,g){return n===null||n.nativeEvent!==g?(n={blockedOn:r,domEventName:l,eventSystemFlags:u,nativeEvent:g,targetContainers:[m]},r!==null&&(r=K(r),r!==null&&Gx(r)),n):(n.eventSystemFlags|=u,r=n.targetContainers,m!==null&&r.indexOf(m)===-1&&r.push(m),n)}function lC(n,r,l,u,m){switch(r){case"focusin":return Es=ao(Es,n,r,l,u,m),!0;case"dragenter":return Ns=ao(Ns,n,r,l,u,m),!0;case"mouseover":return Ts=ao(Ts,n,r,l,u,m),!0;case"pointerover":var g=m.pointerId;return ro.set(g,ao(ro.get(g)||null,n,r,l,u,m)),!0;case"gotpointercapture":return g=m.pointerId,so.set(g,ao(so.get(g)||null,n,r,l,u,m)),!0}return!1}function Xx(n){var r=Bt(n.target);if(r!==null){var l=o(r);if(l!==null){if(r=l.tag,r===13){if(r=c(l),r!==null){n.blockedOn=r,bi(n.priority,function(){Yx(l)});return}}else if(r===31){if(r=h(l),r!==null){n.blockedOn=r,bi(n.priority,function(){Yx(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){n.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Xc(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var l=Fd(n.nativeEvent);if(l===null){l=n.nativeEvent;var u=new l.constructor(l.type,l);$s=u,l.target.dispatchEvent(u),$s=null}else return r=K(l),r!==null&&Gx(r),n.blockedOn=l,!1;r.shift()}return!0}function Zx(n,r,l){Xc(n)&&l.delete(r)}function oC(){Wd=!1,Es!==null&&Xc(Es)&&(Es=null),Ns!==null&&Xc(Ns)&&(Ns=null),Ts!==null&&Xc(Ts)&&(Ts=null),ro.forEach(Zx),so.forEach(Zx)}function Zc(n,r){n.blockedOn===r&&(n.blockedOn=null,Wd||(Wd=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,oC)))}var Qc=null;function Qx(n){Qc!==n&&(Qc=n,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Qc===n&&(Qc=null);for(var r=0;r<n.length;r+=3){var l=n[r],u=n[r+1],m=n[r+2];if(typeof u!="function"){if(qd(u||l)===null)continue;break}var g=K(l);g!==null&&(n.splice(r,3),r-=3,Fh(g,{pending:!0,data:m,method:l.method,action:u},u,m))}}))}function Ja(n){function r(B){return Zc(B,n)}Es!==null&&Zc(Es,n),Ns!==null&&Zc(Ns,n),Ts!==null&&Zc(Ts,n),ro.forEach(r),so.forEach(r);for(var l=0;l<js.length;l++){var u=js[l];u.blockedOn===n&&(u.blockedOn=null)}for(;0<js.length&&(l=js[0],l.blockedOn===null);)Xx(l),l.blockedOn===null&&js.shift();if(l=(n.ownerDocument||n).$$reactFormReplay,l!=null)for(u=0;u<l.length;u+=3){var m=l[u],g=l[u+1],y=m[si]||null;if(typeof g=="function")y||Qx(l);else if(y){var C=null;if(g&&g.hasAttribute("formAction")){if(m=g,y=g[si]||null)C=y.formAction;else if(qd(m)!==null)continue}else C=y.action;typeof C=="function"?l[u+1]=C:(l.splice(u,3),u-=3),Qx(l)}}}function Jx(){function n(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(y){return m=y})},focusReset:"manual",scroll:"manual"})}function r(){m!==null&&(m(),m=null),u||setTimeout(l,20)}function l(){if(!u&&!navigation.transition){var g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,m=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(l,100),function(){u=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),m!==null&&(m(),m=null)}}}function Gd(n){this._internalRoot=n}Jc.prototype.render=Gd.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(s(409));var l=r.current,u=Fn();qx(l,u,n,r,null,null)},Jc.prototype.unmount=Gd.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;qx(n.current,2,null,n,null,null),Mc(),r[Zt]=null}};function Jc(n){this._internalRoot=n}Jc.prototype.unstable_scheduleHydration=function(n){if(n){var r=hi();n={blockedOn:null,target:n,priority:r};for(var l=0;l<js.length&&r!==0&&r<js[l].priority;l++);js.splice(l,0,n),l===0&&Xx(n)}};var eb=t.version;if(eb!=="19.2.3")throw Error(s(527,eb,"19.2.3"));q.findDOMNode=function(n){var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(s(188)):(n=Object.keys(n).join(","),Error(s(268,n)));return n=d(r),n=n!==null?x(n):null,n=n===null?null:n.stateNode,n};var cC={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:A,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var eu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!eu.isDisabled&&eu.supportsFiber)try{nt=eu.inject(cC),xt=eu}catch{}}return oo.createRoot=function(n,r){if(!a(n))throw Error(s(299));var l=!1,u="",m=l_,g=o_,y=c_;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onUncaughtError!==void 0&&(m=r.onUncaughtError),r.onCaughtError!==void 0&&(g=r.onCaughtError),r.onRecoverableError!==void 0&&(y=r.onRecoverableError)),r=$x(n,1,!1,null,null,l,u,null,m,g,y,Jx),n[Zt]=r.current,Nd(n),new Gd(r)},oo.hydrateRoot=function(n,r,l){if(!a(n))throw Error(s(299));var u=!1,m="",g=l_,y=o_,C=c_,B=null;return l!=null&&(l.unstable_strictMode===!0&&(u=!0),l.identifierPrefix!==void 0&&(m=l.identifierPrefix),l.onUncaughtError!==void 0&&(g=l.onUncaughtError),l.onCaughtError!==void 0&&(y=l.onCaughtError),l.onRecoverableError!==void 0&&(C=l.onRecoverableError),l.formState!==void 0&&(B=l.formState)),r=$x(n,1,!0,r,l??null,u,m,B,g,y,C,Jx),r.context=Fx(null),l=r.current,u=Fn(),u=Rt(u),m=ps(u),m.callback=null,ms(l,m,u),l=u,r.current.lanes=l,Te(r,l),kr(r),n[Zt]=r.current,Nd(n),new Jc(r)},oo.version="19.2.3",oo}var ub;function vC(){if(ub)return Vd.exports;ub=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(),Vd.exports=bC(),Vd.exports}var yC=vC();const SC=Ou(yC);function wC({onLogin:e}){const[t,i]=w.useState(""),[s,a]=w.useState(null),[o,c]=w.useState(!1),h=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const d=await e(t);d&&a(d),c(!1)};return f.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:f.jsxs("div",{className:"w-full max-w-sm",children:[f.jsxs("div",{className:"border-border rounded border p-6",children:[f.jsxs("div",{className:"mb-6 text-center",children:[f.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),f.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),f.jsxs("form",{onSubmit:h,className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),f.jsx("input",{type:"password",value:t,onChange:p=>i(p.target.value),placeholder:"enter your passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),s&&f.jsx("p",{className:"text-error text-xs",children:s}),f.jsx("button",{type:"submit",disabled:o||!t.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:o?"authenticating...":"unlock"})]})]}),f.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function CC({onSetup:e}){const[t,i]=w.useState(""),[s,a]=w.useState(""),[o,c]=w.useState(null),[h,p]=w.useState(!1),d=async x=>{if(x.preventDefault(),!t.trim()||t.length<4){c("Passphrase must be at least 4 characters");return}if(t!==s){c("Passphrases do not match");return}p(!0),c(null);const _=await e(t);_&&c(_),p(!1)};return f.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:f.jsx("div",{className:"w-full max-w-sm",children:f.jsxs("div",{className:"border-border rounded border p-6",children:[f.jsxs("div",{className:"mb-6 text-center",children:[f.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),f.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),f.jsx("p",{className:"text-muted mb-4 text-xs leading-relaxed",children:"Choose a passphrase to protect your local writer agent. This will be used to unlock the app and secure your OWS wallet."}),f.jsxs("form",{onSubmit:d,className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),f.jsx("input",{type:"password",value:t,onChange:x=>i(x.target.value),placeholder:"choose a passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),f.jsx("input",{type:"password",value:s,onChange:x=>a(x.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&f.jsx("p",{className:"text-error text-xs",children:o}),f.jsx("button",{type:"submit",disabled:h||!t.trim()||!s.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:h?"setting up...":"create passphrase"})]})]})})})}const Jd="http://localhost:7777";function Ay({token:e}){const[t,i]=w.useState(null),[s,a]=w.useState(!1),[o,c]=w.useState(null),[h,p]=w.useState(!1),[d,x]=w.useState(null),_=w.useCallback((E,H)=>fetch(E,{...H,headers:{...H==null?void 0:H.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]),b=w.useCallback(()=>{_(`${Jd}/api/wallet`).then(E=>E.json()).then(E=>i(E)).catch(()=>i({exists:!1,error:"Failed to load wallet"}))},[_]);w.useEffect(()=>{b()},[b]);const v=async()=>{a(!0),x(null);try{const E=await _(`${Jd}/api/wallet/create`,{method:"POST"}),H=await E.json();if(!E.ok)throw new Error(H.error||"Creation failed");b()}catch(E){x(E instanceof Error?E.message:"Failed to create wallet")}a(!1)},S=async E=>{c(E.walletId||E.name),x(null);try{const H=await _(`${Jd}/api/wallet/active`,{method:"POST",body:JSON.stringify({walletId:E.walletId,name:E.name,address:E.normalizedAddress||E.address})}),z=await H.json();if(!H.ok)throw new Error(z.error||"Wallet switch failed");b()}catch(H){x(H instanceof Error?H.message:"Failed to switch wallet")}c(null)},N=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),p(!0),setTimeout(()=>p(!1),2e3))},M=E=>`${E.slice(0,6)}...${E.slice(-4)}`;return f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&f.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-muted text-xs",children:t.error||"No wallet created yet. Create one to enable autonomous transactions."}),d&&f.jsx("p",{className:"text-error text-xs",children:d}),f.jsx("button",{onClick:v,disabled:s,className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 rounded border px-4 py-2 text-xs font-medium transition-colors",children:s?"creating...":"create wallet"})]}),(t==null?void 0:t.selectionRequired)&&t.wallets&&t.wallets.length>0&&f.jsxs("div",{className:"mb-4 space-y-3 rounded border border-amber-600/30 bg-amber-950/10 p-3",children:[f.jsx("p",{className:"text-xs text-amber-700",children:"Multiple OWS wallets found. Select the wallet OWS should use for publishing and signing."}),t.wallets.map(E=>f.jsxs("div",{className:"border-border flex items-center justify-between gap-3 rounded border p-2",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"text-foreground truncate text-xs font-medium",children:E.name}),f.jsx("p",{className:"text-muted truncate text-[10px] font-mono",children:E.address||"No EVM address"})]}),f.jsx("button",{onClick:()=>S(E),disabled:!E.address||o===(E.walletId||E.name),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 rounded border px-2 py-1 text-[10px] font-medium transition-colors",children:o===(E.walletId||E.name)?"switching...":"use"})]},E.walletId||E.name)),d&&f.jsx("p",{className:"text-error text-xs",children:d})]}),t&&t.exists&&t.address&&f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Active Wallet (Base)"}),f.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[9px] ${t.ethBalance&&parseFloat(t.ethBalance)>0?"border-accent/30 text-accent":"border-accent-dim/30 text-accent-dim"}`,children:t.ethBalance&&parseFloat(t.ethBalance)>0?"active":"no balance"})]}),t.name&&f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Name"}),f.jsx("span",{className:"text-foreground truncate pl-3 font-mono text-[10px]",children:t.name})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:M(t.address)}),f.jsx("button",{onClick:N,className:"text-muted hover:text-accent text-xs transition-colors",children:h?"copied":"copy"})]}),f.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"ETH"}),f.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"USDC"}),f.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"PLOT"}),f.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Network"}),f.jsx("span",{className:"text-foreground",children:"Base"})]})]}),t.wallets&&t.wallets.length>1&&f.jsxs("div",{className:"border-border space-y-2 border-t pt-3",children:[f.jsx("p",{className:"text-muted text-[10px] font-medium uppercase tracking-wider",children:"Switch Wallet"}),t.wallets.map(E=>f.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsxs("p",{className:E.active?"text-accent truncate font-medium":"text-foreground truncate",children:[E.name,E.active?" (active)":""]}),f.jsx("p",{className:"text-muted truncate text-[10px] font-mono",children:E.address||"No EVM address"})]}),!E.active&&f.jsx("button",{onClick:()=>S(E),disabled:!E.address||o===(E.walletId||E.name),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 rounded border px-2 py-1 text-[10px] transition-colors",children:o===(E.walletId||E.name)?"...":"use"})]},E.walletId||E.name)),d&&f.jsx("p",{className:"text-error text-xs",children:d})]}),f.jsxs("div",{className:"border-border border-t pt-3",children:[f.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),f.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),f.jsx("code",{className:"text-foreground bg-surface mt-1 block break-all rounded px-2 py-1.5 text-[10px] font-mono",children:t.address})]})]}),(t==null?void 0:t.exists)&&f.jsx("button",{onClick:v,disabled:s,className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 mt-4 rounded border px-3 py-1.5 text-[10px] font-medium transition-colors",children:s?"creating...":"create another wallet"})]})}function wu(e){return!!e&&e.codex.installed&&e.codex.auth==="unknown"}const $p="Codex is installed but its capabilities couldn't be read — you may need to log in to Codex (resolve outside OWS), then re-check.";function kC({token:e,onLogout:t}){const[i,s]=w.useState(""),[a,o]=w.useState(""),[c,h]=w.useState(null),[p,d]=w.useState(!1),[x,_]=w.useState(!1),[b,v]=w.useState(null),[S,N]=w.useState("AI Writer"),[M,E]=w.useState(""),[H,z]=w.useState(""),[R,te]=w.useState(!1),[L,I]=w.useState(null),[re,_e]=w.useState(""),[j,J]=w.useState(null),[F,G]=w.useState(!1),[Y,U]=w.useState(null),[A,q]=w.useState(null),[$,be]=w.useState(null),T=w.useCallback((ne,de)=>fetch(ne,{...de,headers:{...de==null?void 0:de.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);w.useEffect(()=>{T("/api/settings/link-status").then(ne=>ne.json()).then(ne=>v(ne)).catch(()=>v({linked:!1}))},[]),w.useEffect(()=>{T("/api/agent/readiness").then(ne=>ne.ok?ne.json():null).then(ne=>{ne&&be(ne)}).catch(()=>{})},[]);const D=async()=>{if(!S.trim()){I("Agent name is required");return}if(!M.trim()){I("Description is required");return}te(!0),I(null);try{const ne=await T("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:S,description:M,...H.trim()&&{genre:H}})}),de=await ne.json();if(!ne.ok)throw new Error(de.error||"Registration failed");v({linked:!0,agentId:de.agentId,owsWallet:de.owsWallet,txHash:de.txHash})}catch(ne){I(ne instanceof Error?ne.message:"Registration failed")}te(!1)},V=async()=>{if(!re.trim()||!/^0x[a-fA-F0-9]{40}$/.test(re)){U("Enter a valid wallet address (0x...)");return}G(!0),U(null),J(null);try{const ne=await T("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:re})}),de=await ne.json();if(!ne.ok)throw new Error(de.error||"Failed to generate binding code");J(de)}catch(ne){U(ne instanceof Error?ne.message:"Failed to generate binding code")}G(!1)},k=async(ne,de)=>{await navigator.clipboard.writeText(ne),q(de),setTimeout(()=>q(null),2e3)},le=async()=>{if(h(null),d(!1),!i||i.length<4){h("Passphrase must be at least 4 characters");return}if(i!==a){h("Passphrases do not match");return}_(!0);try{const ne=await T("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:i})});if(!ne.ok){const de=await ne.json();throw new Error(de.error||"Reset failed")}d(!0),s(""),o(""),setTimeout(()=>d(!1),3e3)}catch(ne){h(ne instanceof Error?ne.message:"Reset failed")}_(!1)};return f.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[f.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),b!=null&&b.linked?f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),f.jsxs("span",{className:"text-muted text-xs",children:["Agent #",b.agentId]})]}),b.owsWallet&&f.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",b.owsWallet.slice(0,6),"...",b.owsWallet.slice(-4)]}),b.owner&&f.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",b.owner.slice(0,6),"...",b.owner.slice(-4)]}),b.txHash&&f.jsx("p",{className:"text-muted text-xs",children:f.jsx("a",{href:`https://basescan.org/tx/${b.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),f.jsx("p",{className:"text-muted text-xs",children:f.jsx("a",{href:`https://plotlink.xyz/profile/${b.owsWallet}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-muted text-xs",children:"Register this AI writer on-chain via ERC-8004. Uses your OWS wallet's existing ETH balance for gas."}),f.jsxs("div",{children:[f.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),f.jsx("input",{value:S,onChange:ne=>N(ne.target.value),placeholder:"AI Writer",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),f.jsx("input",{value:M,onChange:ne=>E(ne.target.value),placeholder:"An AI writing assistant for fiction stories",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),f.jsx("input",{value:H,onChange:ne=>z(ne.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),L&&f.jsx("p",{className:"text-error text-xs",children:L}),f.jsx("button",{onClick:D,disabled:R||!S.trim()||!M.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:R?"Registering...":"Register Agent Identity"})]})]}),f.jsxs("div",{className:"border-border rounded border p-4","data-testid":"provider-readiness",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Providers"}),f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-foreground text-sm",children:"Claude"}),f.jsx("span",{className:"text-muted text-xs",children:$!=null&&$.claude.installed?"Installed":"Not detected"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-foreground text-sm",children:"Codex"}),f.jsx("span",{className:"text-muted text-xs",children:$!=null&&$.codex.installed?"Installed":"Not detected"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-foreground text-sm",children:"Codex version"}),f.jsx("span",{className:"text-muted text-xs font-mono",children:($==null?void 0:$.codex.version)??"—"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-foreground text-sm",children:"Image generation"}),f.jsx("span",{className:"text-muted text-xs",children:($==null?void 0:$.codex.imageGeneration)??"unknown"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-foreground text-sm",children:"Codex auth"}),f.jsx("span",{className:"text-muted text-xs","data-testid":"codex-auth-status",children:$!=null&&$.codex.installed?$.codex.auth==="ok"?"ok":"unclear":"—"})]}),wu($)&&f.jsx("p",{className:"text-[11px] text-amber-700","data-testid":"codex-auth-unknown-settings",children:$p}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-foreground text-sm",children:"Last checked"}),f.jsx("span",{className:"text-muted text-xs",children:$!=null&&$.checkedAt?new Date($.checkedAt).toLocaleString():"—"})]})]})]}),f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),b!=null&&b.owner?f.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",f.jsxs("span",{className:"font-mono",children:[b.owner.slice(0,6),"...",b.owner.slice(-4)]})]}):f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-muted text-xs",children:"Link this OWS wallet to your PlotLink account so your stories appear under your profile on plotlink.xyz."}),f.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[f.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),f.jsx("p",{children:'2. Click "Generate Binding Code"'}),f.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),f.jsx("input",{value:re,onChange:ne=>_e(ne.target.value),placeholder:"Your PlotLink wallet address (0x...)",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent font-mono"}),Y&&f.jsx("p",{className:"text-error text-xs",children:Y}),f.jsx("button",{onClick:V,disabled:F||!re.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:F?"Generating...":"Generate Binding Code"}),j&&f.jsxs("div",{className:"space-y-3 mt-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:j.signature}),f.jsx("button",{onClick:()=>k(j.signature,"signature"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:A==="signature"?"Copied!":"Copy"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:j.owsWallet}),f.jsx("button",{onClick:()=>k(j.owsWallet,"wallet"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:A==="wallet"?"Copied!":"Copy"})]})]}),j.agentId&&f.jsxs("div",{children:[f.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:j.agentId}),f.jsx("button",{onClick:()=>k(String(j.agentId),"agentId"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:A==="agentId"?"Copied!":"Copy"})]})]}),f.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),f.jsx(Ay,{token:e}),f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),f.jsxs("div",{className:"space-y-3",children:[f.jsx("input",{type:"password",value:i,onChange:ne=>s(ne.target.value),placeholder:"new passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),f.jsx("input",{type:"password",value:a,onChange:ne=>o(ne.target.value),placeholder:"confirm passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),c&&f.jsx("p",{className:"text-error text-xs",children:c}),p&&f.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),f.jsx("button",{onClick:le,disabled:x||!i.trim(),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 w-full rounded border px-4 py-2 text-xs font-medium transition-colors",children:x?"updating...":"update passphrase"})]})]}),f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),f.jsx("button",{onClick:t,className:"border-border text-muted hover:border-error hover:text-error rounded border px-4 py-2 text-xs font-medium transition-colors",children:"logout"})]})]})}const EC="http://localhost:7777";function NC({token:e}){const[t,i]=w.useState(null),s=w.useCallback((h,p)=>fetch(h,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]),a=w.useCallback(()=>{s(`${EC}/api/dashboard`).then(h=>h.json()).then(i)},[s]);w.useEffect(()=>{a()},[a]);const o=h=>`${h.slice(0,6)}...${h.slice(-4)}`,c=h=>{if(!h)return"Unknown date";const p=new Date(h);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?f.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[f.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),f.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[f.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[f.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),f.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),f.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[f.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),f.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),f.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[f.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),f.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),f.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[f.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),f.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),f.jsxs("div",{className:"space-y-1.5",children:[t.wallet.name&&f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Active wallet"}),f.jsx("span",{className:"text-foreground truncate pl-3 font-mono text-[10px]",children:t.wallet.name})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Address"}),f.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"ETH Balance"}),f.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"USDC Balance"}),f.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),f.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Royalties earned"}),f.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),f.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),f.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[f.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),f.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Stories published"}),f.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?f.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):f.jsx("div",{className:"space-y-3",children:t.stories.published.map(h=>f.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[f.jsxs("div",{className:"flex items-start justify-between",children:[f.jsxs("div",{children:[h.genre&&f.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:h.genre}),f.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:h.title}),f.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:h.storyName})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[h.hasNotIndexed&&f.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),f.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[h.publishedFiles," published"]})]})]}),f.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[f.jsxs("div",{className:"rounded bg-background p-1.5",children:[f.jsx("div",{className:"text-foreground text-sm font-medium",children:h.plotCount}),f.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),f.jsxs("div",{className:"rounded bg-background p-1.5",children:[f.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:h.storylineId?`#${h.storylineId}`:"—"}),f.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),f.jsxs("div",{className:"rounded bg-background p-1.5",children:[f.jsx("div",{className:"text-foreground text-sm font-medium",children:h.totalGasCostEth??"—"}),f.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),f.jsx("div",{className:"mt-2 space-y-1",children:h.files.map(p=>f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),f.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&f.jsxs("a",{href:`https://basescan.org/tx/${p.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",p.txHash.slice(0,8),"..."]})]},p.file))}),f.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[f.jsx("span",{className:"text-muted",children:c(h.latestPublishedAt)}),h.storylineId&&f.jsx("a",{href:`https://plotlink.xyz/story/${h.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},h.id))})]}),t.stories.pendingFiles>0&&f.jsx("div",{className:"border-border rounded border p-4",children:f.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const TC={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},jC={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function AC({authFetch:e,selectedStory:t,selectedFile:i,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,h]=w.useState([]),[p,d]=w.useState([]),[x,_]=w.useState(new Set),[b,v]=w.useState(!1),S=w.useCallback(async()=>{try{const I=await e("/api/stories");if(I.ok){const re=await I.json();h(re.stories)}}catch{}},[e]),N=w.useCallback(async()=>{try{const I=await e("/api/stories/archived");if(I.ok){const re=await I.json();d(re.stories)}}catch{}},[e]),M=w.useCallback(async I=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:I})})).ok&&(N(),S())}catch{}},[e,N,S]);w.useEffect(()=>{S();const I=setInterval(S,5e3);return()=>clearInterval(I)},[S]),w.useEffect(()=>{b&&N()},[b,N]),w.useEffect(()=>{t&&_(I=>new Set(I).add(t))},[t]);const E=I=>{_(re=>{const _e=new Set(re);return _e.has(I)?_e.delete(I):_e.add(I),_e})},H=I=>{var _e;const re=I.map(j=>{var J;return{file:j.file,num:(J=j.file.match(/^plot-(\d+)\.md$/))==null?void 0:J[1]}}).filter(j=>j.num!=null).sort((j,J)=>parseInt(J.num)-parseInt(j.num));return re.length>0?re[0].file:I.some(j=>j.file==="genesis.md")?"genesis.md":I.some(j=>j.file==="structure.md")?"structure.md":((_e=I[0])==null?void 0:_e.file)??null},z=I=>I==="genesis.md"||/^plot-\d+\.md$/.test(I),R=I=>{if(I==="genesis.md")return{label:"epi-01 (Genesis)",sort:1};const re=I.match(/^plot-(\d+)\.md$/);if(!re)return null;const _e=parseInt(re[1],10)+1;return{label:`epi-${String(_e).padStart(2,"0")}`,sort:_e}},te=I=>{if(E(I.name),I.contentType==="cartoon")s(I.name,"");else{const re=H(I.files);re&&s(I.name,re)}},L=(I,re)=>{if(re==="cartoon")return[...I].filter(j=>z(j.file)).sort((j,J)=>{var Y,U;const F=((Y=R(j.file))==null?void 0:Y.sort)??999,G=((U=R(J.file))==null?void 0:U.sort)??999;return F-G});const _e=j=>{if(j==="structure.md")return 0;if(j==="genesis.md")return 1;const J=j.match(/^plot-(\d+)\.md$/);return J?2+parseInt(J[1]):100};return[...I].sort((j,J)=>_e(j.file)-_e(J.file))};return b?f.jsxs("div",{className:"h-full flex flex-col",children:[f.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[f.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),f.jsx("span",{className:"text-xs text-muted",children:p.length})]}),f.jsx("div",{className:"px-3 py-2 border-b border-border",children:f.jsxs("button",{onClick:()=>v(!1),className:"w-full px-3 py-1.5 text-sm text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1.5",children:[f.jsx("span",{children:"←"}),f.jsx("span",{children:"Back"})]})}),f.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:p.length===0?f.jsx("div",{className:"p-3 text-sm text-muted",children:f.jsx("p",{children:"No archived stories."})}):p.map(I=>f.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[f.jsx("span",{className:"text-sm font-medium truncate",title:I.name,children:I.title||I.name}),f.jsx("button",{onClick:()=>M(I.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},I.name))})]}):f.jsxs("div",{className:"h-full flex flex-col",children:[f.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[f.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),f.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&f.jsx("div",{className:"px-3 py-2 border-b border-border",children:f.jsxs("button",{onClick:a,className:"w-full px-3 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent-dim flex items-center justify-center gap-1.5",children:[f.jsx("span",{children:"+"}),f.jsx("span",{children:"New Story"})]})}),f.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(I=>f.jsx("div",{children:f.jsxs("button",{onClick:()=>s(I,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===I?"bg-surface":""}`,children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),f.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},I)),c.length===0&&o.length===0?f.jsxs("div",{className:"p-3 text-sm text-muted",children:[f.jsx("p",{children:"No stories yet."}),f.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter(I=>I.name!=="_example").map(I=>f.jsxs("div",{children:[f.jsxs("button",{onClick:()=>te(I),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[f.jsx("span",{className:"text-xs text-muted",children:x.has(I.name)?"▼":"▶"}),f.jsx("span",{className:"font-medium truncate",title:I.name,children:I.title||I.name}),I.contentType==="cartoon"&&f.jsx("span",{className:"bg-accent/10 text-accent rounded px-1.5 py-0.5 text-[10px] font-medium flex-shrink-0",children:"Cartoon"}),f.jsx("span",{className:"ml-auto flex-shrink-0 text-xs text-muted",children:I.contentType==="cartoon"?`${L(I.files,"cartoon").length} ep`:`${I.publishedCount}/${I.files.length}`})]}),x.has(I.name)&&f.jsx("div",{className:"pl-4",children:L(I.files,I.contentType).map(re=>{const _e=t===I.name&&i===re.file,j=I.contentType==="cartoon"?R(re.file):null;return f.jsxs("button",{onClick:()=>s(I.name,re.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${_e?"bg-surface font-medium":""}`,children:[f.jsx("span",{className:jC[re.status],children:TC[re.status]}),f.jsx("span",{className:I.contentType==="cartoon"?"truncate":"truncate font-mono",children:(j==null?void 0:j.label)??re.file})]},re.file)})})]},I.name))]}),f.jsx("div",{className:"px-3 py-2 border-t border-border",children:f.jsx("button",{onClick:()=>v(!0),className:"w-full px-3 py-1.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center justify-center gap-1.5",children:f.jsx("span",{children:"Archives"})})})]})}/**
50
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
51
+ * @license MIT
52
+ *
53
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
54
+ * @license MIT
55
+ *
56
+ * Originally forked from (with the author's permission):
57
+ * Fabrice Bellard's javascript vt100 for jslinux:
58
+ * http://bellard.org/jslinux/
59
+ * Copyright (c) 2011 Fabrice Bellard
60
+ */var Ry=Object.defineProperty,RC=Object.getOwnPropertyDescriptor,DC=(e,t)=>{for(var i in t)Ry(e,i,{get:t[i],enumerable:!0})},gi=(e,t,i,s)=>{for(var a=s>1?void 0:s?RC(t,i):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(a=(s?c(t,i,a):c(a))||a);return s&&a&&Ry(t,i,a),a},Re=(e,t)=>(i,s)=>t(i,s,e),hb="Terminal input",Hf={get:()=>hb,set:e=>hb=e},db="Too much output to announce, navigate to rows manually to read",Uf={get:()=>db,set:e=>db=e};function MC(e){return e.replace(/\r?\n/g,"\r")}function BC(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function LC(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function OC(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");Dy(a,t,i,s)}}function Dy(e,t,i,s){e=MC(e),e=BC(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function My(e,t,i){let s=i.getBoundingClientRect(),a=e.clientX-s.left-10,o=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${a}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function fb(e,t,i,s,a){My(e,t,i),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Ls(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function zu(e,t=0,i=e.length){let s="";for(let a=t;a<i;++a){let o=e[a];o>65535?(o-=65536,s+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):s+=String.fromCharCode(o)}return s}var zC=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,a=0;if(this._interim){let o=e.charCodeAt(a++);56320<=o&&o<=57343?t[s++]=(this._interim-55296)*1024+o-56320+65536:(t[s++]=this._interim,t[s++]=o),this._interim=0}for(let o=a;o<i;++o){let c=e.charCodeAt(o);if(55296<=c&&c<=56319){if(++o>=i)return this._interim=c,s;let h=e.charCodeAt(o);56320<=h&&h<=57343?t[s++]=(c-55296)*1024+h-56320+65536:(t[s++]=c,t[s++]=h);continue}c!==65279&&(t[s++]=c)}return s}},PC=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,a,o,c,h,p=0,d=0;if(this.interim[0]){let b=!1,v=this.interim[0];v&=(v&224)===192?31:(v&240)===224?15:7;let S=0,N;for(;(N=this.interim[++S]&63)&&S<4;)v<<=6,v|=N;let M=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,E=M-S;for(;d<E;){if(d>=i)return 0;if(N=e[d++],(N&192)!==128){d--,b=!0;break}else this.interim[S++]=N,v<<=6,v|=N&63}b||(M===2?v<128?d--:t[s++]=v:M===3?v<2048||v>=55296&&v<=57343||v===65279||(t[s++]=v):v<65536||v>1114111||(t[s++]=v)),this.interim.fill(0)}let x=i-4,_=d;for(;_<i;){for(;_<x&&!((a=e[_])&128)&&!((o=e[_+1])&128)&&!((c=e[_+2])&128)&&!((h=e[_+3])&128);)t[s++]=a,t[s++]=o,t[s++]=c,t[s++]=h,_+=4;if(a=e[_++],a<128)t[s++]=a;else if((a&224)===192){if(_>=i)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(p=(a&31)<<6|o&63,p<128){_--;continue}t[s++]=p}else if((a&240)===224){if(_>=i)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=i)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(p=(a&15)<<12|(o&63)<<6|c&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((a&248)===240){if(_>=i)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=i)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(_>=i)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=c,s;if(h=e[_++],(h&192)!==128){_--;continue}if(p=(a&7)<<18|(o&63)<<12|(c&63)<<6|h&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},By="",zs=" ",Uo=class Ly{constructor(){this.fg=0,this.bg=0,this.extended=new Cu}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 Ly;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}},Cu=class Oy{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}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 Oy(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},hr=class zy extends Uo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Cu,this.combinedData=""}static fromCharData(t){let i=new zy;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ls(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 i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(s-55296)*1024+a-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},pb="di$target",$f="di$dependencies",ef=new Map;function IC(e){return e[$f]||[]}function Qi(e){if(ef.has(e))return ef.get(e);let t=function(i,s,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");HC(t,i,a)};return t._id=e,ef.set(e,t),t}function HC(e,t,i){t[pb]===t?t[$f].push({id:e,index:i}):(t[$f]=[{id:e,index:i}],t[pb]=t)}var Sn=Qi("BufferService"),Py=Qi("CoreMouseService"),va=Qi("CoreService"),UC=Qi("CharsetService"),Fp=Qi("InstantiationService"),Iy=Qi("LogService"),wn=Qi("OptionsService"),Hy=Qi("OscLinkService"),$C=Qi("UnicodeService"),$o=Qi("DecorationService"),Ff=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var x;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new hr,c=i.getTrimmedLength(),h=-1,p=-1,d=!1;for(let _=0;_<c;_++)if(!(p===-1&&!i.hasContent(_))){if(i.loadCell(_,o),o.hasExtendedAttrs()&&o.extended.urlId)if(p===-1){p=_,h=o.extended.urlId;continue}else d=o.extended.urlId!==h;else p!==-1&&(d=!0);if(d||p!==-1&&_===c-1){let b=(x=this._oscLinkService.getLinkData(h))==null?void 0:x.uri;if(b){let v={start:{x:p+1,y:e},end:{x:_+(!d&&_===c-1?1:0),y:e}},S=!1;if(!(a!=null&&a.allowNonHttpProtocols))try{let N=new URL(b);["http:","https:"].includes(N.protocol)||(S=!0)}catch{S=!0}S||s.push({text:b,range:v,activate:(N,M)=>a?a.activate(N,M,v):FC(N,M),hover:(N,M)=>{var E;return(E=a==null?void 0:a.hover)==null?void 0:E.call(a,N,M,v)},leave:(N,M)=>{var E;return(E=a==null?void 0:a.leave)==null?void 0:E.call(a,N,M,v)}})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=_,h=o.extended.urlId):(p=-1,h=-1)}}t(s)}};Ff=gi([Re(0,Sn),Re(1,wn),Re(2,Hy)],Ff);function FC(e,t){if(confirm(`Do you want to navigate to ${t}?
61
+
62
+ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Pu=Qi("CharSizeService"),rs=Qi("CoreBrowserService"),qp=Qi("MouseService"),ss=Qi("RenderService"),qC=Qi("SelectionService"),Uy=Qi("CharacterJoinerService"),fl=Qi("ThemeService"),$y=Qi("LinkProviderService"),WC=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?mb.isErrorNoTelemetry(e)?new mb(e.message+`
63
+
64
+ `+e.stack):new Error(e.message+`
65
+
66
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},GC=new WC;function pu(e){YC(e)||GC.onUnexpectedError(e)}var qf="Canceled";function YC(e){return e instanceof KC?!0:e instanceof Error&&e.name===qf&&e.message===qf}var KC=class extends Error{constructor(){super(qf),this.name=this.message}};function VC(e){return new Error(`Illegal argument: ${e}`)}var mb=class Wf extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Wf)return t;let i=new Wf;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Gf=class Fy extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Fy.prototype)}};function qn(e,t=0){return e[e.length-(1+t)]}var XC;(e=>{function t(o){return o<0}e.isLessThan=t;function i(o){return o<=0}e.isLessThanOrEqual=i;function s(o){return o>0}e.isGreaterThan=s;function a(o){return o===0}e.isNeitherLessOrGreaterThan=a,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(XC||(XC={}));function ZC(e,t){let i=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(i,arguments))),a}}var qy;(e=>{function t(R){return R&&typeof R=="object"&&typeof R[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*a(R){yield R}e.single=a;function o(R){return t(R)?R:a(R)}e.wrap=o;function c(R){return R||i}e.from=c;function*h(R){for(let te=R.length-1;te>=0;te--)yield R[te]}e.reverse=h;function p(R){return!R||R[Symbol.iterator]().next().done===!0}e.isEmpty=p;function d(R){return R[Symbol.iterator]().next().value}e.first=d;function x(R,te){let L=0;for(let I of R)if(te(I,L++))return!0;return!1}e.some=x;function _(R,te){for(let L of R)if(te(L))return L}e.find=_;function*b(R,te){for(let L of R)te(L)&&(yield L)}e.filter=b;function*v(R,te){let L=0;for(let I of R)yield te(I,L++)}e.map=v;function*S(R,te){let L=0;for(let I of R)yield*te(I,L++)}e.flatMap=S;function*N(...R){for(let te of R)yield*te}e.concat=N;function M(R,te,L){let I=L;for(let re of R)I=te(I,re);return I}e.reduce=M;function*E(R,te,L=R.length){for(te<0&&(te+=R.length),L<0?L+=R.length:L>R.length&&(L=R.length);te<L;te++)yield R[te]}e.slice=E;function H(R,te=Number.POSITIVE_INFINITY){let L=[];if(te===0)return[L,R];let I=R[Symbol.iterator]();for(let re=0;re<te;re++){let _e=I.next();if(_e.done)return[L,e.empty()];L.push(_e.value)}return[L,{[Symbol.iterator](){return I}}]}e.consume=H;async function z(R){let te=[];for await(let L of R)te.push(L);return Promise.resolve(te)}e.asyncToArray=z})(qy||(qy={}));function _a(e){if(qy.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function QC(...e){return li(()=>_a(e))}function li(e){return{dispose:ZC(()=>{e()})}}var Wy=class Gy{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{_a(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Gy.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Wy.DISABLE_DISPOSED_WARNING=!1;var Ps=Wy,ht=class{constructor(){this._store=new Ps,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};ht.None=Object.freeze({dispose(){}});var hl=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},ns=typeof window=="object"?window:globalThis,Yf=class Kf{constructor(t){this.element=t,this.next=Kf.Undefined,this.prev=Kf.Undefined}};Yf.Undefined=new Yf(void 0);var oi=Yf,gb=class{constructor(){this._first=oi.Undefined,this._last=oi.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===oi.Undefined}clear(){let e=this._first;for(;e!==oi.Undefined;){let t=e.next;e.prev=oi.Undefined,e.next=oi.Undefined,e=t}this._first=oi.Undefined,this._last=oi.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new oi(e);if(this._first===oi.Undefined)this._first=i,this._last=i;else if(t){let a=this._last;this._last=i,i.prev=a,a.next=i}else{let a=this._first;this._first=i,i.next=a,a.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==oi.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==oi.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==oi.Undefined&&e.next!==oi.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===oi.Undefined&&e.next===oi.Undefined?(this._first=oi.Undefined,this._last=oi.Undefined):e.next===oi.Undefined?(this._last=this._last.prev,this._last.next=oi.Undefined):e.prev===oi.Undefined&&(this._first=this._first.next,this._first.prev=oi.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==oi.Undefined;)yield e.element,e=e.next}},JC=globalThis.performance&&typeof globalThis.performance.now=="function",ek=class Yy{static create(t){return new Yy(t)}constructor(t){this._now=JC&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},an;(e=>{e.None=()=>ht.None;function t(F,G){return _(F,()=>{},0,void 0,!0,void 0,G)}e.defer=t;function i(F){return(G,Y=null,U)=>{let A=!1,q;return q=F($=>{if(!A)return q?q.dispose():A=!0,G.call(Y,$)},null,U),A&&q.dispose(),q}}e.once=i;function s(F,G,Y){return d((U,A=null,q)=>F($=>U.call(A,G($)),null,q),Y)}e.map=s;function a(F,G,Y){return d((U,A=null,q)=>F($=>{G($),U.call(A,$)},null,q),Y)}e.forEach=a;function o(F,G,Y){return d((U,A=null,q)=>F($=>G($)&&U.call(A,$),null,q),Y)}e.filter=o;function c(F){return F}e.signal=c;function h(...F){return(G,Y=null,U)=>{let A=QC(...F.map(q=>q($=>G.call(Y,$))));return x(A,U)}}e.any=h;function p(F,G,Y,U){let A=Y;return s(F,q=>(A=G(A,q),A),U)}e.reduce=p;function d(F,G){let Y,U={onWillAddFirstListener(){Y=F(A.fire,A)},onDidRemoveLastListener(){Y==null||Y.dispose()}},A=new ke(U);return G==null||G.add(A),A.event}function x(F,G){return G instanceof Array?G.push(F):G&&G.add(F),F}function _(F,G,Y=100,U=!1,A=!1,q,$){let be,T,D,V=0,k,le={leakWarningThreshold:q,onWillAddFirstListener(){be=F(de=>{V++,T=G(T,de),U&&!D&&(ne.fire(T),T=void 0),k=()=>{let X=T;T=void 0,D=void 0,(!U||V>1)&&ne.fire(X),V=0},typeof Y=="number"?(clearTimeout(D),D=setTimeout(k,Y)):D===void 0&&(D=0,queueMicrotask(k))})},onWillRemoveListener(){A&&V>0&&(k==null||k())},onDidRemoveLastListener(){k=void 0,be.dispose()}},ne=new ke(le);return $==null||$.add(ne),ne.event}e.debounce=_;function b(F,G=0,Y){return e.debounce(F,(U,A)=>U?(U.push(A),U):[A],G,void 0,!0,void 0,Y)}e.accumulate=b;function v(F,G=(U,A)=>U===A,Y){let U=!0,A;return o(F,q=>{let $=U||!G(q,A);return U=!1,A=q,$},Y)}e.latch=v;function S(F,G,Y){return[e.filter(F,G,Y),e.filter(F,U=>!G(U),Y)]}e.split=S;function N(F,G=!1,Y=[],U){let A=Y.slice(),q=F(T=>{A?A.push(T):be.fire(T)});U&&U.add(q);let $=()=>{A==null||A.forEach(T=>be.fire(T)),A=null},be=new ke({onWillAddFirstListener(){q||(q=F(T=>be.fire(T)),U&&U.add(q))},onDidAddFirstListener(){A&&(G?setTimeout($):$())},onDidRemoveLastListener(){q&&q.dispose(),q=null}});return U&&U.add(be),be.event}e.buffer=N;function M(F,G){return(Y,U,A)=>{let q=G(new H);return F(function($){let be=q.evaluate($);be!==E&&Y.call(U,be)},void 0,A)}}e.chain=M;let E=Symbol("HaltChainable");class H{constructor(){this.steps=[]}map(G){return this.steps.push(G),this}forEach(G){return this.steps.push(Y=>(G(Y),Y)),this}filter(G){return this.steps.push(Y=>G(Y)?Y:E),this}reduce(G,Y){let U=Y;return this.steps.push(A=>(U=G(U,A),U)),this}latch(G=(Y,U)=>Y===U){let Y=!0,U;return this.steps.push(A=>{let q=Y||!G(A,U);return Y=!1,U=A,q?A:E}),this}evaluate(G){for(let Y of this.steps)if(G=Y(G),G===E)break;return G}}function z(F,G,Y=U=>U){let U=(...be)=>$.fire(Y(...be)),A=()=>F.on(G,U),q=()=>F.removeListener(G,U),$=new ke({onWillAddFirstListener:A,onDidRemoveLastListener:q});return $.event}e.fromNodeEventEmitter=z;function R(F,G,Y=U=>U){let U=(...be)=>$.fire(Y(...be)),A=()=>F.addEventListener(G,U),q=()=>F.removeEventListener(G,U),$=new ke({onWillAddFirstListener:A,onDidRemoveLastListener:q});return $.event}e.fromDOMEventEmitter=R;function te(F){return new Promise(G=>i(F)(G))}e.toPromise=te;function L(F){let G=new ke;return F.then(Y=>{G.fire(Y)},()=>{G.fire(void 0)}).finally(()=>{G.dispose()}),G.event}e.fromPromise=L;function I(F,G){return F(Y=>G.fire(Y))}e.forward=I;function re(F,G,Y){return G(Y),F(U=>G(U))}e.runAndSubscribe=re;class _e{constructor(G,Y){this._observable=G,this._counter=0,this._hasChanged=!1;let U={onWillAddFirstListener:()=>{G.addObserver(this)},onDidRemoveLastListener:()=>{G.removeObserver(this)}};this.emitter=new ke(U),Y&&Y.add(this.emitter)}beginUpdate(G){this._counter++}handlePossibleChange(G){}handleChange(G,Y){this._hasChanged=!0}endUpdate(G){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function j(F,G){return new _e(F,G).emitter.event}e.fromObservable=j;function J(F){return(G,Y,U)=>{let A=0,q=!1,$={beginUpdate(){A++},endUpdate(){A--,A===0&&(F.reportChanges(),q&&(q=!1,G.call(Y)))},handlePossibleChange(){},handleChange(){q=!0}};F.addObserver($),F.reportChanges();let be={dispose(){F.removeObserver($)}};return U instanceof Ps?U.add(be):Array.isArray(U)&&U.push(be),be}}e.fromObservableLight=J})(an||(an={}));var Vf=class Xf{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Xf._idPool++}`,Xf.all.add(this)}start(t){this._stopWatch=new ek,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Vf.all=new Set,Vf._idPool=0;var tk=Vf,ik=-1,Ky=class Vy{constructor(t,i,s=(Vy._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let a=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,a+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[o,c]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${c}):`;console.warn(h),console.warn(o);let p=new sk(h,o);this._errorHandler(p)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,a]of this._stacks)(!t||i<a)&&(t=[s,a],i=a);return t}};Ky._idPool=1;var nk=Ky,rk=class Xy{constructor(t){this.value=t}static create(){let t=new Error;return new Xy(t.stack??"")}print(){console.warn(this.value.split(`
67
+ `).slice(2).join(`
68
+ `))}},sk=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},ak=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},lk=0,tf=class{constructor(e){this.value=e,this.id=lk++}},ok=2,ck,ke=class{constructor(t){var i,s,a,o;this._size=0,this._options=t,this._leakageMon=(i=this._options)!=null&&i.leakWarningThreshold?new nk((t==null?void 0:t.onListenerError)??pu,((s=this._options)==null?void 0:s.leakWarningThreshold)??ik):void 0,this._perfMon=(a=this._options)!=null&&a._profName?new tk(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,i,s,a;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(i=this._options)==null?void 0:i.onDidRemoveLastListener)==null||s.call(i),(a=this._leakageMon)==null||a.dispose())}get event(){return this._event??(this._event=(t,i,s)=>{var h,p,d,x,_;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let v=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],S=new ak(`${b}. HINT: Stack shows most frequent listener (${v[1]}-times)`,v[0]);return(((h=this._options)==null?void 0:h.onListenerError)||pu)(S),ht.None}if(this._disposed)return ht.None;i&&(t=t.bind(i));let a=new tf(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=rk.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof tf?(this._deliveryQueue??(this._deliveryQueue=new uk),this._listeners=[this._listeners,a]):this._listeners.push(a):((d=(p=this._options)==null?void 0:p.onWillAddFirstListener)==null||d.call(p,this),this._listeners=a,(_=(x=this._options)==null?void 0:x.onDidAddFirstListener)==null||_.call(x,this)),this._size++;let c=li(()=>{o==null||o(),this._removeListener(a)});return s instanceof Ps?s.add(c):Array.isArray(s)&&s.push(c),c}),this._event}_removeListener(t){var o,c,h,p;if((c=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||c.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(p=(h=this._options)==null?void 0:h.onDidRemoveLastListener)==null||p.call(h,this),this._size=0;return}let i=this._listeners,s=i.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let a=this._deliveryQueue.current===this;if(this._size*ok<=i.length){let d=0;for(let x=0;x<i.length;x++)i[x]?i[d++]=i[x]:a&&(this._deliveryQueue.end--,d<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=d}}_deliver(t,i){var a;if(!t)return;let s=((a=this._options)==null?void 0:a.onListenerError)||pu;if(!s){t.value(i);return}try{t.value(i)}catch(o){s(o)}}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[t.i++],t.value);t.reset()}fire(t){var i,s,a,o;if((i=this._deliveryQueue)!=null&&i.current&&(this._deliverQueue(this._deliveryQueue),(s=this._perfMon)==null||s.stop()),(a=this._perfMon)==null||a.start(this._size),this._listeners)if(this._listeners instanceof tf)this._deliver(this._listeners,t);else{let c=this._deliveryQueue;c.enqueue(this,t,this._listeners.length),this._deliverQueue(c)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},uk=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Zf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ke,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ke,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Zf.INSTANCE=new Zf;var Wp=Zf;function hk(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Wp.INSTANCE.onDidChangeZoomLevel;function dk(e){return Wp.INSTANCE.getZoomFactor(e)}Wp.INSTANCE.onDidChangeFullscreen;var pl=typeof navigator=="object"?navigator.userAgent:"",Qf=pl.indexOf("Firefox")>=0,fk=pl.indexOf("AppleWebKit")>=0,Gp=pl.indexOf("Chrome")>=0,pk=!Gp&&pl.indexOf("Safari")>=0;pl.indexOf("Electron/")>=0;pl.indexOf("Android")>=0;var nf=!1;if(typeof ns.matchMedia=="function"){let e=ns.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ns.matchMedia("(display-mode: fullscreen)");nf=e.matches,hk(ns,e,({matches:i})=>{nf&&t.matches||(nf=i)})}var ll="en",Jf=!1,ep=!1,mu=!1,Zy=!1,tu,gu=ll,_b=ll,mk,_r,ga=globalThis,sn,Ny;typeof ga.vscode<"u"&&typeof ga.vscode.process<"u"?sn=ga.vscode.process:typeof process<"u"&&typeof((Ny=process==null?void 0:process.versions)==null?void 0:Ny.node)=="string"&&(sn=process);var Ty,gk=typeof((Ty=sn==null?void 0:sn.versions)==null?void 0:Ty.electron)=="string",_k=gk&&(sn==null?void 0:sn.type)==="renderer",jy;if(typeof sn=="object"){Jf=sn.platform==="win32",ep=sn.platform==="darwin",mu=sn.platform==="linux",mu&&sn.env.SNAP&&sn.env.SNAP_REVISION,sn.env.CI||sn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,tu=ll,gu=ll;let e=sn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);tu=t.userLocale,_b=t.osLocale,gu=t.resolvedLanguage||ll,mk=(jy=t.languagePack)==null?void 0:jy.translationsConfigFile}catch{}Zy=!0}else typeof navigator=="object"&&!_k?(_r=navigator.userAgent,Jf=_r.indexOf("Windows")>=0,ep=_r.indexOf("Macintosh")>=0,(_r.indexOf("Macintosh")>=0||_r.indexOf("iPad")>=0||_r.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,mu=_r.indexOf("Linux")>=0,(_r==null?void 0:_r.indexOf("Mobi"))>=0,gu=globalThis._VSCODE_NLS_LANGUAGE||ll,tu=navigator.language.toLowerCase(),_b=tu):console.error("Unable to resolve platform.");var Qy=Jf,Dr=ep,xk=mu,xb=Zy,Mr=_r,Rs=gu,bk;(e=>{function t(){return Rs}e.value=t;function i(){return Rs.length===2?Rs==="en":Rs.length>=3?Rs[0]==="e"&&Rs[1]==="n"&&Rs[2]==="-":!1}e.isDefaultVariant=i;function s(){return Rs==="en"}e.isDefault=s})(bk||(bk={}));var vk=typeof ga.postMessage=="function"&&!ga.importScripts;(()=>{if(vk){let e=[];ga.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,a=e.length;s<a;s++){let o=e[s];if(o.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),o.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),ga.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var yk=!!(Mr&&Mr.indexOf("Chrome")>=0);Mr&&Mr.indexOf("Firefox")>=0;!yk&&Mr&&Mr.indexOf("Safari")>=0;Mr&&Mr.indexOf("Edg/")>=0;Mr&&Mr.indexOf("Android")>=0;var el=typeof navigator=="object"?navigator:{};xb||document.queryCommandSupported&&document.queryCommandSupported("copy")||el&&el.clipboard&&el.clipboard.writeText,xb||el&&el.clipboard&&el.clipboard.readText;var Yp=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},rf=new Yp,bb=new Yp,vb=new Yp,Sk=new Array(230),Jy;(e=>{function t(h){return rf.keyCodeToStr(h)}e.toString=t;function i(h){return rf.strToKeyCode(h)}e.fromString=i;function s(h){return bb.keyCodeToStr(h)}e.toUserSettingsUS=s;function a(h){return vb.keyCodeToStr(h)}e.toUserSettingsGeneral=a;function o(h){return bb.strToKeyCode(h)||vb.strToKeyCode(h)}e.fromUserSettings=o;function c(h){if(h>=98&&h<=113)return null;switch(h){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return rf.keyCodeToStr(h)}e.toElectronAccelerator=c})(Jy||(Jy={}));var wk=class e0{constructor(t,i,s,a,o){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=a,this.keyCode=o}equals(t){return t instanceof e0&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${i}${s}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Ck([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Ck=class{constructor(e){if(e.length===0)throw VC("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function kk(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Jy.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Qf)switch(t){case 59:return 85;case 60:if(xk)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Dr)return 57;break}else if(fk&&(Dr&&t===93||!Dr&&t===92))return 57;return Sk[t]||0}var Ek=Dr?256:2048,Nk=512,Tk=1024,jk=Dr?2048:256,yb=class{constructor(e){var i;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=kk(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=Ek),this.altKey&&(t|=Nk),this.shiftKey&&(t|=Tk),this.metaKey&&(t|=jk),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new wk(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Sb=new WeakMap;function Ak(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var Rk=class{static getSameOriginWindowChain(e){let t=Sb.get(e);if(!t){t=[],Sb.set(e,t);let i=e,s;do s=Ak(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,a=this.getSameOriginWindowChain(e);for(let o of a){let c=o.window.deref();if(i+=(c==null?void 0:c.scrollY)??0,s+=(c==null?void 0:c.scrollX)??0,c===t||!o.iframeElement)break;let h=o.iframeElement.getBoundingClientRect();i+=h.top,s+=h.left}return{top:i,left:s}}},iu=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=Rk.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},wb=class{constructor(e,t=0,i=0){var a;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Gp){let o=navigator.userAgent.match(/Chrome\/(\d+)/);s=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,h=((a=e.view)==null?void 0:a.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")s?this.deltaY=o.wheelDeltaY/(120*h):this.deltaY=o.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Qf&&!Dr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")pk&&Qy?this.deltaX=-(o.wheelDeltaX/120):s?this.deltaX=o.wheelDeltaX/(120*h):this.deltaX=o.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Qf&&!Dr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},t0=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Dk;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Mk?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:an.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:t0})})(Dk||(Dk={}));var Mk=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?t0:(this._emitter||(this._emitter=new ke),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Kp=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Gf("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Gf("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Bk=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new Gf("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=li(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Lk;(e=>{async function t(s){let a,o=await Promise.all(s.map(c=>c.then(h=>h,h=>{a||(a=h)})));if(typeof a<"u")throw a;return o}e.settled=t;function i(s){return new Promise(async(a,o)=>{try{await s(a,o)}catch(c){o(c)}})}e.withAsyncBody=i})(Lk||(Lk={}));var Cb=class or{static fromArray(t){return new or(i=>{i.emitMany(t)})}static fromPromise(t){return new or(async i=>{i.emitMany(await t)})}static fromPromises(t){return new or(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new or(async i=>{await Promise.all(t.map(async s=>{for await(let a of s)i.emitOne(a)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new ke,queueMicrotask(async()=>{let s={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(t(s)),this.resolve()}catch(a){this.reject(a)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await an.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new or(async s=>{for await(let a of t)s.emitOne(i(a))})}map(t){return or.map(this,t)}static filter(t,i){return new or(async s=>{for await(let a of t)i(a)&&s.emitOne(a)})}filter(t){return or.filter(this,t)}static coalesce(t){return or.filter(t,i=>!!i)}coalesce(){return or.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return or.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Cb.EMPTY=Cb.fromArray([]);var{getWindow:Ar,getWindowId:Ok,onDidRegisterWindow:zk}=(function(){let e=new Map,t={window:ns,disposables:new Ps};e.set(ns.vscodeWindowId,t);let i=new ke,s=new ke,a=new ke;function o(c,h){return(typeof c=="number"?e.get(c):void 0)??(h?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return ht.None;let h=new Ps,p={window:c,disposables:h.add(new Ps)};return e.set(c.vscodeWindowId,p),h.add(li(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),h.add(et(c,qi.BEFORE_UNLOAD,()=>{a.fire(c)})),i.fire(p),h},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:o,getWindow(c){var d;let h=c;if((d=h==null?void 0:h.ownerDocument)!=null&&d.defaultView)return h.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:ns},getDocument(c){return Ar(c).document}}})(),Pk=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function et(e,t,i,s){return new Pk(e,t,i,s)}var kb=function(e,t,i,s){return et(e,t,i,s)},Vp,Ik=class extends Bk{constructor(e){super(),this.defaultTarget=e&&Ar(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Eb=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){pu(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,a=o=>{i.set(o,!1);let c=e.get(o)??[];for(t.set(o,c),e.set(o,[]),s.set(o,!0);c.length>0;)c.sort(Eb.sort),c.shift().execute();s.set(o,!1)};Vp=(o,c,h=0)=>{let p=Ok(o),d=new Eb(c,h),x=e.get(p);return x||(x=[],e.set(p,x)),x.push(d),i.get(p)||(i.set(p,!0),o.requestAnimationFrame(()=>a(p))),d}})();function Hk(e){let t=e.getBoundingClientRect(),i=Ar(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var qi={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Uk=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=Mn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Mn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Mn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Mn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Mn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Mn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Mn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Mn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Mn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Mn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Mn(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Mn(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Mn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Mn(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Mn(e){return typeof e=="number"?`${e}px`:e}function jo(e){return new Uk(e)}var i0=class{constructor(){this._hooks=new Ps,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=a;let o=e;try{e.setPointerCapture(t),this._hooks.add(li(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=Ar(e)}this._hooks.add(et(o,qi.POINTER_MOVE,c=>{if(c.buttons!==i){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(et(o,qi.POINTER_UP,c=>this.stopMonitoring(!0)))}};function $k(e,t,i){let s=null,a=null;if(typeof i.value=="function"?(s="value",a=i.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",a=i.get),!a)throw new Error("not supported");let o=`$memoize$${t}`;i[s]=function(...c){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,c)}),this[o]}}var Tr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Tr||(Tr={}));var yo=class hn extends ht{constructor(){super(),this.dispatched=!1,this.targets=new gb,this.ignoreTargets=new gb,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(an.runAndSubscribe(zk,({window:t,disposables:i})=>{i.add(et(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(et(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(et(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:ns,disposables:this._store}))}static addTarget(t){if(!hn.isTouchDevice())return ht.None;hn.INSTANCE||(hn.INSTANCE=new hn);let i=hn.INSTANCE.targets.push(t);return li(i)}static ignoreTarget(t){if(!hn.isTouchDevice())return ht.None;hn.INSTANCE||(hn.INSTANCE=new hn);let i=hn.INSTANCE.ignoreTargets.push(t);return li(i)}static isTouchDevice(){return"ontouchstart"in ns||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,a=t.targetTouches.length;s<a;s++){let o=t.targetTouches.item(s);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:i,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[i],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let c=this.newGestureEvent(Tr.Start,o.target);c.pageX=o.pageX,c.pageY=o.pageY,this.dispatchEvent(c)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),a=Object.keys(this.activeTouches).length;for(let o=0,c=i.changedTouches.length;o<c;o++){let h=i.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(h.identifier))){console.warn("move of an UNKNOWN touch",h);continue}let p=this.activeTouches[h.identifier],d=Date.now()-p.initialTimeStamp;if(d<hn.HOLD_DELAY&&Math.abs(p.initialPageX-qn(p.rollingPageX))<30&&Math.abs(p.initialPageY-qn(p.rollingPageY))<30){let x=this.newGestureEvent(Tr.Tap,p.initialTarget);x.pageX=qn(p.rollingPageX),x.pageY=qn(p.rollingPageY),this.dispatchEvent(x)}else if(d>=hn.HOLD_DELAY&&Math.abs(p.initialPageX-qn(p.rollingPageX))<30&&Math.abs(p.initialPageY-qn(p.rollingPageY))<30){let x=this.newGestureEvent(Tr.Contextmenu,p.initialTarget);x.pageX=qn(p.rollingPageX),x.pageY=qn(p.rollingPageY),this.dispatchEvent(x)}else if(a===1){let x=qn(p.rollingPageX),_=qn(p.rollingPageY),b=qn(p.rollingTimestamps)-p.rollingTimestamps[0],v=x-p.rollingPageX[0],S=_-p.rollingPageY[0],N=[...this.targets].filter(M=>p.initialTarget instanceof Node&&M.contains(p.initialTarget));this.inertia(t,N,s,Math.abs(v)/b,v>0?1:-1,x,Math.abs(S)/b,S>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(Tr.End,p.initialTarget)),delete this.activeTouches[h.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===Tr.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>hn.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Tr.Change||t.type===Tr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let a=0,o=t.initialTarget;for(;o&&o!==s;)a++,o=o.parentElement;i.push([a,s])}i.sort((s,a)=>s[0]-a[0]);for(let[s,a]of i)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,a,o,c,h,p,d){this.handle=Vp(t,()=>{let x=Date.now(),_=x-s,b=0,v=0,S=!0;a+=hn.SCROLL_FRICTION*_,h+=hn.SCROLL_FRICTION*_,a>0&&(S=!1,b=o*a*_),h>0&&(S=!1,v=p*h*_);let N=this.newGestureEvent(Tr.Change);N.translationX=b,N.translationY=v,i.forEach(M=>M.dispatchEvent(N)),S||this.inertia(t,i,x,a,o,c+b,h,p,d+v)})}onTouchMove(t){let i=Date.now();for(let s=0,a=t.changedTouches.length;s<a;s++){let o=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let c=this.activeTouches[o.identifier],h=this.newGestureEvent(Tr.Change,c.initialTarget);h.translationX=o.pageX-qn(c.rollingPageX),h.translationY=o.pageY-qn(c.rollingPageY),h.pageX=o.pageX,h.pageY=o.pageY,this.dispatchEvent(h),c.rollingPageX.length>3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(o.pageX),c.rollingPageY.push(o.pageY),c.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};yo.SCROLL_FRICTION=-.005,yo.HOLD_DELAY=700,yo.CLEAR_TAP_COUNT_TIME=400,gi([$k],yo,"isTouchDevice",1);var Fk=yo,Xp=class extends ht{onclick(e,t){this._register(et(e,qi.CLICK,i=>t(new iu(Ar(e),i))))}onmousedown(e,t){this._register(et(e,qi.MOUSE_DOWN,i=>t(new iu(Ar(e),i))))}onmouseover(e,t){this._register(et(e,qi.MOUSE_OVER,i=>t(new iu(Ar(e),i))))}onmouseleave(e,t){this._register(et(e,qi.MOUSE_LEAVE,i=>t(new iu(Ar(e),i))))}onkeydown(e,t){this._register(et(e,qi.KEY_DOWN,i=>t(new yb(i))))}onkeyup(e,t){this._register(et(e,qi.KEY_UP,i=>t(new yb(i))))}oninput(e,t){this._register(et(e,qi.INPUT,t))}onblur(e,t){this._register(et(e,qi.BLUR,t))}onfocus(e,t){this._register(et(e,qi.FOCUS,t))}onchange(e,t){this._register(et(e,qi.CHANGE,t))}ignoreGesture(e){return Fk.ignoreTarget(e)}},Nb=11,qk=class extends Xp{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Nb+"px",this.domNode.style.height=Nb+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new i0),this._register(kb(this.bgDomNode,qi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(kb(this.domNode,qi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Ik),this._pointerdownScheduleRepeatTimer=this._register(new Kp)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Ar(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Wk=class tp{constructor(t,i,s,a,o,c,h){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,a=a|0,o=o|0,c=c|0,h=h|0),this.rawScrollLeft=a,this.rawScrollTop=h,i<0&&(i=0),a+i>s&&(a=s-i),a<0&&(a=0),o<0&&(o=0),h+o>c&&(h=c-o),h<0&&(h=0),this.width=i,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=c,this.scrollTop=h}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new tp(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new tp(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,h=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:a,scrollLeftChanged:o,heightChanged:c,scrollHeightChanged:h,scrollTopChanged:p}}},Gk=class extends ht{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Wk(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new jb(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=jb.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},Tb=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function sf(e,t){let i=t-e;return function(s){return e+i*Vk(s)}}function Yk(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var jb=class ip{constructor(t,i,s,a){this.from=t,this.to=i,this.duration=a,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let a,o;return t<i?(a=t+.75*s,o=i-.75*s):(a=t-.75*s,o=i+.75*s),Yk(sf(t,a),sf(o,i),.33)}return sf(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),a=this.scrollTop(i);return new Tb(s,a,!1)}return new Tb(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return ip.start(t,i,s)}static start(t,i,s){s=s+10;let a=Date.now()-10;return new ip(t,i,a,s)}};function Kk(e){return Math.pow(e,3)}function Vk(e){return 1-Kk(1-e)}var Xk=class extends ht{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Kp)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},Zk=140,n0=class extends Xp{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Xk(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new i0),this._shouldRender=!0,this.domNode=jo(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(et(this.domNode.domNode,qi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new qk(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=jo(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(et(this.slider.domNode,qi.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);i<=a&&a<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let a=Hk(this.domNode.domNode);t=e.pageX-a.left,i=e.pageY-a.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let o=this._sliderOrthogonalPointerPosition(a),c=Math.abs(o-i);if(Qy&&c>Zk){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let h=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(h))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},r0=class np{constructor(t,i,s,a,o,c){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new np(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,a,o){let c=Math.max(0,s-t),h=Math.max(0,c-2*i),p=a>0&&a>s;if(!p)return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:0,computedSliderPosition:0};let d=Math.round(Math.max(20,Math.floor(s*h/a))),x=(h-d)/(a-s),_=o*x;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(d),computedSliderRatio:x,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=np._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},Qk=class extends n0{constructor(e,t,i){let s=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new r0(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,a.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Jk=class extends n0{constructor(e,t,i){let s=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new r0(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,a.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},e2=500,Ab=50,t2=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},rp=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,s=1,a=this._rear;do{let o=a===this._front?t:Math.pow(2,-s);if(t-=o,i+=this._memory[a].score*o,a===this._front)break;a=(this._capacity+a-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Gp){let i=Ar(t.browserEvent),s=dk(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let a=null,o=new t2(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(a=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,a)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),c=Math.abs(i.deltaX),h=Math.abs(i.deltaY),p=Math.max(Math.min(a,c),1),d=Math.max(Math.min(o,h),1),x=Math.max(a,c),_=Math.max(o,h);x%p===0&&_%d===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};rp.INSTANCE=new rp;var i2=rp,n2=class extends Xp{constructor(e,t,i){super(),this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ke),this.onWillScroll=this._onWillScroll.event,this._options=s2(t),this._scrollable=i,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let s={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Jk(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Qk(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=jo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=jo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=jo(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new Kp),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=_a(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Dr&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new wb(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=_a(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new wb(i))};this._mouseWheelToDispose.push(et(this._listenOnDomNode,qi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=i2.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let h=!Dr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),d={};if(o){let x=Ab*o,_=p.scrollTop-(x<0?Math.floor(x):Math.ceil(x));this._verticalScrollbar.writeScrollPosition(d,_)}if(c){let x=Ab*c,_=p.scrollLeft-(x<0?Math.floor(x):Math.ceil(x));this._horizontalScrollbar.writeScrollPosition(d,_)}d=this._scrollable.validateScrollPosition(d),(p.scrollLeft!==d.scrollLeft||p.scrollTop!==d.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(d):this._scrollable.setScrollPositionNow(d),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",a=t?" top":"",o=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${a}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),e2)}},r2=class extends n2{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function s2(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,Dr&&(t.className+=" mac"),t}var sp=class extends ht{constructor(e,t,i,s,a,o,c,h){super(),this._bufferService=i,this._optionsService=c,this._renderService=h,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new Gk({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:d=>Vp(s.window,d)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new r2(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(d=>{this._scrollableElement.updateOptions({handleMouseWheel:!(d&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(an.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(li(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(li(()=>this._styleElement.remove())),this._register(an.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
69
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(d=>this._handleScroll(d)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};sp=gi([Re(2,Sn),Re(3,rs),Re(4,Py),Re(5,fl),Re(6,wn),Re(7,ss)],sp);var ap=class extends ht{constructor(e,t,i,s,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(li(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};ap=gi([Re(1,Sn),Re(2,rs),Re(3,$o),Re(4,ss)],ap);var a2=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Er={full:0,left:0,center:0,right:0},Ds={full:0,left:0,center:0,right:0},co={full:0,left:0,center:0,right:0},ku=class extends ht{constructor(e,t,i,s,a,o,c,h){var d;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=c,this._coreBrowserService=h,this._colorZoneStore=new a2,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(d=this._viewportElement.parentElement)==null||d.insertBefore(this._canvas,this._viewportElement),this._register(li(()=>{var x;return(x=this._canvas)==null?void 0:x.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Ds.full=this._canvas.width,Ds.left=e,Ds.center=t,Ds.right=e,this._refreshDrawHeightConstants(),co.full=1,co.left=1,co.center=1+Ds.left,co.right=1+Ds.left+Ds.center}_refreshDrawHeightConstants(){Er.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Er.left=t,Er.center=t,Er.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Er.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Er.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Er.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Er.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(co[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Er[e.position||"full"]/2),Ds[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Er[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};ku=gi([Re(2,Sn),Re(3,$o),Re(4,ss),Re(5,wn),Re(6,fl),Re(7,rs)],ku);var ge;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
70
+ `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(ge||(ge={}));var _u;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(_u||(_u={}));var s0;(e=>e.ST=`${ge.ESC}\\`)(s0||(s0={}));var lp=class{constructor(e,t,i,s,a,o){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=a,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${ge.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,a=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=a+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=a+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};lp=gi([Re(2,Sn),Re(3,wn),Re(4,va),Re(5,ss)],lp);var Wi=0,Gi=0,Yi=0,pi=0,Rb={css:"#00000000",rgba:0},Bi;(e=>{function t(a,o,c,h){return h!==void 0?`#${oa(a)}${oa(o)}${oa(c)}${oa(h)}`:`#${oa(a)}${oa(o)}${oa(c)}`}e.toCss=t;function i(a,o,c,h=255){return(a<<24|o<<16|c<<8|h)>>>0}e.toRgba=i;function s(a,o,c,h){return{css:e.toCss(a,o,c,h),rgba:e.toRgba(a,o,c,h)}}e.toColor=s})(Bi||(Bi={}));var ri;(e=>{function t(p,d){if(pi=(d.rgba&255)/255,pi===1)return{css:d.css,rgba:d.rgba};let x=d.rgba>>24&255,_=d.rgba>>16&255,b=d.rgba>>8&255,v=p.rgba>>24&255,S=p.rgba>>16&255,N=p.rgba>>8&255;Wi=v+Math.round((x-v)*pi),Gi=S+Math.round((_-S)*pi),Yi=N+Math.round((b-N)*pi);let M=Bi.toCss(Wi,Gi,Yi),E=Bi.toRgba(Wi,Gi,Yi);return{css:M,rgba:E}}e.blend=t;function i(p){return(p.rgba&255)===255}e.isOpaque=i;function s(p,d,x){let _=xu.ensureContrastRatio(p.rgba,d.rgba,x);if(_)return Bi.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let d=(p.rgba|255)>>>0;return[Wi,Gi,Yi]=xu.toChannels(d),{css:Bi.toCss(Wi,Gi,Yi),rgba:d}}e.opaque=a;function o(p,d){return pi=Math.round(d*255),[Wi,Gi,Yi]=xu.toChannels(p.rgba),{css:Bi.toCss(Wi,Gi,Yi,pi),rgba:Bi.toRgba(Wi,Gi,Yi,pi)}}e.opacity=o;function c(p,d){return pi=p.rgba&255,o(p,pi*d/255)}e.multiplyOpacity=c;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(ri||(ri={}));var ci;(e=>{let t,i;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Wi=parseInt(a.slice(1,2).repeat(2),16),Gi=parseInt(a.slice(2,3).repeat(2),16),Yi=parseInt(a.slice(3,4).repeat(2),16),Bi.toColor(Wi,Gi,Yi);case 5:return Wi=parseInt(a.slice(1,2).repeat(2),16),Gi=parseInt(a.slice(2,3).repeat(2),16),Yi=parseInt(a.slice(3,4).repeat(2),16),pi=parseInt(a.slice(4,5).repeat(2),16),Bi.toColor(Wi,Gi,Yi,pi);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Wi=parseInt(o[1]),Gi=parseInt(o[2]),Yi=parseInt(o[3]),pi=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Bi.toColor(Wi,Gi,Yi,pi);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Wi,Gi,Yi,pi]=t.getImageData(0,0,1,1).data,pi!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Bi.toRgba(Wi,Gi,Yi,pi),css:a}}e.toColor=s})(ci||(ci={}));var xn;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,a,o){let c=s/255,h=a/255,p=o/255,d=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),x=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return d*.2126+x*.7152+_*.0722}e.relativeLuminance2=i})(xn||(xn={}));var xu;(e=>{function t(c,h){if(pi=(h&255)/255,pi===1)return h;let p=h>>24&255,d=h>>16&255,x=h>>8&255,_=c>>24&255,b=c>>16&255,v=c>>8&255;return Wi=_+Math.round((p-_)*pi),Gi=b+Math.round((d-b)*pi),Yi=v+Math.round((x-v)*pi),Bi.toRgba(Wi,Gi,Yi)}e.blend=t;function i(c,h,p){let d=xn.relativeLuminance(c>>8),x=xn.relativeLuminance(h>>8);if(Jr(d,x)<p){if(x<d){let v=s(c,h,p),S=Jr(d,xn.relativeLuminance(v>>8));if(S<p){let N=a(c,h,p),M=Jr(d,xn.relativeLuminance(N>>8));return S>M?v:N}return v}let _=a(c,h,p),b=Jr(d,xn.relativeLuminance(_>>8));if(b<p){let v=s(c,h,p),S=Jr(d,xn.relativeLuminance(v>>8));return b>S?_:v}return _}}e.ensureContrastRatio=i;function s(c,h,p){let d=c>>24&255,x=c>>16&255,_=c>>8&255,b=h>>24&255,v=h>>16&255,S=h>>8&255,N=Jr(xn.relativeLuminance2(b,v,S),xn.relativeLuminance2(d,x,_));for(;N<p&&(b>0||v>0||S>0);)b-=Math.max(0,Math.ceil(b*.1)),v-=Math.max(0,Math.ceil(v*.1)),S-=Math.max(0,Math.ceil(S*.1)),N=Jr(xn.relativeLuminance2(b,v,S),xn.relativeLuminance2(d,x,_));return(b<<24|v<<16|S<<8|255)>>>0}e.reduceLuminance=s;function a(c,h,p){let d=c>>24&255,x=c>>16&255,_=c>>8&255,b=h>>24&255,v=h>>16&255,S=h>>8&255,N=Jr(xn.relativeLuminance2(b,v,S),xn.relativeLuminance2(d,x,_));for(;N<p&&(b<255||v<255||S<255);)b=Math.min(255,b+Math.ceil((255-b)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),N=Jr(xn.relativeLuminance2(b,v,S),xn.relativeLuminance2(d,x,_));return(b<<24|v<<16|S<<8|255)>>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(xu||(xu={}));function oa(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Jr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var l2=class extends Uo{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Eu=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new hr}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],s=t.translateToString(!0),a=0,o=0,c=0,h=t.getFg(0),p=t.getBg(0);for(let d=0;d<t.getTrimmedLength();d++)if(t.loadCell(d,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==h||this._workCell.bg!==p){if(d-a>1){let x=this._getJoinedRanges(s,c,o,t,a);for(let _=0;_<x.length;_++)i.push(x[_])}a=d,c=o,h=this._workCell.fg,p=this._workCell.bg}o+=this._workCell.getChars().length||zs.length}if(this._bufferService.cols-a>1){let d=this._getJoinedRanges(s,c,o,t,a);for(let x=0;x<d.length;x++)i.push(d[x])}return i}_getJoinedRanges(e,t,i,s,a){let o=e.substring(t,i),c=[];try{c=this._characterJoiners[0].handler(o)}catch(h){console.error(h)}for(let h=1;h<this._characterJoiners.length;h++)try{let p=this._characterJoiners[h].handler(o);for(let d=0;d<p.length;d++)Eu._mergeRanges(c,p[d])}catch(p){console.error(p)}return this._stringRangesToCellRanges(c,s,a),c}_stringRangesToCellRanges(e,t,i){let s=0,a=!1,o=0,c=e[s];if(c){for(let h=i;h<this._bufferService.cols;h++){let p=t.getWidth(h),d=t.getString(h).length||zs.length;if(p!==0){if(!a&&c[0]<=o&&(c[0]=h,a=!0),c[1]<=o){if(c[1]=h,c=e[++s],!c)break;c[0]<=o?(c[0]=h,a=!0):a=!1}o+=d}}c&&(c[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let a=e[s];if(i){if(t[1]<=a[0])return e[s-1][1]=t[1],e;if(t[1]<=a[1])return e[s-1][1]=Math.max(t[1],a[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=a[0])return e.splice(s,0,t),e;if(t[1]<=a[1])return a[0]=Math.min(t[0],a[0]),e;t[0]<a[1]&&(a[0]=Math.min(t[0],a[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};Eu=gi([Re(0,Sn)],Eu);function o2(e){return 57508<=e&&e<=57558}function c2(e){return 9472<=e&&e<=9631}function u2(e){return o2(e)||c2(e)}function h2(){return{css:{canvas:nu(),cell:nu()},device:{canvas:nu(),cell:nu(),char:{width:0,height:0,left:0,top:0}}}}function nu(){return{width:0,height:0}}var op=class{constructor(e,t,i,s,a,o,c){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=a,this._decorationService=o,this._themeService=c,this._workCell=new hr,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,a,o,c,h,p,d,x){let _=[],b=this._characterJoinerService.getJoinedCharacters(t),v=this._themeService.colors,S=e.getNoBgTrimmedLength();i&&S<o+1&&(S=o+1);let N,M=0,E="",H=0,z=0,R=0,te=0,L=!1,I=0,re=!1,_e=0,j=0,J=[],F=d!==-1&&x!==-1;for(let G=0;G<S;G++){e.loadCell(G,this._workCell);let Y=this._workCell.getWidth();if(Y===0)continue;let U=!1,A=G>=j,q=G,$=this._workCell;if(b.length>0&&G===b[0][0]&&A){let Oe=b.shift(),Ke=this._isCellInSelection(Oe[0],t);for(H=Oe[0]+1;H<Oe[1];H++)A&&(A=Ke===this._isCellInSelection(H,t));A&&(A=!i||o<Oe[0]||o>=Oe[1]),A?(U=!0,$=new l2(this._workCell,e.translateToString(!0,Oe[0],Oe[1]),Oe[1]-Oe[0]),q=Oe[1]-1,Y=$.getWidth()):j=Oe[1]}let be=this._isCellInSelection(G,t),T=i&&G===o,D=F&&G>=d&&G<=x,V=!1;this._decorationService.forEachDecorationAtCell(G,t,void 0,Oe=>{V=!0});let k=$.getChars()||zs;if(k===" "&&($.isUnderline()||$.isOverline())&&(k=" "),_e=Y*h-p.get(k,$.isBold(),$.isItalic()),!N)N=this._document.createElement("span");else if(M&&(be&&re||!be&&!re&&$.bg===z)&&(be&&re&&v.selectionForeground||$.fg===R)&&$.extended.ext===te&&D===L&&_e===I&&!T&&!U&&!V&&A){$.isInvisible()?E+=zs:E+=k,M++;continue}else M&&(N.textContent=E),N=this._document.createElement("span"),M=0,E="";if(z=$.bg,R=$.fg,te=$.extended.ext,L=D,I=_e,re=be,U&&o>=G&&o<=q&&(o=G),!this._coreService.isCursorHidden&&T&&this._coreService.isCursorInitialized){if(J.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&J.push("xterm-cursor-blink"),J.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":J.push("xterm-cursor-outline");break;case"block":J.push("xterm-cursor-block");break;case"bar":J.push("xterm-cursor-bar");break;case"underline":J.push("xterm-cursor-underline");break}}if($.isBold()&&J.push("xterm-bold"),$.isItalic()&&J.push("xterm-italic"),$.isDim()&&J.push("xterm-dim"),$.isInvisible()?E=zs:E=$.getChars()||zs,$.isUnderline()&&(J.push(`xterm-underline-${$.extended.underlineStyle}`),E===" "&&(E=" "),!$.isUnderlineColorDefault()))if($.isUnderlineColorRGB())N.style.textDecorationColor=`rgb(${Uo.toColorRGB($.getUnderlineColor()).join(",")})`;else{let Oe=$.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&$.isBold()&&Oe<8&&(Oe+=8),N.style.textDecorationColor=v.ansi[Oe].css}$.isOverline()&&(J.push("xterm-overline"),E===" "&&(E=" ")),$.isStrikethrough()&&J.push("xterm-strikethrough"),D&&(N.style.textDecoration="underline");let le=$.getFgColor(),ne=$.getFgColorMode(),de=$.getBgColor(),X=$.getBgColorMode(),ue=!!$.isInverse();if(ue){let Oe=le;le=de,de=Oe;let Ke=ne;ne=X,X=Ke}let ye,fe,Pe=!1;this._decorationService.forEachDecorationAtCell(G,t,void 0,Oe=>{Oe.options.layer!=="top"&&Pe||(Oe.backgroundColorRGB&&(X=50331648,de=Oe.backgroundColorRGB.rgba>>8&16777215,ye=Oe.backgroundColorRGB),Oe.foregroundColorRGB&&(ne=50331648,le=Oe.foregroundColorRGB.rgba>>8&16777215,fe=Oe.foregroundColorRGB),Pe=Oe.options.layer==="top")}),!Pe&&be&&(ye=this._coreBrowserService.isFocused?v.selectionBackgroundOpaque:v.selectionInactiveBackgroundOpaque,de=ye.rgba>>8&16777215,X=50331648,Pe=!0,v.selectionForeground&&(ne=50331648,le=v.selectionForeground.rgba>>8&16777215,fe=v.selectionForeground)),Pe&&J.push("xterm-decoration-top");let $e;switch(X){case 16777216:case 33554432:$e=v.ansi[de],J.push(`xterm-bg-${de}`);break;case 50331648:$e=Bi.toColor(de>>16,de>>8&255,de&255),this._addStyle(N,`background-color:#${Db((de>>>0).toString(16),"0",6)}`);break;case 0:default:ue?($e=v.foreground,J.push("xterm-bg-257")):$e=v.background}switch(ye||$.isDim()&&(ye=ri.multiplyOpacity($e,.5)),ne){case 16777216:case 33554432:$.isBold()&&le<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(le+=8),this._applyMinimumContrast(N,$e,v.ansi[le],$,ye,void 0)||J.push(`xterm-fg-${le}`);break;case 50331648:let Oe=Bi.toColor(le>>16&255,le>>8&255,le&255);this._applyMinimumContrast(N,$e,Oe,$,ye,fe)||this._addStyle(N,`color:#${Db(le.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(N,$e,v.foreground,$,ye,fe)||ue&&J.push("xterm-fg-257")}J.length&&(N.className=J.join(" "),J.length=0),!T&&!U&&!V&&A?M++:N.textContent=E,_e!==this.defaultSpacing&&(N.style.letterSpacing=`${_e}px`),_.push(N),G=q}return N&&M&&(N.textContent=E),_}_applyMinimumContrast(e,t,i,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||u2(s.getCode()))return!1;let c=this._getContrastCache(s),h;if(!a&&!o&&(h=c.getColor(t.rgba,i.rgba)),h===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=ri.ensureContrastRatio(a||t,o||i,p),c.setColor((a||t).rgba,(o||i).rgba,h??null)}return h?(this._addStyle(e,`color:${h.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};op=gi([Re(1,Uy),Re(2,wn),Re(3,rs),Re(4,va),Re(5,$o),Re(6,fl)],op);function Db(e,t,i){for(;e.length<i;)e=t+e;return e}var d2=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[i,s,a,o],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(a),this._container.appendChild(o),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let c=this._measure(e,0);return c>0&&(this._flat[s]=c),c}let a=e;t&&(a+="B"),i&&(a+="I");let o=this._holey.get(a);if(o===void 0){let c=0;t&&(c|=1),i&&(c|=2),o=this._measure(e,c),o>0&&this._holey.set(a,o)}return o}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},f2=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let a=e.buffers.active.ydisp,o=t[1]-a,c=i[1]-a,h=Math.max(o,0),p=Math.min(c,e.rows-1);if(h>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=c,this.viewportCappedStartRow=h,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function p2(){return new f2}var af="xterm-dom-renderer-owner-",lr="xterm-rows",ru="xterm-fg-",Mb="xterm-bg-",uo="xterm-focus",su="xterm-selection",m2=1,cp=class extends ht{constructor(e,t,i,s,a,o,c,h,p,d,x,_,b,v){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=c,this._charSizeService=p,this._optionsService=d,this._bufferService=x,this._coreService=_,this._coreBrowserService=b,this._themeService=v,this._terminalClass=m2++,this._rowElements=[],this._selectionRenderModel=p2(),this.onRequestRedraw=this._register(new ke).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(lr),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(su),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=h2(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(S=>this._injectCss(S))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(op,document),this._element.classList.add(af+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(S=>this._handleLinkHover(S))),this._register(this._linkifier2.onHideLinkUnderline(S=>this._handleLinkLeave(S))),this._register(li(()=>{this._element.classList.remove(af+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new d2(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${lr} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${lr} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${lr} .xterm-dim { color: ${ri.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${lr}.${uo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${lr}.${uo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${lr}.${uo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${lr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${lr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${lr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${lr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${lr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${su} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${su} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${su} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,c]of e.ansi.entries())t+=`${this._terminalSelector} .${ru}${o} { color: ${c.css}; }${this._terminalSelector} .${ru}${o}.xterm-dim { color: ${ri.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Mb}${o} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${ru}257 { color: ${ri.opaque(e.background).css}; }${this._terminalSelector} .${ru}257.xterm-dim { color: ${ri.multiplyOpacity(ri.opaque(e.background),.5).css}; }${this._terminalSelector} .${Mb}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(uo),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(uo),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(i){let p=e[0]>t[0];h.appendChild(this._createSelectionElement(o,p?t[0]:e[0],p?e[0]:t[0],c-o+1))}else{let p=s===o?e[0]:0,d=o===a?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(o,p,d));let x=c-o-1;if(h.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,x)),o!==c){let _=a===c?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(c,0,_))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,t,i,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(i-t);return o+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-o),a.style.height=`${s*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${o}px`,a.style.width=`${c}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,a=Math.min(i.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let d=p+i.ydisp,x=this._rowElements[p],_=i.lines.get(d);if(!x||!_)break;x.replaceChildren(...this._rowFactory.createRow(_,d,d===s,c,h,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${af}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,a,o){i<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;i=Math.max(Math.min(i,c),0),s=Math.max(Math.min(s,c),0),a=Math.min(a,this._bufferService.cols);let h=this._bufferService.buffer,p=h.ybase+h.y,d=Math.min(h.x,a-1),x=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let v=i;v<=s;++v){let S=v+h.ydisp,N=this._rowElements[v],M=h.lines.get(S);if(!N||!M)break;N.replaceChildren(...this._rowFactory.createRow(M,S,S===p,_,b,d,x,this.dimensions.css.cell.width,this._widthCache,o?v===i?e:0:-1,o?(v===s?t:a)-1:-1))}}};cp=gi([Re(7,Fp),Re(8,Pu),Re(9,wn),Re(10,Sn),Re(11,va),Re(12,rs),Re(13,fl)],cp);var up=class extends ht{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ke),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new _2(this._optionsService))}catch{this._measureStrategy=this._register(new g2(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};up=gi([Re(2,wn)],up);var a0=class extends ht{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},g2=class extends a0{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},_2=class extends a0{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},x2=class extends ht{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new b2(this._window)),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ke),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(an.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(et(this._textarea,"focus",()=>this._isFocused=!0)),this._register(et(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},b2=class extends ht{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new hl),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(li(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=et(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},v2=class extends ht{constructor(){super(),this.linkProviders=[],this._register(li(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Zp(e,t,i){let s=i.getBoundingClientRect(),a=e.getComputedStyle(i),o=parseInt(a.getPropertyValue("padding-left")),c=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-c]}function y2(e,t,i,s,a,o,c,h,p){if(!o)return;let d=Zp(e,t,i);if(d)return d[0]=Math.ceil((d[0]+(p?c/2:0))/c),d[1]=Math.ceil(d[1]/h),d[0]=Math.min(Math.max(d[0],1),s+(p?1:0)),d[1]=Math.min(Math.max(d[1],1),a),d}var hp=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,a){return y2(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let i=Zp(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};hp=gi([Re(0,ss),Re(1,Pu)],hp);var S2=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},l0={};DC(l0,{getSafariVersion:()=>C2,isChromeOS:()=>h0,isFirefox:()=>o0,isIpad:()=>k2,isIphone:()=>E2,isLegacyEdge:()=>w2,isLinux:()=>Qp,isMac:()=>Nu,isNode:()=>Iu,isSafari:()=>c0,isWindows:()=>u0});var Iu=typeof process<"u"&&"title"in process,Fo=Iu?"node":navigator.userAgent,qo=Iu?"node":navigator.platform,o0=Fo.includes("Firefox"),w2=Fo.includes("Edge"),c0=/^((?!chrome|android).)*safari/i.test(Fo);function C2(){if(!c0)return 0;let e=Fo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Nu=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(qo),k2=qo==="iPad",E2=qo==="iPhone",u0=["Windows","Win16","Win32","WinCE"].includes(qo),Qp=qo.indexOf("Linux")>=0,h0=/\bCrOS\b/.test(Fo),d0=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),a=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),a=e.timeRemaining(),i*1.5>a){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=a}this.clear()}},N2=class extends d0{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},T2=class extends d0{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Tu=!Iu&&"requestIdleCallback"in window?T2:N2,j2=class{constructor(){this._queue=new Tu}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},dp=class extends ht{constructor(e,t,i,s,a,o,c,h,p){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=a,this._coreBrowserService=h,this._renderer=this._register(new hl),this._pausedResizeTask=new j2,this._observerDisposable=this._register(new hl),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new ke),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ke),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ke),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new S2((d,x)=>this._renderRows(d,x),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new A2(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(li(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var d;return(d=this._renderer.value)==null?void 0:d.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(d=>this._registerIntersectionObserver(d,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=li(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};dp=gi([Re(2,wn),Re(3,Pu),Re(4,va),Re(5,$o),Re(6,Sn),Re(7,rs),Re(8,fl)],dp);var A2=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function R2(e,t,i,s){let a=i.buffer.x,o=i.buffer.y;if(!i.buffer.hasScrollback)return B2(a,o,e,t,i,s)+Hu(o,t,i,s)+L2(a,o,e,t,i,s);let c;if(o===t)return c=a>e?"D":"C",Lo(Math.abs(a-e),Bo(c,s));c=o>t?"D":"C";let h=Math.abs(o-t),p=M2(o>t?e:a,i)+(h-1)*i.cols+1+D2(o>t?a:e);return Lo(p,Bo(c,s))}function D2(e,t){return e-1}function M2(e,t){return t.cols-e}function B2(e,t,i,s,a,o){return Hu(t,s,a,o).length===0?"":Lo(p0(e,t,e,t-xa(t,a),!1,a).length,Bo("D",o))}function Hu(e,t,i,s){let a=e-xa(e,i),o=t-xa(t,i),c=Math.abs(a-o)-O2(e,t,i);return Lo(c,Bo(f0(e,t),s))}function L2(e,t,i,s,a,o){let c;Hu(t,s,a,o).length>0?c=s-xa(s,a):c=t;let h=s,p=z2(e,t,i,s,a,o);return Lo(p0(e,c,i,h,p==="C",a).length,Bo(p,o))}function O2(e,t,i){var c;let s=0,a=e-xa(e,i),o=t-xa(t,i);for(let h=0;h<Math.abs(a-o);h++){let p=f0(e,t)==="A"?-1:1;(c=i.buffer.lines.get(a+p*h))!=null&&c.isWrapped&&s++}return s}function xa(e,t){let i=0,s=t.buffer.lines.get(e),a=s==null?void 0:s.isWrapped;for(;a&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),a=s==null?void 0:s.isWrapped;return i}function z2(e,t,i,s,a,o){let c;return Hu(i,s,a,o).length>0?c=s-xa(s,a):c=t,e<i&&c<=s||e>=i&&c<s?"C":"D"}function f0(e,t){return e>t?"A":"B"}function p0(e,t,i,s,a,o){let c=e,h=t,p="";for(;(c!==i||h!==s)&&h>=0&&h<o.buffer.lines.length;)c+=a?1:-1,a&&c>o.cols-1?(p+=o.buffer.translateBufferLineToString(h,!1,e,c),c=0,e=0,h++):!a&&c<0&&(p+=o.buffer.translateBufferLineToString(h,!1,0,e+1),c=o.cols-1,e=c,h--);return p+o.buffer.translateBufferLineToString(h,!1,e,c)}function Bo(e,t){let i=t?"O":"[";return ge.ESC+i+e}function Lo(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var P2=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Bb(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var lf=50,I2=15,H2=50,U2=500,$2=" ",F2=new RegExp($2,"g"),fp=class extends ht{constructor(e,t,i,s,a,o,c,h,p){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=c,this._renderService=h,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new hr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ke),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ke),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=d=>this._handleMouseMove(d),this._mouseUpListener=d=>this._handleMouseUp(d),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(d=>this._handleTrim(d)),this._register(this._bufferService.buffers.onBufferActivate(d=>this._handleBufferActivate(d))),this.enable(),this._model=new P2(this._bufferService),this._activeSelectionMode=0,this._register(li(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(d=>{d.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let c=e[1];c<=t[1];c++){let h=i.translateBufferLineToString(c,!0,a,o);s.push(h)}}else{let a=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],a));for(let o=e[1]+1;o<=t[1]-1;o++){let c=i.lines.get(o),h=i.translateBufferLineToString(o,!0);c!=null&&c.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==t[1]){let o=i.lines.get(t[1]),c=i.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?s[s.length-1]+=c:s.push(c)}}return s.map(a=>a.replace(F2," ")).join(u0?`\r
71
+ `:`
72
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Qp&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var a,o;let i=(o=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:o.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=Bb(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Zp(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-lf),lf),t/=lf,t/Math.abs(t)+Math.round(t*(I2-1)))}shouldForceSelection(e){return Nu?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),H2)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Nu&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<U2&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=R2(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:a>1&&t!==s&&(i+=a-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,o=a.lines.get(e[1]);if(!o)return;let c=a.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(o,e[0]),p=h,d=e[0]-h,x=0,_=0,b=0,v=0;if(c.charAt(h)===" "){for(;h>0&&c.charAt(h-1)===" ";)h--;for(;p<c.length&&c.charAt(p+1)===" ";)p++}else{let M=e[0],E=e[0];o.getWidth(M)===0&&(x++,M--),o.getWidth(E)===2&&(_++,E++);let H=o.getString(E).length;for(H>1&&(v+=H-1,p+=H-1);M>0&&h>0&&!this._isCharWordSeparator(o.loadCell(M-1,this._workCell));){o.loadCell(M-1,this._workCell);let z=this._workCell.getChars().length;this._workCell.getWidth()===0?(x++,M--):z>1&&(b+=z-1,h-=z-1),h--,M--}for(;E<o.length&&p+1<c.length&&!this._isCharWordSeparator(o.loadCell(E+1,this._workCell));){o.loadCell(E+1,this._workCell);let z=this._workCell.getChars().length;this._workCell.getWidth()===2?(_++,E++):z>1&&(v+=z-1,p+=z-1),p++,E++}}p++;let S=h+d-x+b,N=Math.min(this._bufferService.cols,p-h+x+_-b-v);if(!(!t&&c.slice(h,p).trim()==="")){if(i&&S===0&&o.getCodePoint(0)!==32){let M=a.lines.get(e[1]-1);if(M&&o.isWrapped&&M.getCodePoint(this._bufferService.cols-1)!==32){let E=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(E){let H=this._bufferService.cols-E.start;S-=H,N+=H}}}if(s&&S+N===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let M=a.lines.get(e[1]+1);if(M!=null&&M.isWrapped&&M.getCodePoint(0)!==32){let E=this._getWordAt([0,e[1]+1],!1,!1,!0);E&&(N+=E.length)}}return{start:S,length:N}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Bb(i,this._bufferService.cols)}};fp=gi([Re(3,Sn),Re(4,va),Re(5,qp),Re(6,wn),Re(7,ss),Re(8,rs)],fp);var Lb=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Ob=class{constructor(){this._color=new Lb,this._css=new Lb}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},zi=Object.freeze((()=>{let e=[ci.toColor("#2e3436"),ci.toColor("#cc0000"),ci.toColor("#4e9a06"),ci.toColor("#c4a000"),ci.toColor("#3465a4"),ci.toColor("#75507b"),ci.toColor("#06989a"),ci.toColor("#d3d7cf"),ci.toColor("#555753"),ci.toColor("#ef2929"),ci.toColor("#8ae234"),ci.toColor("#fce94f"),ci.toColor("#729fcf"),ci.toColor("#ad7fa8"),ci.toColor("#34e2e2"),ci.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],a=t[i/6%6|0],o=t[i%6];e.push({css:Bi.toCss(s,a,o),rgba:Bi.toRgba(s,a,o)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Bi.toCss(s,s,s),rgba:Bi.toRgba(s,s,s)})}return e})()),da=ci.toColor("#ffffff"),So=ci.toColor("#000000"),zb=ci.toColor("#ffffff"),Pb=So,ho={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},q2=da,pp=class extends ht{constructor(e){super(),this._optionsService=e,this._contrastCache=new Ob,this._halfContrastCache=new Ob,this._onChangeColors=this._register(new ke),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:da,background:So,cursor:zb,cursorAccent:Pb,selectionForeground:void 0,selectionBackgroundTransparent:ho,selectionBackgroundOpaque:ri.blend(So,ho),selectionInactiveBackgroundTransparent:ho,selectionInactiveBackgroundOpaque:ri.blend(So,ho),scrollbarSliderBackground:ri.opacity(da,.2),scrollbarSliderHoverBackground:ri.opacity(da,.4),scrollbarSliderActiveBackground:ri.opacity(da,.5),overviewRulerBorder:da,ansi:zi.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Wt(e.foreground,da),t.background=Wt(e.background,So),t.cursor=ri.blend(t.background,Wt(e.cursor,zb)),t.cursorAccent=ri.blend(t.background,Wt(e.cursorAccent,Pb)),t.selectionBackgroundTransparent=Wt(e.selectionBackground,ho),t.selectionBackgroundOpaque=ri.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Wt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ri.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Wt(e.selectionForeground,Rb):void 0,t.selectionForeground===Rb&&(t.selectionForeground=void 0),ri.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ri.opacity(t.selectionBackgroundTransparent,.3)),ri.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ri.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Wt(e.scrollbarSliderBackground,ri.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Wt(e.scrollbarSliderHoverBackground,ri.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Wt(e.scrollbarSliderActiveBackground,ri.opacity(t.foreground,.5)),t.overviewRulerBorder=Wt(e.overviewRulerBorder,q2),t.ansi=zi.slice(),t.ansi[0]=Wt(e.black,zi[0]),t.ansi[1]=Wt(e.red,zi[1]),t.ansi[2]=Wt(e.green,zi[2]),t.ansi[3]=Wt(e.yellow,zi[3]),t.ansi[4]=Wt(e.blue,zi[4]),t.ansi[5]=Wt(e.magenta,zi[5]),t.ansi[6]=Wt(e.cyan,zi[6]),t.ansi[7]=Wt(e.white,zi[7]),t.ansi[8]=Wt(e.brightBlack,zi[8]),t.ansi[9]=Wt(e.brightRed,zi[9]),t.ansi[10]=Wt(e.brightGreen,zi[10]),t.ansi[11]=Wt(e.brightYellow,zi[11]),t.ansi[12]=Wt(e.brightBlue,zi[12]),t.ansi[13]=Wt(e.brightMagenta,zi[13]),t.ansi[14]=Wt(e.brightCyan,zi[14]),t.ansi[15]=Wt(e.brightWhite,zi[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=Wt(e.extendedAnsi[s],zi[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};pp=gi([Re(0,wn)],pp);function Wt(e,t){if(e!==void 0)try{return ci.toColor(e)}catch{}return t}var W2=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},G2=class{constructor(){this._services=new W2,this._services.set(Fp,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=IC(e).sort((o,c)=>o.index-c.index),s=[];for(let o of i){let c=this._services.get(o.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(c)}let a=i.length>0?i[0].index:t.length;if(t.length!==a)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},Y2={trace:0,debug:1,info:2,warn:3,error:4,off:5},K2="xterm.js: ",mp=class extends ht{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Y2[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":K2)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};mp=gi([Re(0,wn)],mp);var Ib=class extends ht{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ke),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ke),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ke),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let a=t-1;a>=0;a--)this.set(e+a+i,this.get(e+a));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ut=3,Mi=Object.freeze(new Uo),au=0,of=2,wo=class m0{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ut);let a=i||hr.fromCharData([0,By,1,0]);for(let o=0;o<t;++o)this.setCell(o,a);this.length=t}get(t){let i=this._data[t*ut+0],s=i&2097151;return[this._data[t*ut+1],i&2097152?this._combined[t]:s?Ls(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*ut+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*ut+0]=t|2097152|i[2]<<22):this._data[t*ut+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*ut+0]>>22}hasWidth(t){return this._data[t*ut+0]&12582912}getFg(t){return this._data[t*ut+1]}getBg(t){return this._data[t*ut+2]}hasContent(t){return this._data[t*ut+0]&4194303}getCodePoint(t){let i=this._data[t*ut+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*ut+0]&2097152}getString(t){let i=this._data[t*ut+0];return i&2097152?this._combined[t]:i&2097151?Ls(i&2097151):""}isProtected(t){return this._data[t*ut+2]&536870912}loadCell(t,i){return au=t*ut,i.content=this._data[au+0],i.fg=this._data[au+1],i.bg=this._data[au+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*ut+0]=i.content,this._data[t*ut+1]=i.fg,this._data[t*ut+2]=i.bg}setCellFromCodepoint(t,i,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*ut+0]=i|s<<22,this._data[t*ut+1]=a.fg,this._data[t*ut+2]=a.bg}addCodepointToCell(t,i,s){let a=this._data[t*ut+0];a&2097152?this._combined[t]+=Ls(i):a&2097151?(this._combined[t]=Ls(a&2097151)+Ls(i),a&=-2097152,a|=2097152):a=i|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*ut+0]=a}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let a=new hr;for(let o=this.length-t-i-1;o>=0;--o)this.setCell(t+i+o,this.loadCell(t+o,a));for(let o=0;o<i;++o)this.setCell(t+o,s)}else for(let a=t;a<this.length;++a)this.setCell(a,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let a=new hr;for(let o=0;o<this.length-t-i;++o)this.setCell(t+o,this.loadCell(t+i+o,a));for(let o=this.length-i;o<this.length;++o)this.setCell(o,s)}else for(let a=t;a<this.length;++a)this.setCell(a,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,a=!1){if(a){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*of<this._data.buffer.byteLength;let s=t*ut;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let a=new Uint32Array(s);a.set(this._data),this._data=a}for(let a=this.length;a<t;++a)this.setCell(a,i)}else{this._data=this._data.subarray(0,s);let a=Object.keys(this._combined);for(let c=0;c<a.length;c++){let h=parseInt(a[c],10);h>=t&&delete this._combined[h]}let o=Object.keys(this._extendedAttrs);for(let c=0;c<o.length;c++){let h=parseInt(o[c],10);h>=t&&delete this._extendedAttrs[h]}}return this.length=t,s*4*of<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*of<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new m0(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ut+0]&4194303)return t+(this._data[t*ut+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ut+0]&4194303||this._data[t*ut+2]&50331648)return t+(this._data[t*ut+0]>>22);return 0}copyCellsFrom(t,i,s,a,o){let c=t._data;if(o)for(let p=a-1;p>=0;p--){for(let d=0;d<ut;d++)this._data[(s+p)*ut+d]=c[(i+p)*ut+d];c[(i+p)*ut+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[i+p])}else for(let p=0;p<a;p++){for(let d=0;d<ut;d++)this._data[(s+p)*ut+d]=c[(i+p)*ut+d];c[(i+p)*ut+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[i+p])}let h=Object.keys(t._combined);for(let p=0;p<h.length;p++){let d=parseInt(h[p],10);d>=i&&(this._combined[d-i+s]=t._combined[d])}}translateToString(t,i,s,a){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),a&&(a.length=0);let o="";for(;i<s;){let c=this._data[i*ut+0],h=c&2097151,p=c&2097152?this._combined[i]:h?Ls(h):zs;if(o+=p,a)for(let d=0;d<p.length;++d)a.push(i);i+=c>>22||1}return a&&a.push(i),o}};function V2(e,t,i,s,a,o){let c=[];for(let h=0;h<e.length-1;h++){let p=h,d=e.get(++p);if(!d.isWrapped)continue;let x=[e.get(h)];for(;p<e.length&&d.isWrapped;)x.push(d),d=e.get(++p);if(!o&&s>=h&&s<p){h+=x.length-1;continue}let _=0,b=Oo(x,_,t),v=1,S=0;for(;v<x.length;){let M=Oo(x,v,t),E=M-S,H=i-b,z=Math.min(E,H);x[_].copyCellsFrom(x[v],S,b,z,!1),b+=z,b===i&&(_++,b=0),S+=z,S===M&&(v++,S=0),b===0&&_!==0&&x[_-1].getWidth(i-1)===2&&(x[_].copyCellsFrom(x[_-1],i-1,b++,1,!1),x[_-1].setCell(i-1,a))}x[_].replaceCells(b,i,a);let N=0;for(let M=x.length-1;M>0&&(M>_||x[M].getTrimmedLength()===0);M--)N++;N>0&&(c.push(h+x.length-N),c.push(N)),h+=x.length-1}return c}function X2(e,t){let i=[],s=0,a=t[s],o=0;for(let c=0;c<e.length;c++)if(a===c){let h=t[++s];e.onDeleteEmitter.fire({index:c-o,amount:h}),c+=h-1,o+=h,a=t[++s]}else i.push(c);return{layout:i,countRemoved:o}}function Z2(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function Q2(e,t,i){let s=[],a=e.map((p,d)=>Oo(e,d,t)).reduce((p,d)=>p+d),o=0,c=0,h=0;for(;h<a;){if(a-h<i){s.push(a-h);break}o+=i;let p=Oo(e,c,t);o>p&&(o-=p,c++);let d=e[c].getWidth(o-1)===2;d&&o--;let x=d?i-1:i;s.push(x),h+=x}return s}function Oo(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,a=e[t+1].getWidth(0)===2;return s&&a?i-1:i}var g0=class _0{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=_0._nextId++,this._onDispose=this.register(new ke),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),_a(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};g0._nextId=1;var J2=g0,Hi={},fa=Hi.B;Hi[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Hi.A={"#":"£"};Hi.B=void 0;Hi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Hi.C=Hi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Hi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Hi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Hi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Hi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Hi.E=Hi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Hi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Hi.H=Hi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Hi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Hb=4294967295,Ub=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Mi.clone(),this.savedCharset=fa,this.markers=[],this._nullCell=hr.fromCharData([0,By,1,0]),this._whitespaceCell=hr.fromCharData([0,zs,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Tu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Ib(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Cu),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Cu),this._whitespaceCell}getBlankLine(e,t){return new wo(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>Hb?Hb:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Mi);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Ib(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Mi),s=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols<e)for(let c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(e,i);let o=0;if(this._rows<t)for(let c=this._rows;c<t;c++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new wo(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new wo(e,i)));else for(let c=this._rows;c>t;c--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(a<this.lines.maxLength){let c=this.lines.length-a;c>0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=a}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=V2(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Mi),i);if(s.length>0){let a=X2(this.lines,s);Z2(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Mi),a=i;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new wo(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Mi),a=[],o=0;for(let c=this.lines.length-1;c>=0;c--){let h=this.lines.get(c);if(!h||!h.isWrapped&&h.getTrimmedLength()<=e)continue;let p=[h];for(;h.isWrapped&&c>0;)h=this.lines.get(--c),p.unshift(h);if(!i){let z=this.ybase+this.y;if(z>=c&&z<c+p.length)continue}let d=p[p.length-1].getTrimmedLength(),x=Q2(p,this._cols,e),_=x.length-p.length,b;this.ybase===0&&this.y!==this.lines.length-1?b=Math.max(0,this.y-this.lines.maxLength+_):b=Math.max(0,this.lines.length-this.lines.maxLength+_);let v=[];for(let z=0;z<_;z++){let R=this.getBlankLine(Mi,!0);v.push(R)}v.length>0&&(a.push({start:c+p.length+o,newLines:v}),o+=v.length),p.push(...v);let S=x.length-1,N=x[S];N===0&&(S--,N=x[S]);let M=p.length-_-1,E=d;for(;M>=0;){let z=Math.min(E,N);if(p[S]===void 0)break;if(p[S].copyCellsFrom(p[M],E-z,N-z,z,!0),N-=z,N===0&&(S--,N=x[S]),E-=z,E===0){M--;let R=Math.max(M,0);E=Oo(p,R,this._cols)}}for(let z=0;z<p.length;z++)x[z]<e&&p[z].setCell(x[z],s);let H=_-b;for(;H-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+_,this.ybase+t-1)}if(a.length>0){let c=[],h=[];for(let N=0;N<this.lines.length;N++)h.push(this.lines.get(N));let p=this.lines.length,d=p-1,x=0,_=a[x];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let b=0;for(let N=Math.min(this.lines.maxLength-1,p+o-1);N>=0;N--)if(_&&_.start>d+b){for(let M=_.newLines.length-1;M>=0;M--)this.lines.set(N--,_.newLines[M]);N++,c.push({index:d+1,amount:_.newLines.length}),b+=_.newLines.length,_=a[++x]}else this.lines.set(N,h[d--]);let v=0;for(let N=c.length-1;N>=0;N--)c[N].index+=v,this.lines.onInsertEmitter.fire(c[N]),v+=c[N].amount;let S=Math.max(0,p+o-this.lines.maxLength);S>0&&this.lines.onTrimEmitter.fire(S)}}translateBufferLineToString(e,t,i=0,s){let a=this.lines.get(e);return a?a.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new J2(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},eE=class extends ht{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ke),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Ub(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ub(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},x0=2,b0=1,gp=class extends ht{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,x0),this.rows=Math.max(e.rawOptions.rows||0,b0),this.buffers=this._register(new eE(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let a=i.ybase+i.scrollTop,o=i.ybase+i.scrollBottom;if(i.scrollTop===0){let c=i.lines.isFull;o===i.lines.length-1?c?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(o+1,0,s.clone()),c?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let c=o-a+1;i.lines.shiftElements(a+1,c-1,-1),i.lines.set(o,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};gp=gi([Re(0,wn)],gp);var tl={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Nu,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},tE=["normal","bold","100","200","300","400","500","600","700","800","900"],iE=class extends ht{constructor(e){super(),this._onOptionChange=this._register(new ke),this.onOptionChange=this._onOptionChange.event;let t={...tl};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(li(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in tl))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in tl))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=tl[e]),!nE(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=tl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=tE.includes(t)?t:tl[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function nE(e){return e==="block"||e==="underline"||e==="bar"}function Co(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&Co(e[s],t-1);return i}var $b=Object.freeze({insertMode:!1}),Fb=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),_p=class extends ht{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ke),this.onData=this._onData.event,this._onUserInput=this._register(new ke),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ke),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Co($b),this.decPrivateModes=Co(Fb)}reset(){this.modes=Co($b),this.decPrivateModes=Co(Fb)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};_p=gi([Re(0,Sn),Re(1,Iy),Re(2,wn)],_p);var qb={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function cf(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var uf=String.fromCharCode,Wb={DEFAULT:e=>{let t=[cf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${uf(t[0])}${uf(t[1])}${uf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${cf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${cf(e,!0)};${e.x};${e.y}${t}`}},xp=class extends ht{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ke),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(qb))this.addProtocol(s,qb[s]);for(let s of Object.keys(Wb))this.addEncoding(s,Wb[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=s+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};xp=gi([Re(0,Sn),Re(1,va),Re(2,wn)],xp);var hf=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],rE=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Pi;function sE(e,t){let i=0,s=t.length-1,a;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(a=i+s>>1,e>t[a][1])i=a+1;else if(e<t[a][0])s=a-1;else return!0;return!1}var aE=class{constructor(){if(this.version="6",!Pi){Pi=new Uint8Array(65536),Pi.fill(1),Pi[0]=0,Pi.fill(0,1,32),Pi.fill(0,127,160),Pi.fill(2,4352,4448),Pi[9001]=2,Pi[9002]=2,Pi.fill(2,11904,42192),Pi[12351]=1,Pi.fill(2,44032,55204),Pi.fill(2,63744,64256),Pi.fill(2,65040,65050),Pi.fill(2,65072,65136),Pi.fill(2,65280,65377),Pi.fill(2,65504,65511);for(let e=0;e<hf.length;++e)Pi.fill(0,hf[e][0],hf[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Pi[e]:sE(e,rE)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let a=ma.extractWidth(t);a===0?s=!1:a>i&&(i=a)}return ma.createPropertyValue(0,i,s)}},ma=class bu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ke,this.onChange=this._onChange.event;let t=new aE;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,a=t.length;for(let o=0;o<a;++o){let c=t.charCodeAt(o);if(55296<=c&&c<=56319){if(++o>=a)return i+this.wcwidth(c);let d=t.charCodeAt(o);56320<=d&&d<=57343?c=(c-55296)*1024+d-56320+65536:i+=this.wcwidth(d)}let h=this.charProperties(c,s),p=bu.extractWidth(h);bu.extractShouldJoin(h)&&(p-=bu.extractWidth(s)),i+=p,s=h}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},lE=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Gb(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var fo=2147483647,oE=256,v0=class bp{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>oE)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new bp;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let a=t[s];if(Array.isArray(a))for(let o=0;o<a.length;++o)i.addSubParam(a[o]);else i.addParam(a)}return i}clone(){let t=new bp(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,a=this._subParamsIdx[i]&255;a-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,a))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>fo?fo:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>fo?fo:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,a=this._subParamsIdx[i]&255;a-s>0&&(t[i]=this._subParams.slice(s,a))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,a=s[i-1];s[i-1]=~a?Math.min(a*10+t,fo):t}},po=[],cE=class{constructor(){this._state=0,this._active=po,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=po}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=po,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||po,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",zu(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=po,this._id=-1,this._state=0}}},Wn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=zu(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},mo=[],uE=class{constructor(){this._handlers=Object.create(null),this._active=mo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=mo}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=mo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||mo,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",zu(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=mo,this._ident=0}},ko=new v0;ko.addParam(0);var Yb=class{constructor(e){this._handler=e,this._data="",this._params=ko,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ko,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=zu(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=ko,this._data="",this._hitLimit=!1,i));return this._params=ko,this._data="",this._hitLimit=!1,t}},hE=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let a=0;a<e.length;a++)this.table[t<<8|e[a]]=i<<4|s}},cr=160,dE=(function(){let e=new hE(4095),t=Array.apply(null,Array(256)).map((h,p)=>p),i=(h,p)=>t.slice(h,p),s=i(32,127),a=i(0,24);a.push(25),a.push.apply(a,i(28,32));let o=i(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in o)e.addMany([24,26,153,154],c,3,0),e.addMany(i(128,144),c,3,0),e.addMany(i(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,11,9);return e.addMany(a,0,3,0),e.addMany(a,1,3,1),e.add(127,1,0,1),e.addMany(a,8,0,8),e.addMany(a,3,3,3),e.add(127,3,0,3),e.addMany(a,4,3,4),e.add(127,4,0,4),e.addMany(a,6,3,6),e.addMany(a,5,3,5),e.add(127,5,0,5),e.addMany(a,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(a,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(a,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(cr,0,2,0),e.add(cr,8,5,8),e.add(cr,6,0,6),e.add(cr,11,0,11),e.add(cr,13,13,13),e})(),fE=class extends ht{constructor(e=dE){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new v0,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(li(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new cE),this._dcsParser=this._register(new uE),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;a<e.intermediates.length;++a){let o=e.intermediates.charCodeAt(a);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,t,i){let s=0,a=0,o=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&p>-1){for(;p>=0&&(c=h[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 4:if(i===!1&&p>-1){for(;p>=0&&(c=h[p](),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],c=this._oscParser.end(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let h=o;h<t;++h){switch(s=e[h],a=this._transitions.table[this.currentState<<8|(s<160?s:cr)],a>>4){case 2:for(let b=h+1;;++b){if(b>=t||(s=e[b])<32||s>126&&s<cr){this._printHandler(e,h,b),h=b-1;break}if(++b>=t||(s=e[b])<32||s>126&&s<cr){this._printHandler(e,h,b),h=b-1;break}if(++b>=t||(s=e[b])<32||s>126&&s<cr){this._printHandler(e,h,b),h=b-1;break}if(++b>=t||(s=e[b])<32||s>126&&s<cr){this._printHandler(e,h,b),h=b-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let p=this._csiHandlers[this._collect<<8|s],d=p?p.length-1:-1;for(;d>=0&&(c=p[d](this._params),c!==!0);d--)if(c instanceof Promise)return this._preserveStack(3,p,d,a,h),c;d<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++h<t&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let x=this._escHandlers[this._collect<<8|s],_=x?x.length-1:-1;for(;_>=0&&(c=x[_](),c!==!0);_--)if(c instanceof Promise)return this._preserveStack(4,x,_,a,h),c;_<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let b=h+1;;++b)if(b>=t||(s=e[b])===24||s===26||s===27||s>127&&s<cr){this._dcsParser.put(e,h,b),h=b-1;break}break;case 14:if(c=this._dcsParser.unhook(s!==24&&s!==26),c)return this._preserveStack(6,[],0,a,h),c;s===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let b=h+1;;b++)if(b>=t||(s=e[b])<32||s>127&&s<cr){this._oscParser.put(e,h,b),h=b-1;break}break;case 6:if(c=this._oscParser.end(s!==24&&s!==26),c)return this._preserveStack(5,[],0,a,h),c;s===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=a&15}}},pE=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,mE=/^[\da-f]+$/;function Kb(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=pE.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),mE.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let a=0;a<3;++a){let o=parseInt(t.slice(i*a,i*a+i),16);s[a]=i===1?o<<4:i===2?o:i===3?o>>4:o>>8}return s}}function df(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function gE(e,t=16){let[i,s,a]=e;return`rgb:${df(i,t)}/${df(s,t)}/${df(a,t)}`}var _E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ms=131072,Vb=10;function Xb(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Zb=5e3,Qb=0,xE=class extends ht{constructor(e,t,i,s,a,o,c,h,p=new fE){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=c,this._unicodeService=h,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new zC,this._utf8Decoder=new PC,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Mi.clone(),this._eraseAttrDataInternal=Mi.clone(),this._onRequestBell=this._register(new ke),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ke),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ke),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ke),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ke),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ke),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ke),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ke),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ke),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new vp(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(d=>this._activeBuffer=d.activeBuffer)),this._parser.setCsiHandlerFallback((d,x)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(d),params:x.toArray()})}),this._parser.setEscHandlerFallback(d=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(d)})}),this._parser.setExecuteHandlerFallback(d=>{this._logService.debug("Unknown EXECUTE code: ",{code:d})}),this._parser.setOscHandlerFallback((d,x,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:d,action:x,data:_})}),this._parser.setDcsHandlerFallback((d,x,_)=>{x==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(d),action:x,payload:_})}),this._parser.setPrintHandler((d,x,_)=>this.print(d,x,_)),this._parser.registerCsiHandler({final:"@"},d=>this.insertChars(d)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},d=>this.scrollLeft(d)),this._parser.registerCsiHandler({final:"A"},d=>this.cursorUp(d)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},d=>this.scrollRight(d)),this._parser.registerCsiHandler({final:"B"},d=>this.cursorDown(d)),this._parser.registerCsiHandler({final:"C"},d=>this.cursorForward(d)),this._parser.registerCsiHandler({final:"D"},d=>this.cursorBackward(d)),this._parser.registerCsiHandler({final:"E"},d=>this.cursorNextLine(d)),this._parser.registerCsiHandler({final:"F"},d=>this.cursorPrecedingLine(d)),this._parser.registerCsiHandler({final:"G"},d=>this.cursorCharAbsolute(d)),this._parser.registerCsiHandler({final:"H"},d=>this.cursorPosition(d)),this._parser.registerCsiHandler({final:"I"},d=>this.cursorForwardTab(d)),this._parser.registerCsiHandler({final:"J"},d=>this.eraseInDisplay(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},d=>this.eraseInDisplay(d,!0)),this._parser.registerCsiHandler({final:"K"},d=>this.eraseInLine(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},d=>this.eraseInLine(d,!0)),this._parser.registerCsiHandler({final:"L"},d=>this.insertLines(d)),this._parser.registerCsiHandler({final:"M"},d=>this.deleteLines(d)),this._parser.registerCsiHandler({final:"P"},d=>this.deleteChars(d)),this._parser.registerCsiHandler({final:"S"},d=>this.scrollUp(d)),this._parser.registerCsiHandler({final:"T"},d=>this.scrollDown(d)),this._parser.registerCsiHandler({final:"X"},d=>this.eraseChars(d)),this._parser.registerCsiHandler({final:"Z"},d=>this.cursorBackwardTab(d)),this._parser.registerCsiHandler({final:"`"},d=>this.charPosAbsolute(d)),this._parser.registerCsiHandler({final:"a"},d=>this.hPositionRelative(d)),this._parser.registerCsiHandler({final:"b"},d=>this.repeatPrecedingCharacter(d)),this._parser.registerCsiHandler({final:"c"},d=>this.sendDeviceAttributesPrimary(d)),this._parser.registerCsiHandler({prefix:">",final:"c"},d=>this.sendDeviceAttributesSecondary(d)),this._parser.registerCsiHandler({final:"d"},d=>this.linePosAbsolute(d)),this._parser.registerCsiHandler({final:"e"},d=>this.vPositionRelative(d)),this._parser.registerCsiHandler({final:"f"},d=>this.hVPosition(d)),this._parser.registerCsiHandler({final:"g"},d=>this.tabClear(d)),this._parser.registerCsiHandler({final:"h"},d=>this.setMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"h"},d=>this.setModePrivate(d)),this._parser.registerCsiHandler({final:"l"},d=>this.resetMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"l"},d=>this.resetModePrivate(d)),this._parser.registerCsiHandler({final:"m"},d=>this.charAttributes(d)),this._parser.registerCsiHandler({final:"n"},d=>this.deviceStatus(d)),this._parser.registerCsiHandler({prefix:"?",final:"n"},d=>this.deviceStatusPrivate(d)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},d=>this.softReset(d)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},d=>this.setCursorStyle(d)),this._parser.registerCsiHandler({final:"r"},d=>this.setScrollRegion(d)),this._parser.registerCsiHandler({final:"s"},d=>this.saveCursor(d)),this._parser.registerCsiHandler({final:"t"},d=>this.windowOptions(d)),this._parser.registerCsiHandler({final:"u"},d=>this.restoreCursor(d)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},d=>this.insertColumns(d)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},d=>this.deleteColumns(d)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},d=>this.selectProtected(d)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},d=>this.requestMode(d,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},d=>this.requestMode(d,!1)),this._parser.setExecuteHandler(ge.BEL,()=>this.bell()),this._parser.setExecuteHandler(ge.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(ge.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(ge.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(ge.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(ge.BS,()=>this.backspace()),this._parser.setExecuteHandler(ge.HT,()=>this.tab()),this._parser.setExecuteHandler(ge.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(ge.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(_u.IND,()=>this.index()),this._parser.setExecuteHandler(_u.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(_u.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Wn(d=>(this.setTitle(d),this.setIconName(d),!0))),this._parser.registerOscHandler(1,new Wn(d=>this.setIconName(d))),this._parser.registerOscHandler(2,new Wn(d=>this.setTitle(d))),this._parser.registerOscHandler(4,new Wn(d=>this.setOrReportIndexedColor(d))),this._parser.registerOscHandler(8,new Wn(d=>this.setHyperlink(d))),this._parser.registerOscHandler(10,new Wn(d=>this.setOrReportFgColor(d))),this._parser.registerOscHandler(11,new Wn(d=>this.setOrReportBgColor(d))),this._parser.registerOscHandler(12,new Wn(d=>this.setOrReportCursorColor(d))),this._parser.registerOscHandler(104,new Wn(d=>this.restoreIndexedColor(d))),this._parser.registerOscHandler(110,new Wn(d=>this.restoreFgColor(d))),this._parser.registerOscHandler(111,new Wn(d=>this.restoreBgColor(d))),this._parser.registerOscHandler(112,new Wn(d=>this.restoreCursorColor(d))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let d in Hi)this._parser.registerEscHandler({intermediates:"(",final:d},()=>this.selectCharset("("+d)),this._parser.registerEscHandler({intermediates:")",final:d},()=>this.selectCharset(")"+d)),this._parser.registerEscHandler({intermediates:"*",final:d},()=>this.selectCharset("*"+d)),this._parser.registerEscHandler({intermediates:"+",final:d},()=>this.selectCharset("+"+d)),this._parser.registerEscHandler({intermediates:"-",final:d},()=>this.selectCharset("-"+d)),this._parser.registerEscHandler({intermediates:".",final:d},()=>this.selectCharset("."+d)),this._parser.registerEscHandler({intermediates:"/",final:d},()=>this.selectCharset("/"+d));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(d=>(this._logService.error("Parsing error: ",d),d)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Yb((d,x)=>this.requestStatusString(d,x)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Zb))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Zb} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,a=this._activeBuffer.y,o=0,c=this._parseStack.paused;if(c){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ms&&(o=this._parseStack.position+Ms)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,d=>String.fromCharCode(d)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(d=>d.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ms&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ms))),c||this._dirtyRowTracker.clearRange(),e.length>Ms)for(let d=o;d<e.length;d+=Ms){let x=d+Ms<e.length?d+Ms:e.length,_=typeof e=="string"?this._stringDecoder.decode(e.substring(d,x),this._parseBuffer):this._utf8Decoder.decode(e.subarray(d,x),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,_))return this._preserveStack(s,a,_,d),this._logSlowResolvingAsync(i),i}else if(!c){let d=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,d))return this._preserveStack(s,a,d,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==a)&&this._onCursorMove.fire();let h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),p=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);p<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(p,this._bufferService.rows-1),end:Math.min(h,this._bufferService.rows-1)})}print(e,t,i){let s,a,o=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,p=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,x=this._curAttrData,_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&_.getWidth(this._activeBuffer.x-1)===2&&_.setCellFromCodepoint(this._activeBuffer.x-1,0,1,x);let b=this._parser.precedingJoinState;for(let v=t;v<i;++v){if(s=e[v],s<127&&o){let E=o[String.fromCharCode(s)];E&&(s=E.charCodeAt(0))}let S=this._unicodeService.charProperties(s,b);a=ma.extractWidth(S);let N=ma.extractShouldJoin(S),M=N?ma.extractWidth(b):0;if(b=S,c&&this._onA11yChar.fire(Ls(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+a-M>h){if(p){let E=_,H=this._activeBuffer.x-M;for(this._activeBuffer.x=M,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),M>0&&_ instanceof wo&&_.copyCellsFrom(E,H,0,M,!1);H<h;)E.setCellFromCodepoint(H++,0,1,x)}else if(this._activeBuffer.x=h-1,a===2)continue}if(N&&this._activeBuffer.x){let E=_.getWidth(this._activeBuffer.x-1)?1:2;_.addCodepointToCell(this._activeBuffer.x-E,s,a);for(let H=a-M;--H>=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,x);continue}if(d&&(_.insertCells(this._activeBuffer.x,a-M,this._activeBuffer.getNullCell(x)),_.getWidth(h-1)===2&&_.setCellFromCodepoint(h-1,0,1,x)),_.setCellFromCodepoint(this._activeBuffer.x++,s,a,x),a>0)for(;--a;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,x)}this._parser.precedingJoinState=b,this._activeBuffer.x<h&&i-t>0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,x),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Xb(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Yb(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Wn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,a=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),a),s&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let a=this._activeBuffer.lines.length-this._bufferService.rows;a>0&&(this._activeBuffer.lines.trimStart(a),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-a,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-a,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,a=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(a-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Mi));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=ma.extractWidth(t),a=this._activeBuffer.x-s,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(a),c=new Uint32Array(o.length*i),h=0;for(let d=0;d<o.length;){let x=o.codePointAt(d)||0;c[h++]=x,d+=x>65535?2:1}let p=h;for(let d=1;d<i;++d)c.copyWithin(p,0,h),p+=h;return this.print(c,0,p),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(ge.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ge.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ge.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ge.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ge.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,fa),this._charsetService.setgCharset(1,fa),this._charsetService.setgCharset(2,fa),this._charsetService.setgCharset(3,fa);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(N=>(N[N.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",N[N.SET=1]="SET",N[N.RESET=2]="RESET",N[N.PERMANENTLY_SET=3]="PERMANENTLY_SET",N[N.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,c=this._coreService,{buffers:h,cols:p}=this._bufferService,{active:d,alt:x}=h,_=this._optionsService.rawOptions,b=(N,M)=>(c.triggerDataEvent(`${ge.ESC}[${t?"":"?"}${N};${M}$y`),!0),v=N=>N?1:2,S=e.params[0];return t?S===2?b(S,4):S===4?b(S,v(c.modes.insertMode)):S===12?b(S,3):S===20?b(S,v(_.convertEol)):b(S,0):S===1?b(S,v(s.applicationCursorKeys)):S===3?b(S,_.windowOptions.setWinLines?p===80?2:p===132?1:0:0):S===6?b(S,v(s.origin)):S===7?b(S,v(s.wraparound)):S===8?b(S,3):S===9?b(S,v(a==="X10")):S===12?b(S,v(_.cursorBlink)):S===25?b(S,v(!c.isCursorHidden)):S===45?b(S,v(s.reverseWraparound)):S===66?b(S,v(s.applicationKeypad)):S===67?b(S,4):S===1e3?b(S,v(a==="VT200")):S===1002?b(S,v(a==="DRAG")):S===1003?b(S,v(a==="ANY")):S===1004?b(S,v(s.sendFocus)):S===1005?b(S,4):S===1006?b(S,v(o==="SGR")):S===1015?b(S,4):S===1016?b(S,v(o==="SGR_PIXELS")):S===1048?b(S,1):S===47||S===1047||S===1049?b(S,v(d===x)):S===2004?b(S,v(s.bracketedPasteMode)):S===2026?b(S,v(s.synchronizedOutput)):b(S,0)}_updateAttrColor(e,t,i,s,a){return t===2?(e|=50331648,e&=-16777216,e|=Uo.fromColorRGB([i,s,a])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],a=0,o=0;do{if(s[o+a]=e.params[t+o],e.hasSubParams(t+o)){let c=e.getSubParams(t+o),h=0;do s[1]===5&&(a=1),s[o+h+1+a]=c[h];while(++h<c.length&&h+o+1+a<s.length);break}if(s[1]===5&&o+a>=2||s[1]===2&&o+a>=5)break;s[1]&&(a=1)}while(++o+t<e.length&&o+a<s.length);for(let c=2;c<s.length;++c)s[c]===-1&&(s[c]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return o}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Mi.fg,e.bg=Mi.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let a=0;a<t;a++)i=e.params[a],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=Mi.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Mi.bg&16777215):i===38||i===48||i===58?a+=this._extractColor(e,a,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=Mi.fg&16777215,s.bg&=-67108864,s.bg|=Mi.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${ge.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ge.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ge.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Mi.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Xb(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${ge.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Vb&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Vb&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),a=i.shift();if(/^\d+$/.exec(s)){let o=parseInt(s);if(Jb(o))if(a==="?")t.push({type:0,index:o});else{let c=Kb(a);c&&t.push({type:1,index:o,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,a=i.findIndex(o=>o.startsWith("id="));return a!==-1&&(s=i[a].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=Kb(i[s]);a&&this._onColor.fire([{type:1,index:this._specialColors[t],color:a}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let a=parseInt(i[s]);Jb(a)&&t.push({type:2,index:a})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,fa),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(_E[e[0]],Hi[e[1]]||fa),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Mi.clone(),this._eraseAttrDataInternal=Mi.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new hr;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=c=>(this._coreService.triggerDataEvent(`${ge.ESC}${c}${ge.ESC}\\`),!0),s=this._bufferService.buffer,a=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},vp=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Qb=e,e=t,t=Qb),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};vp=gi([Re(0,Sn)],vp);function Jb(e){return 0<=e&&e<256}var bE=5e7,ev=12,vE=50,yE=class extends ht{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>bE)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],a=this._action(s,t);if(a){let c=h=>performance.now()-i>=ev?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(i,h);a.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(!1))).then(c);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=ev)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>vE&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},yp=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let h=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(p,h)),this._dataByLinkId.set(p.id,p),p.id}let i=e,s=this._getEntryIdKey(i),a=this._entriesWithId.get(s);if(a)return this.addLineToLink(a.id,t.ybase+t.y),a.id;let o=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(c,o)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};yp=gi([Re(0,Sn)],yp);var tv=!1,SE=class extends ht{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new hl),this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onData=this._register(new ke),this.onData=this._onData.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ke),this._instantiationService=new G2,this.optionsService=this._register(new iE(e)),this._instantiationService.setService(wn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(gp)),this._instantiationService.setService(Sn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(mp)),this._instantiationService.setService(Iy,this._logService),this.coreService=this._register(this._instantiationService.createInstance(_p)),this._instantiationService.setService(va,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(xp)),this._instantiationService.setService(Py,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ma)),this._instantiationService.setService($C,this.unicodeService),this._charsetService=this._instantiationService.createInstance(lE),this._instantiationService.setService(UC,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(yp),this._instantiationService.setService(Hy,this._oscLinkService),this._inputHandler=this._register(new xE(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(an.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(an.forward(this._bufferService.onResize,this._onResize)),this._register(an.forward(this.coreService.onData,this._onData)),this._register(an.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new yE((t,i)=>this._inputHandler.parse(t,i))),this._register(an.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ke),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!tv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),tv=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,x0),t=Math.max(t,b0),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Gb.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Gb(this._bufferService),!1))),this._windowsWrappingHeuristics.value=li(()=>{for(let t of e)t.dispose()})}}},wE={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function CE(e,t,i,s){var c;let a={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?a.key=ge.ESC+"OA":a.key=ge.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=ge.ESC+"OD":a.key=ge.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=ge.ESC+"OC":a.key=ge.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=ge.ESC+"OB":a.key=ge.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":ge.DEL,e.altKey&&(a.key=ge.ESC+a.key);break;case 9:if(e.shiftKey){a.key=ge.ESC+"[Z";break}a.key=ge.HT,a.cancel=!0;break;case 13:a.key=e.altKey?ge.ESC+ge.CR:ge.CR,a.cancel=!0;break;case 27:a.key=ge.ESC,e.altKey&&(a.key=ge.ESC+ge.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=ge.ESC+"[1;"+(o+1)+"D":t?a.key=ge.ESC+"OD":a.key=ge.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=ge.ESC+"[1;"+(o+1)+"C":t?a.key=ge.ESC+"OC":a.key=ge.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=ge.ESC+"[1;"+(o+1)+"A":t?a.key=ge.ESC+"OA":a.key=ge.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=ge.ESC+"[1;"+(o+1)+"B":t?a.key=ge.ESC+"OB":a.key=ge.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=ge.ESC+"[2~");break;case 46:o?a.key=ge.ESC+"[3;"+(o+1)+"~":a.key=ge.ESC+"[3~";break;case 36:o?a.key=ge.ESC+"[1;"+(o+1)+"H":t?a.key=ge.ESC+"OH":a.key=ge.ESC+"[H";break;case 35:o?a.key=ge.ESC+"[1;"+(o+1)+"F":t?a.key=ge.ESC+"OF":a.key=ge.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=ge.ESC+"[5;"+(o+1)+"~":a.key=ge.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=ge.ESC+"[6;"+(o+1)+"~":a.key=ge.ESC+"[6~";break;case 112:o?a.key=ge.ESC+"[1;"+(o+1)+"P":a.key=ge.ESC+"OP";break;case 113:o?a.key=ge.ESC+"[1;"+(o+1)+"Q":a.key=ge.ESC+"OQ";break;case 114:o?a.key=ge.ESC+"[1;"+(o+1)+"R":a.key=ge.ESC+"OR";break;case 115:o?a.key=ge.ESC+"[1;"+(o+1)+"S":a.key=ge.ESC+"OS";break;case 116:o?a.key=ge.ESC+"[15;"+(o+1)+"~":a.key=ge.ESC+"[15~";break;case 117:o?a.key=ge.ESC+"[17;"+(o+1)+"~":a.key=ge.ESC+"[17~";break;case 118:o?a.key=ge.ESC+"[18;"+(o+1)+"~":a.key=ge.ESC+"[18~";break;case 119:o?a.key=ge.ESC+"[19;"+(o+1)+"~":a.key=ge.ESC+"[19~";break;case 120:o?a.key=ge.ESC+"[20;"+(o+1)+"~":a.key=ge.ESC+"[20~";break;case 121:o?a.key=ge.ESC+"[21;"+(o+1)+"~":a.key=ge.ESC+"[21~";break;case 122:o?a.key=ge.ESC+"[23;"+(o+1)+"~":a.key=ge.ESC+"[23~";break;case 123:o?a.key=ge.ESC+"[24;"+(o+1)+"~":a.key=ge.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?a.key=ge.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=ge.DEL:e.keyCode===219?a.key=ge.ESC:e.keyCode===220?a.key=ge.FS:e.keyCode===221&&(a.key=ge.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let h=(c=wE[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(h)a.key=ge.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,d=String.fromCharCode(p);e.shiftKey&&(d=d.toUpperCase()),a.key=ge.ESC+d}else if(e.keyCode===32)a.key=ge.ESC+(e.ctrlKey?ge.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),a.key=ge.ESC+p,a.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?a.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(a.key=ge.US),e.key==="@"&&(a.key=ge.NUL));break}return a}var Ci=0,kE=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Tu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Tu,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,o)=>this._getKey(a)-this._getKey(o)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let a=0;a<s.length;a++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[a]=e[t],t++):s[a]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Ci=this._search(t),Ci===-1)||this._getKey(this._array[Ci])!==t)return!1;do if(this._array[Ci]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ci),!0;while(++Ci<this._array.length&&this._getKey(this._array[Ci])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((a,o)=>a-o),t=0,i=new Array(this._array.length-e.length),s=0;for(let a=0;a<this._array.length;a++)e[t]===a?t++:i[s++]=this._array[a];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ci=this._search(e),!(Ci<0||Ci>=this._array.length)&&this._getKey(this._array[Ci])===e))do yield this._array[Ci];while(++Ci<this._array.length&&this._getKey(this._array[Ci])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ci=this._search(e),!(Ci<0||Ci>=this._array.length)&&this._getKey(this._array[Ci])===e))do t(this._array[Ci]);while(++Ci<this._array.length&&this._getKey(this._array[Ci])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,a=this._getKey(this._array[s]);if(a>e)i=s-1;else if(a<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},ff=0,iv=0,EE=class extends ht{constructor(){super(),this._decorations=new kE(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ke),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ke),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(li(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new NE(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,a=0;for(let o of this._decorations.getKeyIterator(t))s=o.options.x??0,a=s+(o.options.width??1),e>=s&&e<a&&(!i||(o.options.layer??"bottom")===i)&&(yield o)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,a=>{ff=a.options.x??0,iv=ff+(a.options.width??1),e>=ff&&e<iv&&(!i||(a.options.layer??"bottom")===i)&&s(a)})}},NE=class extends Ps{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ke),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ke),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=ci.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ci.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},TE=1e3,jE=class{constructor(e,t=TE){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=s-this._lastRefreshMs,o=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},nv=20,ju=class extends ht{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let a=this._coreBrowserService.mainDocument;this._accessibilityContainer=a.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=a.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=a.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new jE(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
73
+ `))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(et(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(li(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<nv+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
74
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===nv+1&&(this._liveRegion.textContent+=Uf.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 i=this._terminal.buffer,s=i.lines.length.toString();for(let a=e;a<=t;a++){let o=i.lines.get(i.ydisp+a),c=[],h=(o==null?void 0:o.translateToString(!0,void 0,void 0,c))||"",p=(i.ydisp+a+1).toString(),d=this._rowElements[a];d&&(h.length===0?(d.textContent=" ",this._rowColumns.set(d,[0,1])):(d.textContent=h,this._rowColumns.set(d,c)),d.setAttribute("aria-posinset",p),d.setAttribute("aria-setsize",s),this._alignRowWidth(d))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],a=i.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===o||e.relatedTarget!==s)return;let c,h;if(t===0?(c=i,h=this._rowElements.pop(),this._rowContainer.removeChild(h)):(c=this._rowElements.shift(),h=i,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),h.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}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(){var h;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},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,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 s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((h=s.textContent)==null?void 0:h.length)??0}),!this._rowContainer.contains(i.node))return;let a=({node:p,offset:d})=>{let x=p instanceof Text?p.parentNode:p,_=parseInt(x==null?void 0:x.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(x);if(!b)return console.warn("columns is null. Race condition?"),null;let v=d<b.length?b[d]:b.slice(-1)[0]+1;return v>=this._terminal.cols&&(++_,v=0),{row:_,column:v}},o=a(t),c=a(i);if(!(!o||!c)){if(o.row>c.row||o.row===c.row&&o.column>=c.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(c.row-o.row)*this._terminal.cols-o.column+c.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){var a,o;e.style.transform="";let t=e.getBoundingClientRect().width,i=(o=(a=this._rowColumns.get(e))==null?void 0:a.slice(-1))==null?void 0:o[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};ju=gi([Re(1,Fp),Re(2,rs),Re(3,ss)],ju);var Sp=class extends ht{constructor(e,t,i,s,a){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=a,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ke),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ke),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(li(()=>{var o;_a(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(et(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(et(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(et(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(et(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 i=e.composedPath();for(let s=0;s<i.length;s++){let a=i[s];if(a.classList.contains("xterm"))break;if(a.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){var s,a;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(o=>{o==null||o.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[o,c]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(i=this._checkLinkProviderResult(o,e,i)):c.provideLinks(e.y,h=>{var d,x;if(this._isMouseOut)return;let p=h==null?void 0:h.map(_=>({link:_}));(d=this._activeProviderReplies)==null||d.set(o,p),i=this._checkLinkProviderResult(o,e,i),((x=this._activeProviderReplies)==null?void 0:x.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let a=t.get(s);if(a)for(let o=0;o<a.length;o++){let c=a[o],h=c.link.range.start.y<e?0:c.link.range.start.x,p=c.link.range.end.y>e?this._bufferService.cols:c.link.range.end.x;for(let d=h;d<=p;d++){if(i.has(d)){a.splice(o--,1);break}i.add(d)}}}}_checkLinkProviderResult(e,t,i){var o;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),a=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(a=!0);if(!a&&s){let c=s.find(h=>this._linkAtPosition(h.link,t));c&&(i=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let c=0;c<this._activeProviderReplies.size;c++){let h=(o=this._activeProviderReplies.get(c))==null?void 0:o.find(p=>this._linkAtPosition(p.link,t));if(h){i=!0,this._handleNewLink(h);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&AE(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,_a(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:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,a,o;(s=this._currentLink)!=null&&s.state&&((o=(a=this._currentLink)==null?void 0:a.state)==null?void 0:o.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(s,a),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,a=t.y*this._bufferService.cols+t.x;return i<=a&&a<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,a){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:a}}};Sp=gi([Re(1,qp),Re(2,ss),Re(3,Sn),Re(4,$y)],Sp);function AE(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 RE=class extends SE{constructor(e={}){super(e),this._linkifier=this._register(new hl),this.browser=l0,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new hl),this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ke),this.onKey=this._onKey.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ke),this.onBell=this._onBell.event,this._onFocus=this._register(new ke),this._onBlur=this._register(new ke),this._onA11yCharEmitter=this._register(new ke),this._onA11yTabEmitter=this._register(new ke),this._onWillOpen=this._register(new ke),this._setup(),this._decorationService=this._instantiationService.createInstance(EE),this._instantiationService.setService($o,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(v2),this._instantiationService.setService($y,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Ff)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 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(an.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(an.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(an.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(an.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(li(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.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 i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let a=ri.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${ge.ESC}]${s};${gE(a)}${s0.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Bi.toColor(...t.color));else{let o=i;this._themeService.modifyColors(c=>c[o]=Bi.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(ju,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ge.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ge.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 i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,a=t.getWidth(i),o=this._renderService.dimensions.css.cell.width*a,c=this.buffer.y*this._renderService.dimensions.css.cell.height,h=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=c+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(et(this.element,"copy",t=>{this.hasSelection()&&LC(t,this._selectionService)}));let e=t=>OC(t,this.textarea,this.coreService,this.optionsService);this._register(et(this.textarea,"paste",e)),this._register(et(this.element,"paste",e)),o0?this._register(et(this.element,"mousedown",t=>{t.button===2&&fb(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(et(this.element,"contextmenu",t=>{fb(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Qp&&this._register(et(this.element,"auxclick",t=>{t.button===1&&My(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(et(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(et(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(et(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(et(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(et(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(et(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(et(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;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"),((a=this.element)==null?void 0:a.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(et(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 i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Hf.get()),h0||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(x2,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(rs,this._coreBrowserService),this._register(et(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(et(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(up,this._document,this._helperContainer),this._instantiationService.setService(Pu,this._charSizeService),this._themeService=this._instantiationService.createInstance(pp),this._instantiationService.setService(fl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Eu),this._instantiationService.setService(Uy,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(dp,this.rows,this.screenElement)),this._instantiationService.setService(ss,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(lp,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(hp),this._instantiationService.setService(qp,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Sp,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(sp,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(fp,this.element,this.screenElement,s)),this._instantiationService.setService(qC,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(an.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(ap,this.screenElement)),this._register(et(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(ju,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ku,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ku,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 i(o){var d,x,_,b,v;let c=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!c)return!1;let h,p;switch(o.overrideType||o.type){case"mousemove":p=32,o.buttons===void 0?(h=3,o.button!==void 0&&(h=o.button<3?o.button:3)):h=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":p=0,h=o.button<3?o.button:3;break;case"mousedown":p=1,h=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let S=o.deltaY;if(S===0||e.coreMouseService.consumeWheelEvent(o,(b=(_=(x=(d=e._renderService)==null?void 0:d.dimensions)==null?void 0:x.device)==null?void 0:_.cell)==null?void 0:b.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return!1;p=S<0?0:1,h=4;break;default:return!1}return p===void 0||h===void 0||h>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:h,action:p,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:o=>(i(o),o.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(o)),wheel:o=>(i(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&i(o)},mousemove:o=>{o.buttons||i(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),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()),o&8?s.mousemove||(t.addEventListener("mousemove",a.mousemove),s.mousemove=a.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),o&16?s.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),s.wheel=a.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),o&2?s.mouseup||(s.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),o&4?s.mousedrag||(s.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(et(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return i(o),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(o)})),this._register(et(t,"wheel",o=>{var c,h,p,d,x;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(d=(p=(h=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:h.device)==null?void 0:p.cell)==null?void 0:d.height,(x=e._coreBrowserService)==null?void 0:x.dpr)===0)return this.cancel(o,!0);let _=ge.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(_,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.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){Dy(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,i){this._selectionService.setSelection(e,t,i)}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(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.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 i=CE(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.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((i.key===ge.ETX||i.key===ge.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=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"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(DE(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){var i;(i=this._charSizeService)==null||i.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(Mi));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(ge.ESC+"[I"):this.coreService.triggerDataEvent(ge.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ge.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),a=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${ge.ESC}[6;${a};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function DE(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var ME=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;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)}},BE=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 hr)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},rv=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 BE(t)}getNullCell(){return new hr}},LE=class extends ht{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ke),this.onBufferChange=this._onBufferChange.event,this._normal=new rv(this._core.buffers.normal,"normal"),this._alternate=new rv(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)}},OE=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.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)}},zE=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}},PE=["cols","rows"],Nr=0,IE=class extends ht{constructor(e){super(),this._core=this._register(new RE(e)),this._addonManager=this._register(new ME),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,a)=>{this._checkReadonlyOptions(s),this._core.options[s]=a};for(let s in this._core.options){let a={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,a)}}_checkReadonlyOptions(e){if(PE.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 OE(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new zE(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 LE(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,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}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
75
+ `,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 Hf.get()},set promptLabel(e){Hf.set(e)},get tooMuchOutput(){return Uf.get()},set tooMuchOutput(e){Uf.set(e)}}}_verifyIntegers(...e){for(Nr of e)if(Nr===1/0||isNaN(Nr)||Nr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Nr of e)if(Nr&&(Nr===1/0||isNaN(Nr)||Nr%1!==0||Nr<0))throw new Error("This API only accepts positive integers")}};/**
76
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
77
+ * @license MIT
78
+ *
79
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
80
+ * @license MIT
81
+ *
82
+ * Originally forked from (with the author's permission):
83
+ * Fabrice Bellard's javascript vt100 for jslinux:
84
+ * http://bellard.org/jslinux/
85
+ * Copyright (c) 2011 Fabrice Bellard
86
+ */var HE=2,UE=1,$E=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(){var _;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)==null?void 0:_.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),a=Math.max(0,parseInt(i.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),c={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},h=c.top+c.bottom,p=c.right+c.left,d=s-h,x=a-p-t;return{cols:Math.max(HE,Math.floor(x/e.css.cell.width)),rows:Math.max(UE,Math.floor(d/e.css.cell.height))}}};/**
87
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
88
+ * @license MIT
89
+ *
90
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
91
+ * @license MIT
92
+ *
93
+ * Originally forked from (with the author's permission):
94
+ * Fabrice Bellard's javascript vt100 for jslinux:
95
+ * http://bellard.org/jslinux/
96
+ * Copyright (c) 2011 Fabrice Bellard
97
+ */var Ki=0,Vi=0,Xi=0,mi=0,dn;(e=>{function t(a,o,c,h){return h!==void 0?`#${ca(a)}${ca(o)}${ca(c)}${ca(h)}`:`#${ca(a)}${ca(o)}${ca(c)}`}e.toCss=t;function i(a,o,c,h=255){return(a<<24|o<<16|c<<8|h)>>>0}e.toRgba=i;function s(a,o,c,h){return{css:e.toCss(a,o,c,h),rgba:e.toRgba(a,o,c,h)}}e.toColor=s})(dn||(dn={}));var FE;(e=>{function t(p,d){if(mi=(d.rgba&255)/255,mi===1)return{css:d.css,rgba:d.rgba};let x=d.rgba>>24&255,_=d.rgba>>16&255,b=d.rgba>>8&255,v=p.rgba>>24&255,S=p.rgba>>16&255,N=p.rgba>>8&255;Ki=v+Math.round((x-v)*mi),Vi=S+Math.round((_-S)*mi),Xi=N+Math.round((b-N)*mi);let M=dn.toCss(Ki,Vi,Xi),E=dn.toRgba(Ki,Vi,Xi);return{css:M,rgba:E}}e.blend=t;function i(p){return(p.rgba&255)===255}e.isOpaque=i;function s(p,d,x){let _=vu.ensureContrastRatio(p.rgba,d.rgba,x);if(_)return dn.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let d=(p.rgba|255)>>>0;return[Ki,Vi,Xi]=vu.toChannels(d),{css:dn.toCss(Ki,Vi,Xi),rgba:d}}e.opaque=a;function o(p,d){return mi=Math.round(d*255),[Ki,Vi,Xi]=vu.toChannels(p.rgba),{css:dn.toCss(Ki,Vi,Xi,mi),rgba:dn.toRgba(Ki,Vi,Xi,mi)}}e.opacity=o;function c(p,d){return mi=p.rgba&255,o(p,mi*d/255)}e.multiplyOpacity=c;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(FE||(FE={}));var rn;(e=>{let t,i;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Ki=parseInt(a.slice(1,2).repeat(2),16),Vi=parseInt(a.slice(2,3).repeat(2),16),Xi=parseInt(a.slice(3,4).repeat(2),16),dn.toColor(Ki,Vi,Xi);case 5:return Ki=parseInt(a.slice(1,2).repeat(2),16),Vi=parseInt(a.slice(2,3).repeat(2),16),Xi=parseInt(a.slice(3,4).repeat(2),16),mi=parseInt(a.slice(4,5).repeat(2),16),dn.toColor(Ki,Vi,Xi,mi);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Ki=parseInt(o[1]),Vi=parseInt(o[2]),Xi=parseInt(o[3]),mi=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),dn.toColor(Ki,Vi,Xi,mi);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ki,Vi,Xi,mi]=t.getImageData(0,0,1,1).data,mi!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:dn.toRgba(Ki,Vi,Xi,mi),css:a}}e.toColor=s})(rn||(rn={}));var bn;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,a,o){let c=s/255,h=a/255,p=o/255,d=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),x=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return d*.2126+x*.7152+_*.0722}e.relativeLuminance2=i})(bn||(bn={}));var vu;(e=>{function t(c,h){if(mi=(h&255)/255,mi===1)return h;let p=h>>24&255,d=h>>16&255,x=h>>8&255,_=c>>24&255,b=c>>16&255,v=c>>8&255;return Ki=_+Math.round((p-_)*mi),Vi=b+Math.round((d-b)*mi),Xi=v+Math.round((x-v)*mi),dn.toRgba(Ki,Vi,Xi)}e.blend=t;function i(c,h,p){let d=bn.relativeLuminance(c>>8),x=bn.relativeLuminance(h>>8);if(es(d,x)<p){if(x<d){let v=s(c,h,p),S=es(d,bn.relativeLuminance(v>>8));if(S<p){let N=a(c,h,p),M=es(d,bn.relativeLuminance(N>>8));return S>M?v:N}return v}let _=a(c,h,p),b=es(d,bn.relativeLuminance(_>>8));if(b<p){let v=s(c,h,p),S=es(d,bn.relativeLuminance(v>>8));return b>S?_:v}return _}}e.ensureContrastRatio=i;function s(c,h,p){let d=c>>24&255,x=c>>16&255,_=c>>8&255,b=h>>24&255,v=h>>16&255,S=h>>8&255,N=es(bn.relativeLuminance2(b,v,S),bn.relativeLuminance2(d,x,_));for(;N<p&&(b>0||v>0||S>0);)b-=Math.max(0,Math.ceil(b*.1)),v-=Math.max(0,Math.ceil(v*.1)),S-=Math.max(0,Math.ceil(S*.1)),N=es(bn.relativeLuminance2(b,v,S),bn.relativeLuminance2(d,x,_));return(b<<24|v<<16|S<<8|255)>>>0}e.reduceLuminance=s;function a(c,h,p){let d=c>>24&255,x=c>>16&255,_=c>>8&255,b=h>>24&255,v=h>>16&255,S=h>>8&255,N=es(bn.relativeLuminance2(b,v,S),bn.relativeLuminance2(d,x,_));for(;N<p&&(b<255||v<255||S<255);)b=Math.min(255,b+Math.ceil((255-b)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),N=es(bn.relativeLuminance2(b,v,S),bn.relativeLuminance2(d,x,_));return(b<<24|v<<16|S<<8|255)>>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(vu||(vu={}));function ca(e){let t=e.toString(16);return t.length<2?"0"+t:t}function es(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var qE=Object.freeze((()=>{let e=[rn.toColor("#2e3436"),rn.toColor("#cc0000"),rn.toColor("#4e9a06"),rn.toColor("#c4a000"),rn.toColor("#3465a4"),rn.toColor("#75507b"),rn.toColor("#06989a"),rn.toColor("#d3d7cf"),rn.toColor("#555753"),rn.toColor("#ef2929"),rn.toColor("#8ae234"),rn.toColor("#fce94f"),rn.toColor("#729fcf"),rn.toColor("#ad7fa8"),rn.toColor("#34e2e2"),rn.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],a=t[i/6%6|0],o=t[i%6];e.push({css:dn.toCss(s,a,o),rgba:dn.toRgba(s,a,o)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:dn.toCss(s,s,s),rgba:dn.toRgba(s,s,s)})}return e})());function sv(e,t,i){return Math.max(t,Math.min(e,i))}function WE(e){switch(e){case"&":return"&amp;";case"<":return"&lt;"}return e}var y0=class{constructor(e){this._buffer=e}serialize(e,t){let i=this._buffer.getNullCell(),s=this._buffer.getNullCell(),a=i,o=e.start.y,c=e.end.y,h=e.start.x,p=e.end.x;this._beforeSerialize(c-o,o,c);for(let d=o;d<=c;d++){let x=this._buffer.getLine(d);if(x){let _=d===e.start.y?h:0,b=d===e.end.y?p:x.length;for(let v=_;v<b;v++){let S=x.getCell(v,a===i?s:i);if(!S){console.warn(`Can't get cell at row=${d}, col=${v}`);continue}this._nextCell(S,a,d,v),a=S}}this._rowEnd(d,d===c)}return this._afterSerialize(),this._serializeString(t)}_nextCell(e,t,i,s){}_rowEnd(e,t){}_beforeSerialize(e,t,i){}_afterSerialize(){}_serializeString(e){return""}};function S0(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function ts(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function w0(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&e.isOverline()===t.isOverline()&&e.isBlink()===t.isBlink()&&e.isInvisible()===t.isInvisible()&&e.isItalic()===t.isItalic()&&e.isDim()===t.isDim()&&e.isStrikethrough()===t.isStrikethrough()}var GE=class extends y0{constructor(e,t){super(e),this._terminal=t,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(e,t,i){this._allRows=new Array(e),this._lastContentCursorRow=t,this._lastCursorRow=t,this._firstRow=t}_rowEnd(e,t){var s;this._nullCellCount>0&&!ts(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let i="";if(!t){e-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let a=this._buffer.getLine(e),o=this._buffer.getLine(e+1);if(!o.isWrapped)i=`\r
98
+ `,this._lastCursorRow=e+1,this._lastCursorCol=0;else{i="";let c=a.getCell(a.length-1,this._thisRowLastChar),h=a.getCell(a.length-2,this._thisRowLastSecondChar),p=o.getCell(0,this._nextRowFirstChar),d=p.getWidth()>1,x=!1;(p.getChars()&&d?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&ts(c,p)&&(x=!0),d&&(h.getChars()||h.getWidth()===0)&&ts(c,p)&&ts(h,p)&&(x=!0)),x||(i="-".repeat(this._nullCellCount+1),i+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(i+="\x1B[A",i+=`\x1B[${a.length-this._nullCellCount}C`,i+=`\x1B[${this._nullCellCount}X`,i+=`\x1B[${a.length-this._nullCellCount}D`,i+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=i,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let i=[],s=!S0(e,t),a=!ts(e,t),o=!w0(e,t);if(s||a||o)if(e.isAttributeDefault())t.isAttributeDefault()||i.push(0);else{if(s){let c=e.getFgColor();e.isFgRGB()?i.push(38,2,c>>>16&255,c>>>8&255,c&255):e.isFgPalette()?c>=16?i.push(38,5,c):i.push(c&8?90+(c&7):30+(c&7)):i.push(39)}if(a){let c=e.getBgColor();e.isBgRGB()?i.push(48,2,c>>>16&255,c>>>8&255,c&255):e.isBgPalette()?c>=16?i.push(48,5,c):i.push(c&8?100+(c&7):40+(c&7)):i.push(49)}o&&(e.isInverse()!==t.isInverse()&&i.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&i.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&i.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&i.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&i.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&i.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&i.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&i.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&i.push(e.isStrikethrough()?9:29))}return i}_nextCell(e,t,i,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,this._cursorStyle);if(a?!ts(this._cursorStyle,e):o.length>0){this._nullCellCount>0&&(ts(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=i,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${o.join(";")}m`;let c=this._buffer.getLine(i);c!==void 0&&(c.getCell(s,this._cursorStyle),this._cursorStyleRow=i,this._cursorStyleCol=s)}a?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(ts(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=i,this._lastContentCursorCol=this._lastCursorCol=s+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let i="";for(let o=0;o<t;o++)i+=this._allRows[o],o+1<t&&(i+=this._allRowSeparators[o]);if(!e){let o=this._buffer.baseY+this._buffer.cursorY,c=this._buffer.cursorX,h=o!==this._lastCursorRow||c!==this._lastCursorCol,p=d=>{d>0?i+=`\x1B[${d}C`:d<0&&(i+=`\x1B[${-d}D`)};h&&((d=>{d>0?i+=`\x1B[${d}B`:d<0&&(i+=`\x1B[${-d}A`)})(o-this._lastCursorRow),p(c-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,a=this._diffStyle(s,this._cursorStyle);return a.length>0&&(i+=`\x1B[${a.join(";")}m`),i}},YE=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,i){let s=t.length,a=i===void 0?s:sv(i+e.rows,0,s);return this._serializeBufferByRange(e,t,{start:s-a,end:s-1},!1)}_serializeBufferByRange(e,t,i,s){return new GE(t,e).serialize({start:{x:0,y:typeof i.start=="number"?i.start:i.start.line},end:{x:e.cols,y:typeof i.end=="number"?i.end:i.end.line}},s)}_serializeBufferAsHTML(e,t){var h;let i=e.buffer.active,s=new KE(i,e,t),a=t.onlySelection??!1,o=t.range;if(o)return s.serialize({start:{x:o.startCol,y:(o.startLine,o.startLine)},end:{x:e.cols,y:(o.endLine,o.endLine)}});if(!a){let p=i.length,d=t.scrollback,x=d===void 0?p:sv(d+e.rows,0,p);return s.serialize({start:{x:0,y:p-x},end:{x:e.cols,y:p-1}})}let c=(h=this._terminal)==null?void 0:h.getSelectionPosition();return c!==void 0?s.serialize({start:{x:c.start.x,y:c.start.y},end:{x:c.end.x,y:c.end.y}}):""}_serializeModes(e){let t="",i=e.modes;if(i.applicationCursorKeysMode&&(t+="\x1B[?1h"),i.applicationKeypadMode&&(t+="\x1B[?66h"),i.bracketedPasteMode&&(t+="\x1B[?2004h"),i.insertMode&&(t+="\x1B[4h"),i.originMode&&(t+="\x1B[?6h"),i.reverseWraparoundMode&&(t+="\x1B[?45h"),i.sendFocusMode&&(t+="\x1B[?1004h"),i.wraparoundMode===!1&&(t+="\x1B[?7l"),i.mouseTrackingMode!=="none")switch(i.mouseTrackingMode){case"x10":t+="\x1B[?9h";break;case"vt200":t+="\x1B[?1000h";break;case"drag":t+="\x1B[?1002h";break;case"any":t+="\x1B[?1003h";break}return t}serialize(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let t=e!=null&&e.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e==null?void 0:e.scrollback);if(!(e!=null&&e.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let i=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${i}`}return e!=null&&e.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},KE=class extends y0{constructor(e,t,i){super(e),this._terminal=t,this._options=i,this._currentRow="",this._htmlContent="",t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=qE}_padStart(e,t,i){return t=t>>0,i=i??" ",e.length>t?e:(t-=e.length,t>i.length&&(i+=i.repeat(t/i.length)),i.slice(0,t)+e)}_beforeSerialize(e,t,i){var c,h;this._htmlContent+="<html><body><!--StartFragment--><pre>";let s="#000000",a="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=((c=this._terminal.options.theme)==null?void 0:c.foreground)??"#ffffff",a=((h=this._terminal.options.theme)==null?void 0:h.background)??"#000000");let o=[];o.push("color: "+s+";"),o.push("background-color: "+a+";"),o.push("font-family: "+this._terminal.options.fontFamily+";"),o.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+o.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre><!--EndFragment--></body></html>"}_rowEnd(e,t){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(e,t){let i=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return"#"+[i>>16&255,i>>8&255,i&255].map(s=>this._padStart(s.toString(16),2,"0")).join("");if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[i].css}_diffStyle(e,t){let i=[],s=!S0(e,t),a=!ts(e,t),o=!w0(e,t);if(s||a||o){let c=this._getHexColor(e,!0);c&&i.push("color: "+c+";");let h=this._getHexColor(e,!1);return h&&i.push("background-color: "+h+";"),e.isInverse()&&i.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&i.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?i.push("text-decoration: overline underline;"):e.isUnderline()?i.push("text-decoration: underline;"):e.isOverline()&&i.push("text-decoration: overline;"),e.isBlink()&&i.push("text-decoration: blink;"),e.isInvisible()&&i.push("visibility: hidden;"),e.isItalic()&&i.push("font-style: italic;"),e.isDim()&&i.push("opacity: 0.5;"),e.isStrikethrough()&&i.push("text-decoration: line-through;"),i}}_nextCell(e,t,i,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,t);o&&(this._currentRow+=o.length===0?"</span><span>":"</span><span style='"+o.join(" ")+"'>"),a?this._currentRow+=" ":this._currentRow+=WE(e.getChars())}_serializeString(){return this._htmlContent}};const VE="__OWS_FRESH_SESSION__",il="[REDACTED]",XE=[[/(authorization\s*:\s*bearer\s+)[^\s'"\x1b]+/gi,`$1${il}`],[/(\bbearer\s+)[A-Za-z0-9._-]{12,}/gi,`$1${il}`],[/(\btoken=)[^\s'"&\x1b]+/gi,`$1${il}`],[/(OWS_PASSPHRASE\s*[=:]\s*)[^\s'"\x1b]+/gi,`$1${il}`],[/(--passphrase[=\s]+)[^\s'"\x1b]+/gi,`$1${il}`],[/(passphrase["']?\s*[:=]\s*["']?)[^\s'"\x1b]+/gi,`$1${il}`]];function av(e){let t=e;for(const[i,s]of XE)t=t.replace(i,s);return t}const lv="codex features enable image_generation";function ZE(e,t){return e!=="cartoon"||!t?!1:!(t.codex.installed&&t.codex.imageGeneration==="enabled")}const QE={background:"#F0EBE1",foreground:"#2C1810",cursor:"#8B4513",cursorAccent:"#F0EBE1",selectionBackground:"#D4C5B0",selectionForeground:"#2C1810",black:"#2C1810",red:"#A63D40",green:"#4A7A4A",yellow:"#8B6914",blue:"#4A6FA5",magenta:"#7B4B8A",cyan:"#3D7A7A",white:"#E6DDD0",brightBlack:"#8B7355",brightRed:"#B85C5C",brightGreen:"#5A8A5A",brightYellow:"#A07D1C",brightBlue:"#5A82BA",brightMagenta:"#8E5D9F",brightCyan:"#5A8F8F",brightWhite:"#4A3728"},JE="plotlink-terminal",eN=1,Is="scrollback",ov=10*1024*1024;function Jp(){return new Promise((e,t)=>{const i=indexedDB.open(JE,eN);i.onupgradeneeded=()=>{const s=i.result;s.objectStoreNames.contains(Is)||s.createObjectStore(Is)},i.onsuccess=()=>e(i.result),i.onerror=()=>t(i.error)})}async function nl(e,t){const i=t.length>ov?t.slice(-ov):t,s=await Jp();return new Promise((a,o)=>{const c=s.transaction(Is,"readwrite");c.objectStore(Is).put(i,e),c.oncomplete=()=>{s.close(),a()},c.onerror=()=>{s.close(),o(c.error)}})}async function tN(e){const t=await Jp();return new Promise((i,s)=>{const o=t.transaction(Is,"readonly").objectStore(Is).get(e);o.onsuccess=()=>{t.close(),i(o.result??null)},o.onerror=()=>{t.close(),s(o.error)}})}async function pf(e){const t=await Jp();return new Promise((i,s)=>{const a=t.transaction(Is,"readwrite");a.objectStore(Is).delete(e),a.oncomplete=()=>{t.close(),i()},a.onerror=()=>{t.close(),s(a.error)}})}const Ii=new Map;function iN({token:e,storyName:t,authFetch:i,onSelectStory:s,onDestroySession:a,onArchiveStory:o,confirmedStories:c,renameRef:h,bypassStories:p,agentProviders:d,readiness:x,contentType:_,needsProviderRepair:b,onRepairProvider:v}){const S=w.useRef(null),N=w.useRef(i),[M,E]=w.useState([]),[H,z]=w.useState(new Set),[R,te]=w.useState(null),[L,I]=w.useState(null),[re,_e]=w.useState(!1),[j,J]=w.useState(!1),F=ZE(_,x),G=!!b,Y=w.useRef(()=>{});w.useEffect(()=>{N.current=i},[i]);const U=w.useCallback(X=>{var ye;const{width:ue}=X.container.getBoundingClientRect();if(!(ue<50))try{X.fit.fit(),((ye=X.ws)==null?void 0:ye.readyState)===WebSocket.OPEN&&X.ws.send(JSON.stringify({type:"resize",cols:X.term.cols,rows:X.term.rows}))}catch{}},[]),A=w.useCallback(X=>{for(const[ue,ye]of Ii)ye.container.style.display=ue===X?"block":"none";if(X){const ue=Ii.get(X);ue&&setTimeout(()=>U(ue),50)}},[U]),q=w.useRef({});w.useEffect(()=>{q.current=p||{}},[p]);const $=w.useRef({});w.useEffect(()=>{$.current=d||{}},[d]);const be=w.useCallback((X,ue,ye)=>{const fe=window.location.protocol==="https:"?"wss:":"ws:",Pe=q.current[X]?"&bypass=true":"",$e=$.current[X],Oe=$e?`&provider=${encodeURIComponent($e)}`:"",Ke=new WebSocket(`${fe}//${window.location.host}/ws/terminal?story=${encodeURIComponent(X)}&token=${e}&resume=${ye}${Pe}${Oe}`);Ke.onopen=()=>{ue.connected=!0,ue._retried=!1,z(tt=>{const Fe=new Set(tt);return Fe.delete(X),Fe}),Ke.send(JSON.stringify({type:"resize",cols:ue.term.cols,rows:ue.term.rows}))};let ft=!0;Ke.onmessage=tt=>{if(ft&&(ft=!1,typeof tt.data=="string"&&tt.data===VE)){ue.term.reset(),pf(X).catch(()=>{});return}ue.term.write(typeof tt.data=="string"?av(tt.data):tt.data)},Ke.onclose=tt=>{if(ue.connected=!1,ue.ws===Ke){ue.ws=null;try{const Fe=ue.serialize.serialize();nl(X,Fe).catch(()=>{})}catch{}if(tt.code===4e3&&!ue._retried){ue._retried=!0,ue.term.write(`\r
99
+ \x1B[33m[Resume failed — starting fresh session...]\x1B[0m\r
100
+ `),Y.current(X,ue,!1);return}z(Fe=>new Set(Fe).add(X))}},ue.term.onData(tt=>{Ke.readyState===WebSocket.OPEN&&Ke.send(tt)}),ue.ws=Ke},[e]);w.useEffect(()=>{Y.current=be},[be]);const T=w.useCallback(async(X,ue)=>{if(!S.current||Ii.has(X))return;const{resume:ye=!1,autoConnect:fe=!0}=ue??{},Pe=document.createElement("div");Pe.style.width="100%",Pe.style.height="100%",Pe.style.display="none",Pe.style.paddingLeft="10px",Pe.style.boxSizing="border-box",S.current.appendChild(Pe);const $e=new IE({cols:80,scrollback:5e3,fontSize:13,fontFamily:'"Geist Mono", ui-monospace, monospace',lineHeight:1.05,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",theme:QE,allowTransparency:!1,drawBoldTextInBrightColors:!1,minimumContrastRatio:7}),Oe=new $E,Ke=new YE;$e.loadAddon(Oe),$e.loadAddon(Ke),$e.open(Pe);const ft={term:$e,fit:Oe,serialize:Ke,ws:null,container:Pe,observer:null,connected:!1},tt=new ResizeObserver(()=>{var ze;const{width:Fe}=Pe.getBoundingClientRect();if(!(Fe<50))try{Oe.fit(),((ze=ft.ws)==null?void 0:ze.readyState)===WebSocket.OPEN&&ft.ws.send(JSON.stringify({type:"resize",cols:$e.cols,rows:$e.rows}))}catch{}});tt.observe(Pe),ft.observer=tt,Ii.set(X,ft),E(Fe=>[...Fe,X]);try{const Fe=await tN(X);if(Fe){const ze=av(Fe);$e.write(ze),ze!==Fe&&nl(X,ze).catch(()=>{})}}catch{}fe?be(X,ft,ye):z(Fe=>new Set(Fe).add(X)),setTimeout(()=>U(ft),50)},[be,U]),D=w.useCallback(async(X,ue)=>{const ye=Ii.get(X);ye&&(ye.ws&&(ye.ws.close(),ye.ws=null),ue||(await N.current(`/api/terminal/${encodeURIComponent(X)}`,{method:"DELETE"}).catch(()=>{}),ye.term.clear()),be(X,ye,ue))},[be]),V=w.useCallback(X=>{const ue=Ii.get(X);if(ue){try{const ye=ue.serialize.serialize();nl(X,ye).catch(()=>{})}catch{}ue.observer.disconnect(),ue.ws&&ue.ws.close(),ue.term.dispose(),ue.container.remove(),Ii.delete(X),E(ye=>ye.filter(fe=>fe!==X)),z(ye=>{const fe=new Set(ye);return fe.delete(X),fe}),i(`/api/terminal/${encodeURIComponent(X)}`,{method:"DELETE"}).catch(()=>{}),a==null||a(X)}},[i,a]),k=w.useCallback(X=>{var ye;const ue=Ii.get(X);ue&&(((ye=ue.ws)==null?void 0:ye.readyState)===WebSocket.OPEN&&ue.ws.send(`exit
101
+ `),pf(X).catch(()=>{}),ue.observer.disconnect(),ue.ws&&ue.ws.close(),ue.term.dispose(),ue.container.remove(),Ii.delete(X),E(fe=>fe.filter(Pe=>Pe!==X)),z(fe=>{const Pe=new Set(fe);return Pe.delete(X),Pe}),i(`/api/terminal/${encodeURIComponent(X)}/discard`,{method:"DELETE"}).catch(()=>{}),a==null||a(X))},[i,a]),le=w.useCallback(async(X,ue,ye)=>{const fe=Ii.get(X);if(!fe||Ii.has(ue)||!(await N.current("/api/terminal/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:X,newName:ue,...ye??{}})})).ok)return!1;Ii.delete(X),Ii.set(ue,fe);try{const $e=fe.serialize.serialize();await pf(X),await nl(ue,$e)}catch{}return E($e=>$e.map(Oe=>Oe===X?ue:Oe)),z($e=>{if(!$e.has(X))return $e;const Oe=new Set($e);return Oe.delete(X),Oe.add(ue),Oe}),(fe.connected||fe.ws)&&(await N.current(`/api/terminal/${encodeURIComponent(ue)}`,{method:"DELETE"}).catch(()=>{}),fe.ws&&(fe.ws.close(),fe.ws=null),Y.current(ue,fe,!0)),!0},[]);w.useEffect(()=>(h&&(h.current=le),()=>{h&&(h.current=null)}),[h,le]),w.useEffect(()=>{if(t){if(F){A(null);return}if(G){A(null);return}Ii.has(t)?A(t):N.current(`/api/terminal/session/${encodeURIComponent(t)}`).then(X=>X.ok?X.json():null).then(X=>{if(!Ii.has(t)){const ue=(X==null?void 0:X.sessionId)&&!(X!=null&&X.running);T(t,{autoConnect:!ue}),A(t)}}).catch(()=>{Ii.has(t)||(T(t),A(t))})}},[t,T,A,F,G]),w.useEffect(()=>{const X=setInterval(()=>{for(const[ue,ye]of Ii)if(ye.connected)try{const fe=ye.serialize.serialize();nl(ue,fe).catch(()=>{})}catch{}},3e4);return()=>clearInterval(X)},[]),w.useEffect(()=>()=>{for(const[X,ue]of Ii){try{const ye=ue.serialize.serialize();nl(X,ye).catch(()=>{})}catch{}ue.observer.disconnect(),ue.ws&&ue.ws.close(),ue.term.dispose(),ue.container.remove(),N.current(`/api/terminal/${encodeURIComponent(X)}`,{method:"DELETE"}).catch(()=>{})}Ii.clear()},[]);const ne=t?H.has(t):!1,de=M.length===0;return f.jsxs("div",{className:"h-full flex flex-col",children:[!de&&f.jsxs("div",{className:"px-2 py-1 border-b border-border flex items-center gap-1 overflow-x-auto",children:[M.map(X=>f.jsxs("div",{onClick:()=>s==null?void 0:s(X),className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono cursor-pointer ${X===t?"bg-accent/10 text-accent":"text-muted hover:text-foreground"}`,children:[f.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${H.has(X)?"bg-amber-500":X===t?"bg-green-600":"bg-muted/50"}`}),f.jsx("span",{className:`truncate max-w-[120px] ${X.startsWith("_new_")?"italic":""}`,children:X.startsWith("_new_")?"Untitled":X}),f.jsx("button",{onClick:ue=>{ue.stopPropagation(),X.startsWith("_new_")?te(X):V(X)},className:"ml-0.5 text-muted hover:text-error text-[10px] leading-none",title:"Close terminal",children:"×"})]},X)),t!=null&&t.startsWith("_new_")?f.jsx("button",{onClick:()=>te(t),className:"ml-auto px-2 py-0.5 text-xs text-error hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Cancel ×"}):t&&o&&(c!=null&&c.has(t))?f.jsx("button",{onClick:()=>I(t),className:"ml-auto px-2 py-0.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Archive"}):null]}),f.jsxs("div",{className:"relative flex-1 min-h-0",children:[f.jsx("div",{ref:S,className:"h-full"}),de&&!F&&!G&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted",children:f.jsxs("div",{className:"text-center",children:[f.jsx("p",{className:"text-lg font-serif",children:"Select a story on the left menu"}),f.jsx("p",{className:"text-sm mt-1",children:"to start an AI Writer session"})]})}),F&&f.jsx("div",{"data-testid":"cartoon-launch-blocked",className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:f.jsxs("div",{className:"space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-md",children:[f.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Cartoon agent can't launch yet"}),f.jsx("p",{className:"text-xs text-muted",children:"This is a cartoon story. The writing agent needs Codex with image generation enabled before it can start, because the clean-image step relies on image generation support."}),x&&!x.codex.installed?f.jsxs("p",{className:"text-xs text-amber-700",children:["Codex was not detected. Install the Codex CLI and sign in (e.g. ",f.jsx("span",{className:"font-mono",children:"npm i -g @openai/codex"})," then"," ",f.jsx("span",{className:"font-mono",children:"codex login"}),"), then reopen this story."]}):wu(x)?f.jsxs("p",{className:"text-xs text-amber-700","data-testid":"codex-auth-unknown-launch",children:[$p," Then reopen this story."]}):f.jsxs("div",{className:"space-y-1",children:[f.jsx("p",{className:"text-xs text-amber-700",children:"Codex is installed but image generation isn't enabled. Enable it, then reopen this story:"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("code",{className:"flex-1 truncate rounded border border-border bg-surface px-1.5 py-1 text-left text-[10px] font-mono text-foreground",children:lv}),f.jsx("button",{type:"button","data-testid":"copy-codex-enable-launch",onClick:async()=>{try{await navigator.clipboard.writeText(lv),_e(!0),setTimeout(()=>_e(!1),2e3)}catch{}},className:"rounded border border-border px-2 py-1 text-[10px] text-muted hover:border-accent hover:text-accent transition-colors",children:re?"Copied!":"Copy"})]})]})]})}),G&&!F&&f.jsx("div",{"data-testid":"legacy-cartoon-provider-repair",className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:f.jsxs("div",{className:"space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-md",children:[f.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Set this cartoon story's provider"}),f.jsx("p",{className:"text-xs text-muted",children:"This cartoon story was created before provider tracking, so it has no provider recorded and would launch with Claude — which can't generate the clean images cartoons need. Set this story's provider to Codex to continue."}),f.jsx("p",{className:"text-[11px] text-muted",children:"Only this story is changed. Other stories and fiction are not affected."}),f.jsx("button",{type:"button","data-testid":"repair-provider-codex",disabled:j,onClick:async()=>{if(!j){J(!0);try{await(v==null?void 0:v())}finally{J(!1)}}},className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:j?"Setting…":"Set this story's provider to Codex"})]})}),R&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:f.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[f.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Discard this session?"}),f.jsx("p",{className:"text-xs text-muted",children:"This session will be lost — your AI hasn't created a story structure yet."}),f.jsxs("div",{className:"flex items-center justify-center gap-2",children:[f.jsx("button",{onClick:()=>te(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),f.jsx("button",{onClick:()=>{const X=R;te(null),k(X)},className:"px-4 py-1.5 bg-error text-white text-sm rounded hover:opacity-80",children:"Discard"})]})]})}),L&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:f.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[f.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Archive this story?"}),f.jsx("p",{className:"text-xs text-muted",children:"You can restore it later from the Archives view."}),f.jsxs("div",{className:"flex items-center justify-center gap-2",children:[f.jsx("button",{onClick:()=>I(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),f.jsx("button",{onClick:async()=>{const X=L;I(null);try{(await N.current("/api/stories/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:X})})).ok&&(V(X),o==null||o(X))}catch{}},className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Archive"})]})]})}),ne&&t&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:f.jsxs("div",{className:"text-center space-y-3",children:[f.jsx("p",{className:"text-sm font-serif text-foreground",children:"Terminal disconnected"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>D(t,!0),className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Resume Session"}),f.jsx("button",{onClick:()=>D(t,!1),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Start Fresh"})]}),f.jsx("p",{className:"text-xs text-muted",children:"Resume continues your previous Claude conversation"})]})})]})]})}function nN(e,t){const i={};return(e[e.length-1]===""?[...e,""]:e).join((i.padRight?" ":"")+","+(i.padLeft===!1?"":" ")).trim()}const rN=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,sN=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,aN={};function cv(e,t){return(aN.jsx?sN:rN).test(e)}const lN=/[ \t\n\f\r]/g;function oN(e){return typeof e=="object"?e.type==="text"?uv(e.value):!1:uv(e)}function uv(e){return e.replace(lN,"")===""}class Wo{constructor(t,i,s){this.normal=i,this.property=t,s&&(this.space=s)}}Wo.prototype.normal={};Wo.prototype.property={};Wo.prototype.space=void 0;function C0(e,t){const i={},s={};for(const a of e)Object.assign(i,a.property),Object.assign(s,a.normal);return new Wo(i,s,t)}function wp(e){return e.toLowerCase()}class On{constructor(t,i){this.attribute=i,this.property=t}}On.prototype.attribute="";On.prototype.booleanish=!1;On.prototype.boolean=!1;On.prototype.commaOrSpaceSeparated=!1;On.prototype.commaSeparated=!1;On.prototype.defined=!1;On.prototype.mustUseProperty=!1;On.prototype.number=!1;On.prototype.overloadedBoolean=!1;On.prototype.property="";On.prototype.spaceSeparated=!1;On.prototype.space=void 0;let cN=0;const ot=ya(),Di=ya(),Cp=ya(),Se=ya(),Jt=ya(),ol=ya(),Gn=ya();function ya(){return 2**++cN}const kp=Object.freeze(Object.defineProperty({__proto__:null,boolean:ot,booleanish:Di,commaOrSpaceSeparated:Gn,commaSeparated:ol,number:Se,overloadedBoolean:Cp,spaceSeparated:Jt},Symbol.toStringTag,{value:"Module"})),mf=Object.keys(kp);class em extends On{constructor(t,i,s,a){let o=-1;if(super(t,i),hv(this,"space",a),typeof s=="number")for(;++o<mf.length;){const c=mf[o];hv(this,mf[o],(s&kp[c])===kp[c])}}}em.prototype.defined=!0;function hv(e,t,i){i&&(e[t]=i)}function ml(e){const t={},i={};for(const[s,a]of Object.entries(e.properties)){const o=new em(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(o.mustUseProperty=!0),t[s]=o,i[wp(s)]=s,i[wp(o.attribute)]=s}return new Wo(t,i,e.space)}const k0=ml({properties:{ariaActiveDescendant:null,ariaAtomic:Di,ariaAutoComplete:null,ariaBusy:Di,ariaChecked:Di,ariaColCount:Se,ariaColIndex:Se,ariaColSpan:Se,ariaControls:Jt,ariaCurrent:null,ariaDescribedBy:Jt,ariaDetails:null,ariaDisabled:Di,ariaDropEffect:Jt,ariaErrorMessage:null,ariaExpanded:Di,ariaFlowTo:Jt,ariaGrabbed:Di,ariaHasPopup:null,ariaHidden:Di,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Jt,ariaLevel:Se,ariaLive:null,ariaModal:Di,ariaMultiLine:Di,ariaMultiSelectable:Di,ariaOrientation:null,ariaOwns:Jt,ariaPlaceholder:null,ariaPosInSet:Se,ariaPressed:Di,ariaReadOnly:Di,ariaRelevant:null,ariaRequired:Di,ariaRoleDescription:Jt,ariaRowCount:Se,ariaRowIndex:Se,ariaRowSpan:Se,ariaSelected:Di,ariaSetSize:Se,ariaSort:null,ariaValueMax:Se,ariaValueMin:Se,ariaValueNow:Se,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function E0(e,t){return t in e?e[t]:t}function N0(e,t){return E0(e,t.toLowerCase())}const uN=ml({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ol,acceptCharset:Jt,accessKey:Jt,action:null,allow:null,allowFullScreen:ot,allowPaymentRequest:ot,allowUserMedia:ot,alt:null,as:null,async:ot,autoCapitalize:null,autoComplete:Jt,autoFocus:ot,autoPlay:ot,blocking:Jt,capture:null,charSet:null,checked:ot,cite:null,className:Jt,cols:Se,colSpan:null,content:null,contentEditable:Di,controls:ot,controlsList:Jt,coords:Se|ol,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ot,defer:ot,dir:null,dirName:null,disabled:ot,download:Cp,draggable:Di,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ot,formTarget:null,headers:Jt,height:Se,hidden:Cp,high:Se,href:null,hrefLang:null,htmlFor:Jt,httpEquiv:Jt,id:null,imageSizes:null,imageSrcSet:null,inert:ot,inputMode:null,integrity:null,is:null,isMap:ot,itemId:null,itemProp:Jt,itemRef:Jt,itemScope:ot,itemType:Jt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ot,low:Se,manifest:null,max:null,maxLength:Se,media:null,method:null,min:null,minLength:Se,multiple:ot,muted:ot,name:null,nonce:null,noModule:ot,noValidate:ot,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ot,optimum:Se,pattern:null,ping:Jt,placeholder:null,playsInline:ot,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ot,referrerPolicy:null,rel:Jt,required:ot,reversed:ot,rows:Se,rowSpan:Se,sandbox:Jt,scope:null,scoped:ot,seamless:ot,selected:ot,shadowRootClonable:ot,shadowRootDelegatesFocus:ot,shadowRootMode:null,shape:null,size:Se,sizes:null,slot:null,span:Se,spellCheck:Di,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Se,step:null,style:null,tabIndex:Se,target:null,title:null,translate:null,type:null,typeMustMatch:ot,useMap:null,value:Di,width:Se,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Jt,axis:null,background:null,bgColor:null,border:Se,borderColor:null,bottomMargin:Se,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ot,declare:ot,event:null,face:null,frame:null,frameBorder:null,hSpace:Se,leftMargin:Se,link:null,longDesc:null,lowSrc:null,marginHeight:Se,marginWidth:Se,noResize:ot,noHref:ot,noShade:ot,noWrap:ot,object:null,profile:null,prompt:null,rev:null,rightMargin:Se,rules:null,scheme:null,scrolling:Di,standby:null,summary:null,text:null,topMargin:Se,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Se,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ot,disableRemotePlayback:ot,prefix:null,property:null,results:Se,security:null,unselectable:null},space:"html",transform:N0}),hN=ml({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Gn,accentHeight:Se,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Se,amplitude:Se,arabicForm:null,ascent:Se,attributeName:null,attributeType:null,azimuth:Se,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Se,by:null,calcMode:null,capHeight:Se,className:Jt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Se,diffuseConstant:Se,direction:null,display:null,dur:null,divisor:Se,dominantBaseline:null,download:ot,dx:null,dy:null,edgeMode:null,editable:null,elevation:Se,enableBackground:null,end:null,event:null,exponent:Se,externalResourcesRequired:null,fill:null,fillOpacity:Se,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ol,g2:ol,glyphName:ol,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Se,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Se,horizOriginX:Se,horizOriginY:Se,id:null,ideographic:Se,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Se,k:Se,k1:Se,k2:Se,k3:Se,k4:Se,kernelMatrix:Gn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Se,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Se,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Se,overlineThickness:Se,paintOrder:null,panose1:null,path:null,pathLength:Se,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Jt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Se,pointsAtY:Se,pointsAtZ:Se,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Gn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Gn,rev:Gn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Gn,requiredFeatures:Gn,requiredFonts:Gn,requiredFormats:Gn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Se,specularExponent:Se,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Se,strikethroughThickness:Se,string:null,stroke:null,strokeDashArray:Gn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Se,strokeOpacity:Se,strokeWidth:null,style:null,surfaceScale:Se,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Gn,tabIndex:Se,tableValues:null,target:null,targetX:Se,targetY:Se,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Gn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Se,underlineThickness:Se,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Se,values:null,vAlphabetic:Se,vMathematical:Se,vectorEffect:null,vHanging:Se,vIdeographic:Se,version:null,vertAdvY:Se,vertOriginX:Se,vertOriginY:Se,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Se,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:E0}),T0=ml({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),j0=ml({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:N0}),A0=ml({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),dN={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},fN=/[A-Z]/g,dv=/-[a-z]/g,pN=/^data[-\w.:]+$/i;function mN(e,t){const i=wp(t);let s=t,a=On;if(i in e.normal)return e.property[e.normal[i]];if(i.length>4&&i.slice(0,4)==="data"&&pN.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(dv,_N);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!dv.test(o)){let c=o.replace(fN,gN);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=em}return new a(s,t)}function gN(e){return"-"+e.toLowerCase()}function _N(e){return e.charAt(1).toUpperCase()}const xN=C0([k0,uN,T0,j0,A0],"html"),tm=C0([k0,hN,T0,j0,A0],"svg");function bN(e){return e.join(" ").trim()}var rl={},gf,fv;function vN(){if(fv)return gf;fv=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,i=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,h=/^\s+|\s+$/g,p=`
102
+ `,d="/",x="*",_="",b="comment",v="declaration";function S(M,E){if(typeof M!="string")throw new TypeError("First argument must be a string");if(!M)return[];E=E||{};var H=1,z=1;function R(Y){var U=Y.match(t);U&&(H+=U.length);var A=Y.lastIndexOf(p);z=~A?Y.length-A:z+Y.length}function te(){var Y={line:H,column:z};return function(U){return U.position=new L(Y),_e(),U}}function L(Y){this.start=Y,this.end={line:H,column:z},this.source=E.source}L.prototype.content=M;function I(Y){var U=new Error(E.source+":"+H+":"+z+": "+Y);if(U.reason=Y,U.filename=E.source,U.line=H,U.column=z,U.source=M,!E.silent)throw U}function re(Y){var U=Y.exec(M);if(U){var A=U[0];return R(A),M=M.slice(A.length),U}}function _e(){re(i)}function j(Y){var U;for(Y=Y||[];U=J();)U!==!1&&Y.push(U);return Y}function J(){var Y=te();if(!(d!=M.charAt(0)||x!=M.charAt(1))){for(var U=2;_!=M.charAt(U)&&(x!=M.charAt(U)||d!=M.charAt(U+1));)++U;if(U+=2,_===M.charAt(U-1))return I("End of comment missing");var A=M.slice(2,U-2);return z+=2,R(A),M=M.slice(U),z+=2,Y({type:b,comment:A})}}function F(){var Y=te(),U=re(s);if(U){if(J(),!re(a))return I("property missing ':'");var A=re(o),q=Y({type:v,property:N(U[0].replace(e,_)),value:A?N(A[0].replace(e,_)):_});return re(c),q}}function G(){var Y=[];j(Y);for(var U;U=F();)U!==!1&&(Y.push(U),j(Y));return Y}return _e(),G()}function N(M){return M?M.replace(h,_):_}return gf=S,gf}var pv;function yN(){if(pv)return rl;pv=1;var e=rl&&rl.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(rl,"__esModule",{value:!0}),rl.default=i;const t=e(vN());function i(s,a){let o=null;if(!s||typeof s!="string")return o;const c=(0,t.default)(s),h=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:d,value:x}=p;h?a(d,x,p):x&&(o=o||{},o[d]=x)}),o}return rl}var go={},mv;function SN(){if(mv)return go;mv=1,Object.defineProperty(go,"__esModule",{value:!0}),go.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,i=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(d){return!d||i.test(d)||e.test(d)},c=function(d,x){return x.toUpperCase()},h=function(d,x){return"".concat(x,"-")},p=function(d,x){return x===void 0&&(x={}),o(d)?d:(d=d.toLowerCase(),x.reactCompat?d=d.replace(a,h):d=d.replace(s,h),d.replace(t,c))};return go.camelCase=p,go}var _o,gv;function wN(){if(gv)return _o;gv=1;var e=_o&&_o.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(yN()),i=SN();function s(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(h,p){h&&p&&(c[(0,i.camelCase)(h,o)]=p)}),c}return s.default=s,_o=s,_o}var CN=wN();const kN=Ou(CN),R0=D0("end"),im=D0("start");function D0(e){return t;function t(i){const s=i&&i.position&&i.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function M0(e){const t=im(e),i=R0(e);if(t&&i)return{start:t,end:i}}function Ao(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?_v(e.position):"start"in e||"end"in e?_v(e):"line"in e||"column"in e?Ep(e):""}function Ep(e){return xv(e&&e.line)+":"+xv(e&&e.column)}function _v(e){return Ep(e&&e.start)+"-"+Ep(e&&e.end)}function xv(e){return e&&typeof e=="number"?e:1}class pn extends Error{constructor(t,i,s){super(),typeof i=="string"&&(s=i,i=void 0);let a="",o={},c=!1;if(i&&("line"in i&&"column"in i?o={place:i}:"start"in i&&"end"in i?o={place:i}:"type"in i?o={ancestors:[i],place:i.position}:o={...i}),typeof t=="string"?a=t:!o.cause&&t&&(c=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof s=="string"){const p=s.indexOf(":");p===-1?o.ruleId=s:(o.source=s.slice(0,p),o.ruleId=s.slice(p+1))}if(!o.place&&o.ancestors&&o.ancestors){const p=o.ancestors[o.ancestors.length-1];p&&(o.place=p.position)}const h=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=h?h.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=h?h.line:void 0,this.name=Ao(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=c&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}pn.prototype.file="";pn.prototype.name="";pn.prototype.reason="";pn.prototype.message="";pn.prototype.stack="";pn.prototype.column=void 0;pn.prototype.line=void 0;pn.prototype.ancestors=void 0;pn.prototype.cause=void 0;pn.prototype.fatal=void 0;pn.prototype.place=void 0;pn.prototype.ruleId=void 0;pn.prototype.source=void 0;const nm={}.hasOwnProperty,EN=new Map,NN=/[A-Z]/g,TN=new Set(["table","tbody","thead","tfoot","tr"]),jN=new Set(["td","th"]),B0="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function AN(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const i=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=PN(i,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=zN(i,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:i,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?tm:xN,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=L0(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function L0(e,t,i){if(t.type==="element")return RN(e,t,i);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return DN(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return BN(e,t,i);if(t.type==="mdxjsEsm")return MN(e,t);if(t.type==="root")return LN(e,t,i);if(t.type==="text")return ON(e,t)}function RN(e,t,i){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=tm,e.schema=a),e.ancestors.push(t);const o=z0(e,t.tagName,!1),c=IN(e,t);let h=sm(e,t);return TN.has(t.tagName)&&(h=h.filter(function(p){return typeof p=="string"?!oN(p):!0})),O0(e,c,o,t),rm(c,h),e.ancestors.pop(),e.schema=s,e.create(t,o,c,i)}function DN(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}zo(e,t.position)}function MN(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);zo(e,t.position)}function BN(e,t,i){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=tm,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:z0(e,t.name,!0),c=HN(e,t),h=sm(e,t);return O0(e,c,o,t),rm(c,h),e.ancestors.pop(),e.schema=s,e.create(t,o,c,i)}function LN(e,t,i){const s={};return rm(s,sm(e,t)),e.create(t,e.Fragment,s,i)}function ON(e,t){return t.value}function O0(e,t,i,s){typeof i!="string"&&i!==e.Fragment&&e.passNode&&(t.node=s)}function rm(e,t){if(t.length>0){const i=t.length>1?t:t[0];i&&(e.children=i)}}function zN(e,t,i){return s;function s(a,o,c,h){const d=Array.isArray(c.children)?i:t;return h?d(o,c,h):d(o,c)}}function PN(e,t){return i;function i(s,a,o,c){const h=Array.isArray(o.children),p=im(s);return t(a,o,c,h,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function IN(e,t){const i={};let s,a;for(a in t.properties)if(a!=="children"&&nm.call(t.properties,a)){const o=UN(e,a,t.properties[a]);if(o){const[c,h]=o;e.tableCellAlignToStyle&&c==="align"&&typeof h=="string"&&jN.has(t.tagName)?s=h:i[c]=h}}if(s){const o=i.style||(i.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return i}function HN(e,t){const i={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const o=s.data.estree.body[0];o.type;const c=o.expression;c.type;const h=c.properties[0];h.type,Object.assign(i,e.evaluater.evaluateExpression(h.argument))}else zo(e,t.position);else{const a=s.name;let o;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const h=s.value.data.estree.body[0];h.type,o=e.evaluater.evaluateExpression(h.expression)}else zo(e,t.position);else o=s.value===null?!0:s.value;i[a]=o}return i}function sm(e,t){const i=[];let s=-1;const a=e.passKeys?new Map:EN;for(;++s<t.children.length;){const o=t.children[s];let c;if(e.passKeys){const p=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(p){const d=a.get(p)||0;c=p+"-"+d,a.set(p,d+1)}}const h=L0(e,o,c);h!==void 0&&i.push(h)}return i}function UN(e,t,i){const s=mN(e.schema,t);if(!(i==null||typeof i=="number"&&Number.isNaN(i))){if(Array.isArray(i)&&(i=s.commaSeparated?nN(i):bN(i)),s.property==="style"){let a=typeof i=="object"?i:$N(e,String(i));return e.stylePropertyNameCase==="css"&&(a=FN(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&s.space?dN[s.property]||s.property:s.attribute,i]}}function $N(e,t){try{return kN(t,{reactCompat:!0})}catch(i){if(e.ignoreInvalidStyle)return{};const s=i,a=new pn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=B0+"#cannot-parse-style-attribute",a}}function z0(e,t,i){let s;if(!i)s={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let o=-1,c;for(;++o<a.length;){const h=cv(a[o])?{type:"Identifier",name:a[o]}:{type:"Literal",value:a[o]};c=c?{type:"MemberExpression",object:c,property:h,computed:!!(o&&h.type==="Literal"),optional:!1}:h}s=c}else s=cv(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const a=s.value;return nm.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(s);zo(e)}function zo(e,t){const i=new pn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=B0+"#cannot-handle-mdx-estrees-without-createevaluater",i}function FN(e){const t={};let i;for(i in e)nm.call(e,i)&&(t[qN(i)]=e[i]);return t}function qN(e){let t=e.replace(NN,WN);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function WN(e){return"-"+e.toLowerCase()}const _f={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},GN={};function am(e,t){const i=GN,s=typeof i.includeImageAlt=="boolean"?i.includeImageAlt:!0,a=typeof i.includeHtml=="boolean"?i.includeHtml:!0;return P0(e,s,a)}function P0(e,t,i){if(YN(e)){if("value"in e)return e.type==="html"&&!i?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return bv(e.children,t,i)}return Array.isArray(e)?bv(e,t,i):""}function bv(e,t,i){const s=[];let a=-1;for(;++a<e.length;)s[a]=P0(e[a],t,i);return s.join("")}function YN(e){return!!(e&&typeof e=="object")}const vv=document.createElement("i");function lm(e){const t="&"+e+";";vv.innerHTML=t;const i=vv.textContent;return i.charCodeAt(i.length-1)===59&&e!=="semi"||i===t?!1:i}function Yn(e,t,i,s){const a=e.length;let o=0,c;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,i=i>0?i:0,s.length<1e4)c=Array.from(s),c.unshift(t,i),e.splice(...c);else for(i&&e.splice(t,i);o<s.length;)c=s.slice(o,o+1e4),c.unshift(t,0),e.splice(...c),o+=1e4,t+=1e4}function ur(e,t){return e.length>0?(Yn(e,e.length,0,t),e):t}const yv={}.hasOwnProperty;function I0(e){const t={};let i=-1;for(;++i<e.length;)KN(t,e[i]);return t}function KN(e,t){let i;for(i in t){const a=(yv.call(e,i)?e[i]:void 0)||(e[i]={}),o=t[i];let c;if(o)for(c in o){yv.call(a,c)||(a[c]=[]);const h=o[c];VN(a[c],Array.isArray(h)?h:h?[h]:[])}}}function VN(e,t){let i=-1;const s=[];for(;++i<t.length;)(t[i].add==="after"?e:s).push(t[i]);Yn(e,0,0,s)}function H0(e,t){const i=Number.parseInt(e,t);return i<9||i===11||i>13&&i<32||i>126&&i<160||i>55295&&i<57344||i>64975&&i<65008||(i&65535)===65535||(i&65535)===65534||i>1114111?"�":String.fromCodePoint(i)}function xr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const yn=Hs(/[A-Za-z]/),fn=Hs(/[\dA-Za-z]/),XN=Hs(/[#-'*+\--9=?A-Z^-~]/);function Au(e){return e!==null&&(e<32||e===127)}const Np=Hs(/\d/),ZN=Hs(/[\dA-Fa-f]/),QN=Hs(/[!-/:-@[-`{-~]/);function Ye(e){return e!==null&&e<-2}function Xt(e){return e!==null&&(e<0||e===32)}function gt(e){return e===-2||e===-1||e===32}const Uu=Hs(new RegExp("\\p{P}|\\p{S}","u")),ba=Hs(/\s/);function Hs(e){return t;function t(i){return i!==null&&i>-1&&e.test(String.fromCharCode(i))}}function gl(e){const t=[];let i=-1,s=0,a=0;for(;++i<e.length;){const o=e.charCodeAt(i);let c="";if(o===37&&fn(e.charCodeAt(i+1))&&fn(e.charCodeAt(i+2)))a=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(c=String.fromCharCode(o));else if(o>55295&&o<57344){const h=e.charCodeAt(i+1);o<56320&&h>56319&&h<57344?(c=String.fromCharCode(o,h),a=1):c="�"}else c=String.fromCharCode(o);c&&(t.push(e.slice(s,i),encodeURIComponent(c)),s=i+a+1,c=""),a&&(i+=a,a=0)}return t.join("")+e.slice(s)}function Et(e,t,i,s){const a=s?s-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(p){return gt(p)?(e.enter(i),h(p)):t(p)}function h(p){return gt(p)&&o++<a?(e.consume(p),h):(e.exit(i),t(p))}}const JN={tokenize:e5};function e5(e){const t=e.attempt(this.parser.constructs.contentInitial,s,a);let i;return t;function s(h){if(h===null){e.consume(h);return}return e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Et(e,t,"linePrefix")}function a(h){return e.enter("paragraph"),o(h)}function o(h){const p=e.enter("chunkText",{contentType:"text",previous:i});return i&&(i.next=p),i=p,c(h)}function c(h){if(h===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(h);return}return Ye(h)?(e.consume(h),e.exit("chunkText"),o):(e.consume(h),c)}}const t5={tokenize:i5},Sv={tokenize:n5};function i5(e){const t=this,i=[];let s=0,a,o,c;return h;function h(z){if(s<i.length){const R=i[s];return t.containerState=R[1],e.attempt(R[0].continuation,p,d)(z)}return d(z)}function p(z){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&H();const R=t.events.length;let te=R,L;for(;te--;)if(t.events[te][0]==="exit"&&t.events[te][1].type==="chunkFlow"){L=t.events[te][1].end;break}E(s);let I=R;for(;I<t.events.length;)t.events[I][1].end={...L},I++;return Yn(t.events,te+1,0,t.events.slice(R)),t.events.length=I,d(z)}return h(z)}function d(z){if(s===i.length){if(!a)return b(z);if(a.currentConstruct&&a.currentConstruct.concrete)return S(z);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Sv,x,_)(z)}function x(z){return a&&H(),E(s),b(z)}function _(z){return t.parser.lazy[t.now().line]=s!==i.length,c=t.now().offset,S(z)}function b(z){return t.containerState={},e.attempt(Sv,v,S)(z)}function v(z){return s++,i.push([t.currentConstruct,t.containerState]),b(z)}function S(z){if(z===null){a&&H(),E(0),e.consume(z);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:o}),N(z)}function N(z){if(z===null){M(e.exit("chunkFlow"),!0),E(0),e.consume(z);return}return Ye(z)?(e.consume(z),M(e.exit("chunkFlow")),s=0,t.interrupt=void 0,h):(e.consume(z),N)}function M(z,R){const te=t.sliceStream(z);if(R&&te.push(null),z.previous=o,o&&(o.next=z),o=z,a.defineSkip(z.start),a.write(te),t.parser.lazy[z.start.line]){let L=a.events.length;for(;L--;)if(a.events[L][1].start.offset<c&&(!a.events[L][1].end||a.events[L][1].end.offset>c))return;const I=t.events.length;let re=I,_e,j;for(;re--;)if(t.events[re][0]==="exit"&&t.events[re][1].type==="chunkFlow"){if(_e){j=t.events[re][1].end;break}_e=!0}for(E(s),L=I;L<t.events.length;)t.events[L][1].end={...j},L++;Yn(t.events,re+1,0,t.events.slice(I)),t.events.length=L}}function E(z){let R=i.length;for(;R-- >z;){const te=i[R];t.containerState=te[1],te[0].exit.call(t,e)}i.length=z}function H(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function n5(e,t,i){return Et(e,e.attempt(this.parser.constructs.document,t,i),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function dl(e){if(e===null||Xt(e)||ba(e))return 1;if(Uu(e))return 2}function $u(e,t,i){const s=[];let a=-1;for(;++a<e.length;){const o=e[a].resolveAll;o&&!s.includes(o)&&(t=o(t,i),s.push(o))}return t}const Tp={name:"attention",resolveAll:r5,tokenize:s5};function r5(e,t){let i=-1,s,a,o,c,h,p,d,x;for(;++i<e.length;)if(e[i][0]==="enter"&&e[i][1].type==="attentionSequence"&&e[i][1]._close){for(s=i;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[i][1]).charCodeAt(0)){if((e[s][1]._close||e[i][1]._open)&&(e[i][1].end.offset-e[i][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[i][1].end.offset-e[i][1].start.offset)%3))continue;p=e[s][1].end.offset-e[s][1].start.offset>1&&e[i][1].end.offset-e[i][1].start.offset>1?2:1;const _={...e[s][1].end},b={...e[i][1].start};wv(_,-p),wv(b,p),c={type:p>1?"strongSequence":"emphasisSequence",start:_,end:{...e[s][1].end}},h={type:p>1?"strongSequence":"emphasisSequence",start:{...e[i][1].start},end:b},o={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[i][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...h.end}},e[s][1].end={...c.start},e[i][1].start={...h.end},d=[],e[s][1].end.offset-e[s][1].start.offset&&(d=ur(d,[["enter",e[s][1],t],["exit",e[s][1],t]])),d=ur(d,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),d=ur(d,$u(t.parser.constructs.insideSpan.null,e.slice(s+1,i),t)),d=ur(d,[["exit",o,t],["enter",h,t],["exit",h,t],["exit",a,t]]),e[i][1].end.offset-e[i][1].start.offset?(x=2,d=ur(d,[["enter",e[i][1],t],["exit",e[i][1],t]])):x=0,Yn(e,s-1,i-s+3,d),i=s+d.length-x-2;break}}for(i=-1;++i<e.length;)e[i][1].type==="attentionSequence"&&(e[i][1].type="data");return e}function s5(e,t){const i=this.parser.constructs.attentionMarkers.null,s=this.previous,a=dl(s);let o;return c;function c(p){return o=p,e.enter("attentionSequence"),h(p)}function h(p){if(p===o)return e.consume(p),h;const d=e.exit("attentionSequence"),x=dl(p),_=!x||x===2&&a||i.includes(p),b=!a||a===2&&x||i.includes(s);return d._open=!!(o===42?_:_&&(a||!b)),d._close=!!(o===42?b:b&&(x||!_)),t(p)}}function wv(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const a5={name:"autolink",tokenize:l5};function l5(e,t,i){let s=0;return a;function a(v){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(v){return yn(v)?(e.consume(v),c):v===64?i(v):d(v)}function c(v){return v===43||v===45||v===46||fn(v)?(s=1,h(v)):d(v)}function h(v){return v===58?(e.consume(v),s=0,p):(v===43||v===45||v===46||fn(v))&&s++<32?(e.consume(v),h):(s=0,d(v))}function p(v){return v===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):v===null||v===32||v===60||Au(v)?i(v):(e.consume(v),p)}function d(v){return v===64?(e.consume(v),x):XN(v)?(e.consume(v),d):i(v)}function x(v){return fn(v)?_(v):i(v)}function _(v){return v===46?(e.consume(v),s=0,x):v===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):b(v)}function b(v){if((v===45||fn(v))&&s++<63){const S=v===45?b:_;return e.consume(v),S}return i(v)}}const Go={partial:!0,tokenize:o5};function o5(e,t,i){return s;function s(o){return gt(o)?Et(e,a,"linePrefix")(o):a(o)}function a(o){return o===null||Ye(o)?t(o):i(o)}}const U0={continuation:{tokenize:u5},exit:h5,name:"blockQuote",tokenize:c5};function c5(e,t,i){const s=this;return a;function a(c){if(c===62){const h=s.containerState;return h.open||(e.enter("blockQuote",{_container:!0}),h.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),o}return i(c)}function o(c){return gt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function u5(e,t,i){const s=this;return a;function a(c){return gt(c)?Et(e,o,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):o(c)}function o(c){return e.attempt(U0,t,i)(c)}}function h5(e){e.exit("blockQuote")}const $0={name:"characterEscape",tokenize:d5};function d5(e,t,i){return s;function s(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),a}function a(o){return QN(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):i(o)}}const F0={name:"characterReference",tokenize:f5};function f5(e,t,i){const s=this;let a=0,o,c;return h;function h(_){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(_),e.exit("characterReferenceMarker"),p}function p(_){return _===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(_),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),o=31,c=fn,x(_))}function d(_){return _===88||_===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(_),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,c=ZN,x):(e.enter("characterReferenceValue"),o=7,c=Np,x(_))}function x(_){if(_===59&&a){const b=e.exit("characterReferenceValue");return c===fn&&!lm(s.sliceSerialize(b))?i(_):(e.enter("characterReferenceMarker"),e.consume(_),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(_)&&a++<o?(e.consume(_),x):i(_)}}const Cv={partial:!0,tokenize:m5},kv={concrete:!0,name:"codeFenced",tokenize:p5};function p5(e,t,i){const s=this,a={partial:!0,tokenize:te};let o=0,c=0,h;return p;function p(L){return d(L)}function d(L){const I=s.events[s.events.length-1];return o=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,h=L,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(L)}function x(L){return L===h?(c++,e.consume(L),x):c<3?i(L):(e.exit("codeFencedFenceSequence"),gt(L)?Et(e,_,"whitespace")(L):_(L))}function _(L){return L===null||Ye(L)?(e.exit("codeFencedFence"),s.interrupt?t(L):e.check(Cv,N,R)(L)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),b(L))}function b(L){return L===null||Ye(L)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),_(L)):gt(L)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Et(e,v,"whitespace")(L)):L===96&&L===h?i(L):(e.consume(L),b)}function v(L){return L===null||Ye(L)?_(L):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),S(L))}function S(L){return L===null||Ye(L)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),_(L)):L===96&&L===h?i(L):(e.consume(L),S)}function N(L){return e.attempt(a,R,M)(L)}function M(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),E}function E(L){return o>0&&gt(L)?Et(e,H,"linePrefix",o+1)(L):H(L)}function H(L){return L===null||Ye(L)?e.check(Cv,N,R)(L):(e.enter("codeFlowValue"),z(L))}function z(L){return L===null||Ye(L)?(e.exit("codeFlowValue"),H(L)):(e.consume(L),z)}function R(L){return e.exit("codeFenced"),t(L)}function te(L,I,re){let _e=0;return j;function j(U){return L.enter("lineEnding"),L.consume(U),L.exit("lineEnding"),J}function J(U){return L.enter("codeFencedFence"),gt(U)?Et(L,F,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):F(U)}function F(U){return U===h?(L.enter("codeFencedFenceSequence"),G(U)):re(U)}function G(U){return U===h?(_e++,L.consume(U),G):_e>=c?(L.exit("codeFencedFenceSequence"),gt(U)?Et(L,Y,"whitespace")(U):Y(U)):re(U)}function Y(U){return U===null||Ye(U)?(L.exit("codeFencedFence"),I(U)):re(U)}}}function m5(e,t,i){const s=this;return a;function a(c){return c===null?i(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return s.parser.lazy[s.now().line]?i(c):t(c)}}const xf={name:"codeIndented",tokenize:_5},g5={partial:!0,tokenize:x5};function _5(e,t,i){const s=this;return a;function a(d){return e.enter("codeIndented"),Et(e,o,"linePrefix",5)(d)}function o(d){const x=s.events[s.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?c(d):i(d)}function c(d){return d===null?p(d):Ye(d)?e.attempt(g5,c,p)(d):(e.enter("codeFlowValue"),h(d))}function h(d){return d===null||Ye(d)?(e.exit("codeFlowValue"),c(d)):(e.consume(d),h)}function p(d){return e.exit("codeIndented"),t(d)}}function x5(e,t,i){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?i(c):Ye(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Et(e,o,"linePrefix",5)(c)}function o(c){const h=s.events[s.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?t(c):Ye(c)?a(c):i(c)}}const b5={name:"codeText",previous:y5,resolve:v5,tokenize:S5};function v5(e){let t=e.length-4,i=3,s,a;if((e[i][1].type==="lineEnding"||e[i][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=i;++s<t;)if(e[s][1].type==="codeTextData"){e[i][1].type="codeTextPadding",e[t][1].type="codeTextPadding",i+=2,t-=2;break}}for(s=i-1,t++;++s<=t;)a===void 0?s!==t&&e[s][1].type!=="lineEnding"&&(a=s):(s===t||e[s][1].type==="lineEnding")&&(e[a][1].type="codeTextData",s!==a+2&&(e[a][1].end=e[s-1][1].end,e.splice(a+2,s-a-2),t-=s-a-2,s=a+2),a=void 0);return e}function y5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function S5(e,t,i){let s=0,a,o;return c;function c(_){return e.enter("codeText"),e.enter("codeTextSequence"),h(_)}function h(_){return _===96?(e.consume(_),s++,h):(e.exit("codeTextSequence"),p(_))}function p(_){return _===null?i(_):_===32?(e.enter("space"),e.consume(_),e.exit("space"),p):_===96?(o=e.enter("codeTextSequence"),a=0,x(_)):Ye(_)?(e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),p):(e.enter("codeTextData"),d(_))}function d(_){return _===null||_===32||_===96||Ye(_)?(e.exit("codeTextData"),p(_)):(e.consume(_),d)}function x(_){return _===96?(e.consume(_),a++,x):a===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(_)):(o.type="codeTextData",d(_))}}class w5{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,i){const s=i??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(t,s):t>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,i,s){const a=i||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&xo(this.left,s),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),xo(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),xo(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const i=this.left.splice(t,Number.POSITIVE_INFINITY);xo(this.right,i.reverse())}else{const i=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);xo(this.left,i.reverse())}}}function xo(e,t){let i=0;if(t.length<1e4)e.push(...t);else for(;i<t.length;)e.push(...t.slice(i,i+1e4)),i+=1e4}function q0(e){const t={};let i=-1,s,a,o,c,h,p,d;const x=new w5(e);for(;++i<x.length;){for(;i in t;)i=t[i];if(s=x.get(i),i&&s[1].type==="chunkFlow"&&x.get(i-1)[1].type==="listItemPrefix"&&(p=s[1]._tokenizer.events,o=0,o<p.length&&p[o][1].type==="lineEndingBlank"&&(o+=2),o<p.length&&p[o][1].type==="content"))for(;++o<p.length&&p[o][1].type!=="content";)p[o][1].type==="chunkText"&&(p[o][1]._isInFirstContentOfListItem=!0,o++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,C5(x,i)),i=t[i],d=!0);else if(s[1]._container){for(o=i,a=void 0;o--;)if(c=x.get(o),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(a&&(x.get(a)[1].type="lineEndingBlank"),c[1].type="lineEnding",a=o);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;a&&(s[1].end={...x.get(a)[1].start},h=x.slice(a,i),h.unshift(s),x.splice(a,i-a+1,h))}}return Yn(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!d}function C5(e,t){const i=e.get(t)[1],s=e.get(t)[2];let a=t-1;const o=[];let c=i._tokenizer;c||(c=s.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const h=c.events,p=[],d={};let x,_,b=-1,v=i,S=0,N=0;const M=[N];for(;v;){for(;e.get(++a)[1]!==v;);o.push(a),v._tokenizer||(x=s.sliceStream(v),v.next||x.push(null),_&&c.defineSkip(v.start),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(x),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),_=v,v=v.next}for(v=i;++b<h.length;)h[b][0]==="exit"&&h[b-1][0]==="enter"&&h[b][1].type===h[b-1][1].type&&h[b][1].start.line!==h[b][1].end.line&&(N=b+1,M.push(N),v._tokenizer=void 0,v.previous=void 0,v=v.next);for(c.events=[],v?(v._tokenizer=void 0,v.previous=void 0):M.pop(),b=M.length;b--;){const E=h.slice(M[b],M[b+1]),H=o.pop();p.push([H,H+E.length-1]),e.splice(H,2,E)}for(p.reverse(),b=-1;++b<p.length;)d[S+p[b][0]]=S+p[b][1],S+=p[b][1]-p[b][0]-1;return d}const k5={resolve:N5,tokenize:T5},E5={partial:!0,tokenize:j5};function N5(e){return q0(e),e}function T5(e,t){let i;return s;function s(h){return e.enter("content"),i=e.enter("chunkContent",{contentType:"content"}),a(h)}function a(h){return h===null?o(h):Ye(h)?e.check(E5,c,o)(h):(e.consume(h),a)}function o(h){return e.exit("chunkContent"),e.exit("content"),t(h)}function c(h){return e.consume(h),e.exit("chunkContent"),i.next=e.enter("chunkContent",{contentType:"content",previous:i}),i=i.next,a}}function j5(e,t,i){const s=this;return a;function a(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Et(e,o,"linePrefix")}function o(c){if(c===null||Ye(c))return i(c);const h=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?t(c):e.interrupt(s.parser.constructs.flow,i,t)(c)}}function W0(e,t,i,s,a,o,c,h,p){const d=p||Number.POSITIVE_INFINITY;let x=0;return _;function _(E){return E===60?(e.enter(s),e.enter(a),e.enter(o),e.consume(E),e.exit(o),b):E===null||E===32||E===41||Au(E)?i(E):(e.enter(s),e.enter(c),e.enter(h),e.enter("chunkString",{contentType:"string"}),N(E))}function b(E){return E===62?(e.enter(o),e.consume(E),e.exit(o),e.exit(a),e.exit(s),t):(e.enter(h),e.enter("chunkString",{contentType:"string"}),v(E))}function v(E){return E===62?(e.exit("chunkString"),e.exit(h),b(E)):E===null||E===60||Ye(E)?i(E):(e.consume(E),E===92?S:v)}function S(E){return E===60||E===62||E===92?(e.consume(E),v):v(E)}function N(E){return!x&&(E===null||E===41||Xt(E))?(e.exit("chunkString"),e.exit(h),e.exit(c),e.exit(s),t(E)):x<d&&E===40?(e.consume(E),x++,N):E===41?(e.consume(E),x--,N):E===null||E===32||E===40||Au(E)?i(E):(e.consume(E),E===92?M:N)}function M(E){return E===40||E===41||E===92?(e.consume(E),N):N(E)}}function G0(e,t,i,s,a,o){const c=this;let h=0,p;return d;function d(v){return e.enter(s),e.enter(a),e.consume(v),e.exit(a),e.enter(o),x}function x(v){return h>999||v===null||v===91||v===93&&!p||v===94&&!h&&"_hiddenFootnoteSupport"in c.parser.constructs?i(v):v===93?(e.exit(o),e.enter(a),e.consume(v),e.exit(a),e.exit(s),t):Ye(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),_(v))}function _(v){return v===null||v===91||v===93||Ye(v)||h++>999?(e.exit("chunkString"),x(v)):(e.consume(v),p||(p=!gt(v)),v===92?b:_)}function b(v){return v===91||v===92||v===93?(e.consume(v),h++,_):_(v)}}function Y0(e,t,i,s,a,o){let c;return h;function h(b){return b===34||b===39||b===40?(e.enter(s),e.enter(a),e.consume(b),e.exit(a),c=b===40?41:b,p):i(b)}function p(b){return b===c?(e.enter(a),e.consume(b),e.exit(a),e.exit(s),t):(e.enter(o),d(b))}function d(b){return b===c?(e.exit(o),p(c)):b===null?i(b):Ye(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Et(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(b))}function x(b){return b===c||b===null||Ye(b)?(e.exit("chunkString"),d(b)):(e.consume(b),b===92?_:x)}function _(b){return b===c||b===92?(e.consume(b),x):x(b)}}function Ro(e,t){let i;return s;function s(a){return Ye(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i=!0,s):gt(a)?Et(e,s,i?"linePrefix":"lineSuffix")(a):t(a)}}const A5={name:"definition",tokenize:D5},R5={partial:!0,tokenize:M5};function D5(e,t,i){const s=this;let a;return o;function o(v){return e.enter("definition"),c(v)}function c(v){return G0.call(s,e,h,i,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function h(v){return a=xr(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),v===58?(e.enter("definitionMarker"),e.consume(v),e.exit("definitionMarker"),p):i(v)}function p(v){return Xt(v)?Ro(e,d)(v):d(v)}function d(v){return W0(e,x,i,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function x(v){return e.attempt(R5,_,_)(v)}function _(v){return gt(v)?Et(e,b,"whitespace")(v):b(v)}function b(v){return v===null||Ye(v)?(e.exit("definition"),s.parser.defined.push(a),t(v)):i(v)}}function M5(e,t,i){return s;function s(h){return Xt(h)?Ro(e,a)(h):i(h)}function a(h){return Y0(e,o,i,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function o(h){return gt(h)?Et(e,c,"whitespace")(h):c(h)}function c(h){return h===null||Ye(h)?t(h):i(h)}}const B5={name:"hardBreakEscape",tokenize:L5};function L5(e,t,i){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return Ye(o)?(e.exit("hardBreakEscape"),t(o)):i(o)}}const O5={name:"headingAtx",resolve:z5,tokenize:P5};function z5(e,t){let i=e.length-2,s=3,a,o;return e[s][1].type==="whitespace"&&(s+=2),i-2>s&&e[i][1].type==="whitespace"&&(i-=2),e[i][1].type==="atxHeadingSequence"&&(s===i-1||i-4>s&&e[i-2][1].type==="whitespace")&&(i-=s+1===i?2:4),i>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[i][1].end},o={type:"chunkText",start:e[s][1].start,end:e[i][1].end,contentType:"text"},Yn(e,s,i-s+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function P5(e,t,i){let s=0;return a;function a(x){return e.enter("atxHeading"),o(x)}function o(x){return e.enter("atxHeadingSequence"),c(x)}function c(x){return x===35&&s++<6?(e.consume(x),c):x===null||Xt(x)?(e.exit("atxHeadingSequence"),h(x)):i(x)}function h(x){return x===35?(e.enter("atxHeadingSequence"),p(x)):x===null||Ye(x)?(e.exit("atxHeading"),t(x)):gt(x)?Et(e,h,"whitespace")(x):(e.enter("atxHeadingText"),d(x))}function p(x){return x===35?(e.consume(x),p):(e.exit("atxHeadingSequence"),h(x))}function d(x){return x===null||x===35||Xt(x)?(e.exit("atxHeadingText"),h(x)):(e.consume(x),d)}}const I5=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Ev=["pre","script","style","textarea"],H5={concrete:!0,name:"htmlFlow",resolveTo:F5,tokenize:q5},U5={partial:!0,tokenize:G5},$5={partial:!0,tokenize:W5};function F5(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function q5(e,t,i){const s=this;let a,o,c,h,p;return d;function d(k){return x(k)}function x(k){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(k),_}function _(k){return k===33?(e.consume(k),b):k===47?(e.consume(k),o=!0,N):k===63?(e.consume(k),a=3,s.interrupt?t:T):yn(k)?(e.consume(k),c=String.fromCharCode(k),M):i(k)}function b(k){return k===45?(e.consume(k),a=2,v):k===91?(e.consume(k),a=5,h=0,S):yn(k)?(e.consume(k),a=4,s.interrupt?t:T):i(k)}function v(k){return k===45?(e.consume(k),s.interrupt?t:T):i(k)}function S(k){const le="CDATA[";return k===le.charCodeAt(h++)?(e.consume(k),h===le.length?s.interrupt?t:F:S):i(k)}function N(k){return yn(k)?(e.consume(k),c=String.fromCharCode(k),M):i(k)}function M(k){if(k===null||k===47||k===62||Xt(k)){const le=k===47,ne=c.toLowerCase();return!le&&!o&&Ev.includes(ne)?(a=1,s.interrupt?t(k):F(k)):I5.includes(c.toLowerCase())?(a=6,le?(e.consume(k),E):s.interrupt?t(k):F(k)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?i(k):o?H(k):z(k))}return k===45||fn(k)?(e.consume(k),c+=String.fromCharCode(k),M):i(k)}function E(k){return k===62?(e.consume(k),s.interrupt?t:F):i(k)}function H(k){return gt(k)?(e.consume(k),H):j(k)}function z(k){return k===47?(e.consume(k),j):k===58||k===95||yn(k)?(e.consume(k),R):gt(k)?(e.consume(k),z):j(k)}function R(k){return k===45||k===46||k===58||k===95||fn(k)?(e.consume(k),R):te(k)}function te(k){return k===61?(e.consume(k),L):gt(k)?(e.consume(k),te):z(k)}function L(k){return k===null||k===60||k===61||k===62||k===96?i(k):k===34||k===39?(e.consume(k),p=k,I):gt(k)?(e.consume(k),L):re(k)}function I(k){return k===p?(e.consume(k),p=null,_e):k===null||Ye(k)?i(k):(e.consume(k),I)}function re(k){return k===null||k===34||k===39||k===47||k===60||k===61||k===62||k===96||Xt(k)?te(k):(e.consume(k),re)}function _e(k){return k===47||k===62||gt(k)?z(k):i(k)}function j(k){return k===62?(e.consume(k),J):i(k)}function J(k){return k===null||Ye(k)?F(k):gt(k)?(e.consume(k),J):i(k)}function F(k){return k===45&&a===2?(e.consume(k),A):k===60&&a===1?(e.consume(k),q):k===62&&a===4?(e.consume(k),D):k===63&&a===3?(e.consume(k),T):k===93&&a===5?(e.consume(k),be):Ye(k)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(U5,V,G)(k)):k===null||Ye(k)?(e.exit("htmlFlowData"),G(k)):(e.consume(k),F)}function G(k){return e.check($5,Y,V)(k)}function Y(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),U}function U(k){return k===null||Ye(k)?G(k):(e.enter("htmlFlowData"),F(k))}function A(k){return k===45?(e.consume(k),T):F(k)}function q(k){return k===47?(e.consume(k),c="",$):F(k)}function $(k){if(k===62){const le=c.toLowerCase();return Ev.includes(le)?(e.consume(k),D):F(k)}return yn(k)&&c.length<8?(e.consume(k),c+=String.fromCharCode(k),$):F(k)}function be(k){return k===93?(e.consume(k),T):F(k)}function T(k){return k===62?(e.consume(k),D):k===45&&a===2?(e.consume(k),T):F(k)}function D(k){return k===null||Ye(k)?(e.exit("htmlFlowData"),V(k)):(e.consume(k),D)}function V(k){return e.exit("htmlFlow"),t(k)}}function W5(e,t,i){const s=this;return a;function a(c){return Ye(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):i(c)}function o(c){return s.parser.lazy[s.now().line]?i(c):t(c)}}function G5(e,t,i){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Go,t,i)}}const Y5={name:"htmlText",tokenize:K5};function K5(e,t,i){const s=this;let a,o,c;return h;function h(T){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(T),p}function p(T){return T===33?(e.consume(T),d):T===47?(e.consume(T),te):T===63?(e.consume(T),z):yn(T)?(e.consume(T),re):i(T)}function d(T){return T===45?(e.consume(T),x):T===91?(e.consume(T),o=0,S):yn(T)?(e.consume(T),H):i(T)}function x(T){return T===45?(e.consume(T),v):i(T)}function _(T){return T===null?i(T):T===45?(e.consume(T),b):Ye(T)?(c=_,q(T)):(e.consume(T),_)}function b(T){return T===45?(e.consume(T),v):_(T)}function v(T){return T===62?A(T):T===45?b(T):_(T)}function S(T){const D="CDATA[";return T===D.charCodeAt(o++)?(e.consume(T),o===D.length?N:S):i(T)}function N(T){return T===null?i(T):T===93?(e.consume(T),M):Ye(T)?(c=N,q(T)):(e.consume(T),N)}function M(T){return T===93?(e.consume(T),E):N(T)}function E(T){return T===62?A(T):T===93?(e.consume(T),E):N(T)}function H(T){return T===null||T===62?A(T):Ye(T)?(c=H,q(T)):(e.consume(T),H)}function z(T){return T===null?i(T):T===63?(e.consume(T),R):Ye(T)?(c=z,q(T)):(e.consume(T),z)}function R(T){return T===62?A(T):z(T)}function te(T){return yn(T)?(e.consume(T),L):i(T)}function L(T){return T===45||fn(T)?(e.consume(T),L):I(T)}function I(T){return Ye(T)?(c=I,q(T)):gt(T)?(e.consume(T),I):A(T)}function re(T){return T===45||fn(T)?(e.consume(T),re):T===47||T===62||Xt(T)?_e(T):i(T)}function _e(T){return T===47?(e.consume(T),A):T===58||T===95||yn(T)?(e.consume(T),j):Ye(T)?(c=_e,q(T)):gt(T)?(e.consume(T),_e):A(T)}function j(T){return T===45||T===46||T===58||T===95||fn(T)?(e.consume(T),j):J(T)}function J(T){return T===61?(e.consume(T),F):Ye(T)?(c=J,q(T)):gt(T)?(e.consume(T),J):_e(T)}function F(T){return T===null||T===60||T===61||T===62||T===96?i(T):T===34||T===39?(e.consume(T),a=T,G):Ye(T)?(c=F,q(T)):gt(T)?(e.consume(T),F):(e.consume(T),Y)}function G(T){return T===a?(e.consume(T),a=void 0,U):T===null?i(T):Ye(T)?(c=G,q(T)):(e.consume(T),G)}function Y(T){return T===null||T===34||T===39||T===60||T===61||T===96?i(T):T===47||T===62||Xt(T)?_e(T):(e.consume(T),Y)}function U(T){return T===47||T===62||Xt(T)?_e(T):i(T)}function A(T){return T===62?(e.consume(T),e.exit("htmlTextData"),e.exit("htmlText"),t):i(T)}function q(T){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),$}function $(T){return gt(T)?Et(e,be,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):be(T)}function be(T){return e.enter("htmlTextData"),c(T)}}const om={name:"labelEnd",resolveAll:Q5,resolveTo:J5,tokenize:eT},V5={tokenize:tT},X5={tokenize:iT},Z5={tokenize:nT};function Q5(e){let t=-1;const i=[];for(;++t<e.length;){const s=e[t][1];if(i.push(e[t]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const a=s.type==="labelImage"?4:2;s.type="data",t+=a}}return e.length!==i.length&&Yn(e,0,e.length,i),e}function J5(e,t){let i=e.length,s=0,a,o,c,h;for(;i--;)if(a=e[i][1],o){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[i][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(c){if(e[i][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(o=i,a.type!=="labelLink")){s=2;break}}else a.type==="labelEnd"&&(c=i);const p={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[o][1].start},end:{...e[c][1].end}},x={type:"labelText",start:{...e[o+s+2][1].end},end:{...e[c-2][1].start}};return h=[["enter",p,t],["enter",d,t]],h=ur(h,e.slice(o+1,o+s+3)),h=ur(h,[["enter",x,t]]),h=ur(h,$u(t.parser.constructs.insideSpan.null,e.slice(o+s+4,c-3),t)),h=ur(h,[["exit",x,t],e[c-2],e[c-1],["exit",d,t]]),h=ur(h,e.slice(c+1)),h=ur(h,[["exit",p,t]]),Yn(e,o,e.length,h),e}function eT(e,t,i){const s=this;let a=s.events.length,o,c;for(;a--;)if((s.events[a][1].type==="labelImage"||s.events[a][1].type==="labelLink")&&!s.events[a][1]._balanced){o=s.events[a][1];break}return h;function h(b){return o?o._inactive?_(b):(c=s.parser.defined.includes(xr(s.sliceSerialize({start:o.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(b),e.exit("labelMarker"),e.exit("labelEnd"),p):i(b)}function p(b){return b===40?e.attempt(V5,x,c?x:_)(b):b===91?e.attempt(X5,x,c?d:_)(b):c?x(b):_(b)}function d(b){return e.attempt(Z5,x,_)(b)}function x(b){return t(b)}function _(b){return o._balanced=!0,i(b)}}function tT(e,t,i){return s;function s(_){return e.enter("resource"),e.enter("resourceMarker"),e.consume(_),e.exit("resourceMarker"),a}function a(_){return Xt(_)?Ro(e,o)(_):o(_)}function o(_){return _===41?x(_):W0(e,c,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(_)}function c(_){return Xt(_)?Ro(e,p)(_):x(_)}function h(_){return i(_)}function p(_){return _===34||_===39||_===40?Y0(e,d,i,"resourceTitle","resourceTitleMarker","resourceTitleString")(_):x(_)}function d(_){return Xt(_)?Ro(e,x)(_):x(_)}function x(_){return _===41?(e.enter("resourceMarker"),e.consume(_),e.exit("resourceMarker"),e.exit("resource"),t):i(_)}}function iT(e,t,i){const s=this;return a;function a(h){return G0.call(s,e,o,c,"reference","referenceMarker","referenceString")(h)}function o(h){return s.parser.defined.includes(xr(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(h):i(h)}function c(h){return i(h)}}function nT(e,t,i){return s;function s(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),a}function a(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):i(o)}}const rT={name:"labelStartImage",resolveAll:om.resolveAll,tokenize:sT};function sT(e,t,i){const s=this;return a;function a(h){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(h),e.exit("labelImageMarker"),o}function o(h){return h===91?(e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelImage"),c):i(h)}function c(h){return h===94&&"_hiddenFootnoteSupport"in s.parser.constructs?i(h):t(h)}}const aT={name:"labelStartLink",resolveAll:om.resolveAll,tokenize:lT};function lT(e,t,i){const s=this;return a;function a(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),o}function o(c){return c===94&&"_hiddenFootnoteSupport"in s.parser.constructs?i(c):t(c)}}const bf={name:"lineEnding",tokenize:oT};function oT(e,t){return i;function i(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Et(e,t,"linePrefix")}}const yu={name:"thematicBreak",tokenize:cT};function cT(e,t,i){let s=0,a;return o;function o(d){return e.enter("thematicBreak"),c(d)}function c(d){return a=d,h(d)}function h(d){return d===a?(e.enter("thematicBreakSequence"),p(d)):s>=3&&(d===null||Ye(d))?(e.exit("thematicBreak"),t(d)):i(d)}function p(d){return d===a?(e.consume(d),s++,p):(e.exit("thematicBreakSequence"),gt(d)?Et(e,h,"whitespace")(d):h(d))}}const Ln={continuation:{tokenize:fT},exit:mT,name:"list",tokenize:dT},uT={partial:!0,tokenize:gT},hT={partial:!0,tokenize:pT};function dT(e,t,i){const s=this,a=s.events[s.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return h;function h(v){const S=s.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(S==="listUnordered"?!s.containerState.marker||v===s.containerState.marker:Np(v)){if(s.containerState.type||(s.containerState.type=S,e.enter(S,{_container:!0})),S==="listUnordered")return e.enter("listItemPrefix"),v===42||v===45?e.check(yu,i,d)(v):d(v);if(!s.interrupt||v===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(v)}return i(v)}function p(v){return Np(v)&&++c<10?(e.consume(v),p):(!s.interrupt||c<2)&&(s.containerState.marker?v===s.containerState.marker:v===41||v===46)?(e.exit("listItemValue"),d(v)):i(v)}function d(v){return e.enter("listItemMarker"),e.consume(v),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||v,e.check(Go,s.interrupt?i:x,e.attempt(uT,b,_))}function x(v){return s.containerState.initialBlankLine=!0,o++,b(v)}function _(v){return gt(v)?(e.enter("listItemPrefixWhitespace"),e.consume(v),e.exit("listItemPrefixWhitespace"),b):i(v)}function b(v){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(v)}}function fT(e,t,i){const s=this;return s.containerState._closeFlow=void 0,e.check(Go,a,o);function a(h){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Et(e,t,"listItemIndent",s.containerState.size+1)(h)}function o(h){return s.containerState.furtherBlankLines||!gt(h)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(h)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(hT,t,c)(h))}function c(h){return s.containerState._closeFlow=!0,s.interrupt=void 0,Et(e,e.attempt(Ln,t,i),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function pT(e,t,i){const s=this;return Et(e,a,"listItemIndent",s.containerState.size+1);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?t(o):i(o)}}function mT(e){e.exit(this.containerState.type)}function gT(e,t,i){const s=this;return Et(e,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const c=s.events[s.events.length-1];return!gt(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):i(o)}}const Nv={name:"setextUnderline",resolveTo:_T,tokenize:xT};function _T(e,t){let i=e.length,s,a,o;for(;i--;)if(e[i][0]==="enter"){if(e[i][1].type==="content"){s=i;break}e[i][1].type==="paragraph"&&(a=i)}else e[i][1].type==="content"&&e.splice(i,1),!o&&e[i][1].type==="definition"&&(o=i);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",c,t]),e.splice(o+1,0,["exit",e[s][1],t]),e[s][1].end={...e[o][1].end}):e[s][1]=c,e.push(["exit",c,t]),e}function xT(e,t,i){const s=this;let a;return o;function o(d){let x=s.events.length,_;for(;x--;)if(s.events[x][1].type!=="lineEnding"&&s.events[x][1].type!=="linePrefix"&&s.events[x][1].type!=="content"){_=s.events[x][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||_)?(e.enter("setextHeadingLine"),a=d,c(d)):i(d)}function c(d){return e.enter("setextHeadingLineSequence"),h(d)}function h(d){return d===a?(e.consume(d),h):(e.exit("setextHeadingLineSequence"),gt(d)?Et(e,p,"lineSuffix")(d):p(d))}function p(d){return d===null||Ye(d)?(e.exit("setextHeadingLine"),t(d)):i(d)}}const bT={tokenize:vT};function vT(e){const t=this,i=e.attempt(Go,s,e.attempt(this.parser.constructs.flowInitial,a,Et(e,e.attempt(this.parser.constructs.flow,a,e.attempt(k5,a)),"linePrefix")));return i;function s(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,i}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,i}}const yT={resolveAll:V0()},ST=K0("string"),wT=K0("text");function K0(e){return{resolveAll:V0(e==="text"?CT:void 0),tokenize:t};function t(i){const s=this,a=this.parser.constructs[e],o=i.attempt(a,c,h);return c;function c(x){return d(x)?o(x):h(x)}function h(x){if(x===null){i.consume(x);return}return i.enter("data"),i.consume(x),p}function p(x){return d(x)?(i.exit("data"),o(x)):(i.consume(x),p)}function d(x){if(x===null)return!0;const _=a[x];let b=-1;if(_)for(;++b<_.length;){const v=_[b];if(!v.previous||v.previous.call(s,s.previous))return!0}return!1}}}function V0(e){return t;function t(i,s){let a=-1,o;for(;++a<=i.length;)o===void 0?i[a]&&i[a][1].type==="data"&&(o=a,a++):(!i[a]||i[a][1].type!=="data")&&(a!==o+2&&(i[o][1].end=i[a-1][1].end,i.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(i,s):i}}function CT(e,t){let i=0;for(;++i<=e.length;)if((i===e.length||e[i][1].type==="lineEnding")&&e[i-1][1].type==="data"){const s=e[i-1][1],a=t.sliceStream(s);let o=a.length,c=-1,h=0,p;for(;o--;){const d=a[o];if(typeof d=="string"){for(c=d.length;d.charCodeAt(c-1)===32;)h++,c--;if(c)break;c=-1}else if(d===-2)p=!0,h++;else if(d!==-1){o++;break}}if(t._contentTypeTextTrailing&&i===e.length&&(h=0),h){const d={type:i===e.length||p||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:s.start._bufferIndex+c,_index:s.start._index+o,line:s.end.line,column:s.end.column-h,offset:s.end.offset-h},end:{...s.end}};s.end={...d.start},s.start.offset===s.end.offset?Object.assign(s,d):(e.splice(i,0,["enter",d,t],["exit",d,t]),i+=2)}i++}return e}const kT={42:Ln,43:Ln,45:Ln,48:Ln,49:Ln,50:Ln,51:Ln,52:Ln,53:Ln,54:Ln,55:Ln,56:Ln,57:Ln,62:U0},ET={91:A5},NT={[-2]:xf,[-1]:xf,32:xf},TT={35:O5,42:yu,45:[Nv,yu],60:H5,61:Nv,95:yu,96:kv,126:kv},jT={38:F0,92:$0},AT={[-5]:bf,[-4]:bf,[-3]:bf,33:rT,38:F0,42:Tp,60:[a5,Y5],91:aT,92:[B5,$0],93:om,95:Tp,96:b5},RT={null:[Tp,yT]},DT={null:[42,95]},MT={null:[]},BT=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:DT,contentInitial:ET,disable:MT,document:kT,flow:TT,flowInitial:NT,insideSpan:RT,string:jT,text:AT},Symbol.toStringTag,{value:"Module"}));function LT(e,t,i){let s={_bufferIndex:-1,_index:0,line:i&&i.line||1,column:i&&i.column||1,offset:i&&i.offset||0};const a={},o=[];let c=[],h=[];const p={attempt:I(te),check:I(L),consume:H,enter:z,exit:R,interrupt:I(L,{interrupt:!0})},d={code:null,containerState:{},defineSkip:N,events:[],now:S,parser:e,previous:null,sliceSerialize:b,sliceStream:v,write:_};let x=t.tokenize.call(d,p);return t.resolveAll&&o.push(t),d;function _(J){return c=ur(c,J),M(),c[c.length-1]!==null?[]:(re(t,0),d.events=$u(o,d.events,d),d.events)}function b(J,F){return zT(v(J),F)}function v(J){return OT(c,J)}function S(){const{_bufferIndex:J,_index:F,line:G,column:Y,offset:U}=s;return{_bufferIndex:J,_index:F,line:G,column:Y,offset:U}}function N(J){a[J.line]=J.column,j()}function M(){let J;for(;s._index<c.length;){const F=c[s._index];if(typeof F=="string")for(J=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===J&&s._bufferIndex<F.length;)E(F.charCodeAt(s._bufferIndex));else E(F)}}function E(J){x=x(J)}function H(J){Ye(J)?(s.line++,s.column=1,s.offset+=J===-3?2:1,j()):J!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===c[s._index].length&&(s._bufferIndex=-1,s._index++)),d.previous=J}function z(J,F){const G=F||{};return G.type=J,G.start=S(),d.events.push(["enter",G,d]),h.push(G),G}function R(J){const F=h.pop();return F.end=S(),d.events.push(["exit",F,d]),F}function te(J,F){re(J,F.from)}function L(J,F){F.restore()}function I(J,F){return G;function G(Y,U,A){let q,$,be,T;return Array.isArray(Y)?V(Y):"tokenize"in Y?V([Y]):D(Y);function D(de){return X;function X(ue){const ye=ue!==null&&de[ue],fe=ue!==null&&de.null,Pe=[...Array.isArray(ye)?ye:ye?[ye]:[],...Array.isArray(fe)?fe:fe?[fe]:[]];return V(Pe)(ue)}}function V(de){return q=de,$=0,de.length===0?A:k(de[$])}function k(de){return X;function X(ue){return T=_e(),be=de,de.partial||(d.currentConstruct=de),de.name&&d.parser.constructs.disable.null.includes(de.name)?ne():de.tokenize.call(F?Object.assign(Object.create(d),F):d,p,le,ne)(ue)}}function le(de){return J(be,T),U}function ne(de){return T.restore(),++$<q.length?k(q[$]):A}}}function re(J,F){J.resolveAll&&!o.includes(J)&&o.push(J),J.resolve&&Yn(d.events,F,d.events.length-F,J.resolve(d.events.slice(F),d)),J.resolveTo&&(d.events=J.resolveTo(d.events,d))}function _e(){const J=S(),F=d.previous,G=d.currentConstruct,Y=d.events.length,U=Array.from(h);return{from:Y,restore:A};function A(){s=J,d.previous=F,d.currentConstruct=G,d.events.length=Y,h=U,j()}}function j(){s.line in a&&s.column<2&&(s.column=a[s.line],s.offset+=a[s.line]-1)}}function OT(e,t){const i=t.start._index,s=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;let c;if(i===a)c=[e[i].slice(s,o)];else{if(c=e.slice(i,a),s>-1){const h=c[0];typeof h=="string"?c[0]=h.slice(s):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function zT(e,t){let i=-1;const s=[];let a;for(;++i<e.length;){const o=e[i];let c;if(typeof o=="string")c=o;else switch(o){case-5:{c="\r";break}case-4:{c=`
103
+ `;break}case-3:{c=`\r
104
+ `;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&a)continue;c=" ";break}default:c=String.fromCharCode(o)}a=o===-2,s.push(c)}return s.join("")}function PT(e){const s={constructs:I0([BT,...(e||{}).extensions||[]]),content:a(JN),defined:[],document:a(t5),flow:a(bT),lazy:{},string:a(ST),text:a(wT)};return s;function a(o){return c;function c(h){return LT(s,o,h)}}}function IT(e){for(;!q0(e););return e}const Tv=/[\0\t\n\r]/g;function HT(){let e=1,t="",i=!0,s;return a;function a(o,c,h){const p=[];let d,x,_,b,v;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(c||void 0).decode(o)),_=0,t="",i&&(o.charCodeAt(0)===65279&&_++,i=void 0);_<o.length;){if(Tv.lastIndex=_,d=Tv.exec(o),b=d&&d.index!==void 0?d.index:o.length,v=o.charCodeAt(b),!d){t=o.slice(_);break}if(v===10&&_===b&&s)p.push(-3),s=void 0;else switch(s&&(p.push(-5),s=void 0),_<b&&(p.push(o.slice(_,b)),e+=b-_),v){case 0:{p.push(65533),e++;break}case 9:{for(x=Math.ceil(e/4)*4,p.push(-2);e++<x;)p.push(-1);break}case 10:{p.push(-4),e=1;break}default:s=!0,e=1}_=b+1}return h&&(s&&p.push(-5),t&&p.push(t),p.push(null)),p}}const UT=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function $T(e){return e.replace(UT,FT)}function FT(e,t,i){if(t)return t;if(i.charCodeAt(0)===35){const a=i.charCodeAt(1),o=a===120||a===88;return H0(i.slice(o?2:1),o?16:10)}return lm(i)||e}const X0={}.hasOwnProperty;function qT(e,t,i){return t&&typeof t=="object"&&(i=t,t=void 0),WT(i)(IT(PT(i).document().write(HT()(e,t,!0))))}function WT(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(qe),autolinkProtocol:_e,autolinkEmail:_e,atxHeading:o(ft),blockQuote:o(fe),characterEscape:_e,characterReference:_e,codeFenced:o(Pe),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:o(Pe,c),codeText:o($e,c),codeTextData:_e,data:_e,codeFlowValue:_e,definition:o(Oe),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:o(Ke),hardBreakEscape:o(tt),hardBreakTrailing:o(tt),htmlFlow:o(Fe,c),htmlFlowData:_e,htmlText:o(Fe,c),htmlTextData:_e,image:o(ze),label:c,link:o(qe),listItem:o(wt),listItemValue:b,listOrdered:o(Gt,_),listUnordered:o(Gt),paragraph:o(ki),reference:k,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:o(ft),strong:o(Ei),thematicBreak:o(Li)},exit:{atxHeading:p(),atxHeadingSequence:te,autolink:p(),autolinkEmail:ye,autolinkProtocol:ue,blockQuote:p(),characterEscapeValue:j,characterReferenceMarkerHexadecimal:ne,characterReferenceMarkerNumeric:ne,characterReferenceValue:de,characterReference:X,codeFenced:p(M),codeFencedFence:N,codeFencedFenceInfo:v,codeFencedFenceMeta:S,codeFlowValue:j,codeIndented:p(E),codeText:p(U),codeTextData:j,data:j,definition:p(),definitionDestinationString:R,definitionLabelString:H,definitionTitleString:z,emphasis:p(),hardBreakEscape:p(F),hardBreakTrailing:p(F),htmlFlow:p(G),htmlFlowData:j,htmlText:p(Y),htmlTextData:j,image:p(q),label:be,labelText:$,lineEnding:J,link:p(A),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:le,resourceDestinationString:T,resourceTitleString:D,resource:V,setextHeading:p(re),setextHeadingLineSequence:I,setextHeadingText:L,strong:p(),thematicBreak:p()}};Z0(t,(e||{}).mdastExtensions||[]);const i={};return s;function s(oe){let se={type:"root",children:[]};const Ie={stack:[se],tokenStack:[],config:t,enter:h,exit:d,buffer:c,resume:x,data:i},je=[];let De=-1;for(;++De<oe.length;)if(oe[De][1].type==="listOrdered"||oe[De][1].type==="listUnordered")if(oe[De][0]==="enter")je.push(De);else{const Ct=je.pop();De=a(oe,Ct,De)}for(De=-1;++De<oe.length;){const Ct=t[oe[De][0]];X0.call(Ct,oe[De][1].type)&&Ct[oe[De][1].type].call(Object.assign({sliceSerialize:oe[De][2].sliceSerialize},Ie),oe[De][1])}if(Ie.tokenStack.length>0){const Ct=Ie.tokenStack[Ie.tokenStack.length-1];(Ct[1]||jv).call(Ie,void 0,Ct[0])}for(se.position={start:Bs(oe.length>0?oe[0][1].start:{line:1,column:1,offset:0}),end:Bs(oe.length>0?oe[oe.length-2][1].end:{line:1,column:1,offset:0})},De=-1;++De<t.transforms.length;)se=t.transforms[De](se)||se;return se}function a(oe,se,Ie){let je=se-1,De=-1,Ct=!1,_t,nt,xt,Tt;for(;++je<=Ie;){const ct=oe[je];switch(ct[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ct[0]==="enter"?De++:De--,Tt=void 0;break}case"lineEndingBlank":{ct[0]==="enter"&&(_t&&!Tt&&!De&&!xt&&(xt=je),Tt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Tt=void 0}if(!De&&ct[0]==="enter"&&ct[1].type==="listItemPrefix"||De===-1&&ct[0]==="exit"&&(ct[1].type==="listUnordered"||ct[1].type==="listOrdered")){if(_t){let ui=je;for(nt=void 0;ui--;){const ei=oe[ui];if(ei[1].type==="lineEnding"||ei[1].type==="lineEndingBlank"){if(ei[0]==="exit")continue;nt&&(oe[nt][1].type="lineEndingBlank",Ct=!0),ei[1].type="lineEnding",nt=ui}else if(!(ei[1].type==="linePrefix"||ei[1].type==="blockQuotePrefix"||ei[1].type==="blockQuotePrefixWhitespace"||ei[1].type==="blockQuoteMarker"||ei[1].type==="listItemIndent"))break}xt&&(!nt||xt<nt)&&(_t._spread=!0),_t.end=Object.assign({},nt?oe[nt][1].start:ct[1].end),oe.splice(nt||je,0,["exit",_t,ct[2]]),je++,Ie++}if(ct[1].type==="listItemPrefix"){const ui={type:"listItem",_spread:!1,start:Object.assign({},ct[1].start),end:void 0};_t=ui,oe.splice(je,0,["enter",ui,ct[2]]),je++,Ie++,xt=void 0,Tt=!0}}}return oe[se][1]._spread=Ct,Ie}function o(oe,se){return Ie;function Ie(je){h.call(this,oe(je),je),se&&se.call(this,je)}}function c(){this.stack.push({type:"fragment",children:[]})}function h(oe,se,Ie){this.stack[this.stack.length-1].children.push(oe),this.stack.push(oe),this.tokenStack.push([se,Ie||void 0]),oe.position={start:Bs(se.start),end:void 0}}function p(oe){return se;function se(Ie){oe&&oe.call(this,Ie),d.call(this,Ie)}}function d(oe,se){const Ie=this.stack.pop(),je=this.tokenStack.pop();if(je)je[0].type!==oe.type&&(se?se.call(this,oe,je[0]):(je[1]||jv).call(this,oe,je[0]));else throw new Error("Cannot close `"+oe.type+"` ("+Ao({start:oe.start,end:oe.end})+"): it’s not open");Ie.position.end=Bs(oe.end)}function x(){return am(this.stack.pop())}function _(){this.data.expectingFirstListItemValue=!0}function b(oe){if(this.data.expectingFirstListItemValue){const se=this.stack[this.stack.length-2];se.start=Number.parseInt(this.sliceSerialize(oe),10),this.data.expectingFirstListItemValue=void 0}}function v(){const oe=this.resume(),se=this.stack[this.stack.length-1];se.lang=oe}function S(){const oe=this.resume(),se=this.stack[this.stack.length-1];se.meta=oe}function N(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function M(){const oe=this.resume(),se=this.stack[this.stack.length-1];se.value=oe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const oe=this.resume(),se=this.stack[this.stack.length-1];se.value=oe.replace(/(\r?\n|\r)$/g,"")}function H(oe){const se=this.resume(),Ie=this.stack[this.stack.length-1];Ie.label=se,Ie.identifier=xr(this.sliceSerialize(oe)).toLowerCase()}function z(){const oe=this.resume(),se=this.stack[this.stack.length-1];se.title=oe}function R(){const oe=this.resume(),se=this.stack[this.stack.length-1];se.url=oe}function te(oe){const se=this.stack[this.stack.length-1];if(!se.depth){const Ie=this.sliceSerialize(oe).length;se.depth=Ie}}function L(){this.data.setextHeadingSlurpLineEnding=!0}function I(oe){const se=this.stack[this.stack.length-1];se.depth=this.sliceSerialize(oe).codePointAt(0)===61?1:2}function re(){this.data.setextHeadingSlurpLineEnding=void 0}function _e(oe){const Ie=this.stack[this.stack.length-1].children;let je=Ie[Ie.length-1];(!je||je.type!=="text")&&(je=yt(),je.position={start:Bs(oe.start),end:void 0},Ie.push(je)),this.stack.push(je)}function j(oe){const se=this.stack.pop();se.value+=this.sliceSerialize(oe),se.position.end=Bs(oe.end)}function J(oe){const se=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ie=se.children[se.children.length-1];Ie.position.end=Bs(oe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(se.type)&&(_e.call(this,oe),j.call(this,oe))}function F(){this.data.atHardBreak=!0}function G(){const oe=this.resume(),se=this.stack[this.stack.length-1];se.value=oe}function Y(){const oe=this.resume(),se=this.stack[this.stack.length-1];se.value=oe}function U(){const oe=this.resume(),se=this.stack[this.stack.length-1];se.value=oe}function A(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const se=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=se,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function q(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const se=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=se,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function $(oe){const se=this.sliceSerialize(oe),Ie=this.stack[this.stack.length-2];Ie.label=$T(se),Ie.identifier=xr(se).toLowerCase()}function be(){const oe=this.stack[this.stack.length-1],se=this.resume(),Ie=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ie.type==="link"){const je=oe.children;Ie.children=je}else Ie.alt=se}function T(){const oe=this.resume(),se=this.stack[this.stack.length-1];se.url=oe}function D(){const oe=this.resume(),se=this.stack[this.stack.length-1];se.title=oe}function V(){this.data.inReference=void 0}function k(){this.data.referenceType="collapsed"}function le(oe){const se=this.resume(),Ie=this.stack[this.stack.length-1];Ie.label=se,Ie.identifier=xr(this.sliceSerialize(oe)).toLowerCase(),this.data.referenceType="full"}function ne(oe){this.data.characterReferenceType=oe.type}function de(oe){const se=this.sliceSerialize(oe),Ie=this.data.characterReferenceType;let je;Ie?(je=H0(se,Ie==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):je=lm(se);const De=this.stack[this.stack.length-1];De.value+=je}function X(oe){const se=this.stack.pop();se.position.end=Bs(oe.end)}function ue(oe){j.call(this,oe);const se=this.stack[this.stack.length-1];se.url=this.sliceSerialize(oe)}function ye(oe){j.call(this,oe);const se=this.stack[this.stack.length-1];se.url="mailto:"+this.sliceSerialize(oe)}function fe(){return{type:"blockquote",children:[]}}function Pe(){return{type:"code",lang:null,meta:null,value:""}}function $e(){return{type:"inlineCode",value:""}}function Oe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ke(){return{type:"emphasis",children:[]}}function ft(){return{type:"heading",depth:0,children:[]}}function tt(){return{type:"break"}}function Fe(){return{type:"html",value:""}}function ze(){return{type:"image",title:null,url:"",alt:null}}function qe(){return{type:"link",title:null,url:"",children:[]}}function Gt(oe){return{type:"list",ordered:oe.type==="listOrdered",start:null,spread:oe._spread,children:[]}}function wt(oe){return{type:"listItem",spread:oe._spread,checked:null,children:[]}}function ki(){return{type:"paragraph",children:[]}}function Ei(){return{type:"strong",children:[]}}function yt(){return{type:"text",value:""}}function Li(){return{type:"thematicBreak"}}}function Bs(e){return{line:e.line,column:e.column,offset:e.offset}}function Z0(e,t){let i=-1;for(;++i<t.length;){const s=t[i];Array.isArray(s)?Z0(e,s):GT(e,s)}}function GT(e,t){let i;for(i in t)if(X0.call(t,i))switch(i){case"canContainEols":{const s=t[i];s&&e[i].push(...s);break}case"transforms":{const s=t[i];s&&e[i].push(...s);break}case"enter":case"exit":{const s=t[i];s&&Object.assign(e[i],s);break}}}function jv(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ao({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ao({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ao({start:t.start,end:t.end})+") is still open")}function YT(e){const t=this;t.parser=i;function i(s){return qT(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function KT(e,t){const i={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,i),e.applyData(t,i)}function VT(e,t){const i={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,i),[e.applyData(t,i),{type:"text",value:`
105
+ `}]}function XT(e,t){const i=t.value?t.value+`
106
+ `:"",s={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(s.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:i}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function ZT(e,t){const i={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function QT(e,t){const i={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function JT(e,t){const i=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=gl(s.toLowerCase()),o=e.footnoteOrder.indexOf(s);let c,h=e.footnoteCounts.get(s);h===void 0?(h=0,e.footnoteOrder.push(s),c=e.footnoteOrder.length):c=o+1,h+=1,e.footnoteCounts.set(s,h);const p={type:"element",tagName:"a",properties:{href:"#"+i+"fn-"+a,id:i+"fnref-"+a+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,p);const d={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,d),e.applyData(t,d)}function ej(e,t){const i={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function tj(e,t){if(e.options.allowDangerousHtml){const i={type:"raw",value:t.value};return e.patch(t,i),e.applyData(t,i)}}function Q0(e,t){const i=t.referenceType;let s="]";if(i==="collapsed"?s+="[]":i==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const c=a[a.length-1];return c&&c.type==="text"?c.value+=s:a.push({type:"text",value:s}),a}function ij(e,t){const i=String(t.identifier).toUpperCase(),s=e.definitionById.get(i);if(!s)return Q0(e,t);const a={src:gl(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function nj(e,t){const i={src:gl(t.url)};t.alt!==null&&t.alt!==void 0&&(i.alt=t.alt),t.title!==null&&t.title!==void 0&&(i.title=t.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function rj(e,t){const i={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,i);const s={type:"element",tagName:"code",properties:{},children:[i]};return e.patch(t,s),e.applyData(t,s)}function sj(e,t){const i=String(t.identifier).toUpperCase(),s=e.definitionById.get(i);if(!s)return Q0(e,t);const a={href:gl(s.url||"")};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function aj(e,t){const i={href:gl(t.url)};t.title!==null&&t.title!==void 0&&(i.title=t.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function lj(e,t,i){const s=e.all(t),a=i?oj(i):J0(t),o={},c=[];if(typeof t.checked=="boolean"){const x=s[0];let _;x&&x.type==="element"&&x.tagName==="p"?_=x:(_={type:"element",tagName:"p",properties:{},children:[]},s.unshift(_)),_.children.length>0&&_.children.unshift({type:"text",value:" "}),_.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let h=-1;for(;++h<s.length;){const x=s[h];(a||h!==0||x.type!=="element"||x.tagName!=="p")&&c.push({type:"text",value:`
107
+ `}),x.type==="element"&&x.tagName==="p"&&!a?c.push(...x.children):c.push(x)}const p=s[s.length-1];p&&(a||p.type!=="element"||p.tagName!=="p")&&c.push({type:"text",value:`
108
+ `});const d={type:"element",tagName:"li",properties:o,children:c};return e.patch(t,d),e.applyData(t,d)}function oj(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const i=e.children;let s=-1;for(;!t&&++s<i.length;)t=J0(i[s])}return t}function J0(e){const t=e.spread;return t??e.children.length>1}function cj(e,t){const i={},s=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(i.start=t.start);++a<s.length;){const c=s[a];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){i.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:i,children:e.wrap(s,!0)};return e.patch(t,o),e.applyData(t,o)}function uj(e,t){const i={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function hj(e,t){const i={type:"root",children:e.wrap(e.all(t))};return e.patch(t,i),e.applyData(t,i)}function dj(e,t){const i={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function fj(e,t){const i=e.all(t),s=i.shift(),a=[];if(s){const c={type:"element",tagName:"thead",properties:{},children:e.wrap([s],!0)};e.patch(t.children[0],c),a.push(c)}if(i.length>0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(i,!0)},h=im(t.children[1]),p=R0(t.children[t.children.length-1]);h&&p&&(c.position={start:h,end:p}),a.push(c)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function pj(e,t,i){const s=i?i.children:void 0,o=(s?s.indexOf(t):1)===0?"th":"td",c=i&&i.type==="table"?i.align:void 0,h=c?c.length:t.children.length;let p=-1;const d=[];for(;++p<h;){const _=t.children[p],b={},v=c?c[p]:void 0;v&&(b.align=v);let S={type:"element",tagName:o,properties:b,children:[]};_&&(S.children=e.all(_),e.patch(_,S),S=e.applyData(_,S)),d.push(S)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,x),e.applyData(t,x)}function mj(e,t){const i={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}const Av=9,Rv=32;function gj(e){const t=String(e),i=/\r?\n|\r/g;let s=i.exec(t),a=0;const o=[];for(;s;)o.push(Dv(t.slice(a,s.index),a>0,!0),s[0]),a=s.index+s[0].length,s=i.exec(t);return o.push(Dv(t.slice(a),a>0,!1)),o.join("")}function Dv(e,t,i){let s=0,a=e.length;if(t){let o=e.codePointAt(s);for(;o===Av||o===Rv;)s++,o=e.codePointAt(s)}if(i){let o=e.codePointAt(a-1);for(;o===Av||o===Rv;)a--,o=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function _j(e,t){const i={type:"text",value:gj(String(t.value))};return e.patch(t,i),e.applyData(t,i)}function xj(e,t){const i={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,i),e.applyData(t,i)}const bj={blockquote:KT,break:VT,code:XT,delete:ZT,emphasis:QT,footnoteReference:JT,heading:ej,html:tj,imageReference:ij,image:nj,inlineCode:rj,linkReference:sj,link:aj,listItem:lj,list:cj,paragraph:uj,root:hj,strong:dj,table:fj,tableCell:mj,tableRow:pj,text:_j,thematicBreak:xj,toml:lu,yaml:lu,definition:lu,footnoteDefinition:lu};function lu(){}const eS=-1,Fu=0,Do=1,Ru=2,cm=3,um=4,hm=5,dm=6,tS=7,iS=8,Mv=typeof self=="object"?self:globalThis,vj=(e,t)=>{const i=(a,o)=>(e.set(o,a),a),s=a=>{if(e.has(a))return e.get(a);const[o,c]=t[a];switch(o){case Fu:case eS:return i(c,a);case Do:{const h=i([],a);for(const p of c)h.push(s(p));return h}case Ru:{const h=i({},a);for(const[p,d]of c)h[s(p)]=s(d);return h}case cm:return i(new Date(c),a);case um:{const{source:h,flags:p}=c;return i(new RegExp(h,p),a)}case hm:{const h=i(new Map,a);for(const[p,d]of c)h.set(s(p),s(d));return h}case dm:{const h=i(new Set,a);for(const p of c)h.add(s(p));return h}case tS:{const{name:h,message:p}=c;return i(new Mv[h](p),a)}case iS:return i(BigInt(c),a);case"BigInt":return i(Object(BigInt(c)),a);case"ArrayBuffer":return i(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:h}=new Uint8Array(c);return i(new DataView(h),c)}}return i(new Mv[o](c),a)};return s},Bv=e=>vj(new Map,e)(0),sl="",{toString:yj}={},{keys:Sj}=Object,bo=e=>{const t=typeof e;if(t!=="object"||!e)return[Fu,t];const i=yj.call(e).slice(8,-1);switch(i){case"Array":return[Do,sl];case"Object":return[Ru,sl];case"Date":return[cm,sl];case"RegExp":return[um,sl];case"Map":return[hm,sl];case"Set":return[dm,sl];case"DataView":return[Do,i]}return i.includes("Array")?[Do,i]:i.includes("Error")?[tS,i]:[Ru,i]},ou=([e,t])=>e===Fu&&(t==="function"||t==="symbol"),wj=(e,t,i,s)=>{const a=(c,h)=>{const p=s.push(c)-1;return i.set(h,p),p},o=c=>{if(i.has(c))return i.get(c);let[h,p]=bo(c);switch(h){case Fu:{let x=c;switch(p){case"bigint":h=iS,x=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);x=null;break;case"undefined":return a([eS],c)}return a([h,x],c)}case Do:{if(p){let b=c;return p==="DataView"?b=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(b=new Uint8Array(c)),a([p,[...b]],c)}const x=[],_=a([h,x],c);for(const b of c)x.push(o(b));return _}case Ru:{if(p)switch(p){case"BigInt":return a([p,c.toString()],c);case"Boolean":case"Number":case"String":return a([p,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const x=[],_=a([h,x],c);for(const b of Sj(c))(e||!ou(bo(c[b])))&&x.push([o(b),o(c[b])]);return _}case cm:return a([h,c.toISOString()],c);case um:{const{source:x,flags:_}=c;return a([h,{source:x,flags:_}],c)}case hm:{const x=[],_=a([h,x],c);for(const[b,v]of c)(e||!(ou(bo(b))||ou(bo(v))))&&x.push([o(b),o(v)]);return _}case dm:{const x=[],_=a([h,x],c);for(const b of c)(e||!ou(bo(b)))&&x.push(o(b));return _}}const{message:d}=c;return a([h,{name:p,message:d}],c)};return o},Lv=(e,{json:t,lossy:i}={})=>{const s=[];return wj(!(t||i),!!t,new Map,s)(e),s},Po=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Bv(Lv(e,t)):structuredClone(e):(e,t)=>Bv(Lv(e,t));function Cj(e,t){const i=[{type:"text",value:"↩"}];return t>1&&i.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),i}function kj(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Ej(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=e.options.footnoteBackContent||Cj,s=e.options.footnoteBackLabel||kj,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},h=[];let p=-1;for(;++p<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[p]);if(!d)continue;const x=e.all(d),_=String(d.identifier).toUpperCase(),b=gl(_.toLowerCase());let v=0;const S=[],N=e.footnoteCounts.get(_);for(;N!==void 0&&++v<=N;){S.length>0&&S.push({type:"text",value:" "});let H=typeof i=="string"?i:i(p,v);typeof H=="string"&&(H={type:"text",value:H}),S.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+b+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(p,v),className:["data-footnote-backref"]},children:Array.isArray(H)?H:[H]})}const M=x[x.length-1];if(M&&M.type==="element"&&M.tagName==="p"){const H=M.children[M.children.length-1];H&&H.type==="text"?H.value+=" ":M.children.push({type:"text",value:" "}),M.children.push(...S)}else x.push(...S);const E={type:"element",tagName:"li",properties:{id:t+"fn-"+b},children:e.wrap(x,!0)};e.patch(d,E),h.push(E)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Po(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
109
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(h,!0)},{type:"text",value:`
110
+ `}]}}const qu=(function(e){if(e==null)return Aj;if(typeof e=="function")return Wu(e);if(typeof e=="object")return Array.isArray(e)?Nj(e):Tj(e);if(typeof e=="string")return jj(e);throw new Error("Expected function, string, or object as test")});function Nj(e){const t=[];let i=-1;for(;++i<e.length;)t[i]=qu(e[i]);return Wu(s);function s(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function Tj(e){const t=e;return Wu(i);function i(s){const a=s;let o;for(o in e)if(a[o]!==t[o])return!1;return!0}}function jj(e){return Wu(t);function t(i){return i&&i.type===e}}function Wu(e){return t;function t(i,s,a){return!!(Rj(i)&&e.call(this,i,typeof s=="number"?s:void 0,a||void 0))}}function Aj(){return!0}function Rj(e){return e!==null&&typeof e=="object"&&"type"in e}const nS=[],Dj=!0,jp=!1,Mj="skip";function rS(e,t,i,s){let a;typeof t=="function"&&typeof i!="function"?(s=i,i=t):a=t;const o=qu(a),c=s?-1:1;h(e,void 0,[])();function h(p,d,x){const _=p&&typeof p=="object"?p:{};if(typeof _.type=="string"){const v=typeof _.tagName=="string"?_.tagName:typeof _.name=="string"?_.name:void 0;Object.defineProperty(b,"name",{value:"node ("+(p.type+(v?"<"+v+">":""))+")"})}return b;function b(){let v=nS,S,N,M;if((!t||o(p,d,x[x.length-1]||void 0))&&(v=Bj(i(p,x)),v[0]===jp))return v;if("children"in p&&p.children){const E=p;if(E.children&&v[0]!==Mj)for(N=(s?E.children.length:-1)+c,M=x.concat(E);N>-1&&N<E.children.length;){const H=E.children[N];if(S=h(H,N,M)(),S[0]===jp)return S;N=typeof S[1]=="number"?S[1]:N+c}}return v}}}function Bj(e){return Array.isArray(e)?e:typeof e=="number"?[Dj,e]:e==null?nS:[e]}function fm(e,t,i,s){let a,o,c;typeof t=="function"&&typeof i!="function"?(o=void 0,c=t,a=i):(o=t,c=i,a=s),rS(e,o,h,a);function h(p,d){const x=d[d.length-1],_=x?x.children.indexOf(p):void 0;return c(p,_,x)}}const Ap={}.hasOwnProperty,Lj={};function Oj(e,t){const i=t||Lj,s=new Map,a=new Map,o=new Map,c={...bj,...i.handlers},h={all:d,applyData:Pj,definitionById:s,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:c,one:p,options:i,patch:zj,wrap:Hj};return fm(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const _=x.type==="definition"?s:a,b=String(x.identifier).toUpperCase();_.has(b)||_.set(b,x)}}),h;function p(x,_){const b=x.type,v=h.handlers[b];if(Ap.call(h.handlers,b)&&v)return v(h,x,_);if(h.options.passThrough&&h.options.passThrough.includes(b)){if("children"in x){const{children:N,...M}=x,E=Po(M);return E.children=h.all(x),E}return Po(x)}return(h.options.unknownHandler||Ij)(h,x,_)}function d(x){const _=[];if("children"in x){const b=x.children;let v=-1;for(;++v<b.length;){const S=h.one(b[v],x);if(S){if(v&&b[v-1].type==="break"&&(!Array.isArray(S)&&S.type==="text"&&(S.value=Ov(S.value)),!Array.isArray(S)&&S.type==="element")){const N=S.children[0];N&&N.type==="text"&&(N.value=Ov(N.value))}Array.isArray(S)?_.push(...S):_.push(S)}}}return _}}function zj(e,t){e.position&&(t.position=M0(e))}function Pj(e,t){let i=t;if(e&&e.data){const s=e.data.hName,a=e.data.hChildren,o=e.data.hProperties;if(typeof s=="string")if(i.type==="element")i.tagName=s;else{const c="children"in i?i.children:[i];i={type:"element",tagName:s,properties:{},children:c}}i.type==="element"&&o&&Object.assign(i.properties,Po(o)),"children"in i&&i.children&&a!==null&&a!==void 0&&(i.children=a)}return i}function Ij(e,t){const i=t.data||{},s="value"in t&&!(Ap.call(i,"hProperties")||Ap.call(i,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function Hj(e,t){const i=[];let s=-1;for(t&&i.push({type:"text",value:`
111
+ `});++s<e.length;)s&&i.push({type:"text",value:`
112
+ `}),i.push(e[s]);return t&&e.length>0&&i.push({type:"text",value:`
113
+ `}),i}function Ov(e){let t=0,i=e.charCodeAt(t);for(;i===9||i===32;)t++,i=e.charCodeAt(t);return e.slice(t)}function zv(e,t){const i=Oj(e,t),s=i.one(e,void 0),a=Ej(i),o=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&o.children.push({type:"text",value:`
114
+ `},a),o}function Uj(e,t){return e&&"run"in e?async function(i,s){const a=zv(i,{file:s,...t});await e.run(a,s)}:function(i,s){return zv(i,{file:s,...e||t})}}function Pv(e){if(e)throw e}var vf,Iv;function $j(){if(Iv)return vf;Iv=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(d){return typeof Array.isArray=="function"?Array.isArray(d):t.call(d)==="[object Array]"},o=function(d){if(!d||t.call(d)!=="[object Object]")return!1;var x=e.call(d,"constructor"),_=d.constructor&&d.constructor.prototype&&e.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!x&&!_)return!1;var b;for(b in d);return typeof b>"u"||e.call(d,b)},c=function(d,x){i&&x.name==="__proto__"?i(d,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):d[x.name]=x.newValue},h=function(d,x){if(x==="__proto__")if(e.call(d,x)){if(s)return s(d,x).value}else return;return d[x]};return vf=function p(){var d,x,_,b,v,S,N=arguments[0],M=1,E=arguments.length,H=!1;for(typeof N=="boolean"&&(H=N,N=arguments[1]||{},M=2),(N==null||typeof N!="object"&&typeof N!="function")&&(N={});M<E;++M)if(d=arguments[M],d!=null)for(x in d)_=h(N,x),b=h(d,x),N!==b&&(H&&b&&(o(b)||(v=a(b)))?(v?(v=!1,S=_&&a(_)?_:[]):S=_&&o(_)?_:{},c(N,{name:x,newValue:p(H,S,b)})):typeof b<"u"&&c(N,{name:x,newValue:b}));return N},vf}var Fj=$j();const yf=Ou(Fj);function Rp(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function qj(){const e=[],t={run:i,use:s};return t;function i(...a){let o=-1;const c=a.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);h(null,...a);function h(p,...d){const x=e[++o];let _=-1;if(p){c(p);return}for(;++_<a.length;)(d[_]===null||d[_]===void 0)&&(d[_]=a[_]);a=d,x?Wj(x,h)(...d):c(null,...d)}}function s(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function Wj(e,t){let i;return s;function s(...c){const h=e.length>c.length;let p;h&&c.push(a);try{p=e.apply(this,c)}catch(d){const x=d;if(h&&i)throw x;return a(x)}h||(p&&p.then&&typeof p.then=="function"?p.then(o,a):p instanceof Error?a(p):o(p))}function a(c,...h){i||(i=!0,t(c,...h))}function o(c){a(null,c)}}const jr={basename:Gj,dirname:Yj,extname:Kj,join:Vj,sep:"/"};function Gj(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Yo(e);let i=0,s=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){i=a+1;break}}else s<0&&(o=!0,s=a+1);return s<0?"":e.slice(i,s)}if(t===e)return"";let c=-1,h=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){i=a+1;break}}else c<0&&(o=!0,c=a+1),h>-1&&(e.codePointAt(a)===t.codePointAt(h--)?h<0&&(s=a):(h=-1,s=c));return i===s?s=c:s<0&&(s=e.length),e.slice(i,s)}function Yj(e){if(Yo(e),e.length===0)return".";let t=-1,i=e.length,s;for(;--i;)if(e.codePointAt(i)===47){if(s){t=i;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function Kj(e){Yo(e);let t=e.length,i=-1,s=0,a=-1,o=0,c;for(;t--;){const h=e.codePointAt(t);if(h===47){if(c){s=t+1;break}continue}i<0&&(c=!0,i=t+1),h===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||i<0||o===0||o===1&&a===i-1&&a===s+1?"":e.slice(a,i)}function Vj(...e){let t=-1,i;for(;++t<e.length;)Yo(e[t]),e[t]&&(i=i===void 0?e[t]:i+"/"+e[t]);return i===void 0?".":Xj(i)}function Xj(e){Yo(e);const t=e.codePointAt(0)===47;let i=Zj(e,!t);return i.length===0&&!t&&(i="."),i.length>0&&e.codePointAt(e.length-1)===47&&(i+="/"),t?"/"+i:i}function Zj(e,t){let i="",s=0,a=-1,o=0,c=-1,h,p;for(;++c<=e.length;){if(c<e.length)h=e.codePointAt(c);else{if(h===47)break;h=47}if(h===47){if(!(a===c-1||o===1))if(a!==c-1&&o===2){if(i.length<2||s!==2||i.codePointAt(i.length-1)!==46||i.codePointAt(i.length-2)!==46){if(i.length>2){if(p=i.lastIndexOf("/"),p!==i.length-1){p<0?(i="",s=0):(i=i.slice(0,p),s=i.length-1-i.lastIndexOf("/")),a=c,o=0;continue}}else if(i.length>0){i="",s=0,a=c,o=0;continue}}t&&(i=i.length>0?i+"/..":"..",s=2)}else i.length>0?i+="/"+e.slice(a+1,c):i=e.slice(a+1,c),s=c-a-1;a=c,o=0}else h===46&&o>-1?o++:o=-1}return i}function Yo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Qj={cwd:Jj};function Jj(){return"/"}function Dp(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function eA(e){if(typeof e=="string")e=new URL(e);else if(!Dp(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return tA(e)}function tA(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let i=-1;for(;++i<t.length;)if(t.codePointAt(i)===37&&t.codePointAt(i+1)===50){const s=t.codePointAt(i+2);if(s===70||s===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const Sf=["history","path","basename","stem","extname","dirname"];class sS{constructor(t){let i;t?Dp(t)?i={path:t}:typeof t=="string"||iA(t)?i={value:t}:i=t:i={},this.cwd="cwd"in i?"":Qj.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<Sf.length;){const o=Sf[s];o in i&&i[o]!==void 0&&i[o]!==null&&(this[o]=o==="history"?[...i[o]]:i[o])}let a;for(a in i)Sf.includes(a)||(this[a]=i[a])}get basename(){return typeof this.path=="string"?jr.basename(this.path):void 0}set basename(t){Cf(t,"basename"),wf(t,"basename"),this.path=jr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?jr.dirname(this.path):void 0}set dirname(t){Hv(this.basename,"dirname"),this.path=jr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?jr.extname(this.path):void 0}set extname(t){if(wf(t,"extname"),Hv(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=jr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Dp(t)&&(t=eA(t)),Cf(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?jr.basename(this.path,this.extname):void 0}set stem(t){Cf(t,"stem"),wf(t,"stem"),this.path=jr.join(this.dirname||"",t+(this.extname||""))}fail(t,i,s){const a=this.message(t,i,s);throw a.fatal=!0,a}info(t,i,s){const a=this.message(t,i,s);return a.fatal=void 0,a}message(t,i,s){const a=new pn(t,i,s);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function wf(e,t){if(e&&e.includes(jr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+jr.sep+"`")}function Cf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Hv(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function iA(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const nA=(function(e){const s=this.constructor.prototype,a=s[e],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,s),o}),rA={}.hasOwnProperty;class pm extends nA{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=qj()}copy(){const t=new pm;let i=-1;for(;++i<this.attachers.length;){const s=this.attachers[i];t.use(...s)}return t.data(yf(!0,{},this.namespace)),t}data(t,i){return typeof t=="string"?arguments.length===2?(Nf("data",this.frozen),this.namespace[t]=i,this):rA.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Nf("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[i,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const a=i.call(t,...s);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const i=cu(t),s=this.parser||this.Parser;return kf("parse",s),s(String(i),i)}process(t,i){const s=this;return this.freeze(),kf("process",this.parser||this.Parser),Ef("process",this.compiler||this.Compiler),i?a(void 0,i):new Promise(a);function a(o,c){const h=cu(t),p=s.parse(h);s.run(p,h,function(x,_,b){if(x||!_||!b)return d(x);const v=_,S=s.stringify(v,b);lA(S)?b.value=S:b.result=S,d(x,b)});function d(x,_){x||!_?c(x):o?o(_):i(void 0,_)}}}processSync(t){let i=!1,s;return this.freeze(),kf("processSync",this.parser||this.Parser),Ef("processSync",this.compiler||this.Compiler),this.process(t,a),$v("processSync","process",i),s;function a(o,c){i=!0,Pv(o),s=c}}run(t,i,s){Uv(t),this.freeze();const a=this.transformers;return!s&&typeof i=="function"&&(s=i,i=void 0),s?o(void 0,s):new Promise(o);function o(c,h){const p=cu(i);a.run(t,p,d);function d(x,_,b){const v=_||t;x?h(x):c?c(v):s(void 0,v,b)}}}runSync(t,i){let s=!1,a;return this.run(t,i,o),$v("runSync","run",s),a;function o(c,h){Pv(c),a=h,s=!0}}stringify(t,i){this.freeze();const s=cu(i),a=this.compiler||this.Compiler;return Ef("stringify",a),Uv(t),a(t,s)}use(t,...i){const s=this.attachers,a=this.namespace;if(Nf("use",this.frozen),t!=null)if(typeof t=="function")p(t,i);else if(typeof t=="object")Array.isArray(t)?h(t):c(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(d){if(typeof d=="function")p(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[x,..._]=d;p(x,_)}else c(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function c(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");h(d.plugins),d.settings&&(a.settings=yf(!0,a.settings,d.settings))}function h(d){let x=-1;if(d!=null)if(Array.isArray(d))for(;++x<d.length;){const _=d[x];o(_)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function p(d,x){let _=-1,b=-1;for(;++_<s.length;)if(s[_][0]===d){b=_;break}if(b===-1)s.push([d,...x]);else if(x.length>0){let[v,...S]=x;const N=s[b][1];Rp(N)&&Rp(v)&&(v=yf(!0,N,v)),s[b]=[d,v,...S]}}}}const sA=new pm().freeze();function kf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Ef(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Nf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Uv(e){if(!Rp(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function $v(e,t,i){if(!i)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function cu(e){return aA(e)?e:new sS(e)}function aA(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function lA(e){return typeof e=="string"||oA(e)}function oA(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const cA="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Fv=[],qv={allowDangerousHtml:!0},uA=/^(https?|ircs?|mailto|xmpp)$/i,hA=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function dA(e){const t=fA(e),i=pA(e);return mA(t.runSync(t.parse(i),i),e)}function fA(e){const t=e.rehypePlugins||Fv,i=e.remarkPlugins||Fv,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...qv}:qv;return sA().use(YT).use(i).use(Uj,s).use(t)}function pA(e){const t=e.children||"",i=new sS;return typeof t=="string"&&(i.value=t),i}function mA(e,t){const i=t.allowedElements,s=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,h=t.unwrapDisallowed,p=t.urlTransform||gA;for(const x of hA)Object.hasOwn(t,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+cA+x.id,void 0);return fm(e,d),AN(e,{Fragment:f.Fragment,components:a,ignoreInvalidStyle:!0,jsx:f.jsx,jsxs:f.jsxs,passKeys:!0,passNode:!0});function d(x,_,b){if(x.type==="raw"&&b&&typeof _=="number")return c?b.children.splice(_,1):b.children[_]={type:"text",value:x.value},_;if(x.type==="element"){let v;for(v in _f)if(Object.hasOwn(_f,v)&&Object.hasOwn(x.properties,v)){const S=x.properties[v],N=_f[v];(N===null||N.includes(x.tagName))&&(x.properties[v]=p(String(S||""),v,x))}}if(x.type==="element"){let v=i?!i.includes(x.tagName):o?o.includes(x.tagName):!1;if(!v&&s&&typeof _=="number"&&(v=!s(x,_,b)),v&&b&&typeof _=="number")return h&&x.children?b.children.splice(_,1,...x.children):b.children.splice(_,1),_}}}function gA(e){const t=e.indexOf(":"),i=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||i!==-1&&t>i||s!==-1&&t>s||uA.test(e.slice(0,t))?e:""}function _A(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function aS(e,t,i){const a=qu((i||{}).ignore||[]),o=xA(t);let c=-1;for(;++c<o.length;)rS(e,"text",h);function h(d,x){let _=-1,b;for(;++_<x.length;){const v=x[_],S=b?b.children:void 0;if(a(v,S?S.indexOf(v):void 0,b))return;b=v}if(b)return p(d,x)}function p(d,x){const _=x[x.length-1],b=o[c][0],v=o[c][1];let S=0;const M=_.children.indexOf(d);let E=!1,H=[];b.lastIndex=0;let z=b.exec(d.value);for(;z;){const R=z.index,te={index:z.index,input:z.input,stack:[...x,d]};let L=v(...z,te);if(typeof L=="string"&&(L=L.length>0?{type:"text",value:L}:void 0),L===!1?b.lastIndex=R+1:(S!==R&&H.push({type:"text",value:d.value.slice(S,R)}),Array.isArray(L)?H.push(...L):L&&H.push(L),S=R+z[0].length,E=!0),!b.global)break;z=b.exec(d.value)}return E?(S<d.value.length&&H.push({type:"text",value:d.value.slice(S)}),_.children.splice(M,1,...H)):H=[d],M+H.length}}function xA(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const i=!e[0]||Array.isArray(e[0])?e:[e];let s=-1;for(;++s<i.length;){const a=i[s];t.push([bA(a[0]),vA(a[1])])}return t}function bA(e){return typeof e=="string"?new RegExp(_A(e),"g"):e}function vA(e){return typeof e=="function"?e:function(){return e}}function yA(e){aS(e,[/\r?\n|\r/g,SA])}function SA(){return{type:"break"}}function wA(){return function(e){yA(e)}}function Wv(e,t){const i=String(e);if(typeof t!="string")throw new TypeError("Expected character");let s=0,a=i.indexOf(t);for(;a!==-1;)s++,a=i.indexOf(t,a+t.length);return s}const Tf="phrasing",jf=["autolink","link","image","label"];function CA(){return{transforms:[RA],enter:{literalAutolink:EA,literalAutolinkEmail:Af,literalAutolinkHttp:Af,literalAutolinkWww:Af},exit:{literalAutolink:AA,literalAutolinkEmail:jA,literalAutolinkHttp:NA,literalAutolinkWww:TA}}}function kA(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Tf,notInConstruct:jf},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Tf,notInConstruct:jf},{character:":",before:"[ps]",after:"\\/",inConstruct:Tf,notInConstruct:jf}]}}function EA(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Af(e){this.config.enter.autolinkProtocol.call(this,e)}function NA(e){this.config.exit.autolinkProtocol.call(this,e)}function TA(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function jA(e){this.config.exit.autolinkEmail.call(this,e)}function AA(e){this.exit(e)}function RA(e){aS(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,DA],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),MA]],{ignore:["link","linkReference"]})}function DA(e,t,i,s,a){let o="";if(!lS(a)||(/^w/i.test(t)&&(i=t+i,t="",o="http://"),!BA(i)))return!1;const c=LA(i+s);if(!c[0])return!1;const h={type:"link",title:null,url:o+t+c[0],children:[{type:"text",value:t+c[0]}]};return c[1]?[h,{type:"text",value:c[1]}]:h}function MA(e,t,i,s){return!lS(s,!0)||/[-\d_]$/.test(i)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+i,children:[{type:"text",value:t+"@"+i}]}}function BA(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function LA(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let i=t[0],s=i.indexOf(")");const a=Wv(e,"(");let o=Wv(e,")");for(;s!==-1&&a>o;)e+=i.slice(0,s+1),i=i.slice(s+1),s=i.indexOf(")"),o++;return[e,i]}function lS(e,t){const i=e.input.charCodeAt(e.index-1);return(e.index===0||ba(i)||Uu(i))&&(!t||i!==47)}oS.peek=qA;function OA(){this.buffer()}function zA(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function PA(){this.buffer()}function IA(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function HA(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=xr(this.sliceSerialize(e)).toLowerCase(),i.label=t}function UA(e){this.exit(e)}function $A(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=xr(this.sliceSerialize(e)).toLowerCase(),i.label=t}function FA(e){this.exit(e)}function qA(){return"["}function oS(e,t,i,s){const a=i.createTracker(s);let o=a.move("[^");const c=i.enter("footnoteReference"),h=i.enter("reference");return o+=a.move(i.safe(i.associationId(e),{after:"]",before:o})),h(),c(),o+=a.move("]"),o}function WA(){return{enter:{gfmFootnoteCallString:OA,gfmFootnoteCall:zA,gfmFootnoteDefinitionLabelString:PA,gfmFootnoteDefinition:IA},exit:{gfmFootnoteCallString:HA,gfmFootnoteCall:UA,gfmFootnoteDefinitionLabelString:$A,gfmFootnoteDefinition:FA}}}function GA(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:i,footnoteReference:oS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function i(s,a,o,c){const h=o.createTracker(c);let p=h.move("[^");const d=o.enter("footnoteDefinition"),x=o.enter("label");return p+=h.move(o.safe(o.associationId(s),{before:p,after:"]"})),x(),p+=h.move("]:"),s.children&&s.children.length>0&&(h.shift(4),p+=h.move((t?`
115
+ `:" ")+o.indentLines(o.containerFlow(s,h.current()),t?cS:YA))),d(),p}}function YA(e,t,i){return t===0?e:cS(e,t,i)}function cS(e,t,i){return(i?"":" ")+e}const KA=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];uS.peek=JA;function VA(){return{canContainEols:["delete"],enter:{strikethrough:ZA},exit:{strikethrough:QA}}}function XA(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:KA}],handlers:{delete:uS}}}function ZA(e){this.enter({type:"delete",children:[]},e)}function QA(e){this.exit(e)}function uS(e,t,i,s){const a=i.createTracker(s),o=i.enter("strikethrough");let c=a.move("~~");return c+=i.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),o(),c}function JA(){return"~"}function eR(e){return e.length}function tR(e,t){const i=t||{},s=(i.align||[]).concat(),a=i.stringLength||eR,o=[],c=[],h=[],p=[];let d=0,x=-1;for(;++x<e.length;){const N=[],M=[];let E=-1;for(e[x].length>d&&(d=e[x].length);++E<e[x].length;){const H=iR(e[x][E]);if(i.alignDelimiters!==!1){const z=a(H);M[E]=z,(p[E]===void 0||z>p[E])&&(p[E]=z)}N.push(H)}c[x]=N,h[x]=M}let _=-1;if(typeof s=="object"&&"length"in s)for(;++_<d;)o[_]=Gv(s[_]);else{const N=Gv(s);for(;++_<d;)o[_]=N}_=-1;const b=[],v=[];for(;++_<d;){const N=o[_];let M="",E="";N===99?(M=":",E=":"):N===108?M=":":N===114&&(E=":");let H=i.alignDelimiters===!1?1:Math.max(1,p[_]-M.length-E.length);const z=M+"-".repeat(H)+E;i.alignDelimiters!==!1&&(H=M.length+H+E.length,H>p[_]&&(p[_]=H),v[_]=H),b[_]=z}c.splice(1,0,b),h.splice(1,0,v),x=-1;const S=[];for(;++x<c.length;){const N=c[x],M=h[x];_=-1;const E=[];for(;++_<d;){const H=N[_]||"";let z="",R="";if(i.alignDelimiters!==!1){const te=p[_]-(M[_]||0),L=o[_];L===114?z=" ".repeat(te):L===99?te%2?(z=" ".repeat(te/2+.5),R=" ".repeat(te/2-.5)):(z=" ".repeat(te/2),R=z):R=" ".repeat(te)}i.delimiterStart!==!1&&!_&&E.push("|"),i.padding!==!1&&!(i.alignDelimiters===!1&&H==="")&&(i.delimiterStart!==!1||_)&&E.push(" "),i.alignDelimiters!==!1&&E.push(z),E.push(H),i.alignDelimiters!==!1&&E.push(R),i.padding!==!1&&E.push(" "),(i.delimiterEnd!==!1||_!==d-1)&&E.push("|")}S.push(i.delimiterEnd===!1?E.join("").replace(/ +$/,""):E.join(""))}return S.join(`
116
+ `)}function iR(e){return e==null?"":String(e)}function Gv(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function nR(e,t,i,s){const a=i.enter("blockquote"),o=i.createTracker(s);o.move("> "),o.shift(2);const c=i.indentLines(i.containerFlow(e,o.current()),rR);return a(),c}function rR(e,t,i){return">"+(i?"":" ")+e}function sR(e,t){return Yv(e,t.inConstruct,!0)&&!Yv(e,t.notInConstruct,!1)}function Yv(e,t,i){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return i;let s=-1;for(;++s<t.length;)if(e.includes(t[s]))return!0;return!1}function Kv(e,t,i,s){let a=-1;for(;++a<i.unsafe.length;)if(i.unsafe[a].character===`
117
+ `&&sR(i.stack,i.unsafe[a]))return/[ \t]/.test(s.before)?"":" ";return`\\
118
+ `}function aR(e,t){const i=String(e);let s=i.indexOf(t),a=s,o=0,c=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;s!==-1;)s===a?++o>c&&(c=o):o=1,a=s+t.length,s=i.indexOf(t,a);return c}function lR(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function oR(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function cR(e,t,i,s){const a=oR(i),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(lR(e,i)){const _=i.enter("codeIndented"),b=i.indentLines(o,uR);return _(),b}const h=i.createTracker(s),p=a.repeat(Math.max(aR(o,a)+1,3)),d=i.enter("codeFenced");let x=h.move(p);if(e.lang){const _=i.enter(`codeFencedLang${c}`);x+=h.move(i.safe(e.lang,{before:x,after:" ",encode:["`"],...h.current()})),_()}if(e.lang&&e.meta){const _=i.enter(`codeFencedMeta${c}`);x+=h.move(" "),x+=h.move(i.safe(e.meta,{before:x,after:`
119
+ `,encode:["`"],...h.current()})),_()}return x+=h.move(`
120
+ `),o&&(x+=h.move(o+`
121
+ `)),x+=h.move(p),d(),x}function uR(e,t,i){return(i?"":" ")+e}function mm(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function hR(e,t,i,s){const a=mm(i),o=a==='"'?"Quote":"Apostrophe",c=i.enter("definition");let h=i.enter("label");const p=i.createTracker(s);let d=p.move("[");return d+=p.move(i.safe(i.associationId(e),{before:d,after:"]",...p.current()})),d+=p.move("]: "),h(),!e.url||/[\0- \u007F]/.test(e.url)?(h=i.enter("destinationLiteral"),d+=p.move("<"),d+=p.move(i.safe(e.url,{before:d,after:">",...p.current()})),d+=p.move(">")):(h=i.enter("destinationRaw"),d+=p.move(i.safe(e.url,{before:d,after:e.title?" ":`
122
+ `,...p.current()}))),h(),e.title&&(h=i.enter(`title${o}`),d+=p.move(" "+a),d+=p.move(i.safe(e.title,{before:d,after:a,...p.current()})),d+=p.move(a),h()),c(),d}function dR(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Io(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Du(e,t,i){const s=dl(e),a=dl(t);return s===void 0?a===void 0?i==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}hS.peek=fR;function hS(e,t,i,s){const a=dR(i),o=i.enter("emphasis"),c=i.createTracker(s),h=c.move(a);let p=c.move(i.containerPhrasing(e,{after:a,before:h,...c.current()}));const d=p.charCodeAt(0),x=Du(s.before.charCodeAt(s.before.length-1),d,a);x.inside&&(p=Io(d)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Du(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+Io(_));const v=c.move(a);return o(),i.attentionEncodeSurroundingInfo={after:b.outside,before:x.outside},h+p+v}function fR(e,t,i){return i.options.emphasis||"*"}function pR(e,t){let i=!1;return fm(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return i=!0,jp}),!!((!e.depth||e.depth<3)&&am(e)&&(t.options.setext||i))}function mR(e,t,i,s){const a=Math.max(Math.min(6,e.depth||1),1),o=i.createTracker(s);if(pR(e,i)){const x=i.enter("headingSetext"),_=i.enter("phrasing"),b=i.containerPhrasing(e,{...o.current(),before:`
123
+ `,after:`
124
+ `});return _(),x(),b+`
125
+ `+(a===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(`
126
+ `))+1))}const c="#".repeat(a),h=i.enter("headingAtx"),p=i.enter("phrasing");o.move(c+" ");let d=i.containerPhrasing(e,{before:"# ",after:`
127
+ `,...o.current()});return/^[\t ]/.test(d)&&(d=Io(d.charCodeAt(0))+d.slice(1)),d=d?c+" "+d:c,i.options.closeAtx&&(d+=" "+c),p(),h(),d}dS.peek=gR;function dS(e){return e.value||""}function gR(){return"<"}fS.peek=_R;function fS(e,t,i,s){const a=mm(i),o=a==='"'?"Quote":"Apostrophe",c=i.enter("image");let h=i.enter("label");const p=i.createTracker(s);let d=p.move("![");return d+=p.move(i.safe(e.alt,{before:d,after:"]",...p.current()})),d+=p.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=i.enter("destinationLiteral"),d+=p.move("<"),d+=p.move(i.safe(e.url,{before:d,after:">",...p.current()})),d+=p.move(">")):(h=i.enter("destinationRaw"),d+=p.move(i.safe(e.url,{before:d,after:e.title?" ":")",...p.current()}))),h(),e.title&&(h=i.enter(`title${o}`),d+=p.move(" "+a),d+=p.move(i.safe(e.title,{before:d,after:a,...p.current()})),d+=p.move(a),h()),d+=p.move(")"),c(),d}function _R(){return"!"}pS.peek=xR;function pS(e,t,i,s){const a=e.referenceType,o=i.enter("imageReference");let c=i.enter("label");const h=i.createTracker(s);let p=h.move("![");const d=i.safe(e.alt,{before:p,after:"]",...h.current()});p+=h.move(d+"]["),c();const x=i.stack;i.stack=[],c=i.enter("reference");const _=i.safe(i.associationId(e),{before:p,after:"]",...h.current()});return c(),i.stack=x,o(),a==="full"||!d||d!==_?p+=h.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=h.move("]"),p}function xR(){return"!"}mS.peek=bR;function mS(e,t,i){let s=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(s);)a+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++o<i.unsafe.length;){const c=i.unsafe[o],h=i.compilePattern(c);let p;if(c.atBreak)for(;p=h.exec(s);){let d=p.index;s.charCodeAt(d)===10&&s.charCodeAt(d-1)===13&&d--,s=s.slice(0,d)+" "+s.slice(p.index+1)}}return a+s+a}function bR(){return"`"}function gS(e,t){const i=am(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(i===e.url||"mailto:"+i===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}_S.peek=vR;function _S(e,t,i,s){const a=mm(i),o=a==='"'?"Quote":"Apostrophe",c=i.createTracker(s);let h,p;if(gS(e,i)){const x=i.stack;i.stack=[],h=i.enter("autolink");let _=c.move("<");return _+=c.move(i.containerPhrasing(e,{before:_,after:">",...c.current()})),_+=c.move(">"),h(),i.stack=x,_}h=i.enter("link"),p=i.enter("label");let d=c.move("[");return d+=c.move(i.containerPhrasing(e,{before:d,after:"](",...c.current()})),d+=c.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=i.enter("destinationLiteral"),d+=c.move("<"),d+=c.move(i.safe(e.url,{before:d,after:">",...c.current()})),d+=c.move(">")):(p=i.enter("destinationRaw"),d+=c.move(i.safe(e.url,{before:d,after:e.title?" ":")",...c.current()}))),p(),e.title&&(p=i.enter(`title${o}`),d+=c.move(" "+a),d+=c.move(i.safe(e.title,{before:d,after:a,...c.current()})),d+=c.move(a),p()),d+=c.move(")"),h(),d}function vR(e,t,i){return gS(e,i)?"<":"["}xS.peek=yR;function xS(e,t,i,s){const a=e.referenceType,o=i.enter("linkReference");let c=i.enter("label");const h=i.createTracker(s);let p=h.move("[");const d=i.containerPhrasing(e,{before:p,after:"]",...h.current()});p+=h.move(d+"]["),c();const x=i.stack;i.stack=[],c=i.enter("reference");const _=i.safe(i.associationId(e),{before:p,after:"]",...h.current()});return c(),i.stack=x,o(),a==="full"||!d||d!==_?p+=h.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=h.move("]"),p}function yR(){return"["}function gm(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function SR(e){const t=gm(e),i=e.options.bulletOther;if(!i)return t==="*"?"-":"*";if(i!=="*"&&i!=="+"&&i!=="-")throw new Error("Cannot serialize items with `"+i+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(i===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+i+"`) to be different");return i}function wR(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function bS(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function CR(e,t,i,s){const a=i.enter("list"),o=i.bulletCurrent;let c=e.ordered?wR(i):gm(i);const h=e.ordered?c==="."?")":".":SR(i);let p=t&&i.bulletLastUsed?c===i.bulletLastUsed:!1;if(!e.ordered){const x=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&x&&(!x.children||!x.children[0])&&i.stack[i.stack.length-1]==="list"&&i.stack[i.stack.length-2]==="listItem"&&i.stack[i.stack.length-3]==="list"&&i.stack[i.stack.length-4]==="listItem"&&i.indexStack[i.indexStack.length-1]===0&&i.indexStack[i.indexStack.length-2]===0&&i.indexStack[i.indexStack.length-3]===0&&(p=!0),bS(i)===c&&x){let _=-1;for(;++_<e.children.length;){const b=e.children[_];if(b&&b.type==="listItem"&&b.children&&b.children[0]&&b.children[0].type==="thematicBreak"){p=!0;break}}}}p&&(c=h),i.bulletCurrent=c;const d=i.containerFlow(e,s);return i.bulletLastUsed=c,i.bulletCurrent=o,a(),d}function kR(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function ER(e,t,i,s){const a=kR(i);let o=i.bulletCurrent||gm(i);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(i.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let c=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const h=i.createTracker(s);h.move(o+" ".repeat(c-o.length)),h.shift(c);const p=i.enter("listItem"),d=i.indentLines(i.containerFlow(e,h.current()),x);return p(),d;function x(_,b,v){return b?(v?"":" ".repeat(c))+_:(v?o:o+" ".repeat(c-o.length))+_}}function NR(e,t,i,s){const a=i.enter("paragraph"),o=i.enter("phrasing"),c=i.containerPhrasing(e,s);return o(),a(),c}const TR=qu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function jR(e,t,i,s){return(e.children.some(function(c){return TR(c)})?i.containerPhrasing:i.containerFlow).call(i,e,s)}function AR(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}vS.peek=RR;function vS(e,t,i,s){const a=AR(i),o=i.enter("strong"),c=i.createTracker(s),h=c.move(a+a);let p=c.move(i.containerPhrasing(e,{after:a,before:h,...c.current()}));const d=p.charCodeAt(0),x=Du(s.before.charCodeAt(s.before.length-1),d,a);x.inside&&(p=Io(d)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Du(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+Io(_));const v=c.move(a+a);return o(),i.attentionEncodeSurroundingInfo={after:b.outside,before:x.outside},h+p+v}function RR(e,t,i){return i.options.strong||"*"}function DR(e,t,i,s){return i.safe(e.value,s)}function MR(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function BR(e,t,i){const s=(bS(i)+(i.options.ruleSpaces?" ":"")).repeat(MR(i));return i.options.ruleSpaces?s.slice(0,-1):s}const yS={blockquote:nR,break:Kv,code:cR,definition:hR,emphasis:hS,hardBreak:Kv,heading:mR,html:dS,image:fS,imageReference:pS,inlineCode:mS,link:_S,linkReference:xS,list:CR,listItem:ER,paragraph:NR,root:jR,strong:vS,text:DR,thematicBreak:BR};function LR(){return{enter:{table:OR,tableData:Vv,tableHeader:Vv,tableRow:PR},exit:{codeText:IR,table:zR,tableData:Rf,tableHeader:Rf,tableRow:Rf}}}function OR(e){const t=e._align;this.enter({type:"table",align:t.map(function(i){return i==="none"?null:i}),children:[]},e),this.data.inTable=!0}function zR(e){this.exit(e),this.data.inTable=void 0}function PR(e){this.enter({type:"tableRow",children:[]},e)}function Rf(e){this.exit(e)}function Vv(e){this.enter({type:"tableCell",children:[]},e)}function IR(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,HR));const i=this.stack[this.stack.length-1];i.type,i.value=t,this.exit(e)}function HR(e,t){return t==="|"?t:e}function UR(e){const t=e||{},i=t.tableCellPadding,s=t.tablePipeAlign,a=t.stringLength,o=i?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
128
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:c,tableCell:p,tableRow:h}};function c(v,S,N,M){return d(x(v,N,M),v.align)}function h(v,S,N,M){const E=_(v,N,M),H=d([E]);return H.slice(0,H.indexOf(`
129
+ `))}function p(v,S,N,M){const E=N.enter("tableCell"),H=N.enter("phrasing"),z=N.containerPhrasing(v,{...M,before:o,after:o});return H(),E(),z}function d(v,S){return tR(v,{align:S,alignDelimiters:s,padding:i,stringLength:a})}function x(v,S,N){const M=v.children;let E=-1;const H=[],z=S.enter("table");for(;++E<M.length;)H[E]=_(M[E],S,N);return z(),H}function _(v,S,N){const M=v.children;let E=-1;const H=[],z=S.enter("tableRow");for(;++E<M.length;)H[E]=p(M[E],v,S,N);return z(),H}function b(v,S,N){let M=yS.inlineCode(v,S,N);return N.stack.includes("tableCell")&&(M=M.replace(/\|/g,"\\$&")),M}}function $R(){return{exit:{taskListCheckValueChecked:Xv,taskListCheckValueUnchecked:Xv,paragraph:qR}}}function FR(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:WR}}}function Xv(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function qR(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const i=this.stack[this.stack.length-1];i.type;const s=i.children[0];if(s&&s.type==="text"){const a=t.children;let o=-1,c;for(;++o<a.length;){const h=a[o];if(h.type==="paragraph"){c=h;break}}c===i&&(s.value=s.value.slice(1),s.value.length===0?i.children.shift():i.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,i.position.start=Object.assign({},s.position.start)))}}this.exit(e)}function WR(e,t,i,s){const a=e.children[0],o=typeof e.checked=="boolean"&&a&&a.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",h=i.createTracker(s);o&&h.move(c);let p=yS.listItem(e,t,i,{...s,...h.current()});return o&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),p;function d(x){return x+c}}function GR(){return[CA(),WA(),VA(),LR(),$R()]}function YR(e){return{extensions:[kA(),GA(e),XA(),UR(e),FR()]}}const KR={tokenize:e3,partial:!0},SS={tokenize:t3,partial:!0},wS={tokenize:i3,partial:!0},CS={tokenize:n3,partial:!0},VR={tokenize:r3,partial:!0},kS={name:"wwwAutolink",tokenize:QR,previous:NS},ES={name:"protocolAutolink",tokenize:JR,previous:TS},as={name:"emailAutolink",tokenize:ZR,previous:jS},Br={};function XR(){return{text:Br}}let ua=48;for(;ua<123;)Br[ua]=as,ua++,ua===58?ua=65:ua===91&&(ua=97);Br[43]=as;Br[45]=as;Br[46]=as;Br[95]=as;Br[72]=[as,ES];Br[104]=[as,ES];Br[87]=[as,kS];Br[119]=[as,kS];function ZR(e,t,i){const s=this;let a,o;return c;function c(_){return!Mp(_)||!jS.call(s,s.previous)||_m(s.events)?i(_):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),h(_))}function h(_){return Mp(_)?(e.consume(_),h):_===64?(e.consume(_),p):i(_)}function p(_){return _===46?e.check(VR,x,d)(_):_===45||_===95||fn(_)?(o=!0,e.consume(_),p):x(_)}function d(_){return e.consume(_),a=!0,p}function x(_){return o&&a&&yn(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(_)):i(_)}}function QR(e,t,i){const s=this;return a;function a(c){return c!==87&&c!==119||!NS.call(s,s.previous)||_m(s.events)?i(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(KR,e.attempt(SS,e.attempt(wS,o),i),i)(c))}function o(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function JR(e,t,i){const s=this;let a="",o=!1;return c;function c(_){return(_===72||_===104)&&TS.call(s,s.previous)&&!_m(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(_),e.consume(_),h):i(_)}function h(_){if(yn(_)&&a.length<5)return a+=String.fromCodePoint(_),e.consume(_),h;if(_===58){const b=a.toLowerCase();if(b==="http"||b==="https")return e.consume(_),p}return i(_)}function p(_){return _===47?(e.consume(_),o?d:(o=!0,p)):i(_)}function d(_){return _===null||Au(_)||Xt(_)||ba(_)||Uu(_)?i(_):e.attempt(SS,e.attempt(wS,x),i)(_)}function x(_){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(_)}}function e3(e,t,i){let s=0;return a;function a(c){return(c===87||c===119)&&s<3?(s++,e.consume(c),a):c===46&&s===3?(e.consume(c),o):i(c)}function o(c){return c===null?i(c):t(c)}}function t3(e,t,i){let s,a,o;return c;function c(d){return d===46||d===95?e.check(CS,p,h)(d):d===null||Xt(d)||ba(d)||d!==45&&Uu(d)?p(d):(o=!0,e.consume(d),c)}function h(d){return d===95?s=!0:(a=s,s=void 0),e.consume(d),c}function p(d){return a||s||!o?i(d):t(d)}}function i3(e,t){let i=0,s=0;return a;function a(c){return c===40?(i++,e.consume(c),a):c===41&&s<i?o(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(CS,t,o)(c):c===null||Xt(c)||ba(c)?t(c):(e.consume(c),a)}function o(c){return c===41&&s++,e.consume(c),a}}function n3(e,t,i){return s;function s(h){return h===33||h===34||h===39||h===41||h===42||h===44||h===46||h===58||h===59||h===63||h===95||h===126?(e.consume(h),s):h===38?(e.consume(h),o):h===93?(e.consume(h),a):h===60||h===null||Xt(h)||ba(h)?t(h):i(h)}function a(h){return h===null||h===40||h===91||Xt(h)||ba(h)?t(h):s(h)}function o(h){return yn(h)?c(h):i(h)}function c(h){return h===59?(e.consume(h),s):yn(h)?(e.consume(h),c):i(h)}}function r3(e,t,i){return s;function s(o){return e.consume(o),a}function a(o){return fn(o)?i(o):t(o)}}function NS(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Xt(e)}function TS(e){return!yn(e)}function jS(e){return!(e===47||Mp(e))}function Mp(e){return e===43||e===45||e===46||e===95||fn(e)}function _m(e){let t=e.length,i=!1;for(;t--;){const s=e[t][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){i=!0;break}if(s._gfmAutolinkLiteralWalkedInto){i=!1;break}}return e.length>0&&!i&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),i}const s3={tokenize:f3,partial:!0};function a3(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:u3,continuation:{tokenize:h3},exit:d3}},text:{91:{name:"gfmFootnoteCall",tokenize:c3},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:l3,resolveTo:o3}}}}function l3(e,t,i){const s=this;let a=s.events.length;const o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c;for(;a--;){const p=s.events[a][1];if(p.type==="labelImage"){c=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return h;function h(p){if(!c||!c._balanced)return i(p);const d=xr(s.sliceSerialize({start:c.end,end:s.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?i(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function o3(e,t){let i=e.length;for(;i--;)if(e[i][1].type==="labelImage"&&e[i][0]==="enter"){e[i][1];break}e[i+1][1].type="data",e[i+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[i+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[i+3][1].end),end:Object.assign({},e[i+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},h=[e[i+1],e[i+2],["enter",s,t],e[i+3],e[i+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(i,e.length-i+1,...h),e}function c3(e,t,i){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,c;return h;function h(_){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),p}function p(_){return _!==94?i(_):(e.enter("gfmFootnoteCallMarker"),e.consume(_),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(_){if(o>999||_===93&&!c||_===null||_===91||Xt(_))return i(_);if(_===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return a.includes(xr(s.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):i(_)}return Xt(_)||(c=!0),o++,e.consume(_),_===92?x:d}function x(_){return _===91||_===92||_===93?(e.consume(_),o++,d):d(_)}}function u3(e,t,i){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o,c=0,h;return p;function p(S){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(S),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(S){return S===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(S),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",x):i(S)}function x(S){if(c>999||S===93&&!h||S===null||S===91||Xt(S))return i(S);if(S===93){e.exit("chunkString");const N=e.exit("gfmFootnoteDefinitionLabelString");return o=xr(s.sliceSerialize(N)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(S),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return Xt(S)||(h=!0),c++,e.consume(S),S===92?_:x}function _(S){return S===91||S===92||S===93?(e.consume(S),c++,x):x(S)}function b(S){return S===58?(e.enter("definitionMarker"),e.consume(S),e.exit("definitionMarker"),a.includes(o)||a.push(o),Et(e,v,"gfmFootnoteDefinitionWhitespace")):i(S)}function v(S){return t(S)}}function h3(e,t,i){return e.check(Go,t,e.attempt(s3,t,i))}function d3(e){e.exit("gfmFootnoteDefinition")}function f3(e,t,i){const s=this;return Et(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(o):i(o)}}function p3(e){let i=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:o,resolveAll:a};return i==null&&(i=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(c,h){let p=-1;for(;++p<c.length;)if(c[p][0]==="enter"&&c[p][1].type==="strikethroughSequenceTemporary"&&c[p][1]._close){let d=p;for(;d--;)if(c[d][0]==="exit"&&c[d][1].type==="strikethroughSequenceTemporary"&&c[d][1]._open&&c[p][1].end.offset-c[p][1].start.offset===c[d][1].end.offset-c[d][1].start.offset){c[p][1].type="strikethroughSequence",c[d][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},c[d][1].start),end:Object.assign({},c[p][1].end)},_={type:"strikethroughText",start:Object.assign({},c[d][1].end),end:Object.assign({},c[p][1].start)},b=[["enter",x,h],["enter",c[d][1],h],["exit",c[d][1],h],["enter",_,h]],v=h.parser.constructs.insideSpan.null;v&&Yn(b,b.length,0,$u(v,c.slice(d+1,p),h)),Yn(b,b.length,0,[["exit",_,h],["enter",c[p][1],h],["exit",c[p][1],h],["exit",x,h]]),Yn(c,d-1,p-d+3,b),p=d+b.length-2;break}}for(p=-1;++p<c.length;)c[p][1].type==="strikethroughSequenceTemporary"&&(c[p][1].type="data");return c}function o(c,h,p){const d=this.previous,x=this.events;let _=0;return b;function b(S){return d===126&&x[x.length-1][1].type!=="characterEscape"?p(S):(c.enter("strikethroughSequenceTemporary"),v(S))}function v(S){const N=dl(d);if(S===126)return _>1?p(S):(c.consume(S),_++,v);if(_<2&&!i)return p(S);const M=c.exit("strikethroughSequenceTemporary"),E=dl(S);return M._open=!E||E===2&&!!N,M._close=!N||N===2&&!!E,h(S)}}}class m3{constructor(){this.map=[]}add(t,i,s){g3(this,t,i,s)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let i=this.map.length;const s=[];for(;i>0;)i-=1,s.push(t.slice(this.map[i][0]+this.map[i][1]),this.map[i][2]),t.length=this.map[i][0];s.push(t.slice()),t.length=0;let a=s.pop();for(;a;){for(const o of a)t.push(o);a=s.pop()}this.map.length=0}}function g3(e,t,i,s){let a=0;if(!(i===0&&s.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=i,e.map[a][2].push(...s);return}a+=1}e.map.push([t,i,s])}}function _3(e,t){let i=!1;const s=[];for(;t<e.length;){const a=e[t];if(i){if(a[0]==="enter")a[1].type==="tableContent"&&s.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=s.length-1;s[o]=s[o]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(i=!0);t+=1}return s}function x3(){return{flow:{null:{name:"table",tokenize:b3,resolveAll:v3}}}}function b3(e,t,i){const s=this;let a=0,o=0,c;return h;function h(j){let J=s.events.length-1;for(;J>-1;){const Y=s.events[J][1].type;if(Y==="lineEnding"||Y==="linePrefix")J--;else break}const F=J>-1?s.events[J][1].type:null,G=F==="tableHead"||F==="tableRow"?L:p;return G===L&&s.parser.lazy[s.now().line]?i(j):G(j)}function p(j){return e.enter("tableHead"),e.enter("tableRow"),d(j)}function d(j){return j===124||(c=!0,o+=1),x(j)}function x(j){return j===null?i(j):Ye(j)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),v):i(j):gt(j)?Et(e,x,"whitespace")(j):(o+=1,c&&(c=!1,a+=1),j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),c=!0,x):(e.enter("data"),_(j)))}function _(j){return j===null||j===124||Xt(j)?(e.exit("data"),x(j)):(e.consume(j),j===92?b:_)}function b(j){return j===92||j===124?(e.consume(j),_):_(j)}function v(j){return s.interrupt=!1,s.parser.lazy[s.now().line]?i(j):(e.enter("tableDelimiterRow"),c=!1,gt(j)?Et(e,S,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):S(j))}function S(j){return j===45||j===58?M(j):j===124?(c=!0,e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),N):te(j)}function N(j){return gt(j)?Et(e,M,"whitespace")(j):M(j)}function M(j){return j===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),E):j===45?(o+=1,E(j)):j===null||Ye(j)?R(j):te(j)}function E(j){return j===45?(e.enter("tableDelimiterFiller"),H(j)):te(j)}function H(j){return j===45?(e.consume(j),H):j===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),z):(e.exit("tableDelimiterFiller"),z(j))}function z(j){return gt(j)?Et(e,R,"whitespace")(j):R(j)}function R(j){return j===124?S(j):j===null||Ye(j)?!c||a!==o?te(j):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(j)):te(j)}function te(j){return i(j)}function L(j){return e.enter("tableRow"),I(j)}function I(j){return j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),I):j===null||Ye(j)?(e.exit("tableRow"),t(j)):gt(j)?Et(e,I,"whitespace")(j):(e.enter("data"),re(j))}function re(j){return j===null||j===124||Xt(j)?(e.exit("data"),I(j)):(e.consume(j),j===92?_e:re)}function _e(j){return j===92||j===124?(e.consume(j),re):re(j)}}function v3(e,t){let i=-1,s=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],h=!1,p=0,d,x,_;const b=new m3;for(;++i<e.length;){const v=e[i],S=v[1];v[0]==="enter"?S.type==="tableHead"?(h=!1,p!==0&&(Zv(b,t,p,d,x),x=void 0,p=0),d={type:"table",start:Object.assign({},S.start),end:Object.assign({},S.end)},b.add(i,0,[["enter",d,t]])):S.type==="tableRow"||S.type==="tableDelimiterRow"?(s=!0,_=void 0,o=[0,0,0,0],c=[0,i+1,0,0],h&&(h=!1,x={type:"tableBody",start:Object.assign({},S.start),end:Object.assign({},S.end)},b.add(i,0,[["enter",x,t]])),a=S.type==="tableDelimiterRow"?2:x?3:1):a&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")?(s=!1,c[2]===0&&(o[1]!==0&&(c[0]=c[1],_=uu(b,t,o,a,void 0,_),o=[0,0,0,0]),c[2]=i)):S.type==="tableCellDivider"&&(s?s=!1:(o[1]!==0&&(c[0]=c[1],_=uu(b,t,o,a,void 0,_)),o=c,c=[o[1],i,0,0])):S.type==="tableHead"?(h=!0,p=i):S.type==="tableRow"||S.type==="tableDelimiterRow"?(p=i,o[1]!==0?(c[0]=c[1],_=uu(b,t,o,a,i,_)):c[1]!==0&&(_=uu(b,t,c,a,i,_)),a=0):a&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")&&(c[3]=i)}for(p!==0&&Zv(b,t,p,d,x),b.consume(t.events),i=-1;++i<t.events.length;){const v=t.events[i];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=_3(t.events,i))}return e}function uu(e,t,i,s,a,o){const c=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",h="tableContent";i[0]!==0&&(o.end=Object.assign({},al(t.events,i[0])),e.add(i[0],0,[["exit",o,t]]));const p=al(t.events,i[1]);if(o={type:c,start:Object.assign({},p),end:Object.assign({},p)},e.add(i[1],0,[["enter",o,t]]),i[2]!==0){const d=al(t.events,i[2]),x=al(t.events,i[3]),_={type:h,start:Object.assign({},d),end:Object.assign({},x)};if(e.add(i[2],0,[["enter",_,t]]),s!==2){const b=t.events[i[2]],v=t.events[i[3]];if(b[1].end=Object.assign({},v[1].end),b[1].type="chunkText",b[1].contentType="text",i[3]>i[2]+1){const S=i[2]+1,N=i[3]-i[2]-1;e.add(S,N,[])}}e.add(i[3]+1,0,[["exit",_,t]])}return a!==void 0&&(o.end=Object.assign({},al(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function Zv(e,t,i,s,a){const o=[],c=al(t.events,i);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),s.end=Object.assign({},c),o.push(["exit",s,t]),e.add(i+1,0,o)}function al(e,t){const i=e[t],s=i[0]==="enter"?"start":"end";return i[1][s]}const y3={name:"tasklistCheck",tokenize:w3};function S3(){return{text:{91:y3}}}function w3(e,t,i){const s=this;return a;function a(p){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?i(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),o)}function o(p){return Xt(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),c):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),c):i(p)}function c(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),h):i(p)}function h(p){return Ye(p)?t(p):gt(p)?e.check({tokenize:C3},t,i)(p):i(p)}}function C3(e,t,i){return Et(e,s,"whitespace");function s(a){return a===null?i(a):t(a)}}function k3(e){return I0([XR(),a3(),p3(e),x3(),S3()])}const E3={};function N3(e){const t=this,i=e||E3,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(k3(i)),o.push(GR()),c.push(YR(i))}const ha=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],Mu={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...ha,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...ha],h2:[["className","sr-only"]],img:[...ha,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...ha,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...ha],table:[...ha],ul:[...ha,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},Os={}.hasOwnProperty;function T3(e,t){let i={type:"root",children:[]};const s={schema:t?{...Mu,...t}:Mu,stack:[]},a=AS(s,e);return a&&(Array.isArray(a)?a.length===1?i=a[0]:i.children=a:i=a),i}function AS(e,t){if(t&&typeof t=="object"){const i=t;switch(typeof i.type=="string"?i.type:""){case"comment":return j3(e,i);case"doctype":return A3(e,i);case"element":return R3(e,i);case"root":return D3(e,i);case"text":return M3(e,i)}}}function j3(e,t){if(e.schema.allowComments){const i=typeof t.value=="string"?t.value:"",s=i.indexOf("-->"),o={type:"comment",value:s<0?i:i.slice(0,s)};return Ko(o,t),o}}function A3(e,t){if(e.schema.allowDoctypes){const i={type:"doctype"};return Ko(i,t),i}}function R3(e,t){const i=typeof t.tagName=="string"?t.tagName:"";e.stack.push(i);const s=RS(e,t.children),a=B3(e,t.properties);e.stack.pop();let o=!1;if(i&&i!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(i))&&(o=!0,e.schema.ancestors&&Os.call(e.schema.ancestors,i))){const h=e.schema.ancestors[i];let p=-1;for(o=!1;++p<h.length;)e.stack.includes(h[p])&&(o=!0)}if(!o)return e.schema.strip&&!e.schema.strip.includes(i)?s:void 0;const c={type:"element",tagName:i,properties:a,children:s};return Ko(c,t),c}function D3(e,t){const s={type:"root",children:RS(e,t.children)};return Ko(s,t),s}function M3(e,t){const s={type:"text",value:typeof t.value=="string"?t.value:""};return Ko(s,t),s}function RS(e,t){const i=[];if(Array.isArray(t)){const s=t;let a=-1;for(;++a<s.length;){const o=AS(e,s[a]);o&&(Array.isArray(o)?i.push(...o):i.push(o))}}return i}function B3(e,t){const i=e.stack[e.stack.length-1],s=e.schema.attributes,a=e.schema.required,o=s&&Os.call(s,i)?s[i]:void 0,c=s&&Os.call(s,"*")?s["*"]:void 0,h=t&&typeof t=="object"?t:{},p={};let d;for(d in h)if(Os.call(h,d)){const x=h[d];let _=Qv(e,Jv(o,d),d,x);_==null&&(_=Qv(e,Jv(c,d),d,x)),_!=null&&(p[d]=_)}if(a&&Os.call(a,i)){const x=a[i];for(d in x)Os.call(x,d)&&!Os.call(p,d)&&(p[d]=x[d])}return p}function Qv(e,t,i,s){return t?Array.isArray(s)?L3(e,t,i,s):DS(e,t,i,s):void 0}function L3(e,t,i,s){let a=-1;const o=[];for(;++a<s.length;){const c=DS(e,t,i,s[a]);(typeof c=="number"||typeof c=="string")&&o.push(c)}return o}function DS(e,t,i,s){if(!(typeof s!="boolean"&&typeof s!="number"&&typeof s!="string")&&O3(e,i,s)){if(typeof t=="object"&&t.length>1){let a=!1,o=0;for(;++o<t.length;){const c=t[o];if(c&&typeof c=="object"&&"flags"in c){if(c.test(String(s))){a=!0;break}}else if(c===s){a=!0;break}}if(!a)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(i)?e.schema.clobberPrefix+s:s}}function O3(e,t,i){const s=e.schema.protocols&&Os.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!s||s.length===0)return!0;const a=String(i),o=a.indexOf(":"),c=a.indexOf("?"),h=a.indexOf("#"),p=a.indexOf("/");if(o<0||p>-1&&o>p||c>-1&&o>c||h>-1&&o>h)return!0;let d=-1;for(;++d<s.length;){const x=s[d];if(o===x.length&&a.slice(0,x.length)===x)return!0}return!1}function Ko(e,t){const i=M0(t);t.data&&(e.data=Po(t.data)),i&&(e.position=i)}function Jv(e,t){let i,s=-1;if(e)for(;++s<e.length;){const a=e[s],o=typeof a=="string"?a:a[0];if(o===t)return a;o==="data*"&&(i=a)}if(t.length>4&&t.slice(0,4).toLowerCase()==="data")return i}function z3(e){return function(t){return T3(t,e)}}const cl=["Romance","Fantasy","Science Fiction","Mystery","Thriller","Horror","Adventure","Historical Fiction","Contemporary Lit","Humor","Poetry","Non-Fiction","Fanfiction","Short Story","Paranormal","Werewolf","LGBTQ+","New Adult","Teen Fiction","Diverse Lit","Others"],is=["English","Chinese","Korean","Japanese","Spanish","French","Hindi","Arabic","Portuguese","Russian","Others"];function MS(e){return e.toLowerCase().replace(/[^a-z0-9+]/g,"")}const P3=Object.fromEntries(cl.map(e=>[MS(e),e])),I3={scifi:"Science Fiction",sf:"Science Fiction",comedy:"Humor",humour:"Humor",ya:"Teen Fiction",youngadult:"Teen Fiction",lgbt:"LGBTQ+",lgbtq:"LGBTQ+","lgbtqia+":"LGBTQ+",historical:"Historical Fiction",scary:"Horror"};function Su(e){if(!e)return null;const t=MS(e.trim());return t?P3[t]??I3[t]??null:null}const H3="modulepreload",U3=function(e){return"/"+e},ey={},ty=function(t,i,s){let a=Promise.resolve();if(i&&i.length>0){let c=function(d){return Promise.all(d.map(x=>Promise.resolve(x).then(_=>({status:"fulfilled",value:_}),_=>({status:"rejected",reason:_}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),p=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));a=c(i.map(d=>{if(d=U3(d),d in ey)return;ey[d]=!0;const x=d.endsWith(".css"),_=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${_}`))return;const b=document.createElement("link");if(b.rel=x?"stylesheet":H3,x||(b.as="script"),b.crossOrigin="",b.href=d,p&&b.setAttribute("nonce",p),document.head.appendChild(b),x)return new Promise((v,S)=>{b.addEventListener("load",v),b.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${d}`)))})}))}function o(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&o(h.reason);return t().catch(o)})},xm=[{family:"Noto Sans",googleFontsId:"Noto+Sans",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/noto/specimen/Noto+Sans/about",category:"body",weights:[400,500,700],languages:["English","Spanish","French","Portuguese","Russian","Others"]},{family:"Noto Sans KR",googleFontsId:"Noto+Sans+KR",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/noto/specimen/Noto+Sans+KR/about",category:"body",weights:[400,500,700],languages:["Korean"]},{family:"Noto Sans JP",googleFontsId:"Noto+Sans+JP",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/noto/specimen/Noto+Sans+JP/about",category:"body",weights:[400,500,700],languages:["Japanese"]},{family:"Noto Sans SC",googleFontsId:"Noto+Sans+SC",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/noto/specimen/Noto+Sans+SC/about",category:"body",weights:[400,500,700],languages:["Chinese"]},{family:"Noto Sans Devanagari",googleFontsId:"Noto+Sans+Devanagari",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/noto/specimen/Noto+Sans+Devanagari/about",category:"body",weights:[400,500,700],languages:["Hindi"]},{family:"Noto Naskh Arabic",googleFontsId:"Noto+Naskh+Arabic",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/noto/specimen/Noto+Naskh+Arabic/about",category:"body",weights:[400,500,700],languages:["Arabic"]},{family:"Bangers",googleFontsId:"Bangers",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/specimen/Bangers/about",category:"display",weights:[400],languages:[]}],$3="system-ui, sans-serif",F3=xm.find(e=>e.family==="Noto Sans"),q3=xm.find(e=>e.category==="display");function BS(e){return xm.find(i=>i.category==="body"&&i.languages.includes(e))||F3}function LS(){return q3}function OS(e){const t=e.weights.join(";");return`https://fonts.googleapis.com/css2?family=${e.googleFontsId}:wght@${t}&display=swap`}function Bu(e){return`"${e.family}", ${$3}`}function iy(e,t,i,s){const a=t.split(/\s+/).filter(Boolean);if(a.length===0)return[""];const o=[];let c="";for(const h of a){const p=c?`${c} ${h}`:h;!c||e(p,s)<=i?c=p:(o.push(c),c=h)}return c&&o.push(c),o}function Eo(e,t,i,s,a){const o=a.lineHeightFactor??1.2,c=a.speakerScale??.8,h=a.paddingX??Math.max(2,i*.06),p=a.paddingY??Math.max(2,s*.08),d=Math.max(1,i-2*h),x=Math.max(1,s-2*p),_=Math.max(a.minFontSize,a.maxFontSize),b=Math.max(1,Math.min(a.minFontSize,_)),v=N=>{const M=a.hasSpeaker?N*c:0,E=a.hasSpeaker?M*o:0,H=Math.max(1,x-E),z=a.fontWeight??400,R=iy((I,re)=>e(I,re,z),t,d,N),te=R.length*N*o,L=R.every(I=>e(I,N,z)<=d+.5);return{lines:R,ok:te<=H&&L}};if(typeof a.fontSize=="number"&&Number.isFinite(a.fontSize)&&a.fontSize>0){const N=Math.max(1,a.fontSize),{lines:M,ok:E}=v(N);return{lines:M,fontSize:N,lineHeight:N*o,speakerFontSize:a.hasSpeaker?N*c:0,overflow:!E}}for(let N=_;N>=b;N-=.5){const{lines:M,ok:E}=v(N);if(E)return{lines:M,fontSize:N,lineHeight:N*o,speakerFontSize:a.hasSpeaker?N*c:0,overflow:!1}}return{lines:iy(e,t,d,b),fontSize:b,lineHeight:b*o,speakerFontSize:a.hasSpeaker?b*c:0,overflow:!0}}function W3(e){return{minFontSize:Math.max(1,e*.022),maxFontSize:Math.max(1,e*.05)}}const zS=["speech","narration","sfx"],G3=2;function Rr(e,t,i){return Math.min(i,Math.max(t,e))}function ul(e,t,i){return typeof e=="number"&&Number.isFinite(e)?Rr(e,t,i):void 0}function bm(e){if(!e||typeof e!="object")return;const t=e,i=t.mode==="manual"?"manual":t.mode==="auto"?"auto":void 0,s=ul(t.fontScale,.015,.12),a=t.fontWeight===700?700:t.fontWeight===400?400:void 0,o=ul(t.lineHeightFactor,.9,2),c=ul(t.speakerScale,.5,1.5);if(!(!i&&s===void 0&&a===void 0&&o===void 0&&c===void 0))return{...i?{mode:i}:{},...s!==void 0?{fontScale:s}:{},...a!==void 0?{fontWeight:a}:{},...o!==void 0?{lineHeightFactor:o}:{},...c!==void 0?{speakerScale:c}:{}}}function Gu(e){if(!e||typeof e!="object")return;const t=e,i=ul(t.paddingX,0,.25),s=ul(t.paddingY,0,.25),a=ul(t.cornerRadius,0,.49);if(!(i===void 0&&s===void 0&&a===void 0))return{...i!==void 0?{paddingX:i}:{},...s!==void 0?{paddingY:s}:{},...a!==void 0?{cornerRadius:a}:{}}}function No(e,t,i,s){const{minFontSize:a,maxFontSize:o}=W3(t),c=bm(e.textStyle),h=Gu(e.bubbleStyle);return{minFontSize:a,maxFontSize:o,hasSpeaker:e.type!=="sfx"&&!!e.speaker,...(c==null?void 0:c.lineHeightFactor)!==void 0?{lineHeightFactor:c.lineHeightFactor}:{},...(c==null?void 0:c.speakerScale)!==void 0?{speakerScale:c.speakerScale}:{},...(c==null?void 0:c.fontWeight)!==void 0?{fontWeight:c.fontWeight}:{},...(c==null?void 0:c.mode)==="manual"&&c.fontScale!==void 0?{fontSize:Math.max(1,t*c.fontScale)}:{},...(h==null?void 0:h.paddingX)!==void 0?{paddingX:i*h.paddingX}:{},...(h==null?void 0:h.paddingY)!==void 0?{paddingY:s*h.paddingY}:{}}}function PS(e,t,i){const s=Gu(e.bubbleStyle);return(s==null?void 0:s.cornerRadius)!==void 0?Math.min(t,i)*s.cornerRadius:void 0}function IS(e,t){const i=Math.min(e,t);return Math.max(0,Math.min(i*.4,i/2))}function ny(e,t,i,s,a){const o=Math.max(0,i-2*s),c=Math.max(1,Math.min(a,o)/2),h=t+s+c,p=t+i-s-c;return{center:p>=h?Rr(e,h,p):t+i/2,half:c}}function vm(e,t,i,s,a,o){const c=e+i/2,h=t+s/2,p=e+a.x*i,d=t+a.y*s;if(p>=e&&p<=e+i&&d>=t&&d<=t+s)return null;const x=p-c,_=d-h,b=Math.max(6,Math.min(i,s)*.3),v=o??IS(i,s);if(Math.abs(_)>=Math.abs(x)){const E=_>=0?t+s:t,{center:H,half:z}=ny(p,e,i,v,b);return{tip:{x:p,y:d},base1:{x:H-z,y:E},base2:{x:H+z,y:E}}}const S=x>=0?e+i:e,{center:N,half:M}=ny(d,t,s,v,b);return{tip:{x:p,y:d},base1:{x:S,y:N-M},base2:{x:S,y:N+M}}}function Y3(e){return e.type!=="speech"||!e.tailAnchor?!1:vm(0,0,1,1,e.tailAnchor)!==null}function K3(e,t,i,s,a,o){const c=o??IS(i,s),h=e+i,p=t+s,d=!!a&&a.base1.y===t&&a.base2.y===t,x=!!a&&a.base1.x===h&&a.base2.x===h,_=!!a&&a.base1.y===p&&a.base2.y===p,b=!!a&&a.base1.x===e&&a.base2.x===e,v=[{k:"M",x:e+c,y:t}];return d&&a&&v.push({k:"L",x:a.base1.x,y:t},{k:"L",x:a.tip.x,y:a.tip.y},{k:"L",x:a.base2.x,y:t}),v.push({k:"L",x:h-c,y:t},{k:"A",cornerX:h,cornerY:t,x:h,y:t+c,r:c}),x&&a&&v.push({k:"L",x:h,y:a.base1.y},{k:"L",x:a.tip.x,y:a.tip.y},{k:"L",x:h,y:a.base2.y}),v.push({k:"L",x:h,y:p-c},{k:"A",cornerX:h,cornerY:p,x:h-c,y:p,r:c}),_&&a&&v.push({k:"L",x:a.base2.x,y:p},{k:"L",x:a.tip.x,y:a.tip.y},{k:"L",x:a.base1.x,y:p}),v.push({k:"L",x:e+c,y:p},{k:"A",cornerX:e,cornerY:p,x:e,y:p-c,r:c}),b&&a&&v.push({k:"L",x:e,y:a.base2.y},{k:"L",x:a.tip.x,y:a.tip.y},{k:"L",x:e,y:a.base1.y}),v.push({k:"L",x:e,y:t+c},{k:"A",cornerX:e,cornerY:t,x:e+c,y:t,r:c}),v}function HS(e,t,i,s,a,o){const c=K3(e,t,i,s,a,o).map(h=>h.k==="A"?`A ${h.r} ${h.r} 0 0 1 ${h.x} ${h.y}`:`${h.k} ${h.x} ${h.y}`);return c.push("Z"),c.join(" ")}function V3(e){return e.x<-1e-6||e.y<-1e-6||e.x+e.width>1+1e-6||e.y+e.height>1+1e-6}let ry=0;function Bp(e,t=.1,i=.1){return ry++,{id:`overlay-${Date.now()}-${ry}`,type:e,x:t,y:i,width:e==="sfx"?.15:.25,height:e==="sfx"?.08:.12,text:"",...e==="speech"?{speaker:"",tailAnchor:{x:.5,y:1.2}}:{}}}function US(e,t,i){return{width:Math.min(e==="sfx"?.3:.5,Math.max(.15,1-t)),height:Math.min(e==="sfx"?.1:.2,Math.max(.06,1-i))}}const hu=.05;function Zi(e){return typeof e=="number"&&Number.isFinite(e)}function X3(e,t,i){const s=e.toLowerCase(),a=/\bleft\b/.test(s),o=/\bright\b/.test(s),c=/\b(?:top|upper)\b/.test(s),h=/\b(?:bottom|lower)\b/.test(s),p=/\b(?:center|centre|middle)\b/.test(s);if(!a&&!o&&!c&&!h&&!p)return null;const d=a?hu:Rr(o?1-t-hu:(1-t)/2,0,1),x=c?hu:Rr(h?1-i-hu:(1-i)/2,0,1);return{x:d,y:x}}let Z3=0;function Q3(e){if(!e||typeof e!="object")return null;const t=e,i=zS.includes(t.type)?t.type:"speech",s=typeof t.text=="string"?t.text:"";let a=Zi(t.width)&&t.width>0?t.width:i==="sfx"?.15:.4,o=Zi(t.height)&&t.height>0?t.height:i==="sfx"?.08:.16,c,h;if(Zi(t.x)&&Zi(t.y))c=t.x,h=t.y;else{const b=typeof t.position=="string"?X3(t.position,a,o):null;if(!b)return null;c=b.x,h=b.y}c=Rr(c,0,1),h=Rr(h,0,1),a=Rr(a,.02,1),o=Rr(o,.02,1);const d={id:typeof t.id=="string"&&t.id?t.id:`overlay-norm-${++Z3}`,type:i,x:c,y:h,width:a,height:o,text:s};if(i==="speech"){d.speaker=typeof t.speaker=="string"?t.speaker:"";const b=t.tailAnchor;d.tailAnchor=b&&Zi(b.x)&&Zi(b.y)?{x:b.x,y:b.y}:{x:.5,y:1.2}}else typeof t.speaker=="string"&&t.speaker&&(d.speaker=t.speaker);const x=bm(t.textStyle),_=Gu(t.bubbleStyle);return x&&(d.textStyle=x),_&&(d.bubbleStyle=_),d}function J3(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&!!t.id&&zS.includes(t.type)&&Zi(t.x)&&Zi(t.y)&&Zi(t.width)&&Zi(t.height)&&typeof t.text=="string"}function eD(e){const t=Array.isArray(e)?e:[],i=[],s=[];let a=!Array.isArray(e);return t.forEach((o,c)=>{const h=Q3(o);if(!h){s.push({index:c,reason:"overlay has no numeric x/y/width/height and no recognizable position"}),a=!0;return}i.push(h),J3(o)||(a=!0)}),{overlays:i,changed:a,invalid:s}}function e4(e){for(let t=0;t<e.length;t++){const i=e[t];if(!(Zi(i==null?void 0:i.x)&&Zi(i==null?void 0:i.y)&&Zi(i==null?void 0:i.width)&&Zi(i==null?void 0:i.height)&&i.width>0&&i.height>0))return{valid:!1,error:`Overlay ${t+1}${i!=null&&i.type?` (${i.type})`:""} has invalid geometry — repair or re-place it in the lettering editor before export`};const a=bm(i==null?void 0:i.textStyle);if(i!=null&&i.textStyle&&!a)return{valid:!1,error:`Overlay ${t+1}${i!=null&&i.type?` (${i.type})`:""} has invalid typography controls — reset them in the lettering editor before export`};const o=Gu(i==null?void 0:i.bubbleStyle);if(i!=null&&i.bubbleStyle&&!o)return{valid:!1,error:`Overlay ${t+1}${i!=null&&i.type?` (${i.type})`:""} has invalid bubble controls — reset them in the lettering editor before export`}}return{valid:!0}}const sy=new Set(["speech","narration"]),tD=.12;function ay(e){return Zi(e==null?void 0:e.x)&&Zi(e==null?void 0:e.y)&&Zi(e==null?void 0:e.width)&&Zi(e==null?void 0:e.height)&&e.width>0&&e.height>0}function iD(e,t=tD){const i=[];for(let s=0;s<e.length;s++){const a=e[s];if(!(!sy.has(a==null?void 0:a.type)||!ay(a)))for(let o=s+1;o<e.length;o++){const c=e[o];if(!sy.has(c==null?void 0:c.type)||!ay(c))continue;const h=Math.min(a.x+a.width,c.x+c.width)-Math.max(a.x,c.x),p=Math.min(a.y+a.height,c.y+c.height)-Math.max(a.y,c.y);if(h<=0||p<=0)continue;const d=h*p,x=Math.min(a.width*a.height,c.width*c.height),_=x>0?d/x:0;_>=t&&i.push({indexA:s,indexB:o,idA:a.id,idB:c.id,ratio:_})}}return i}function nD(e,t={}){var a,o,c,h;const i=!t.staleExport&&(!!e.finalImagePath||!!e.exportedAt),s=!t.staleExport&&(!!e.uploadedUrl||!!e.uploadedCid);return{hasCleanImage:!!e.cleanImagePath,hasScriptText:(((a=e.dialogue)==null?void 0:a.length)??0)>0||!!((o=e.narration)!=null&&o.trim())||!!((c=e.sfx)!=null&&c.trim()),bubblesPlaced:((h=e.overlays)==null?void 0:h.length)??0,exported:i,uploaded:s}}function pa(e){return JSON.stringify((e??[]).map(t=>[t.type,t.x,t.y,t.width,t.height,t.text,t.speaker??"",t.tailAnchor??null,t.textStyle??null,t.bubbleStyle??null]))}function rD(e){return!e.exported&&!e.uploaded?!1:e.baselineSig!==pa(e.current)}function ym(e){var i,s;const t=[];return(e.dialogue??[]).forEach((a,o)=>{var c;(c=a==null?void 0:a.text)!=null&&c.trim()&&t.push({type:"speech",speaker:a.speaker,text:a.text.trim(),key:`speech-${o}`})}),(i=e.narration)!=null&&i.trim()&&t.push({type:"narration",text:e.narration.trim(),key:"narration"}),(s=e.sfx)!=null&&s.trim()&&t.push({type:"sfx",text:e.sfx.trim(),key:"sfx"}),t}function sD(e,t,i){if(e==="narration")return{x:.08,y:.05+Math.min(t,2)*.18};if(e==="sfx"){const c=t%2,h=Math.floor(t/2);return{x:c===0?.1:.62,y:.68+h*.12}}const s=Math.floor(t/2),a=t%2===0,o=.08+s*Math.max(.15,Math.min(.22,i>4?.16:.2));return{x:a?.05:.45,y:o}}function ly(e){const t=ym(e);return t.map((i,s)=>{const{x:a,y:o}=sD(i.type,s,t.length),c=Bp(i.type,a,o),h=US(i.type,a,o);return{...c,...h,text:i.text,...i.type==="speech"?{speaker:i.speaker??""}:{}}})}function vn(e){return e.kind==="text"}function $S(e,t=G3){return!e.finalImagePath||!(e.overlays??[]).some(Y3)?!1:(e.finalRendererVersion??0)<t}const oy=800;function FS(e){if(!e)return null;const t=e.match(/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/);if(!t)return null;const i=parseFloat(t[1]),s=parseFloat(t[2]);return!(i>0)||!(s>0)?null:{width:oy,height:Math.round(oy*s/i)}}function qS(e,t){const i=t.startsWith("assets/")?t.slice(7):t;return`/api/stories/${e}/asset/${i}`}function WS(e,t,i){const[s,a]=w.useState({url:null,loading:!!t,error:!1});return w.useEffect(()=>{if(!t){a({url:null,loading:!1,error:!1});return}let o=null,c=!1;return a({url:null,loading:!0,error:!1}),(async()=>{try{const h=await i(qS(e,t));if(!h.ok)throw new Error(`asset request failed (${h.status})`);const p=await h.blob();if(c)return;o=URL.createObjectURL(p),a({url:o,loading:!1,error:!1})}catch{c||a({url:null,loading:!1,error:!0})}})(),()=>{c=!0,o&&URL.revokeObjectURL(o)}},[e,t,i]),s}function Bn(e,t){return e*t}function cy(e,t){return t===0?0:e/t}function uy(e){const t=`gfont-${e.googleFontsId}`;if(document.getElementById(t))return;const i=document.createElement("link");i.id=t,i.rel="stylesheet",i.href=OS(e),document.head.appendChild(i)}const To={speech:"Speech",narration:"Narration",sfx:"SFX"},aD={speech:"border-foreground/40",narration:"border-muted/40",sfx:"border-accent/40"};function Df(e){const t=(e.speaker||e.text||"").trim().replace(/\s+/g," ");return t?`“${t.length>18?`${t.slice(0,18)}…`:t}”`:To[e.type]}const hy=.05,lD=[{key:"down",label:"Down",anchor:{x:.5,y:1.2}},{key:"up",label:"Up",anchor:{x:.5,y:-.2}},{key:"left",label:"Left",anchor:{x:-.2,y:.5}},{key:"right",label:"Right",anchor:{x:1.2,y:.5}}];function du(e,t,i){return Math.min(i,Math.max(t,e))}function oD({storyName:e,cut:t,plotFile:i,onSave:s,onClose:a,onExported:o,language:c="English",authFetch:h,targetLabel:p,returnOnSave:d=!1,workspaceVisible:x=!1,onToggleWorkspaceVisible:_,onPreviousCut:b,onNextCut:v,hasPreviousCut:S=!1,hasNextCut:N=!1}){var ei,Kn,mn,_i,xi,Ht,ln,Ui;const M=BS(c),E=LS(),H=Bu(M),z=Bu(E);w.useEffect(()=>{uy(M),uy(E)},[M,E]),w.useEffect(()=>{let O=!1;return q(!1),(async()=>{try{const{ensureFontsReady:we}=await ty(async()=>{const{ensureFontsReady:Me}=await import("./export-cut-DVpOZ5AO.js");return{ensureFontsReady:Me}},[]);await we([M.family,E.family])}catch{}O||q(!0)})(),()=>{O=!0}},[M.family,E.family]);const R=WS(e,t.cleanImagePath,h),te=w.useMemo(()=>eD(t.overlays),[t.overlays]),L=te.invalid.length,[I,re]=w.useState(!1),_e=L===0&&te.changed&&te.overlays.length>0,[j,J]=w.useState(()=>te.overlays),[F,G]=w.useState(()=>pa(te.overlays)),Y=w.useRef(null),U=w.useCallback(O=>(we,Me,Te=400)=>{var Qe;!Y.current&&typeof document<"u"&&(Y.current=document.createElement("canvas"));const Ze=(Qe=Y.current)==null?void 0:Qe.getContext("2d");return Ze?(Ze.font=`${Te} ${Me}px ${O}`,Ze.measureText(we).width):we.length*Me*.5},[]),[A,q]=w.useState(!1),[$,be]=w.useState(null),[T,D]=w.useState(!1),[V,k]=w.useState(!1),[le,ne]=w.useState(null),[de,X]=w.useState(null),[ue,ye]=w.useState(!1),[fe,Pe]=w.useState({x:0,y:0,width:0,height:0}),$e=w.useRef(null),Oe=w.useRef(null),Ke=w.useRef(null);w.useEffect(()=>{const O=te.overlays;J(O),be(null),re(!1),D(!1),ne(null),X(null),G(pa(O))},[t.id,te]);const ft=w.useCallback(()=>{const O=$e.current;if(!O)return;const we=O.clientWidth,Me=O.clientHeight;let Te,Ze;if(t.kind==="text"){const Rt=FS(t.aspectRatio)??{width:800,height:600};Te=Rt.width,Ze=Rt.height}else{const Rt=Oe.current;if(!Rt||!Rt.naturalWidth)return;Te=Rt.naturalWidth,Ze=Rt.naturalHeight}if(!we||!Me)return;const Qe=Math.min(we/Te,Me/Ze),Nt=Te*Qe,kt=Ze*Qe;Pe({x:(we-Nt)/2,y:(Me-kt)/2,width:Nt,height:kt})},[t.kind,t.aspectRatio]);w.useEffect(()=>{const O=$e.current;if(!O)return;const we=new ResizeObserver(()=>ft());return we.observe(O),()=>we.disconnect()},[ft]);const tt=w.useCallback(O=>{const we=US(O.type,O.x,O.y),Me=we.width,Te=Math.max(.08,1-O.y);if(!O.text||!A||fe.width<=0)return we;const Ze=O.type==="sfx"?z:H,Qe=Bn(Me,fe.width);let Nt=O.type==="sfx"?.08:.12;for(let kt=0;kt<24;kt++){const Rt=Math.min(Nt,Te),Je=Bn(Rt,fe.height);if(!Eo(U(Ze),O.text,Qe,Je,No({...O},fe.height||300,Qe,Je)).overflow||Rt>=Te)return{width:Me,height:Rt};Nt+=.03}return{width:Me,height:Math.min(Nt,Te)}},[A,fe,U,H,z]),Fe=w.useCallback(O=>{const we=Bp(O,.1+Math.random()*.3,.1+Math.random()*.3),Me={...we,...tt(we)};J(Te=>[...Te,Me]),be(Me.id)},[tt]),ze=w.useCallback(O=>{const Me={...Bp(O.type,.1+Math.random()*.3,.1+Math.random()*.3),text:O.text,...O.type==="speech"&&O.speaker?{speaker:O.speaker}:{}},Te={...Me,...tt(Me)};J(Ze=>[...Ze,Te]),be(Te.id)},[tt]),qe=w.useCallback((O,we)=>{J(Me=>Me.map(Te=>Te.id===O?{...Te,...we}:Te))},[]),Gt=w.useCallback(O=>{var Nt;const we=fe.height||300,Me=fe.width>0?Bn(O.width,fe.width):200,Te=fe.height>0?Bn(O.height,fe.height):100,Ze=O.type==="sfx"?z:H,Qe=Eo(U(Ze),O.text,Me,Te,No({...O,textStyle:void 0},we,Me,Te));qe(O.id,{textStyle:{mode:"manual",fontScale:Qe.fontSize/Math.max(1,we),fontWeight:((Nt=O.textStyle)==null?void 0:Nt.fontWeight)??400,lineHeightFactor:Qe.fontSize>0?Qe.lineHeight/Qe.fontSize:1.2,speakerScale:Qe.fontSize>0&&Qe.speakerFontSize>0?Qe.speakerFontSize/Qe.fontSize:.8}})},[fe,z,H,U,qe]),wt=w.useCallback(O=>{J(we=>we.filter(Me=>Me.id!==O)),be(null),D(!1)},[]),ki=w.useCallback(()=>{be(null),D(!1)},[]),Ei=w.useCallback((O,we)=>{O.stopPropagation(),be(we),D(!1)},[]),yt=w.useCallback((O,we,Me)=>{O.stopPropagation(),O.preventDefault();const Te=j.find(Ze=>Ze.id===we);Te&&(be(we),Ke.current={id:we,mode:Me,startX:O.clientX,startY:O.clientY,origX:Te.x,origY:Te.y,origW:Te.width,origH:Te.height})},[j]);w.useEffect(()=>{const O=Me=>{const Te=Ke.current;if(!Te||fe.width===0)return;const Ze=cy(Me.clientX-Te.startX,fe.width),Qe=cy(Me.clientY-Te.startY,fe.height);if(Te.mode==="move"){const Nt=du(Te.origX+Ze,0,1-Te.origW),kt=du(Te.origY+Qe,0,1-Te.origH);qe(Te.id,{x:Nt,y:kt})}else{const Nt=du(Te.origW+Ze,hy,1-Te.origX),kt=du(Te.origH+Qe,hy,1-Te.origY);qe(Te.id,{width:Nt,height:kt})}},we=()=>{Ke.current=null};return window.addEventListener("mousemove",O),window.addEventListener("mouseup",we),()=>{window.removeEventListener("mousemove",O),window.removeEventListener("mouseup",we)}},[fe,qe]);const Li=w.useCallback(async()=>{var O;X(null);try{const we=pa(j),Me=((O=t.aiDraft)==null?void 0:O.status)==="generated"&&we!==(t.aiDraft.baseSig??"")?{...t.aiDraft,status:"edited",updatedAt:new Date().toISOString()}:t.aiDraft??void 0;await s(j,Me??null),d&&a()}catch(we){X(we instanceof Error?we.message:"Failed to save overlays")}},[j,s,a,d,t.aiDraft]),oe=w.useCallback(async()=>{if(L>0&&!I){const O=L;ne(`${O} overlay${O===1?"":"s"} from the cut plan ${O===1?"has":"have"} no usable position and cannot be exported — re-place ${O===1?"it":"them"} or discard ${O===1?"it":"them"} first.`);return}k(!0),ne(null);try{await s(j);const{exportCut:O,ensureFontsReady:we}=await ty(async()=>{const{exportCut:bi,ensureFontsReady:vi}=await import("./export-cut-DVpOZ5AO.js");return{exportCut:bi,ensureFontsReady:vi}},[]),Me=j.some(bi=>bi.type==="sfx"),Te=[M.family,...Me?[E.family]:[]],{ready:Ze,missing:Qe}=await we(Te);if(!Ze){ne(`Fonts not loaded: ${Qe.join(", ")}. Check your connection and retry.`),k(!1);return}if(t.cleanImagePath&&!R.url){ne(R.error?"Clean image failed to load — cannot export. Retry once it renders.":"Clean image still loading — wait for it to render, then export."),k(!1);return}const Nt=R.url,kt=await O(Nt,j,H,z,{narration:t.narration,dialogue:t.dialogue},t.kind==="text"?{background:t.background,aspectRatio:t.aspectRatio}:void 0),Rt=new FormData,Je=kt.type==="image/webp"?"webp":"jpg";Rt.append("file",kt,`cut-${t.id}.${Je}`);const hi=await h(`/api/stories/${e}/cuts/${i}/export-final/${t.id}`,{method:"POST",body:Rt});if(hi.ok)G(pa(j)),o==null||o();else{const bi=await hi.json();ne(bi.error||"Export failed")}}catch(O){ne(O instanceof Error?O.message:"Export failed")}finally{k(!1)}},[t,R,j,e,i,M,E,H,z,h,s,o,L,I]),se=j.find(O=>O.id===$),Ie=w.useMemo(()=>iD(j),[j]),je=w.useRef(t.id);w.useEffect(()=>{je.current!==t.id&&(je.current=t.id,G(pa(te.overlays)))},[t.id,te.overlays]);const De=rD({exported:!!t.finalImagePath||!!t.exportedAt,uploaded:!!t.uploadedUrl||!!t.uploadedCid,baselineSig:F,current:j}),Ct=w.useMemo(()=>nD({...t,overlays:j},{staleExport:De}),[t,j,De]),_t=w.useMemo(()=>ym(t),[t]),nt=w.useMemo(()=>{const O={};for(const we of j){const Me=V3(we);let Te=!1;if(A&&fe.width>0&&we.text){const Ze=we.type==="sfx"?z:H,Qe=Bn(we.width,fe.width),Nt=Bn(we.height,fe.height);Te=Eo(U(Ze),we.text,Qe,Nt,No(we,fe.height||300,Qe,Nt)).overflow}(Me||Te)&&(O[we.id]={outOfBounds:Me,overflow:Te})}return O},[j,A,fe,U,H,z]),xt=Object.keys(nt).length,Tt=[{key:"clean-image",label:"Clean",done:Ct.hasCleanImage},{key:"script-text",label:"Script",done:Ct.hasScriptText},{key:"bubbles",label:Ct.bubblesPlaced?`Bubbles ${Ct.bubblesPlaced}`:"Bubbles",done:Ct.bubblesPlaced>0},{key:"exported",label:"Exported",done:Ct.exported},{key:"uploaded",label:"Uploaded",done:Ct.uploaded}],ct=t.kind==="text",ui=!t.cleanImagePath;return!ct&&ui&&j.length===0&&!t.narration&&!((ei=t.dialogue)!=null&&ei.length)?f.jsx("div",{className:"h-full flex items-center justify-center text-sm text-muted",children:"No clean image — upload one first, or add overlays for a narration cut."}):f.jsxs("div",{className:"h-full flex flex-col","data-testid":"focused-lettering-editor",children:[f.jsxs("div",{className:"px-3 py-1.5 border-b border-border bg-surface/55 grid grid-cols-[minmax(14rem,1fr)_auto_minmax(12rem,1fr)] items-center gap-2","data-testid":"lettering-toolbar",children:[f.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden",children:[f.jsx("button",{onClick:a,className:"px-2.5 py-1 text-[11px] border border-border rounded text-muted hover:text-foreground","data-testid":"return-to-cut-review-btn",children:"Cut review"}),f.jsx("span",{className:"rounded-full border border-accent/30 bg-accent/10 px-2 py-0.5 text-[10px] font-bold uppercase tracking-[0.14em] text-accent whitespace-nowrap",children:"Lettering"}),f.jsx("span",{className:"text-[11px] font-mono text-muted",children:p??`Cut #${t.id}`}),f.jsxs("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-[10px] text-muted","data-testid":"overlay-count",children:[j.length," overlays"]}),Tt.map(O=>f.jsxs("span",{"data-testid":`lettering-check-${O.key}`,"data-done":O.done?"true":"false",className:`rounded-full border px-2 py-0.5 text-[10px] ${O.key==="exported"||O.key==="uploaded"?"hidden xl:inline-flex":""} ${O.done?"border-green-700/30 bg-green-700/10 text-green-700":"border-border bg-background text-muted"}`,children:[O.done?"✓ ":"○ ",O.label]},O.key)),f.jsx("span",{className:"sr-only",children:"Focused lettering editor"}),((Kn=t.aiDraft)==null?void 0:Kn.status)==="generated"&&f.jsx("span",{className:"rounded-full border border-accent/30 bg-accent/10 px-2 py-0.5 text-[10px] text-accent","data-testid":"ai-draft-current-target",children:"AI draft ready"})]}),f.jsxs("div",{className:"flex items-center justify-center gap-1 rounded border border-border bg-background px-1 py-0.5",children:[f.jsx("button",{onClick:()=>Fe("speech"),className:"px-2.5 py-1 text-[11px] rounded hover:bg-accent/10 hover:text-accent","data-testid":"add-speech",children:"Speech"}),f.jsx("button",{onClick:()=>Fe("narration"),className:"px-2.5 py-1 text-[11px] rounded hover:bg-accent/10 hover:text-accent","data-testid":"add-narration",children:"Narration"}),f.jsx("button",{onClick:()=>Fe("sfx"),className:"px-2.5 py-1 text-[11px] rounded hover:bg-accent/10 hover:text-accent","data-testid":"add-sfx",children:"SFX"})]}),f.jsxs("div",{className:"flex items-center gap-1.5 justify-end min-w-0",children:[_&&f.jsx("button",{onClick:_,className:"px-2.5 py-1 text-[11px] border border-border rounded text-muted hover:border-accent hover:text-accent","data-testid":"toggle-work-area-btn",children:x?"Hide work area":"Show work area"}),f.jsx("button",{type:"button",onClick:()=>ye(O=>!O),className:"px-2.5 py-1 text-[11px] border border-border rounded text-muted hover:border-accent hover:text-accent","data-testid":"lettering-help-toggle",children:ue?"Hide help":"Help"}),le&&f.jsx("span",{className:"text-[10px] text-error max-w-[18rem]",children:le}),de&&f.jsx("span",{className:"text-[10px] text-error max-w-[18rem]",children:de}),f.jsx("button",{onClick:oe,disabled:V,className:"px-2.5 py-1 text-[11px] border border-accent text-accent rounded hover:bg-accent/5 disabled:opacity-50","data-testid":"export-btn",children:V?"Exporting...":"Export"}),f.jsx("button",{onClick:()=>{Li()},className:"px-2.5 py-1 text-[11px] bg-accent text-white rounded hover:bg-accent-dim","data-testid":"save-lettering-btn",children:"Save"}),f.jsx("button",{onClick:a,className:"px-2.5 py-1 text-[11px] text-muted hover:text-foreground border border-border rounded","data-testid":"cancel-lettering-btn",children:"Cancel"})]})]}),ue&&f.jsx("div",{className:"px-3 py-1.5 border-b border-border bg-background text-[10px] text-muted","data-testid":"lettering-help-panel",children:"Add or select a bubble, edit it in the inspector, then Save to return to cut review. Use Export after the overlay layout is ready. Text cards use narration overlays on the canvas."}),L>0&&!I?f.jsxs("div",{className:"px-3 py-1 border-b border-border bg-error/10 text-[10px] text-error flex items-center gap-2 flex-wrap","data-testid":"overlay-repair-note",children:[f.jsxs("span",{children:[L," overlay",L===1?"":"s"," ","from the cut plan ",L===1?"has":"have"," no usable position and cannot be exported. Re-place"," ",L===1?"it":"them",", or"]}),f.jsxs("button",{onClick:()=>re(!0),"data-testid":"discard-invalid-overlays",className:"px-1.5 py-0.5 border border-error/40 rounded hover:bg-error/10",children:["discard ",L," unplaceable overlay",L===1?"":"s"]})]}):L>0?f.jsxs("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"overlay-repair-note",children:["Discarded ",L," unplaceable overlay",L===1?"":"s"," — the export will not include"," ",L===1?"it":"them","."]}):_e?f.jsx("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"overlay-repair-note",children:"Auto-placed overlays from the cut plan — review their positions before exporting."}):null,Ie.length>0&&f.jsxs("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"overlay-overlap-warning",children:["Cut #",t.id,": ",Ie.length," bubble"," ",Ie.length===1?"pair overlaps":"pairs overlap"," and may be hard to read —"," ",Ie.map(O=>`#${O.indexA+1} ${Df(j[O.indexA])} ↔ #${O.indexB+1} ${Df(j[O.indexB])}`).join("; "),". Move them apart, or export as-is if the overlap is intended."]}),De&&f.jsx("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"lettering-stale-export-warning",children:"Bubbles changed since the last export — re-export this cut and upload the new final image before publishing."}),xt>0&&f.jsxs("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"lettering-export-warning",children:[xt," bubble",xt===1?"":"s"," may not export cleanly:"," ",Object.entries(nt).map(([O,we])=>{const Me=j.findIndex(Ze=>Ze.id===O),Te=[we.outOfBounds?"outside image":null,we.overflow?"text overflow":null].filter(Boolean).join(", ");return`#${Me+1} ${Df(j[Me])} (${Te})`}).join("; "),". Resize or reposition before exporting."]}),f.jsxs("div",{className:"flex-1 min-h-0 flex",children:[f.jsxs("div",{ref:$e,className:"flex-1 min-w-0 relative overflow-hidden bg-[#f8f5ef]",onClick:ki,"data-testid":"editor-surface",children:[t.cleanImagePath&&R.error?f.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted text-xs","data-testid":"clean-image-error",children:"Clean image not available"}):t.cleanImagePath&&!R.url?f.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted text-xs","data-testid":"clean-image-loading",children:"Loading clean image…"}):t.cleanImagePath?f.jsx("img",{ref:Oe,src:R.url,alt:`Cut ${t.id} clean`,className:"w-full h-full object-contain",draggable:!1,onLoad:ft}):ct?fe.width>0&&f.jsx("div",{className:"absolute flex items-center justify-center text-muted text-xs",style:{left:fe.x,top:fe.y,width:fe.width,height:fe.height,background:t.background||"#ffffff"},"data-testid":"text-panel-canvas",children:"Text panel"}):f.jsx("div",{className:"w-full h-full bg-white flex items-center justify-center text-muted text-xs",ref:O=>{if(O&&fe.width===0){const we=O.getBoundingClientRect();we.width>0&&Pe({x:0,y:0,width:we.width,height:we.height})}},children:"Narration cut"}),(b||v)&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{type:"button",onClick:b,disabled:!S,className:"absolute left-3 top-1/2 z-20 flex h-12 w-8 -translate-y-1/2 items-center justify-center rounded border border-border bg-background/85 text-2xl text-accent shadow-sm hover:bg-background disabled:opacity-30 disabled:hover:bg-background/85","data-testid":"previous-cut-btn","aria-label":"Previous cut",children:[f.jsx("span",{"aria-hidden":!0,children:"‹"}),f.jsx("span",{className:"sr-only",children:"Previous cut"})]}),f.jsxs("button",{type:"button",onClick:v,disabled:!N,className:"absolute right-3 top-1/2 z-20 flex h-12 w-8 -translate-y-1/2 items-center justify-center rounded border border-border bg-background/85 text-2xl text-accent shadow-sm hover:bg-background disabled:opacity-30 disabled:hover:bg-background/85","data-testid":"next-cut-btn","aria-label":"Next cut",children:[f.jsx("span",{"aria-hidden":!0,children:"›"}),f.jsx("span",{className:"sr-only",children:"Next cut"})]})]}),fe.width>0&&f.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","data-testid":"balloon-layer",children:j.map(O=>{if(O.type!=="speech")return null;const we=fe.x+Bn(O.x,fe.width),Me=fe.y+Bn(O.y,fe.height),Te=Bn(O.width,fe.width),Ze=Bn(O.height,fe.height),Qe=PS(O,Te,Ze),Nt=O.tailAnchor?vm(we,Me,Te,Ze,O.tailAnchor,Qe):null,kt=Math.max(1.5,fe.height*.004),Rt=O.id===$;return f.jsx("path",{"data-testid":`balloon-${O.id}`,d:HS(we,Me,Te,Ze,Nt,Qe),className:`fill-white/95 ${Rt?"stroke-accent":"stroke-[#1a1a1a]"}`,strokeWidth:Rt?kt+.5:kt,strokeLinejoin:"round"},O.id)})}),fe.width>0&&j.map(O=>{const we=fe.x+Bn(O.x,fe.width),Me=fe.y+Bn(O.y,fe.height),Te=Bn(O.width,fe.width),Ze=Bn(O.height,fe.height),Qe=O.id===$,Nt=O.type==="speech",kt=O.type==="narration",Rt=!!nt[O.id];return f.jsxs("div",{"data-testid":`overlay-${O.id}`,"data-warning":Rt?"true":"false",onClick:Je=>Ei(Je,O.id),onMouseDown:Je=>yt(Je,O.id,"move"),className:`absolute rounded cursor-move select-none ${Nt?"":`border-2 ${aD[O.type]}`} ${kt?"bg-[#f4efe6]/85 rounded-md":""} ${Qe&&!Nt?"ring-2 ring-accent":""} ${Rt?"ring-2 ring-amber-500":""}`,style:{left:we,top:Me,width:Te,height:Ze},children:[(()=>{var vi,Ot;const Je=O.type==="sfx"?z:H;if(!O.text)return f.jsx("span",{className:"text-[9px] px-1 text-muted truncate block pointer-events-none",style:{fontFamily:Je},children:To[O.type]});const hi=O.type!=="sfx"&&!!O.speaker;if(!A)return f.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-1 overflow-hidden pointer-events-none text-center break-words",style:{fontFamily:Je,fontSize:Math.max(9,Math.min(Ze*.05,16)),fontWeight:((vi=O.textStyle)==null?void 0:vi.fontWeight)??400},"data-testid":`overlay-text-${O.id}`,"data-fonts-ready":"false",children:hi?`${O.speaker}: ${O.text}`:O.text});const bi=Eo(U(Je),O.text,Te,Ze,No(O,fe.height,Te,Ze));return f.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center px-1 overflow-hidden pointer-events-none text-center",style:{fontFamily:Je},"data-testid":`overlay-text-${O.id}`,"data-fonts-ready":"true",children:[hi&&f.jsx("span",{className:"font-bold text-[#3a3a3a] block",style:{fontSize:bi.speakerFontSize,lineHeight:1.2},children:O.speaker}),f.jsx("span",{className:"text-[#1a1a1a]",style:{fontSize:bi.fontSize,lineHeight:`${bi.lineHeight}px`,fontWeight:((Ot=O.textStyle)==null?void 0:Ot.fontWeight)??400},children:bi.lines.map((si,Zt)=>f.jsx("span",{className:"block",children:si},Zt))})]})})(),Qe&&f.jsx("div",{onMouseDown:Je=>{Je.stopPropagation(),yt(Je,O.id,"resize")},className:"absolute bottom-0 right-0 w-2 h-2 bg-accent cursor-se-resize","data-testid":`resize-${O.id}`})]},O.id)})]}),f.jsx("div",{className:"w-64 border-l border-border p-3 overflow-y-auto flex-shrink-0",children:se?f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsx("p",{className:"text-xs font-medium text-foreground",children:To[se.type]}),f.jsxs("span",{className:"text-[10px] text-muted",children:["#",j.findIndex(O=>O.id===se.id)+1]})]}),se.speaker!==void 0&&f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Speaker"}),f.jsx("input",{value:se.speaker||"",onChange:O=>qe(se.id,{speaker:O.target.value}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",placeholder:"Character name","data-testid":"inspector-speaker"})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Text"}),f.jsx("textarea",{value:se.text,onChange:O=>qe(se.id,{text:O.target.value}),rows:3,className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent resize-none focus:border-accent focus:outline-none",placeholder:"Overlay text","data-testid":"inspector-text"})]}),f.jsx("button",{onClick:()=>qe(se.id,tt(se)),"data-testid":"inspector-fit-text",className:"w-full px-2 py-1 text-[11px] border border-border rounded hover:border-accent hover:text-accent",title:"Resize this overlay so its text fits without overflowing",children:"Fit box to text"}),f.jsxs("div",{className:"space-y-1.5 rounded border border-border/70 p-2","data-testid":"inspector-typography",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Typography"}),((mn=se.textStyle)==null?void 0:mn.mode)==="manual"?f.jsx("button",{type:"button",onClick:()=>qe(se.id,{textStyle:void 0}),className:"px-1.5 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":"inspector-text-auto",children:"Auto-fit"}):f.jsx("button",{type:"button",onClick:()=>Gt(se),className:"px-1.5 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":"inspector-text-manual",children:"Manual"})]}),((_i=se.textStyle)==null?void 0:_i.mode)==="manual"?f.jsxs("div",{className:"space-y-1.5",children:[f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Font size (% panel height)"}),f.jsx("input",{type:"number",step:"0.1",min:"1.5",max:"12",value:((se.textStyle.fontScale??.032)*100).toFixed(1),onChange:O=>qe(se.id,{textStyle:{...se.textStyle,mode:"manual",fontScale:Math.max(.015,Math.min(.12,(parseFloat(O.target.value)||3.2)/100))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-font-scale"})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Weight"}),f.jsxs("select",{value:String(se.textStyle.fontWeight??400),onChange:O=>qe(se.id,{textStyle:{...se.textStyle,mode:"manual",fontWeight:O.target.value==="700"?700:400}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-font-weight",children:[f.jsx("option",{value:"400",children:"Regular"}),f.jsx("option",{value:"700",children:"Bold"})]})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Line height"}),f.jsx("input",{type:"number",step:"0.05",min:"0.9",max:"2",value:(se.textStyle.lineHeightFactor??1.2).toFixed(2),onChange:O=>qe(se.id,{textStyle:{...se.textStyle,mode:"manual",lineHeightFactor:Math.max(.9,Math.min(2,parseFloat(O.target.value)||1.2))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-line-height"})]}),se.type!=="sfx"&&f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Speaker scale"}),f.jsx("input",{type:"number",step:"0.05",min:"0.5",max:"1.5",value:(se.textStyle.speakerScale??.8).toFixed(2),onChange:O=>qe(se.id,{textStyle:{...se.textStyle,mode:"manual",speakerScale:Math.max(.5,Math.min(1.5,parseFloat(O.target.value)||.8))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-speaker-scale"})]})]}):f.jsx("p",{className:"text-[10px] text-muted",children:"Auto-fit stays on by default and resizes text to the box."})]}),se.type==="speech"&&(()=>{const O=se.tailAnchor||{x:.5,y:1.2};return f.jsxs("div",{className:"space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Tail anchor"}),f.jsx("div",{className:"flex flex-wrap gap-1","data-testid":"inspector-tail-presets",children:lD.map(we=>f.jsx("button",{type:"button",onClick:()=>qe(se.id,{tailAnchor:we.anchor}),className:"px-1.5 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":`inspector-tail-${we.key}`,children:we.label},we.key))}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("label",{className:"flex items-center gap-1 text-[10px] font-mono text-muted",children:["x",f.jsx("input",{type:"number",step:"0.1",value:O.x,onChange:we=>qe(se.id,{tailAnchor:{...O,x:parseFloat(we.target.value)||0}}),className:"w-14 px-1 py-0.5 text-[10px] border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-tail-x"})]}),f.jsxs("label",{className:"flex items-center gap-1 text-[10px] font-mono text-muted",children:["y",f.jsx("input",{type:"number",step:"0.1",value:O.y,onChange:we=>qe(se.id,{tailAnchor:{...O,y:parseFloat(we.target.value)||0}}),className:"w-14 px-1 py-0.5 text-[10px] border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-tail-y"})]})]})]})})(),se.type!=="sfx"&&f.jsxs("div",{className:"space-y-1.5 rounded border border-border/70 p-2","data-testid":"inspector-bubble-style",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Bubble controls"}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Padding X (% width)"}),f.jsx("input",{type:"number",step:"1",min:"0",max:"25",value:((((xi=se.bubbleStyle)==null?void 0:xi.paddingX)??.06)*100).toFixed(0),onChange:O=>qe(se.id,{bubbleStyle:{...se.bubbleStyle,paddingX:Math.max(0,Math.min(.25,(parseFloat(O.target.value)||6)/100))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-padding-x"})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Padding Y (% height)"}),f.jsx("input",{type:"number",step:"1",min:"0",max:"25",value:((((Ht=se.bubbleStyle)==null?void 0:Ht.paddingY)??.08)*100).toFixed(0),onChange:O=>qe(se.id,{bubbleStyle:{...se.bubbleStyle,paddingY:Math.max(0,Math.min(.25,(parseFloat(O.target.value)||8)/100))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-padding-y"})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Corner roundness (% short side)"}),f.jsx("input",{type:"number",step:"1",min:"0",max:"49",value:((((ln=se.bubbleStyle)==null?void 0:ln.cornerRadius)??.4)*100).toFixed(0),onChange:O=>qe(se.id,{bubbleStyle:{...se.bubbleStyle,cornerRadius:Math.max(0,Math.min(.49,(parseFloat(O.target.value)||40)/100))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-corner-radius"})]})]}),f.jsxs("div",{className:"text-[10px] text-muted","data-testid":"inspector-font",children:["Font:"," ",se.type==="sfx"?E.family:M.family]}),f.jsxs("div",{className:"text-[10px] font-mono text-muted space-y-0.5",children:[f.jsxs("p",{children:["x: ",se.x.toFixed(3),", y:"," ",se.y.toFixed(3)]}),f.jsxs("p",{children:["w: ",se.width.toFixed(3),", h:"," ",se.height.toFixed(3)]})]}),f.jsx("button",{onClick:()=>{T?wt(se.id):D(!0)},className:"w-full px-2 py-1 text-xs text-error border border-error/30 rounded hover:bg-error/5","data-testid":"delete-overlay",children:T?"Click again to delete":"Delete"}),_t.length>0&&f.jsxs("div",{className:"space-y-1.5 border-t border-border pt-3","data-testid":"script-insert-panel",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Add from script"}),f.jsx("div",{className:"flex flex-col gap-1",children:_t.map(O=>f.jsxs("button",{onClick:()=>ze(O),"data-testid":`script-insert-${O.key}`,title:`Add ${O.type} overlay with this text`,className:"text-left px-2 py-1 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5",children:[f.jsxs("span",{className:"font-medium text-accent",children:["+ ",To[O.type]]})," ",f.jsxs("span",{className:"text-muted",children:[O.speaker?`${O.speaker}: `:"",O.text.length>32?`${O.text.slice(0,32)}…`:O.text]})]},O.key))})]})]}):f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-xs text-muted","data-testid":"inspector-empty",children:"Select or add an overlay to inspect it."}),((Ui=t.aiDraft)==null?void 0:Ui.status)==="generated"&&f.jsx("div",{className:"rounded border border-accent/30 bg-accent/5 p-2 text-[10px] text-muted",children:"AI drafted overlays are editable here before export."}),_t.length>0&&f.jsxs("div",{className:"space-y-1.5","data-testid":"script-insert-panel",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Add from script"}),f.jsx("div",{className:"flex flex-col gap-1",children:_t.map(O=>f.jsxs("button",{onClick:()=>ze(O),"data-testid":`script-insert-${O.key}`,title:`Add ${O.type} overlay with this text`,className:"text-left px-2 py-1 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5",children:[f.jsxs("span",{className:"font-medium text-accent",children:["+ ",To[O.type]]})," ",f.jsxs("span",{className:"text-muted",children:[O.speaker?`${O.speaker}: `:"",O.text.length>32?`${O.text.slice(0,32)}…`:O.text]})]},O.key))})]})]})})]})]})}function dy(e){const t=`gfont-${e.googleFontsId}`;if(document.getElementById(t))return;const i=document.createElement("link");i.id=t,i.rel="stylesheet",i.href=OS(e),document.head.appendChild(i)}function cD({storyName:e,assetPath:t,authFetch:i,alt:s,overlays:a,language:o="English",background:c,aspectRatio:h,className:p,onClick:d,testId:x}){const _=BS(o),b=LS(),v=Bu(_),S=Bu(b),N=WS(e,t,i),M=w.useRef(null),E=w.useMemo(()=>typeof document<"u"?document.createElement("canvas").getContext("2d"):null,[]),[H,z]=w.useState(!1),[R,te]=w.useState(()=>FS(h)??{width:800,height:600}),[L,I]=w.useState({width:0,height:0});w.useEffect(()=>{dy(_),dy(b)},[_,b]),w.useEffect(()=>{let j=!1;return(async()=>{var J;try{(J=document.fonts)!=null&&J.load&&await Promise.all([document.fonts.load(`16px "${_.family}"`),document.fonts.load(`16px "${b.family}"`)])}catch{}j||z(!0)})(),()=>{j=!0}},[_.family,b.family]),w.useEffect(()=>{const j=M.current;if(!j)return;const J=()=>{I({width:j.clientWidth,height:j.clientHeight})};if(typeof ResizeObserver>"u")return J(),window.addEventListener("resize",J),()=>window.removeEventListener("resize",J);const F=new ResizeObserver(()=>{J()});return F.observe(j),()=>F.disconnect()},[]);const re=w.useCallback(j=>(J,F,G=400)=>E?(E.font=`${G} ${F}px ${j}`,E.measureText(J).width):J.length*F*.5,[E]),_e=f.jsx("div",{className:p??"w-full rounded border border-border bg-white","data-testid":x,ref:M,style:{aspectRatio:`${R.width} / ${R.height}`,maxHeight:"32rem"},children:f.jsxs("div",{className:"relative w-full h-full overflow-hidden rounded border border-border bg-white",children:[t?N.error||!N.loading&&!N.url?f.jsx("div",{className:"w-full h-full flex items-center justify-center text-[10px] text-muted bg-surface/40",children:"Image not available"}):N.url?f.jsx("img",{src:N.url,alt:s,className:"absolute inset-0 w-full h-full object-contain",draggable:!1,onLoad:j=>{const J=j.currentTarget.naturalWidth||R.width,F=j.currentTarget.naturalHeight||R.height;J>0&&F>0&&te({width:J,height:F})}}):f.jsx("div",{className:"w-full h-full flex items-center justify-center text-[10px] text-muted bg-surface/40",children:"Loading image…"}):f.jsx("div",{className:"absolute inset-0",style:{background:c||"#101820"}}),L.width>0&&L.height>0&&a.length>0&&f.jsxs(f.Fragment,{children:[f.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","data-testid":x?`${x}-overlay-layer`:void 0,children:a.map(j=>{if(j.type!=="speech")return null;const J=j.x*L.width,F=j.y*L.height,G=j.width*L.width,Y=j.height*L.height,U=PS(j,G,Y),A=j.tailAnchor?vm(J,F,G,Y,j.tailAnchor,U):null,q=Math.max(1.25,L.height*.004);return f.jsx("path",{"data-testid":x?`${x}-overlay-${j.id}`:void 0,d:HS(J,F,G,Y,A,U),className:"fill-white/95 stroke-[#1a1a1a]",strokeWidth:q,strokeLinejoin:"round"},j.id)})}),a.map(j=>{var $;const J=j.x*L.width,F=j.y*L.height,G=j.width*L.width,Y=j.height*L.height,U=j.type==="sfx"?S:v,A=j.type==="speech";j.type;const q=j.type!=="sfx"&&!!j.speaker;return f.jsx("div",{className:`absolute rounded overflow-hidden ${A?"":"border-2"} ${j.type==="narration"?"border-muted/40 bg-[#f4efe6]/85 rounded-md":j.type==="sfx"?"border-accent/40":""}`,style:{left:J,top:F,width:G,height:Y},children:j.text?H?(()=>{var T;const be=Eo(re(U),j.text,G,Y,No(j,L.height,G,Y));return f.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center px-1 text-center",style:{fontFamily:U},children:[q&&f.jsx("span",{className:"block font-bold text-[#3a3a3a]",style:{fontSize:be.speakerFontSize,lineHeight:1.2},children:j.speaker}),f.jsx("span",{className:"text-[#1a1a1a]",style:{fontSize:be.fontSize,lineHeight:`${be.lineHeight}px`,fontWeight:((T=j.textStyle)==null?void 0:T.fontWeight)??400},children:be.lines.map((D,V)=>f.jsx("span",{className:"block",children:D},V))})]})})():f.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-1 text-center break-words",style:{fontFamily:U,fontSize:Math.max(8,Math.min(Y*.05,14)),fontWeight:(($=j.textStyle)==null?void 0:$.fontWeight)??400},children:q?`${j.speaker}: ${j.text}`:j.text}):f.jsx("span",{className:"block truncate px-1 text-[9px] text-muted",style:{fontFamily:U},children:j.type})},j.id)})]})]})});return d?f.jsx("button",{type:"button",onClick:d,className:"block w-full text-left","data-testid":x?`${x}-open`:void 0,children:_e}):_e}const uD={wide:"Wide",medium:"Medium","close-up":"Close-up","extreme-close-up":"Extreme close-up"},hD="No speech bubbles, captions, sound effects, narration, or any text or lettering in the image.",dD="Style lock — illustrated comic/webtoon panel art: clean black contour/ink lines, flat or cel shading, simplified but realistic (semi-realistic) anatomy and faces, backgrounds drawn as illustrated comic panels. Hold this same style on every cut for character and panel consistency. Hard negatives — NOT photorealistic, NOT a photograph, NOT a glossy or painterly digital painting, NOT concept art, NOT a 3D/CGI render, NOT airbrushed, no photoreal textures.";function fD(e){var a;const t=uD[e.shotType]??e.shotType,i=((a=e.description)==null?void 0:a.trim())||`Cut ${e.id}`,s=[`${t} shot. ${i}`];return e.characters.length>0&&s.push(`Characters: ${e.characters.join(", ")}.`),s.push(dD),s.push(hD),s.join(`
130
+ `).trim()}function pD(e,t){return`assets/${e}/cut-${String(t).padStart(2,"0")}-clean.webp`}function fy(e,t){const i=pD(t,e.id);return[`Generate the clean image for cut ${e.id}.`,"","Image description:",fD(e),"","How to hand it off:","- Produce the actual image — do not just describe it or return a prompt.",`- If your image tool can write a WebP or JPEG under 1MB, save it at ${i} and run "Sync clean images".`,'- If it only produces a PNG (e.g. built-in image generation saves to ~/.codex/generated_images), that is fine — do NOT convert or rename it yourself. Leave it there and import it into this cut with the OWS "Import from Codex" button, which converts the PNG automatically.',"- Clean image only: no text, speech bubbles, captions, sound effects, signage, watermark, or signature.","- Hold the style lock above — an illustrated comic/webtoon panel, NOT a photoreal photo, painterly concept art, or 3D render. If a result reads photorealistic, regenerate it as illustrated panel art.","- Do not letter or upload anything — final lettering and upload happen later in OWS."].join(`
131
+ `)}const GS=12e3,mD=5,gD=6e4,_D=6e4,xD=5;function bD(e,t){return e===429?!0:!!t&&/rate[\s-]?limit/i.test(t)}function vD(e,t=GS){return Math.min(t*2**e,gD)}const YS=e=>new Promise(t=>setTimeout(t,e));async function yD(e,t={}){var c;const i=t.sleep??YS,s=t.maxRetries??mD,a=t.baseDelayMs??GS;let o=0;for(;;){const h=await e();if(h.ok||!bD(h.status,h.errorMessage)||o>=s)return h;const p=vD(o,a);o+=1,(c=t.onWaiting)==null||c.call(t,{attempt:o,maxRetries:s,waitMs:p}),await i(p)}}function SD(e={}){const t=e.limit??xD,i=e.windowMs??_D,s=e.sleep??YS,a=e.now??(()=>Date.now()),o=[],c=()=>{const h=a()-i;for(;o.length&&o[0]<=h;)o.shift()};return async function(){var p;if(c(),o.length>=t){const d=o[0]+i-a();d>0&&((p=e.onWaiting)==null||p.call(e,{waitMs:d}),await s(d)),c()}o.push(a())}}const Lp=1024*1024;function py(e,t,i){return new Promise((s,a)=>{e.toBlob(o=>o?s(o):a(new Error(`Failed to export as ${t}`)),t,i)})}async function wD(e){const t=[.9,.8,.7,.6];for(const s of t)try{const a=await py(e,"image/webp",s);if(a.type!=="image/webp")break;if(a.size<=Lp)return a}catch{break}const i=[.85,.7,.5];for(const s of i){const a=await py(e,"image/jpeg",s);if(a.size<=Lp)return a}throw new Error("Cannot compress image under 1MB — reduce overlay count or image size")}const CD=["image/webp","image/jpeg"];function KS(e){return CD.includes(e.type)&&e.size<=Lp}async function kD(e){var i;if(typeof createImageBitmap!="function")throw new Error("This browser cannot decode the image for import");let t;try{t=await createImageBitmap(e)}catch{throw new Error("Could not read the selected image — pick a PNG, WebP, or JPEG file")}try{const s=document.createElement("canvas");s.width=t.width,s.height=t.height;const a=s.getContext("2d");if(!a)throw new Error("Could not process the image for import");return a.drawImage(t,0,0),s}finally{(i=t.close)==null||i.call(t)}}async function Yu(e){if(KS(e))return e;const t=await kD(e);return wD(t)}function ED(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.token=="string"&&t.token.length>0&&typeof t.name=="string"&&typeof t.size=="number"&&typeof t.mtimeMs=="number"}async function ND(e){let t;try{t=await e("/api/codex/images")}catch{return[]}if(!t.ok)return[];let i;try{i=await t.json()}catch{return[]}const s=i==null?void 0:i.images;return Array.isArray(s)?s.filter(ED):[]}async function TD(e,t){let i;try{i=await e(`/api/codex/images/${encodeURIComponent(t.token)}`)}catch{throw new Error("Could not read the generated image from the Codex cache")}if(!i.ok)throw new Error("Could not read the generated image from the Codex cache");const s=await i.blob(),a=s.type||i.headers.get("Content-Type")||"image/png";return new File([s],t.name||"codex-image.png",{type:a})}function jD(e,t){const[i,s]=w.useState(null);return w.useEffect(()=>{let a=null,o=!1;return(async()=>{try{const c=await t(e);if(!c.ok)return;const h=await c.blob();if(o)return;a=URL.createObjectURL(h),s(a)}catch{}})(),()=>{o=!0,a&&URL.revokeObjectURL(a)}},[e,t]),i}function AD(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function RD(e,t){const i=t-e;if(!Number.isFinite(i)||i<45e3)return"just now";const s=Math.round(i/6e4);if(s<60)return`${s}m ago`;const a=Math.round(i/36e5);if(a<24)return`${a}h ago`;const o=Math.round(i/864e5);return o<7?`${o}d ago`:`${Math.round(i/(7*864e5))}w ago`}function DD({image:e,authFetch:t}){const i=jD(`/api/codex/images/${encodeURIComponent(e.token)}`,t);return i?f.jsx("img",{src:i,alt:e.name,className:"w-16 h-16 flex-shrink-0 rounded border border-border object-cover bg-white"}):f.jsx("div",{className:"w-16 h-16 flex-shrink-0 rounded border border-border bg-surface"})}function MD({authFetch:e,cutId:t,onImport:i,onClose:s}){const[a,o]=w.useState(null),[c,h]=w.useState(null),[p,d]=w.useState(null),[x,_]=w.useState("");w.useEffect(()=>{let E=!1;return(async()=>{const H=await ND(e);E||o(H)})(),()=>{E=!0}},[e]);const b=x.trim().toLowerCase(),v=w.useMemo(()=>a?b?a.filter(E=>E.name.toLowerCase().includes(b)):a:[],[a,b]),S=Date.now(),N=async E=>{h(null),d(E.token);try{const H=await TD(e,E);await i(H)}catch(H){h(H instanceof Error?H.message:"Could not import the generated image")}finally{d(null)}},M=a!==null&&a.length>0;return f.jsxs("div",{className:"rounded border border-border bg-surface/60 p-2 space-y-2","data-testid":`codex-picker-${t}`,children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Import a Codex-generated image"}),f.jsx("button",{onClick:s,"data-testid":`codex-picker-close-${t}`,className:"text-[11px] text-muted hover:text-foreground",children:"Close"})]}),M&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"search",value:x,onChange:E=>_(E.target.value),placeholder:"Filter by file name…","data-testid":`codex-picker-search-${t}`,className:"min-w-0 flex-1 px-2 py-1 text-[11px] border border-border rounded bg-transparent focus:border-accent focus:outline-none"}),f.jsx("span",{className:"text-[10px] text-muted whitespace-nowrap","data-testid":`codex-picker-count-${t}`,children:b?`${v.length} of ${a.length}`:`${a.length} image${a.length===1?"":"s"}`})]}),a===null&&f.jsx("p",{className:"text-[11px] text-muted","data-testid":`codex-picker-loading-${t}`,children:"Looking for generated images…"}),a!==null&&a.length===0&&f.jsx("p",{className:"text-[11px] text-muted","data-testid":`codex-picker-empty-${t}`,children:"No generated images found in the Codex cache yet. Generate art in Codex, then reopen this list — or use “Upload clean image” to pick a file."}),M&&v.length===0&&f.jsxs("p",{className:"text-[11px] text-muted","data-testid":`codex-picker-no-match-${t}`,children:["No generated images match “",x.trim(),"”."]}),M&&v.length>0&&f.jsx("ul",{className:"space-y-1 max-h-72 overflow-y-auto",children:v.map(E=>f.jsxs("li",{"data-testid":`codex-image-${E.token}`,className:"flex items-center gap-2 rounded border border-border bg-background/40 p-1.5",children:[f.jsx(DD,{image:E,authFetch:e}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("p",{className:"text-[11px] text-foreground",children:[RD(E.mtimeMs,S)," · ",AD(E.size)]}),f.jsx("p",{className:"truncate text-[10px] font-mono text-muted",title:E.name,children:E.name})]}),f.jsx("button",{onClick:()=>N(E),disabled:p!==null,"data-testid":`codex-import-${E.token}`,className:"px-2 py-1 text-[11px] border border-accent/30 text-accent rounded hover:bg-accent/5 disabled:opacity-50",children:p===E.token?"Importing…":"Import to this cut"})]},E.token))}),c&&f.jsx("p",{className:"text-[11px] text-error",children:c})]})}function BD(e){return`${e}: re-export required before publish — this final image uses an older speech-bubble tail style that can show a visible seam`}const LD=[/placeholder only/i,/\bOWS (?:should )?generates? the publish markdown/i,/generate(?:s|d)? the publish markdown from/i,/after clean images are approved/i,/lettered final images are created/i,/do not hand-?write/i,/\b(?:TODO|FIXME)\b/];function OD(e){for(const t of LD){const i=e.match(t);if(i)return i[0]}return null}function Sm(e,t){const i=`<!-- ows:cartoon-cut ${t} start -->`,s=`<!-- ows:cartoon-cut ${t} end -->`,a=e.indexOf(i),o=e.indexOf(s);return a===-1||o===-1||o<a?null:e.slice(a+i.length,o)}function zD(e,t){if(t.length===0)return!1;for(let i=0;i<t.length;i++){const s=`cut-${String(i+1).padStart(3,"0")}`;if(Sm(e,s)===null)return!0}return!1}function VS(e,t){const i=[];if(t.length===0)return{ready:!1,issues:["This episode has no cuts planned yet — plan and produce its cuts before publishing."]};for(let c=0;c<t.length;c++){const h=t[c],p=`Cut ${c+1}`,d=`cut-${String(c+1).padStart(3,"0")}`;h.uploadedUrl||i.push(`${p}: not uploaded (no recorded uploaded URL)`),$S(h)&&i.push(BD(p));const x=Sm(e,d);if(x===null){i.push(`${p}: missing or incomplete markdown block`);continue}const _=[...x.matchAll(/!\[[^\]]*\]\(([^)]*)\)/g)].map(b=>b[1].trim());_.length===0?i.push(`${p}: block has no image reference`):_.length>1?i.push(`${p}: block must contain exactly one image reference`):h.uploadedUrl&&_[0]!==h.uploadedUrl&&i.push(`${p}: image URL does not match the recorded uploaded URL`)}/awaiting upload|image pending|final image pending|pending upload/i.test(e)&&i.push("Markdown contains awaiting-upload placeholders");const s=OD(e);s&&i.push(`This episode still has placeholder/instructional text ("${s.slice(0,60)}") — remove it or re-run “Prepare episode for publish” so the published episode is images only`);const a=new Set(t.map(c=>c.uploadedUrl).filter(c=>!!c&&/^https?:\/\//i.test(c))),o=[...e.matchAll(/!\[[^\]]*\]\(([^)]*)\)/g)];for(const c of o){const h=c[1].trim();/^https?:\/\//i.test(h)?a.has(h)||i.push(`Image reference is not a recorded uploaded cut URL: ${h.slice(0,60)}`):i.push(`Invalid image reference (not an http(s) URL): ${h.slice(0,60)}`)}return e.length>1e4&&i.push(`Markdown is ${e.length} chars (limit 10,000)`),{ready:i.length===0,issues:i}}function XS(e,t){const i=t.length;if(i===0)return{stage:"not-started",issues:[],awaitingCount:0,totalCuts:0};if(zD(e,t))return{stage:"planning",issues:[],awaitingCount:0,totalCuts:i};const{ready:s,issues:a}=VS(e,t);if(s)return{stage:"ready",issues:[],awaitingCount:0,totalCuts:i};const o=new Set;for(let p=0;p<t.length;p++){const d=`Cut ${p+1}`,x=`cut-${String(p+1).padStart(3,"0")}`,_=Sm(e,x);if(_===null)continue;!/!\[[^\]]*\]\([^)]*\)/.test(_)&&!t[p].uploadedUrl&&o.add(d)}const c=new Set(["Markdown contains awaiting-upload placeholders"]);for(const p of o)c.add(`${p}: not uploaded (no recorded uploaded URL)`),c.add(`${p}: block has no image reference`);const h=a.filter(p=>!c.has(p));return h.length>0?{stage:"error",issues:h,awaitingCount:o.size,totalCuts:i}:{stage:"awaiting-upload",issues:[],awaitingCount:o.size,totalCuts:i}}const Mf=[{key:"assemble",title:"Prepare the episode for publish",test:/markdown block|missing or incomplete/i},{key:"export",title:"Export final images",test:/re-export|older speech-bubble|visible seam/i},{key:"upload",title:"Upload final images",test:/not uploaded|no recorded uploaded url/i},{key:"images",title:"Fix image references",test:/image reference|not an http|does not match|exactly one image/i},{key:"cleanup",title:"Remove leftover text",test:/placeholder|instructional|awaiting-upload|awaiting upload/i},{key:"size",title:"Shorten the episode",test:/\blimit\b|\bchars\b/i}];function PD(e){const t=new Map,i=[],s=[];for(const o of e){const c=o.match(/^Cut (\d+): (.+)$/);if(c){const h=c[2];t.has(h)||(t.set(h,[]),i.push(h)),t.get(h).push(Number(c[1]))}else s.push(o)}return[...i.map(o=>{const c=t.get(o).slice().sort((p,d)=>p-d);return`${c.length===1?`Cut ${c[0]}`:`Cuts ${c.join(", ")}`}: ${o}`}),...s]}function ZS(e){const t=c=>{var h;return((h=Mf.find(p=>p.test.test(c)))==null?void 0:h.key)??"other"},i=new Map;for(const c of e){const h=t(c);i.has(h)||i.set(h,[]),i.get(h).push(c)}const s=[...Mf.map(c=>c.key),"other"],a=c=>{var h;return((h=Mf.find(p=>p.key===c))==null?void 0:h.title)??"Other issues"},o=[];for(const c of s){const h=i.get(c);!h||h.length===0||o.push({key:c,title:a(c),lines:PD(h)})}return o}const ID=220,Bf=/^(genre|logline|synopsis|premise|setting|tone|theme|themes|summary|hook|characters?|cast|arc|status|word\s*count|length|title)\b\s*[:\-–]/i;function wm(e){const t=[],i=[],s=e??"",a=s.match(/^#[ \t]+(.+)$/m),o=!!(a&&a[1].trim());o||t.push("Add a “# Title” heading — the Story opening needs a real title readers see first.");const c=s.replace(/^#\s+.+$/m,"").trim();if(c.length<ID)t.push("This Story opening is too short. Open the story for readers — the premise, the lead, and the stakes across a few short paragraphs that bridge into Episode 01, not a one-line setup.");else{const h=c.split(`
132
+ `).map(_=>_.trim()).filter(Boolean),p=h.filter(_=>/^([-*+]|\d+[.)])\s/.test(_)||Bf.test(_)).length,d=c.split(/\n\s*\n/).map(_=>_.trim()).filter(Boolean),x=d.some(_=>_.length>=120&&!/^([-*+]|\d+[.)])\s/.test(_)&&!Bf.test(_));h.length>0&&p/h.length>=.5||!x?t.push("This reads like a synopsis or outline. Write the Genesis as a reader-facing opening scene that sets up the first beat and stakes, then bridges into Episode 01 — not a logline, genre pitch, or character list."):d.filter(b=>b.length>=40&&!/^([-*+]|\d+[.)])\s/.test(b)&&!Bf.test(b)).length<2&&t.push("Give the opening room to build: open across a few short paragraphs — the premise, what the lead wants, and the hook — that lead into Episode 01, instead of a single dense block that drops readers into a cold scene.")}return{hasTitle:o,blockers:t,warnings:i}}function HD(e){return/\.(webp|jpe?g)$/i.test(e)}function Op(e){var c,h;let t=0,i=0,s=0,a=0,o=0;for(const p of e)vn(p)?(((h=p.overlays)==null?void 0:h.length)??0)>0&&s++:(t++,p.cleanImagePath&&HD(p.cleanImagePath)&&(i++,(((c=p.overlays)==null?void 0:c.length)??0)>0&&s++)),p.finalImagePath&&p.exportedAt&&a++,p.uploadedUrl&&o++;return{total:e.length,needClean:t,withClean:i,withText:s,exported:a,uploaded:o}}const UD={plan:"Plan cuts",clean:"Create clean images",letter:"Add speech bubbles & captions",export:"Export final images",upload:"Upload final images",publish:"Publish to PlotLink"};function vo(e,t){return`${e} / ${t} cut${t===1?"":"s"}`}function QS(e){const{cuts:t,published:i=!1}=e,s=Op(t);if(s.total===0)return{steps:[],nextStep:null};const a=s.total>0,o=a&&s.withClean===s.needClean,c=o&&s.withText===s.total,h=c&&s.exported===s.total,p=h&&s.uploaded===s.total,x={plan:a,clean:o,letter:c,export:h,upload:p,publish:p&&i},_=["plan","clean","letter","export","upload","publish"],b=_.findIndex(H=>!x[H]),v=H=>s.needClean>0?vo(H,s.needClean):"no image cuts",S={plan:vo(s.total,s.total),clean:v(s.withClean),letter:vo(s.withText,s.total),export:vo(s.exported,s.total),upload:vo(s.uploaded,s.total),publish:null},N=_.map((H,z)=>({key:H,label:UD[H],status:b===-1||z<b?"done":z===b?"current":"todo",detail:S[H]})),E=b===-1?"Published — this episode is live on PlotLink.":{plan:"Plan the episode's cuts to begin.",clean:"Create a clean image for each cut — artwork only, no text or bubbles.",letter:"Open each cut in the lettering editor and place its speech bubbles and captions.",export:"Export the lettered final image for each cut.",upload:"Upload the exported final images so they're ready to publish.",publish:"Preview the episode, then publish to PlotLink."}[_[b]];return{steps:N,nextStep:E}}const $D="This is your story outline — not publishable. Ask AI to write the genesis next.";function FD(e){const{fileName:t,contentType:i,hasGenesis:s,isPublished:a,cutCount:o,cutProgress:c}=e,h=t==="structure.md",p=t==="genesis.md",d=/^plot-\d+\.md$/.test(t);if(h)return i!=="cartoon"?$D:s?"Your story outline is set. Genesis (Episode 1) already exists — review its opening and cuts; you don't need to write the Genesis again.":"This is your story outline — not publishable. Write the Genesis opening (Episode 1) next.";if(i==="cartoon"&&!a&&(p||d)&&o!==null){if(o===0)return p?"Genesis is your Episode 1 opening. Plan its cuts, then generate clean images for them.":"This episode hasn't been started — expand its cut plan before preparing it for publish.";if(p&&c){const x=c;if(x.withClean<x.needClean)return"Genesis has a cut plan — generate the clean images for its cuts next.";if(x.withText<x.total)return"Genesis clean art is ready — review the cuts and add speech bubbles & captions next.";if(x.exported<x.total)return"Genesis lettering is underway — export the final images next.";if(x.uploaded<x.total)return"Genesis final images are exported — upload them next, then prepare to publish."}}return null}function Cm(e){var _;const{checklist:t,markdownReady:i=!1,published:s=!1}=e;if(!t||t.steps.length===0)return null;const a=((_=t.steps.find(b=>b.key==="upload"))==null?void 0:_.status)==="done",o=a&&i&&!s,c=s||i?"done":a?"current":"todo",h=s?"done":o?"current":"todo",p=[...t.steps.filter(b=>b.key!=="publish"),{key:"assemble",label:"Episode sequence prepared",status:c,detail:null},{key:"ready",label:s?"Published to PlotLink":"Ready to publish",status:h,detail:null}],d=p.find(b=>b.status==="current")??p.find(b=>b.status==="todo")??p[p.length-1]??null,x=p.filter(b=>b.status==="done").length;return{steps:p,activeStep:d,statusLabel:(d==null?void 0:d.label)??null,completedCount:x,totalCount:p.length,outstandingCount:p.filter(b=>b.status!=="done").length}}const qD={done:"✓",current:"▸",todo:"○"};function JS({checklist:e,markdownReady:t=!1,published:i=!1,issues:s=[],title:a="Episode production",subtitle:o,action:c,rootTestId:h="cartoon-production-status",detailsTestId:p="cartoon-production-details",stepTestIdPrefix:d="cartoon-production-step",issuesTestId:x,issueGroupTestIdPrefix:_,detailsLabel:b,summaryTestId:v}){var R;const S=Cm({checklist:e,markdownReady:t,published:i});if(!S)return null;const N=ZS(s),M=N.reduce((te,L)=>te+L.lines.length,0),E=S.statusLabel??"Review cuts",H=`${S.completedCount} / ${S.totalCount} steps done`,z=b??(S.outstandingCount===0?"Production details":`${S.outstandingCount} step${S.outstandingCount===1?"":"s"} left`);return f.jsxs("div",{className:"rounded-lg border border-border bg-background/80 px-3 py-2","data-testid":h,children:[f.jsxs("div",{className:"flex flex-wrap items-start gap-2 justify-between",children:[f.jsxs("div",{className:"min-w-0 space-y-1",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px]",children:[f.jsx("span",{className:"font-medium text-foreground",children:a}),f.jsxs("span",{className:"rounded-full border border-accent/30 bg-accent/10 px-2 py-0.5 font-medium text-accent","data-testid":v,children:["Active: ",E]}),f.jsx("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-muted",children:H}),((R=S.activeStep)==null?void 0:R.detail)&&f.jsx("span",{className:"text-muted",children:S.activeStep.detail})]}),o?f.jsx("div",{className:"text-[10px] text-muted",children:o}):null]}),c?f.jsx("div",{className:"flex-shrink-0",children:c}):null]}),f.jsxs("details",{className:"mt-2","data-testid":p,children:[f.jsxs("summary",{className:"cursor-pointer select-none text-[10px] text-muted hover:text-foreground",children:[z,M>0?` · ${M} blocker${M===1?"":"s"}`:""]}),f.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[f.jsx("ol",{className:"flex flex-wrap gap-1.5",children:S.steps.map(te=>f.jsxs("li",{"data-testid":`${d}-${te.key}`,"data-status":te.status,className:`flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${te.status==="current"?"border-accent/40 bg-accent/10 text-accent":te.status==="done"?"border-border bg-background/70 text-foreground":"border-border/70 bg-background/40 text-muted"}`,children:[f.jsx("span",{"aria-hidden":!0,children:qD[te.status]}),f.jsx("span",{children:te.label}),te.detail&&f.jsxs("span",{className:"text-muted",children:["· ",te.detail]})]},te.key))}),N.length>0&&f.jsx("div",{className:"space-y-1.5","data-testid":x??`${d}-issues`,children:N.map(te=>f.jsxs("div",{"data-testid":`${_??`${d}-issue-group`}-${te.key}`,className:"text-[10px]",children:[f.jsx("p",{className:"font-medium text-amber-700",children:te.title}),f.jsx("ul",{className:"ml-3 list-disc text-muted",children:te.lines.map((L,I)=>f.jsx("li",{children:L},I))})]},te.key))})]})]})]})}function WD({checklist:e,issues:t,onFinish:i,finishing:s,progressText:a,canFinish:o,markdownReady:c=!1,published:h=!1}){if(!e||e.steps.length===0)return null;const p=s?a||"Finishing…":h?"Published ✓":c?"Episode ready to publish":"Finish episode";return f.jsx(JS,{checklist:e,markdownReady:c,published:h,issues:t,title:"Episode production",subtitle:"Per-cut actions stay on each card. Open details for the full workflow and blockers.",rootTestId:"finish-episode-panel",detailsTestId:"finish-episode-details",stepTestIdPrefix:"finish-step",issuesTestId:"finish-issues",issueGroupTestIdPrefix:"finish-issue-group",action:f.jsx("button",{onClick:i,disabled:s||!o,"data-testid":"finish-episode-btn",title:"Upload the exported final panels, then prepare the episode for publishing — picks up where it left off",className:"px-2.5 py-1 text-[11px] border border-accent/40 text-accent rounded hover:bg-accent/5 disabled:opacity-50",children:p})})}function e1(e){return{planned:e.filter(t=>t.state==="planned").length,needsConversion:e.filter(t=>t.state==="needs-conversion").length,missing:e.filter(t=>t.state==="missing").length,cleanReady:e.filter(t=>t.state==="clean-ready").length,finalReady:e.filter(t=>t.state==="final-ready").length,uploaded:e.filter(t=>t.state==="uploaded").length}}function Mo(e){return(!!e.cleanImagePath||vn(e))&&ym(e).length>0}function my(e){const t=new Date().toISOString();return{status:"generated",baseSig:pa(e),generatedAt:t,updatedAt:t}}function t1(e){return e.uploadedCid?"uploaded":e.finalImagePath||e.exportedAt?"lettered":e.cleanImagePath?"clean":vn(e)?"text":"missing"}const gy={muted:"text-muted",amber:"text-amber-700",green:"text-green-700",accent:"text-accent"},GD={muted:"bg-muted/40",amber:"bg-amber-500",green:"bg-green-600",accent:"bg-accent"};function YD(e,t,i){var s;return e.uploadedCid||e.uploadedUrl?{key:"uploaded",label:"Uploaded",tone:"green"}:t?{key:"convert",label:"Needs conversion",tone:"amber"}:i?e.finalImagePath?{key:"review",label:"Needs review",tone:"amber"}:{key:"needs-image",label:"Needs image",tone:"muted"}:e.finalImagePath?{key:"exported",label:"Exported",tone:"green"}:vn(e)?{key:"text",label:"Ready for captions",tone:"accent"}:e.cleanImagePath?(((s=e.overlays)==null?void 0:s.length)??0)>0?{key:"review",label:"Needs review",tone:"amber"}:{key:"letter",label:"Ready for lettering",tone:"green"}:{key:"needs-image",label:"Needs image",tone:"muted"}}function KD(e){var t,i;return e.uploadedCid||e.uploadedUrl?{label:"Complete",detail:"Final image uploaded",tone:"green"}:e.finalImagePath||e.exportedAt?{label:"Exported",detail:"Ready to upload",tone:"green"}:(((t=e.overlays)==null?void 0:t.length)??0)>0?((i=e.aiDraft)==null?void 0:i.status)==="generated"?{label:"Draft ready",detail:`${e.overlays.length} AI-drafted overlay${e.overlays.length===1?"":"s"} ready to review`,tone:"amber"}:{label:"User-edited",detail:`${e.overlays.length} overlay${e.overlays.length===1?"":"s"} adjusted and ready to review`,tone:"amber"}:Mo(e)?{label:"No draft",detail:"Draft with AI or place bubbles manually",tone:"muted"}:vn(e)?{label:"Between-scene card",detail:"Open to add narration or title text",tone:"accent"}:e.cleanImagePath?{label:"Unlettered",detail:"Clean art ready for bubble placement",tone:"muted"}:{label:"Needs artwork",detail:"Add or sync clean art first",tone:"muted"}}function VD({cut:e,storyName:t,plotFile:i,language:s,expanded:a,onToggle:o,authFetch:c,onUpdated:h,onOpenEditor:p,detectedLocalClean:d,onSyncClean:x,syncing:_,onAiDraft:b,aiDrafting:v,staleMessages:S,onRepairStale:N,repairing:M,conversionPng:E,onConvert:H,converting:z,rowRef:R,featured:te=!1}){var ft,tt;const L=w.useRef(null),[I,re]=w.useState(!1),[_e,j]=w.useState(null),[J,F]=w.useState(!1),[G,Y]=w.useState(!1),[U,A]=w.useState(!1),[q,$]=w.useState(!1),be=t1(e),T=S.length>0,D=!!E,V=w.useCallback(async()=>{E&&($(!0),await H(e.id,E),$(!1),h())},[E,H,e.id,h]),k=w.useCallback(async Fe=>{re(!0),j(null);try{let ze=Fe;if(!KS(Fe))try{ze=await Yu(Fe)}catch(ki){return j(ki instanceof Error?ki.message:"Could not import image"),!1}const qe=ze.type==="image/jpeg"?"jpg":"webp",Gt=new FormData;Gt.append("file",new File([ze],`clean.${qe}`,{type:ze.type}));const wt=await c(`/api/stories/${t}/cuts/${i}/upload-clean/${e.id}`,{method:"POST",body:Gt});if(!wt.ok){const ki=await wt.json();return j(ki.error||"Upload failed"),!1}return h(),!0}catch{return j("Upload failed"),!1}finally{re(!1)}},[c,t,i,e.id,h]),le=YD(e,D,T),ne=e.cleanImagePath??E??null,de=((ft=e.overlays)==null?void 0:ft.length)??0,X=!vn(e)&&!!e.cleanImagePath&&!e.finalImagePath&&!e.uploadedCid&&!e.uploadedUrl&&!T&&!D,ue=!T&&!D&&!e.finalImagePath&&!e.uploadedCid&&!e.uploadedUrl&&Mo(e),ye=(((tt=e.overlays)==null?void 0:tt.length)??0)>0?"Re-draft bubbles with AI":"AI draft bubbles",fe=le.key==="convert"?{label:q?"Converting…":"Convert image",onClick:V,testid:`card-convert-${e.id}`}:le.key==="review"?{label:"Review cut",onClick:p,testid:`card-review-${e.id}`}:le.key==="text"?{label:"Add captions",onClick:p,testid:`card-letter-${e.id}`}:le.key==="needs-image"?{label:"Add artwork",onClick:o,testid:`card-addart-${e.id}`}:null,Pe=KD(e),$e=!!e.cleanImagePath||!!e.narration||e.dialogue.length>0||vn(e),Oe=te?"w-full rounded border border-border bg-white min-h-[14rem] md:min-h-[18rem] xl:min-h-[21rem]":"w-full rounded border border-border bg-white min-h-[11rem] md:min-h-[13rem]",Ke=f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[X?f.jsxs(f.Fragment,{children:[f.jsx("button",{onClick:p,"data-testid":`add-bubbles-${e.id}`,className:"px-2.5 py-1 text-[11px] font-medium rounded bg-accent text-white hover:bg-accent-dim",children:de>0?"Review lettering":"Open focused editor"}),ue&&f.jsx("button",{onClick:b,disabled:v,"data-testid":`ai-draft-${e.id}`,className:"px-2.5 py-1 text-[11px] rounded border border-accent/40 text-accent hover:bg-accent/5 disabled:opacity-50",children:v?"Drafting…":ye})]}):fe?f.jsx("button",{onClick:fe.onClick,disabled:le.key==="convert"&&(q||z),"data-testid":fe.testid,className:"px-2.5 py-1 text-[11px] font-medium rounded bg-accent text-white hover:bg-accent-dim disabled:opacity-50",children:fe.label}):null,!X&&!fe&&ue&&f.jsx("button",{onClick:b,disabled:v,"data-testid":`ai-draft-${e.id}`,className:"px-2.5 py-1 text-[11px] rounded border border-accent/40 text-accent hover:bg-accent/5 disabled:opacity-50",children:v?"Drafting…":ye}),f.jsx("button",{onClick:o,"data-testid":`cut-details-${e.id}`,className:"px-2.5 py-1 text-[11px] rounded border border-border text-muted hover:border-accent hover:text-accent",children:a?"Hide details":"Open details"})]});return f.jsxs("div",{ref:R,"data-cut-row":e.id,className:`border rounded ${a?"border-accent/30":"border-border"}`,children:[f.jsxs("div",{className:"px-3 py-2 space-y-2","data-testid":`cut-card-${e.id}`,children:[f.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[f.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${GD[le.tone]}`}),f.jsxs("span",{className:"font-medium text-xs text-foreground",children:["Cut ",String(e.id).padStart(2,"0")]}),f.jsxs("span",{className:"font-mono text-[10px] text-muted",children:["· ",e.shotType]}),f.jsx("span",{className:`ml-auto text-[10px] font-medium flex-shrink-0 ${gy[le.tone]}`,"data-testid":`cut-card-status-${e.id}`,children:le.label})]}),Ke,ne||vn(e)?f.jsx(cD,{storyName:t,assetPath:ne,authFetch:c,alt:`Cut ${e.id} artwork`,overlays:e.overlays,language:s,background:e.background,aspectRatio:e.aspectRatio,onClick:$e?p:void 0,className:Oe,testId:`cut-preview-${e.id}`}):f.jsx("div",{className:`${te?"min-h-[14rem] md:min-h-[18rem] xl:min-h-[21rem]":"min-h-28 md:min-h-40"} w-full rounded border border-dashed border-border bg-surface/40 flex items-center justify-center text-[10px] text-muted`,"data-testid":`cut-card-noart-${e.id}`,children:vn(e)?"Text panel — no artwork needed":"No artwork yet"}),f.jsxs("div",{className:`rounded border border-border/70 bg-surface/50 px-2 py-1.5 text-[11px] ${gy[Pe.tone]}`,"data-testid":`lettering-review-state-${e.id}`,children:[f.jsx("span",{className:"font-semibold",children:Pe.label}),f.jsxs("span",{className:"text-muted",children:[" · ",Pe.detail]})]}),f.jsx("button",{onClick:o,"data-testid":`cut-desc-${e.id}`,className:"block w-full text-left text-[11px] text-muted hover:text-foreground",children:e.description||"No description"})]}),a&&f.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-border",children:[D&&f.jsxs("div",{className:"mt-2 rounded border border-amber-500/40 bg-amber-500/10 p-2 space-y-1","data-testid":`needs-conversion-${e.id}`,children:[f.jsx("p",{className:"text-[11px] text-amber-800",children:"This cut’s artwork is a PNG. Convert it to WebP so it can be lettered and published."}),f.jsx("button",{onClick:V,disabled:q||z,"data-testid":`convert-cut-${e.id}`,className:"px-2 py-1 text-[11px] border border-amber-500/50 text-amber-800 rounded hover:bg-amber-500/20 disabled:opacity-50",children:q?"Converting…":"Convert image"})]}),T&&!D&&f.jsxs("div",{className:"mt-2 rounded border border-error/40 bg-error/5 p-2 space-y-1","data-testid":`stale-asset-${e.id}`,children:[S.map((Fe,ze)=>f.jsx("p",{className:"text-[11px] text-error",children:Fe},ze)),f.jsx("button",{onClick:N,disabled:M,"data-testid":`repair-stale-${e.id}`,className:"px-2 py-1 text-[11px] border border-error/40 text-error rounded hover:bg-error/10 disabled:opacity-50",children:M?"Repairing…":"Clear stale path"})]}),!vn(e)&&f.jsxs("div",{className:"mt-2 space-y-2",children:[f.jsx("button",{onClick:()=>{navigator.clipboard.writeText(fy(e,i)),F(!0),setTimeout(()=>F(!1),2e3)},"data-testid":`copy-prompt-${e.id}`,className:"px-3 py-1.5 text-xs border border-border rounded hover:border-accent hover:bg-accent/5",children:J?"Copied!":"Copy Codex task"}),f.jsx("input",{ref:L,type:"file",accept:"image/webp,image/jpeg,image/png",className:"hidden",onChange:Fe=>{var qe;const ze=(qe=Fe.target.files)==null?void 0:qe[0];ze&&k(ze),Fe.target.value=""}}),f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsx("button",{onClick:()=>{var Fe;return(Fe=L.current)==null?void 0:Fe.click()},disabled:I,className:"px-3 py-1.5 text-xs border border-border rounded hover:border-accent hover:bg-accent/5 disabled:opacity-50",children:I?"Uploading...":e.cleanImagePath?"Replace clean image":"Upload clean image"}),f.jsx("button",{onClick:()=>A(Fe=>!Fe),disabled:I,"data-testid":`import-codex-${e.id}`,className:"px-3 py-1.5 text-xs border border-border rounded hover:border-accent hover:bg-accent/5 disabled:opacity-50",children:U?"Hide Codex images":"Import from Codex"})]}),U&&f.jsx(MD,{authFetch:c,cutId:e.id,onImport:async Fe=>{await k(Fe)&&A(!1)},onClose:()=>A(!1)}),!e.cleanImagePath&&f.jsx("p",{className:"text-xs text-muted","data-testid":`clean-image-handoff-${e.id}`,children:"Generate this cut in Codex, then import the cached PNG with “Import from Codex” — or upload an image manually. Letter it next."}),be==="missing"&&f.jsxs("div",{className:"rounded border border-border bg-surface/60 p-2 space-y-1","data-testid":`ask-codex-${e.id}`,children:[f.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Generate this cut in Codex"}),f.jsxs("p",{className:"text-[10px] text-muted",children:["Copy the task below and paste it into Codex. Codex usually saves a PNG to its image cache — bring it into this cut with “Import from Codex” above (the PNG becomes a WebP automatically). If Codex instead writes a WebP/JPEG at"," ",f.jsxs("span",{className:"font-mono",children:["assets/",i,"/cut-",String(e.id).padStart(2,"0"),"-clean.webp"]}),", it’s picked up by “Sync clean images”."]}),f.jsx("button",{onClick:()=>{navigator.clipboard.writeText(fy(e,i)),Y(!0),setTimeout(()=>Y(!1),2e3)},"data-testid":`ask-codex-copy-${e.id}`,className:"px-2 py-1 text-[11px] border border-border rounded hover:border-accent hover:bg-accent/5",children:G?"Copied!":"Copy Codex task"})]}),be==="missing"&&d&&f.jsx("button",{onClick:x,disabled:_,"data-testid":`found-local-clean-${e.id}`,className:"px-3 py-1.5 text-xs border border-green-700/40 text-green-700 rounded hover:bg-green-700/5 disabled:opacity-50",children:_?"Syncing...":"Found local clean image — sync to cut plan"}),_e&&f.jsx("p",{className:"text-xs text-error mt-1",children:_e})]}),(e.cleanImagePath||e.narration||e.dialogue.length>0||vn(e))&&f.jsx("button",{onClick:p,"data-testid":`open-editor-${e.id}`,className:"px-3 py-1.5 text-xs border border-accent/30 text-accent rounded hover:bg-accent/5",children:"Open editor"}),e.characters.length>0&&f.jsxs("p",{className:"text-xs text-muted",children:["Characters: ",e.characters.join(", ")]}),e.dialogue.length>0&&f.jsx("div",{className:"text-xs text-muted",children:e.dialogue.map((Fe,ze)=>f.jsxs("p",{children:[f.jsxs("span",{className:"font-medium",children:[Fe.speaker,":"]})," ",Fe.text]},ze))}),e.narration&&f.jsx("p",{className:"text-xs text-muted italic",children:e.narration})]})]})}function _y({storyName:e,fileName:t,authFetch:i,language:s,uploadRetry:a,onCutsChanged:o,focusRequest:c,onFocusHandled:h,onFocusedLetteringModeChange:p,workspaceVisible:d=!1,onWorkspaceVisibleChange:x,mode:_="preview",onExitFocusedEditor:b,compactEpisodeChrome:v=!1}){var st,at,Bt;const[S,N]=w.useState(null),M=w.useRef(o);M.current=o;const E=w.useRef(h);E.current=h;const[H,z]=w.useState(!0),[R,te]=w.useState(null),[L,I]=w.useState(null),[re,_e]=w.useState(null),j=w.useRef(!1),[J,F]=w.useState(!1),[G,Y]=w.useState([]),[U,A]=w.useState(!1),[q,$]=w.useState(""),[be,T]=w.useState({markdownReady:!1,published:!1}),[D,V]=w.useState(!1),[k,le]=w.useState(!1),[ne,de]=w.useState(!1),[X,ue]=w.useState(null),[ye,fe]=w.useState(null),[Pe,$e]=w.useState(null),[Oe,Ke]=w.useState(!1),[ft,tt]=w.useState(new Set),[Fe,ze]=w.useState(new Map),[qe,Gt]=w.useState(!1),[wt,ki]=w.useState(null),[Ei,yt]=w.useState(!1),[Li,oe]=w.useState(null),se=w.useRef(new Map),Ie=w.useRef(null),je=t.replace(/\.md$/,"");w.useEffect(()=>{var K;c&&Ie.current!==c.seq&&(Ie.current=c.seq,c.openEditor?_e(c.cutId):(I(c.cutId),oe(c.cutId)),(K=E.current)==null||K.call(E))},[c]),w.useEffect(()=>(p==null||p(re!==null),()=>p==null?void 0:p(!1)),[re,p]),w.useEffect(()=>{if(_!=="edit"){j.current=!1;return}if(j.current||re!==null||!(S!=null&&S.cuts.length))return;const K=S.cuts.find(xe=>xe.cleanImagePath||xe.narration||xe.dialogue.length>0||vn(xe))??S.cuts[0];j.current=!0,_e(K.id)},[_,re,S]),w.useEffect(()=>{var xe;if(Li==null)return;const K=se.current.get(Li);K&&((xe=K.scrollIntoView)==null||xe.call(K,{behavior:"smooth",block:"center"}),oe(null))},[Li,S]);const De=w.useCallback(async()=>{var K;try{const xe=await i(`/api/stories/${e}/cuts/${je}`);if(xe.status===404){N(null);return}if(!xe.ok){const Be=await xe.json();te(Be.error||"Failed to load cuts");return}const ve=await xe.json(),Ce={...ve,version:typeof(ve==null?void 0:ve.version)=="number"?ve.version:1,plotFile:typeof(ve==null?void 0:ve.plotFile)=="string"?ve.plotFile:je,cuts:Array.isArray(ve==null?void 0:ve.cuts)?ve.cuts:[]};N(Ce),te(null);try{const Be=await i(`/api/stories/${e}/${t}`);if(Be.ok){const He=await Be.json(),dt=typeof(He==null?void 0:He.content)=="string"?He.content:"",Lt=Ce.cuts,gn=dt.length>0&&VS(dt,Lt).ready,on=(He==null?void 0:He.status)==="published"||(He==null?void 0:He.status)==="published-not-indexed";T({markdownReady:gn,published:on})}else T({markdownReady:!1,published:!1})}catch{T({markdownReady:!1,published:!1})}(K=M.current)==null||K.call(M)}catch{te("Failed to load cuts")}finally{z(!1)}},[i,e,je,t]),Ct=w.useCallback(async K=>!!(await i(`/api/stories/${e}/cuts/${je}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(K)})).ok,[i,e,je]),_t=w.useCallback(async()=>{Gt(!1);try{const K=await i(`/api/stories/${e}/cuts/${je}/detect-clean-images`);if(!K.ok)return;const xe=await K.json();tt(new Set(Array.isArray(xe.detected)?xe.detected:[]));const ve=new Map,Ce=xe.stale;if(Array.isArray(Ce))for(const Be of Ce){if(typeof(Be==null?void 0:Be.cutId)!="number"||typeof(Be==null?void 0:Be.message)!="string")continue;const He=ve.get(Be.cutId)??[];He.push(Be.message),ve.set(Be.cutId,He)}ze(ve),Gt(!0)}catch{}},[i,e,je]),nt=w.useCallback(async()=>{ki(null);try{const K=await i(`/api/stories/${e}/cuts/${je}/asset-diagnostics`);if(!K.ok)return;const xe=await K.json();ki(Array.isArray(xe.diagnostics)?xe.diagnostics:null)}catch{}},[i,e,je]),xt=w.useCallback(async()=>{yt(!0);try{await Promise.all([De(),_t(),nt()])}finally{yt(!1)}},[De,_t,nt]),Tt=w.useCallback(async(K,xe={})=>{var Be;if(!S)return!1;const ve=S.cuts.find(He=>He.id===K);if(!ve||!Mo(ve)||(((Be=ve.overlays)==null?void 0:Be.length)??0)>0&&!window.confirm("This cut already has overlays. Re-drafting with AI will replace the current draft overlays for this cut. Continue?"))return!1;const Ce=ly(ve);if(Ce.length===0)return fe(`Cut ${ve.id}: no script lines available to draft.`),!1;$e(K),fe(null);try{const He={...S,cuts:S.cuts.map(Lt=>Lt.id===K?{...Lt,overlays:Ce,aiDraft:my(Ce)}:Lt)};return await Ct(He)?(fe(`Cut ${ve.id}: AI draft ready`),await De(),xe.openEditor&&_e(K),!0):(fe(`Cut ${ve.id}: AI draft failed`),!1)}finally{$e(null)}},[S,Ct,De]),ct=w.useCallback(async()=>{if(!S)return;const K=S.cuts.filter(xe=>{var ve;return Mo(xe)&&(((ve=xe.overlays)==null?void 0:ve.length)??0)===0&&!xe.finalImagePath&&!xe.uploadedCid&&!xe.uploadedUrl});if(K.length===0){fe("No unlettered cuts need an AI draft");return}Ke(!0),fe(null);try{const xe={...S,cuts:S.cuts.map(Ce=>{if(!K.some(He=>He.id===Ce.id))return Ce;const Be=ly(Ce);return Be.length>0?{...Ce,overlays:Be,aiDraft:my(Be)}:Ce})};if(!await Ct(xe)){fe("AI draft failed");return}fe(`AI draft ready for ${K.length} cut${K.length===1?"":"s"}`),await De()}finally{Ke(!1)}},[S,Ct,De]),ui=w.useCallback(async()=>{V(!0),fe(null),Y([]);try{const K=await i(`/api/stories/${e}/cuts/${je}/sync-clean-images`,{method:"POST"}),xe=await K.json().catch(()=>({}));if(!K.ok)fe(xe.error||"Sync failed");else{const ve=Array.isArray(xe.synced)?xe.synced.length:0,Ce=Array.isArray(xe.cleared)?xe.cleared.length:0,Be=Array.isArray(xe.rejected)?xe.rejected:[];Be.length>0&&Y(Be.map(dt=>`Cut ${dt.cutId}: ${dt.reason}`));const He=[];ve>0&&He.push(`Synced ${ve}`),Ce>0&&He.push(`Cleared ${Ce} stale path${Ce===1?"":"s"}`),fe(He.length>0?He.join(", "):"No new clean images"),await De(),await _t(),await nt()}}catch{fe("Sync failed")}V(!1)},[i,e,je,De,_t,nt]),ei=w.useCallback(async(K,xe)=>{try{const ve=await i(qS(e,xe));if(!ve.ok)return!1;const Ce=await ve.blob(),Be=await Yu(new File([Ce],"clean.png",{type:Ce.type||"image/png"})),He=Be.type==="image/jpeg"?"jpg":"webp",dt=new FormData;return dt.append("file",new File([Be],`clean.${He}`,{type:Be.type})),(await i(`/api/stories/${e}/cuts/${je}/upload-clean/${K}`,{method:"POST",body:dt})).ok}catch{return!1}},[i,e,je]),Kn=w.useCallback(async K=>{de(!0),ue(null);let xe=0;const ve=[];for(const Ce of K)await ei(Ce.cutId,Ce.pngPath)?xe++:ve.push(Ce.cutId);await xt(),de(!1),ue(ve.length===0?`Converted ${xe} image${xe===1?"":"s"} to WebP`:`Converted ${xe}; ${ve.length} failed (Cut ${ve.join(", ")}) — try Convert image on each`)},[ei,xt]),mn=w.useCallback(async()=>{var Be;if(!S)return;A(!0),$(""),Y([]);const K=S.cuts.filter(He=>He.finalImagePath&&!He.uploadedCid),xe=[],ve=SD({sleep:a==null?void 0:a.sleep,onWaiting:({waitMs:He})=>$(`Upload limit reached — waiting ${Math.round(He/1e3)}s before continuing…`)});for(let He=0;He<K.length;He++){const dt=K[He];$(`Uploading cut ${dt.id} (${He+1}/${K.length})...`);try{const Lt=dt.finalImagePath.startsWith("assets/")?dt.finalImagePath.slice(7):dt.finalImagePath,gn=await i(`/api/stories/${e}/asset/${Lt}`);if(!gn.ok){xe.push(`Cut ${dt.id}: failed to fetch asset`);continue}const on=await gn.blob(),Vn=new FormData;Vn.append("file",on,`cut-${dt.id}.${on.type==="image/webp"?"webp":"jpg"}`),await ve();const br=await yD(async()=>{const Ut=await i("/api/publish/upload-plot-image",{method:"POST",body:Vn});if(Ut.ok){const{cid:vr,url:zt}=await Ut.json();return{ok:!0,status:Ut.status,cid:vr,url:zt}}const Cn=await Ut.json().catch(()=>({}));return{ok:!1,status:Ut.status,errorMessage:Cn.error}},{...a,onWaiting:({attempt:Ut,maxRetries:Cn,waitMs:vr})=>$(`Cut ${dt.id} rate-limited — waiting ${Math.round(vr/1e3)}s before retry ${Ut}/${Cn}...`)});if(!br.ok){xe.push(`Cut ${dt.id}: upload failed — ${br.errorMessage||"unknown"}`);continue}const{cid:Xn,url:Yt}=br;(await i(`/api/stories/${e}/cuts/${je}/set-uploaded/${dt.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cid:Xn,url:Yt})})).ok||xe.push(`Cut ${dt.id}: failed to record upload`)}catch(Lt){xe.push(`Cut ${dt.id}: ${Lt instanceof Error?Lt.message:"failed"}`)}}if(xe.length>0){Y(xe),A(!1),$(""),De();return}$("Preparing episode for publishing…");const Ce=await i(`/api/stories/${e}/cuts/${je}/generate-markdown`,{method:"POST"});if(Ce.ok){const He=await Ce.json();((Be=He.warnings)==null?void 0:Be.length)>0&&Y(He.warnings)}A(!1),$(""),De()},[S,i,e,je,a,De]),_i=w.useCallback(async()=>{le(!0),fe(null);try{const K=await i(`/api/stories/${e}/cuts/${je}/repair-asset-paths`,{method:"POST"}),xe=await K.json().catch(()=>({}));if(!K.ok)fe(xe.error||"Repair failed");else{const ve=Array.isArray(xe.cleared)?xe.cleared.length:0;fe(ve>0?`Cleared ${ve} stale path${ve===1?"":"s"}`:"No stale paths to clear"),await De(),await _t()}}catch{fe("Repair failed")}le(!1)},[i,e,je,De,_t]),[xi,Ht]=w.useState(!1),ln=w.useCallback(async(K,xe=!0)=>{if(S){Ht(!0);try{const ve=S.cuts.reduce((Lt,gn)=>Math.max(Lt,gn.id),0)+1,Ce={id:ve,shotType:"wide",description:"Text panel",characters:[],dialogue:[],narration:"",sfx:"",cleanImagePath:null,finalImagePath:null,exportedAt:null,uploadedCid:null,uploadedUrl:null,overlays:[],kind:"text",background:"#101820",aspectRatio:"4:5"},Be=[...S.cuts];Be.splice(Math.max(0,Math.min(K,Be.length)),0,Ce);const He={...S,cuts:Be},dt=await i(`/api/stories/${e}/cuts/${je}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(He)});if(dt.ok)xe?_e(ve):I(ve),await De();else{const Lt=await dt.json().catch(()=>({}));fe(Lt.error||"Could not add text panel")}}catch{fe("Could not add text panel")}Ht(!1)}},[S,i,e,je,De]),Ui=w.useCallback(()=>ln((S==null?void 0:S.cuts.length)??0,!0),[ln,S]);if(w.useEffect(()=>{De(),_t(),nt()},[De,_t,nt]),H)return f.jsx("div",{className:"p-4 text-sm text-muted",children:"Loading cuts..."});if(R)return f.jsxs("div",{className:"p-4 space-y-2","data-testid":"cuts-error",children:[f.jsx("p",{className:"text-sm text-error font-medium",children:"Invalid cuts file"}),f.jsx("p",{className:"text-xs text-error",children:R}),f.jsxs("p",{className:"text-xs text-muted",children:[je,".cuts.json must follow the OWS v1 schema. Ask Claude to regenerate it using the v1 cuts schema from the cartoon writing instructions."]}),f.jsx("button",{onClick:De,className:"text-xs text-accent hover:text-accent-dim",children:"Retry"})]});if(!S||S.cuts.length===0)return f.jsxs("div",{className:"p-4 text-center space-y-1",children:[f.jsx("p",{className:"text-sm text-muted",children:"No cuts yet"}),f.jsx("p",{className:"text-xs text-muted",children:"Ask Claude to create a cut plan for this episode."})]});const O=re!==null?S.cuts.find(K=>K.id===re):null,we=re!==null?S.cuts.findIndex(K=>K.id===re):-1;if(O)return f.jsx(oD,{storyName:e,cut:O,plotFile:je,language:s,authFetch:i,targetLabel:vn(O)?`Between-scene card ${O.id}`:`Cut ${String(O.id).padStart(2,"0")}`,returnOnSave:!0,workspaceVisible:d,onToggleWorkspaceVisible:x?()=>x(!d):void 0,onSave:async(K,xe)=>{const ve={...S,cuts:S.cuts.map(Be=>Be.id===re?{...Be,overlays:K,aiDraft:xe??Be.aiDraft??null}:Be)};if(!await Ct(ve))throw new Error("Failed to save overlays")},onExported:()=>De(),hasPreviousCut:we>0,hasNextCut:we>=0&&we<S.cuts.length-1,onPreviousCut:()=>{const K=S.cuts[we-1];K&&_e(K.id)},onNextCut:()=>{const K=S.cuts[we+1];K&&_e(K.id)},onClose:()=>{_e(null),b==null||b(),De()}});const Me=S.cuts.reduce((K,xe)=>{const ve=t1(xe);return K[ve]++,K},{missing:0,clean:0,lettered:0,uploaded:0,text:0}),Te=S.cuts.filter(K=>!vn(K)).length,Ze=S.cuts.filter(K=>$S(K)).map(K=>K.id),Qe=QS({cuts:S.cuts,published:be.published}),Nt=((st=Qe.steps.find(K=>K.key==="upload"))==null?void 0:st.status)==="done",kt=S.cuts.some(K=>K.finalImagePath&&!K.uploadedCid)||Nt&&!be.markdownReady,Rt=ZD(Qe,be.markdownReady,be.published),Je=(wt??[]).filter(K=>K.state==="needs-conversion"&&K.convertiblePng).map(K=>({cutId:K.cutId,pngPath:K.convertiblePng})),hi=new Map(Je.map(K=>[K.cutId,K.pngPath])),bi=(wt??[]).filter(K=>K.state==="needs-conversion"&&K.issue).map(K=>K.issue),vi=t==="genesis.md"?"Genesis / Episode 1":`Episode ${parseInt(((at=je.match(/\d+/))==null?void 0:at[0])??"0",10)+1}`,Ot=typeof S.title=="string"?S.title:null,si=S.cuts.filter(K=>!vn(K)),Zt={cuts:S.cuts.length,artwork:si.filter(K=>K.cleanImagePath||hi.has(K.id)).length,converted:si.filter(K=>K.cleanImagePath&&/\.(webp|jpe?g)$/i.test(K.cleanImagePath)).length,lettered:S.cuts.filter(K=>{var xe;return(((xe=K.overlays)==null?void 0:xe.length)??0)>0||!!K.finalImagePath}).length,uploaded:S.cuts.filter(K=>K.uploadedCid||K.uploadedUrl).length},he=S.cuts.filter(K=>{var xe;return Mo(K)&&(((xe=K.overlays)==null?void 0:xe.length)??0)===0&&!K.finalImagePath&&!K.uploadedCid&&!K.uploadedUrl}).length,Ae=XD(wt),Ge=f.jsxs("div",{className:"rounded border border-border bg-surface/45 px-3 py-2 text-xs text-muted","data-testid":"cut-board-end-summary",children:[f.jsxs("span",{className:"font-medium text-foreground",children:[vi,Ot?` · ${Ot}`:""]}),f.jsxs("span",{className:"ml-2",children:[Zt.cuts," cuts · ",Zt.converted," clean ·"," ",Zt.lettered," lettered · ",Zt.uploaded," uploaded"]})]}),Dt=f.jsxs("details",{className:"border-b border-border bg-surface/35 flex-shrink-0","data-testid":"cut-workspace-tools",children:[f.jsx("summary",{className:"list-none cursor-pointer px-3 py-1 hover:bg-surface/50",children:f.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[f.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-[10px]",children:[f.jsxs("span",{className:"rounded-full border border-accent/30 bg-background px-2 py-0.5 font-medium text-accent",children:["Workflow: ",Rt]}),Ae&&f.jsxs("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-muted","data-testid":"workspace-asset-summary",children:["Assets: ",Ae]}),Je.length>0&&f.jsxs("span",{className:"rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-amber-700",children:["Convert ",Je.length," PNG",Je.length===1?"":"s"]})]}),f.jsx("span",{className:"flex-shrink-0 rounded border border-border bg-background px-2 py-1 text-[10px] text-muted",children:"Workspace tools"})]})}),f.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-3",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[10px]",children:[f.jsxs("span",{className:"font-mono text-muted",children:[S.cuts.length," cuts"]}),Me.missing>0&&f.jsxs("span",{className:"text-muted",children:[Me.missing," missing"]}),Me.clean>0&&f.jsxs("span",{className:"text-green-700",children:[Me.clean," clean"]}),Me.lettered>0&&f.jsxs("span",{className:"text-amber-700",children:[Me.lettered," lettered"]}),Me.uploaded>0&&f.jsxs("span",{className:"text-green-700",children:[Me.uploaded," uploaded"]}),Me.text>0&&f.jsxs("span",{className:"text-accent",children:[Me.text," text ",Me.text===1?"panel":"panels"]}),f.jsx("button",{onClick:async()=>{F(!0),Y([]);try{const K=await i(`/api/stories/${e}/cuts/${je}/generate-markdown`,{method:"POST"});if(K.ok){const xe=await K.json();Y(xe.warnings||[])}}catch{}F(!1)},disabled:J,className:"ml-auto px-2 py-0.5 border border-accent/30 text-accent rounded hover:bg-accent/5 disabled:opacity-50","data-testid":"generate-markdown-btn",title:"Build the publish-ready episode from the uploaded cut images",children:J?"Preparing…":"Prepare episode for publish"}),f.jsx("button",{onClick:Ui,disabled:xi,className:"px-2 py-0.5 border border-accent/30 text-accent rounded hover:bg-accent/5 disabled:opacity-50","data-testid":"add-text-panel-btn",title:"Insert a narration/title card between art panels — a solid card exported as a final image panel, no drawing needed",children:xi?"Adding…":"Add narration/text panel"}),f.jsx("button",{onClick:xt,disabled:Ei,className:"px-2 py-0.5 border border-border text-muted rounded hover:border-accent hover:text-accent disabled:opacity-50","data-testid":"refresh-assets-btn",title:"Re-check the story folder for agent-generated images and report each cut's asset state — read only, nothing is uploaded or published",children:Ei?"Checking…":"Refresh assets"}),f.jsx("button",{onClick:ui,disabled:D,className:"px-2 py-0.5 border border-accent/30 text-accent rounded hover:bg-accent/5 disabled:opacity-50","data-testid":"sync-clean-btn",children:D?"Syncing...":"Sync clean images"}),f.jsx("button",{onClick:mn,disabled:U||!(S!=null&&S.cuts.some(K=>K.finalImagePath&&!K.uploadedCid)),className:"px-2 py-0.5 border border-accent/30 text-accent rounded hover:bg-accent/5 disabled:opacity-50","data-testid":"upload-generate-btn",title:"Upload each cut's final lettered image, then prepare the episode for publishing",children:q||"Upload & Prepare for Publish"})]}),f.jsxs("div",{className:"mt-1 text-[10px] text-muted",children:["Use ",f.jsx("span",{className:"text-accent",children:"Add narration/text panel"})," ","for a narration or title card. It becomes a solid card exported as a final image."]}),Je.length>0&&f.jsxs("div",{className:"rounded border border-amber-500/40 bg-amber-500/10 p-2 text-[11px]","data-testid":"convert-artwork",children:[f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsxs("span",{className:"font-medium text-amber-700","data-testid":"convert-artwork-count",children:[Je.length," PNG image",Je.length===1?"":"s"," found"]}),f.jsx("button",{onClick:()=>Kn(Je),disabled:ne,"data-testid":"convert-all-btn",className:"ml-auto px-2 py-0.5 border border-amber-500/50 text-amber-800 rounded hover:bg-amber-500/20 disabled:opacity-50",children:ne?"Converting…":"Convert all to WebP"})]}),f.jsx("p",{className:"mt-1 text-[10px] text-muted",children:"PNG artwork is fine while drafting. Convert it before lettering/export so PlotLink can publish it safely."}),X&&f.jsx("p",{className:"mt-1 text-[10px] text-muted","data-testid":"convert-result",children:X}),bi.length>0&&f.jsxs("details",{className:"mt-1","data-testid":"convert-technical-details",children:[f.jsx("summary",{className:"text-[10px] text-muted cursor-pointer",children:"Conversion notes"}),f.jsx("ul",{className:"mt-1 ml-3 list-disc text-[10px] text-muted",children:bi.map((K,xe)=>f.jsx("li",{children:K},xe))})]})]}),wt&&wt.length>0&&(()=>{const K=e1(wt),xe=wt.filter(ve=>ve.state==="missing");return f.jsxs("div",{className:"rounded border border-border bg-background p-2 text-[10px]","data-testid":"asset-diagnostics",children:[f.jsxs("span",{className:"text-muted","data-testid":"asset-diag-summary",children:["Assets: ",K.uploaded," uploaded · ",K.finalReady," final ·"," ",K.cleanReady," clean · ",K.planned," planned",K.needsConversion>0?` · ${K.needsConversion} needs conversion`:"",K.missing>0?` · ${K.missing} missing`:""]}),xe.length>0&&f.jsx("ul",{className:"mt-1 ml-3 list-disc text-error","data-testid":"asset-diag-issues",children:xe.map(ve=>f.jsx("li",{children:ve.issue},ve.cutId))})]})})(),f.jsx(WD,{checklist:Qe,issues:G,onFinish:mn,finishing:U,progressText:q,canFinish:kt,markdownReady:be.markdownReady,published:be.published})]})]});return f.jsxs("div",{className:"h-full min-h-[22rem] flex flex-col overflow-hidden","data-testid":"cut-list-panel",children:[!v&&f.jsx("div",{className:"px-3 py-1 border-b border-border flex-shrink-0","data-testid":"cut-board-header",children:f.jsxs("div",{className:"flex items-center gap-3 justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0 text-xs",children:[f.jsx("span",{className:"font-serif text-foreground truncate",children:vi}),Ot&&f.jsxs("span",{className:"text-muted truncate",children:["· ",Ot]}),f.jsxs("span",{className:"text-[10px] text-muted whitespace-nowrap","data-testid":"cut-board-summary",children:[Zt.cuts," cuts · ",Zt.converted," clean ·"," ",Zt.lettered," lettered · ",Zt.uploaded," uploaded"]})]}),he>0&&f.jsx("button",{onClick:ct,disabled:Oe,"data-testid":"ai-draft-all-btn",className:"px-2.5 py-1 text-[11px] rounded border border-accent/40 text-accent hover:bg-accent/5 disabled:opacity-50",children:Oe?"Drafting…":`AI draft all unlettered (${he})`})]})}),!v&&Dt,Ze.length>0&&f.jsxs("div",{className:"px-3 py-1.5 border-b border-amber-500/40 bg-amber-500/10 text-[10px] text-amber-700 flex-shrink-0","data-testid":"stale-bubble-export-warning",children:[Ze.length===1?"Cut":"Cuts"," ",Ze.join(", ")," ",Ze.length===1?"was":"were"," lettered with an older speech-bubble style whose tail can show a visible seam. Re-export"," ",Ze.length===1?"it":"them"," (open lettering → Export) and re-upload before publishing so the bubble tails are seamless."]}),qe&&!v&&Te>0&&Me.missing===0&&Fe.size===0&&f.jsxs("div",{className:"px-3 py-0.5 border-b border-border bg-green-600/10 text-[10px] text-green-700 flex items-center gap-1 flex-shrink-0","data-testid":"clean-assets-ready",children:[f.jsx("span",{"aria-hidden":!0,children:"✓"}),f.jsxs("span",{children:["All ",Te," clean image",Te===1?"":"s"," ","present — clean-asset generation is complete. Ready for lettering in OWS."]})]}),ye&&f.jsx("div",{className:"px-3 py-1 border-b border-border text-[10px] text-muted flex-shrink-0","data-testid":"sync-result",children:ye}),f.jsxs("div",{className:"flex-1 min-h-56 overflow-y-auto p-3 space-y-3","data-testid":"lettering-review-board",children:[S.cuts.map((K,xe)=>{var ve;return f.jsxs(w.Fragment,{children:[f.jsx(xy,{index:xe,beforeLabel:xe===0?"Episode opening":`After cut ${(ve=S.cuts[xe-1])==null?void 0:ve.id}`,afterLabel:`Before cut ${K.id}`,disabled:xi,onAdd:()=>ln(xe)}),f.jsx(VD,{cut:K,storyName:e,plotFile:je,language:s,expanded:L===K.id,onToggle:()=>I(L===K.id?null:K.id),authFetch:i,onUpdated:()=>{De(),_t(),nt()},onOpenEditor:()=>_e(K.id),detectedLocalClean:ft.has(K.id),onSyncClean:ui,syncing:D,onAiDraft:()=>{Tt(K.id,{openEditor:!0})},aiDrafting:Pe===K.id,staleMessages:Fe.get(K.id)??[],onRepairStale:_i,repairing:k,conversionPng:hi.get(K.id)??null,onConvert:ei,converting:ne,featured:xe===0,rowRef:Ce=>{Ce?se.current.set(K.id,Ce):se.current.delete(K.id)}})]},K.id)}),f.jsx(xy,{index:S.cuts.length,beforeLabel:`After cut ${(Bt=S.cuts[S.cuts.length-1])==null?void 0:Bt.id}`,afterLabel:"Episode ending",disabled:xi,onAdd:()=>ln(S.cuts.length)}),v&&f.jsxs(f.Fragment,{children:[Ge,Dt]})]})]})}function xy({index:e,beforeLabel:t,afterLabel:i,disabled:s,onAdd:a}){return f.jsxs("div",{className:"rounded border border-dashed border-border bg-surface/35 px-3 py-2 text-[11px] text-muted flex items-center gap-3","data-testid":`between-scene-slot-${e}`,children:[f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:"font-medium text-foreground",children:"Between-scene lettering"}),f.jsxs("span",{className:"block truncate",children:[t," · ",i]})]}),f.jsx("button",{type:"button",onClick:a,disabled:s,className:"flex-shrink-0 rounded border border-accent/40 px-2.5 py-1 text-[11px] font-medium text-accent hover:bg-accent/5 disabled:opacity-50","data-testid":`add-between-scene-${e}`,children:"Add card"})]})}function XD(e){if(!e||e.length===0)return null;const t=e1(e),i=[`${t.cleanReady} clean`,`${t.finalReady} final`,`${t.uploaded} uploaded`];return t.needsConversion>0&&i.push(`${t.needsConversion} PNG`),t.missing>0&&i.push(`${t.missing} missing`),i.join(" · ")}function ZD(e,t,i){var s;return((s=Cm({checklist:e,markdownReady:t,published:i}))==null?void 0:s.statusLabel)??"Review cuts"}const QD=1024*1024,JD=["image/webp","image/jpeg"],eM="Cover: WebP or JPEG, max 1MB, 600×900 portrait recommended. Use clean cover art — avoid unreadable AI text or broken lettering.";function tM(e){return e.attached?{state:"attached",label:"Cover attached to your story.",tone:"success"}:e.invalid?{state:"invalid",label:"Cover file can't be used — must be WebP or JPEG, max 1MB.",tone:"error"}:e.hasSelectedCover?{state:"selected",label:"Cover selected — it will be uploaded when you publish.",tone:"accent"}:{state:"none",label:"No cover yet — add one before publishing (recommended).",tone:"muted"}}function by(e){return e.size>QD?"Image exceeds 1MB limit":JD.includes(e.type)?null:"Only WebP and JPEG images are accepted"}async function iM(e,t,i){const s=new FormData;s.append("file",i);const a=await e("/api/publish/upload-cover",{method:"POST",body:s});if(!a.ok)return null;const{cid:o}=await a.json();return!o||!(await e("/api/publish/update-storyline",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storylineId:t,coverCid:o})})).ok?null:o}function zp(e){const t=e.match(/^#\s+(.+)$/m),i=t?t[1].trim():"";return i||null}function nM(e){return e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim().split(" ").map(t=>t&&t[0].toUpperCase()+t.slice(1)).join(" ")}function Ho(e,t){const i=(e??"").trim().toLowerCase();if(!i)return!0;if(t==="genesis.md")return i==="genesis";const s=t.match(/^(plot-\d+)\.md$/);return s?i===s[1].toLowerCase()||/^plot-\d+$/.test(i):!1}function rM(e){const t=e.match(/^plot-(\d+)\.md$/);if(!t)return null;const i=t[1];return`Episode ${i.length<2?i.padStart(2,"0"):i}`}function Pp(e){const t=(e??"").trim();return!!(!t||/^(?:episode|ep|chapter|ch|part|pt|plot)\.?\s*[-–—:#]?\s*\d+$/i.test(t)||/^\d+$/.test(t)||/^plot[-_\s]?\d+$/i.test(t))}function km(e){var s;const t=zp(e.fileContent);if(t)return!Pp(t);const i=((s=e.episodeTitle)==null?void 0:s.trim())||null;return!!i&&!Pp(i)}function Em(e){const{fileName:t,fileContent:i,storySlug:s,structureContent:a,contentType:o,episodeTitle:c}=e,h=zp(i);if(t==="genesis.md"){const p=a?zp(a):null;return(h??p??nM(s)).slice(0,60)}if(h)return h.slice(0,60);if(o==="cartoon"){const p=c==null?void 0:c.trim(),d=rM(t);return((p||d)??t.replace(/\.md$/,"")).slice(0,60)}return t.replace(/\.md$/,"").slice(0,60)}function sM(e){return!!(e!=null&&e.txHash)&&(e==null?void 0:e.plotIndex)!=null&&e.plotIndex>0}function aM(e){return sM(e)&&(e==null?void 0:e.status)!=="published-not-indexed"}function vy(e,t,i){if(e[t]==="cartoon"&&!i)return"cartoon"}function lM(e,t,i){return!(e!=="cartoon"||t||!i||i.startsWith("_new_"))}function Lf(e,t,i){if(e)return t[e]||i.get(e)||"fiction"}function Of(e){if(!e)return null;const t=Number(e);return Number.isFinite(t)?(t/1e18).toFixed(6):null}function oM(e){return!!e&&e.ready===!1}function cM(e){const t=Of(e.requiredBalance)??Of(e.creationFee),i=Of(e.ethBalance);return e.hasEnoughEth===!1&&t&&i?`Insufficient ETH: need at least ${t} ETH to publish; current balance is ${i} ETH.`+(e.address?` Top up the OWS wallet (${e.address}) and try again.`:" Top up the OWS wallet and try again."):e.error||"Publish preflight failed — the OWS wallet isn't ready to publish."}const uM={...Mu,attributes:{...Mu.attributes,img:["src","alt","title"]}},hM="https://ipfs.filebase.io/ipfs/";function dM(e){const t=[],i=/!\[([^\]]*)\]\(([^)]+)\)/g;let s;for(;(s=i.exec(e))!==null;)t.push({full:s[0],alt:s[1],url:s[2]});return t}function fM(e){const t=dM(e),i=[];for(const a of t)a.url.startsWith(hM)||i.push(`Non-IPFS image URL: ${a.url.length>60?a.url.slice(0,60)+"...":a.url}`);return e.match(/!\[[^\]]*\]\([^)]*$|!\[[^\]]*$(?!\])/gm)&&i.push("Malformed image markdown detected — check brackets and parentheses"),{count:t.length,warnings:i}}function pM(e){return e==="open-cuts"||e==="open-lettering"||e==="upload"||e==="refresh-assets"}function mM(e){if(e==="genesis.md")return"epi-01 (Genesis)";const t=e==null?void 0:e.match(/^plot-(\d+)\.md$/);if(!t)return e??"";const i=parseInt(t[1],10)+1;return`epi-${String(i).padStart(2,"0")}`}function yy(e){var i,s;return((s=(i=e==null?void 0:e.match(/^#\s+(.+?)\s*$/m))==null?void 0:i[1])==null?void 0:s.trim())||null}function gM(e){if(e==="genesis.md")return"Episode 1";const t=e==null?void 0:e.match(/^plot-(\d+)\.md$/);return t?`Episode ${parseInt(t[1],10)+1}`:null}function _M(e,t){const i=t==null?void 0:t.trim();if(!i)return null;if(/^Episode\s+\d+\s*[—-]\s*/i.test(i))return i;const s=gM(e);return s?`${s} — ${i}`:i}function xM({storyName:e,fileName:t,authFetch:i,onPublish:s,publishingFile:a,walletAddress:o,contentType:c="fiction",language:h,genre:p,isNsfw:d,hasGenesis:x=!1,onViewProgress:_,onOpenFile:b,onViewPublish:v,focusedLetteringMode:S=!1,focusedLetteringWorkspaceVisible:N=!1,onFocusedLetteringModeChange:M,onFocusedLetteringWorkspaceVisibleChange:E,workflowActionRequest:H=null,onWorkflowActionHandled:z}){const[R,te]=w.useState(null),[L,I]=w.useState(!1),[re,_e]=w.useState("preview"),[j,J]=w.useState(null),[F,G]=w.useState(""),[Y,U]=w.useState(!1),[A,q]=w.useState(!1),[$,be]=w.useState(!1),[T,D]=w.useState(null),[V,k]=w.useState(""),[le,ne]=w.useState(""),[de,X]=w.useState(!1),[ue,ye]=w.useState(null),[fe,Pe]=w.useState(0),[$e,Oe]=w.useState(0),[Ke,ft]=w.useState(null),[tt,Fe]=w.useState(null),[ze,qe]=w.useState(null),[Gt,wt]=w.useState(0),ki=w.useRef(null),Ei=w.useRef(!1),[yt,Li]=w.useState(!1),[oe,se]=w.useState(cl[0]),[Ie,je]=w.useState(is[0]),[De,Ct]=w.useState(!1),[_t,nt]=w.useState(null),[xt,Tt]=w.useState(null),[ct,ui]=w.useState(!1),[ei,Kn]=w.useState(!1),[mn,_i]=w.useState(!1),[xi,Ht]=w.useState(null),[ln,Ui]=w.useState(!1),O=w.useRef(null),we=w.useRef(null),[Me,Te]=w.useState(!1),[Ze,Qe]=w.useState(null),[Nt,kt]=w.useState(null),[Rt,Je]=w.useState("unknown"),hi=w.useRef(!1),[bi,vi]=w.useState(!1),[Ot,si]=w.useState(!1),[Zt,he]=w.useState(null),[Ae,Ge]=w.useState([]),[Dt,st]=w.useState(null),at=w.useRef(null),Bt=w.useRef(null),K=w.useRef(0),xe=w.useRef(!1);xe.current=pM(H==null?void 0:H.action);const ve=w.useCallback(async()=>{if(!e||!t){te(null);return}const ie=`${e}/${t}`,Ee=Bt.current!==ie;Ee&&(Bt.current=ie);try{const Ne=await i(`/api/stories/${e}/${t}`);if(Ne.ok){const Xe=await Ne.json();te(Xe),(Ee||!Ei.current)&&(G(Xe.content??""),Ee&&(q(!1),Ei.current=!1))}}catch{}},[e,t,i]);w.useEffect(()=>{I(!0),ve().finally(()=>I(!1))},[ve]),w.useEffect(()=>{if(!e||!t||re==="edit"&&A)return;const ie=setInterval(ve,3e3);return()=>clearInterval(ie)},[e,t,ve,re,A]);const[Ce,Be]=w.useState(null),He=c==="cartoon"&&t==="genesis.md";w.useEffect(()=>{if(!He||!e){Be(null);return}let ie=!1;return i(`/api/stories/${e}/cuts/genesis`).then(Ee=>Ee.ok?Ee.json():null).then(Ee=>{ie||Be(Ee?Op(Ee.cuts||[]):null)}).catch(()=>{ie||Be(null)}),()=>{ie=!0}},[He,e,i]);const dt=c==="cartoon"&&!!t&&/^plot-\d+\.md$/.test(t);w.useEffect(()=>{if(!dt||!e||!t){ye(null),Pe(0),Oe(0),ft(null);return}let ie=!1;const Ee=t.replace(/\.md$/,"");return ft(null),(async()=>{try{const[Ne,Xe]=await Promise.all([i(`/api/stories/${e}/${t}`),i(`/api/stories/${e}/cuts/${Ee}`)]);if(ie)return;if(!Xe.ok){ye("error"),Pe(0),Oe(0),ft(null);return}const Kt=await Xe.json(),yi=Kt.cuts||[],dr=Ne.ok?(await Ne.json()).content??"":"",fr=XS(dr,yi);if(!ie){ye(fr.stage),Pe(fr.awaitingCount),Oe(fr.totalCuts),ft(Op(yi));const En=typeof Kt.title=="string"?Kt.title.trim():"";qe(En||yy(dr))}}catch{ie||(ye("error"),Pe(0),Oe(0),ft(null))}})(),()=>{ie=!0}},[dt,e,t,i,R==null?void 0:R.content,R==null?void 0:R.status,Gt]),w.useEffect(()=>{if(!e){Fe(null);return}let ie=!1;return i(`/api/stories/${e}/structure.md`).then(Ee=>Ee.ok?Ee.json():null).then(Ee=>{ie||Fe((Ee==null?void 0:Ee.content)??null)}).catch(()=>{}),()=>{ie=!0}},[e,i]),w.useEffect(()=>{if(!e)return;const ie=Su(p);let Ee=ie??"";if(!ie&&tt){const Xe=tt.match(/\*{0,2}genre\*{0,2}[:\s]+(.+)/i);Xe&&(Ee=Su(Xe[1].replace(/\*+/g,"").trim())??"")}k(Ee);let Ne=h&&is.find(Xe=>Xe.toLowerCase()===h.toLowerCase())||"";if(!Ne&&tt){const Xe=tt.match(/\*{0,2}language\*{0,2}[:\s]+(.+)/i);Xe&&(Ne=is.find(Kt=>Kt.toLowerCase()===Xe[1].replace(/\*+/g,"").trim().toLowerCase())||"")}ne(Ne),X(d??!1)},[e,p,h,d,tt]);const Lt=w.useCallback(ie=>{e&&i(`/api/stories/${e}/publish-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)}).catch(()=>{})},[e,i]),gn=w.useCallback(async()=>{if(!(!e||!t)){U(!0);try{(await i(`/api/stories/${e}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:F})})).ok&&(q(!1),Ei.current=!1,te(Ee=>Ee&&{...Ee,content:F}))}catch{}U(!1)}},[e,t,i,F]),on=w.useCallback(async()=>{if(!e||!t)return;const ie=t.replace(/\.md$/,"");try{(await i(`/api/stories/${e}/cuts/${ie}/generate-markdown`,{method:"POST"})).ok&&(await ve(),wt(Ne=>Ne+1))}catch{}},[e,t,i,ve]);w.useEffect(()=>{if(H&&H.seq!==K.current){switch(K.current=H.seq,H.action){case"view-progress":_==null||_();break;case"open-cuts":case"open-lettering":case"upload":case"refresh-assets":_e("edit");break;case"generate-markdown":on();break;case"publish":_e("preview");break}z==null||z(H.seq)}},[H,_,on,z]);const Vn=w.useCallback(ie=>{var Xe;const Ee=(Xe=ie.target.files)==null?void 0:Xe[0];if(!Ee)return;hi.current=!0,Qe(null),kt(null);const Ne=by(Ee);if(Ne){nt(null),Tt(Kt=>(Kt&&URL.revokeObjectURL(Kt),null)),O.current&&(O.current.value=""),Ht(Ne),Je("invalid");return}nt(Ee),Tt(Kt=>(Kt&&URL.revokeObjectURL(Kt),URL.createObjectURL(Ee))),Ht(null),Je("selected")},[]),br=w.useCallback(async ie=>{var Ne;const Ee=(Ne=ie.target.files)==null?void 0:Ne[0];if(we.current&&(we.current.value=""),!(!Ee||!e)){hi.current=!0,Qe(null),Te(!0),Ht(null);try{let Xe;try{Xe=await Yu(Ee)}catch(En){nt(null),Tt(yl=>(yl&&URL.revokeObjectURL(yl),null)),Ht(En instanceof Error?En.message:"Could not import image");return}const Kt=Xe.type==="image/jpeg"?"jpg":"webp",yi=new File([Xe],`cover.${Kt}`,{type:Xe.type}),dr=new FormData;dr.append("file",yi);const fr=await i(`/api/stories/${e}/import-cover`,{method:"POST",body:dr});if(!fr.ok){const En=await fr.json().catch(()=>({}));Ht(En.error||"Cover import failed");return}nt(yi),Tt(En=>(En&&URL.revokeObjectURL(En),URL.createObjectURL(yi))),kt(null),Je("selected"),Ht(null)}catch{Ht("Cover import failed")}finally{Te(!1)}}},[e,i]),Xn=w.useCallback(async ie=>{if(ie.size>1024*1024){he("Image exceeds 1MB limit");return}if(!["image/webp","image/jpeg"].includes(ie.type)){he("Only WebP and JPEG images are accepted");return}si(!0),he(null);try{const Ne=new FormData;Ne.append("file",ie);const Xe=await i("/api/publish/upload-plot-image",{method:"POST",body:Ne});if(!Xe.ok){const yi=await Xe.json();throw new Error(yi.error||"Upload failed")}const Kt=await Xe.json();Ge(yi=>[...yi,{cid:Kt.cid,url:Kt.url}])}catch(Ne){he(Ne instanceof Error?Ne.message:"Upload failed")}finally{si(!1),at.current&&(at.current.value="")}},[i]),Yt=w.useCallback(ie=>{var Ne;const Ee=(Ne=ie.target.files)==null?void 0:Ne[0];Ee&&Xn(Ee)},[Xn]),$i=w.useCallback(async()=>{if(R!=null&&R.storylineId){ui(!0),Ht(null),Ui(!1);try{let ie;if(_t){const Ne=new FormData;Ne.append("file",_t);const Xe=await i("/api/publish/upload-cover",{method:"POST",body:Ne});if(!Xe.ok){const yi=await Xe.json();throw new Error(yi.error||"Cover upload failed")}ie=(await Xe.json()).cid}const Ee=await i("/api/publish/update-storyline",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storylineId:R.storylineId,...ie!==void 0&&{coverCid:ie},genre:oe,language:Ie,isNsfw:De})});if(!Ee.ok){const Ne=await Ee.json();throw new Error(Ne.error||"Update failed")}Ui(!0),nt(null),ie!==void 0&&(_i(!0),Tt(Ne=>(Ne&&URL.revokeObjectURL(Ne),null)),Je("unknown"),O.current&&(O.current.value="")),setTimeout(()=>Ui(!1),3e3)}catch(ie){Ht(ie instanceof Error?ie.message:"Update failed")}finally{ui(!1)}}},[R==null?void 0:R.storylineId,_t,oe,Ie,De,i]);w.useEffect(()=>{Li(!1),nt(null),Tt(null),Ht(null),Ui(!1),Kn(!1),vi(!1),Ge([]),he(null),Qe(null),kt(null),Je("unknown"),hi.current=!1,xe.current&&_e("edit")},[e,t]),w.useEffect(()=>{if(t!=="genesis.md"||!e||!R||R.storylineId||R.status==="published"||R.status==="published-not-indexed"||hi.current)return;let ie=!1;return(async()=>{try{const Ee=await i(`/api/stories/${e}/cover-asset`);if(ie||!Ee.ok)return;const Ne=await Ee.json();if(ie)return;if(!(Ne!=null&&Ne.found)){Je("none");return}if(!Ne.valid){kt(Ne.error||"Detected cover asset is invalid and was not used"),Je("invalid");return}const Xe=await i(`/api/stories/${e}/asset/${Ne.path.replace(/^assets\//,"")}`);if(ie||!Xe.ok)return;const Kt=await Xe.blob(),yi=new File([Kt],Ne.path.split("/").pop()||"cover.webp",{type:Ne.type});if(by(yi)||ie||hi.current)return;nt(yi),Tt(dr=>(dr&&URL.revokeObjectURL(dr),URL.createObjectURL(yi))),Qe(Ne.path),Je("detected")}catch{}})(),()=>{ie=!0}},[e,t,R,R==null?void 0:R.status,R==null?void 0:R.storylineId,i]),w.useEffect(()=>{if(!yt||!(R!=null&&R.storylineId))return;Kn(!1);const ie="https://plotlink.xyz";let Ee=!1;return fetch(`${ie}/api/storyline/${R.storylineId}`).then(Ne=>Ne.ok?Ne.json():null).then(Ne=>{if(!Ee){if(!Ne){Ht("Could not load current story metadata");return}if(Ne.genre){const Xe=Su(Ne.genre);Xe&&se(Xe)}if(Ne.language){const Xe=is.find(Kt=>Kt.toLowerCase()===Ne.language.toLowerCase());Xe&&je(Xe)}Ne.isNsfw!==void 0&&Ct(!!Ne.isNsfw),_i(!!(Ne.coverCid||Ne.coverUrl||Ne.cover)),Kn(!0)}}).catch(()=>{Ee||Ht("Could not load current story metadata")}),()=>{Ee=!0}},[yt,R==null?void 0:R.storylineId]),w.useEffect(()=>{if(re!=="edit")return;const ie=Ee=>{(Ee.metaKey||Ee.ctrlKey)&&Ee.key==="s"&&(Ee.preventDefault(),gn())};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[re,gn]),w.useEffect(()=>{if((R==null?void 0:R.status)!=="published-not-indexed"||!R.publishedAt)return;const ie=new Date(R.publishedAt).getTime(),Ee=300*1e3,Ne=()=>{const Kt=Math.max(0,Ee-(Date.now()-ie));D(Kt)};Ne();const Xe=setInterval(Ne,1e3);return()=>clearInterval(Xe)},[R==null?void 0:R.status,R==null?void 0:R.publishedAt]);const Ut=T!==null&&T<=0,Cn=T!==null&&T>0?`${Math.floor(T/6e4)}:${String(Math.floor(T%6e4/1e3)).padStart(2,"0")}`:null;if(!e||!t)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:f.jsxs("div",{className:"text-center",children:[f.jsx("p",{className:"text-lg font-serif",children:"Select a file to preview"}),f.jsx("p",{className:"text-sm mt-1",children:"Click a story file in the sidebar"})]})});if(L&&!R)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:"Loading..."});const zt=(re==="edit"?F:(R==null?void 0:R.content)??"").length,ti=t==="genesis.md",kn=t?/^plot-\d+\.md$/.test(t):!1,cn=c==="cartoon"&&kn,Qt=c==="cartoon"&&ti,Ni=Qt||cn,ls=Ni?_M(t,ze||yy(R==null?void 0:R.content)):null,yr=(R==null?void 0:R.status)==="published"||(R==null?void 0:R.status)==="published-not-indexed",Lr=S&&Ni,_l=Qt?Ce?Ce.total:null:cn?ue===null?null:$e:null,Sa=FD({fileName:t??"",contentType:c,hasGenesis:x,isPublished:yr,cutCount:_l,cutProgress:Qt?Ce:null}),Or=(Qt||cn)&&!yr,Us=Or?Em({fileName:t,fileContent:(R==null?void 0:R.content)??"",storySlug:e??"",structureContent:tt,contentType:"cartoon",episodeTitle:ze}):null,wa=!!Us&&Ho(Us,t),xl=cn&&!yr&&!km({fileContent:(R==null?void 0:R.content)??"",episodeTitle:ze}),zr=Qt&&!yr?wm((R==null?void 0:R.content)??""):null,Vo=!!zr&&zr.blockers.length>0,Ku="w-full max-w-[32rem] rounded-xl border px-3 py-3",Ca={muted:"text-muted",accent:"text-accent",error:"text-error",success:"text-green-700"},Zn=ie=>{if(!Qt)return null;const Ee=tM({hasSelectedCover:!!_t,invalid:Rt==="invalid",attached:ie});return f.jsxs("div",{className:"flex flex-col gap-0.5","data-testid":"cartoon-cover-status","data-state":Ee.state,children:[f.jsx("span",{className:`text-[11px] font-medium ${Ca[Ee.tone]}`,children:Ee.label}),f.jsxs("details",{className:"text-[10px] text-muted","data-testid":"cover-details",children:[f.jsx("summary",{className:"cursor-pointer select-none",children:"Cover tips"}),f.jsx("span",{className:"block mt-0.5","data-testid":"cartoon-cover-guidance",children:eM})]})]})},$s=wa||xl,bl=()=>{if(!Or||!Us)return null;const ie=ti?"Story title":"Episode title";return f.jsxs("div",{className:"flex flex-col gap-0.5","data-testid":"publish-title-preview","data-raw":wa?"true":"false","data-blocked":$s?"true":"false",children:[f.jsxs("span",{className:"text-[11px] text-foreground",children:[f.jsxs("span",{className:"font-medium",children:[ie,":"]})," ",f.jsx("span",{className:$s?"text-error font-medium":"text-foreground",children:Us})]}),wa?f.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-raw-error",children:["This would publish as a raw filename."," ",ti?"Add a real “# Title” heading to genesis.md":"Set a title in the cut plan (or add a “# Title” to the episode)"," ","before publishing."]}):xl?f.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-episode-required",children:["“",Us,"” is a generic placeholder, not a reader-facing title, so it can’t be published. Set a real episode title in the cut plan (or add a “# Title” to the episode) — e.g. “Episode 01 — The Couple Coupon” — before publishing."]}):null]})},os=()=>zr?f.jsxs("div",{className:"flex flex-col gap-1 rounded border border-border bg-surface/50 p-2","data-testid":"cartoon-genesis-readiness","data-blocked":Vo?"true":"false",children:[f.jsx("span",{className:"text-[11px] font-medium text-foreground",children:"Story opening (Prologue)"}),f.jsx("span",{className:"text-[10px] text-muted","data-testid":"genesis-readiness-hint",children:"Genesis is the first thing readers see. Write it as the story opening/prologue, not a synopsis — set up the premise and stakes, then bridge into Episode 01."}),zr.blockers.map((ie,Ee)=>f.jsx("span",{className:"text-[10px] text-error","data-testid":"genesis-readiness-blocker",children:ie},`b-${Ee}`)),zr.warnings.map((ie,Ee)=>f.jsx("span",{className:"text-[10px] text-amber-600","data-testid":"genesis-readiness-warning",children:ie},`w-${Ee}`))]}):null,Qn=ti||kn?1e4:null,Fs=!yr&&Qn!==null&&zt>Qn,vl=(R==null?void 0:R.content)??"",qs=yr?{count:0,warnings:[]}:fM(vl),Ws=f.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden","data-testid":"prose-editor-shell",style:{background:"var(--paper-bg)"},children:[f.jsx("textarea",{ref:ki,value:F,onChange:ie=>{G(ie.target.value),q(!0),Ei.current=!0},className:"flex-1 min-h-0 w-full resize-none px-4 py-3 text-sm leading-relaxed focus:outline-none",style:{fontFamily:'"Geist Mono", ui-monospace, monospace',background:"var(--paper-bg)",color:"var(--text)"},spellCheck:!1,"data-testid":"prose-editor-textarea"}),f.jsxs("div",{className:"shrink-0 px-3 py-1.5 border-t border-border flex items-center justify-between bg-surface/95","data-testid":"prose-editor-savebar",children:[f.jsx("span",{className:"text-xs text-muted",children:A?"Unsaved changes":"No changes"}),f.jsx("button",{onClick:gn,disabled:!A||Y,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:Y?"Saving...":"Save"})]})]});return f.jsxs("div",{className:"h-full min-h-0 flex flex-col",children:[!Lr&&f.jsxs("div",{className:"border-b border-border",children:[f.jsxs("div",{className:Ni?"px-3 py-1.5 flex items-center justify-between gap-3":"px-3 py-1.5 flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted min-w-0",children:[_&&f.jsx("button",{onClick:_,"data-testid":"view-progress-btn",className:"text-accent hover:underline",title:"Story progress overview",children:"← Progress"}),f.jsx("span",{className:Ni?"font-medium text-foreground truncate":"font-mono",children:Ni?`${mM(t)}${ls?` · ${ls}`:""}`:`${e}/${t}`}),(R==null?void 0:R.status)==="published"&&f.jsx("span",{className:"text-green-700 font-medium",children:"Published"}),(R==null?void 0:R.status)==="published-not-indexed"&&f.jsx("span",{className:"text-amber-700 font-medium",title:R.indexError,children:"Published (not indexed)"}),(R==null?void 0:R.status)==="pending"&&f.jsx("span",{className:"text-amber-700 font-medium",children:"Pending"})]}),Ni?f.jsxs("div",{className:"flex items-center gap-1 rounded border border-border bg-surface/40 p-0.5",children:[f.jsx("button",{onClick:()=>_e("preview"),className:`px-2.5 py-0.5 text-[11px] font-medium rounded transition-colors ${re==="preview"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Preview"}),f.jsxs("button",{onClick:()=>_e("edit"),className:`px-2.5 py-0.5 text-[11px] font-medium rounded transition-colors ${re==="edit"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:["Edit",A&&f.jsx("span",{className:"ml-1 text-amber-200",children:"*"})]})]}):f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:`text-xs font-mono ${Fs?"text-error font-medium":"text-muted"}`,children:[zt.toLocaleString(),Qn!==null?`/${Qn.toLocaleString()}`:" chars"]}),Fs&&f.jsxs("span",{className:"text-error text-xs font-medium",children:[(zt-Qn).toLocaleString()," over limit"]})]})]}),!Ni&&f.jsxs("div",{className:"flex px-3 gap-1",children:[f.jsx("button",{onClick:()=>_e("preview"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${re==="preview"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:"Preview"}),f.jsxs("button",{onClick:()=>_e("edit"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${re==="edit"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:["Edit",A&&f.jsx("span",{className:"ml-1 text-amber-600",children:"*"})]})]})]}),re==="preview"?Ni?f.jsx("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:f.jsx("div",{className:"flex-1 min-h-0",children:f.jsx(_y,{storyName:e,fileName:t,authFetch:i,language:h,mode:"preview",onCutsChanged:()=>wt(ie=>ie+1),focusRequest:j,onFocusHandled:()=>J(null),compactEpisodeChrome:!0})})}):f.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 py-4",style:{background:"var(--paper-bg)"},children:R!=null&&R.content?f.jsx("div",{className:"prose max-w-none",children:f.jsx(dA,{remarkPlugins:[wA,N3],rehypePlugins:[[z3,uM]],children:R.content})}):f.jsx("p",{className:"text-muted italic",children:"No content"})}):Ni?f.jsx("div",{className:"flex-1 min-h-[22rem] overflow-hidden",style:{background:"var(--paper-bg)"},children:f.jsx(_y,{storyName:e,fileName:t,authFetch:i,language:h,mode:"edit",onCutsChanged:()=>wt(ie=>ie+1),focusRequest:j,onFocusHandled:()=>J(null),onFocusedLetteringModeChange:M,workspaceVisible:N,onWorkspaceVisibleChange:E,onExitFocusedEditor:()=>_e("preview"),compactEpisodeChrome:!0})}):Ws,!Lr&&!Ni&&f.jsx("div",{className:"shrink-0 px-3 py-2 border-t border-border flex items-center justify-between bg-surface/95","data-testid":"preview-panel-footer",children:t==="structure.md"?f.jsx("p",{className:"text-muted text-xs italic","data-testid":"footer-guidance",children:Sa}):(R==null?void 0:R.status)==="published-not-indexed"?f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[f.jsx("span",{className:"text-amber-700",children:"Published on-chain but not indexed on PlotLink"}),!Ut&&f.jsx("button",{onClick:async()=>{if(!(!e||!t||!R.txHash)){be(!0);try{(await(await i("/api/publish/retry-index",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:e,fileName:t,txHash:R.txHash,content:R.content,storylineId:R.storylineId})})).json()).ok&&(await i(`/api/stories/${e}/${t}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:R.txHash,storylineId:R.storylineId,contentCid:"",gasCost:""})}),ve())}catch{}be(!1)}},disabled:$,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:$?"Retrying...":`Retry Index${Cn?` (${Cn})`:""}`}),kn&&f.jsx("button",{onClick:()=>{!e||!t||!window.confirm(`This episode is already on-chain — try “Retry Index” first.
133
+
134
+ Retry Publish creates a NEW on-chain transaction and a SECOND, permanent chapter on PlotLink (PlotLink content is immutable). Only do this if the chapter never appeared after indexing.
135
+
136
+ Create a new on-chain chapter anyway?`)||s==null||s(e,t,V,le,de)},disabled:!!a,"data-testid":"retry-publish-btn",className:"px-3 py-1 border border-border text-xs rounded hover:bg-surface disabled:opacity-50",children:a===t?"Publishing...":"Retry Publish"}),R.txHash&&f.jsx("a",{href:`https://basescan.org/tx/${R.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}),f.jsx("p",{className:"text-muted text-xs",children:Ut?kn?"Index window expired. Use Retry Publish to create a new on-chain tx.":"Index window expired. Contact support or re-publish manually.":kn?"Try Retry Index first (available for 5 min after publish). If that fails, Retry Publish creates a new on-chain tx.":"Retry Index is available for 5 min after publish."}),R.indexError&&f.jsx("p",{className:"text-error text-xs",children:R.indexError})]}):(R==null?void 0:R.status)==="published"?f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[f.jsx("span",{className:"text-green-700",children:"Published"}),R.storylineId&&f.jsx("a",{href:(()=>{var Ne;const ie=`https://plotlink.xyz/story/${R.storylineId}`;if(!kn)return ie;const Ee=R.plotIndex!=null&&R.plotIndex>0?R.plotIndex:parseInt(((Ne=t==null?void 0:t.match(/^plot-(\d+)\.md$/))==null?void 0:Ne[1])??"1");return`${ie}/${Ee}`})(),target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"}),R.txHash&&f.jsx("a",{href:`https://basescan.org/tx/${R.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"}),ti&&o&&R.storylineId&&(!R.authorAddress||R.authorAddress.toLowerCase()===o.toLowerCase())&&f.jsx("button",{onClick:()=>Li(ie=>!ie),className:"px-2 py-0.5 border border-border text-xs rounded hover:bg-surface",children:yt?"Close Edit":"Edit Story"})]}),yt&&ti&&R.storylineId&&f.jsxs("div",{className:"border border-border rounded p-3 flex flex-col gap-3 bg-surface",children:[f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-foreground",children:"Cover Image"}),Zn(mn),f.jsxs("div",{className:"flex items-start gap-3",children:[xt&&f.jsxs("div",{className:"relative",children:[f.jsx("img",{src:xt,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),f.jsx("button",{onClick:()=>{nt(null),Tt(null),kt(null),Je("unknown"),O.current&&(O.current.value="")},className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-error text-white rounded-full text-xs flex items-center justify-center",children:"x"})]}),f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx("input",{ref:O,type:"file",accept:"image/webp,image/jpeg",onChange:Vn,className:"text-xs","data-testid":"cover-input"}),f.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 1MB, 600x900px recommended"})]})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("select",{value:oe,onChange:ie=>se(ie.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:cl.map(ie=>f.jsx("option",{value:ie,children:ie},ie))}),f.jsx("select",{value:Ie,onChange:ie=>je(ie.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:is.map(ie=>f.jsx("option",{value:ie,children:ie},ie))})]}),f.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:De,onChange:ie=>Ct(ie.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:$i,disabled:ct||!ei,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:ct?"Saving...":ei?"Save Changes":"Loading..."}),ln&&f.jsx("span",{className:"text-green-700 text-xs",children:"Updated!"}),xi&&f.jsx("span",{className:"text-error text-xs",children:xi})]})]})]}):f.jsxs("div",{className:"flex flex-col gap-2",children:[cn&&Ke&&Ke.total>0&&f.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-0.5 text-[10px] text-muted","data-testid":"cartoon-status-summary",children:[f.jsxs("span",{children:["Cuts:"," ",f.jsx("span",{className:"text-foreground font-medium",children:Ke.total})]}),f.jsxs("span",{children:["Clean:"," ",f.jsxs("span",{className:"text-foreground font-medium",children:[Ke.withClean,"/",Ke.needClean]})]}),f.jsxs("span",{children:["Lettered:"," ",f.jsxs("span",{className:"text-foreground font-medium",children:[Ke.withText,"/",Ke.total]})]}),f.jsxs("span",{children:["Uploaded:"," ",f.jsxs("span",{className:"text-foreground font-medium",children:[Ke.uploaded,"/",Ke.total]})]}),_&&f.jsx("button",{onClick:_,className:"ml-auto text-accent hover:underline","data-testid":"status-view-progress",children:"View progress →"})]}),Qt&&Ce&&f.jsxs("div",{className:"text-xs text-muted","data-testid":"genesis-cuts-summary",children:["Episode 1 (Genesis) cuts: ",Ce.total," planned",Ce.total>0&&f.jsxs(f.Fragment,{children:[" ","· ",Ce.withClean," clean ·"," ",Ce.withText," lettered ·"," ",Ce.exported," exported ·"," ",Ce.uploaded," uploaded"]})]}),(Qt||cn)&&Sa&&f.jsxs("div",{className:`${Ku} flex flex-col gap-1 border-border bg-surface/50`,"data-testid":"cartoon-not-started",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"rounded-full bg-background px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-muted",children:_l===0?"Not started":"Next step"}),f.jsx("span",{className:"text-xs font-medium text-foreground",children:Qt?"Genesis (Episode 1)":"Future episode"})]}),f.jsx("span",{className:"text-xs text-muted",children:Sa})]}),kn&&!cn&&re==="preview"&&f.jsxs("div",{children:[f.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:bi,onChange:ie=>vi(ie.target.checked),className:"rounded border-border"}),"Add illustrations in the plot"]}),bi&&f.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[f.jsxs("div",{className:"border-2 border-dashed border-border rounded p-3 flex flex-col items-center gap-1.5 cursor-pointer hover:border-accent transition-colors",onClick:()=>{var ie;return(ie=at.current)==null?void 0:ie.click()},onDragOver:ie=>{ie.preventDefault(),ie.stopPropagation()},onDrop:ie=>{var Ne;ie.preventDefault(),ie.stopPropagation();const Ee=(Ne=ie.dataTransfer.files)==null?void 0:Ne[0];Ee&&Xn(Ee)},children:[f.jsx("input",{ref:at,type:"file",accept:"image/webp,image/jpeg",onChange:Yt,className:"hidden"}),f.jsx("span",{className:"text-xs text-muted",children:Ot?"Uploading...":"Drop image here or click to browse"}),f.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 1MB"})]}),Zt&&f.jsx("span",{className:"text-error text-xs",children:Zt}),Ae.map((ie,Ee)=>f.jsxs("div",{className:"border border-border rounded p-2 flex flex-col gap-1 bg-surface",children:[f.jsx("span",{className:"text-xs text-green-700",children:"Image uploaded! Copy the markdown below and paste it where you want the illustration to appear in your plot:"}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsxs("code",{className:"flex-1 text-xs bg-background px-2 py-1 rounded font-mono break-all",children:["![Scene description](",ie.url,")"]}),f.jsx("button",{onClick:()=>{navigator.clipboard.writeText(`![Scene description](${ie.url})`),st(Ee),setTimeout(()=>st(null),2e3)},className:"px-2 py-1 text-xs border border-border rounded hover:bg-surface shrink-0",children:Dt===Ee?"Copied!":"Copy"})]})]},ie.cid))]})]}),ti&&c!=="cartoon"&&f.jsxs("div",{className:"flex flex-col gap-1.5","data-testid":"prepublish-cover",children:[f.jsxs("span",{className:"text-xs font-medium text-foreground",children:["Cover Image"," ",f.jsx("span",{className:"text-muted font-normal",children:"(optional)"})]}),Zn(!1),f.jsxs("div",{className:"flex items-start gap-3",children:[xt&&f.jsxs("div",{className:"relative",children:[f.jsx("img",{src:xt,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),f.jsx("button",{onClick:()=>{hi.current=!0,Qe(null),kt(null),Je("unknown"),nt(null),Tt(ie=>(ie&&URL.revokeObjectURL(ie),null)),O.current&&(O.current.value="")},className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-error text-white rounded-full text-xs flex items-center justify-center",children:"x"})]}),f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx("input",{ref:O,type:"file",accept:"image/webp,image/jpeg",onChange:Vn,className:"text-xs","data-testid":"prepublish-cover-input"}),f.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 1MB, 600x900px recommended"}),f.jsx("input",{ref:we,type:"file",accept:"image/png,image/webp,image/jpeg",onChange:br,className:"hidden","data-testid":"prepublish-cover-import-input"}),f.jsx("button",{type:"button",onClick:()=>{var ie;return(ie=we.current)==null?void 0:ie.click()},disabled:Me,className:"self-start px-2 py-1 text-xs border border-border rounded hover:border-accent hover:bg-accent/5 disabled:opacity-50","data-testid":"prepublish-cover-import",children:Me?"Importing…":"Import generated image (PNG ok)"}),_t&&f.jsx("span",{className:"text-green-700 text-xs","data-testid":"prepublish-cover-will-upload",children:"This cover will be uploaded as the PlotLink storyline cover when you publish."}),Ze&&f.jsxs("span",{className:"text-accent text-xs","data-testid":"prepublish-cover-detected",children:["Auto-detected generated cover ",Ze," — pick a file to override."]}),Nt&&f.jsxs("span",{className:"text-amber-700 text-xs","data-testid":"prepublish-cover-detected-warning",children:[Nt," Use “Import generated image” below to convert/compress it, or pick a file."]}),c==="cartoon"&&Rt==="none"&&!_t&&f.jsxs("span",{className:"text-muted text-xs","data-testid":"prepublish-cover-none",children:["No generated cover detected. Create"," ",f.jsx("span",{className:"font-mono",children:"assets/cover.webp"})," ","or use “Import generated image” — it will be uploaded as the PlotLink storyline cover when you publish."]}),xi&&f.jsx("span",{className:"text-error text-xs","data-testid":"prepublish-cover-error",children:xi})]})]})]}),!Ni&&bl(),!Ni&&os(),!Ni&&f.jsxs("div",{className:"flex items-center gap-2",children:[ti&&c!=="cartoon"&&f.jsxs(f.Fragment,{children:[f.jsxs("select",{value:V,"data-testid":"publish-genre-select",onChange:ie=>{k(ie.target.value),ie.target.value&&Lt({genre:ie.target.value})},className:`px-2 py-1.5 text-xs border rounded bg-surface text-foreground ${V?"border-border":"border-amber-500"}`,children:[!V&&f.jsx("option",{value:"",disabled:!0,children:"Needs metadata — select genre"}),cl.map(ie=>f.jsx("option",{value:ie,children:ie},ie))]}),f.jsxs("select",{value:le,"data-testid":"publish-language-select",onChange:ie=>{ne(ie.target.value),ie.target.value&&Lt({language:ie.target.value})},className:`px-2 py-1.5 text-xs border rounded bg-surface text-foreground ${le?"border-border":"border-amber-500"}`,children:[!le&&f.jsx("option",{value:"",disabled:!0,children:"Needs metadata — select language"}),is.map(ie=>f.jsx("option",{value:ie,children:ie},ie))]})]}),f.jsx("button",{onClick:async()=>{if(!e||!t)return;if(qs.count>0){const Ee=`This plot contains ${qs.count} illustration(s). Content is immutable after publishing — image references cannot be changed or removed.
137
+
138
+ Please verify illustrations appear correctly in Preview before continuing.
139
+
140
+ Publish now?`;if(!window.confirm(Ee))return}const ie=ti?_t:null;ie?await(s==null?void 0:s(e,t,V,le,de,ie))&&(hi.current=!0,Qe(null),kt(null),Je("unknown"),nt(null),Tt(Ne=>(Ne&&URL.revokeObjectURL(Ne),null)),O.current&&(O.current.value="")):s==null||s(e,t,V,le,de)},disabled:!!a||Fs||$s||Vo||ti&&(!V||!le)||cn&&ue!=="ready",className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:a===t?"Publishing...":"Publish to PlotLink"}),ti&&c==="cartoon"&&(!V||!le)&&f.jsx("span",{className:"text-amber-600 text-xs","data-testid":"cartoon-metadata-needs-story-info",children:"Set the genre and language in Story Info before publishing"}),ti&&c!=="cartoon"&&!V&&f.jsx("span",{className:"text-amber-600 text-xs","data-testid":"genre-needs-metadata",children:"Needs metadata — choose a genre before publishing"}),ti&&c!=="cartoon"&&V&&!le&&f.jsx("span",{className:"text-amber-600 text-xs","data-testid":"language-needs-metadata",children:"Needs metadata — choose a language before publishing"}),Fs&&f.jsx("span",{className:"text-error text-xs",children:"Reduce content to publish"}),cn&&ue==="error"&&f.jsx("span",{className:"text-error text-xs","data-testid":"publish-disabled-reason",children:"Fix the issues below before publishing"}),cn&&ue==="planning"&&f.jsx("span",{className:"text-muted text-xs","data-testid":"publish-disabled-reason",children:"Prepare the episode for publish to continue"}),cn&&ue==="awaiting-upload"&&f.jsxs("span",{className:"text-muted text-xs","data-testid":"publish-disabled-reason",children:["Upload all final images, then “Prepare episode for publish” — ",fe," of ",$e," ","still need an uploaded image"]})]}),Ni&&f.jsx("button",{onClick:()=>v==null?void 0:v(),"data-testid":"cartoon-review-publish",className:"self-start rounded border border-accent/40 px-3 py-1 text-xs text-accent hover:bg-accent/5 transition-colors",children:"Review publish checklist →"}),qs.warnings.length>0&&f.jsx("div",{className:"flex flex-col gap-0.5",children:qs.warnings.map((ie,Ee)=>f.jsx("span",{className:"text-amber-600 text-xs",children:ie},Ee))}),ti&&c!=="cartoon"&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:de,onChange:ie=>{X(ie.target.checked),Lt({isNsfw:ie.target.checked})},className:"rounded border-border"}),"This story contains adult content (18+)"]}),de&&f.jsx("span",{className:"text-xs text-amber-600",children:"Adult content will be hidden from the default browse view."})]})]})})]})}function bM(e){if(e.cover!=="present")return e.cover==="invalid"?"Replace the cover image - it must be a valid WebP or JPEG.":"Add a cover image before publishing.";const t=[];return e.metadata.language||t.push("language"),e.metadata.genre||t.push("genre"),e.metadata.title||t.push("title"),`Add the story ${t.join(" and ")||"details"} before publishing.`}function i1(e){const t=e.coach??null,i=e.metadata,s=e.setup.hasStructure,a=e.setup.hasGenesis,o=e.cover==="present",c=!i.title||!i.language||!i.genre,h=e.episodes.find(d=>!d.published)??null,p=!!h&&h.state!=="ready";return s?a?c?"story-info":p&&(t!=null&&t.episodeFile)?t.episodeFile:o?(t==null?void 0:t.episodeFile)??null:"story-info":"genesis.md":"whitepaper"}function Ip({badge:e,tone:t="accent",summary:i,children:s,note:a,testId:o}){const c=t==="complete"?"border-green-700/20 bg-green-950/5":"border-accent/30 bg-background/95",h=t==="complete"?"bg-green-700/10 text-green-700":"bg-accent/10 text-accent";return f.jsx("div",{className:`border px-3 py-3 sm:px-4 ${c}`,"data-testid":o,"data-state":t==="complete"?"complete":"active",children:f.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:`inline-flex rounded-full px-2 py-0.5 text-[10px] font-bold uppercase tracking-[0.14em] ${h}`,children:e}),f.jsx("p",{className:"mt-1 text-sm text-foreground",children:i}),a?f.jsx("p",{className:"mt-1 text-[11px] font-medium text-accent",children:a}):null]}),s?f.jsx("div",{className:"flex w-full justify-end sm:w-auto sm:flex-shrink-0",children:s}):null]})})}function Hp({onClick:e,disabled:t,testId:i}){return f.jsx("button",{type:"button",onClick:e,disabled:t,className:"w-full rounded bg-accent px-4 py-2.5 text-sm font-bold text-white shadow-sm transition-colors hover:bg-accent-dim disabled:cursor-not-allowed disabled:opacity-50 sm:w-auto","data-testid":i,children:"Next Action"})}function n1({coach:e,onAction:t}){const[i,s]=w.useState(null),a=i!==null&&i===(e==null?void 0:e.prompt);if(e===void 0)return null;if(!e)return f.jsx(Ip,{badge:"Complete",tone:"complete",summary:"No next action available.",note:"This workflow has no queued next step right now.",testId:"cartoon-next-action"});const o=e.actionKind==="agent"&&e.prompt?f.jsx(Hp,{testId:"workflow-coach-copy",onClick:()=>{var h;if(!e.prompt)return;const c=e.prompt;(h=navigator.clipboard)==null||h.writeText(c).then(()=>s(c)).catch(()=>{})}}):e.actionKind==="ui"&&e.uiAction?f.jsx(Hp,{testId:"workflow-coach-do",onClick:()=>t(e.uiAction,e.episodeFile)}):null;return f.jsx(Ip,{badge:e.stageLabel,summary:f.jsxs("span",{"data-testid":"workflow-coach-action",children:[f.jsx("span",{className:"font-semibold",children:"Next: "}),f.jsx("span",{children:e.action})]}),note:a?"Prompt copied.":void 0,testId:"cartoon-next-action",children:o})}function vM({progress:e,onOpenStoryInfo:t}){return f.jsx(Ip,{badge:"Story info",summary:f.jsxs("span",{"data-testid":"story-info-next-action",children:[f.jsx("span",{className:"font-semibold",children:"Next: "}),f.jsx("span",{children:bM(e)})]}),testId:"story-info-cta",children:f.jsx(Hp,{testId:"story-info-next-action-btn",onClick:()=>t==null?void 0:t(),disabled:!t})})}function yM({progress:e,onCoachAction:t,onOpenStoryInfo:i}){return i1(e)==="story-info"?f.jsx(vM,{progress:e,onOpenStoryInfo:i}):f.jsx(n1,{coach:e.coach??null,onAction:t})}function SM({storyName:e,authFetch:t,fileName:i,refreshKey:s=0,onCoachAction:a,onOpenStoryInfo:o}){const[c,h]=w.useState(void 0),p=JSON.stringify([e,i??"",s]),[d,x]=w.useState(null);return d!==p&&(h(void 0),x(p)),w.useEffect(()=>{let _=!1;const b=i?`?focus=${encodeURIComponent(i)}`:"";return t(`/api/stories/${e}/progress${b}`).then(v=>v.ok?v.json():null).then(v=>{_||h(wM(v)?v:null)}).catch(()=>{_||h(null)}),()=>{_=!0}},[e,i,t,s]),c===void 0?null:c?f.jsx(yM,{progress:c,onCoachAction:a,onOpenStoryInfo:o}):f.jsx(n1,{coach:null,onAction:a})}function wM(e){return!!e&&!!e.metadata&&!!e.setup&&Array.isArray(e.episodes)}function CM({storyName:e,authFetch:t,onOpenFile:i,refreshKey:s=0}){const[a,o]=w.useState(null),[c,h]=w.useState(!0);return w.useEffect(()=>{let p=!1;return(async()=>{h(!0);try{const x=await t(`/api/stories/${e}/progress`),_=x.ok?await x.json():null;p||(o(_),h(!1))}catch{p||(o(null),h(!1))}})(),()=>{p=!0}},[e,t,s]),c?f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"progress-loading",children:"Loading progress…"}):!a||!a.metadata||!Array.isArray(a.episodes)?f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load story progress."}):a.contentType==="cartoon"?f.jsx(DM,{progress:a,storyName:e,onOpenFile:i}):f.jsx(LM,{progress:a,storyName:e,onOpenFile:i})}function fu({label:e,value:t,tone:i="muted"}){const s=i==="ok"?"text-green-700":i==="warn"?"text-amber-700":"text-muted";return f.jsxs("span",{className:"text-[11px]",children:[f.jsxs("span",{className:"text-muted",children:[e,": "]}),f.jsx("span",{className:`font-medium ${s}`,children:t})]})}function r1({progress:e}){const t=e.contentType==="cartoon",i=e.cover==="present"?"ok":e.cover==="invalid"?"warn":"muted";return f.jsxs("div",{className:"px-4 py-3 border-b border-border",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h2",{className:"text-base font-serif text-foreground truncate",children:e.metadata.title||e.name}),f.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-medium ${t?"bg-accent/10 text-accent":"bg-surface text-muted"}`,children:t?"Cartoon":"Fiction"})]}),f.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-x-3 gap-y-1",children:[f.jsx(fu,{label:"Language",value:e.metadata.language||"Needs metadata",tone:e.metadata.language?"muted":"warn"}),f.jsx(fu,{label:"Genre",value:e.metadata.genre||"Needs metadata",tone:e.metadata.genre?"muted":"warn"}),e.metadata.isNsfw!=null&&f.jsx(fu,{label:"Adult",value:e.metadata.isNsfw?"Yes (18+)":"No"}),t&&f.jsx(fu,{label:"Cover",value:e.cover==="present"?"Ready":e.cover==="invalid"?"Invalid":"Missing",tone:i})]})]})}const s1={published:"✓",done:"●",current:"◉","needs-action":"●","not-started":"○"},Lu={published:"text-green-700",done:"text-green-700",current:"text-accent","needs-action":"text-amber-700","not-started":"text-muted"},a1={published:"Published",done:"Complete",current:"Current","needs-action":"Needs action","not-started":"Not started"},kM={done:"✓",current:"◓",todo:"○"},EM={done:"text-green-700",current:"text-accent",todo:"text-muted"};function l1({item:e}){return f.jsxs("div",{className:"flex items-baseline gap-2 text-[11px]","data-testid":"checklist-item","data-status":e.status,children:[f.jsx("span",{className:`${EM[e.status]} flex-shrink-0`,"aria-hidden":!0,children:kM[e.status]}),f.jsx("span",{className:e.status==="todo"?"text-muted":"text-foreground",children:e.label}),e.detail&&f.jsxs("span",{className:"text-muted",children:["· ",e.detail]})]})}function Sy({index:e,title:t,status:i,items:s,fileName:a,openFile:o}){const c=f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{className:`flex-shrink-0 ${Lu[i]}`,"aria-hidden":!0,children:s1[i]}),f.jsxs("span",{className:"text-xs font-medium text-foreground truncate",children:[e,". ",t]}),a&&f.jsx("span",{className:"text-[10px] text-muted truncate",children:a}),f.jsx("span",{className:`ml-auto text-[10px] font-medium ${Lu[i]} flex-shrink-0`,children:a1[i]})]});return f.jsxs("div",{className:"px-4 py-2.5 border-b border-border","data-testid":`workflow-section-${e}`,"data-status":i,children:[o?f.jsx("button",{onClick:o,className:"w-full text-left rounded hover:bg-surface -mx-1 px-1 py-0.5","data-testid":`section-open-${e}`,children:c}):c,f.jsx("div",{className:"mt-1.5 ml-1 flex flex-col gap-1 border-l border-border pl-3",children:s.map((h,p)=>f.jsx(l1,{item:h},p))})]})}function NM(e,t){return e.published?"published":t?"current":e.state==="placeholder"?"not-started":(e.state==="blocked","needs-action")}function TM(e){if(e.file==="genesis.md")return"epi-01 (Genesis)";const t=e.file.match(/^plot-(\d+)\.md$/);if(!t)return e.label;const i=parseInt(t[1],10)+1;return`epi-${String(i).padStart(2,"0")}`}function jM(e,t=!0){const i=e.checklist??[],s=[];if(e.kind==="genesis"&&s.push({label:"Opening text",status:t?"done":"todo"}),i.length===0)return s.push({label:"Cut plan",status:"todo"}),s.push({label:"Clean artwork",status:"todo"}),s;for(const a of i)s.push(AM(a));return s}function AM(e){return{label:e.label,status:e.status,detail:e.detail}}const RM={file:"genesis.md",label:"Episode 1 / Genesis",kind:"genesis",title:null,state:"placeholder",summary:"",published:!1,checklist:[],cuts:null};function DM({progress:e,storyName:t,onOpenFile:i}){const s=e.metadata,a=e.setup.hasStructure,o=e.cover==="present",h=!s.title||!s.language||!s.genre||!o,p=i1(e),d=[{label:"Public title",status:s.title?"done":"todo",detail:s.title??null},{label:"Language",status:s.language?"done":"todo",detail:s.language??null},{label:"Genre",status:s.genre?"done":"todo",detail:s.genre??null},{label:"Cover image",status:o?"done":"todo",detail:e.cover==="invalid"?"Invalid — re-import":o?null:"Missing"}],x=p==="story-info"?"current":h?"needs-action":"done",_=a?"done":p==="whitepaper"?"current":"not-started",b=e.episodes.find(N=>N.kind==="genesis")??null,v=e.episodes.filter(N=>N.kind==="plot");let S=0;return f.jsxs("div",{className:"h-full overflow-y-auto","data-testid":"story-progress-panel",children:[f.jsx(r1,{progress:e}),f.jsx("p",{className:"px-4 pt-3 pb-1 text-[11px] font-medium text-muted uppercase tracking-wider",children:"Production Progress"}),f.jsx(Sy,{index:++S,title:"Define Story Info",status:x,items:d}),f.jsx(Sy,{index:++S,title:"Story Bible",status:_,openFile:a?()=>i(t,"structure.md"):void 0,items:[{label:"Planning document",status:a?"done":"todo",detail:a?null:"Not written yet"}]}),b?f.jsx(zf,{index:++S,ep:b,isActive:p===b.file,storyName:t,onOpenFile:i}):f.jsx(zf,{index:++S,ep:RM,isActive:p==="genesis.md",openingDone:!1,canOpen:!1,storyName:t,onOpenFile:i}),v.map(N=>f.jsx(zf,{index:++S,ep:N,isActive:p===N.file,storyName:t,onOpenFile:i},N.file)),f.jsxs("div",{className:"px-4 py-2 text-[11px] text-muted flex flex-wrap gap-x-3","data-testid":"progress-summary",children:[f.jsxs("span",{children:[e.summary.published," published"]}),f.jsxs("span",{children:[e.summary.readyToPublish," ready"]}),e.summary.placeholders>0&&f.jsxs("span",{children:[e.summary.placeholders," not started"]}),e.summary.blocked>0&&f.jsxs("span",{className:"text-error",children:[e.summary.blocked," need fixes"]})]})]})}function zf({index:e,ep:t,isActive:i,storyName:s,onOpenFile:a,openingDone:o=!0,canOpen:c=!0}){var v;const h=NM(t,i),p=jM(t,o),d=Cm({checklist:t.checklist?{steps:t.checklist,nextStep:null}:null,markdownReady:t.state==="ready"||t.published,published:t.published}),x=TM(t),_=t.title?`${x} · ${t.title}`:x,b=f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{className:`flex-shrink-0 ${Lu[h]}`,"aria-hidden":!0,children:s1[h]}),f.jsxs("span",{className:"text-xs font-medium text-foreground truncate",children:[e,". ",_]}),f.jsx("span",{className:`ml-auto text-[10px] font-medium ${Lu[h]} flex-shrink-0`,children:a1[h]})]});return f.jsxs("div",{className:"px-4 py-2.5 border-b border-border","data-testid":`workflow-section-${e}`,"data-status":h,children:[c?f.jsx("button",{onClick:()=>a(s,t.file),"data-testid":`progress-episode-${t.file}`,"data-state":t.state,className:"w-full text-left rounded hover:bg-surface -mx-1 px-1 py-0.5",children:b}):f.jsx("div",{"data-state":t.state,children:b}),(d==null?void 0:d.statusLabel)&&f.jsxs("div",{className:"mt-1 ml-1 text-[10px] text-muted",children:[f.jsx("span",{className:"font-medium text-foreground",children:"Active step:"})," ",d.statusLabel,(v=d.activeStep)!=null&&v.detail?` · ${d.activeStep.detail}`:""]}),f.jsx("div",{className:"mt-1.5 ml-1 flex flex-col gap-1 border-l border-border pl-3",children:p.map((S,N)=>f.jsx(l1,{item:S},N))})]})}const MM={published:"✓",ready:"●","in-progress":"◐",planning:"○",placeholder:"○",blocked:"✕",draft:"○"},wy={published:"text-green-700",ready:"text-green-700","in-progress":"text-accent",planning:"text-accent",placeholder:"text-muted",blocked:"text-error",draft:"text-muted"},BM={published:"Published",ready:"Ready","in-progress":"In progress",planning:"Planning",placeholder:"Not started",blocked:"Needs fixes",draft:"Draft"};function LM({progress:e,storyName:t,onOpenFile:i}){const[s,a]=w.useState(!1);return f.jsxs("div",{className:"h-full overflow-y-auto","data-testid":"story-progress-panel",children:[f.jsx(r1,{progress:e}),e.nextAction&&f.jsxs("div",{className:"px-4 py-2 border-b border-accent/30 bg-accent/5 text-xs space-y-1.5","data-testid":"progress-next-action",children:[f.jsxs("div",{children:[f.jsx("span",{className:"font-medium text-foreground",children:"Next: "}),f.jsx("span",{className:"text-muted",children:e.nextAction})]}),e.nextPrompt&&f.jsxs("div",{className:"flex items-start gap-1.5","data-testid":"progress-next-prompt",children:[f.jsx("code",{className:"flex-1 rounded border border-border bg-surface px-1.5 py-1 text-[10px] text-foreground break-words",children:e.nextPrompt}),f.jsx("button",{onClick:()=>{var o;e.nextPrompt&&((o=navigator.clipboard)==null||o.writeText(e.nextPrompt).then(()=>{a(!0)}).catch(()=>{}))},"data-testid":"copy-next-prompt",className:"rounded border border-border px-2 py-1 text-[10px] text-muted hover:border-accent hover:text-accent transition-colors flex-shrink-0",children:s?"Copied!":"Copy"})]})]}),f.jsxs("div",{className:"px-4 py-2 border-b border-border flex flex-col gap-1",children:[f.jsx(Cy,{done:e.setup.hasStructure,label:"Story bible (structure.md)",onClick:e.setup.hasStructure?()=>i(t,"structure.md"):void 0}),f.jsx(Cy,{done:e.setup.hasGenesis,label:"Genesis written",onClick:e.setup.hasGenesis?()=>i(t,"genesis.md"):void 0})]}),f.jsxs("div",{className:"px-4 py-2",children:[f.jsx("p",{className:"text-[11px] font-medium text-muted uppercase tracking-wider mb-1.5",children:"Chapters"}),e.episodes.length===0?f.jsx("p",{className:"text-xs text-muted italic","data-testid":"progress-no-episodes",children:"No chapters yet — write the Genesis to start."}):f.jsx("ol",{className:"flex flex-col gap-1",children:e.episodes.map(o=>f.jsx("li",{children:f.jsxs("button",{onClick:()=>i(t,o.file),"data-testid":`progress-episode-${o.file}`,"data-state":o.state,className:"w-full text-left flex items-start gap-2 rounded px-2 py-1.5 hover:bg-surface",children:[f.jsx("span",{className:`mt-0.5 ${wy[o.state]}`,"aria-hidden":!0,children:MM[o.state]}),f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-foreground",children:o.label}),o.title&&f.jsxs("span",{className:"text-[11px] text-muted truncate",children:["· ",o.title]}),f.jsx("span",{className:`ml-auto text-[10px] font-medium ${wy[o.state]}`,children:BM[o.state]})]}),f.jsx("span",{className:"block text-[11px] text-muted",children:o.summary})]})]})},o.file))})]}),f.jsxs("div",{className:"px-4 py-2 border-t border-border text-[11px] text-muted flex flex-wrap gap-x-3","data-testid":"progress-summary",children:[f.jsxs("span",{children:[e.summary.published," published"]}),e.summary.blocked>0&&f.jsxs("span",{className:"text-error",children:[e.summary.blocked," need fixes"]})]})]})}function Cy({done:e,label:t,onClick:i}){const s=f.jsxs("span",{className:"flex items-center gap-2 text-xs",children:[f.jsx("span",{className:e?"text-green-700":"text-muted","aria-hidden":!0,children:e?"✓":"○"}),f.jsx("span",{className:e?"text-foreground":"text-muted",children:t})]});return i?f.jsx("button",{onClick:i,className:"text-left hover:underline",children:s}):f.jsx("div",{children:s})}const OM=[{key:"progress",label:"Progress"},{key:"story-info",label:"Story Info"},{key:"episodes",label:"Episodes"},{key:"publish",label:"Publish"}];function zM({storyTitle:e,active:t,onSelect:i}){return f.jsxs("div",{className:"flex-shrink-0 border-b border-border bg-surface/40","data-testid":"cartoon-workflow-nav",children:[f.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2",children:[f.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-accent",children:"Cartoon"}),f.jsx("span",{className:"text-xs font-serif text-foreground truncate",children:e})]}),f.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 overflow-x-auto",role:"tablist",children:OM.map(s=>{const a=s.key===t;return f.jsx("button",{role:"tab","aria-selected":a,"data-testid":`nav-tab-${s.key}`,"data-active":a,onClick:()=>i(s.key),className:`flex-shrink-0 rounded-full px-2.5 py-1 text-[11px] font-medium transition-colors ${a?"bg-accent text-white":"text-muted hover:text-foreground hover:bg-surface"}`,children:s.label},s.key)})})]})}function PM({storyName:e,authFetch:t,onSaved:i}){const[s,a]=w.useState(!0),[o,c]=w.useState(!1),[h,p]=w.useState(""),[d,x]=w.useState(""),[_,b]=w.useState(""),[v,S]=w.useState(""),[N,M]=w.useState(!1),[E,H]=w.useState("cartoon"),[z,R]=w.useState("unknown"),[te,L]=w.useState(!1),[I,re]=w.useState(!1),[_e,j]=w.useState(null),[J,F]=w.useState(!1),[G,Y]=w.useState(null),[U,A]=w.useState(!1),q=w.useRef(null);w.useEffect(()=>{let k=!1;return a(!0),c(!1),re(!1),j(null),(async()=>{try{const[le,ne]=await Promise.all([t(`/api/stories/${e}`),t(`/api/stories/${e}/progress`)]);if(!le.ok){k||(c(!0),a(!1));return}const de=await le.json(),X=ne.ok?await ne.json().catch(()=>null):null;if(k)return;p(de.title??""),x(de.description??""),b(Su(de.genre)??""),S(de.language&&is.find(ue=>ue.toLowerCase()===de.language.toLowerCase())||""),M(!!de.isNsfw),H(de.contentType==="fiction"?"fiction":"cartoon"),R((X==null?void 0:X.cover)??"unknown"),a(!1)}catch{k||(c(!0),a(!1))}})(),()=>{k=!0}},[e,t]);const $=w.useCallback(async()=>{L(!0),re(!1),j(null);const k={title:h.trim(),description:d.trim(),genre:_,language:v,isNsfw:N};try{const le=await t(`/api/stories/${e}/publish-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});if(le.ok)re(!0),i==null||i({genre:_,language:v,isNsfw:N});else{const ne=await le.json().catch(()=>({}));j(ne.error||"Could not save story info.")}}catch{j("Could not save story info.")}L(!1)},[e,t,h,d,_,v,N,i]),be=w.useCallback(async k=>{var ne;const le=(ne=k.target.files)==null?void 0:ne[0];if(q.current&&(q.current.value=""),!!le){F(!0),j(null);try{let de;try{de=await Yu(le)}catch(Pe){j(Pe instanceof Error?Pe.message:"Could not import image");return}const X=de.type==="image/jpeg"?"jpg":"webp",ue=new File([de],`cover.${X}`,{type:de.type}),ye=new FormData;ye.append("file",ue);const fe=await t(`/api/stories/${e}/import-cover`,{method:"POST",body:ye});if(!fe.ok){const Pe=await fe.json().catch(()=>({}));j(Pe.error||"Cover import failed.");return}R("present"),Y(Pe=>(Pe&&URL.revokeObjectURL(Pe),URL.createObjectURL(ue)))}catch{j("Cover import failed.")}finally{F(!1)}}},[e,t]),T=w.useCallback(()=>{var le;const k=`Generate a cover image for this story (${h||e}) and save it as assets/cover.webp — portrait 600x900, WebP, under 1MB. Don't publish.`;(le=navigator.clipboard)==null||le.writeText(k).then(()=>{A(!0)}).catch(()=>{})},[h,e]);if(s)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"story-info-loading",children:"Loading story info…"});if(o)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load story info."});const D=z==="present"?"Cover set":z==="invalid"?"Invalid cover — re-import a WebP/JPEG under 1MB":"Missing cover",V=z==="present"?"text-green-700":z==="invalid"?"text-amber-700":"text-muted";return f.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"story-info-page",children:[f.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("h2",{className:"text-base font-serif text-foreground",children:"Story Info"}),f.jsx("p",{className:"mt-0.5 text-[11px] text-muted",children:"These details appear on PlotLink when the story is published."}),f.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5 text-[10px]",children:[f.jsxs("span",{className:`rounded-full border px-2 py-0.5 ${h.trim()?"border-green-700/30 bg-green-700/10 text-green-700":"border-border bg-background text-muted"}`,children:["Title ",h.trim()?"ready":"missing"]}),f.jsxs("span",{className:`rounded-full border px-2 py-0.5 ${_?"border-green-700/30 bg-green-700/10 text-green-700":"border-border bg-background text-muted"}`,children:["Genre ",_?"set":"needed"]}),f.jsxs("span",{className:`rounded-full border px-2 py-0.5 ${v?"border-green-700/30 bg-green-700/10 text-green-700":"border-border bg-background text-muted"}`,children:["Language ",v?"set":"needed"]}),f.jsx("span",{className:`rounded-full border px-2 py-0.5 ${z==="present"?"border-green-700/30 bg-green-700/10 text-green-700":"border-border bg-background text-muted"}`,children:z==="present"?"Cover ready":"Cover missing"})]})]}),f.jsxs("div",{className:"flex flex-col items-start gap-1.5",children:[f.jsx("button",{type:"button",onClick:$,disabled:te,"data-testid":"story-info-save",className:"rounded bg-accent px-3 py-1.5 text-xs font-medium text-white hover:bg-accent-dim transition-colors disabled:opacity-50",children:te?"Saving…":"Save Story Info"}),I&&f.jsx("span",{className:"text-[11px] text-green-700","data-testid":"story-info-saved",children:"Saved"}),_e&&f.jsx("span",{className:"text-[11px] text-error","data-testid":"story-info-error",children:_e})]})]}),f.jsxs("div",{className:"mt-4 flex flex-col gap-4 max-w-xl",children:[f.jsxs("label",{className:"flex flex-col gap-1",children:[f.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Public title"}),f.jsx("input",{type:"text",value:h,onChange:k=>{p(k.target.value),re(!1)},"data-testid":"story-info-title",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none"})]}),f.jsxs("label",{className:"flex flex-col gap-1",children:[f.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Short description"}),f.jsx("textarea",{value:d,onChange:k=>{x(k.target.value),re(!1)},rows:3,"data-testid":"story-info-description",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none resize-y"})]}),f.jsxs("div",{className:"flex flex-wrap gap-4",children:[f.jsxs("label",{className:"flex flex-col gap-1 min-w-[140px] flex-1",children:[f.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Genre"}),f.jsxs("select",{value:_,onChange:k=>{b(k.target.value),re(!1)},"data-testid":"story-info-genre",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",children:[f.jsx("option",{value:"",children:"Needs metadata"}),cl.map(k=>f.jsx("option",{value:k,children:k},k))]})]}),f.jsxs("label",{className:"flex flex-col gap-1 min-w-[140px] flex-1",children:[f.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Language"}),f.jsxs("select",{value:v,onChange:k=>{S(k.target.value),re(!1)},"data-testid":"story-info-language",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",children:[f.jsx("option",{value:"",children:"Needs metadata"}),is.map(k=>f.jsx("option",{value:k,children:k},k))]})]}),f.jsxs("label",{className:"flex flex-col gap-1 min-w-[140px] flex-1",children:[f.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Content type"}),f.jsx("span",{className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-surface text-muted","data-testid":"story-info-content-type",title:"Content type is locked after creation.",children:E==="cartoon"?"Cartoon · locked":"Fiction · locked"})]})]}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Cover image"}),f.jsxs("div",{className:"flex items-start gap-3",children:[G&&f.jsx("img",{src:G,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("span",{className:`text-[11px] font-medium ${V}`,"data-testid":"story-info-cover-status",children:D}),f.jsx("span",{className:"text-[10px] text-muted",children:"WebP or JPEG, max 1MB, 600×900 recommended."}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{type:"button",onClick:()=>{var k;return(k=q.current)==null?void 0:k.click()},disabled:J,"data-testid":"story-info-import-cover",className:"rounded border border-border px-2.5 py-1 text-[11px] text-foreground hover:border-accent hover:text-accent transition-colors disabled:opacity-50",children:J?"Importing…":"Import cover"}),f.jsx("button",{type:"button",onClick:T,"data-testid":"story-info-cover-prompt",className:"rounded border border-border px-2.5 py-1 text-[11px] text-muted hover:border-accent hover:text-accent transition-colors",children:U?"Copied!":"Ask agent for cover prompt"})]}),f.jsx("input",{ref:q,type:"file",accept:"image/*",onChange:be,className:"hidden"})]})]})]}),f.jsxs("label",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",checked:N,onChange:k=>{M(k.target.checked),re(!1)},"data-testid":"story-info-nsfw"}),f.jsx("span",{className:"text-xs text-foreground",children:"This story contains adult content (18+)"})]})]})]})}function IM({storyName:e,authFetch:t,onOpenFile:i}){const[s,a]=w.useState(null),[o,c]=w.useState(!0);if(w.useEffect(()=>{let b=!1;return(async()=>{c(!0);try{const S=await t(`/api/stories/${e}/progress`),N=S.ok?await S.json():null;b||(a(Array.isArray(N==null?void 0:N.episodes)?N.episodes:null),c(!1))}catch{b||(a(null),c(!1))}})(),()=>{b=!0}},[e,t]),o)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"episodes-loading",children:"Loading episodes…"});if(!s)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load episodes."});const h=s.filter(b=>b.published).length,p=s.filter(b=>!b.published).length,d=s.filter(b=>b.state==="blocked").length,x=s.filter(b=>b.state==="ready").length,_=b=>{if(b.file==="genesis.md")return"epi-01 (Genesis)";const v=b.file.match(/^plot-(\d+)\.md$/);if(!v)return b.label;const S=parseInt(v[1],10)+1;return`epi-${String(S).padStart(2,"0")}`};return f.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"episodes-page",children:[f.jsx("h2",{className:"text-base font-serif text-foreground",children:"Episodes"}),f.jsx("p",{className:"mt-0.5 text-[11px] text-muted",children:"Open an episode to preview its cuts or edit lettering."}),f.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5 text-[10px]","data-testid":"episodes-summary",children:[f.jsxs("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-foreground",children:[s.length," total"]}),f.jsxs("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-muted",children:[p," active"]}),f.jsxs("span",{className:"rounded-full border border-green-700/30 bg-green-700/10 px-2 py-0.5 text-green-700",children:[h," published"]}),f.jsxs("span",{className:"rounded-full border border-accent/30 bg-accent/10 px-2 py-0.5 text-accent",children:[x," ready"]}),d>0&&f.jsxs("span",{className:"rounded-full border border-error/30 bg-error/10 px-2 py-0.5 text-error",children:[d," need fixes"]})]}),s.length===0?f.jsx("p",{className:"mt-4 text-xs text-muted italic","data-testid":"episodes-empty",children:"No episodes yet."}):f.jsx("ol",{className:"mt-3 flex flex-col gap-1",children:s.map(b=>f.jsx("li",{children:f.jsx("button",{onClick:()=>i(e,b.file),"data-testid":`episodes-row-${b.file}`,"data-state":b.state,className:"w-full text-left flex items-start gap-2 rounded px-2 py-1.5 hover:bg-surface",children:f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-foreground",children:_(b)}),b.title&&f.jsxs("span",{className:"text-[11px] text-muted truncate",children:["· ",b.title]})]}),f.jsx("span",{className:"block text-[11px] text-muted",children:b.summary})]})})},b.file))})]})}function HM({storyName:e,authFetch:t,onOpenFile:i,onOpenStoryInfo:s,onPublish:a,publishingFile:o,genre:c,language:h,isNsfw:p,refreshKey:d=0}){var tt,Fe;const[x,_]=w.useState(null),[b,v]=w.useState(!0),[S,N]=w.useState(!1),[M,E]=w.useState(null),[H,z]=w.useState(null),[R,te]=w.useState(null),[L,I]=w.useState(null),[re,_e]=w.useState(null),j=async()=>{try{const ze=await t(`/api/stories/${e}/cover-asset`),qe=ze.ok?await ze.json():null;if(!(qe!=null&&qe.found)||!qe.valid||!qe.path)return null;const Gt=await t(`/api/stories/${e}/asset/${String(qe.path).replace(/^assets\//,"")}`);if(!Gt.ok)return null;const wt=await Gt.blob();return new File([wt],String(qe.path).split("/").pop()||"cover.webp",{type:qe.type||wt.type})}catch{return null}};w.useEffect(()=>{let ze=!1;return(async()=>{v(!0),N(!1);try{const Gt=await t(`/api/stories/${e}/progress`),wt=Gt.ok?await Gt.json():null;if(ze)return;!wt||!Array.isArray(wt.episodes)?(N(!0),_(null)):_(wt),v(!1)}catch{ze||(N(!0),_(null),v(!1))}})(),()=>{ze=!0}},[e,t,d]);const J=((Fe=(tt=x==null?void 0:x.episodes)==null?void 0:tt.find(ze=>!ze.published))==null?void 0:Fe.file)??null,F=J==="genesis.md",G=JSON.stringify([J??"",d]),[Y,U]=w.useState(null);if(Y!==G&&(U(G),z(null),te(null),I(null),_e(null)),w.useEffect(()=>{if(!J)return;let ze=!1;const qe=J.replace(/\.md$/,"");return(async()=>{var Gt;try{const wt=[t(`/api/stories/${e}/${J}`),t(`/api/stories/${e}/cuts/${qe}`)];F&&wt.push(t(`/api/stories/${e}/structure.md`));const[ki,Ei,yt]=await Promise.all(wt);if(ze)return;if(z(ki.ok?(await ki.json()).content??"":""),Ei.ok){const Li=await Ei.json();if(ze)return;te(Array.isArray(Li.cuts)?Li.cuts:[]),I(typeof Li.title=="string"?Li.title:null)}else te(null),I(null);_e(F&&yt&&yt.ok?((Gt=await yt.json())==null?void 0:Gt.content)??null:null)}catch{ze||(z(""),te(null),I(null),_e(null))}})(),()=>{ze=!0}},[J,F,e,t,d]),b)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"publish-page-loading",children:"Loading publish readiness…"});if(S||!x)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load publish readiness."});const A=x.episodes.find(ze=>!ze.published);if(!A)return f.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"cartoon-publish-page",children:[f.jsx("h2",{className:"text-base font-serif text-foreground",children:"Publish"}),f.jsx("p",{className:"mt-2 text-xs text-green-700","data-testid":"publish-all-done",children:x.episodes.length>0?"All episodes are published to PlotLink. Plan the next episode to continue.":"No episodes yet — write the Genesis (Episode 1) to begin."})]});const q=x.cover==="present",$=QS({cuts:R??[],published:A.published}),be=A.state==="ready",T=A.state==="blocked",D=A.file==="genesis.md",V=!D||!!c&&!!h,k=!!o&&o===A.file,le=H!==null,ne=le?Em({fileName:A.file,fileContent:H??"",storySlug:e,structureContent:re,contentType:"cartoon",episodeTitle:L}):null,de=!!ne&&Ho(ne,A.file),X=!D&&le&&!km({fileContent:H??"",episodeTitle:L}),ue=de||X,ye=D&&le?wm(H??""):null,fe=!!ye&&ye.blockers.length>0,Pe=!D&&le&&R!==null?XS(H??"",R):null,$e=Pe&&Pe.stage==="error"?Pe.issues:[],Ke=be&&V&&(le&&(D||R!==null))&&!ue&&!fe&&!k&&!!a,ft=async()=>{if(!(!Ke||!a)){E(null);try{const ze=D?await j():null;await a(e,A.file,c??"",h??"",!!p,ze)}catch{E("Publish could not be started. Please try again.")}}};return f.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"cartoon-publish-page",children:[f.jsxs("h2",{className:"text-base font-serif text-foreground",children:["Publish ",A.label]}),f.jsx("p",{className:"mt-0.5 text-[11px] text-muted",children:"Publish stays focused on readiness and blockers. Open production details only if you need the full step map."}),f.jsxs("div",{className:"mt-3 max-w-xl","data-testid":"publish-checklist",children:[f.jsx(JS,{checklist:$,markdownReady:be,published:A.published,title:"Episode production",subtitle:q?"Cover and publish readiness are checked below.":"Episode production is tracked here; cover readiness is checked below.",rootTestId:"publish-production-status",detailsTestId:"publish-production-details",stepTestIdPrefix:"publish-step"}),f.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5 text-[10px]",children:[f.jsxs("span",{className:`rounded-full border px-2 py-0.5 ${q?"border-green-700/30 bg-green-700/10 text-green-700":"border-border bg-background text-muted"}`,"data-testid":"publish-cover-status",children:["Cover image: ",q?"Ready":"Missing"]}),D&&f.jsxs("span",{className:`rounded-full border px-2 py-0.5 ${V?"border-green-700/30 bg-green-700/10 text-green-700":"border-border bg-background text-muted"}`,"data-testid":"publish-metadata-status",children:["Story info: ",V?"Ready":"Set genre & language"]})]})]}),ne&&f.jsxs("div",{className:"mt-4 flex flex-col gap-0.5 max-w-xl","data-testid":"publish-title-preview","data-raw":de?"true":"false","data-blocked":ue?"true":"false",children:[f.jsxs("span",{className:"text-[11px] text-foreground",children:[f.jsxs("span",{className:"font-medium",children:[D?"Story title":"Episode title",":"]})," ",f.jsx("span",{className:ue?"text-error font-medium":"text-foreground",children:ne})]}),de?f.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-raw-error",children:["This would publish as a raw filename. ",D?"Add a real “# Title” heading to genesis.md":"Set a title in the cut plan (or add a “# Title” to the episode)"," before publishing."]}):X?f.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-episode-required",children:["“",ne,"” is a generic placeholder, not a reader-facing title, so it can’t be published. Set a real episode title in the cut plan (or add a “# Title” to the episode) — e.g. “Episode 01 — The Couple Coupon” — before publishing."]}):null]}),ye&&f.jsxs("div",{className:"mt-4 flex flex-col gap-1 rounded border border-border bg-surface/50 p-2 max-w-xl","data-testid":"cartoon-genesis-readiness","data-blocked":fe?"true":"false",children:[f.jsx("span",{className:"text-[11px] font-medium text-foreground",children:"Story opening (Prologue)"}),f.jsx("span",{className:"text-[10px] text-muted","data-testid":"genesis-readiness-hint",children:"Genesis is the first thing readers see. Write it as the story opening/prologue, not a synopsis — set up the premise and stakes, then bridge into Episode 01."}),ye.blockers.map((ze,qe)=>f.jsx("span",{className:"text-[10px] text-error","data-testid":"genesis-readiness-blocker",children:ze},`b-${qe}`)),ye.warnings.map((ze,qe)=>f.jsx("span",{className:"text-[10px] text-amber-600","data-testid":"genesis-readiness-warning",children:ze},`w-${qe}`))]}),$e.length>0&&f.jsxs("div",{className:"mt-4 flex flex-col gap-2 rounded-xl border border-error/30 bg-error/5 px-3 py-3 max-w-xl","data-testid":"cartoon-publish-issues",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"rounded-full bg-error px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-white",children:"Before publish"}),f.jsx("span",{className:"text-xs font-medium text-foreground",children:"Finish these workflow steps"})]}),ZS($e).map(ze=>f.jsx("div",{className:"rounded-lg border border-error/15 bg-background/70 px-2.5 py-2","data-testid":`cartoon-issue-group-${ze.key}`,children:f.jsx("span",{className:"text-[11px] font-medium text-foreground",children:ze.title})},ze.key)),f.jsxs("details",{className:"text-[10px] text-muted","data-testid":"cartoon-technical-details",children:[f.jsx("summary",{className:"cursor-pointer select-none",children:"Technical details"}),f.jsx("ul",{className:"mt-1 ml-3 list-disc",children:$e.map((ze,qe)=>f.jsx("li",{className:"font-mono break-words",children:ze},qe))})]})]}),f.jsxs("div",{className:"mt-4 flex flex-col gap-2 max-w-xl",children:[!q&&f.jsx("button",{onClick:s,"data-testid":"publish-add-cover",className:"self-start rounded border border-border px-3 py-1.5 text-xs text-foreground hover:border-accent hover:text-accent transition-colors",children:"Add a cover image (Story Info)"}),D&&!V&&f.jsx("button",{onClick:s,"data-testid":"publish-set-metadata",className:"self-start rounded border border-border px-3 py-1.5 text-xs text-foreground hover:border-accent hover:text-accent transition-colors",children:"Set genre & language (Story Info)"}),!be&&f.jsxs("button",{onClick:()=>i(e,A.file),"data-testid":"publish-open-episode",className:"self-start rounded border border-accent/40 px-3 py-1.5 text-xs text-accent hover:bg-accent/5 transition-colors",children:["Open ",A.label," to finish ",T?"and fix issues":"(letter / export / upload)"]}),f.jsx("button",{onClick:ft,disabled:!Ke,"data-testid":"publish-cta",className:"self-start rounded bg-accent px-3 py-1.5 text-xs font-medium text-white hover:bg-accent-dim disabled:opacity-50 transition-colors",title:Ke?void 0:"Finish the remaining steps above first",children:k?"Publishing…":`Publish ${A.label} to PlotLink`}),be?V?ue||fe?f.jsx("p",{className:"text-[11px] text-error","data-testid":"publish-title-blocked-reason",children:fe?"Fix the Story opening issues above before publishing.":"Set a real reader-facing title above before publishing."}):null:f.jsx("p",{className:"text-[11px] text-amber-700","data-testid":"publish-needs-metadata",children:"Set the genre and language in Story Info before publishing."}):f.jsx("p",{className:"text-[11px] text-muted","data-testid":"publish-blocked-reason",children:T?`Not publishable yet — ${A.summary.toLowerCase()}. Open the episode to fix the flagged cuts.`:`Not ready yet — ${A.summary.toLowerCase()}.`}),M&&f.jsx("p",{className:"text-[11px] text-error","data-testid":"publish-error",children:M})]}),f.jsxs("details",{className:"mt-4 max-w-xl","data-testid":"publish-technical-details",children:[f.jsx("summary",{className:"text-[11px] text-muted cursor-pointer hover:text-foreground",children:"Technical validation details"}),f.jsxs("div",{className:"mt-1 text-[10px] text-muted space-y-0.5",children:[f.jsxs("p",{children:["Episode file: ",f.jsx("span",{className:"font-mono",children:A.file})]}),f.jsxs("p",{children:["State: ",A.state," — ",A.summary]}),f.jsx("p",{children:"Per-cut production (cut plan, clean images, lettering, export, upload) happens in the episode’s cut workspace; open it above to finish any remaining step."})]})]})]})}function UM(e,t){var s;const i=[e.plots,e.chapters].filter(Boolean);for(const a of i){let c=t!=null?a.find(p=>p.plotIndex===t||p.index===t):void 0;if(!c&&a.length===1){const p=a[0];(!(p.plotIndex!=null||p.index!=null)||t==null)&&(c=p)}const h=(s=(c==null?void 0:c.title)??(c==null?void 0:c.name))==null?void 0:s.trim();if(h)return h}}function $M(e){var o;const{fileName:t,detail:i,plotIndex:s}=e;if(!i)return{ok:!0,checked:!1};if(t==="genesis.md"){const c=(o=i.title??i.name)==null?void 0:o.trim();return c?Ho(c,"genesis.md")?{ok:!1,checked:!0,publicTitle:c,reason:`PlotLink indexed the storyline title as “${c}”, a raw filename rather than the reader-facing title.`}:{ok:!0,checked:!0,publicTitle:c}:{ok:!0,checked:!1}}const a=UM(i,s);return a?Ho(a,t)||Pp(a)?{ok:!1,checked:!0,publicTitle:a,reason:`PlotLink indexed the episode title as “${a}”, a generic placeholder rather than a reader-facing episode title.`}:{ok:!0,checked:!0,publicTitle:a}:{ok:!0,checked:!1}}function FM(e){return`${e.reason??"PlotLink indexed a raw/generic public title for this publish."} Published metadata is immutable on-chain and cannot be edited — the next publish must use corrected, reader-facing metadata. (The webtoon pilot stays blocked until a publish indexes a real public title.)`}const o1="plotlink-panel-ratio",qM=.6,ky=300,Pf=224,If=6;function WM(){try{const e=localStorage.getItem(o1);if(e){const t=parseFloat(e);if(t>0&&t<1)return t}}catch{}return qM}function Ey(e,t){if(t<=0)return e;const i=ky/t,s=1-ky/t;return i>=s?.5:Math.min(s,Math.max(i,e))}function GM({token:e,authFetch:t}){const[i,s]=w.useState(null),[a,o]=w.useState(null),[c,h]=w.useState(null),[p,d]=w.useState(null),[x,_]=w.useState(0),[b,v]=w.useState(""),[S,N]=w.useState(null),[M,E]=w.useState(null),[H,z]=w.useState(WM),[R,te]=w.useState([]),[L,I]=w.useState(!1),[re,_e]=w.useState(""),[j,J]=w.useState(""),[F,G]=w.useState(""),[Y,U]=w.useState("English"),[A,q]=w.useState("normal"),[$,be]=w.useState("claude"),[T,D]=w.useState(null),[V,k]=w.useState(!1),[le,ne]=w.useState({}),[de,X]=w.useState({}),[ue,ye]=w.useState(new Set),[fe,Pe]=w.useState(new Set),[$e,Oe]=w.useState({}),[Ke,ft]=w.useState({}),[tt,Fe]=w.useState({}),[ze,qe]=w.useState({}),[Gt,wt]=w.useState({}),[ki,Ei]=w.useState({}),[yt,Li]=w.useState(!1),[oe,se]=w.useState(!0),[Ie,je]=w.useState(null),De=w.useRef(new Map),Ct=w.useRef(new Map),_t=w.useRef(new Map),nt=w.useRef(new Map),xt=w.useRef(new Set),Tt=w.useRef(0),ct=w.useRef(null),ui=w.useRef(null),ei=w.useRef(!1);w.useEffect(()=>{t("/api/wallet").then(he=>he.ok?he.json():null).then(he=>{he!=null&&he.address&&E(he.address)}).catch(()=>{})},[t]),w.useEffect(()=>{t("/api/agent/readiness").then(he=>he.ok?he.json():null).then(he=>{he&&D(he)}).catch(()=>{})},[t]),w.useEffect(()=>{try{localStorage.setItem(o1,String(H))}catch{}},[H]),w.useEffect(()=>{const he=()=>{if(!ui.current)return;const Ae=ui.current.getBoundingClientRect().width-Pf-If;z(Ge=>Ey(Ge,Ae))};return window.addEventListener("resize",he),he(),()=>window.removeEventListener("resize",he)},[]);const Kn=w.useCallback(()=>{_e(""),J(""),G(""),q("normal"),be("claude"),I(!0)},[]),mn=w.useCallback(async(he,Ae,Ge,Dt)=>{const st=re.trim();if(!st)return;const at=he==="cartoon"?"codex":Dt;try{const Bt=await t("/api/stories/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:st,description:j.trim()||void 0,language:Ae,genre:F||void 0,contentType:he,agentMode:Ge,agentProvider:at})});if(!Bt.ok)return;const K=await Bt.json();I(!1),Oe(xe=>({...xe,[K.name]:he})),ft(xe=>({...xe,[K.name]:Ae})),F&&Fe(xe=>({...xe,[K.name]:F})),X(xe=>({...xe,[K.name]:at})),Ge==="bypass"&&ne(xe=>({...xe,[K.name]:!0})),s(K.name),o(null)}catch{}},[t,re,j,F]);w.useEffect(()=>{if(R.length===0)return;const he=setInterval(async()=>{try{const Ae=await t("/api/stories");if(!Ae.ok)return;const Ge=await Ae.json(),Dt=new Set(Ge.stories.filter(st=>st.name!=="_example").map(st=>st.name));for(const st of Dt)if(!xt.current.has(st)&&R.length>0){const at=R[0],Bt=De.current.get(at)||"fiction",K=Ct.current.get(at)||"English",xe=_t.current.get(at)||"normal",ve=nt.current.get(at)||"claude";let Ce=!1;ct.current&&(Ce=await ct.current(at,st,{contentType:Bt,language:K,agentMode:xe,agentProvider:ve}).catch(()=>!1)),Ce&&(te(Be=>Be.slice(1)),De.current.delete(at),Ct.current.delete(at),_t.current.delete(at),nt.current.delete(at),xe==="bypass"&&ne(Be=>{const He={...Be,[st]:!0};return delete He[at],He}),X(Be=>{const He={...Be,[st]:ve};return delete He[at],He}),t(`/api/stories/${st}/metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentType:Bt,language:K,agentMode:xe,agentProvider:ve})}).catch(()=>{})),s(st),o(null)}xt.current=Dt}catch{}},3e3);return()=>clearInterval(he)},[t,R]),w.useEffect(()=>{t("/api/stories").then(he=>{if(he.ok)return he.json()}).then(he=>{he!=null&&he.stories&&(xt.current=new Set(he.stories.filter(Ae=>Ae.name!=="_example").map(Ae=>Ae.name)))}).catch(()=>{})},[t]);const _i=w.useCallback((he,Ae)=>{s(he),o(Ae),h(null)},[]),xi=w.useRef(null),Ht=w.useCallback(async he=>{var Ae,Ge,Dt,st;xi.current=he,s(he),o(null),h(null);try{const at=await t(`/api/stories/${he}`);if(at.ok&&xi.current===he){const Bt=await at.json();if(Bt.contentType==="cartoon")return;const K=Bt.files||[],ve=((Ae=K.map(Ce=>{var Be;return{file:Ce.file,num:(Be=Ce.file.match(/^plot-(\d+)\.md$/))==null?void 0:Be[1]}}).filter(Ce=>Ce.num!=null).sort((Ce,Be)=>parseInt(Be.num)-parseInt(Ce.num))[0])==null?void 0:Ae.file)??((Ge=K.find(Ce=>Ce.file==="genesis.md"))==null?void 0:Ge.file)??((Dt=K.find(Ce=>Ce.file==="structure.md"))==null?void 0:Dt.file)??((st=K[0])==null?void 0:st.file);ve&&xi.current===he&&o(ve)}}catch{}},[t]),ln=w.useCallback(he=>{he.preventDefault(),ei.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const Ae=Dt=>{if(!ei.current||!ui.current)return;const st=ui.current.getBoundingClientRect(),at=st.width-Pf-If,Bt=Dt.clientX-st.left-Pf;z(Ey(Bt/at,at))},Ge=()=>{ei.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",Ae),window.removeEventListener("mouseup",Ge)};window.addEventListener("mousemove",Ae),window.addEventListener("mouseup",Ge)},[]),Ui=w.useCallback(async(he,Ae,Ge,Dt,st,at)=>{var ve;d(Ae),v("Reading file..."),N(null);let Bt=!1,K=null,xe=!1;try{const Ce=await t(`/api/stories/${he}/${Ae}`);if(!Ce.ok)throw new Error("Failed to read file");const Be=await Ce.json(),He=$e[he];let dt=null,Lt=null;if(Ae==="genesis.md")try{const Yt=await t(`/api/stories/${he}/structure.md`);Yt.ok&&(dt=(await Yt.json()).content??null)}catch{}else if(He==="cartoon"&&Ae.match(/^plot-\d+\.md$/))try{const Yt=await t(`/api/stories/${he}/cuts/${Ae.replace(/\.md$/,"")}`);Yt.ok&&(Lt=(await Yt.json()).title??null)}catch{}const gn=Em({fileName:Ae,fileContent:Be.content,storySlug:he,structureContent:dt,contentType:He,episodeTitle:Lt});if(He==="cartoon"&&Ho(gn,Ae))return v(Ae==="genesis.md"?"Add a real “# Title” heading to genesis.md before publishing — it would otherwise publish as a raw filename.":"Set an episode title in the cut plan before publishing — it would otherwise publish as a raw filename."),setTimeout(()=>{d(null),v("")},6e3),!1;if(He==="cartoon"&&Ae.match(/^plot-\d+\.md$/)&&!km({fileContent:Be.content,episodeTitle:Lt}))return v("Set a real episode title in the cut plan (or add a “# Title” to the episode) before publishing — a generic “Episode NN” placeholder can’t be published."),setTimeout(()=>{d(null),v("")},6e3),!1;if(He==="cartoon"&&Ae==="genesis.md"){const Yt=wm(Be.content).blockers;if(Yt.length>0)return v(`Genesis is the reader-facing Story opening — fix it before publishing: ${Yt[0]}`),setTimeout(()=>{d(null),v("")},6e3),!1}let on;if(Ae.match(/^plot-\d+\.md$/)){if(aM(Be)){v("Already published on PlotLink — republishing would create a duplicate chapter. Open it on PlotLink instead (or use Retry Index if it isn't showing yet)."),setTimeout(()=>{d(null),v("")},6e3);return}try{const Yt=await t(`/api/stories/${he}`);if(Yt.ok){const Ut=(await Yt.json()).files.find(Cn=>Cn.file==="genesis.md"&&Cn.storylineId);on=Ut==null?void 0:Ut.storylineId}}catch{}if(!on)return v("Error: Publish genesis first to create the storyline"),setTimeout(()=>{d(null),v("")},3e3),!1}v("Checking wallet balance...");try{const Yt=await t("/api/publish/preflight");if(Yt.ok){const $i=await Yt.json();if(oM($i))return N(cM($i)),d(null),v(""),!1}}catch{}v("Publishing...");const Vn=await t("/api/publish/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:he,fileName:Ae,title:gn,content:Be.content,genre:Ge,language:Dt,isNsfw:st,storylineId:on,...vy($e,he,on)?{contentType:vy($e,he,on)}:{}})});if(!Vn.ok){const Yt=await Vn.json();throw new Error(Yt.error||"Publish failed")}const br=(ve=Vn.body)==null?void 0:ve.getReader(),Xn=new TextDecoder;if(br)for(;;){const{done:Yt,value:$i}=await br.read();if(Yt)break;const Cn=Xn.decode($i).split(`
141
+ `).filter(vr=>vr.startsWith("data: "));for(const vr of Cn)try{const zt=JSON.parse(vr.slice(6));if(zt.step&&v(zt.message||zt.step),zt.step==="done"&&zt.txHash){if(xe=!0,await t(`/api/stories/${he}/${Ae}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:zt.txHash,storylineId:zt.storylineId,plotIndex:zt.plotIndex,contentCid:zt.contentCid,gasCost:zt.gasCost,indexError:zt.indexError,authorAddress:M})}),_(ti=>ti+1),at&&Ae==="genesis.md"&&zt.storylineId){v("Uploading cover...");let ti=null;try{ti=await iM(t,zt.storylineId,at)}catch{}ti||(Bt=!0)}if(He==="cartoon"&&zt.storylineId)try{const ti=Ae!=="genesis.md",kn=`storylineId=${zt.storylineId}`+(ti&&zt.plotIndex!=null?`&plotIndex=${zt.plotIndex}`:""),cn=await t(`/api/publish/public-title?${kn}`);if(cn.ok){const Qt=await cn.json(),Ni=ti?{plots:Qt.plotTitle!=null?[{plotIndex:zt.plotIndex,title:Qt.plotTitle}]:[]}:{title:Qt.storylineTitle},ls=$M({fileName:Ae,detail:Ni,plotIndex:zt.plotIndex});ls.ok||(K=FM(ls))}}catch{}}}catch{}}K&&N(K),v(Bt?"Published, but cover upload failed — set it later from Edit Story.":"Published!")}catch(Ce){const Be=Ce instanceof Error?Ce.message:"Publish failed";v(`Error: ${Be}`)}finally{setTimeout(()=>{d(null),v("")},3e3)}return xe&&!Bt},[t,$e,M]),O=w.useCallback(he=>{he.startsWith("_new_")&&(te(Ae=>Ae.filter(Ge=>Ge!==he)),De.current.delete(he),Ct.current.delete(he),_t.current.delete(he),nt.current.delete(he),ne(Ae=>{if(!(he in Ae))return Ae;const Ge={...Ae};return delete Ge[he],Ge}),X(Ae=>{if(!(he in Ae))return Ae;const Ge={...Ae};return delete Ge[he],Ge}))},[]);w.useEffect(()=>{const he=Ge=>{ye(new Set(Ge.filter(ve=>ve.hasStructure).map(ve=>ve.name))),Pe(new Set(Ge.filter(ve=>ve.hasGenesis).map(ve=>ve.name)));const Dt={},st={},at={},Bt={},K={},xe={};for(const ve of Ge)Dt[ve.name]=ve.contentType||"fiction",st[ve.name]=ve.language,at[ve.name]=ve.genre,Bt[ve.name]=ve.isNsfw,K[ve.name]=ve.agentProvider,ve.title&&(xe[ve.name]=ve.title);Oe(Dt),ft(st),Fe(at),qe(Bt),Ei(K),wt(xe)};t("/api/stories").then(Ge=>Ge.ok?Ge.json():null).then(Ge=>{Ge!=null&&Ge.stories&&he(Ge.stories)}).catch(()=>{});const Ae=setInterval(async()=>{try{const Ge=await t("/api/stories");if(Ge.ok){const Dt=await Ge.json();he(Dt.stories)}}catch{}},5e3);return()=>clearInterval(Ae)},[t]);const we=!!T&&T.codex.installed&&T.codex.imageGeneration==="enabled",Me=!!T&&!we,Te=w.useCallback(async()=>{try{await navigator.clipboard.writeText("codex features enable image_generation"),k(!0),setTimeout(()=>k(!1),2e3)}catch{}},[]),Ze=w.useCallback(async()=>{if(!i||i.startsWith("_new_"))return;const he=i;if((await t(`/api/stories/${he}/metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentType:"cartoon",agentProvider:"codex"})})).ok){Ei(Ge=>({...Ge,[he]:"codex"})),X(Ge=>({...Ge,[he]:"codex"}));try{const Ge=await t("/api/stories");if(Ge.ok){const Dt=await Ge.json();if(Dt!=null&&Dt.stories){const st={};for(const at of Dt.stories)st[at.name]=at.agentProvider;Ei(st)}}}catch{}}},[t,i]),Qe=w.useCallback(he=>{i===he&&(s(null),o(null))},[i]),Nt=i?de[i]??ki[i]:void 0,kt=Lf(i,$e,De.current),Rt=lM(kt,Nt,i),Je=!!i&&kt==="cartoon",hi=c==="story-info"?"story-info":c==="episodes"?"episodes":c==="publish"?"publish":a&&(a==="genesis.md"||/^plot-\d+\.md$/.test(a))?"episodes":"progress",bi=w.useCallback(he=>{if(i)switch(he){case"progress":h(null),o(null);break;case"story-info":h("story-info");break;case"episodes":h("episodes");break;case"publish":h("publish");break}},[i,_i]),vi=w.useCallback((he,Ae)=>{const Ge=i;if(!Ge)return;const Dt=st=>{Tt.current+=1,je({action:st,seq:Tt.current})};switch(he){case"view-progress":h(null),o(null);break;case"publish":h("publish");break;case"open-cuts":case"open-lettering":case"upload":case"refresh-assets":case"generate-markdown":if(!Ae)return;_i(Ge,Ae),Dt(he);break}},[i,_i]),Ot=w.useCallback(he=>{i&&(he.genre!==void 0&&Fe(Ae=>({...Ae,[i]:he.genre||void 0})),he.language!==void 0&&ft(Ae=>({...Ae,[i]:he.language||void 0})),he.isNsfw!==void 0&&qe(Ae=>({...Ae,[i]:he.isNsfw})))},[i]),si=w.useCallback(he=>{Li(he),se(!he)},[]),Zt=yt&&!oe;return f.jsxs("div",{ref:ui,className:"h-[calc(100vh-3.5rem)] flex","data-testid":Zt?"stories-focused-lettering-mode":"stories-default-layout",children:[!Zt&&f.jsx("div",{className:"w-56 border-r border-border flex-shrink-0",children:f.jsx(AC,{authFetch:t,selectedStory:i,selectedFile:a,onSelectFile:_i,onNewStory:Kn,untitledSessions:R})}),!Zt&&f.jsx("div",{className:"min-w-0 border-r border-border",style:{flex:`${H} 0 0`},children:f.jsx(iN,{token:e,storyName:i,authFetch:t,onSelectStory:Ht,onDestroySession:O,onArchiveStory:Qe,confirmedStories:ue,renameRef:ct,bypassStories:le,agentProviders:de,readiness:T,contentType:Lf(i,$e,De.current),needsProviderRepair:Rt,onRepairProvider:Ze})}),!Zt&&f.jsx("div",{onMouseDown:ln,className:"flex-shrink-0 flex items-center justify-center hover:bg-border/50 transition-colors",style:{width:If,cursor:"col-resize",background:"var(--border)"},children:f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),f.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),f.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}})]})}),f.jsxs("div",{className:"min-w-0 min-h-0 flex flex-col",style:Zt?{flex:"1 0 0"}:{flex:`${1-H} 0 0`},children:[!yt&&Je&&i&&f.jsx(zM,{storyTitle:Gt[i]||i,active:hi,onSelect:bi}),f.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:Je&&c==="story-info"&&i?f.jsx(PM,{storyName:i,authFetch:t,onSaved:Ot}):Je&&c==="episodes"&&i?f.jsx(IM,{storyName:i,authFetch:t,onOpenFile:_i}):Je&&c==="publish"&&i?f.jsx(HM,{storyName:i,authFetch:t,onOpenFile:_i,onOpenStoryInfo:()=>h("story-info"),onPublish:Ui,publishingFile:p,genre:tt[i],language:Ke[i],isNsfw:ze[i],refreshKey:x}):i&&!a?f.jsx(CM,{storyName:i,authFetch:t,onOpenFile:_i}):f.jsx(xM,{storyName:i,fileName:a,authFetch:t,onPublish:Ui,publishingFile:p,walletAddress:M,contentType:Lf(i,$e,De.current)||"fiction",language:i?Ke[i]:void 0,genre:i?tt[i]:void 0,isNsfw:i?ze[i]:void 0,hasGenesis:i?fe.has(i):!1,onViewProgress:()=>o(null),onOpenFile:he=>i&&_i(i,he),onViewPublish:()=>h("publish"),focusedLetteringMode:yt,focusedLetteringWorkspaceVisible:oe,onFocusedLetteringModeChange:si,onFocusedLetteringWorkspaceVisibleChange:se,workflowActionRequest:Ie,onWorkflowActionHandled:he=>je(Ae=>(Ae==null?void 0:Ae.seq)===he?null:Ae)})}),!yt&&Je&&i&&!a&&f.jsx("div",{className:"pointer-events-none absolute bottom-4 right-4 z-10 w-[min(22rem,calc(100%-2rem))]","data-testid":"workflow-persistent-next-action",children:f.jsx("div",{className:"pointer-events-auto rounded-xl border border-border/80 bg-background/95 shadow-lg backdrop-blur",children:f.jsx(SM,{storyName:i,fileName:c===null?a:null,authFetch:t,refreshKey:x,onCoachAction:vi,onOpenStoryInfo:()=>h("story-info")})})}),b&&f.jsx("div",{className:"shrink-0 px-3 py-1.5 bg-surface border-t border-border text-xs text-muted",children:b}),S&&f.jsxs("div",{className:"shrink-0 px-3 py-2 bg-error/10 border-t border-error/40 text-xs text-error flex items-start justify-between gap-3","data-testid":"publish-block-error",role:"alert",children:[f.jsx("span",{children:S}),f.jsx("button",{type:"button",onClick:()=>N(null),className:"shrink-0 text-error/70 hover:text-error underline","data-testid":"publish-block-error-dismiss",children:"Dismiss"})]})]}),L&&f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:f.jsxs("div",{className:"bg-surface border border-border rounded-lg shadow-lg p-6 max-w-sm w-full space-y-4",children:[f.jsx("h3",{className:"text-sm font-serif font-medium text-foreground text-center",children:"New Story"}),f.jsxs("label",{className:"block space-y-1",children:[f.jsxs("span",{className:"text-[10px] font-medium text-muted",children:["Title ",f.jsx("span",{className:"text-accent",children:"*"})]}),f.jsx("input",{type:"text",value:re,onChange:he=>_e(he.target.value),placeholder:"e.g. 신의 세포","data-testid":"new-story-title",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none"})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Short description (optional)"}),f.jsx("input",{type:"text",value:j,onChange:he=>J(he.target.value),placeholder:"One line about the story","data-testid":"new-story-description",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none"})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Genre (optional)"}),f.jsxs("select",{value:F,onChange:he=>G(he.target.value),"data-testid":"new-story-genre",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",children:[f.jsx("option",{value:"",children:"— Select later —"}),cl.map(he=>f.jsx("option",{value:he,children:he},he))]})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Language"}),f.jsx("select",{value:Y,onChange:he=>U(he.target.value),className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",children:is.map(he=>f.jsx("option",{value:he,children:he},he))})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Agent mode"}),f.jsxs("select",{value:A,onChange:he=>q(he.target.value),className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"agent-mode-select",children:[f.jsx("option",{value:"normal",children:"Normal (approve each action)"}),f.jsx("option",{value:"bypass",children:"Permissions Bypass (advanced)"})]}),A==="bypass"&&f.jsx("p",{className:"text-[10px] text-amber-700","data-testid":"agent-mode-warning",children:"Less safe: Claude can run actions without per-command approval."})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Provider"}),f.jsxs("select",{value:$,onChange:he=>be(he.target.value),className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"agent-provider-select",children:[f.jsx("option",{value:"claude",children:"🤖 Claude (default)"}),f.jsx("option",{value:"codex",children:"🎨 Codex"})]}),f.jsx("p",{className:"text-[10px] text-muted","data-testid":"agent-provider-helper",children:$==="codex"?"Codex can generate clean cartoon images directly in the terminal.":"Claude prepares image prompts; you generate and upload clean images externally."})]}),f.jsx("p",{className:"text-xs text-muted text-center",children:"Choose a content type to create"}),!re.trim()&&f.jsx("p",{className:"text-[10px] text-amber-700 text-center","data-testid":"new-story-title-required",children:"Enter a title to create your story."}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("button",{onClick:()=>mn("fiction",Y,A,$),disabled:!re.trim(),"data-testid":"create-fiction",className:"border border-border rounded-lg p-4 hover:border-accent hover:bg-accent/5 transition-colors text-center space-y-1 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-border disabled:hover:bg-transparent",children:[f.jsx("p",{className:"text-sm font-serif font-medium text-foreground",children:"Fiction"}),f.jsx("p",{className:"text-[11px] text-muted",children:"Novels, short stories, poetry"})]}),f.jsxs("div",{className:"space-y-1",children:[f.jsxs("button",{onClick:()=>mn("cartoon",Y,A,"codex"),disabled:Me||!re.trim(),"data-testid":"create-cartoon",className:"w-full border border-border rounded-lg p-4 hover:border-accent hover:bg-accent/5 transition-colors text-center space-y-1 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-border disabled:hover:bg-transparent",children:[f.jsx("p",{className:"text-sm font-serif font-medium text-foreground",children:"Cartoon"}),f.jsx("p",{className:"text-[11px] text-muted",children:"Comics, manga, webtoons"}),f.jsx("p",{className:"text-[11px] text-muted","data-testid":"cartoon-codex-note",children:"Cartoon mode requires Codex because the clean-image step needs image generation support."})]}),T&&!T.codex.installed&&f.jsxs("p",{className:"text-[11px] text-amber-700 text-left","data-testid":"cartoon-codex-warning",children:["Codex was not detected. Install the Codex CLI and sign in (e.g."," ",f.jsx("span",{className:"font-mono",children:"npm i -g @openai/codex"})," ","then ",f.jsx("span",{className:"font-mono",children:"codex login"}),") to create cartoons."]}),wu(T)&&f.jsx("p",{className:"text-[11px] text-amber-700 text-left","data-testid":"cartoon-codex-auth-unknown",children:$p}),T&&T.codex.installed&&!wu(T)&&T.codex.imageGeneration!=="enabled"&&f.jsxs("div",{"data-testid":"cartoon-codex-warning",children:[f.jsx("p",{className:"text-[11px] text-amber-700 text-left",children:"Codex is installed but image generation isn't enabled. Enable it, then reopen this dialog:"}),f.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[f.jsx("code",{className:"flex-1 truncate rounded border border-border bg-surface px-1.5 py-1 text-left text-[10px] font-mono text-foreground",children:"codex features enable image_generation"}),f.jsx("button",{type:"button","data-testid":"copy-codex-enable",onClick:Te,className:"rounded border border-border px-2 py-1 text-[10px] text-muted hover:border-accent hover:text-accent transition-colors",children:V?"Copied!":"Copy"})]})]})]})]}),f.jsx("button",{onClick:()=>I(!1),className:"w-full px-3 py-1.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded text-center",children:"Cancel"})]})})]})}function YM({token:e,onComplete:t}){const[i,s]=w.useState(!1),[a,o]=w.useState(null),[c,h]=w.useState(!1),p=async()=>{s(!0),o(null);try{const d=await fetch("/api/wallet/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),x=await d.json();if(!d.ok)throw new Error(x.error||"Wallet creation failed");h(!0)}catch(d){o(d instanceof Error?d.message:"Wallet creation failed")}s(!1)};return w.useEffect(()=>{p()},[]),f.jsxs("div",{className:"mx-auto max-w-sm p-6 text-center",children:[f.jsx("h2",{className:"text-accent mb-1 text-lg font-bold",children:"Wallet Setup"}),f.jsx("p",{className:"text-muted mb-6 text-xs",children:"creating your OWS wallet for on-chain publishing"}),i&&f.jsx("p",{className:"text-accent text-sm",children:"creating wallet..."}),a&&f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"rounded border border-red-700/30 p-3 text-xs text-red-700",children:a}),f.jsx("button",{onClick:p,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"retry"})]}),c&&f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"text-accent text-2xl",children:"✓"}),f.jsx("p",{className:"text-foreground text-sm font-medium",children:"wallet created"}),f.jsx("button",{onClick:t,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"continue"})]})]})}function KM({token:e,onLogout:t}){const[i,s]=w.useState("home"),[a,o]=w.useState(0),[c,h]=w.useState(null),p=w.useCallback(async(d,x)=>fetch(d,{...x,headers:{...(x==null?void 0:x.headers)||{},Authorization:`Bearer ${e}`}}),[e]);return w.useEffect(()=>{fetch("/api/health").then(d=>d.json()).then(d=>{d.version&&h(d.version)}).catch(()=>{})},[]),w.useEffect(()=>{async function d(){try{if(!(await(await p("/api/wallet")).json()).exists){s("wallet-setup");return}const b=await p("/api/stories");if(b.ok){const v=await b.json();o(v.stories.filter(S=>S.name!=="_example").length)}}catch{}}d()},[e]),f.jsxs("div",{className:"flex h-screen flex-col",children:[f.jsxs("header",{className:"border-border flex h-14 items-center justify-between border-b px-4 flex-shrink-0",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("button",{onClick:()=>{i!=="wallet-setup"&&s("home")},className:"flex items-center gap-2 hover:opacity-80",children:f.jsx("span",{className:"text-accent text-sm font-bold tracking-tight",children:"PlotLink OWS"})}),f.jsxs("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:["writer",c?` v${c}`:""]})]}),i!=="wallet-setup"&&f.jsxs("nav",{className:"flex items-center gap-4",children:[f.jsx("button",{onClick:()=>s("stories"),className:`text-xs transition-colors ${i==="stories"?"text-accent":"text-muted hover:text-foreground"}`,children:"stories"}),f.jsx("button",{onClick:()=>s("dashboard"),className:`text-xs transition-colors ${i==="dashboard"?"text-accent":"text-muted hover:text-foreground"}`,children:"dashboard"}),f.jsx("button",{onClick:()=>s("settings"),className:`text-xs transition-colors ${i==="settings"?"text-accent":"text-muted hover:text-foreground"}`,children:"settings"}),f.jsx("button",{onClick:t,className:"text-muted hover:text-foreground text-xs transition-colors",children:"logout"})]})]}),f.jsxs("main",{className:"flex-1 min-h-0",children:[i==="home"&&f.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-8",children:[f.jsxs("div",{className:"text-center space-y-2",children:[f.jsx("h1",{className:"text-2xl font-serif text-foreground",children:"Write. Publish. Earn."}),f.jsx("p",{className:"text-muted text-sm",children:"Claude or Codex helps create your story. You publish it on-chain."})]}),f.jsxs("div",{className:"text-center space-y-3",children:[f.jsx("button",{onClick:()=>s("stories"),className:"bg-accent text-white hover:bg-accent-dim px-6 py-2.5 rounded text-sm font-medium transition-colors",children:"Start Writing"}),a>0&&f.jsxs("p",{className:"text-muted text-xs",children:[a," ",a===1?"story":"stories"," in progress"]})]}),f.jsxs("div",{className:"rounded border border-border p-4 space-y-2 text-xs text-muted",children:[f.jsx("p",{className:"font-medium text-foreground text-sm",children:"How it works"}),f.jsxs("ol",{className:"space-y-1.5 list-decimal list-inside",children:[f.jsxs("li",{children:["Open the ",f.jsx("strong",{children:"Stories"})," tab — your writing agent launches in the terminal"]}),f.jsx("li",{children:"Tell the agent your story idea — it brainstorms, outlines, and writes"}),f.jsx("li",{children:"Review the live preview as the agent creates files"}),f.jsxs("li",{children:["Click ",f.jsx("strong",{children:"Publish"})," to put your story on-chain"]}),f.jsxs("li",{children:["Earn 5% royalties on every trade at ",f.jsx("a",{href:"https://plotlink.xyz",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"plotlink.xyz"})]})]}),f.jsx("p",{className:"text-[11px] text-muted",children:"Fiction defaults to Claude; cartoon mode uses Codex for clean-image generation."})]}),f.jsx("div",{className:"text-center",children:f.jsx("a",{href:"https://github.com/realproject7/plotlink-ows#-wallet-setup",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-accent underline transition-colors",children:"Wallet Setup Guide"})}),f.jsx(Ay,{token:e})]}),i==="stories"&&f.jsx(GM,{token:e,authFetch:p}),i==="dashboard"&&f.jsx(NC,{token:e}),i==="wallet-setup"&&f.jsx(YM,{token:e,onComplete:()=>s("home")}),i==="settings"&&f.jsx(kC,{token:e,onLogout:t})]})]})}function VM(){const[e,t]=w.useState(()=>localStorage.getItem("ows-token")),[i,s]=w.useState(null),[a,o]=w.useState(!0);w.useEffect(()=>{fetch("/api/auth/status").then(d=>d.json()).then(d=>s(d.configured)).catch(()=>s(null))},[]),w.useEffect(()=>{if(!e){o(!1);return}fetch("/api/auth/verify",{headers:{Authorization:`Bearer ${e}`}}).then(d=>{d.ok||(localStorage.removeItem("ows-token"),t(null))}).catch(()=>{localStorage.removeItem("ows-token"),t(null)}).finally(()=>o(!1))},[e]);const c=async d=>{try{const x=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:d})}),_=await x.json();return x.ok?(localStorage.setItem("ows-token",_.token),t(_.token),null):_.error||"Login failed"}catch{return"Cannot connect to server"}},h=async d=>{try{const x=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:d})}),_=await x.json();return x.ok?(localStorage.setItem("ows-token",_.token),t(_.token),s(!0),null):_.error||"Setup failed"}catch{return"Cannot connect to server"}},p=()=>{localStorage.removeItem("ows-token"),t(null)};return a||i===null?f.jsx("div",{className:"flex h-screen items-center justify-center",children:f.jsx("span",{className:"text-muted text-sm",children:"connecting..."})}):i?e?f.jsx(KM,{token:e,onLogout:p}):f.jsx(wC,{onLogin:c}):f.jsx(CC,{onSetup:h})}SC.createRoot(document.getElementById("root")).render(f.jsx(pC.StrictMode,{children:f.jsx(VM,{})}));export{Lp as M,No as a,PS as b,wD as c,K3 as d,Eo as l,vm as s,FS as t,e4 as v};